Exemplo n.º 1
0
Arquivo: select.php Projeto: rair/yacs
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // build a form to assign some sections to this item
} else {
    // assign a section, and add it to the watch list
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set' && isset($_REQUEST['member'])) {
        Members::assign($_REQUEST['anchor'], $_REQUEST['member']);
        if (preg_match('/^user:/', $_REQUEST['anchor'])) {
            Members::assign($_REQUEST['member'], $_REQUEST['anchor']);
        }
        // break an assignment, and also purge the watch list
    } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset' && isset($_REQUEST['member'])) {
        Members::free($_REQUEST['anchor'], $_REQUEST['member']);
        if (preg_match('/^user:/', $_REQUEST['anchor'])) {
            Members::free($_REQUEST['member'], $_REQUEST['anchor']);
        }
    }
    // insert anchor prefix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_prefix();
    }
    // the current list of linked sections
    $sections =& Members::list_sections_by_title_for_anchor($anchor->get_reference(), 0, SECTIONS_LIST_SIZE, 'raw');
    // the form to link additional sections
    if (!is_array($sections) || count($sections) < SECTIONS_LIST_SIZE) {
        $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . i18n::s('To assign a section, look in the content tree below and assign one section at a time') . BR . '<select name="member">' . Sections::get_options(NULL, $sections) . '</select>' . ' ' . Skin::build_submit_button(' >> ') . '<input type="hidden" name="anchor" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="set">' . '</p></form>' . "\n";
    }
    // splash
    $context['text'] .= '<p style="margin-top: 2em;">' . sprintf(i18n::s('This is the list of sections assigned to %s'), $anchor->get_title()) . '</p>';
    // layout assigned sections
Exemplo n.º 2
0
     $anchor = Anchors::get($_REQUEST['anchor']);
     $cat = Anchors::get($_REQUEST['cat']);
     // check existance
     if (!is_object($anchor) && !is_object($cat) && $cat->get_type() != 'category') {
         $output['success'] = false;
         break;
     }
     // check surfer's rights
     if (!$cat->allows('categorization', $anchor)) {
         $output['success'] = false;
         break;
     }
     if ($way == 'assign') {
         $output['success'] = Members::assign($cat->get_reference(), $anchor->get_reference());
     } else {
         $output['success'] = Members::free($cat->get_reference(), $anchor->get_reference());
     }
     break;
     // create a new object under a given anchor, same kind as anchor
     // this means to build a hierarchy, eg sections or categories
 // create a new object under a given anchor, same kind as anchor
 // this means to build a hierarchy, eg sections or categories
 case 'create':
     // reference to anchor and new title are mandatory
     if (!isset($_REQUEST['anchor']) || !$_REQUEST['anchor'] || !isset($_REQUEST['title']) || !$_REQUEST['title']) {
         die_on_invalid();
     }
     // get type of anchor from given reference
     list($type, $anchor_id) = explode(":", $_REQUEST['anchor']);
     // 'index' is keyword used by the layout to point out the root,
     // witch is a empty string in database.
