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


PHP JAccess類代碼示例

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


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

示例1: 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

示例2: display

 /**
  * display method of playjoom view
  * @return void
  */
 public function display($tpl = null)
 {
     $dispatcher = JDispatcher::getInstance();
     //Get User Objects
     $user = JFactory::getUser();
     $canDo = PlayJoomHelper::getActions();
     // get the Data
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->script = $this->get('Script');
     $this->OptionsNewCover = $this->get('OptionsNewCover');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Problem with database query. Error500: ' . implode('<br />', $errors), 'priority' => JLog::ERROR, 'section' => 'admin')));
         return false;
     }
     if ($canDo->get('core.edit') || $canDo->get('core.create') && !JRequest::getVar('id') || JAccess::check($user->get('id'), 'core.admin') == 1) {
         // Set the toolbar
         $this->addToolBar();
         // Display the template
         $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Load template for cover viewer.', 'priority' => JLog::INFO, 'section' => 'admin')));
         parent::display($tpl);
     } else {
         $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Can not displaying cover viewer. ' . JText::_('JERROR_ALERTNOAUTHOR'), 'priority' => JLog::WARNING, 'section' => 'admin')));
         JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Set the document
     $this->setDocument();
 }
開發者ID:TFToto,項目名稱:playjoom-builds,代碼行數:34,代碼來源:view.html.php

示例3: bind

 /**
  * Overloaded bind function to pre-process the params.
  *
  * @param   array  $array   Named array
  * @param   mixed  $ignore  Optional array or list of parameters to ignore
  *
  * @return  null|string  null is operation was satisfactory, otherwise returns an error
  *
  * @see     JTable:bind
  * @since   1.5
  */
 public function bind($array, $ignore = '')
 {
     $input = JFactory::getApplication()->input;
     $task = $input->getString('task', '');
     if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_autofilter') && $array['state'] == 1)) {
         $array['state'] = 0;
     }
     if ($array['id'] == 0) {
         $array['created_by'] = JFactory::getUser()->id;
     }
     if (isset($array['params']) && is_array($array['params'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['params']);
         $array['params'] = (string) $registry;
     }
     if (isset($array['metadata']) && is_array($array['metadata'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['metadata']);
         $array['metadata'] = (string) $registry;
     }
     if (!JFactory::getUser()->authorise('core.admin', 'com_autofilter.categorie.' . $array['id'])) {
         $actions = JAccess::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/com_autofilter/access.xml', "/access/section[@name='categorie']/");
         $default_actions = JAccess::getAssetRules('com_autofilter.categorie.' . $array['id'])->getData();
         $array_jaccess = array();
         foreach ($actions as $action) {
             $array_jaccess[$action->name] = $default_actions[$action->name];
         }
         $array['rules'] = $this->JAccessRulestoArray($array_jaccess);
     }
     // Bind the rules for ACL where supported.
     if (isset($array['rules']) && is_array($array['rules'])) {
         $this->setRules($array['rules']);
     }
     return parent::bind($array, $ignore);
 }
開發者ID:tomazkramberger,項目名稱:autofilter,代碼行數:46,代碼來源:categorie.php

示例4: 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

示例5: getList

 public static function getList(&$params)
 {
     // Get the dbo
     $db = JFactory::getDbo();
     // Get an instance of the generic tracks model
     $model = JModelLegacy::getInstance('Sections', 'PlayjoomModel', array('ignore_request' => true));
     // Set application parameters in model
     $app = JFactory::getApplication();
     $appParams = $app->getParams();
     $model->setState('params', $appParams);
     // Set the filters based on the module params
     $model->setState('list.start', 0);
     $model->setState('list.limit', (int) $params->get('count', 5));
     // Access filter
     $access = !JComponentHelper::getParams('com_playjoom')->get('show_noauth', 1);
     $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
     $ordering = 'a.access_datetime';
     $dir = 'DESC';
     $model->setState('list.ordering', $ordering);
     $model->setState('list.direction', $dir);
     $items = $model->getItems();
     //create item link
     foreach ($items as &$item) {
         //Check for Trackcontrol
         if (JPluginHelper::isEnabled('playjoom', 'trackcontrol') == false) {
             $item->link = null;
         } else {
             $item->link = JRoute::_('index.php?option=com_playjoom&view=broadcast&id=' . $item->id);
         }
         $item->accessinfo = modLastPlayedHelper::GetTimeInfoList($item->access_datetime, $params, 'access');
     }
     return $items;
 }
開發者ID:TFToto,項目名稱:playjoom-builds,代碼行數:33,代碼來源:helper.php

示例6: groups

 /**
  * Displays a list of user groups.
  *
  * @param   boolean  true to include super admin groups, false to exclude them
  *
  * @return  array  An array containing a list of user groups.
  *
  * @since   11.4
  */
 public static function groups($includeSuperAdmin = false)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level');
     $query->from($db->quoteName('#__usergroups') . ' AS a');
     $query->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
     $query->group('a.id, a.title, a.lft, a.rgt');
     $query->order('a.lft ASC');
     $db->setQuery($query);
     $options = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
         return null;
     }
     for ($i = 0, $n = count($options); $i < $n; $i++) {
         $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
         $groups[] = JHtml::_('select.option', $options[$i]->value, $options[$i]->text);
     }
     // Exclude super admin groups if requested
     if (!$includeSuperAdmin) {
         $filteredGroups = array();
         foreach ($groups as $group) {
             if (!JAccess::checkGroup($group->value, 'core.admin')) {
                 $filteredGroups[] = $group;
             }
         }
         $groups = $filteredGroups;
     }
     return $groups;
 }
