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


PHP JUserHelper::getUserGroups方法代码示例

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


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

示例1: display

 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->params = $app->getParams();
     /* Default Page fallback*/
     $active = $app->getMenu()->getActive();
     if (NULL == $active) {
         $this->params->merge($app->getMenu()->getDefault()->params);
         $active = $app->getMenu()->getDefault();
     }
     $this->currentItemid = $active->id;
     $entriesPerPage = $this->params->get('max_events_per_page', 12);
     $model = $this->getModel('events');
     $eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel');
     $recursive = $this->params->get('show_items_per_category_recursive', false);
     $user = JFactory::getUser();
     $usergroups = JUserHelper::getUserGroups($user->id);
     $entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->params->get('catid', null), $recursive);
     $this->pageNav = $model->getPagination();
     $this->entries = $entries;
     $this->eventModel = $eventModel;
     $this->_prepareDocument();
     parent::display($tpl);
 }
开发者ID:sansandeep143,项目名称:av,代码行数:27,代码来源:view.html.php

示例2: isAdmin

 /**
  * the user is admin?
  * @param JUser $user
  * @return boolean      
  */
 public function isAdmin($user = false)
 {
     jimport('joomla.user.helper');
     if ($user == false) {
         $user = JFactory::getUser();
     }
     $result = false;
     if ($user) {
         $groups = JUserHelper::getUserGroups($user->id);
         //DBG foreach($groups as $fn => $fv) echo '<p>'.$fn.'='.$fv.'</p>'; exit();
         $admin_groups = array();
         //put all the groups that you consider to be admins
         $admin_groups[] = "Super Users";
         $admin_groups[] = "Administrator";
         $admin_groups[] = "Manager";
         $admin_groups[] = "8";
         $admin_groups[] = "7";
         $admin_groups[] = "6";
         foreach ($admin_groups as $temp) {
             if (!empty($groups[$temp])) {
                 $result = true;
             }
         }
     }
     return $result;
 }
开发者ID:madcsaba,项目名称:li-de,代码行数:31,代码来源:temakorok.php

示例3: display

 function display($tpl = null)
 {
     $option = JRequest::getCMD('option');
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($user->get('guest')) {
         // Redirect to login
         $uri = JFactory::getURI();
         $mainframe->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), null);
         return;
     } else {
         $groups = JUserHelper::getUserGroups($user->get('id'));
         if (!in_array(4, $groups)) {
             JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return;
         }
     }
     $document =& JFactory::getDocument();
     //$document->addScript( '/media/system/js/viewutils.js');
     //$document->addScript('/media/system/js/mootools1.js');
     //$document->addStyleSheet('/media/system/css/global.css');
     //$document->addStyleSheet('/media/system/css/content.css');
     $document->addStylesheet('/media/system/css/ZoneStyle.css');
     $helper = new comZonalesHelper();
     $this->assignRef('template', $mainframe->getTemplate());
     $this->assignRef('user', $user);
     $host = 'localhost';
     $this->assignRef('tomcat_host', $host);
     $port = '38080';
     $this->assignRef('tomcat_port', $port);
     $this->assignRef('zonal_id', ucwords(str_replace("_", "+", $helper->getZonalActual())));
     parent::display($tpl);
 }
开发者ID:BGCX261,项目名称:zonales-svn-to-git,代码行数:33,代码来源:view.html.php

示例4: isAdmin

 /**
  * Checks if the current user, or userID passed to function is an administrator
  *
  * @param INT
  */
 public static function isAdmin($userid = NULL, $admin_groups = array("7", "8"), $group_ids_passed = true)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         jimport('joomla.user.helper');
         $user = JFactory::getUser($userid);
         $groups = JUserHelper::getUserGroups($user->id);
         //var_dump($admin_groups);
         if ($group_ids_passed) {
             foreach ($groups as $temp) {
                 if (in_array($temp, $admin_groups)) {
                     return true;
                 }
             }
         } else {
             foreach ($admin_groups as $temp) {
                 if (!empty($groups[$temp])) {
                     return true;
                 }
             }
         }
         return false;
     } else {
         // Joomla! 1.5 code here
         jimport('joomla.user.helper');
         $user = JFactory::getUser($userid);
         // Note: in practice I'd use $user->gid here
         if (in_array($user->usertype, array("Super Administrator", "Administrator"))) {
             return true;
         } else {
             return false;
         }
     }
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:39,代码来源:acl.php

