本文整理汇总了PHP中FlexicontentHelperPerm::checkTypeAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentHelperPerm::checkTypeAccess方法的具体用法?PHP FlexicontentHelperPerm::checkTypeAccess怎么用?PHP FlexicontentHelperPerm::checkTypeAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentHelperPerm
的用法示例。
在下文中一共展示了FlexicontentHelperPerm::checkTypeAccess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canEditState
/**
* Method to check if the user can edit the STATE of the item
*
* @access public
* @return boolean True on success
* @since 1.5
*/
function canEditState($item = null, $check_cat_perm = true)
{
if (empty($item)) {
$item =& $this->_item;
}
$user = JFactory::getUser();
$session = JFactory::getSession();
$isOwner = !empty($item->created_by) && $item->created_by == $user->get('id');
$hasCoupon = false;
if ($session->has('rendered_uneditable', 'flexicontent')) {
$rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
$hasCoupon = !empty($item->id) && !empty($rendered_uneditable[$item->id]) && $rendered_uneditable[$item->id] == 2;
// editable temporarily via coupon
}
// get "edit items state" permission on the type of the item
$hasTypeEditState = !$item->type_id ? true : FlexicontentHelperPerm::checkTypeAccess($item->type_id, 'core.edit.state');
$hasTypeEditStateOwn = !$item->type_id ? true : FlexicontentHelperPerm::checkTypeAccess($item->type_id, 'core.edit.state.own');
if (!$hasTypeEditState && !$hasTypeEditStateOwn) {
return false;
}
if (!empty($item->id)) {
// Existing item, use item specific permissions
$asset = 'com_content.article.' . $item->id;
$allowed = $hasTypeEditState && $user->authorise('core.edit.state', $asset) || $hasTypeEditStateOwn && $user->authorise('core.edit.state.own', $asset) && ($isOwner || $hasCoupon);
} elseif ($check_cat_perm && !empty($item->catid)) {
// *** New item *** with main category set
$cat_asset = 'com_content.category.' . (int) @$item->catid;
$allowed = $hasTypeEditState && $user->authorise('core.edit.state', $cat_asset) || $hasTypeEditStateOwn && $user->authorise('core.edit.state.own', $cat_asset) && $isOwner;
} else {
// *** New item *** get general edit/publish/delete permissions
$allowed = $hasTypeEditState && $user->authorise('core.edit.state', 'com_flexicontent') || $hasTypeEditStateOwn && $user->authorise('core.edit.state.own', 'com_flexicontent');
}
return $allowed;
}