本文整理汇总了PHP中JUser::getAuthorisedGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::getAuthorisedGroups方法的具体用法?PHP JUser::getAuthorisedGroups怎么用?PHP JUser::getAuthorisedGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::getAuthorisedGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthorisedGroups
/**
* Gets an array of the authorised user-groups for this entity
*
* @param boolean $inheritedOnesToo True to include inherited user groups.
* @return array
*/
public function getAuthorisedGroups($inheritedOnesToo = true)
{
if ($inheritedOnesToo) {
return $this->cmsOwnUser->getAuthorisedGroups($inheritedOnesToo);
} else {
return JAccess::getGroupsByUser($this->cmsOwnUser->id, false);
}
}
示例2: onBeforeStore
/**
* process the plugin, called when form is submitted
*
* @param object $params
* @param object form model
*/
function onBeforeStore(&$params, &$formModel)
{
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$lang = JFactory::getLanguage();
//load up com_users lang - used in email text
$lang->load('com_users');
//if the fabrik table is set to be jos_users and the this plugin is used
//we need to alter the form model to tell it not to store the main row
// but to still store any joined rows
$ftable = str_replace('#__', $app->getCfg('dbprefix'), $formModel->getlistModel()->getTable()->db_table_name);
$jos_users = $app->getCfg('dbprefix') . 'users';
if ($ftable == $jos_users) {
$formModel->_storeMainRow = false;
}
$usersConfig = JComponentHelper::getParams('com_users');
// Initialize some variables
$me = JFactory::getUser();
$acl = JFactory::getACL();
//$mailFrom = $app->getCfg('mailfrom');
//$FromName = $app->getCfg('fromname');
//$SiteName = $app->getCfg('sitename');
$siteURL = JURI::base();
$bypassActivation = $params->get('juser_bypass_activation', false);
$bypassRegistration = $params->get('juser_bypass_registration', true);
// load in the com_user language file
$lang = JFactory::getLanguage();
$lang->load('com_user');
$data = $formModel->_formData;
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$option = JRequest::getCmd('option');
$original_id = 0;
if ($params->get('juser_field_userid') != '') {
$this->useridfield = $this->getFieldName($params, 'juser_field_userid');
if (!empty($formModel->_rowId)) {
$original_id = (int) $formModel->_formData[$this->useridfield];
}
} else {
$original_id = 0;
$this->useridfield = '';
}
// Create a new JUser object
$user = new JUser($original_id);
$originalGroups = $user->getAuthorisedGroups();
// Are we dealing with a new user which we need to create?
$isNew = $user->get('id') < 1;
if ($isNew && $usersConfig->get('allowUserRegistration') == '0' && !$bypassRegistration) {
JError::raiseError(403, JText::_('Access Forbidden - Registration not enabled'));
return false;
}
$data = array();
$this->passwordfield = $this->getFieldName($params, 'juser_field_password');
$this->passwordvalue = $this->getFieldValue($params, 'juser_field_password', $formModel->_formData);
$this->namefield = $this->getFieldName($params, 'juser_field_name');
$this->namevalue = $this->getFieldValue($params, 'juser_field_name', $formModel->_formData);
$this->usernamefield = $this->getFieldName($params, 'juser_field_username');
$this->usernamevalue = $this->getFieldValue($params, 'juser_field_username', $formModel->_formData);
$this->emailfield = $this->getFieldName($params, 'juser_field_email');
$this->emailvalue = $this->getFieldValue($params, 'juser_field_email', $formModel->_formData);
$data['id'] = $original_id;
$this->gidfield = $this->getFieldName($params, 'juser_field_usertype');
$defaultGroup = (int) $params->get('juser_field_default_group');
$groupId = JArrayHelper::getValue($formModel->_formData, $this->gidfield, $defaultGroup);
if (is_array($groupId)) {
$groupId = $groupId[0];
}
$groupId = (int) $groupId;
if (!$isNew) {
if ($params->get('juser_field_usertype') != '') {
if (in_array($groupId, $me->getAuthorisedGroups()) || $me->authorise('core.admin')) {
$data['gid'] = $groupId;
} else {
JError::raiseNotice(500, "could not alter user group to {$groupId} as you are not assigned to that group");
}
} else {
// if editing an existing user and no gid field being used,
// use default group id
$data['gid'] = $defaultGroup;
}
} else {
$data['gid'] = $params->get('juser_field_usertype') != '' ? $groupId : $defaultGroup;
}
if ($data['gid'] === 0) {
$data['gid'] = $defaultGroup;
}
$user->groups = (array) $data['gid'];
if ($params->get('juser_field_block') != '') {
$this->blockfield = $this->getFieldName($params, 'juser_field_block');
$blocked = JArrayHelper::getValue($formModel->_formData, $this->blockfield, '');
if (is_array($blocked)) {
// probably a dropdown
$data['block'] = (int) $blocked[0];
} else {
//.........这里部分代码省略.........