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


PHP JEVHelper::getAuthorisedCategories方法代碼示例

本文整理匯總了PHP中JEVHelper::getAuthorisedCategories方法的典型用法代碼示例。如果您正苦於以下問題:PHP JEVHelper::getAuthorisedCategories方法的具體用法?PHP JEVHelper::getAuthorisedCategories怎麽用?PHP JEVHelper::getAuthorisedCategories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JEVHelper的用法示例。


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

示例1: canCreateEvent

 /**
  * Test to see if user can create event within the specified category
  *
  * @param unknown_type $row
  * @param unknown_type $user
  * @return unknown
  */
 public static function canCreateEvent($row, $user = null)
 {
     // TODO make this call a plugin
     if ($user == null) {
         $user = JFactory::getUser();
     }
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $authorisedonly = $params->get("authorisedonly", 0);
     if (!$authorisedonly) {
         if ($user->authorise('core.create', 'com_jevents')) {
             return true;
         }
         $allowedcats = JEVHelper::getAuthorisedCategories($user, 'com_jevents', 'core.create');
         if (!in_array($row->_catid, $allowedcats)) {
             return false;
         }
         // check multi cats too
         if (JEVHelper::rowCatids($row)) {
             if (count(array_diff(JEVHelper::rowCatids($row), $allowedcats))) {
                 return false;
             }
         }
     } else {
         // are we authorised to do anything with this category or calendar
         $jevuser = JEVHelper::getAuthorisedUser();
         if ($row->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
             $allowedcals = explode("|", $jevuser->calendars);
             if (!in_array($row->_icsid, $allowedcals)) {
                 return false;
             }
         }
         if ($row->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
             $allowedcats = explode("|", $jevuser->categories);
             if (!in_array($row->_catid, $allowedcats)) {
                 return false;
             }
             // check multi cats too
             if (JEVHelper::rowCatids($row)) {
                 if (count(array_diff(JEVHelper::rowCatids($row), $allowedcats))) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
開發者ID:madcsaba,項目名稱:li-de,代碼行數:53,代碼來源:helper.php

示例2: canCreateEvent

 /**
  * Test to see if user can create event within the specified category
  *
  * @param unknown_type $row
  * @param unknown_type $user
  * @return unknown
  */
 public static function canCreateEvent($row, $user = null)
 {
     // TODO make this call a plugin
     if ($user == null) {
         $user = JFactory::getUser();
     }
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $authorisedonly = $params->get("authorisedonly", 0);
     if (!$authorisedonly) {
         if ($user->authorise('core.create', 'com_jevents')) {
             return true;
         }
         $allowedcats = JEVHelper::getAuthorisedCategories($user, 'com_jevents', 'core.create');
         // anon user event creation
         if ($user->id == 0 && count($allowedcats) == 0) {
             $jevtask = JRequest::getString("task");
             // This allows savenew through too!
             if (strpos($jevtask, "icalevent.save") !== false || strpos($jevtask, "icalevent.apply") !== false) {
                 JRequest::setVar("task", "icalevent.edit");
                 $catids = JEVHelper::rowCatids($row) ? JEVHelper::rowCatids($row) : array(intval($row->_catid));
                 $catids = implode(",", $catids);
                 $dispatcher = JEventDispatcher::getInstance();
                 $dispatcher->trigger('onGetAccessibleCategories', array(&$catids));
                 $allowedcats = explode(",", $catids);
                 JRequest::setVar("task", $jevtask);
             }
         }
         if (!in_array($row->_catid, $allowedcats)) {
             return false;
         }
         // check multi cats too
         if (JEVHelper::rowCatids($row)) {
             if (count(array_diff(JEVHelper::rowCatids($row), $allowedcats))) {
                 return false;
             }
         }
     } else {
         // are we authorised to do anything with this category or calendar
         $jevuser = JEVHelper::getAuthorisedUser();
         if ($row->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
             $allowedcals = explode("|", $jevuser->calendars);
             if (!in_array($row->_icsid, $allowedcals)) {
                 return false;
             }
         }
         if ($row->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
             $allowedcats = explode("|", $jevuser->categories);
             if (!in_array($row->_catid, $allowedcats)) {
                 return false;
             }
             // check multi cats too
             if (JEVHelper::rowCatids($row)) {
                 if (count(array_diff(JEVHelper::rowCatids($row), $allowedcats))) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
開發者ID:hriggs,項目名稱:cs-website,代碼行數:67,代碼來源:helper.php


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