開發者ID:jimyb3,項目名稱:mathematicalteachingsite,代碼行數:41,代碼來源:user.php

示例7: edit

 function edit()
 {
     JEVHelper::stylesheet('eventsadmin.css', 'administrator/components/' . JEV_COM_COMPONENT . '/assets/css/');
     $document =& JFactory::getDocument();
     $document->setTitle(JText::_('COM_JEVENTS_CONFIGURATION'));
     // Set toolbar items for the page
     JToolBarHelper::title(JText::_('COM_JEVENTS_CONFIGURATION'), 'jevents');
     //APPLY BUTTON BY PRAKASH.
     JToolBarHelper::apply('params.apply');
     //APPLY BUTTON
     JToolBarHelper::save('params.save');
     JToolBarHelper::cancel('cpanel.cpanel');
     $model = $this->getModel();
     $this->params =& $model->getParams();
     $component = JComponentHelper::getComponent(JEV_COM_COMPONENT);
     JHTML::_('behavior.tooltip');
     if (JVersion::isCompatible("1.6.0")) {
         // Get the actions for the asset.
         $actions = JAccess::getActions(JEV_COM_COMPONENT, "component");
         jimport('joomla.form.form');
         // Add the search path for the admin component config.xml file.
         JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/' . JEV_COM_COMPONENT);
         // Get the form.
         $modelForm = $model->getForm();
         $this->assignRef("form", $modelForm);
     }
 }
開發者ID:andreassetiawanhartanto,項目名稱:PDKKI,代碼行數:27,代碼來源:view.html.php

示例8: auth

 protected function auth($area)
 {
     //echo '<pre>' . print_r(JAccess::getActions('com_chessvn','gamechat'),true).'</pre>';die();
     $aclLocal = array();
     foreach (JAccess::getActions('com_chessvn', 'gamechat') as $ar) {
         $aclLocal[] = $ar->name;
     }
     if (in_array($area, $aclLocal)) {
         return $this->user->authorise($area, 'com_chessvn', 'gamechat');
     } else {
         $aclGlobal = array();
         foreach (JAccess::getActions('com_chessvn') as $ar) {
             $aclGlobal[] = $ar->name;
         }
         if (in_array($area, $aclGlobal)) {
             if (!empty($aclLocal)) {
                 JFactory::getApplication()->enqueueMessage('Undefined authorization area: ' . $area . ' -- fall back on component acl', 'Warning');
             }
             return $this->user->authorise($area, 'com_chessvn');
         } else {
             JFactory::getApplication()->enqueueMessage('Undefined authorization area: ' . $area . ' -- NO fall back found', 'Error');
             return true;
         }
     }
 }
