本文整理汇总了PHP中Surfer::is方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::is方法的具体用法?PHP Surfer::is怎么用?PHP Surfer::is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surfer
的用法示例。
在下文中一共展示了Surfer::is方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list servers
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = Servers::get_url($item['id']);
// use the title as a label
$label = Skin::strip($item['title'], 10);
// flag files uploaded recently
if ($item['edit_date'] >= $context['fresh']) {
$prefix = NEW_FLAG . $prefix;
}
// description
if ($item['description']) {
$suffix .= ' ' . ucfirst(trim($item['description']));
}
// the menu bar for associates and poster
if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
$menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
$suffix .= ' ' . Skin::build_list($menu, 'menu');
}
// add a separator
if ($suffix) {
$suffix = ' - ' . $suffix;
}
// append details to the suffix
$suffix .= BR . '<span class="details">';
// details
$details = array();
// item poster
if ($item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// the edition date
$details[] = Skin::build_date($item['edit_date']);
// all details
if (count($details)) {
$suffix .= ucfirst(implode(', ', $details)) . "\n";
}
// end of details
$suffix .= '</span>';
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'server', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例2: is_owned
/**
* check if a surfer owns a section
*
* @param array section attributes
* @param object parent anchor, if any
* @param boolean FALSE if the surfer can be an editor of parent section
* @param int optional reference to some user profile
* @return TRUE or FALSE
*/
public static function is_owned($item = NULL, $anchor = NULL, $strict = FALSE, $user_id = NULL)
{
global $context;
// id of requesting user
if (!$user_id) {
if (!Surfer::get_id()) {
return FALSE;
}
$user_id = Surfer::get_id();
}
// surfer owns this section
if (isset($item['owner_id']) && $item['owner_id'] == $user_id) {
return TRUE;
}
// do not look upwards
if (!$anchor || !is_object($anchor)) {
return FALSE;
}
// associates can do what they want
if (Surfer::is($user_id) && Surfer::is_associate()) {
return TRUE;
}
// we are owning one of the parents
if ($anchor->is_owned($user_id)) {
return TRUE;
}
// surfer is a member assigned to one of the parents
if (!$strict && Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned($user_id)) {
return TRUE;
}
// sorry
return FALSE;
}
示例3: elseif
// re-enforce the canonical link
} elseif (!$zoom_type && $page == 1 && $context['self_url'] && $whole_rendering && strncmp($context['self_url'], $context['page_link'], strlen($context['page_link']))) {
Safe::header('Status: 301 Moved Permanently', TRUE, 301);
Safe::header('Location: ' . $context['page_link']);
Logger::error(Skin::build_link($context['page_link']));
// display the article
} else {
// behaviors can change page menu
if (is_object($behaviors)) {
$context['page_menu'] = $behaviors->add_commands('articles/view.php', 'article:' . $item['id'], $context['page_menu']);
}
// remember surfer visit
Surfer::is_visiting(Articles::get_permalink($item), Codes::beautify_title($item['title']), 'article:' . $item['id'], $item['active']);
// increment silently the hits counter if not robot, nor associate, nor owner, nor at follow-up page
if (Surfer::is_crawler() || Surfer::is_associate()) {
} elseif (isset($item['owner_id']) && Surfer::is($item['owner_id'])) {
} elseif (!$zoom_type) {
$item['hits'] = isset($item['hits']) ? $item['hits'] + 1 : 1;
Articles::increment_hits($item['id']);
}
// initialize the rendering engine
Codes::initialize(Articles::get_permalink($item));
// neighbours information
$neighbours = NULL;
if (Articles::has_option('with_neighbours', $anchor, $item) && is_object($anchor)) {
$neighbours = $anchor->get_neighbours('article', $item);
}
//
// set page image -- $context['page_image']
//
// the article or the anchor icon, if any
示例4: put
/**
* put an updated user profile in the database
*
* If present, only the password is changed. Or other fields except the password are modified.
*
* To change a password, set fields 'id', 'password' and 'confirm'
*
* @param array an array of fields
* @return TRUE on success, FALSE otherwise
*
* @see users/edit.php
* @see users/password.php
* @see users/select_avatar.php
**/
public static function put(&$fields)
{
global $context;
// load the record
$item = Users::get($fields['id']);
if (!isset($item['id']) || !$item['id']) {
Logger::error(i18n::s('No item has the provided id.'));
return FALSE;
}
// remember who is changing this record
Surfer::check_default_editor($fields);
// if a password change
if (isset($fields['password'])) {
// ensure that the password has been provided twice
if (!isset($fields['confirm']) || $fields['confirm'] != $fields['password']) {
Logger::error(i18n::s('New password has to be confirmed.'));
return FALSE;
}
// hash password, we are coming from an interactive form
$fields['password'] = md5($fields['password']);
// else if a regular profile update
} else {
// nick_name is required
if (!isset($fields['nick_name']) || !trim($fields['nick_name'])) {
Logger::error(i18n::s('Please indicate a nick name.'));
return FALSE;
}
// some weird users put spaces around
$fields['nick_name'] = trim($fields['nick_name']);
// nick_name may be already used
if (($used = Users::get($fields['nick_name'])) && $used['id'] != $fields['id']) {
Logger::error(i18n::s('Another member already has this nick name. Please select a different one.'));
return FALSE;
}
// ensure we have a full name
if (!isset($fields['full_name']) || !trim($fields['full_name'])) {
$fields['full_name'] = $fields['nick_name'];
}
// protect from hackers
if (isset($fields['avatar_url'])) {
$fields['avatar_url'] = encode_link($fields['avatar_url']);
}
// set default values
if (!isset($fields['active']) || !$fields['active']) {
$fields['active'] = 'Y';
}
if (isset($fields['selected_editor'])) {
$fields['editor'] = $fields['selected_editor'];
} elseif (isset($context['users_default_editor'])) {
$fields['editor'] = $context['users_default_editor'];
} else {
$fields['editor'] = 'yacs';
}
if (!isset($fields['interface']) || $fields['interface'] != 'C') {
$fields['interface'] = 'I';
}
if (!isset($fields['with_newsletters']) || $fields['with_newsletters'] != 'Y') {
$fields['with_newsletters'] = 'N';
}
if (!isset($fields['without_alerts']) || $fields['without_alerts'] != 'N') {
$fields['without_alerts'] = 'Y';
}
if (!isset($fields['without_confirmations']) || $fields['without_confirmations'] != 'N') {
$fields['without_confirmations'] = 'Y';
}
if (!isset($fields['without_messages']) || $fields['without_messages'] != 'N') {
$fields['without_messages'] = 'Y';
}
if (!isset($fields['birth_date']) || !$fields['birth_date']) {
$fields['birth_date'] = NULL_DATE;
}
// clean provided tags
if (isset($fields['tags'])) {
$fields['tags'] = trim($fields['tags'], " \t.:,!?");
}
// save new settings in session and in cookie
if (Surfer::is($fields['id'])) {
// change preferred editor
$_SESSION['surfer_editor'] = $fields['editor'];
Safe::setcookie('surfer_editor', $fields['editor'], NULL, '/');
// change preferred language
if (isset($fields['language']) && $_SESSION['surfer_language'] != $fields['language']) {
$_SESSION['surfer_language'] = $fields['language'];
$_SESSION['l10n_modules'] = array();
}
}
//.........这里部分代码省略.........
示例5: ucfirst
}
// page details
if (is_array($details)) {
$context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
}
// insert anchor suffix
if (is_object($anchor)) {
$context['text'] .= $anchor->get_suffix();
}
// back to the anchor page
if (is_object($anchor) && $anchor->is_viewable()) {
$menu = array(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'));
$context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
}
//
// populate the extra panel
//
// commands for associates and editors
if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
$context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'edit'), i18n::s('Edit'));
$context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'delete'), i18n::s('Delete'));
// commands for the author
} elseif (Surfer::is($item['edit_id'])) {
$context['page_tools'][] = Skin::build_link(Locations::get_url($item['id'], 'edit'), i18n::s('Edit'));
}
// referrals, if any, in a sidebar
//
$context['components']['referrals'] =& Skin::build_referrals(Locations::get_url($item['id']));
}
// render the skin
render_skin();
示例6: layout
/**
* list links
*
* Recognize following variants:
* - 'no_anchor' to list items attached to one particular anchor
* - 'no_author' to list items attached to one user prolink
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'no_anchor';
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// initialize variables
$prefix = $suffix = $icon = '';
// make a label
$label = Links::clean($item['title'], $item['link_url']);
// flag links uploaded recently
if ($item['edit_date'] >= $context['fresh']) {
$prefix = NEW_FLAG . $prefix;
}
// the number of clicks
if ($item['hits'] > 1) {
$suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') ';
}
// add a separator
if ($suffix) {
$suffix = ' - ' . $suffix;
}
// details
$details = array();
// item poster
if ($item['edit_name'] && $this->layout_variant != 'no_author') {
if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
}
// show an anchor link
if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$anchor_url = $anchor->get_url();
$anchor_label = ucfirst($anchor->get_title());
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
}
// the menu bar for associates and poster
if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
$details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span');
$details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span');
}
// append details to the suffix
if (count($details)) {
$suffix .= BR . Skin::finalize_list($details, 'menu');
}
// description
if ($item['description']) {
$suffix .= BR . Codes::beautify($item['description']);
}
// build the actual link to check it
if ($this->layout_variant == 'review') {
$icon = $item['link_url'];
}
// url is the link itself -- hack for xhtml compliance
$url = str_replace('&', '&', $item['link_url']);
// let the rendering engine guess the type of link
$link_type = NULL;
// except if we want to stay within this window
if (isset($item['link_target']) && $item['link_target'] != 'I') {
$link_type = 'external';
}
// hovering title
$link_title = NULL;
if (isset($item['link_title']) && $item['link_title']) {
$link_title = $item['link_title'];
}
// pack everything
$items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title);
}
// end of processing
SQL::free($result);
return $items;
}
示例7: is_owned
/**
* check that the surfer owns an anchor
*
* To be overloaded into derived class if attribute has a different name than 'owner_id'.
*
* @param int optional reference to some user profile
* @param boolean FALSE to not cascade the check to parent containers
* @return TRUE or FALSE
*/
function is_owned($user_id = NULL, $cascade = TRUE)
{
global $context;
// id of requesting user
if (!$user_id) {
if (!Surfer::get_id()) {
return FALSE;
}
$user_id = Surfer::get_id();
}
// surfer owns this item
if (isset($this->item['owner_id']) && $user_id == $this->item['owner_id']) {
return TRUE;
}
// do not cascade
if (!$cascade) {
return FALSE;
}
// associates can always do it, except if not cascading
if (Surfer::is($user_id) && Surfer::is_associate()) {
return TRUE;
}
// if surfer manages parent container it's ok too
if (isset($this->item['anchor'])) {
// save requests
if (!isset($this->anchor) || !$this->anchor) {
$this->anchor = Anchors::get($this->item['anchor']);
}
// test strict ownership
if (is_object($this->anchor) && $this->anchor->is_owned($user_id)) {
return TRUE;
}
}
// sorry
return FALSE;
}
示例8: elseif
$context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
}
// adding followers
} else {
if (Surfer::may_mail()) {
$help = i18n::s('Each new person will be notified that you are following him.');
// in a side box
$context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
}
}
// list editors
} elseif ($permitted == 'editors') {
// the title of the page
if (is_object($anchor)) {
if (!strncmp($anchor->get_reference(), 'user:', 5)) {
if (Surfer::is(intval(substr($anchor->get_reference(), 5)))) {
$context['page_title'] = i18n::s('Persons that I am following');
} else {
$context['page_title'] = sprintf(i18n::s('Persons followed by %s'), $anchor->get_title());
}
} elseif (!strncmp($anchor->get_reference(), 'category:', 9)) {
$context['page_title'] = sprintf(i18n::s('Members of %s'), $anchor->get_title());
} else {
$context['page_title'] = i18n::s('Editors');
}
}
// look for the user through his nick name
if (isset($_REQUEST['assigned_name']) && ($user = Users::get($_REQUEST['assigned_name']))) {
$_REQUEST['anchor'] = 'user:' . $user['id'];
}
// the current list of category members
示例9: is_owned
/**
* check if a surfer owns a page
*
* @param array page attributes
* @param object cascade to parent if set
* @param boolean FALSE if the surfer can be an editor of parent section
* @param int optional reference to some user profile
* @return TRUE or FALSE
*/
public static function is_owned($item = NULL, $anchor = NULL, $strict = FALSE, $user_id = NULL)
{
global $context;
// ownership requires to be authenticated
if (!$user_id) {
if (!Surfer::get_id()) {
return FALSE;
}
$user_id = Surfer::get_id();
}
// surfer owns this page
if (isset($item['owner_id']) && $item['owner_id'] == $user_id) {
return TRUE;
}
// do not look upwards
if (!$anchor || !is_object($anchor)) {
return FALSE;
}
// associates can do what they want
if (Surfer::is($user_id) && Surfer::is_associate()) {
return TRUE;
}
// surfer owns parent container
if ($anchor->is_owned($user_id)) {
return TRUE;
}
// page has not been created yet, section is not private, and surfer is member --not subscriber
// Alexis => desactivated cause it's rejected later
//if(!$strict && !isset($item['id']) && Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden())
// return TRUE;
// page is not private, and surfer is editor --not subscriber-- of parent container
if (!$strict && isset($item['active']) && $item['active'] != 'N' && Surfer::is_member() && is_object($anchor) && $anchor->is_assigned($user_id)) {
return TRUE;
}
// sorry
return FALSE;
}
示例10:
// change avatar
if (Surfer::is_empowered() && isset($item['avatar_url']) && $item['avatar_url']) {
Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
$label = i18n::s('Change picture');
$context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'select_avatar'), IMAGES_ADD_IMG . $label, 'basic');
}
// modify this page
Skin::define_img('USERS_EDIT_IMG', 'users/edit.gif');
$context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'edit'), USERS_EDIT_IMG . i18n::s('Edit this profile'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
// change password
if (!isset($context['users_authenticator']) || !$context['users_authenticator']) {
Skin::define_img('USERS_PASSWORD_IMG', 'users/password.gif');
$context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'password'), USERS_PASSWORD_IMG . i18n::s('Change password'), 'basic');
}
// only associates can delete user profiles; self-deletion may also be allowed
if (isset($item['id']) && !$zoom_type && $permitted && (Surfer::is_associate() || Surfer::is($item['id']) && (!isset($context['users_without_self_deletion']) || $context['users_without_self_deletion'] != 'Y'))) {
Skin::define_img('USERS_DELETE_IMG', 'users/delete.gif');
$context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'delete'), USERS_DELETE_IMG . i18n::s('Delete this profile'));
}
}
// associates can transfer ownership
if (Surfer::is_associate()) {
Skin::define_img('USERS_TRANSFER_IMG', 'users/transfer.gif');
$context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'transfer'), USERS_TRANSFER_IMG . i18n::s('Transfer ownership'));
}
// user profile aside
$context['components']['profile'] = Skin::build_profile($item, 'extra');
// add extra information from the overlay, if any
if (is_object($overlay)) {
$context['components']['overlay'] = $overlay->get_text('extra', $item);
}
示例11: layout
/**
* list files for search requests
*
* @param resource the SQL result
* @return array of resulting items ($score, $summary), or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of array($score, $summary)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// one box at a time
$box = '';
// get the main anchor
$anchor = Anchors::get($item['anchor']);
$prefix = $suffix = '';
// stream the file
if (Files::is_stream($item['file_name'])) {
$url = Files::get_url($item['id'], 'stream', $item['file_name']);
} else {
$url = Files::get_url($item['id'], 'fetch', $item['file_name']);
}
// absolute url
$url = $context['url_to_home'] . $context['url_to_root'] . $url;
// signal restricted and private files
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
// show a reference to the file for members
$hover = i18n::s('Get the file');
if (Surfer::is_member()) {
$hover .= ' [file=' . $item['id'] . ']';
}
// flag files uploaded recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// one line of text
$box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix;
// side icon
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} else {
$icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
}
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />';
// make it a clickable link
$icon = Skin::build_link($url, $icon, 'basic');
// first line of details
$details = array();
// file poster and last action
$details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
// downloads
if ($item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('downloads'));
}
// file size
if ($item['file_size'] > 1) {
$details[] = Skin::build_number($item['file_size'], i18n::s('bytes'));
}
// file has been detached
if (isset($item['assign_id']) && $item['assign_id']) {
// who has been assigned?
if (Surfer::is($item['assign_id'])) {
$details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date']));
} else {
$details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date']));
}
}
// the main anchor link
if (is_object($anchor)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'article'));
}
// append details
if (count($details)) {
$box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
}
// layout this item
if ($icon) {
$list = array(array($box, $icon));
$items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
// put the item in a division
//.........这里部分代码省略.........
示例12: layout
/**
* list blogmarks
*
* @param resource the SQL result
* @return string resulting text
**/
function layout($result)
{
global $context;
// we return a string
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// start in north
$in_north = TRUE;
// define allowed HTML tags for the cover page
define('ALLOWED_HTML_TAGS', '<a><b><br><h1><h2><h3><i><img><li><ol><p><ul>');
// build a list of articles
$box = array();
$box['content'] = '';
$previous_date = NULL;
while ($item = SQL::fetch($result)) {
// not the same date
$current_date = substr($item['edit_date'], 0, 10);
if ($previous_date != $current_date) {
// insert a complete box for the previous date
if ($box['content']) {
if ($in_north) {
$text .= '<div class="newest">' . "\n";
}
$text .= Skin::build_box($box['title'], $box['content']);
if ($in_north) {
$text .= '</div>' . "\n";
}
$in_north = FALSE;
}
// prepare a box for a new date
$previous_date = $current_date;
$box['title'] = Skin::build_date($item['edit_date'], 'no_hour');
$box['content'] = '';
}
$box['content'] .= '<br clear="both" />';
// time
$box['content'] .= '<span class="details">' . substr($item['edit_date'], 11, 5) . '</span> ';
// make a label
$label = Links::clean($item['title'], $item['link_url']);
$box['content'] .= Skin::build_link($item['link_url'], $label);
// flag links updated recently
if ($item['edit_date'] >= $context['fresh']) {
$box['content'] .= ' ' . NEW_FLAG;
}
// the description
if (trim($item['description'])) {
$box['content'] .= "\n<br/>" . Skin::cap(Codes::beautify($item['description']), 500) . "\n";
}
// the menu bar for associates and poster
if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
$menu = array('links/edit.php?id=' . $item['id'] => i18n::s('Edit'), 'links/delete.php?id=' . $item['id'] => i18n::s('Delete'));
$box['content'] .= ' ' . Skin::build_list($menu, 'menu');
}
// append details to the suffix
$box['content'] .= BR . '<span class="details">';
// details
$details = array();
// item poster
if (Surfer::is_member()) {
if ($item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
} else {
$details[] = Anchors::get_action_label($item['edit_action']);
}
// show an anchor link
if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$anchor_url = $anchor->get_url();
$anchor_label = ucfirst($anchor->get_title());
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label));
}
// all details
$box['content'] .= ucfirst(trim(implode(' ', $details))) . "\n";
// end of details
$box['content'] .= '</span><br/><br/>';
}
// close the on-going box
if ($in_north) {
$text .= '<div class="newest">' . "\n";
}
$text .= Skin::build_box($box['title'], $box['content']);
if ($in_north) {
$text .= '</div>' . "\n";
}
// end of processing
SQL::free($result);
return $text;
}
示例13: elseif
} elseif (isset($_REQUEST['anchor'])) {
$link = 'articles/edit.php?anchor=' . $_REQUEST['anchor'];
} else {
$link = 'articles/edit.php';
}
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode($link));
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// an error occured
} elseif (count($context['error'])) {
$item = $_REQUEST;
$with_form = TRUE;
// page has been assigned to another person during the last 5 minutes
} elseif (isset($item['assign_id']) && $item['assign_id'] && !Surfer::is($item['assign_id']) && SQL::strtotime($item['assign_date']) + 5 * 60 >= time()) {
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
$context['text'] .= Skin::build_block(sprintf(i18n::s('This page is currently edited by %s. You have to wait for a new version to be released.'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id'])), 'caution');
// process uploaded data
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
// protect from hackers
if (isset($_REQUEST['edit_name'])) {
$_REQUEST['edit_name'] = preg_replace(FORBIDDEN_IN_NAMES, '_', $_REQUEST['edit_name']);
}
if (isset($_REQUEST['edit_address'])) {
$_REQUEST['edit_address'] = encode_link($_REQUEST['edit_address']);
}
// track anonymous surfers
Surfer::track($_REQUEST);
// set options
示例14: elseif
} 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'])) {
$permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
$permitted = FALSE;
} elseif (isset($item['active']) && $item['active'] == 'R' && Surfer::is_logged()) {
$permitted = TRUE;
} elseif (isset($item['active']) && $item['active'] == 'Y') {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// load localized strings
i18n::bind('overlays');
// load the skin, maybe with a variant
load_skin('articles', $anchor, isset($item['options']) ? $item['options'] : '');
// clear the tab we are in
示例15: allow_deletion
/**
* check if a file can be deleted
*
* This function returns TRUE if the file can be deleted,
* and FALSE otherwise.
*
* @param array a set of item attributes, aka, the target file
* @param object an instance of the Anchor interface
* @return TRUE or FALSE
*/
public static function allow_deletion($item, $anchor)
{
global $context;
// sanity check
if (!isset($item['id'])) {
return FALSE;
}
// surfer is an associate
if (Surfer::is_associate()) {
return TRUE;
}
// surfer owns the container
if (is_object($anchor) && $anchor->is_owned()) {
return TRUE;
}
// allow container editors --not subscribers-- to manage content, except on private sections
if (Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// the file 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;
}
// surfer has created the file
if (isset($item['create_id']) && Surfer::is($item['create_id'])) {
return TRUE;
}
// surfer has changed the file
if (isset($item['edit_id']) && Surfer::is($item['edit_id'])) {
return TRUE;
}
// default case
return FALSE;
}