示例5: onAfterInitialise

 /**
  * Disables creating new admins or updating new ones
  */
 public function onAfterInitialise()
 {
     $input = $this->input;
     $option = $input->getCmd('option', '');
     $task = $input->getCmd('task', '');
     $gid = $input->getInt('gid', 0);
     if ($option != 'com_users' && $option != 'com_admin') {
         return;
     }
     $jform = $this->input->get('jform', array(), 'array');
     $allowedTasks = array('save', 'apply', 'user.apply', 'user.save', 'user.save2new', 'profile.apply', 'profile.save');
     if (!in_array($task, $allowedTasks)) {
         return;
     }
     // Not editing, just core devs using the same task throughout the component, dammit
     if (empty($jform)) {
         return;
     }
     $groups = array();
     if (isset($jform['groups'])) {
         $groups = $jform['groups'];
     }
     $user = JFactory::getUser((int) $jform['id']);
     // Sometimes $user->groups is null... let's be 100% sure that we loaded all the groups of the user
     if (empty($user->groups)) {
         $user->groups = JUserHelper::getUserGroups($user->id);
     }
     if (!empty($user->groups)) {
         foreach ($user->groups as $title => $gid) {
             if (!in_array($gid, $groups)) {
                 $groups[] = $gid;
             }
         }
     }
     $isAdmin = false;
     if (!empty($groups)) {
         foreach ($groups as $group) {
             // First try to see if the group has explicit backend login privileges
             $backend = JAccess::checkGroup($group, 'core.login.admin', 1);
             // If not, is it a Super Admin (ergo inherited privileges)?
             if (is_null($backend)) {
                 $backend = JAccess::checkGroup($group, 'core.admin', 1);
             }
             $isAdmin |= $backend;
         }
     }
     if ($isAdmin) {
         $jlang = JFactory::getLanguage();
         $jlang->load('joomla', JPATH_ROOT, 'en-GB', true);
         $jlang->load('joomla', JPATH_ROOT, $jlang->getDefault(), true);
         $jlang->load('joomla', JPATH_ROOT, null, true);
         if (version_compare(JVERSION, '3.0', 'ge')) {
             throw new Exception(JText::_('JGLOBAL_AUTH_ACCESS_DENIED'), '403');
         } else {
             JError::raiseError(403, JText::_('JGLOBAL_AUTH_ACCESS_DENIED'));
         }
     }
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:61,代码来源:nonewadmins.php

示例6: __construct

 function __construct($config, $sitemap)
 {
     jimport('joomla.utilities.date');
     jimport('joomla.user.helper');
     $user = JFactory::getUser();
     $groups = array_keys(JUserHelper::getUserGroups($user->get('id')));
     $date = new JDate();
     $this->userLevels = (array) $user->getAuthorisedViewLevels();
     // Deprecated: should use userLevels from now on
     // $this->gid	= $user->gid;
     $this->now = $date->toUnix();
     $this->config = $config;
     $this->sitemap = $sitemap;
     $this->isNews = false;
     $this->count = 0;
     $this->canEdit = false;
 }
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:17,代码来源:displayer.php

示例7: isAdmin

 /**
  * the user is admin?
  * @param JUser $user
  * @return boolean      
  */
 protected function isAdmin($user)
 {
     jimport('joomla.user.helper');
     $result = false;
     if ($user) {
         $groups = JUserHelper::getUserGroups($user->id);
         $admin_groups = array();
         //put all the groups that you consider to be admins
         $admin_groups[] = "Super Users";
         $admin_groups[] = "Administrator";
         foreach ($admin_groups as $temp) {
             if (!empty($groups[$temp])) {
                 $result = true;
             }
         }
     }
     return $result;
 }
开发者ID:madcsaba,项目名称:li-de,代码行数:23,代码来源:defview.php

示例8: onUserAfterSave

 function onUserAfterSave($user, $isnew, $success, $msg)
 {
     jimport('joomla.user.helper');
     //if 'latitude' key exists, event triggered from within JomSocial
     if (array_key_exists('latitude', $user)) {
         return;
     }
     $app = JFactory::getApplication();
     // Instantiate JomSocial
     require_once JPATH_ROOT . '/administrator/components/com_community/defines.php';
     require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
     // Get sync mappings
     $mappings = self::getJomSocialGroupSyncMappings();
     if (empty($mappings)) {
         return;
     }
     // create JomSocial objects needed to manage group members
     $group =& JTable::getInstance('Group', 'CTable');
     $model = CFactory::getModel('Groups');
     // create
     $data = new stdClass();
     $data->memberid = $user['id'];
     $data->approved = 1;
     $data->permissions = 0;
     //get the users ACL groups; retrieve using helper if not set in user object
     if (empty($user['groups'])) {
         $jUserGroups = JUserHelper::getUserGroups($user['id']);
     } else {
         $jUserGroups = $user['groups'];
     }
     // Cycle through mappings and add to/remove from JomSocial groups
     foreach ($mappings as $mapping) {
         $data->groupid = $mapping['jsgroup_id'];
         if (in_array($mapping['jgroup_id'], $jUserGroups)) {
             // Add user to group members table
             if (!$model->isMember($data->memberid, $data->groupid)) {
                 $addResult = $group->addMember($data);
             }
         } else {
             $model->removeMember($data);
         }
     }
     return;
 }
开发者ID:kishoreweblabs,项目名称:JomSocial-Group-Sync,代码行数:44,代码来源:jomsocialgroupsyncsystem.php

示例9: editElement

 public function editElement()
 {
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     jimport('joomla.utilities.date');
     jimport('joomla.user.helper');
     $user = JFactory::getUser();
     $groups = array_keys(JUserHelper::getUserGroups($user->get('id')));
     $result = new JRegistry('_default');
     $sitemapId = JREquest::getInt('id');
     if (!$user->authorise('core.edit', 'com_xmap.sitemap.' . $sitemapId)) {
         $result->setValue('result', 'KO');
         $result->setValue('message', 'You are not authorized to perform this action!');
     } else {
         $model = $this->getModel('sitemap');
         if ($model->getItem()) {
             $action = JRequest::getCmd('action', '');
             $uid = JRequest::getCmd('uid', '');
             $itemid = JRequest::getInt('itemid', '');
             switch ($action) {
                 case 'toggleElement':
                     if ($uid && $itemid) {
                         $state = $model->toggleItem($uid, $itemid);
                     }
                     break;
                 case 'changeProperty':
                     $uid = JRequest::getCmd('uid', '');
                     $property = JRequest::getCmd('property', '');
                     $value = JRequest::getCmd('value', '');
                     if ($uid && $itemid && $uid && $property) {
                         $state = $model->chageItemPropery($uid, $itemid, 'xml', $property, $value);
                     }
                     break;
             }
         }
         $result->set('result', 'OK');
         $result->set('state', $state);
         $result->set('message', '');
     }
     echo $result->toString();
 }
开发者ID:01J,项目名称:topm,代码行数:40,代码来源:ajax.json.php

示例10: defined

 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$user = User::getInstance();
$unknown = true;
$name = '';
$usertype = Lang::txt('COM_SUPPORT_UNKNOWN');
$notify = array();
if ($this->row->get('login')) {
    if ($this->row->get('name')) {
        jimport('joomla.user.helper');
        $usertype = implode(', ', JUserHelper::getUserGroups($this->row->submitter()->get('id')));
        $name = '<a rel="profile" href="' . Route::url('index.php?option=com_members&task=edit&id=' . $this->row->submitter()->get('id')) . '">' . $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')</a>';
        $unknown = false;
        $notify[] = $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')';
    }
}
if (!$name) {
    if ($this->row->get('name')) {
        $name = $this->escape($this->row->get('name')) . ' (' . $this->escape($this->row->get('email')) . ')';
    } else {
        $name = $this->escape($this->row->get('email'));
    }
    $notify[] = $name;
}
if ($this->row->isOwned()) {
    if ($this->row->owner()->get('name')) {
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:31,代码来源:edit.php

示例11: getAssignedGroups

 public function getAssignedGroups($userId = null)
 {
     $userId = !empty($userId) ? $userId : (int) $this->getState('socialconnect.id');
     if (empty($userId)) {
         $result = array();
         $config = JComponentHelper::getParams('com_users');
         if ($groupId = $config->get('new_usertype')) {
             $result[] = $groupId;
         }
     } else {
         $result = JUserHelper::getUserGroups($userId);
     }
     return $result;
 }
开发者ID:juanferden,项目名称:adoperp,代码行数:14,代码来源:socialconnect.php

示例12: defined

 * @package   hubzero-cms
 * @author    Shawn Rice <zooley@purdue.edu>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$this->css()->css('jquery.ui.css', 'system')->js('jquery.timepicker.js', 'system')->js();
$status = $this->row->status('text');
$unknown = 1;
//$name     = Lang::txt('COM_SUPPORT_UNKNOWN');
$usertype = Lang::txt('COM_SUPPORT_UNKNOWN');
if ($this->row->get('login')) {
    $submitter = $this->row->submitter();
    if ($submitter->get('id')) {
        $usertype = implode(', ', \JUserHelper::getUserGroups($submitter->get('id')));
        $name = '<a rel="profile" href="' . Route::url('index.php?option=com_members&id=' . $submitter->get('id')) . '">' . $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')</a>';
        $unknown = 0;
    } else {
        $name = '<a rel="email" href="mailto:' . $this->row->get('email') . '">';
        $name .= $this->row->get('login') ? $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')' : $this->escape(stripslashes($this->row->get('name')));
        $name .= '</a>';
    }
} else {
    $name = '<a rel="email" href="mailto:' . $this->row->get('email') . '">' . $this->escape(stripslashes($this->row->get('name'))) . '</a>';
}
$prev = null;
$next = null;
$sq = new \Components\Support\Tables\Query($this->database);
$sq->load($this->filters['show']);
if ($sq->conditions) {
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:31,代码来源:ticket.php

示例13: getRootDir

 /**
  * Return the full user directory path. Create if required
  *
  * @param string  The base path
  * @access public
  * @return Full path to folder
  */
 public function getRootDir()
 {
     static $root;
     if (!isset($root)) {
         $user = JFactory::getUser();
         $wf = WFEditor::getInstance();
         $profile = $wf->getProfile();
         // Get base directory as shared parameter
         $root = $this->get('dir', '');
         // Remove whitespace
         $root = trim($root);
         if (!empty($root)) {
             // Convert slashes / Strip double slashes
             $root = preg_replace('/[\\\\]+/', '/', $root);
             // Remove first leading slash
             $root = ltrim($root, '/');
             // Force default directory if base param starts with a variable or a . eg $id
             if (preg_match('/[\\.\\$]/', $root[0])) {
                 $root = 'images';
             }
             jimport('joomla.user.helper');
             // Joomla! 1.6+
             if (method_exists('JUserHelper', 'getUserGroups')) {
                 $groups = JUserHelper::getUserGroups($user->id);
                 // get the first group
                 $group_id = array_shift(array_keys($groups));
                 // Joomla! 2.5?
                 if (is_int($group_id)) {
                     // usergroup table
                     $group = JTable::getInstance('Usergroup');
                     $group->load($group_id);
                     // usertype
                     $usertype = $group->title;
                 } else {
                     $usertype = $group_id;
                 }
             } else {
                 $usertype = $user->usertype;
             }
             // Replace any path variables
             $pattern = array('/\\$id/', '/\\$username/', '/\\$user(group|type)/', '/\\$(group|profile)/', '/\\$day/', '/\\$month/', '/\\$year/');
             $replace = array($user->id, $user->username, $usertype, $profile->name, date('d'), date('m'), date('Y'));
             $root = preg_replace($pattern, $replace, $root);
             // split into path parts to preserve /
             $parts = explode('/', $root);
             $textcase = $wf->getParam('editor.websafe_textcase');
             if (!empty($textcase)) {
                 $textcase = array_shift($textcase);
             }
             // clean path parts
             $parts = WFUtility::makeSafe($parts, $wf->getParam('editor.websafe_mode', 'utf-8'), $wf->getParam('editor.websafe_allow_spaces', 0), $textcase);
             //join path parts
             $root = implode('/', $parts);
         }
     }
     return $root;
 }
开发者ID:creativeprogramming,项目名称:jce,代码行数:64,代码来源:filesystem.php

示例14: getUserGroups

 /**
  * Helper wrapper method for getUserGroups
  *
  * @param   integer  $userId  The id of the user.
  *
  * @return  array    List of groups
  *
  * @see     JUserHelper::addUserToGroup()
  * @since   3.4
  */
 public function getUserGroups($userId)
 {
     return JUserHelper::getUserGroups($userId);
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:14,代码来源:helper.php

示例15: getAssignedGroups

 /**
  * Gets the groups this object is assigned to
  *
  * @param   integer  $userId  The user ID to retrieve the groups for
  *
  * @return  array  An array of assigned groups
  *
  * @since   1.6
  */
 public function getAssignedGroups($userId = null)
 {
     $userId = !empty($userId) ? $userId : (int) $this->getState('user.id');
     if (empty($userId)) {
         $result = array();
         $groupsIDs = $this->getForm()->getValue('groups');
         if (!empty($groupsIDs)) {
             $result = $groupsIDs;
         } else {
             $config = JComponentHelper::getParams('com_users');
             if ($groupId = $config->get('new_usertype')) {
                 $result[] = $groupId;
             }
         }
     } else {
         $result = JUserHelper::getUserGroups($userId);
     }
     return $result;
 }
开发者ID:Caojunkai,项目名称:working,代码行数:28,代码来源:user.php


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