本文整理汇总了PHP中JUser::clearAccessRights方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::clearAccessRights方法的具体用法?PHP JUser::clearAccessRights怎么用?PHP JUser::clearAccessRights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::clearAccessRights方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* If table key (id) is NULL : inserts new rows
* otherwise updates existing row in the database tables
*
* Can be overridden or overloaded by the child classes
*
* @param boolean $updateNulls TRUE: null object variables are also updated, FALSE: not.
* @return boolean TRUE if successful otherwise FALSE
*
* @throws \RuntimeException
*/
public function store($updateNulls = false)
{
global $_CB_framework, $ueConfig;
$this->id = (int) $this->id;
$isNew = $this->id == 0;
$oldUsername = null;
$oldGids = array();
$oldBlock = null;
if (!$isNew) {
// get actual username to update sessions in case:
$sql = 'SELECT ' . $this->_db->NameQuote($this->_cmsUserTableUsername) . ', ' . $this->_db->NameQuote('block') . ' FROM ' . $this->_db->NameQuote($this->_cmsUserTable) . ' WHERE ' . $this->_db->NameQuote($this->_cmsUserTableKey) . ' = ' . (int) $this->user_id;
$this->_db->setQuery($sql);
$oldEntry = null;
if ($this->_db->loadObject($oldEntry)) {
/** @var \JUser $oldEntry */
$oldUsername = $oldEntry->username;
$gids = array_values((array) \JFactory::getAcl()->getGroupsByUser($this->id, false));
foreach ($gids as $k => $v) {
$gids[$k] = (string) $v;
}
$oldGids = $gids;
$oldBlock = $oldEntry->block;
}
}
if (!$isNew && $this->confirmed == 0 && $this->cbactivation == '' && $ueConfig['reg_confirmation'] != 0) {
$this->_setActivationCode();
}
// creates CMS and CB objects:
$this->_mapUsers();
// remove the previous email set in bindSafely() and needed for checkSafely():
unset($this->_original_email);
// stores first into CMS to get id of user if new:
$this->_cmsUser->groups = $this->gids;
$result = $this->_cmsUser->save();
if (!$result) {
$this->_error = $this->_cmsUser->getError();
if (class_exists('JText')) {
$this->_error = \JText::_($this->_error);
}
}
if ($result) {
// synchronize id and user_id:
if ($isNew) {
$this->id = $this->_cmsUser->id;
$this->_comprofilerUser->id = $this->_cmsUser->id;
if ($this->confirmed == 0 && $this->cbactivation == '' && $ueConfig['reg_confirmation'] != 0) {
$this->_setActivationCode();
}
}
// stores CB user into comprofiler: if new, inserts, otherwise updates:
if ($this->user_id == 0) {
$this->user_id = $this->_cmsUser->id;
$this->_comprofilerUser->user_id = $this->user_id;
$result = $this->_comprofilerUser->storeNew($updateNulls);
} else {
$result = $this->_comprofilerUser->store($updateNulls);
}
if (!$result) {
$this->_error = $this->_comprofilerUser->getError();
}
}
if ($result) {
// update the ACL:
$query = 'SELECT m.id AS aro_id, a.group_id FROM #__user_usergroup_map AS a' . "\n INNER JOIN #__usergroups AS m ON m.id= a.group_id" . "\n WHERE a.user_id = " . (int) $this->id;
$this->_db->setQuery($query);
$aro_group = null;
$result = $this->_db->loadObject($aro_group);
/** @var \StdClass $aro_group */
if ($result && !$isNew && ($oldUsername != $this->username || !self::_ArraysEquivalent($oldGids, $this->gids) || $oldBlock == 0 && $this->block == 1)) {
// Update current sessions state if there is a change in gid or in username:
if ($this->block == 0) {
$query = 'UPDATE #__session ' . "\n SET username = " . $this->_db->Quote($this->username) . "\n WHERE userid = " . (int) $this->id;
$this->_db->setQuery($query);
$result = $this->_db->query();
// Clear usergroup and access caches on gid change (fixing bug #5461):
if (method_exists('clearAccessRights', $this->_cmsUser)) {
// This already calls clearStatics
$this->_cmsUser->clearAccessRights();
} else {
\JAccess::clearStatics();
}
// This is needed for instant adding of groups to logged-in user (fixing bug #3581):
$session = \JFactory::getSession();
$jUser = $session->get('user');
if ($jUser->id == $this->id) {
$session->set('user', new \JUser((int) $this->id));
}
} else {
// logout user now that user login has been blocked:
//.........这里部分代码省略.........