開發者ID:khangcodt,項目名稱:nvssehcweb,代碼行數:25,代碼來源:view.html.php

示例9: 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

示例10: prepareData

 /**
  * Prepare data hook.
  *
  * @return  void
  */
 protected function prepareData()
 {
     require_once JPATH_SITE . '/components/com_content/helpers/route.php';
     $app = JFactory::getApplication();
     $data = $this->getData();
     $data->params = JComponentHelper::getParams('com_content');
     $data->user = $user = JUser::getInstance($app->input->getUsername('username'));
     JModelLegacy::addIncludePath(\Windwalker\Helper\PathHelper::getSite('com_content') . '/models');
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     $model->setState('params', $data->params);
     $access = !JComponentHelper::getParams('com_content')->get('show_noauth');
     $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
     $model->setState('filter.published', 1);
     $model->setState('filter.access', $access);
     $model->setState('filter.author_id', (int) $user->id);
     $model->setState('list.ordering', 'a.created');
     $model->setState('list.direction', 'DESC');
     $model->setState('list.limit', 10);
     $data->items = $model->getItems();
     $data->pagination = $model->getPagination();
     foreach ($data->items as &$item) {
         $item->slug = $item->id . ':' . $item->alias;
         $item->catslug = $item->catid . ':' . $item->category_alias;
         $item->params = $data->params;
         if ($access || in_array($item->access, $authorised)) {
             // We know that user has the privilege to view the article
             $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
         } else {
             $item->link = JRoute::_('index.php?option=com_users&view=login');
         }
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->event = new stdClass();
         $dispatcher = JEventDispatcher::getInstance();
         // Old plugins: Ensure that text property is available
         if (!isset($item->text)) {
             $item->text = $item->introtext;
         }
         $app->input->set('option', 'com_content');
         $app->input->set('view', 'category');
         $app->input->set('layout', 'blog');
         JPluginHelper::importPlugin('content');
         $dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$item->params, 0));
         // Old plugins: Use processed text as introtext
         $item->introtext = $item->text;
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
         $app->input->set('option', 'com_userxtd');
         $app->input->set('view', 'content');
         $app->input->set('layout', 'default');
     }
     $this->setTitle();
 }
開發者ID:ForAEdesWeb,項目名稱:AEW27,代碼行數:65,代碼來源:html.php

示例11: getItems

	/**
	 * Override getItems method.
	 *
	 * @return  array
	 * @since   1.6
	 */
	public function getItems()
	{
		$groupId = $this->getState('filter.group_id');

		if (($assets = parent::getItems()) && $groupId)
		{

			$actions = $this->getDebugActions();

			foreach ($assets as &$asset)
			{
				$asset->checks = array();

				foreach ($actions as $action)
				{
					$name = $action[0];
					$level = $action[1];

					// Check that we check this action for the level of the asset.
					if ($action[1] === null || $action[1] >= $asset->level)
					{
						// We need to test this action.
						$asset->checks[$name] = JAccess::checkGroup($groupId, $action[0], $asset->name);
					}
					else
					{
						// We ignore this action.
						$asset->checks[$name] = 'skip';
					}
				}
			}
		}

		return $assets;
	}
開發者ID:GitIPFire,項目名稱:Homeworks,代碼行數:41,代碼來源:debuggroup.php

示例12: getList

 public static function getList(&$params)
 {
     // Get the dbo
     $db = JFactory::getDbo();
     // Get an instance of the generic articles model
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     // Set application parameters in model
     $app = JFactory::getApplication();
     $appParams = $app->getParams();
     $model->setState('params', $appParams);
     // Set the filters based on the module params
     $model->setState('list.start', 0);
     $model->setState('list.limit', (int) $params->get('count', 10));
     $model->setState('filter.published', 1);
     // Access filter
     $access = !JComponentHelper::getParams('com_content')->get('show_noauth');
     $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
     $model->setState('filter.access', $access);
     // Category filter
     $model->setState('filter.category_id', $params->get('catid', array(), 'title'));
     // Ordering
     $model->setState('list.ordering', $params->get('article_ordering', 'a.ordering'));
     $model->setState('list.direction', $params->get('article_ordering_direction', 'ASC'));
     $items = $model->getItems();
     return $items;
 }
