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


PHP JFactory::getAcl方法代码示例

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


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

示例1: _actionAdd

 protected function _actionAdd(KCommandContext $context)
 {
     $parameters = JComponentHelper::getParams('com_users');
     if (!($group_name = $parameters->get('new_usertype'))) {
         $group_name = 'Registered';
     }
     $context->data->id = 0;
     $context->data->group_name = $group_name;
     $context->data->users_group_id = JFactory::getAcl()->get_group_id('', $group_name, 'ARO');
     $context->data->registered_on = JFactory::getDate()->toMySQL();
     if ($parameters->get('useractivation') == '1') {
         $password = $this->getService('com://site/users.helper.password');
         $context->data->activation = $password->getHash($password->getRandom(32));
         $context->data->enabled = 0;
         $message = JText::_('REG_COMPLETE_ACTIVATE');
     } else {
         $message = JText::_('REG_COMPLETE');
     }
     return parent::_actionAdd($context);
 }
开发者ID:raeldc,项目名称:nooku-server,代码行数:20,代码来源:user.php

示例2: testGetAcl

 /**
  * Tests the JFactory::getACL method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetAcl()
 {
     $this->assertInstanceOf('JAccess', JFactory::getAcl(), 'Line: ' . __LINE__);
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:11,代码来源:JFactoryTest.php

示例3: usergroups

 /**
  * Renders a user group select list
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public static function usergroups($name, $selected = '')
 {
     $model = FD::model('Users');
     $groups = $model->getUserGroups();
     $theme = FD::themes();
     $theme->set('name', $name);
     $theme->set('selected', $selected);
     $theme->set('groups', $groups);
     $output = $theme->output('admin/html/form.usergroups');
     return $output;
     return JHTML::_('select.genericlist', JFactory::getAcl()->get_group_children_tree(null, 'USERS', false), $name, 'size="10"', 'value', 'text', $selected);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:20,代码来源:form.php

示例4: checkPermissions

 public static function checkPermissions($action, $error_msg, $suffix = '', $auth = false)
 {
     $allowed = false;
     jimport('joomla.version');
     $version = new JVersion();
     if (version_compare($version->getShortVersion(), '1.6', '<')) {
         $user = JFactory::getUser();
         if ($user->guest) {
             $user->usertype = 'public frontend';
             $user->gid = JFactory::getAcl()->get_group_id('public frontend', 'ARO');
         }
         $user_return = $user->authorize('com_contentbuilder', $action);
         $published_return = $user->authorize('com_contentbuilder_published', 'any');
         if ($published_return !== 'ok') {
             if (!$auth) {
                 //JError::raiseError(403, $error_msg);
                 JFactory::getApplication()->redirect('index.php', $error_msg, 'error');
             } else {
                 return false;
             }
         }
         switch ($action) {
             case 'edit':
                 $edit_return = $user->authorize('com_contentbuilder_limit_edit', $action);
                 if ($edit_return !== 'ok') {
                     if (!$auth) {
                         //JError::raiseError(403, $error_msg);
                         JFactory::getApplication()->redirect('index.php', $error_msg, 'error');
                     } else {
                         return false;
                     }
                 }
                 break;
         }
         switch ($action) {
             case 'new':
                 $add_return = $user->authorize('com_contentbuilder_limit_add', $action);
                 if ($add_return !== 'ok') {
                     if (!$auth) {
                         //JError::raiseError(403, $error_msg);
                         JFactory::getApplication()->redirect('index.php', $error_msg, 'error');
                     } else {
                         return false;
                     }
                 }
                 break;
         }
         switch ($action) {
             case 'edit':
             case 'new':
             case 'view':
             case 'delete':
                 $myaction = $action == 'delete' ? 'edit' : $action;
                 $verify_return = $user->authorize('com_contentbuilder_verify', $myaction);
                 if ($verify_return !== 'ok') {
                     if ($verify_return === 'notok') {
                         if (!$auth) {
                             //JError::raiseError(403, $error_msg);
                             JFactory::getApplication()->redirect('index.php', $error_msg, 'error');
                         } else {
                             return false;
                         }
                     } else {
                         if ($verify_return !== 'notok') {
                             if (!$auth) {
                                 JFactory::getApplication()->redirect($verify_return);
                             } else {
                                 return false;
                             }
                         }
                     }
                 }
                 break;
         }
         if ($user->guest) {
             $user->usertype = '';
             $user->gid = 0;
         }
         if (is_array($user_return) && isset($user_return['own']) && $user_return['own']) {
             $db = JFactory::getDBO();
             static $typeref;
             if (is_array($typeref)) {
                 $typerefid = $typeref[intval($user_return['form_id'])];
             } else {
                 $db->setQuery("Select `type`, `reference_id` From #__contentbuilder_forms Where id = " . intval($user_return['form_id']));
                 $typerefid = $db->loadAssoc();
                 $typeref[intval($user_return['form_id'])] = $typerefid;
             }
             if (is_array($typerefid)) {
                 $form = self::getForm($typerefid['type'], $typerefid['reference_id']);
                 if ($form && !isset($user_return['record_id'])) {
                     $allowed = true;
                 } else {
                     if (is_array($user_return['record_id'])) {
                         foreach ($user_return['record_id'] as $recid) {
                             $db->setQuery("Select session_id From #__contentbuilder_records Where `record_id` = " . $db->Quote($recid) . " And `type` = " . $db->Quote($typerefid['type']) . " And `reference_id` = " . $db->Quote($typerefid['reference_id']) . "");
                             $session_id = $db->loadResult();
                             if ($form && $session_id != JFactory::getSession()->getId() && !$form->isOwner(JFactory::getUser()->get('id', 0), $recid)) {
                                 $allowed = false;
                                 break;
//.........这里部分代码省略.........
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:101,代码来源:contentbuilder.php

示例5: 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
  */
 function store($updateNulls = false)
 {
     global $_CB_framework, $_CB_database, $ueConfig;
     $this->id = (int) $this->id;
     if (checkJversion() == 2) {
         $this->gids = is_array($this->gids) ? $this->gids : array($this->gid);
         $this->gid = (int) $_CB_framework->acl->getBackwardsCompatibleGid($this->gids);
     } else {
         $this->gid = (int) $this->gid;
         $this->gids = array($this->gid);
     }
     $isNew = $this->id == 0;
     $oldUsername = null;
     $oldGid = null;
     $oldGids = array();
     $oldBlock = null;
     if (!$isNew) {
         // get actual username to update sessions in case:
         $sql = 'SELECT ' . $_CB_database->NameQuote($this->_cmsUserTableUsername) . (checkJversion() < 2 ? ', ' . $_CB_database->NameQuote($this->_cmsUserTableGid) : null) . ', ' . $_CB_database->NameQuote('block') . ' FROM ' . $_CB_database->NameQuote($this->_cmsUserTable) . ' WHERE ' . $_CB_database->NameQuote($this->_cmsUserTableKey) . ' = ' . (int) $this->user_id;
         $_CB_database->setQuery($sql);
         $oldEntry = null;
         if ($_CB_database->loadObject($oldEntry)) {
             $oldUsername = $oldEntry->username;
             if (checkJversion() == 2) {
                 $gids = array_values((array) JFactory::getAcl()->getGroupsByUser($this->id, false));
                 foreach ($gids as $k => $v) {
                     $gids[$k] = (string) $v;
                 }
                 $oldGids = $gids;
                 $oldGid = (int) $_CB_framework->acl->getBackwardsCompatibleGid($oldGids);
             } else {
                 $oldGid = (int) $oldEntry->gid;
                 $oldGids = array($oldEntry->gid);
             }
             $oldBlock = $oldEntry->block;
         }
     }
     // insure usertype is in sync with gid:
     /*
      * This could be a better method:
     		if ( checkJversion() == 1 ) {
     			$gdataArray								=	$_CB_framework->acl->get_group_data( (int) $this->gid, 'ARO' );
     			if ( $gdataArray ) {
     				$this->usertype						=	$gdataArray[3];
     			} else {
     				user_error( sprintf( 'comprofilerUser::store: gacl:get_group_data: for user_id %d, name of group_id %d not found in acl groups table.', $this->id, $this->gid ), E_USER_WARNING );
     				$this->usertype						=	'Registered';
     			}
     		} else {
     			$this->usertype							=	$_CB_framework->acl->get_group_name( (int) $gid, 'ARO' );
     		}
     */
     if (checkJversion() == 2) {
         $this->usertype = null;
     } else {
         if (checkJversion() == 1) {
             $query = 'SELECT name' . "\n FROM #__core_acl_aro_groups" . "\n WHERE id = " . (int) $this->gid;
         } else {
             $query = 'SELECT name' . "\n FROM #__core_acl_aro_groups" . "\n WHERE group_id = " . (int) $this->gid;
         }
         $_CB_database->setQuery($query);
         $this->usertype = $_CB_database->loadResult();
     }
     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:
     if (is_callable(array($this->_cmsUser, 'store'))) {
         $result = $this->_cmsUser->store($updateNulls);
         if (!$result) {
             $this->_error = $this->_cmsUser->getError();
         }
     } else {
         if (checkJversion() == 2) {
             $this->_cmsUser->groups = $this->gids;
         }
         $result = $this->_cmsUser->save();
         // Joomla 1.5 native
         if (!$result) {
             $this->_error = $this->_cmsUser->getError();
             if (class_exists('JText')) {
                 $this->_error = JText::_($this->_error);
             }
         }
     }
     if ($result) {
         // synchronize id and user_id:
//.........这里部分代码省略.........
开发者ID:rogatnev-nikita,项目名称:cloudinterpreter,代码行数:101,代码来源:cb.tables.php

示例6:

 function &_getCmsUserObject($cmsUserId = null)
 {
     if ($this->_cmsUserNeedsDb) {
         global $_CB_database;
         $obj = new $this->_cmsUserClassName($_CB_database);
     } else {
         $obj = new $this->_cmsUserClassName();
     }
     if ($cmsUserId !== null) {
         if (!$obj->load((int) $cmsUserId)) {
             $obj = null;
         } else {
             if (checkJversion() == 2) {
                 global $_CB_framework;
                 $obj->gid = (int) $_CB_framework->acl->getBackwardsCompatibleGid(array_values((array) JFactory::getAcl()->getGroupsByUser($obj->id, false)));
             }
         }
     }
     return $obj;
 }
开发者ID:rogatnev-nikita,项目名称:cloudinterpreter,代码行数:20,代码来源:plugin.foundation.php

示例7: 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();
                 // 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) {
                     \JAccess::clearStatics();
                     $session->set('user', new \JUser((int) $this->id));
                 }
             } else {
                 // logout user now that user login has been blocked:
                 if ($_CB_framework->myId() == $this->id) {
                     $_CB_framework->logout();
                 }
                 $this->_db->setQuery("DELETE FROM #__session WHERE userid = " . (int) $this->id);
                 //TBD: check if this is enough for J 1.5
                 $result = $this->_db->query();
//.........这里部分代码省略.........
开发者ID:Raul-mz,项目名称:web-erpcya,代码行数:101,代码来源:UserTable.php


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