本文整理汇总了PHP中Members::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Members::check方法的具体用法?PHP Members::check怎么用?PHP Members::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Members
的用法示例。
在下文中一共展示了Members::check方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_assigned
/**
* check that the surfer is an editor of an anchor
*
* This function is used to control the authority delegation from the anchor.
* For example, if some editor is assigned to a complete section of the
* web site, he/she should be able to edit all articles in this section.
* you can use following code to check that:
* [php]
* $anchor = Anchors::get($article['anchor']);
* if($anchor->is_assigned() {
* ...
* }
* [/php]
*
* A logged member is always considered as an editor if he has created the target item.
*
* An anonymous surfer is considered as an editor if he has provided the secret handle.
*
* To be overloaded into derived class if field has a different name
*
* @param int optional reference to some user profile
* @param boolean TRUE to climb the list of containers up to the top
* @return TRUE or FALSE
*/
function is_assigned($user_id = NULL, $cascade = TRUE)
{
global $context;
// we need some data to proceed
if (!isset($this->item['id'])) {
return FALSE;
}
// id of requesting user
if (!$user_id) {
$user_id = Surfer::get_id();
}
// anonymous is allowed
if (!$user_id) {
$user_id = 0;
}
// create the cache
if (!isset($this->is_assigned_cache)) {
$this->is_assigned_cache = array();
}
// cache the answer
if (isset($this->is_assigned_cache[$user_id])) {
return $this->is_assigned_cache[$user_id];
}
// surfer has provided the secret handle
if (isset($this->item['handle']) && Surfer::may_handle($this->item['handle'])) {
return $this->is_assigned_cache[$user_id] = TRUE;
}
// surfer owns this item
if ($user_id && isset($this->item['owner_id']) && $user_id == $this->item['owner_id']) {
return $this->is_assigned_cache[$user_id] = TRUE;
}
// anchor has been assigned to this surfer
if ($user_id && Members::check('user:' . $user_id, $this->get_reference())) {
return $this->is_assigned_cache[$user_id] = TRUE;
}
// anonymous edition is allowed
if ($this->item['active'] == 'Y' && $this->has_option('anonymous_edit')) {
return $this->is_assigned_cache[$user_id] = TRUE;
}
// members edition is allowed
if ($this->item['active'] == 'Y' && Surfer::is_empowered('M') && $this->has_option('members_edit')) {
return $this->is_assigned_cache[$user_id] = TRUE;
}
// check parent container
if ($cascade && isset($this->item['anchor'])) {
// save requests
if (!isset($this->anchor) || !$this->anchor) {
$this->anchor = Anchors::get($this->item['anchor']);
}
// check for ownership
if (is_object($this->anchor)) {
return $this->is_assigned_cache[$user_id] = $this->anchor->is_assigned($user_id);
}
}
// sorry
return $this->is_assigned_cache[$user_id] = FALSE;
}
示例2: is_watched
/**
* is the surfer watching this section?
*
* @param int the id of the target section
* @param int optional id to impersonate
* @return TRUE or FALSE
*/
public static function is_watched($id, $surfer_id = NULL)
{
global $context;
// no impersonation
if (!$surfer_id) {
// a managed section requires an authenticated user
if (!Surfer::is_logged()) {
return FALSE;
}
// use surfer profile
$surfer_id = Surfer::get_id();
}
// ensure this section has been linked to this user
return Members::check('section:' . $id, 'user:' . $surfer_id);
}
示例3: array
// build a complete box
$box = array('bar' => array(), 'text' => '');
// list participants
$rows = array();
Skin::define_img('CHECKED_IMG', 'ajax/accept.png', '*');
$offset = ($zoom_index - 1) * USERS_LIST_SIZE;
// list editors of this section, and of parent sections
if ($items = Sections::list_editors_by_name($item, 0, 1000, 'watch')) {
foreach ($items as $user_id => $user_label) {
$owner_state = '';
if ($user_id == $item['owner_id']) {
$owner_state = CHECKED_IMG;
}
$editor_state = CHECKED_IMG;
$watcher_state = '';
if (Members::check($anchors, 'user:' . $user_id)) {
$watcher_state = CHECKED_IMG;
}
$rows[$user_id] = array($user_label, $watcher_state, $editor_state, $owner_state);
}
}
// watchers
if ($items = Sections::list_watchers_by_posts($item, 0, 1000, 'watch')) {
foreach ($items as $user_id => $user_label) {
// this is a true participant to the item
$users_count += 1;
// add the checkmark to existing row
if (isset($rows[$user_id])) {
$rows[$user_id][1] = CHECKED_IMG;
} else {
$owner = '';
示例4: elseif
$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()) {
$in_watch_list = Members::check('article:' . $item['id'], 'user:' . Surfer::get_id());
}
// has this page some versions?
$has_versions = FALSE;
if (isset($item['id']) && !$zoom_type && Surfer::is_empowered() && Versions::count_for_anchor('article:' . $item['id'])) {
$has_versions = TRUE;
}
// load the skin, maybe with a variant
load_skin('article', $anchor, isset($item['options']) ? $item['options'] : '');
// clear the tab we are in
if (is_object($anchor)) {
$context['current_focus'] = $anchor->get_focus();
}
// current item
if (isset($item['id'])) {
$context['current_item'] = 'article:' . $item['id'];
示例5: array
Logger::error($error);
// post-processing tasks
} else {
// successful operation reflected into page title
if (!strncmp($track, 'user:', 5)) {
$context['page_title'] = i18n::s('The list of persons that you follow has been updated');
} else {
$context['page_title'] = i18n::s('Your watch list has been updated');
}
// follow-up commands
$menu = array();
if (is_object($anchor) && $anchor->is_viewable()) {
$menu[] = Skin::build_link($anchor->get_url(), i18n::s('Done'), 'button');
}
// the page now appears in the watch list
if (Members::check($track, 'user:' . Surfer::get_id())) {
// we are tracking a user
if (!strncmp($track, 'user:', 5)) {
// notify a person that is followed
if (($user = Users::get(str_replace('user:', '', $track))) && isset($user['email']) && $user['email'] && $user['without_alerts'] != 'Y') {
// contact target user by e-mail
$subject = sprintf(i18n::c('%s is following you'), strip_tags(Surfer::get_name()));
// headline
$headline = sprintf(i18n::c('%s is following you'), Surfer::get_link());
// information
$message = '<p>' . sprintf(i18n::c('%s will receive notifications when you will update your followers at %s'), Surfer::get_name(), $context['site_name']) . '</p>';
// assemble main content of this message
$message = Skin::build_mail_content($headline, $message);
// a set of links
$menu = array();
// call for action
示例6: layout
//.........这里部分代码省略.........
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// next line, except if we already are at the beginning of a line
if ($suffix && !preg_match('/<br\\s*\\/>$/', rtrim($suffix))) {
$suffix .= BR;
}
// append details to the suffix
$suffix .= '<span class="details">';
// details
$details = array();
// display details only at the main index page, and also at anchor pages
if (isset($this->focus) && $item['anchor'] != $this->focus) {
// the author
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
} else {
$details[] = sprintf(i18n::s('by %s'), $item['create_name']);
}
}
// the last action
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
// the number of hits
if (Surfer::is_logged() && $item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// 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);
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// unusual ranks are signaled to associates and owners
if ($item['rank'] != 10000 && Articles::is_owned($item, $anchor)) {
$details[] = '{' . $item['rank'] . '}';
}
}
// at the user page
if ($this->layout_variant == 'no_author' && Surfer::get_id()) {
if (Members::check('article:' . $item['id'], 'user:' . Surfer::get_id())) {
$label = i18n::s('Stop notifications');
} else {
$label = i18n::s('Watch this page');
}
$menu = array('users/track.php?anchor=' . urlencode('article:' . $item['id']) => $label);
$details[] = Skin::build_list($menu, 'menu');
}
// 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()), 'section'));
}
// combine in-line details
if (count($details)) {
$suffix .= ucfirst(trim(implode(', ', $details)));
}
// end of details
$suffix .= '</span>';
// display all tags
if ($item['tags']) {
$suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
}
// strip empty details
$suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
$suffix = str_replace('<span class="details"></span>', '', $suffix);
// insert a suffix separator
if (trim($suffix)) {
$suffix = ' ' . $suffix;
}
// the icon to put in the left column
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif (is_callable(array($anchor, 'get_bullet_url'))) {
$icon = $anchor->get_bullet_url();
}
// list all components for this item
$items[$url] = array($prefix, $title, $suffix, 'article', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例7: sprintf
// the list of followers
$followers = '';
if ($items = Members::list_watchers_by_name_for_anchor('user:' . $item['id'], 0, 1000, 'compact')) {
if (is_array($items)) {
$items = Skin::build_list($items, 'compact');
}
if (Surfer::get_id() == $item['id']) {
$followers .= '<p>' . i18n::s('Persons who follow you:') . '</p>' . $items;
} else {
$followers .= '<p>' . sprintf(i18n::s('Persons who follow %s:'), $item['full_name']) . '</p>' . $items;
}
}
// connect to people
if (Surfer::get_id() && Surfer::get_id() != $item['id']) {
// suggest a new connection
if (!Members::check('user:' . $item['id'], 'user:' . Surfer::get_id())) {
Skin::define_img('USERS_WATCH_IMG', 'users/watch.gif');
$link = Users::get_url('user:' . $item['id'], 'track');
$followers .= '<p style="margin: 1em 0;">' . Skin::build_link($link, USERS_WATCH_IMG . sprintf(i18n::s('Follow %s'), $item['full_name']), 'basic', i18n::s('Be notified of additions from this person')) . '</p>';
}
}
// put followers in a sidebar
if ($followers) {
$output .= Skin::layout_horizontally($watched, Skin::build_block($followers, 'sidecolumn'));
} else {
$output .= $watched;
}
// actual transmission except on a HEAD request
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
echo $output;
}