當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JAccess::getGroupsByUser方法代碼示例

本文整理匯總了PHP中JAccess::getGroupsByUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP JAccess::getGroupsByUser方法的具體用法?PHP JAccess::getGroupsByUser怎麽用?PHP JAccess::getGroupsByUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JAccess的用法示例。


在下文中一共展示了JAccess::getGroupsByUser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 /**
  * Method to save the configuration data.
  *
  * @param   array  $data  An array containing all global config data.
  *
  * @return	boolean  True on success, false on failure.
  *
  * @since	1.6
  */
 public function save($data)
 {
     $app = JFactory::getApplication();
     // Save the rules
     if (isset($data['rules'])) {
         $rules = new JAccessRules($data['rules']);
         // Check that we aren't removing our Super User permission
         // Need to get groups from database, since they might have changed
         $myGroups = JAccess::getGroupsByUser(JFactory::getUser()->get('id'));
         $myRules = $rules->getData();
         $hasSuperAdmin = $myRules['core.admin']->allow($myGroups);
         if (!$hasSuperAdmin) {
             $app->enqueueMessage(JText::_('COM_CONFIG_ERROR_REMOVING_SUPER_ADMIN'), 'error');
             return false;
         }
         $asset = JTable::getInstance('asset');
         if ($asset->loadByName('root.1')) {
             $asset->rules = (string) $rules;
             if (!$asset->check() || !$asset->store()) {
                 $app->enqueueMessage(JText::_('SOME_ERROR_CODE'), 'error');
                 return;
             }
         } else {
             $app->enqueueMessage(JText::_('COM_CONFIG_ERROR_ROOT_ASSET_NOT_FOUND'), 'error');
             return false;
         }
     }
     // Clear cache of com_config component.
     $this->cleanCache('_system', 0);
     $this->cleanCache('_system', 1);
 }
開發者ID:woakes070048,項目名稱:joomlatools-platform,代碼行數:40,代碼來源:application.php

示例2: loadAllowedCategories

	public function loadAllowedCategories($user, &$categories) {
		$user = JFactory::getUser($user);

		$accesslevels = (array) $user->authorisedLevels();
		$groups_r = JAccess::getGroupsByUser($user->id, true);
		$groups = JAccess::getGroupsByUser($user->id, false);

		$catlist = array();
		foreach ( $categories as $category ) {
			// Check if user is a moderator
			if (self::isModerator($user->id, $category->id)) {
				$catlist[$category->id] = $category->id;
			}
			// Check against Joomla access level
			elseif ($category->accesstype == 'joomla') {
				if ( in_array($category->access, $accesslevels) ) {
					$catlist[$category->id] = $category->id;
				}
			}
			// Check against Joomla user group
			elseif ($category->accesstype == 'none') {
				$pub_access = (($category->pub_recurse && in_array($category->pub_access, $groups_r)) || in_array($category->pub_access, $groups));
				$admin_access = (($category->admin_recurse && in_array($category->admin_access, $groups_r)) || in_array($category->admin_access, $groups));

				if (($category->pub_access == 0)
					|| ($category->pub_access == - 1 && $user->id > 0)
					|| ( $pub_access )
					|| ( $admin_access )) {
					$catlist[$category->id] = $category->id;
				}
			}
		}
		return $catlist;
	}
開發者ID:rich20,項目名稱:Kunena,代碼行數:34,代碼來源:access.php

示例3: isAllowed

 function isAllowed($allowedGroups, $groups = null)
 {
     if ($allowedGroups == 'all') {
         return true;
     }
     if ($allowedGroups == 'none') {
         return false;
     }
     $my = JFactory::getUser();
     if (empty($groups) and empty($my->id)) {
         return false;
     }
     if (empty($groups)) {
         if (version_compare(JVERSION, '1.6.0', '<')) {
             $groups = $my->gid;
         } else {
             $groups = JAccess::getGroupsByUser($my->id);
         }
     }
     if (!is_array($allowedGroups)) {
         $allowedGroups = explode(',', trim($allowedGroups, ','));
     }
     if (is_array($groups)) {
         $inter = array_intersect($groups, $allowedGroups);
         if (empty($inter)) {
             return false;
         }
         return true;
     } else {
         return in_array($groups, $allowedGroups);
     }
 }
