当前位置: 首页>>代码示例>>PHP>>正文


PHP Members::assign方法代码示例

本文整理汇总了PHP中Members::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP Members::assign方法的具体用法?PHP Members::assign怎么用?PHP Members::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Members的用法示例。


在下文中一共展示了Members::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: touch


//.........这里部分代码省略.........
             }
             if ($url = Images::get_thumbnail_href($image)) {
                 if ($this->item['icon_url'] == $url) {
                     $query[] = "icon_url = ''";
                 }
                 if ($this->item['thumbnail_url'] == $url) {
                     $query[] = "thumbnail_url = ''";
                 }
             }
         }
         // set an existing image as the article icon
     } elseif ($action == 'image:set_as_icon' && $origin) {
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_icon_href($image)) {
                 $query[] = "icon_url = '" . SQL::escape($url) . "'";
             }
             // also use it as thumnail if none has been defined yet
             if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         }
         // set an existing image as the article thumbnail
     } elseif ($action == 'image:set_as_thumbnail' && $origin) {
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             // use the thumbnail for large files, or the image itself for smaller files
             if ($image['image_size'] > $context['thumbnail_threshold']) {
                 $url = Images::get_thumbnail_href($image);
             } else {
                 $url = Images::get_icon_href($image);
             }
             $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
         } elseif ($origin) {
             $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
         }
         // do not remember minor changes
         $silently = TRUE;
         // append a new image, and set it as the article thumbnail
     } elseif ($action == 'image:set_as_both' && $origin) {
         if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
         }
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             // use the thumbnail for large files, or the image itself for smaller files
             if ($image['image_size'] > $context['thumbnail_threshold']) {
                 $url = Images::get_thumbnail_href($image);
             } else {
                 $url = Images::get_icon_href($image);
             }
             $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
         } elseif ($origin) {
             $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
         }
         // do not remember minor changes
         $silently = TRUE;
         // add a reference to a location in the article description
     } elseif ($action == 'location:create' && $origin) {
         if (!Codes::check_embedded($this->item['description'], 'location', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' [location=' . $origin . ']') . "'";
         }
         // suppress a reference to a location that has been deleted
     } elseif ($action == 'location:delete' && $origin) {
         $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'location', $origin)) . "'";
         // add a reference to a new table in the article description
     } elseif ($action == 'table:create' && $origin) {
         if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . "\n" . '[table=' . $origin . ']' . "\n") . "'";
         }
         // suppress a reference to a table that has been deleted
     } elseif ($action == 'table:delete' && $origin) {
         $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'table', $origin)) . "'";
     }
     // stamp the update
     if (!$silently) {
         $query[] = "edit_name='" . SQL::escape(Surfer::get_name()) . "'," . "edit_id=" . SQL::escape(Surfer::get_id()) . "," . "edit_address='" . SQL::escape(Surfer::get_email_address()) . "'," . "edit_action='" . SQL::escape($action) . "'," . "edit_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'";
     }
     // update the database
     if (count($query)) {
         $query = "UPDATE " . SQL::table_name('articles') . " SET " . implode(', ', $query) . " WHERE id = " . SQL::escape($this->item['id']);
         SQL::query($query);
     }
     // add this page to the watch list of the contributor, on any action
     if (Surfer::get_id()) {
         Members::assign('article:' . $this->item['id'], 'user:' . Surfer::get_id());
     }
     // surfer is visiting this page
     Surfer::is_visiting($this->get_url(), $this->get_title(), 'article:' . $this->item['id'], $this->item['active']);
     // always clear the cache, even on no update
     Articles::clear($this->item);
     // get the parent
     if (!$this->anchor) {
         $this->anchor = Anchors::get($this->item['anchor']);
     }
     // propagate the touch upwards
     if (is_object($this->anchor)) {
         $this->anchor->touch('article:update', $this->item['id'], TRUE);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:article.php

示例2: array

 // create a new page
 if ($item['id'] = Articles::post($item)) {
     // also duplicate the provided overlay, if any -- re-use 'overlay_type' only
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // post an overlay, with the new article id
     if (is_object($overlay)) {
         $overlay->remember('insert', $item, 'article:' . $item['id']);
     }
     // duplicate all related items, images, etc.
     Anchors::duplicate_related_to($original_anchor, 'article:' . $item['id']);
     // if poster is a registered user
     if (Surfer::get_id()) {
         // increment the post counter of the surfer
         Users::increment_posts(Surfer::get_id());
         // add this page to watch list
         Members::assign('article:' . $item['id'], 'user:' . Surfer::get_id());
     }
     // get the new item
     $article = Anchors::get('article:' . $item['id'], TRUE);
     $context['page_title'] = i18n::s('Thank you for your contribution');
     // the page has been duplicated
     $context['text'] .= '<p>' . i18n::s('The page has been duplicated.') . '</p>';
     // follow-up commands
     $follow_up = i18n::s('What do you want to do now?');
     $menu = array();
     $menu = array_merge($menu, array($article->get_url() => i18n::s('View the page')));
     $menu = array_merge($menu, array($article->get_url('edit') => i18n::s('Edit the page')));
     if (Surfer::may_upload()) {
         $menu = array_merge($menu, array('images/edit.php?anchor=' . urlencode($article->get_reference()) => i18n::s('Add an image')));
         $menu = array_merge($menu, array('files/edit.php?anchor=' . urlencode($article->get_reference()) => i18n::s('Add a file')));
     }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:duplicate.php

示例3: post


//.........这里部分代码省略.........
         $fields['activation_date'] = NULL_DATE;
     }
     if (!isset($fields['create_date']) || $fields['create_date'] <= NULL_DATE) {
         $fields['create_date'] = $fields['edit_date'];
     }
     if (!isset($fields['expiry_date']) || $fields['expiry_date'] <= NULL_DATE) {
         $fields['expiry_date'] = NULL_DATE;
     }
     if (!isset($fields['publish_date']) || $fields['publish_date'] <= NULL_DATE) {
         $fields['publish_date'] = NULL_DATE;
     }
     // set conservative default values
     if (!isset($fields['active_set'])) {
         $fields['active_set'] = 'Y';
     }
     if (isset($fields['edit_action'])) {
         $fields['edit_action'] = preg_replace('/import$/i', 'update', $fields['edit_action']);
     }
     if (!isset($fields['home_panel']) || !$fields['home_panel']) {
         $fields['home_panel'] = 'main';
     }
     if (!isset($fields['index_map']) || !$fields['index_map']) {
         $fields['index_map'] = 'Y';
     }
     if (!isset($fields['index_news']) || !$fields['index_news']) {
         $fields['index_news'] = 'none';
     }
     // save on requests
     if (!isset($fields['rank']) || !$fields['rank']) {
         $fields['rank'] = 10000;
     }
     // set layout for sections
     if (!isset($fields['sections_layout']) || !$fields['sections_layout'] || !preg_match('/^(accordion|carrousel|compact|custom|decorated|directory|folded|inline|jive|map|slashdot|tabs|titles|yabb|none)$/', $fields['sections_layout'])) {
         $fields['sections_layout'] = 'none';
     } elseif ($fields['sections_layout'] == 'custom') {
         if (isset($fields['sections_custom_layout']) && $fields['sections_custom_layout']) {
             $fields['sections_layout'] = $fields['sections_custom_layout'];
         } else {
             $fields['sections_layout'] = 'none';
         }
     }
     // set layout for articles
     if (!isset($fields['articles_layout']) || !$fields['articles_layout'] || !preg_match('/^(accordion|alistapart|carrousel|custom|compact|daily|decorated|digg|directory|hardboiled|jive|map|newspaper|none|simile|slashdot|table|tabs|tagged|threads|titles|yabb)$/', $fields['articles_layout'])) {
         $fields['articles_layout'] = 'decorated';
     } elseif ($fields['articles_layout'] == 'custom') {
         if (isset($fields['articles_custom_layout']) && $fields['articles_custom_layout']) {
             $fields['articles_layout'] = $fields['articles_custom_layout'];
         } else {
             $fields['articles_layout'] = 'decorated';
         }
     }
     // set canvas for articles
     if (!isset($fields['articles_canvas']) || !$fields['articles_canvas']) {
         $fields['articles_canvas'] = 'standard';
     }
     // clean provided tags
     if (isset($fields['tags'])) {
         $fields['tags'] = trim($fields['tags'], " \t.:,!?");
     }
     // cascade anchor access rights
     if (isset($fields['anchor']) && ($anchor = Anchors::get($fields['anchor']))) {
         $fields['active'] = $anchor->ceil_rights($fields['active_set']);
     } else {
         $fields['active'] = $fields['active_set'];
     }
     // always create a random handle for this section
     if (!isset($fields['handle']) || strlen($fields['handle']) < 32) {
         $fields['handle'] = md5(mt_rand());
     }
     $handle = "handle='" . SQL::escape($fields['handle']) . "',";
     // allow anonymous surfer to access this section during his session
     if (!Surfer::get_id()) {
         Surfer::add_handle($fields['handle']);
     }
     // insert a new record
     $query = "INSERT INTO " . SQL::table_name('sections') . " SET ";
     // on import
     if (isset($fields['id'])) {
         $query .= "id='" . SQL::escape($fields['id']) . "',";
     }
     // all fields should be visible
     $query .= "anchor='" . SQL::escape(isset($fields['anchor']) ? $fields['anchor'] : '') . "'," . "activation_date='" . SQL::escape($fields['activation_date']) . "'," . "active='" . SQL::escape($fields['active']) . "'," . "active_set='" . SQL::escape($fields['active_set']) . "'," . "articles_canvas='" . SQL::escape(isset($fields['articles_canvas']) ? $fields['articles_canvas'] : 'null') . "'," . "articles_layout='" . SQL::escape(isset($fields['articles_layout']) ? $fields['articles_layout'] : 'decorated') . "'," . "articles_templates='" . SQL::escape(isset($fields['articles_templates']) ? $fields['articles_templates'] : '') . "'," . "behaviors='" . SQL::escape(isset($fields['behaviors']) ? $fields['behaviors'] : '') . "'," . "content_options='" . SQL::escape(isset($fields['content_options']) ? $fields['content_options'] : '') . "'," . "content_overlay='" . SQL::escape(isset($fields['content_overlay']) ? $fields['content_overlay'] : '') . "'," . "create_address='" . SQL::escape(isset($fields['create_address']) ? $fields['create_address'] : $fields['edit_address']) . "', " . "create_date='" . SQL::escape($fields['create_date']) . "'," . "create_id=" . SQL::escape(isset($fields['create_id']) ? $fields['create_id'] : $fields['edit_id']) . ", " . "create_name='" . SQL::escape(isset($fields['create_name']) ? $fields['create_name'] : $fields['edit_name']) . "', " . "description='" . SQL::escape(isset($fields['description']) ? $fields['description'] : '') . "'," . "edit_action='" . SQL::escape(isset($fields['edit_action']) ? $fields['edit_action'] : 'section:create') . "', " . "edit_address='" . SQL::escape($fields['edit_address']) . "', " . "edit_date='" . SQL::escape($fields['edit_date']) . "'," . "edit_id=" . SQL::escape($fields['edit_id']) . ", " . "edit_name='" . SQL::escape($fields['edit_name']) . "', " . "expiry_date='" . SQL::escape($fields['expiry_date']) . "'," . "extra='" . SQL::escape(isset($fields['extra']) ? $fields['extra'] : '') . "'," . "family='" . SQL::escape(isset($fields['family']) ? $fields['family'] : '') . "'," . "file_overlay='" . SQL::escape(isset($fields['file_overlay']) ? $fields['file_overlay'] : '') . "'," . $handle . "hits=" . SQL::escape(isset($fields['hits']) ? $fields['hits'] : 0) . "," . "home_panel='" . SQL::escape(isset($fields['home_panel']) ? $fields['home_panel'] : 'main') . "'," . "icon_url='" . SQL::escape(isset($fields['icon_url']) ? $fields['icon_url'] : '') . "'," . "index_map='" . SQL::escape(isset($fields['index_map']) ? $fields['index_map'] : 'Y') . "'," . "index_news='" . SQL::escape(isset($fields['index_news']) ? $fields['index_news'] : 'static') . "'," . "index_news_count=" . SQL::escape(isset($fields['index_news_count']) ? $fields['index_news_count'] : 5) . "," . "index_title='" . SQL::escape(isset($fields['index_title']) ? $fields['index_title'] : '') . "'," . "introduction='" . SQL::escape(isset($fields['introduction']) ? $fields['introduction'] : '') . "'," . "language='" . SQL::escape(isset($fields['language']) ? $fields['language'] : '') . "'," . "locked='" . SQL::escape(isset($fields['locked']) ? $fields['locked'] : 'N') . "'," . "meta='" . SQL::escape(isset($fields['meta']) ? $fields['meta'] : '') . "'," . "nick_name='" . SQL::escape(isset($fields['nick_name']) ? $fields['nick_name'] : '') . "'," . "options='" . SQL::escape(isset($fields['options']) ? $fields['options'] : '') . "'," . "overlay='" . SQL::escape(isset($fields['overlay']) ? $fields['overlay'] : '') . "'," . "overlay_id='" . SQL::escape(isset($fields['overlay_id']) ? $fields['overlay_id'] : '') . "'," . "owner_id=" . SQL::escape(isset($fields['create_id']) ? $fields['create_id'] : $fields['edit_id']) . ", " . "prefix='" . SQL::escape(isset($fields['prefix']) ? $fields['prefix'] : '') . "'," . "rank='" . SQL::escape(isset($fields['rank']) ? $fields['rank'] : 10000) . "'," . "section_overlay='" . SQL::escape(isset($fields['section_overlay']) ? $fields['section_overlay'] : '') . "'," . "sections_layout='" . SQL::escape(isset($fields['sections_layout']) ? $fields['sections_layout'] : 'map') . "'," . "suffix='" . SQL::escape(isset($fields['suffix']) ? $fields['suffix'] : '') . "'," . "tags='" . SQL::escape(isset($fields['tags']) ? $fields['tags'] : '') . "'," . "template='" . SQL::escape(isset($fields['template']) ? $fields['template'] : '') . "'," . "thumbnail_url='" . SQL::escape(isset($fields['thumbnail_url']) ? $fields['thumbnail_url'] : '') . "'," . "title='" . SQL::escape(isset($fields['title']) ? $fields['title'] : '') . "'," . "trailer='" . SQL::escape(isset($fields['trailer']) ? $fields['trailer'] : '') . "'";
     // actual insert
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // remember the id of the new item
     $fields['id'] = SQL::get_last_id($context['connection']);
     // assign the page to related categories
     Categories::remember('section:' . $fields['id'], NULL_DATE, isset($fields['tags']) ? $fields['tags'] : '');
     // turn author to page editor and update author's watch list
     if ($watch && isset($fields['edit_id']) && $fields['edit_id']) {
         Members::assign('user:' . $fields['edit_id'], 'section:' . $fields['id']);
         Members::assign('section:' . $fields['id'], 'user:' . $fields['edit_id']);
     }
     // clear the cache
     Sections::clear($fields);
     // return the id of the new item
     return $fields['id'];
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:sections.php

示例4: join_meeting

 /**
  * remember that surfer is joining a meeting
  *
  */
 function join_meeting()
 {
     global $context;
     // sanity check
     if (!is_callable(array($this->anchor, 'get_reference'))) {
         return;
     }
     // create a comment only on first join, and if not a robot, and if comments are allowed
     if (!isset($_SESSION['event_' . $this->anchor->get_reference()]) && !Surfer::is_crawler() && !$this->anchor->has_option('no_comments')) {
         // track the new participant
         include_once $context['path_to_root'] . 'comments/comments.php';
         $fields = array();
         $fields['anchor'] = $this->anchor->get_reference();
         $fields['description'] = sprintf(i18n::s('%s has joined the meeting'), Surfer::get_name());
         $fields['type'] = 'notification';
         Comments::post($fields);
     }
     // remember that you joined the event
     $_SESSION['event_' . $this->anchor->get_reference()] = TRUE;
     // additional steps only for authenticated users
     if (!Surfer::get_id()) {
         return;
     }
     // add this page to the watching list of this surfer
     Members::assign($this->anchor->get_reference(), 'user:' . Surfer::get_id());
     // update enrolment
     include_once $context['path_to_root'] . 'shared/enrolments.php';
     enrolments::confirm($this->anchor->get_reference());
 }
开发者ID:rair,项目名称:yacs,代码行数:33,代码来源:event.php

示例5: sprintf

         $fields['create_name'] = $user['full_name'];
         $fields['edit_id'] = $user['id'];
         $fields['edit_name'] = $user['full_name'];
         $fields['owner_id'] = $user['id'];
     }
     if ($id = Articles::post($fields)) {
         $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['nick_name']) . BR . "\n";
         // assign aeditor
         if ($user = Users::get('aeditor')) {
             Members::assign('user:' . $user['id'], 'article:' . $id);
             Members::assign('article:' . $id, 'user:' . $user['id']);
         }
         // assign areader
         if ($user = Users::get('areader')) {
             Members::assign('user:' . $user['id'], 'article:' . $id);
             Members::assign('article:' . $id, 'user:' . $user['id']);
         }
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // sections
 //
 $text .= Skin::build_block(i18n::s('Sections'), 'subtitle');
 // 'files' section
 if (Sections::get('files')) {
     $text .= sprintf(i18n::s('A section "%s" already exists.'), 'files') . BR . "\n";
 } else {
     $fields = array();
     $fields['nick_name'] = 'files';
     $fields['title'] = i18n::c('Files');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:populate.php

示例6: isset

 $section->load_by_content($anchor);
 $anchor = $section;
 $_REQUEST['anchor'] = $anchor->get_reference();
 $_REQUEST['active_set'] = $_REQUEST['active'];
 // do not break home page layout
 $_REQUEST['index_map'] = 'N';
 // display the form on error
 if (!($_REQUEST['id'] = Sections::post($_REQUEST))) {
     $item = $_REQUEST;
     $with_form = TRUE;
     // post-processing
 } else {
     // make the surfer an editor of this section
     Members::assign('user:' . Surfer::get_id(), 'section:' . $_REQUEST['id']);
     // also update its watch list
     Members::assign('section:' . $_REQUEST['id'], 'user:' . Surfer::get_id());
     // touch the related anchor
     if (is_object($anchor)) {
         $anchor->touch('section:create', $_REQUEST['id'], isset($_REQUEST['active']) && $_REQUEST['active'] != 'Y');
     }
     // add content to the new group
     if ($_REQUEST['space_type'] == 'group') {
         // a sticky page to define group rules
         $fields = array();
         $fields['anchor'] = 'section:' . $_REQUEST['id'];
         $fields['description'] = i18n::c('This is the right place to describe ways of working in this group.');
         $fields['locked'] = 'Y';
         // no direct contributions
         $fields['index_map'] = 'N';
         // not mentioned at the home page
         $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:new.php

示例7: sprintf

     $query = "DELETE FROM " . SQL::table_name('enrolments') . " WHERE id = " . SQL::escape($_REQUEST['target']);
     SQL::query($query);
 }
 // validate an application
 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'validate' && isset($_REQUEST['target']) && $_REQUEST['target']) {
     // update enrolment record
     $query = "UPDATE " . SQL::table_name('enrolments') . " SET approved = 'Y' WHERE id = " . SQL::escape($_REQUEST['target']);
     SQL::query($query);
     // list enrolment for this meeting
     $query = "SELECT * FROM " . SQL::table_name('enrolments') . " WHERE id = " . SQL::escape($_REQUEST['target']);
     if (($result = SQL::query_first($query)) && ($user = Users::get($result['user_id']))) {
         // add the page to the watch list
         Members::assign($anchor->get_reference(), 'user:' . $user['id']);
         // ensure that the enrolled person can access private pages
         if ($anchor->is_hidden()) {
             Members::assign('user:' . $user['id'], $anchor->get_reference());
         }
         // confirm enrolment by e-mail
         if ($user['email'] && preg_match(VALID_RECIPIENT, $user['email'])) {
             // use this email address
             if ($user['full_name']) {
                 $recipient = Mailer::encode_recipient($user['email'], $user['full_name']);
             } else {
                 $recipient = Mailer::encode_recipient($user['email'], $user['nick_name']);
             }
             // mail subject
             $subject = sprintf(i18n::c('%s: %s'), i18n::c('Meeting'), strip_tags($anchor->get_title()));
             // headline
             $headline = sprintf(i18n::c('%s has confirmed your participation to %s'), Surfer::get_link(), '<a href="' . $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url() . '">' . $anchor->get_title() . '</a>');
             // message confirmation
             $message = $overlay->get_invite_default_message('PUBLISH');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:enroll.php

示例8: isset

     $way = isset($_REQUEST['way']) ? $_REQUEST['way'] : 'assign';
     // get object interface
     $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']);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:tree_manager_ajax.php

示例9: elseif

    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // do the job
} elseif (!count($context['error'])) {
    // look for the user through his nick name
    if (isset($_REQUEST['assigned_name']) && ($user = Users::get($_REQUEST['assigned_name']))) {
        $_REQUEST['anchor'] = 'user:' . $user['id'];
    }
    // transfer ownership
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set' && isset($_REQUEST['anchor'])) {
        // assign a user, and also update his watch list
        $attributes = array('id' => $item['id'], 'owner_id' => $user['id']);
        Sections::put_attributes($attributes);
        Members::assign($_REQUEST['anchor'], 'section:' . $item['id']);
        Members::assign('section:' . $item['id'], $_REQUEST['anchor']);
        $context['text'] .= '<p>' . sprintf(i18n::s('Current owner is %s'), Users::get_link($user['full_name'], $user['email'], $user['id'])) . '</p>';
        // name current owner
    } elseif (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) {
        $context['text'] .= '<p>' . sprintf(i18n::s('Current owner is %s'), Users::get_link($owner['full_name'], $owner['email'], $owner['id'])) . '</p>';
    }
    // delegate to another person
    $context['text'] .= '<p style="margin-top: 2em;">' . i18n::s('To transfer ownership to another person, type some letters of the name you are looking for.') . '</p>';
    // the form to link additional users
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . '<input type="text" name="assigned_name" id="assigned_name" size="45" maxlength="255" />' . '<input type="hidden" name="id" value="' . encode_field($item['id']) . '" />' . '<input type="hidden" name="action" value="set" />' . ' <input type="submit" id="submit_button" value="' . i18n::s('Submit') . '" style="display: none;" />' . '</p></form>' . "\n";
    // enable autocompletion
    Page::insert_script('$(function() {' . "\n" . '	$("#name").focus();' . "\n" . '	Yacs.autocomplete_names("assigned_name",true, "", function(data) { $("#submit_button").show().click(); });' . "\n" . '});' . "\n");
    // back to the anchor page
    $links = array();
    $links[] = Skin::build_link(Sections::get_permalink($item) . '#_users', i18n::s('Done'), 'button');
    $context['text'] .= Skin::finalize_list($links, 'assistant_bar');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:own.php

示例10: foreach

 // feed-back to surfer
 // $context['text'] .= '<p>'.i18n::s('A new thread has been created, and it will be listed in profiles of the persons that you have involved. You can invite additional people later on if you wish.').'</p>';
 // increment the post counter of the surfer
 Users::increment_posts(Surfer::get_id());
 // make editors of the new page
 Members::assign('user:' . Surfer::get_id(), 'article:' . $article['id']);
 foreach ($items as $item) {
     if (isset($item['id'])) {
         Members::assign('user:' . $item['id'], 'article:' . $article['id']);
     }
 }
 // add this page to watch lists
 Members::assign('article:' . $article['id'], 'user:' . Surfer::get_id());
 foreach ($items as $item) {
     if (isset($item['id'])) {
         Members::assign('article:' . $article['id'], 'user:' . $item['id']);
     }
 }
 // email has to be activated
 if (isset($context['with_email']) && $context['with_email'] == 'Y') {
     // contact target user by e-mail
     $mail = array();
     $mail['subject'] = sprintf(i18n::c('Private message: %s'), strip_tags($article['title']));
     $mail['message'] = Articles::build_notification('message', $article, $overlay);
     // enable threading
     $mail['headers'] = Mailer::set_thread('article:' . $article['id'], $anchor);
     // each recipient, one at a time
     foreach ($items as $item) {
         // you cannot write to yourself
         if (isset($item['id']) && Surfer::get_id() == $item['id']) {
             continue;
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:contact.php

示例11: elseif

} elseif (!($articles = Articles::search($search, 1.0, 50, 'raw'))) {
    Logger::error(i18n::s('No item has been found.'));
    // create a category for this keyword if none exists yet
} elseif (!($category =& Categories::get_by_keyword($search))) {
    $fields = array();
    $fields['keywords'] = $search;
    $fields['anchor'] = $root_category;
    $fields['title'] = ucfirst($search);
    if ($fields['id'] = Categories::post($fields)) {
        Categories::clear($fields);
        $category = Categories::get($fields['id']);
    }
}
// ensure we have a valid category for found articles
if (isset($articles) && (!isset($category) || !$category)) {
    Logger::error(i18n::s('No item has been found.'));
} elseif (isset($articles) && is_array($articles)) {
    foreach ($articles as $id => $not_used) {
        if (!Members::assign('category:' . $category['id'], 'article:' . $id)) {
            break;
        }
    }
    // redirect to the updated category, if no error has happened
    if (!count($context['error'])) {
        Safe::redirect(Categories::get_permalink($category));
    }
}
// failed operation
$context['text'] .= '<p>' . i18n::s('Impossible to update the item.') . '</p>';
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:set_keyword.php

示例12: sprintf

     }
     // report on results
     $context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been associated with %s.', '%d pages have been associated with %s.', $count), $count, Skin::build_link($destination->get_url(), $destination->get_title(), 'category')) . '</p>';
     // follow-up commands
     $follow_up = i18n::s('What do you want to do now?');
     $menu = array();
     $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
     $menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
     $follow_up .= Skin::finalize_list($menu, 'menu_bar');
     $context['text'] .= Skin::build_block($follow_up, 'bottom');
     // sections
 } elseif (isset($_REQUEST['selected_sections'])) {
     // do it, and clear the cache
     $count = 0;
     foreach ($_REQUEST['selected_sections'] as $dummy => $id) {
         if (Members::assign($_REQUEST['associate_to'], 'section:' . $id)) {
             $count++;
         }
     }
     // report on results
     $context['text'] .= '<p>' . sprintf(i18n::ns('%d section has been associated with %s.', '%d sections have been associated with %s.', $count), $count, Skin::build_link($destination->get_url(), $destination->get_title(), 'category')) . '</p>';
     // follow-up commands
     $follow_up = i18n::s('What do you want to do now?');
     $menu = array();
     $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
     $menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
     $follow_up .= Skin::finalize_list($menu, 'menu_bar');
     $context['text'] .= Skin::build_block($follow_up, 'bottom');
     // nothing to do
 } else {
     Logger::error(i18n::s('No page has been selected.'));
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:manage.php

示例13: elseif

             Members::assign($_REQUEST['anchor'], $_REQUEST['member']);
         }
     }
     // set editor
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set' && isset($_REQUEST['editor']) && isset($_REQUEST['member'])) {
     Members::assign($_REQUEST['editor'], $_REQUEST['member']);
     // reset editor
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset' && isset($_REQUEST['editor']) && isset($_REQUEST['member'])) {
     Members::free($_REQUEST['editor'], $_REQUEST['member']);
     // purge watch list too
     if ($anchor->is_hidden()) {
         Members::free($_REQUEST['member'], $_REQUEST['editor']);
     }
     // set watcher
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set' && isset($_REQUEST['watcher']) && isset($_REQUEST['member'])) {
     Members::assign($_REQUEST['member'], $_REQUEST['watcher']);
     // reset watcher
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset' && isset($_REQUEST['watcher']) && isset($_REQUEST['member'])) {
     Members::free($_REQUEST['member'], $_REQUEST['watcher']);
     // break an assignment
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset' && isset($_REQUEST['anchor']) && isset($_REQUEST['member'])) {
     Members::free($_REQUEST['anchor'], $_REQUEST['member']);
     // following links between users are not symmetrical
     if (!preg_match('/^user:/', $_REQUEST['member'])) {
         Members::free($_REQUEST['member'], $_REQUEST['anchor']);
     }
 }
 // the form to link additional users
 $form = '<form method="post" action="' . $context['script_url'] . '" id="main_form">';
 // horizontal layout
 $cells = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select.php

示例14: remember

 /**
  * remember an action once it's done
  *
  * This function saves data into the table [code]yacs_issues[/code].
  *
  * @see overlays/overlay.php
  *
  * @param string the action 'insert', 'update' or 'delete'
  * @param array the hosting record
  * @param string reference of the hosting record (e.g., 'article:123')
  * @return FALSE on error, TRUE otherwise
  */
 function remember($action, $host, $reference)
 {
     global $context;
     // locate anchor on 'insert'
     if ($reference) {
         $this->anchor = Anchors::get($reference);
     }
     // remember data from the anchor
     $this->attributes['anchor_reference'] = '';
     $this->attributes['anchor_title'] = '';
     $this->attributes['anchor_url'] = '';
     if (is_callable(array($this->anchor, 'get_url'))) {
         $this->attributes['anchor_reference'] = $this->anchor->get_reference();
         $this->attributes['anchor_title'] = $this->anchor->get_title();
         $this->attributes['anchor_url'] = $this->anchor->get_url();
     }
     // set default values for this editor
     Surfer::check_default_editor($this->attributes);
     // default date values
     if (!isset($this->attributes['create_date']) || $this->attributes['create_date'] <= NULL_DATE) {
         $this->attributes['create_date'] = $this->attributes['edit_date'];
     }
     if (!isset($this->attributes['qualification_date']) || $this->attributes['qualification_date'] <= NULL_DATE) {
         $this->attributes['qualification_date'] = NULL_DATE;
     }
     if (!isset($this->attributes['analysis_date']) || $this->attributes['analysis_date'] <= NULL_DATE) {
         $this->attributes['analysis_date'] = NULL_DATE;
     }
     if (!isset($this->attributes['resolution_date']) || $this->attributes['resolution_date'] <= NULL_DATE) {
         $this->attributes['resolution_date'] = NULL_DATE;
     }
     if (!isset($this->attributes['close_date']) || $this->attributes['close_date'] <= NULL_DATE) {
         $this->attributes['close_date'] = NULL_DATE;
     }
     // add a notification to the anchor page
     $comments = array();
     // build the update query
     switch ($action) {
         case 'delete':
             $query = "DELETE FROM " . SQL::table_name('issues') . " WHERE anchor LIKE '" . $this->attributes['anchor_reference'] . "'";
             break;
         case 'insert':
             $comments[] = i18n::s('Page has been created');
             // set host owner, if any
             if (isset($this->attributes['owner']) && ($user = Users::get($this->attributes['owner'])) && $user['id'] != Surfer::get_id()) {
                 $fields = array();
                 $fields['owner_id'] = $user['id'];
                 $this->anchor->set_values($fields);
                 Members::assign('user:' . $user['id'], $this->anchor->get_reference());
                 Members::assign($this->anchor->get_reference(), 'user:' . $user['id']);
                 $comments[] = sprintf(i18n::s('Owner has been changed to %s'), Skin::build_link(Users::get_permalink($user), $user['full_name']));
             }
             $query = "INSERT INTO " . SQL::table_name('issues') . " SET \n" . "anchor='" . SQL::escape($this->attributes['anchor_reference']) . "', \n" . "anchor_url='" . SQL::escape($this->attributes['anchor_url']) . "', \n" . "color='" . SQL::escape(isset($this->attributes['color']) ? $this->attributes['color'] : 'green') . "', \n" . "status='" . SQL::escape(isset($this->attributes['status']) ? $this->attributes['status'] : 'on-going:suspect') . "', \n" . "title='" . SQL::escape($this->attributes['anchor_title']) . "', \n" . "type='" . SQL::escape(isset($this->attributes['type']) ? $this->attributes['type'] : 'incident') . "', \n" . "create_name='" . SQL::escape(isset($this->attributes['create_name']) ? $this->attributes['create_name'] : $this->attributes['edit_name']) . "', \n" . "create_id=" . SQL::escape(isset($this->attributes['create_id']) ? $this->attributes['create_id'] : $this->attributes['edit_id']) . ", \n" . "create_address='" . SQL::escape(isset($this->attributes['create_address']) ? $this->attributes['create_address'] : $this->attributes['edit_address']) . "', \n" . "create_date='" . SQL::escape(isset($this->attributes['create_date']) ? $this->attributes['create_date'] : $this->attributes['edit_date']) . "', \n" . "edit_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "edit_id=" . SQL::escape($this->attributes['edit_id']) . ", \n" . "edit_address='" . SQL::escape($this->attributes['edit_address']) . "', \n" . "edit_action='create', \n" . "edit_date='" . SQL::escape($this->attributes['edit_date']) . "', \n" . "qualification_date='" . SQL::escape(isset($this->attributes['qualification_date']) ? $this->attributes['qualification_date'] : NULL_DATE) . "', \n" . "analysis_date='" . SQL::escape(isset($this->attributes['analysis_date']) ? $this->attributes['analysis_date'] : NULL_DATE) . "', \n" . "resolution_date='" . SQL::escape(isset($this->attributes['resolution_date']) ? $this->attributes['resolution_date'] : NULL_DATE) . "', \n" . "close_date='" . SQL::escape(isset($this->attributes['close_date']) ? $this->attributes['close_date'] : NULL_DATE) . "'";
             break;
         case 'update':
             // only associates and page owners can update the record
             if (is_callable(array($this->anchor, 'is_owned')) && $this->anchor->is_owned()) {
                 // detect type modification
                 if ($this->attributes['type'] != $this->snapshot['type']) {
                     $comments[] = sprintf(i18n::s('Workflow has been changed to "%s"'), $this->get_type_label($this->attributes['type']));
                 }
                 // detect color modification
                 if ($this->attributes['color'] != $this->snapshot['color']) {
                     $comments[] = $this->get_color_label($this->attributes['color']);
                 }
                 // change host owner, if any
                 if ($this->attributes['owner'] && ($user = Users::get($this->attributes['owner'])) && $user['id'] != $this->anchor->get_value('owner_id')) {
                     $fields = array();
                     $fields['owner_id'] = $user['id'];
                     $this->anchor->set_values($fields);
                     Members::assign('user:' . $user['id'], $this->anchor->get_reference());
                     Members::assign($this->anchor->get_reference(), 'user:' . $user['id']);
                     $comments[] = sprintf(i18n::s('Owner has been changed to %s'), Skin::build_link(Users::get_permalink($user), $user['full_name']));
                 }
                 // update the table of issues
                 $query = "UPDATE " . SQL::table_name('issues') . " SET \n" . "anchor='" . SQL::escape($this->attributes['anchor_reference']) . "', \n" . "anchor_url='" . SQL::escape($this->attributes['anchor_url']) . "', \n" . "color='" . SQL::escape($this->attributes['color']) . "', \n" . "status='" . SQL::escape($this->attributes['status']) . "', \n" . "title='" . SQL::escape($this->attributes['anchor_title']) . "', \n" . "type='" . SQL::escape($this->attributes['type']) . "', \n" . "create_date='" . SQL::escape(isset($this->attributes['create_date']) ? $this->attributes['create_date'] : $this->attributes['edit_date']) . "', \n" . "qualification_date='" . SQL::escape(isset($this->attributes['qualification_date']) ? $this->attributes['qualification_date'] : NULL_DATE) . "', \n" . "analysis_date='" . SQL::escape(isset($this->attributes['analysis_date']) ? $this->attributes['analysis_date'] : NULL_DATE) . "', \n" . "resolution_date='" . SQL::escape(isset($this->attributes['resolution_date']) ? $this->attributes['resolution_date'] : NULL_DATE) . "', \n" . "close_date='" . SQL::escape(isset($this->attributes['close_date']) ? $this->attributes['close_date'] : NULL_DATE) . "', \n";
                 // detect status modification
                 if ($this->attributes['status'] != $this->snapshot['status']) {
                     $comments[] = $this->get_status_label($this->attributes['status']);
                     // depending of new status
                     switch ($this->attributes['status']) {
                         // case has been recorded --should not happen
                         case 'on-going:suspect':
                             $query .= "create_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "create_id=" . SQL::escape($this->attributes['edit_id']) . ", \n" . "create_address='" . SQL::escape($this->attributes['edit_address']) . "', \n";
                             break;
                             // problem has been validated
                         // problem has been validated
                         case 'cancelled:suspect':
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:issue.php

示例15: trim

 // clean the provided string
 $recipient = trim(str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $recipient));
 // look for a user with this nick name
 if (!($user = Users::lookup($recipient))) {
     // skip this recipient
     if ($recipient) {
         Logger::error(sprintf(i18n::s('Error while sending the message to %s'), $recipient));
     }
     continue;
 }
 // make this user an editor of the target item
 if ($item['active'] == 'N' || Sections::is_owned($item, $anchor, TRUE) && isset($_REQUEST['provide_credentials']) && $_REQUEST['provide_credentials'] == 'Y') {
     Members::assign('user:' . $user['id'], 'section:' . $item['id']);
 }
 // always add the item to the watch list
 Members::assign('section:' . $item['id'], 'user:' . $user['id']);
 // propagate the invitation to the overlay, if applicable
 if (is_callable(array($overlay, 'invite'))) {
     $overlay->invite($user['id']);
 }
 // this person has no valid email address
 if (!$user['email'] || !preg_match(VALID_RECIPIENT, $user['email'])) {
     continue;
 }
 // use this email address
 if ($user['full_name']) {
     $recipient = Mailer::encode_recipient($user['email'], $user['full_name']);
 } else {
     $recipient = Mailer::encode_recipient($user['email'], $user['nick_name']);
 }
 // headline
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:invite.php


注:本文中的Members::assign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。