本文整理汇总了PHP中Articles::is_assigned方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::is_assigned方法的具体用法?PHP Articles::is_assigned怎么用?PHP Articles::is_assigned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::is_assigned方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: allow_creation
/**
* check if new links can be added
*
* This function returns TRUE if links can be added to some place,
* and FALSE otherwise.
*
* @param object an instance of the Anchor interface, if any
* @param array a set of item attributes, if any
* @param string the type of item, e.g., 'section'
* @return boolean TRUE or FALSE
*/
public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
{
global $context;
// backward compatibility, reverse parameters :
// $anchor is always a object and $item a array
if (is_object($item) || is_array($anchor)) {
$permute = $anchor;
$anchor = $item;
$item = $permute;
}
// guess the variant
if (!$variant) {
// most frequent case
if (isset($item['id'])) {
$variant = 'article';
} elseif (is_object($anchor)) {
$variant = $anchor->get_type();
} else {
return FALSE;
}
}
// only in articles
if ($variant == 'article') {
// 'no_links' option
if (Articles::has_option('no_links', $anchor, $item)) {
return FALSE;
}
// other containers
} else {
// links have to be activated
if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bwith_links\\b/i', $item['options'])) {
} elseif (!isset($item['id']) && is_object($anchor) && $anchor->has_option('with_links', FALSE)) {
} else {
return FALSE;
}
}
// surfer is an associate
if (Surfer::is_associate()) {
return TRUE;
}
// submissions have been disallowed
if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
return FALSE;
}
// only in articles
if ($variant == 'article') {
// surfer owns this item, or the anchor
if (Articles::is_owned($item, $anchor)) {
return TRUE;
}
// surfer is an editor, and the page is not private
if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
return TRUE;
}
// only in sections
} elseif ($variant == 'section') {
// surfer owns this item, or the anchor
if (Sections::is_owned($item, $anchor, TRUE)) {
return TRUE;
}
// surfer is an editor, and the section is not private
if (isset($item['active']) && $item['active'] != 'N' && Sections::is_assigned($item['id'])) {
return TRUE;
}
}
// surfer is an editor, and container is not private
if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) {
return TRUE;
}
if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// item has been locked
if (isset($item['locked']) && $item['locked'] == 'Y') {
return FALSE;
}
// anchor has been locked --only used when there is no item provided
if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) {
return FALSE;
}
// surfer is an editor (and item has not been locked)
if ($variant == 'article' && isset($item['id']) && Articles::is_assigned($item['id'])) {
return TRUE;
}
if ($variant == 'section' && isset($item['id']) && Sections::is_assigned($item['id'])) {
return TRUE;
}
if (is_object($anchor) && $anchor->is_assigned()) {
return TRUE;
//.........这里部分代码省略.........
示例2: layout_newest
//.........这里部分代码省略.........
// article rating, if the anchor allows for it
if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
// report on current rating
$label = '';
if ($item['rating_count']) {
$label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
}
$label .= i18n::s('Rate this page');
// allow for rating
$text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
}
// the introduction text, if any
if (is_object($overlay)) {
$text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} else {
$text .= Skin::build_block($item['introduction'], 'introduction');
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('view', $item);
}
// the beautified description, which is the actual page body
if ($item['description']) {
// use adequate label
if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
$text .= Skin::build_block($label, 'title');
}
$text .= Skin::build_block($item['description'], 'description', '', $item['options']);
}
//
// list related files
//
// if this surfer is an editor of this article, show hidden files as well
if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower();
}
// build a complete box
$box['bar'] = array();
$box['text'] = '';
// count the number of files in this article
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
if ($count > 20) {
$box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
}
// list files by date (default) or by title (option files_by_title)
if (Articles::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
} else {
$items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
}
if (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
}
// navigation commands for files
$prefix = Articles::get_url($item['id'], 'navigate', 'files');
$box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0);
// the command to post a new file, if allowed
if (Files::allow_creation($item, $anchor, 'article')) {
$link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
$box['bar'] += array($link => i18n::s('Add a file'));
}
if (is_array($box['bar'])) {
$box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
}
}
// actually render the html for this box
示例3: strip_tags
}
$vote = strip_tags($vote);
// next url
$next = '';
if (isset($_REQUEST['next'])) {
$next = $_REQUEST['next'];
}
if (isset($context['arguments'][2])) {
$next = $context['arguments'][2];
}
$next = strip_tags($next);
//
// is this surfer allowed to browse the resulting page?
//
// associates and editors can do what they want
if (Surfer::is_associate() || Articles::is_assigned($id) || is_object($anchor) && $anchor->is_assigned()) {
$permitted = TRUE;
} elseif (Surfer::get_id() && isset($item['create_id']) && $item['create_id'] == Surfer::get_id()) {
$permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
$permitted = FALSE;
} elseif (isset($item['active']) && $item['active'] == 'R' && Surfer::is_member()) {
$permitted = TRUE;
} elseif (isset($item['active']) && $item['active'] == 'Y') {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// load the skin, maybe with a variant
load_skin('polls', $anchor);
// the path to this page
示例4: allow_modification
/**
* 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;
}
示例5: allow_creation
/**
* check if new files can be added
*
* This function returns TRUE if files can be added to some place,
* and FALSE otherwise.
*
* @param array a set of item attributes, if any
* @param object an instance of the Anchor interface, if any
* @param string the type of item, e.g., 'article' or 'section'
* @return boolean TRUE or FALSE
*/
public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
{
global $context;
// guess the variant
if (!$variant) {
// most frequent case
if (isset($item['id'])) {
$variant = 'article';
} elseif (is_object($anchor)) {
$variant = $anchor->get_type();
} else {
return FALSE;
}
}
// attach a file to an article
if ($variant == 'article') {
// 'no initial upload' option
if (!isset($item['id']) && Articles::has_option('no_initial_upload', $anchor, $item)) {
return FALSE;
}
// 'no files' option
if (Articles::has_option('no_files', $anchor, $item)) {
return FALSE;
}
// attach a file to a user profile
} elseif ($variant == 'user') {
// associates can always proceed
if (Surfer::is_associate()) {
} elseif (!is_object($anchor) || !Surfer::get_id()) {
return FALSE;
} elseif ($anchor->get_reference() != 'user:' . Surfer::get_id()) {
return FALSE;
}
// other containers
} else {
// files have to be activated explicitly
if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bwith_files\\b/i', $item['options'])) {
} elseif (!isset($item['id']) && is_object($anchor) && $anchor->has_option('with_files', FALSE)) {
} else {
return FALSE;
}
}
// surfer is not allowed to upload a file
if (!Surfer::may_upload()) {
return FALSE;
}
// surfer is an associate
if (Surfer::is_associate()) {
return TRUE;
}
// submissions have been disallowed
if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
return FALSE;
}
// only in articles
if ($variant == 'article') {
// surfer owns this item, or the anchor
if (Articles::is_owned($item, $anchor)) {
return TRUE;
}
// surfer is an editor, and the page is not private
if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
return TRUE;
}
// only in sections
} elseif ($variant == 'section') {
// surfer owns this item, or the anchor
if (Sections::is_owned($item, $anchor, TRUE)) {
return TRUE;
}
// surfer is an editor, and the section is not private
if (isset($item['active']) && $item['active'] != 'N' && Sections::is_assigned($item['id'])) {
return TRUE;
}
}
// surfer is an editor, and container is not private
if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) {
return TRUE;
}
if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// item has been locked
if (isset($item['locked']) && $item['locked'] == 'Y') {
return FALSE;
}
// anchor has been locked --only used when there is no item provided
if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) {
return FALSE;
//.........这里部分代码省略.........
示例6: allow_creation
/**
* check if new images can be added
*
* This function returns TRUE if images can be added to some place,
* and FALSE otherwise.
*
* @param object an instance of the Anchor interface, if any
* @param array a set of item attributes, if any
* @param string the type of item, e.g., 'section'
* @return TRUE or FALSE
*/
public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
{
global $context;
// backward compatibility, reverse parameters :
// $anchor is always a object and $item a array
if (is_object($item) || is_array($anchor)) {
$permute = $anchor;
$anchor = $item;
$item = $permute;
}
// guess the variant
if (!$variant) {
// most frequent case
if (isset($item['id'])) {
$variant = 'article';
} elseif (is_object($anchor)) {
$variant = $anchor->get_type();
} else {
return FALSE;
}
}
// only in articles
if ($variant == 'article') {
// 'no images' option
if (Articles::has_option('no_images', $anchor, $item)) {
return FALSE;
}
// other containers
} else {
// in item
if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bno_images\\b/i', $item['options'])) {
return FALSE;
}
// in container
if (is_object($anchor) && $anchor->has_option('no_images', FALSE)) {
return FALSE;
}
}
// surfer is not allowed to upload a file
if (!Surfer::may_upload()) {
return FALSE;
}
// surfer is an associate
if (Surfer::is_associate()) {
return TRUE;
}
// submissions have been disallowed
if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
return FALSE;
}
// only in articles
if ($variant == 'article') {
// surfer is entitled to change content
if (Articles::allow_modification($item, $anchor)) {
return TRUE;
}
// surfer is an editor, and the page is not private
if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
return TRUE;
}
if (is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// only in iles
} elseif ($variant == 'file') {
// surfer owns the anchor
if (is_object($anchor) && $anchor->is_owned()) {
return TRUE;
}
// only in sections
} elseif ($variant == 'section') {
// surfer is entitled to change content
if (Sections::allow_modification($item, $anchor)) {
return TRUE;
}
// only in user profiles
} elseif ($variant == 'user') {
// the item is anchored to the profile of this member
if (Surfer::get_id() && is_object($anchor) && !strcmp($anchor->get_reference(), 'user:' . Surfer::get_id())) {
return TRUE;
}
// should not happen...
if (isset($item['id']) && Surfer::is($item['id'])) {
return TRUE;
}
}
// item has been locked
if (isset($item['locked']) && $item['locked'] == 'Y') {
return FALSE;
//.........这里部分代码省略.........
示例7: elseif
if (isset($item['overlay'])) {
$overlay = Overlay::load($item, 'article:' . $item['id']);
}
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor'])) {
$anchor = Anchors::get($item['anchor']);
}
// editors can do what they want on items anchored here
if (Surfer::is_member() && is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower();
} elseif (isset($item['id']) && Articles::is_assigned($item['id']) && Surfer::is_member()) {
Surfer::empower();
} elseif (Surfer::is_logged() && is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower('S');
} elseif (isset($item['id']) && Articles::is_assigned($item['id']) && Surfer::is_logged()) {
Surfer::empower('S');
} elseif (isset($item['options']) && $item['options'] && preg_match('/\\banonymous_edit\\b/i', $item['options'])) {
Surfer::empower();
} elseif (Surfer::is_member() && isset($item['options']) && $item['options'] && preg_match('/\\bmembers_edit\\b/i', $item['options'])) {
Surfer::empower();
} elseif (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
Surfer::empower();
}
//
// is this surfer allowed to browse the page?
//
// associates, editors and readers can read this page
if (Surfer::is_empowered('S')) {
$permitted = TRUE;
} elseif (isset($item['create_id']) && Surfer::is($item['create_id'])) {
示例8: array
// invite participants, for owners
if (Articles::is_owned($item, $anchor) && isset($context['with_email']) && $context['with_email'] == 'Y') {
Skin::define_img('ARTICLES_INVITE_IMG', 'articles/invite.gif');
$box['bar'] += array(Articles::get_url($item['id'], 'invite') => ARTICLES_INVITE_IMG . i18n::s('Invite participants'));
}
// notify participants
if ($count > 1 && Articles::allow_message($item, $anchor) && isset($context['with_email']) && $context['with_email'] == 'Y') {
Skin::define_img('ARTICLES_EMAIL_IMG', 'articles/email.gif');
$box['bar'] += array(Articles::get_url($item['id'], 'mail') => ARTICLES_EMAIL_IMG . i18n::s('Notify participants'));
}
// manage editors, for owners
if (Articles::is_owned($item, $anchor, TRUE) || Surfer::is_associate()) {
Skin::define_img('ARTICLES_ASSIGN_IMG', 'articles/assign.gif');
$box['bar'] += array(Users::get_url('article:' . $item['id'], 'select') => ARTICLES_ASSIGN_IMG . i18n::s('Manage participants'));
// leave this page, for editors
} elseif (Articles::is_assigned($item['id'])) {
Skin::define_img('ARTICLES_ASSIGN_IMG', 'sections/assign.gif');
$box['bar'] += array(Users::get_url('article:' . $item['id'], 'leave') => ARTICLES_ASSIGN_IMG . i18n::s('Leave this page'));
}
// headers
$headers = array(i18n::s('Person'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner'));
// layout columns
if ($rows) {
$box['text'] .= Skin::table($headers, $rows, 'grid');
}
// actually render the html
$users .= Skin::build_content(NULL, NULL, $box['text'], $box['bar']);
}
// display in a separate panel
if ($users) {
$label = i18n::s('Persons');
示例9: elseif
$overlay = NULL;
if (isset($item['overlay'])) {
$overlay = Overlay::load($item, 'article:' . $item['id']);
}
// look for the action
$action = NULL;
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
} elseif (isset($context['arguments'][1])) {
$action = $context['arguments'][1];
}
$action = strip_tags($action);
// maybe this anonymous surfer is allowed to handle this item
if (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
Surfer::empower();
} elseif (isset($item['id']) && Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower();
} elseif (Articles::has_option('anonymous_edit', $anchor, $item)) {
Surfer::empower();
} elseif (Surfer::is_member() && Articles::has_option('members_edit', $anchor, $item)) {
Surfer::empower();
}
// associates and editors can do what they want
if (Surfer::is_empowered()) {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// no not kill script validation
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
return;
示例10: layout
//.........这里部分代码省略.........
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// reset everything
$summary = $update = $owner = $editor = $watcher = '';
// signal articles to be published
if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$summary .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$summary .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$summary .= RESTRICTED_FLAG;
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// use the title to label the link
if (is_object($overlay)) {
$label = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$label = Codes::beautify_title($item['title']);
}
// use the title as a link to the page
$summary .= Skin::build_link($url, $label, 'basic', $hover);
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$summary .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$summary .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$summary .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$summary .= ' ' . UPDATED_FLAG;
}
// insert overlay data, if any
if (is_object($overlay)) {
$summary .= $overlay->get_text('list', $item);
}
// attachment details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic'));
}
// combine in-line details
if (count($details)) {
$summary .= BR . '<span class="details">' . trim(implode(' · ', $details)) . '</span>';
}
// display all tags
if ($item['tags']) {
$summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
}
// dates
// $update = '<span class="details">'.join(BR, Articles::build_dates($anchor, $item)).'</span>';
// watcher
if (Articles::is_watched($item['id'], $this->focus)) {
$watcher = CHECKED_IMG;
}
// editor
if (Articles::is_assigned($item['id'], $this->focus)) {
$editor = CHECKED_IMG;
}
// owner
if (isset($item['owner_id']) && $item['owner_id'] == $this->focus) {
$owner = CHECKED_IMG;
}
// this is another row of the output
// $cells = array($summary, $update, $watcher, $editor, $owner);
$cells = array($summary, $watcher, $editor, $owner);
// append this row
$rows[] = $cells;
}
// end of processing
SQL::free($result);
// headers
// $headers = array(i18n::s('Page'), i18n::s('Dates'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner'));
$headers = array(i18n::s('Page'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner'));
// return a sortable table
$text .= Skin::table($headers, $rows, 'grid');
return $text;
}