開發者ID:bizanto,項目名稱:Hooked,代碼行數:32,代碼來源:helper.php

示例4: loadAllowedCategories

 function loadAllowedCategories($user)
 {
     $user = JFactory::getUser($user);
     $accesslevels = (array) $user->authorisedLevels();
     $groups_r = (array) JAccess::getGroupsByUser($user->id, true);
     $groups = (array) JAccess::getGroupsByUser($user->id, false);
     $categories = KunenaCategory::loadCategories();
     $catlist = array();
     foreach ($categories as $category) {
         // Check if user is a moderator
         if (self::isModerator($user->id, $category->id)) {
             $catlist[$category->id] = $category->id;
         } elseif ($category->accesstype == 'joomla.level') {
             if (in_array($category->access, $accesslevels)) {
                 $catlist[$category->id] = $category->id;
             }
         } elseif ($category->accesstype == 'none') {
             $pub_access = in_array($category->pub_access, $category->pub_recurse ? $groups_r : $groups);
             $admin_access = in_array($category->admin_access, $category->admin_recurse ? $groups_r : $groups);
             if ($pub_access || $admin_access) {
                 $catlist[$category->id] = $category->id;
             }
         }
     }
     return $catlist;
 }
開發者ID:rich20,項目名稱:Kunena-1.6,代碼行數:26,代碼來源:access.php

示例5: isCommunityAdmin

 /**
  * Check if a user can administer the community
  */
 public static function isCommunityAdmin($userid = null)
 {
     static $resultArr;
     if (isset($resultArr[$userid])) {
         return $resultArr[$userid];
     }
     //for Joomla 1.6 afterward checking
     $jUser = CFactory::getUser($userid);
     if ($jUser instanceof CUser && method_exists($jUser, 'authorise')) {
         // group 6 = manager, 7 = administrator
         if ($jUser->authorise('core.admin') || in_array('7', JAccess::getGroupsByUser($userid))) {
             $resultArr[$userid] = true;
             return true;
         } else {
             $resultArr[$userid] = false;
             return false;
         }
     }
     //for joomla 1.5
     $my = CFactory::getUser($userid);
     $cacl = CACL::getInstance();
     $usergroup = $cacl->getGroupsByUserId($my->id);
     $admingroups = array(0 => 'Super Administrator', 1 => 'Administrator', 2 => 'Manager', 3 => 'Super Users');
     return in_array($usergroup, $admingroups);
     //return ( $my->usertype == 'Super Administrator' || $my->usertype == 'Administrator' || $my->usertype == 'Manager' );
 }
開發者ID:Jougito,項目名稱:DynWeb,代碼行數:29,代碼來源:owner.php

