示例#1
0
文件: describe.php 项目: rair/yacs
}
// load the skin, maybe with a variant
load_skin('articles', $anchor, isset($item['options']) ? $item['options'] : '');
// clear the tab we are in, if any
if (is_object($anchor)) {
    $context['current_focus'] = $anchor->get_focus();
}
// the title of the page
if (isset($item['title'])) {
    $context['page_title'] = $item['title'];
}
// not found
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!Articles::allow_access($item, $anchor)) {
    // give anonymous surfers a chance for HTTP authentication
    if (!Surfer::is_logged()) {
        Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"');
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the article
} else {
    // initialize the rendering engine
    Codes::initialize(Articles::get_permalink($item));
    // compute the url for this article
    $permanent_link = Articles::get_permalink($item);
    // the trackback link
示例#2
0
文件: articles.php 项目: rair/yacs
 /**
  * check if an article can be modified
  *
  * This function returns TRUE if the page can be modified,
  * and FALSE otherwise.
  *
  * @param array a set of item attributes, aka, the target article
  * @param object an instance of the Anchor interface
  * @return TRUE or FALSE
  */
 public static function allow_modification($item, $anchor)
 {
     global $context;
     // sanity check
     if (!isset($item['id']) && !$anchor) {
         return FALSE;
     }
     // surfer is an associate
     if (Surfer::is_associate()) {
         return TRUE;
     }
     // ensure access rights
     if (!Articles::allow_access($item, $anchor)) {
         return FALSE;
     }
     // submissions have been disallowed
     if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
         return FALSE;
     }
     // surfer owns the container or the article
     if (Articles::is_owned($item, $anchor)) {
         return TRUE;
     }
     // allow section editors to manage content, except on private sections
     if (Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
         return TRUE;
     }
     // allow page editors to manage content, except on private page
     if (Surfer::is_member() && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
         return TRUE;
     }
     // article has been locked
     if (isset($item['locked']) && $item['locked'] == 'Y') {
         return FALSE;
     }
     // maybe this anonymous surfer is allowed to handle this item
     if (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
         return TRUE;
     }
     // community wiki
     if (Surfer::is_logged() && Articles::has_option('members_edit', $anchor, $item)) {
         return TRUE;
     }
     // public wiki
     if (Articles::has_option('anonymous_edit', $anchor, $item)) {
         return TRUE;
     }
     // default case
     return FALSE;
 }