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


PHP SibdietHelper::getUserPermissions方法代码示例

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


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

示例1: display

 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         SibdietHelper::addSubmenu('profiles');
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->permissions = SibdietHelper::getUserPermissions();
     if ($this->getLayout() !== 'modal') {
         // Calculate profile refer No.
         foreach ($this->items as $item) {
             $item->referNo = SibdietHelper::getReferNo($item->id);
         }
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
     }
     if (in_array('profiles', $this->permissions) || $this->getLayout() == 'modal') {
         parent::display($tpl);
     }
 }
开发者ID:smhnaji,项目名称:sdnet,代码行数:35,代码来源:view.html.php

示例2: featured

 /**
  * Method to toggle the featured setting of a list of articles.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Access checks.
     foreach ($ids as $i => $id) {
         $permissions = SibdietHelper::getUserPermissions();
         if (!in_array('nutrients', $permissions) || !$user->authorise('core.edit.state', 'com_sibdiet.nutrient.' . (int) $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
         if ($value == 1) {
             $message = JText::plural('COM_SIBDIET_N_ITEMS_FEATURED', count($ids));
         } else {
             $message = JText::plural('COM_SIBDIET_N_ITEMS_UNFEATURED', count($ids));
         }
     }
     $this->setRedirect('index.php?option=com_sibdiet&view=nutrients', false, $message);
 }
开发者ID:smhnaji,项目名称:sdnet,代码行数:42,代码来源:nutrients.php

示例3: allowEdit

 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array   $data  An array of input data.
  * @param   string  $key   The name of the key for the primary key.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     $permissions = SibdietHelper::getUserPermissions();
     $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
     $user = JFactory::getUser();
     $userId = $user->get('id');
     // Check requests manage permission first.
     if ($this->input->get('return') == 'requestschecks') {
         if (in_array('requestschecks', $permissions)) {
             return parent::allowEdit($data, $key);
         }
     } elseif (in_array('requests', $permissions)) {
         // Check that diet not started
         if ($recordId) {
             // Need to do a lookup from the model.
             $record = $this->getModel()->getItem($recordId);
             if ($record->room1 || $record->room2 || $record->room3 || $record->room4 || $record->room5 || $record->room6) {
                 return false;
             }
             // Now test the owner is the user.
             $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
             if (empty($ownerId)) {
                 if (empty($record)) {
                     return false;
                 }
                 $ownerId = $record->created_by;
             }
             // If the owner matches 'me' then do the test.
             if ($ownerId == $userId) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:smhnaji,项目名称:sdnet,代码行数:45,代码来源:request.php

示例4: canEditState

 /**
  * Method to test whether a record can have its state edited.
  *
  * @param   object  $record  A record object.
  *
  * @return  boolean  True if allowed to change the state of the record. Defaults to the permission set in the component.
  *
  * @since   1.6
  */
 protected function canEditState($record)
 {
     $permissions = SibdietHelper::getUserPermissions();
     if (in_array('contags', $permissions)) {
         return parent::canEditState($record);
     }
     return false;
 }
开发者ID:smhnaji,项目名称:sdnet,代码行数:17,代码来源:contag.php

示例5: allowEdit

 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array   $data  An array of input data.
  * @param   string  $key   The name of the key for the primary key.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     $permissions = SibdietHelper::getUserPermissions();
     if (in_array('sweeteners', $permissions)) {
         return parent::allowEdit($data, $key);
     } else {
         return false;
     }
 }
开发者ID:smhnaji,项目名称:sdnet,代码行数:19,代码来源:sweetener.php


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