Exemplo n.º 3
0
Arquivo: leave.php Projeto: rair/yacs
} else {
    $context['path_bar'] = array('users/' => i18n::s('People'));
}
// an anchor is mandatory
if (!is_object($anchor)) {
    Logger::error(i18n::s('No anchor has been found.'));
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // please suppress editor rights to this item
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'leave') {
    // break an assignment, and also purge the watch list
    Members::free('user:'******'t break symetric connections from another user
    if ($anchor->get_type() != 'user') {
        Members::free($anchor->get_reference(), 'user:'******'section') {
        $label = i18n::s('a section');
    } else {
        $label = i18n::s('a page');
    }
    $context['page_title'] = sprintf(i18n::s('You have left %s'), $label);
    // splash message
    $context['text'] .= '<p>' . sprintf(i18n::s('The operation has completed, and you have no specific access rights to %s.'), Skin::build_link($anchor->get_url(), $anchor->get_title())) . '</p>';
    // back to the anchor page
    $links = array();
    $url = Surfer::get_permalink();
    $links[] = Skin::build_link($url, i18n::s('Done'), 'button');
Exemplo n.º 4
0
 /**
  * remember publications and tags
  *
  * This function links the provided reference to categories, based
  * on publication time and tags.
  *
  * The reference is linked to weekly and monthly categories, except if the
  * global parameter 'users_without_archiving' has been set to 'Y'.
  *
  * @see users/configure.php
  *
  * Tags can be provided either as a string of keywords separated by commas,
  * or as an array of strings.
  *
  * @param string a reference to the published material (e.g., 'article:12')
  * @param string the publication date and time, if any
  * @param mixed a list of related tags, if any
  *
  * @see articles/articles.php
  * @see categories/check.php
  * @see services/blog.php
  */
 public static function remember($reference, $stamp = NULL, $tags = NULL)
 {
     global $context;
     // if automatic archiving has not been disabled
     if (!isset($context['users_without_archiving']) || $context['users_without_archiving'] != 'Y') {
         // if the stamp has a value, this is a valid publication
         if (is_string($stamp) && $stamp > NULL_DATE && ($stamp = strtotime($stamp)) && ($stamp = getdate($stamp))) {
             // weeks are starting on Monday
             $week = mktime(0, 0, 0, $stamp['mon'], $stamp['mday'] - $stamp['wday'] + 1, $stamp['year']);
             // create the category for this week if it does not exist
             if (!($category = Categories::lookup('week ' . date('y/m/d', $week))) && ($anchor = Categories::get(i18n::c('weekly')))) {
                 $fields = array();
                 $fields['anchor'] = 'category:' . $anchor['id'];
                 $fields['nick_name'] = 'week ' . date('y/m/d', $week);
                 $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $week);
                 $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $week);
                 $fields['title'] = sprintf(i18n::c('Week of&nbsp;%s'), date(i18n::c('m/d/y'), $week));
                 $fields['options'] = 'no_links';
                 if ($fields['id'] = Categories::post($fields)) {
                     Categories::clear($fields);
                     $category = 'category:' . $fields['id'];
                 }
             }
             // link the reference to this weekly category
             if ($category) {
                 Members::assign($category, $reference);
             }
             // months are starting on day 1
             $month = mktime(0, 0, 0, $stamp['mon'], 1, $stamp['year']);
             // create the category for this month if it does not exist
             if (!($category = Categories::lookup('month ' . date('M Y', $month))) && ($anchor = Categories::get(i18n::c('monthly')))) {
                 $fields = array();
                 $fields['anchor'] = 'category:' . $anchor['id'];
                 $fields['nick_name'] = 'month ' . date('M Y', $month);
                 $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $month);
                 $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $month);
                 $fields['title'] = Skin::build_date($month, 'month', $context['preferred_language']);
                 $fields['options'] = 'no_links';
                 if ($fields['id'] = Categories::post($fields)) {
                     Categories::clear($fields);
                     $category = 'category:' . $fields['id'];
                 }
             }
             // link the reference to this monthly category
             if ($category) {
                 Members::assign($category, $reference);
             }
         }
     }
     // link to selected categories --do not accept ; as separator, because this conflicts with UTF-8 encoding
     if (is_string($tags) && $tags) {
         $tags = preg_split('/[ \\t]*,\\s*/', $tags);
     }
     if (is_array($tags) && count($tags)) {
         // create a category to host keywords, if none exists
         if (!($root_category = Categories::lookup('keywords'))) {
             $fields = array();
             $fields['nick_name'] = 'keywords';
             $fields['title'] = i18n::c('Keywords');
             $fields['introduction'] = i18n::c('Classified pages');
             $fields['description'] = i18n::c('This category is a specialized glossary of terms, made out of tags added to pages, and out of search requests.');
             $fields['rank'] = 29000;
             $fields['options'] = 'no_links';
             if ($fields['id'] = Categories::post($fields)) {
                 Categories::clear($fields);
                 $root_category = 'category:' . $fields['id'];
             }
         }
         // one category per tag
         $assigned = array();
         foreach ($tags as $title) {
             // create a category if tag is unknown
             if (!($category =& Categories::get_by_keyword($title))) {
                 $fields = array();
                 $fields['title'] = ucfirst($title);
                 $fields['keywords'] = $title;
                 if ($root_category) {
                     $fields['anchor'] = $root_category;
                 }
                 if ($fields['id'] = Categories::post($fields)) {
                     Categories::clear($fields);
                     $category = 'category:' . $fields['id'];
                 }
             } else {
                 $category = 'category:' . $category['id'];
             }
             // link page to the category
             if ($category) {
                 Members::assign($category, $reference);
                 $assigned[] = $category;
             }
         }
         // back to a string representation
         $tags = join(', ', $tags);
         // clean assignments for removed tags
         // the list of members
         $query = "SELECT anchor FROM " . SQL::table_name('members') . " WHERE (member LIKE '" . SQL::escape($reference) . "') AND (anchor LIKE 'category:%')" . " LIMIT 0, 500";
         if ($result = SQL::query($query)) {
             while ($row = SQL::fetch($result)) {
                 if (in_array($row['anchor'], $assigned)) {
                     continue;
                 }
                 // assigned, and a keyword exists, but not in the string of tags
                 if (($category = Anchors::get($row['anchor'])) && ($keywords = $category->get_value('keywords')) && stripos($tags, $keywords) === FALSE) {
                     Members::free($row['anchor'], $reference);
                 }
             }
         }
     }
 }