本文整理汇总了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;
}
示例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;
}