本文整理汇总了PHP中article::allows方法的典型用法代码示例。如果您正苦于以下问题:PHP article::allows方法的具体用法?PHP article::allows怎么用?PHP article::allows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类article
的用法示例。
在下文中一共展示了article::allows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: article
// current edited article as object
$cur_article = new article();
$cur_article->item = $item;
$cur_article->anchor = $anchor;
$cur_article->overlay = $overlay;
// get related behaviors, if any
$behaviors = NULL;
if (isset($item['id'])) {
$behaviors = new Behaviors($item, $anchor);
}
// change default behavior
if (isset($item['id']) && is_object($behaviors) && !$behaviors->allow('articles/edit.php', 'article:' . $item['id'])) {
$permitted = FALSE;
} elseif (!isset($item['id']) && $anchor->allows('creation', 'article')) {
$permitted = TRUE;
} elseif (isset($item['id']) && $cur_article->allows('modification')) {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
global $render_overlaid;
$whole_rendering = !$render_overlaid;
// cascade empowerment
if ($cur_article->is_owned() || Surfer::is_associate()) {
Surfer::empower();
}
// do not always show the edition form
$with_form = FALSE;
// load the skin, maybe with a variant
load_skin('articles', $anchor, isset($item['options']) ? $item['options'] : '');
// clear the tab we are in, if any
示例2: article
$anchor = Anchors::get($item['anchor']);
}
// current viewed article as object
$cur_article = new article();
$cur_article->item = $item;
$cur_article->anchor = $anchor;
$cur_article->overlay = $overlay;
// get related behaviors, if any
$behaviors = NULL;
if (isset($item['id'])) {
$behaviors = new Behaviors($item, $anchor);
}
// change default behavior
if (isset($item['id']) && is_object($behaviors) && !$behaviors->allow('articles/view.php', 'article:' . $item['id'])) {
$permitted = FALSE;
} elseif ($cur_article->allows('access')) {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// owners can do what they want
if ($cur_article->allows('modification')) {
Surfer::empower();
} elseif (Surfer::is_logged() && is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower('S');
} elseif (isset($item['id']) && $cur_article->is_assigned() && Surfer::is_logged()) {
Surfer::empower('S');
}
// is the article on user watch list?
$in_watch_list = FALSE;
if (isset($item['id']) && Surfer::get_id()) {
示例3: sprintf
}
// path to this page
$context['path_bar'] = Surfer::get_path_bar($anchor);
// page title
if (isset($item['title'])) {
$context['page_title'] = sprintf(i18n::s('Stamp: %s'), $item['title']);
}
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// not found
} elseif (!isset($item['id'])) {
include '../error.php';
// publication is restricted to some people
} elseif (!$cur_article->allows('publication')) {
// anonymous users are invited to log in
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_url($item['id'], 'stamp')));
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// review is confirmed
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'review') {
// update the database
if ($error = Articles::stamp($item['id'])) {
Logger::error($error);
} else {
// touch the related anchor
if (is_object($anchor)) {