開發者ID:renekreijveld,項目名稱:ModBootstrapCarousel,代碼行數:26,代碼來源:helper.php

示例13: getActions

 /**
  * Получаем доступы для действий.
  *
  * @param   int  $categoryId  Id категории.
  * @param   int  $messageId   Id сообщения.
  *
  * @return  object
  */
 public static function getActions($categoryId = 0, $messageId = 0)
 {
     // Определяем имя ассета (ресурса).
     if (empty($messageId) && empty($categoryId)) {
         $assetName = 'com_helloworld';
         $section = 'component';
     } elseif (empty($messageId)) {
         $assetName = 'com_helloworld.category.' . (int) $categoryId;
         $section = 'category';
     } else {
         $assetName = 'com_helloworld.message.' . (int) $messageId;
         $section = 'message';
     }
     if (empty(self::$actions)) {
         // Получаем список доступных действий для компонента.
         $accessFile = JPATH_ADMINISTRATOR . '/components/com_helloworld/access.xml';
         $actions = JAccess::getActionsFromFile($accessFile, "/access/section[@name='" . $section . "']/");
         // Для сообщения и категорий добавляем действие core.admin.
         if ($section == 'category' || $section == 'message') {
             $adminAction = new stdClass();
             $adminAction->name = 'core.admin';
             array_push($actions, $adminAction);
         }
         self::$actions = new JObject();
         foreach ($actions as $action) {
             // Устанавливаем доступы пользователя для действий.
             self::$actions->set($action->name, JFactory::getUser()->authorise($action->name, $assetName));
         }
     }
     return self::$actions;
 }
開發者ID:thebeuving,項目名稱:joomla-25-component-example,代碼行數:39,代碼來源:helloworld.php

示例14: before

 /**
  * Load user list.
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $config = KunenaConfig::getInstance();
     if ($config->userlist_allowed && JFactory::getUser()->guest) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401');
     }
     require_once KPATH_SITE . '/models/user.php';
     $this->model = new KunenaModelUser(array(), $this->input);
     $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
     $this->state = $this->model->getState();
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $start = $this->state->get('list.start');
     $limit = $this->state->get('list.limit');
     // Get list of super admins to exclude or not in filter by configuration.
     $filter = JAccess::getUsersByGroup(8);
     $finder = new KunenaUserFinder();
     $finder->filterByConfiguration($filter)->filterByName($this->state->get('list.search'));
     $this->total = $finder->count();
     $this->pagination = new KunenaPagination($this->total, $start, $limit);
     $alias = 'ku';
     $aliasList = array('id', 'name', 'username', 'email', 'block', 'registerDate', 'lastvisitDate');
     if (in_array($this->state->get('list.ordering'), $aliasList)) {
         $alias = 'a';
     }
     $this->users = $finder->order($this->state->get('list.ordering'), $this->state->get('list.direction') == 'asc' ? 1 : -1, $alias)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
 }
開發者ID:anawu2006,項目名稱:PeerLearning,代碼行數:33,代碼來源:display.php

示例15: getActions

	/**
	 * Gets a list of the actions that can be performed.
	 *
	 * @param   integer  The category ID.
	 *
	 * @return  JObject
	 * @since   1.6
	 */
	public static function getActions($categoryId = 0)
	{
		$user	= JFactory::getUser();
		$result	= new JObject;
	
		if (empty($categoryId))
		{
			$assetName = 'com_mvceditor';
			$level = 'component';
		}
		else
		{
			$assetName = 'com_mvceditor.category.'.(int) $categoryId;
			$level = 'category';
		}
	
		$actions = JAccess::getActions('com_mvceditor', $level);
	
		foreach ($actions as $action)
		{
			$result->set($action->name,	$user->authorise($action->name, $assetName));
		}
	
		return $result;
	}	
開發者ID:utopszkij,項目名稱:lmp,代碼行數:33,代碼來源:mvceditor.php


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