示例6: display

 public function display($tpl = null)
 {
     $this->doc = JFactory::getDocument();
     $this->app = JFactory::getApplication();
     $this->user = JFactory::getUser();
     $this->params = $this->app->getParams();
     $this->menu = $this->app->getMenu()->getActive();
     // Params
     $this->showDate = $this->app->input->get('showDate', $this->params->get('showDate', 1));
     $this->showIcon = $this->app->input->get('showIcon', $this->params->get('showIcon', 1));
     $this->showDesc = $this->app->input->get('showDesc', $this->params->get('showDesc', 1));
     $this->showAuth = $this->app->input->get('showAuth', $this->params->get('showAuth', 0));
     $this->showLicence = $this->app->input->get('showLicence', $this->params->get('showLicence', 0));
     $this->showSize = $this->app->input->get('showSize', $this->params->get('showSize', 1));
     $this->showMD5 = $this->app->input->get('showMD5', $this->params->get('showMD5', 0));
     $this->showNew = $this->app->input->get('showNew', $this->params->get('showNew', 1));
     $this->newfiledays = $this->params->get('newfiledays', 7);
     $this->show_page_heading = $this->app->input->get('show_page_heading', 1);
     $this->subview = $this->app->input->get('subview', 'list');
     $this->defIcon = $this->params->get('defaulticon', "./media/com_simplefilemanager/images/document.png");
     $this->linkOnEntryTitle = $this->params->get('linkOnTitle', 1);
     $this->enableOrderingSelect = $this->app->input->get('sortFieldSelection', 1);
     // Permissions
     $this->canCreate = $this->user->authorise('core.create', 'com_simplefilemanager');
     $this->canEdit = $this->user->authorise('core.edit', 'com_simplefilemanager');
     $this->canCheckin = $this->user->authorise('core.manage', 'com_simplefilemanager');
     $this->canChange = $this->user->authorise('core.edit.state', 'com_simplefilemanager');
     $this->canDelete = $this->user->authorise('core.delete', 'com_simplefilemanager');
     // View data
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->app->getParams('com_simplefilemanager');
     $this->catID = $this->app->input->get('catid', 0);
     $this->category = JCategories::getInstance('Simplefilemanager')->get($this->catID);
     $this->sortDirection = $this->state->get('list.direction');
     $this->sortColumn = $this->state->get('list.ordering');
     $this->sortFields = $this->getSortFields();
     // CSS and Libraries
     $this->doc->addStyleSheet("./media/com_simplefilemanager/css/site.stylesheet.css");
     foreach ($this->items as $item) {
         $item->icon = $item->icon ?: $this->defIcon;
         $item->canDownload = $item->visibility == 1 || $item->visibility == 3 && $item->reserved_user == $this->user->id || $item->visibility == 2 && $item->user->id || $item->visibility == 5 && $item->author == $this->user->id || $item->visibility == 4 && in_array($item->reserved_group, JAccess::getGroupsByUser($this->user->id));
     }
     if (!$this->catID or !$this->category) {
         JError::raiseError(500);
     }
     // TODO: Check if user can view cateogry else throw a 403 error
     $this->children = $this->category->getChildren();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
     }
     $this->_prepareDocument();
     parent::display($tpl);
     echo JText::_("COM_SIMPLEFILEMANAGER_CREDITS");
 }
開發者ID:gmansillo,項目名稱:simplefilemanager,代碼行數:57,代碼來源:view.html.php

示例7: getGroups

 /**
  * Returns the groups the user is part of
  *
  * @return array An array of group id's
  */
 public function getGroups()
 {
     $data = $this->getData();
     $groups = KObjectConfig::unbox($data->groups);
     if (empty($groups)) {
         $this->getSession()->set('user.groups', JAccess::getGroupsByUser($this->getId()));
     }
     return parent::getGroups();
 }
開發者ID:daodaoliang,項目名稱:nooku-framework,代碼行數:14,代碼來源:user.php

示例8: allowEdit

 /**
  * Check user access
  * 	 	 
  */
 public function allowEdit($userid)
 {
     // This condition is already available in StreamAccess class
     // added here to eliminate dependency, in case StreamAccess has the condition removed
     $groupIds = JAccess::getGroupsByUser($userid);
     if (in_array(8, $groupIds) || in_array(7, $groupIds)) {
         return true;
     }
     return false;
 }
開發者ID:ErickLopez76,項目名稱:offiria,代碼行數:14,代碼來源:access.php

示例9: getOptions

 /**
  * Method to get the options to populate list
  *
  * @return  array  The field option objects.
  *
  * @since   3.2
  */
 protected function getOptions()
 {
     $showEmpty = $this->element['showempty'];
     // Hash for caching
     $hash = md5($this->element);
     if (!isset(static::$options[$hash])) {
         static::$options[$hash] = parent::getOptions();
         $options = array();
         $db = JFactory::getDbo();
         $user = JFactory::getUser();
         $canDo = ImcHelper::getActions();
         $canShowAllIssues = $canDo->get('imc.showall.issues');
         if ($canShowAllIssues) {
             $query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__usergroups as a')->where('a.id > 9')->join('LEFT', '#__usergroups  AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC');
         } else {
             //get user groups higher than 9
             $usergroups = JAccess::getGroupsByUser($user->id, false);
             for ($i = 0; $i < count($usergroups); $i++) {
                 if ($usergroups[$i] <= 9) {
                     unset($usergroups[$i]);
                 }
             }
             $ids = implode(',', $usergroups);
             //get lft, rgt for these groups
             $where = array();
             $query = $db->getQuery(true)->select('a.id, a.lft, a.rgt')->from('#__usergroups as a')->where('a.id IN (' . $ids . ')');
             $db->setQuery($query);
             if ($grps = $db->loadAssocList()) {
                 foreach ($grps as $grp) {
                     $where[] = '(a.lft >= ' . $grp['lft'] . ' AND a.rgt <= ' . $grp['rgt'] . ')';
                     $where[] = ' OR ';
                 }
                 array_pop($where);
             } else {
                 $where[] = "1=1";
             }
             $query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__usergroups as a')->where('a.id > 9')->where(implode("\n", $where))->join('LEFT', '#__usergroups  AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC');
         }
         $db->setQuery($query);
         if ($options = $db->loadObjectList()) {
             if ($showEmpty) {
                 $empty = new stdClass();
                 $empty->value = '0';
                 $empty->text = '';
                 $empty->level = 1;
                 array_unshift($options, $empty);
             }
             foreach ($options as &$option) {
                 $option->text = str_repeat('- ', $option->level) . $option->text;
             }
             static::$options[$hash] = array_merge(static::$options[$hash], $options);
         }
     }
     return static::$options[$hash];
 }
