当前位置: 首页>>代码示例>>PHP>>正文


PHP Current_User::getUnrestrictedLevels方法代码示例

本文整理汇总了PHP中Current_User::getUnrestrictedLevels方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::getUnrestrictedLevels方法的具体用法?PHP Current_User::getUnrestrictedLevels怎么用?PHP Current_User::getUnrestrictedLevels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Current_User的用法示例。


在下文中一共展示了Current_User::getUnrestrictedLevels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: restrictView

 /**
  * added limitations to a select query to only pull rows that
  * the user is allowed to see. This function does does not work alone.
  * it requires a database object to already be started.
  *
  * The user module MUST be active for this function to work.
  * This Key function cannot be called without it.
  *
  * If the user is a deity or an unrestricted user, no change will be made
  * to your db object.
  *
  */
 public static function restrictView($db, $module = null, $check_dates = true, $source_table = null)
 {
     $now = time();
     if (empty($source_table)) {
         $source_table = $db->tables[0];
     }
     if ($source_table == 'phpws_key') {
         if (!isset($db->tables[1])) {
             return PHPWS_Error::get(KEY_RESTRICT_NO_TABLE, 'core', 'Key::restrictView');
         }
         $source_table = $db->tables[1];
         $key_table = true;
     } else {
         $key_table = false;
     }
     if (!$key_table) {
         $db->addJoin('left', $source_table, 'phpws_key', 'key_id', 'id');
     } else {
         $db->addJoin('left', 'phpws_key', $source_table, 'id', 'key_id');
     }
     $db->addWhere("{$source_table}.key_id", '0', null, null, 'base');
     $db->addWhere('phpws_key.active', 1, null, null, 'active');
     $db->groupIn('active', 'base');
     $db->setGroupConj('active', 'or');
     if (Current_User::isDeity() || isset($module) && Current_User::isUnrestricted($module)) {
         return;
     }
     if ($check_dates) {
         $db->addWhere('phpws_key.show_after', $now, '<', null, 'active');
         $db->addWhere('phpws_key.hide_after', $now, '>', null, 'active');
     }
     if (!Current_User::isLogged()) {
         $db->addWhere('phpws_key.restricted', 0, null, 'and', 'active');
         return;
     } else {
         $groups = Current_User::getGroups();
         if (empty($groups)) {
             return;
         }
         $db->addJoin('left', 'phpws_key', 'phpws_key_view', 'id', 'key_id');
         // if key only has a level 1 restriction, a logged user can view it
         $db->addWhere('phpws_key.restricted', KEY_LOGGED_RESTRICTED, '<=', null, 'restrict_1');
         $db->setGroupConj('restrict_1', 'and');
         // at level 2, the user must be in a group given view permissions
         $db->addWhere('phpws_key.restricted', KEY_GROUP_RESTRICTED, '=', null, 'restrict_2');
         $db->addWhere('phpws_key_view.group_id', $groups, 'in', null, 'restrict_2');
         $db->setGroupConj('restrict_2', 'or');
         if (empty($module)) {
             $levels = Current_User::getUnrestrictedLevels();
             if (!empty($levels)) {
                 $db->addWhere('phpws_key.module', $levels, null, null, 'permission');
                 $db->groupIn('permission', 'restrict_2');
             }
         }
         $db->groupIn('restrict_1', 'base');
         $db->groupIn('restrict_2', 'restrict_1');
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:70,代码来源:Key.php


注:本文中的Current_User::getUnrestrictedLevels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。