Exemple #1
0
// 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
Exemple #2
0
    $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()) {
Exemple #3
0
}
// 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)) {