開發者ID:Ricardolau,項目名稱:imc,代碼行數:62,代碼來源:subgrouplist.php

示例10: getUserAccessLevel

 public static function getUserAccessLevel($board_id)
 {
     $userData = JFactory::getUser();
     $userGroups = JAccess::getGroupsByUser($userData->id);
     $boardAccessList = comQuipForumHelper::getboardAccessListDB($userGroups);
     $highestAccessLevel = 0;
     foreach ((array) $userGroups as $kgroup => $vgroup) {
         if (@$boardAccessList[$board_id][$vgroup] > $highestAccessLevel) {
             $highestAccessLevel = $boardAccessList[$board_id][$vgroup];
         }
     }
     return $highestAccessLevel;
 }
開發者ID:rgeraldporter,項目名稱:com_quipforum,代碼行數:13,代碼來源:helper.php

示例11: calculate

 public function calculate()
 {
     $variant = $this->get('variant');
     $quantity = $this->get('quantity');
     $date = $this->get('date');
     $group_id = $this->get('group_id');
     $pricing = new JObject();
     //set the base price
     $pricing->base_price = $variant->price;
     $pricing->price = $variant->price;
     $pricing->calculator = 'standard';
     //see if we have advanced pricing for this product / variant
     $model = F0FModel::getTmpInstance('ProductPrices', 'J2StoreModel');
     J2Store::plugin()->event('BeforeGetPrice', array(&$pricing, &$model));
     $model->setState('variant_id', $variant->j2store_variant_id);
     //where quantity_from < $quantity
     $model->setState('filter_quantity', $quantity);
     $tz = JFactory::getConfig()->get('offset');
     // does date even matter?
     $nullDate = JFactory::getDBO()->getNullDate();
     if (empty($date) || $date == $nullDate) {
         $date = JFactory::getDate('now', $tz)->toSql(true);
     }
     //where date_from <= $date
     //where date_to >= $date OR date_to == nullDate
     $model->setState('filter_date', $date);
     // does group_id?
     $user = JFactory::getUser();
     if (empty($group_id)) {
         $group_id = implode(',', JAccess::getGroupsByUser($user->id));
     }
     //if(empty($group_id)) $group_id = implode(',', JAccess::getAuthorisedViewLevels($user->id));
     $model->setState('group_id', $group_id);
     // set the ordering so the most discounted item is at the top of the list
     $model->setState('orderby', 'quantity_from');
     $model->setState('direction', 'DESC');
     try {
         $price = $model->getItem();
         //var_dump($price);
     } catch (Exception $e) {
         $price = new stdClass();
     }
     if (isset($price->price)) {
         $pricing->special_price = $price->price;
         //this is going to be the sale price
         $pricing->price = $price->price;
         $pricing->is_discount_pricing_available = $pricing->base_price > $pricing->price ? true : false;
     }
     return $pricing;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:50,代碼來源:standardcalculator.php

示例12: fetch

 /**
  * Fetch the user for the given user identifier from the backend
  *
  * @param string $identifier A unique user identifier, (i.e a username or email address)
  * @return KUserInterface|null Returns a UserInterface object or NULL if the user could not be found.
  */
 public function fetch($identifier)
 {
     $table = JUser::getTable();
     if ($table->load($identifier)) {
         $user = JUser::getInstance(0);
         $user->setProperties($table->getProperties());
         $params = new JRegistry();
         $params->loadString($table->params);
         $user->setParameters($params);
         $data = array('id' => $user->id, 'email' => $user->email, 'name' => $user->name, 'username' => $user->username, 'password' => $user->password, 'salt' => '', 'groups' => JAccess::getGroupsByUser($user->id), 'roles' => JAccess::getAuthorisedViewLevels($user->id), 'authentic' => !$user->guest, 'enabled' => !$user->block, 'expired' => (bool) $user->activation, 'attributes' => $user->getParameters()->toArray());
         $user = $this->create($data);
     } else {
         $user = null;
     }
     return $user;
 }
開發者ID:daodaoliang,項目名稱:nooku-framework,代碼行數:22,代碼來源:provider.php

示例13: checkContenuto4Utente

    public static function checkContenuto4Utente($userid, $contenutoid)
    {
        $groups = JAccess::getGroupsByUser($userid, true);
        $db = JFactory::getDBO();
        $query = '  
		SELECT count(*) as count
                FROM #__gg_contenuti_acl
                WHERE id_contenuto=' . $contenutoid . ' 
                and id_group in (' . implode(",", $groups) . ')';
        FB::LOG($query, "query checkContenuto4Utente");
        // FB::LOG($groups, "groups getTOTContenuti");
        $db->setQuery($query);
        $totgroups = $db->loadAssoc();
        FB::LOG($totgroups, "risultato checkContenuto4Utente");
        return $totgroups['count'];
    }
開發者ID:GGallery,項目名稱:MDWEBTV-new,代碼行數:16,代碼來源:gglms.php

示例14: allowedUserGroups

 /**
  * Checks the user group of the user and returns true if the user belongs to a selected group
  *
  * @return bool
  */
 private function allowedUserGroups()
 {
     $user = JFactory::getUser();
     $allowed_user_groups = false;
     $filter_groups = (array) $this->params->get('filter_groups', 8);
     $user_group = JAccess::getGroupsByUser($user->id);
     foreach ($user_group as $value) {
         foreach ($filter_groups as $filter_groups_value) {
             if ($value == $filter_groups_value) {
                 $allowed_user_groups = true;
                 break;
             }
         }
     }
     return $allowed_user_groups;
 }
開發者ID:vstorm83,項目名稱:propertease,代碼行數:21,代碼來源:easyerrorreporting.php

示例15: genAccessSQL

 /**
  * generate contribution access sql that used with blogs
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function genAccessSQL($contributorType, $columnPrefix, $options = array())
 {
     $db = EB::db();
     $my = JFactory::getUser();
     $gid = array();
     if ($my->id == 0) {
         $gid = JAccess::getGroupsByUser(0, false);
     } else {
         $gid = JAccess::getGroupsByUser($my->id, false);
     }
     $gids = '';
     if (count($gid) > 0) {
         foreach ($gid as $id) {
             $gids .= empty($gids) ? $id : ',' . $id;
         }
     }
     $sourceSQL = '';
     if ($contributorType == EASYBLOG_POST_SOURCE_TEAM) {
         $sourceSQL = self::getTeamBlogSQL($columnPrefix, $gids, $options);
     } else {
         if ($contributorType == EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP) {
             $sourceSQL = self::getJomSocialGroupSQL($columnPrefix, $options);
         } else {
             if ($contributorType == EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT) {
                 $sourceSQL = self::getJomSocialEventSQL($columnPrefix, $options);
             } else {
                 if ($contributorType == EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP) {
                     $sourceSQL = self::getEasySocialGroupSQL($columnPrefix, $options);
                 } else {
                     if ($contributorType == EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT) {
                         $sourceSQL = self::getEasySocialEventSQL($columnPrefix, $options);
                     }
                 }
             }
         }
     }
     $concate = isset($options['concateOperator']) ? $options['concateOperator'] : 'OR';
     $sql = '';
     if ($sourceSQL) {
         //starting bracket
         $sql = " {$concate} (";
         $sql .= $sourceSQL;
         //ending bracket
         $sql .= ")";
     }
     return $sql;
 }
開發者ID:knigherrant,項目名稱:decopatio,代碼行數:55,代碼來源:contributor.php


注:本文中的JAccess::getGroupsByUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。