/** * list users * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!($delta = SQL::count($result))) { return $text; } // flag idle users $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600); // process all items in the list $count = 0; $items = array(); while ($item = SQL::fetch($result)) { // url to view the user $url = Users::get_permalink($item); // initialize variables $prefix = $suffix = ''; // signal restricted and private users if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if (isset($item['capability']) && $item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if (isset($item['full_name']) && $item['full_name']) { $label = ucfirst(Skin::strip($item['full_name'], 10)); $hover = $item['nick_name']; } else { $label = ucfirst(Skin::strip($item['nick_name'], 10)); $hover = $item['full_name']; } // flag idle users if (!isset($item['click_date']) || $item['click_date'] < $idle) { $class = 'idle user'; } else { $class = 'user'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover); // provide only some results if (++$count >= 5) { break; } } // end of processing SQL::free($result); // turn this to some text $text = Skin::build_list($items, 'comma'); // some indications on the number of connections if ($delta -= $count) { $text .= ', ...'; } return $text; }
/** * list users * * @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)) { // url to view the user profile $url = Users::get_permalink($item); // time of last update $time = SQL::strtotime($item['edit_date']); // item title if ($item['full_name']) { $label = ucfirst(Skin::strip($item['full_name'], 10)); } else { $label = ucfirst(Skin::strip($item['nick_name'], 10)); } // the section $section = ''; // the author(s) is an e-mail address, according to rss 2.0 spec $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')'; // introduction $introduction = Codes::beautify($item['introduction']); // the description $description = Codes::beautify($item['description']); // cap the number of words $description = Skin::cap($description, 300); // fix image references $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description); // other rss fields $extensions = array(); // list all components for this item $items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions); } // end of processing SQL::free($result); return $items; }
$new_users[$url] = array($prefix, $label, $suffix, $type, $icon); } // display attached users with unlink buttons $context['text'] .= Skin::build_list($new_users, 'compact') . '</div>'; } // list also editors of parent containers $inherited = ''; $handle = $anchor->get_parent(); while ($handle && ($parent = Anchors::get($handle))) { $handle = $parent->get_parent(); if (($users =& Members::list_users_by_posts_for_member($parent->get_reference(), 0, 50 * USERS_LIST_SIZE, 'raw')) && count($users)) { // browse the list $items = array(); foreach ($users as $id => $user) { // make an url $url = Users::get_permalink($user); // gather information on this user $prefix = $suffix = $type = $icon = ''; if (isset($user['full_name']) && $user['full_name']) { $label = $user['full_name'] . ' (' . $user['nick_name'] . ')'; } else { $label = $user['nick_name']; } // surfer cannot be deselected if ($parent->is_owned($id, FALSE)) { $suffix .= ' - <span class="details">' . i18n::s('owner') . '</span>'; } // format the item $items[$url] = array($prefix, $label, $suffix, $type, $icon); } // display attached users with unlink buttons
Safe::header('Status: 401 Unauthorized', TRUE, 401); } elseif (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_permalink($item))); } elseif (isset($_REQUEST['requested']) && ($requested = Users::get($_REQUEST['requested'])) && $requested['email']) { // prepare the mail message $to = Mailer::encode_recipient($requested['email'], $requested['full_name']); $subject = sprintf(i18n::c('%s: %s'), i18n::c('Request'), strip_tags($item['title'])); $message = Articles::build_notification('apply', $item, $overlay); $headers = Mailer::set_thread('article:' . $item['id']); // allow for skinnable template $message = Skin::build_mail_message($message); // build multiple parts, for HTML rendering $message = Mailer::build_multipart($message); // send the message to requested user if (Mailer::post(Surfer::from(), $to, $subject, $message, NULL, $headers)) { $text = sprintf(i18n::s('Your request has been transmitted to %s. Check your mailbox for feed-back.'), Skin::build_link(Users::get_permalink($requested), Codes::beautify_title($requested['full_name']), 'user')); $context['text'] .= Skin::build_block($text, 'note'); } // follow-up navigation $context['text'] .= '<div>' . i18n::s('Where do you want to go now?') . '</div>'; $menu = array(); $menu[] = Skin::build_link($context['url_to_root'], i18n::s('Front page'), 'button'); $menu[] = Skin::build_link(Surfer::get_permalink(), i18n::s('My profile'), 'span'); $context['text'] .= Skin::finalize_list($menu, 'menu_bar'); // offer to request some owner } else { // provide feed-back to surfer $context['text'] .= Skin::build_block(i18n::s('You are not allowed to access this page.'), 'caution'); // list owners $owners = array(); // owner of this section
$fields[] = array($label, $input); // the password has to be repeated for confirmation $label = i18n::s('Password confirmation'); $input = '<input type="password" name="confirm" size="20" value="' . encode_field(isset($_REQUEST['confirm']) ? $_REQUEST['confirm'] : '') . '" />'; $fields[] = array($label, $input); // append the script used for data checking on the browser Page::insert_script('$("#password").focus();'); } // stop replay attacks and robots if ($field = Surfer::get_robot_stopper()) { $fields[] = $field; } // build the form $context['text'] .= Skin::build_form($fields); // cancel link if (!isset($item['id'])) { $cancel_url = $context['url_to_home'] . $context['url_to_root']; } else { $cancel_url = Users::get_permalink($item); } // bottom commands $context['text'] .= Skin::finalize_list(array(Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'), Skin::build_link($cancel_url, i18n::s('Cancel'), 'span')), 'assistant_bar'); // hidden field that have to be saved as well if (isset($item['id']) && $item['id']) { $context['text'] .= '<input type="hidden" name="id" value="' . $item['id'] . '" />'; } // end of the form $context['text'] .= '</div></form>'; } // render the skin render_skin();
} elseif (($item = Categories::get($id)) || ($item =& Categories::get_by_keyword($id))) { Safe::redirect(Categories::get_permalink($item)); // look in articles } elseif ($items =& Articles::list_for_name($id, NULL, 'full')) { // only one page has this name if (count($items) == 1) { list($url, $attributes) = each($items); Safe::redirect($url); } // splash $context['text'] .= '<p>' . i18n::s('Select below among available pages.') . '</p>'; // several pages $context['text'] .= Skin::build_list($items, 'decorated'); // look in user profiles } elseif ($item = Users::get($id)) { Safe::redirect(Users::get_permalink($item)); // not found } else { $context['text'] .= '<p>' . sprintf(i18n::s('Sorry, no page has the provided name: %s'), $id) . '</p>' . "\n"; // offer to create a new page $context['text'] .= '<p>' . Skin::build_link('articles/edit.php?name=' . urlencode($id), i18n::s('Add a page with this name'), 'shortcut') . '</p>' . "\n"; } // the form to submit a new search if ($id) { $label = i18n::s('Look for'); } else { $label = i18n::s('Nick name'); } $input = '<input type="text" name="id" id="id" size="25" value="' . encode_field($id) . '" maxlength="64" />' . ' ' . Skin::build_submit_button(i18n::s('Search')); $context['text'] .= '<form method="get" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><p>' . $label . ' ' . $input . '</p></form>'; // the script used for form handling at the browser
Logger::error(i18n::s('You are not allowed to perform this operation.')); // no deletion in demo mode } elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes' && file_exists($context['path_to_root'] . 'parameters/demo.flag')) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.')); // deletion is confirmed } elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') { // close the session on self-deletion if (Surfer::get_id() == $item['id']) { Surfer::reset(); } // attempt to delete if (Users::delete($item['id'])) { // log item deletion $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['nick_name'])); $description = Users::get_permalink($item); Logger::remember('users/delete.php: ' . $label, $description); // this can appear anywhere Cache::clear(); // back to the index page Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/'); } // deletion has to be confirmed } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { Logger::error(i18n::s('The action has not been confirmed.')); } else { // the submit button if (Surfer::is($item['id'])) { $label = i18n::s('Yes, I want to suppress my own profile from this server and log out.'); } else { $label = i18n::s('Yes, I want to suppress this user');
} elseif (isset($context['with_email']) && $context['with_email'] == 'Y') { $label = Skin::build_link($context['url_to_root'] . Users::get_url($id, 'mail'), $item['email'], 'email'); } else { $label = Skin::build_link('mailto:' . $item['email'], $item['email'], 'email'); } $text .= BR . $label; } // web address, if any if (isset($item['web_address']) && $item['web_address']) { $text .= BR . Skin::build_link($item['web_address'], $item['web_address'], 'external'); } // agent, if any if (isset($item['vcard_agent']) && $item['vcard_agent']) { $text .= '</p><p>'; if ($agent = Users::get($item['vcard_agent'])) { $text .= sprintf(i18n::s('%s: %s'), i18n::s('Alternate contact'), Skin::build_link(Users::get_permalink($agent), $agent['full_name'] ? $agent['full_name'] : $agent['nick_name'], 'user')); } else { $text .= sprintf(i18n::s('%s: %s'), i18n::s('Alternate contact'), $item['vcard_agent']); } } $text .= '</p>'; $information .= Skin::build_box(i18n::s('Business card'), $text, 'unfolded'); // do not let robots steal addresses $box = array('bar' => array(), 'text' => ''); if (Surfer::may_contact()) { // put contact addresses in a table $rows = array(); // a clickable twitter address if (isset($item['twitter_address']) && $item['twitter_address']) { $rows[] = array(i18n::s('Twitter'), Skin::build_presence($item['twitter_address'], 'twitter') . ' ' . Skin::build_link('http://www.twitter.com/' . $item['twitter_address'], $item['twitter_address'])); }
} elseif (!$permitted) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // send the list of recent contributions by this user } else { // get the list from the cache, if possible $cache_id = 'users/feed.php?id=' . $item['id'] . '#channel'; if (!($text = Cache::get($cache_id))) { // loads feeding parameters Safe::load('parameters/feeds.include.php'); // structured data $values = array(); $values['channel'] = array(); // set channel information $values['channel']['title'] = $item['full_name'] ? $item['full_name'] : $item['nick_name']; $values['channel']['link'] = Users::get_permalink($item); $values['channel']['description'] = $item['introduction']; // the image for this channel if (isset($context['powered_by_image']) && $context['powered_by_image']) { $values['channel']['image'] = $context['url_to_home'] . $context['url_to_root'] . $context['powered_by_image']; } // the list of newest pages $values['items'] = (array) Articles::list_for_author_by('publication', $item['id'], 0, 50, 'feed'); // make a text include_once '../services/codec.php'; include_once '../services/rss_codec.php'; $result = rss_Codec::encode($values); $status = @$result[0]; $text = @$result[1]; // save in cache for the next request Cache::put($cache_id, $text, 'articles');
} // we only have a recipient address } elseif ($item['email'] && !Mailer::notify(Surfer::from(), $item['email'], $mail['subject'], $mail['message'], $mail['headers'])) { Logger::error(sprintf(i18n::s('Impossible to send a message to %s.'), $item['email'])); } } } } // follow-up commands if (!$render_overlaid) { $menu = array(); if (isset($article['id'])) { $menu = array(Articles::get_permalink($article) => i18n::s('View the new thread')); } if (count($items) == 1 && ($item = $items[0]) && isset($item['id'])) { $menu = array_merge($menu, array(Users::get_permalink($item) => sprintf(i18n::s('Back to %s'), $item['nick_name']))); } elseif (Surfer::get_id()) { $menu = array_merge($menu, array(Surfer::get_permalink() => i18n::s('Back to my profile'))); } if (count($menu)) { $context['text'] .= Skin::build_block(i18n::s('Where do you want to go now?') . Skin::build_list($menu, 'menu_bar'), 'bottom'); } } } elseif ($with_form) { // target user statut doen't allow MP, except from associates if (!Surfer::is_associate() && ($overlay->attributes['user_status'] == 'donotdisturb' || $overlay->attributes['user_status'] == 'anonymous' || $item['without_alerts'] == 'Y')) { $context['text'] .= '<p>' . sprintf(i18n::s('Sorry, "%s" wish not to receive private message'), $item['nick_name']) . '</p>' . "\n"; render_skin(); finalize_page(TRUE); } $context['text'] .= Users::get_thread_creation_form($item['id']);
if ($item['full_name']) { $text .= ' <foaf:name>' . encode_field($item['full_name']) . '</foaf:name>' . "\n"; } // nick name if ($item['nick_name']) { $text .= ' <foaf:nick>' . encode_field($item['nick_name']) . '</foaf:nick>' . "\n"; } // a representation of the mailto: URI -- protect privacy if ($item['email'] && is_callable('sha1')) { $text .= ' <foaf:mbox_sha1sum>' . sha1(encode_field('mailto:' . $item['email'])) . '</foaf:mbox_sha1sum>' . "\n"; } // the web address if ($item['web_address']) { $text .= ' <foaf:homepage rdf:resource="' . encode_field($item['web_address']) . '" />' . "\n"; } else { $text .= ' <foaf:homepage rdf:resource="' . encode_field(Users::get_permalink($item)) . '" />' . "\n"; } // the user avatar if ($item['avatar_url']) { if ($item['avatar_url'][0] == '/') { $item['avatar_url'] = str_replace('//', '/', $context['url_to_home'] . $context['url_to_root'] . $item['avatar_url']); } $text .= ' <foaf:img rdf:resource="' . encode_field($item['avatar_url']) . '" />' . "\n"; } // list watched users by posts if ($items =& Members::list_users_by_posts_for_member('user:'******'id'], 0, USERS_PER_PAGE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <foaf:knows>' . "\n" . ' <foaf:Person>' . "\n" . ' <foaf:name>' . encode_field($attributes['full_name']) . '</foaf:name>' . "\n" . ' <rdfs:seeAlso rdf:resource="' . encode_field($context['url_to_home'] . $context['url_to_root'] . Users::get_url($id, 'describe')) . '" />' . "\n" . ' </foaf:Person>' . "\n" . ' </foaf:knows>' . "\n"; } } $text .= ' </foaf:Person>' . "\n" . '</rdf:RDF>';
/** * list users * * @param resource the SQL result * @return string the rendered text * * @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; } // flag idle users $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600); // default variant if (!isset($this->layout_variant)) { $this->layout_variant == 'full'; } // process all items in the list while ($item = SQL::fetch($result)) { // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Users::get_permalink($item); // flag profiles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if ($item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if ($item['full_name']) { $label = ucfirst(Skin::strip($item['full_name'], 10)); $hover = $item['nick_name']; } else { $label = ucfirst(Skin::strip($item['nick_name'], 10)); $hover = $item['full_name']; } // show contact information if (Surfer::may_contact()) { $suffix .= Users::build_presence($item); } // the introduction if ($item['introduction']) { if (is_callable(array('codes', 'beautify'))) { $suffix .= ' - ' . Codes::beautify($item['introduction']); } else { $suffix .= ' - ' . $item['introduction']; } } // display all tags if ($item['tags']) { $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>'; } // details $details = array(); // capability if ($item['capability'] == 'A') { $details[] = i18n::s('Associate'); } elseif ($item['capability'] == 'S') { $details[] = i18n::s('Subscriber'); } else { $details[] = i18n::s('Member'); } // creation date if ($item['create_date']) { $details[] = sprintf(i18n::s('registered %s'), Skin::build_date($item['create_date'])); } // last login if ($this->layout_variant == 'dates') { if (isset($item['login_date']) && $item['login_date'] > NULL_DATE) { $address = ''; if ($item['login_address']) { $address = ' (' . $item['login_address'] . ')'; } $details[] = sprintf(i18n::s('last login %s'), Skin::build_date($item['login_date']) . $address); } else { $details[] = i18n::s('no login'); } } // last post if ($this->layout_variant == 'dates') { if (isset($item['post_date']) && $item['post_date'] > NULL_DATE) { $details[] = sprintf(i18n::s('last post %s'), Skin::build_date($item['post_date'])); } } // posts if (intval($item['posts']) > 1) { $details[] = sprintf(i18n::s('%d posts'), intval($item['posts'])); } if (count($details)) { if ($this->layout_variant == 'full') { $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>'; } else { $suffix .= ' <span class="details">' . implode(', ', $details) . '</span>'; } } // flag idle users if (isset($item['click_date']) && $item['click_date'] < $idle) { $class = 'idle user'; } else { $class = 'user'; } // use the avatar, if any if (isset($item['avatar_url']) && isset($context['users_with_avatars']) && $context['users_with_avatars'] == 'Y') { $icon = $item['avatar_url']; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, $class, $icon, $hover); } // end of processing SQL::free($result); return $items; }
$context['page_title'] = i18n::s('Validate your e-mail address'); // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!isset($item['id'])) { include '../error.php'; // bad handle } elseif ($id != $item['handle']) { include '../error.php'; } elseif (Users::validate($item['id'])) { // congratulations $context['text'] .= sprintf(i18n::s('<p>%s,</p><p>Your e-mail address has been validated, and you are now an active member of this community.</p>'), ucfirst($item['nick_name'])); // set permanent name shown from top level Safe::setcookie('surfer_name', $item['nick_name'], time() + 60 * 60 * 24 * 500, '/'); // save surfer profile in session context Surfer::set($item); // follow-up commands $follow_up = i18n::s('Where do you want to go now?'); $menu = array(); $menu = array_merge($menu, array(Users::get_permalink($item) => i18n::s('My profile'))); $menu = array_merge($menu, array($context['url_to_root'] => i18n::s('Front page'))); $follow_up .= Skin::build_list($menu, 'menu_bar'); $context['text'] .= Skin::build_block($follow_up, 'bottom'); // failed operation } else { $context['text'] .= '<p>' . i18n::s('Your e-mail address has not been validated.') . "</p>\n"; } // render the skin render_skin();
/** * list users * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!($count = SQL::count($result))) { return $text; } $text = '<div>'; // process all items in the list $count = 0; $checked = ' checked="checked"'; while ($item = SQL::fetch($result)) { // we need some address if (!$item['email']) { continue; } // do not write to myself if ($item['id'] == Surfer::get_id()) { continue; } // get the related overlay, if any $overlay = Overlay::load($item, 'user:'******'id']); // one radio button per person $text .= '<input type="radio" name="requested" value="' . encode_field($item['id']) . '"' . $checked . ' />'; // signal restricted and private users if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // the url to view this item $url = Users::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['full_name']); } // sanity check if (!$title) { $title = $item['nick_name']; } // link to this page $text .= Skin::build_link($url, $title, 'user'); // the introductory text if ($item['introduction']) { $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>'; } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('list', $item); } // append the row $text .= BR; $count++; $checked = ''; } // div suffix $text .= '</div>'; // no valid account has been found if (!$count) { $text = ''; } // end of processing SQL::free($result); return $text; }
/** * get the url to display the main page for this anchor * * @param string the targeted action ('view', 'print', 'edit', 'delete', ...) * @return an anchor to the viewing script, or NULL * * @see shared/anchor.php */ function get_url($action = 'view') { // sanity check if (!isset($this->item['id'])) { return NULL; } switch ($action) { // list of files case 'files': return Users::get_permalink($this->item) . '#_information'; // the permalink page // the permalink page case 'view': return Users::get_permalink($this->item); // another action // another action default: return Users::get_url($this->item['id'], $action, $this->item['nick_name']); } }
/** * list users * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!($delta = SQL::count($result))) { return $items; } // flag idle users $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600); // process all items in the list $count = 0; while ($item = SQL::fetch($result)) { // url to view the user $url = Users::get_permalink($item); // initialize variables $prefix = $suffix = ''; // signal restricted and private users if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if (isset($item['active']) && $item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if (isset($item['full_name']) && $item['full_name']) { $label = ucfirst(Skin::strip($item['full_name'], 10)); $hover = $item['nick_name']; } else { $label = ucfirst(Skin::strip($item['nick_name'], 10)); $hover = $item['full_name']; } // flag idle users if (!isset($item['click_date']) || $item['click_date'] < $idle) { $class = 'idle user'; } else { $class = 'user'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover); // limit to one page of results if (++$count >= USERS_PER_PAGE) { break; } } // end of processing SQL::free($result); // turn this to some text $items = Skin::build_list($items, 'compact'); // some indications on the number of connections if ($delta -= $count) { if ($delta < 100) { $label = sprintf(i18n::ns('and %d other person', 'and %d other persons', $delta), $delta); } else { $label = i18n::s('and many more persons'); } $items .= '<p>' . $label . '</p>'; } return $items; }
/** * list users * * @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; } // flag idle users $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600); // process all items in the list while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Users::get_permalink($item); // flag profiles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if ($item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if ($item['full_name']) { $title = ucfirst(Skin::strip($item['full_name'], 10)); $hover = $item['nick_name']; } else { $title = ucfirst(Skin::strip($item['nick_name'], 10)); $hover = $item['full_name']; } // show contact information if (Surfer::may_contact()) { $suffix .= Users::build_presence($item); } // the introduction if ($item['introduction']) { if (is_callable(array('codes', 'beautify'))) { $suffix .= ' - ' . Codes::beautify($item['introduction']); } else { $suffix .= ' - ' . $item['introduction']; } } // display all tags if ($item['tags']) { $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>'; } // details $details = array(); // capability if ($item['capability'] == 'A') { $details[] = i18n::s('Associate'); } elseif ($item['capability'] == 'S') { $details[] = i18n::s('Subscriber'); } else { $details[] = i18n::s('Member'); } // creation date if ($item['create_date']) { $details[] = sprintf(i18n::s('registered %s'), Skin::build_date($item['create_date'])); } // last login if ($this->layout_variant == 'dates') { if (isset($item['login_date']) && $item['login_date'] > NULL_DATE) { $address = ''; if ($item['login_address']) { $address = ' (' . $item['login_address'] . ')'; } $details[] = sprintf(i18n::s('last login %s'), Skin::build_date($item['login_date']) . $address); } else { $details[] = i18n::s('no login'); } } // last post if ($this->layout_variant == 'dates') { if (isset($item['post_date']) && $item['post_date'] > NULL_DATE) { $details[] = sprintf(i18n::s('last post %s'), Skin::build_date($item['post_date'])); } } // posts if (intval($item['posts']) > 1) { $details[] = sprintf(i18n::s('%d posts'), intval($item['posts'])); } if (count($details)) { if ($this->layout_variant == 'full') { $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>'; } else { $suffix .= ' <span class="details">' . implode(', ', $details) . '</span>'; } } // flag idle users if (isset($item['click_date']) && $item['click_date'] < $idle) { $class = 'idle user'; } else { $class = 'user'; } // item summary $box .= $prefix . Skin::build_link($url, $title, 'user') . $suffix; // use the avatar, if any if (isset($item['avatar_url']) && isset($context['users_with_avatars']) && $context['users_with_avatars'] == 'Y') { $icon = $item['avatar_url']; } // layout this item if ($icon) { // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); // put the item in a division } else { $items[] = array($item['score'], '<div style="margin: 0 0 1em 0">' . $box . '</div>'); } } // end of processing SQL::free($result); return $items; }
/** * list users * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!($count = SQL::count($result))) { return $text; } // allow for several lists in the same page static $serial; if (isset($serial)) { $serial++; } else { $serial = 1; } // don't blast too many people if ($count > 100) { $checked = ''; } elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') { $checked = ''; } else { $checked = ' checked="checked"'; } // div prefix $text .= '<div id="users_as_mail_panel_' . $serial . '">'; // allow to select/deslect multiple rows at once $text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR; // process all items in the list $count = 0; while ($item = SQL::fetch($result)) { // we need some address if (!$item['email']) { continue; } // do not write to myself if ($item['id'] == Surfer::get_id()) { continue; } // get the related overlay, if any $overlay = Overlay::load($item, 'user:'******'id']); // column to select the row $text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />'; // signal restricted and private users if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // the url to view this item $url = Users::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['full_name']); } // sanity check if (!$title) { $title = $item['nick_name']; } // link to this page $text .= Skin::build_link($url, $title, 'user'); // the introductory text if ($item['introduction']) { $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>'; } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('list', $item); } // display all tags if ($item['tags']) { $text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>'; } // append the row $text .= BR; $count++; } // the script used to check all items at once Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . ' $(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // div suffix $text .= '</div>'; // no valid account has been found if (!$count) { $text = ''; } // end of processing SQL::free($result); return $text; }
/** * 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:'******'id'], $this->anchor->get_reference()); Members::assign($this->anchor->get_reference(), '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:'******'id'], $this->anchor->get_reference()); Members::assign($this->anchor->get_reference(), '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': case 'on-going:problem': $query .= "qualification_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "qualification_id='" . SQL::escape($this->attributes['edit_id']) . "', \n" . "qualification_address='" . SQL::escape($this->attributes['edit_address']) . "', \n"; break; // cause has been identified // cause has been identified case 'cancelled:problem': case 'on-going:issue': $query .= "analysis_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "analysis_id='" . SQL::escape($this->attributes['edit_id']) . "', \n" . "analysis_address='" . SQL::escape($this->attributes['edit_address']) . "', \n"; break; // solution has been achieved // solution has been achieved case 'cancelled:issue': case 'on-going:solution': $query .= "resolution_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "resolution_id='" . SQL::escape($this->attributes['edit_id']) . "', \n" . "resolution_address='" . SQL::escape($this->attributes['edit_address']) . "', \n"; break; // ending the issue // ending the issue case 'cancelled:solution': case 'completed:solution': $query .= "close_name='" . SQL::escape($this->attributes['edit_name']) . "', \n" . "close_id='" . SQL::escape($this->attributes['edit_id']) . "', \n" . "close_address='" . SQL::escape($this->attributes['edit_address']) . "', \n"; break; } } // track the person who modifies the record $query .= "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='update', \n" . "edit_date='" . SQL::escape($this->attributes['edit_date'] ? $this->attributes['edit_date'] : $this->attributes['edit_date']) . "' \n" . " WHERE anchor LIKE '" . SQL::escape($this->attributes['anchor_reference']) . "'"; } // ensure that this change has been recorded if (!$comments) { $comments[] = i18n::s('Page has been edited'); } break; } // execute the query --don't stop on error if (isset($query) && $query) { SQL::query($query); } // add a comment if ($comments && !$this->anchor->has_option('no_comments')) { include_once $context['path_to_root'] . 'comments/comments.php'; $fields = array(); $fields['anchor'] = $this->attributes['anchor_reference']; $fields['description'] = join(BR, $comments); $fields['type'] = 'notification'; Comments::post($fields); } // job done return TRUE; }
/** * list users * * @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 = Users::get_permalink($item); // flag profiles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private profiles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if ($item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if ($item['full_name']) { $label = ucfirst(Skin::strip($item['full_name'], 10)) . ' [' . $item['nick_name'] . ']'; } else { $label = ucfirst(Skin::strip($item['nick_name'], 10)); } // the introduction if ($item['introduction']) { if (is_callable(array('codes', 'beautify'))) { $suffix .= ' - ' . Codes::beautify($item['introduction']); } else { $suffix .= ' - ' . $item['introduction']; } } // details $details = array(); // creation date if ($item['create_date']) { $details[] = sprintf(i18n::s('registered %s'), Skin::build_date($item['create_date'])); } // last login if (isset($item['login_date']) && $item['login_date'] > NULL_DATE) { $details[] = sprintf(i18n::s('last login %s'), Skin::build_date($item['login_date'])); } else { $details[] = i18n::s('no login'); } // last post if (isset($item['post_date']) && $item['post_date'] > NULL_DATE) { $details[] = sprintf(i18n::s('last post %s'), Skin::build_date($item['post_date'])); } // posts if (intval($item['posts']) > 1) { $details[] = sprintf(i18n::s('%d posts'), intval($item['posts'])); } if (count($details)) { $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>'; } // the command to ask for a new password $suffix .= '<p style="padding: 0.5em 0 0.5em 0">' . Skin::build_link(Users::get_url($item['id'], 'password', $item['nick_name']), i18n::s('Authenticate with this profile'), 'button') . '</p>'; // use the avatar, if any if (isset($item['avatar_url'])) { $icon = $item['avatar_url']; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'user', $icon); } // end of processing SQL::free($result); return $items; }
/** * build a user profile * * @param array one user profile * @param string a profiling option, including 'prefix', 'suffix', and 'extra' * @param string more information * @return a string to be returned to the browser * * @see sections/section.php */ public static function build_profile(&$user, $variant = 'prefix', $more = '') { global $context; // we return some text $text = ''; // label $label = isset($user['full_name']) && $user['full_name'] ? $user['full_name'] : $user['nick_name']; // link to the user profile $url = Users::get_permalink($user); // configured styles $more_styles = ''; if (isset($context['classes_for_avatar_images']) && $context['classes_for_avatar_images']) { $more_styles = ' ' . encode_field($context['classes_for_avatar_images']); } // depending of what we want to do switch ($variant) { // at the beginning of the page case 'prefix': default: // avatar $avatar = ''; if (isset($user['avatar_url']) && $user['avatar_url']) { $thumb = ''; if ($position = strrpos($user['avatar_url'], '/')) { $thumb = substr($user['avatar_url'], 0, $position) . '/thumbs' . substr($user['avatar_url'], $position); } if (is_readable($context['path_to_root'] . str_replace($context['url_to_root'], '', $thumb))) { $avatar =& Skin::build_link($url, '<img src="' . $thumb . '" alt="" title="avatar" class="avatar left_image" />', 'basic'); } else { $avatar =& Skin::build_link($url, '<img src="' . $user['avatar_url'] . '" alt="" title="avatar" class="avatar left_image' . $more_styles . '" />', 'basic'); } } // several items $details = array(); // date of post if ($more) { $details[] = $more; } // from where if (isset($user['from_where']) && $user['from_where']) { $details[] = sprintf(i18n::s('from %s'), Codes::beautify($user['from_where'])); } // display details if (count($details)) { $text .= '<span class="details">' . implode(', ', $details) . '</span>' . BR; } // use the introduction field, if any if (isset($user['introduction']) && $user['introduction']) { $text .= Codes::beautify($user['introduction']); } // suffix after the full name if ($text) { $text = ' -- ' . $text; } $text = '<div class="top">' . $avatar . Skin::build_link($url, $label, 'user') . $text . '</div><br style="clear: left;" />'; break; // at the end of the page // at the end of the page case 'suffix': // avatar $avatar = ''; if (isset($user['avatar_url']) && $user['avatar_url']) { $thumb = ''; if ($position = strrpos($user['avatar_url'], '/')) { $thumb = substr($user['avatar_url'], 0, $position) . '/thumbs' . substr($user['avatar_url'], $position); } if (is_readable($context['path_to_root'] . str_replace($context['url_to_root'], '', $thumb))) { $avatar =& Skin::build_link($url, '<img src="' . $thumb . '" alt="" title="avatar" class="avatar left_image" />', 'basic'); } else { $avatar =& Skin::build_link($url, '<img src="' . $user['avatar_url'] . '" alt="" title="avatar" class="avatar left_image' . $more_styles . '" />', 'basic'); } } // date of post if ($more) { $text .= $more . ' '; } // from where if (isset($user['from_where']) && $user['from_where']) { $text .= sprintf(i18n::s('from %s'), Codes::beautify($user['from_where'])); } // display details if ($text) { $text = '<span class="details">' . $text . '</span>' . BR; } // use the introduction field, if any if (isset($user['introduction']) && $user['introduction']) { $text .= Codes::beautify($user['introduction']); } // suffix after the full name if ($text) { $text = ' -- ' . $text; } $text = '<address>' . $avatar . Skin::build_link($url, $label, 'user') . $text . '</address><br style="clear: left;" />'; break; // in a sidebox // in a sidebox case 'extra': // details attributes $details = array(); // avatar if (isset($user['avatar_url']) && $user['avatar_url']) { $details[] =& Skin::build_link($url, '<img src="' . $user['avatar_url'] . '" alt="" title="avatar" class="avatar' . $more_styles . '" />', 'basic'); } else { if (Surfer::is_empowered()) { Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif'); $details[] =& Skin::build_link(Users::get_url($user['id'], 'select_avatar'), IMAGES_ADD_IMG . i18n::s('Add picture'), 'basic'); } } // date of post if ($more) { $details[] = $more; } // from where if (isset($user['from_where']) && $user['from_where']) { $details[] = sprintf(i18n::s('from %s'), Codes::beautify($user['from_where'])); } // details first if (count($details)) { $text .= '<p class="details">' . join(BR, $details) . '</p>'; } // do not use description because of codes such as location, etc if (isset($user['introduction']) && $user['introduction']) { $text .= Codes::beautify($user['introduction']); } // show contact information if (Surfer::may_contact()) { $contacts = Users::build_presence($user); if ($contacts) { $text .= BR . $contacts; } } // everything in an extra box $text = Skin::build_box($label, $text, 'profile'); break; } // return by reference return $text; }
/** * display the content of one instance * * @see overlays/overlay.php * * @param array the hosting record * @return some HTML to be inserted into the resulting page */ function &get_view_text($host = NULL) { global $context; // we may look at enrolments include_once $context['path_to_root'] . 'shared/enrolments.php'; // minutes to go if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp'] > NULL_DATE) { $this->minutes_before_start = (sql::strtotime($this->attributes['date_stamp']) - time()) / 60; } else { $this->minutes_before_start = 120; } // prevent automatic start // minutes since the end of the event if (isset($this->attributes['duration']) && $this->attributes['duration']) { $this->minutes_since_stop = -($this->attributes['duration'] + $this->minutes_before_start); } else { $this->minutes_since_stop = -120; } // prevent automatic stop // tabular information $rows = array(); // initialize feed-back to end-user $this->feed_back = array('message' => '', 'status' => array(), 'menu' => array(), 'commands' => array(), 'reload_this_page' => FALSE); // maybe a bare instance if (!isset($this->attributes['status'])) { $this->attributes['status'] = 'created'; } // step 5 - end of the event if ($this->attributes['status'] == 'stopped') { // list enrolment for this meeting $query = "SELECT * FROM " . SQL::table_name('enrolments') . " WHERE anchor LIKE '" . SQL::escape($this->anchor->get_reference()) . "'"; if ($result = SQL::query($query)) { // browse the list $items = array(); while ($item = SQL::fetch($result)) { // a user registered on this server if ($item['user_id'] && ($user = Users::get($item['user_id']))) { // make an url $url = Users::get_permalink($user); // gather information on this user if (isset($user['full_name']) && $user['full_name']) { $label = $user['full_name'] . ' (' . $user['nick_name'] . ')'; } else { $label = $user['nick_name']; } $items[] = Skin::build_link($url, $label, 'user'); // we only have some e-mail address } else { $items[] = $item['user_email']; } } // shape a compact list if (count($items)) { $this->feed_back['status'][] = Skin::build_folded_box(i18n::s('Enrolment') . ' (' . count($items) . ')', Skin::finalize_list($items, 'compact')); } } // signal that the event is over $this->feed_back['status'][] = i18n::s('Event is over'); // display the follow-up message if (isset($this->attributes['follow_up_message']) && $this->attributes['follow_up_message']) { $this->feed_back['message'] .= Codes::render($this->attributes['follow_up_message']); } // possible transition to state 'stopped' } else { $this->transition_to_stopped(); } // step 4 - event has started if ($this->attributes['status'] == 'started') { // display the welcome message if (isset($this->attributes['welcome_message'])) { $this->feed_back['message'] .= Codes::render($this->attributes['welcome_message']); } // possible transition to state 'started' } else { $this->transition_to_started(); } // step 3 - waiting for event start if ($this->attributes['status'] == 'lobby') { // display the lobby message if (isset($this->attributes['lobby_message'])) { $this->feed_back['message'] .= Codes::render($this->attributes['lobby_message']); } // possible transition to state 'lobby' } else { $this->transition_to_lobby(); } // step 2 - enrolment has been opened if ($this->attributes['status'] == 'open') { // display the induction message if (isset($this->attributes['induction_message'])) { $this->feed_back['message'] .= Codes::render($this->attributes['induction_message']); } // possible transition to state 'open' } else { $this->transition_to_open(); } // step 1 - at the very beginning of the workflow if (!isset($this->attributes['status']) || $this->attributes['status'] == 'created') { // display the induction message if (isset($this->attributes['induction_message'])) { $this->feed_back['message'] .= Codes::render($this->attributes['induction_message']); } // possible transition to state 'created' } else { $this->transition_to_created(); } // event details if ($details = $this->get_event_details_text()) { $rows[] = array($this->get_event_details_label(), $details); } // meeting date if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) { // offer to update the calendar $button = ''; if ($this->attributes['status'] == 'stopped') { } elseif (enrolments::get_record($this->anchor->get_reference())) { $button = ' ' . Skin::build_link($this->get_url('fetch_ics'), '<img src="' . $context['url_to_root'] . 'included/jscalendar/img.gif" style="border: none; cursor: pointer;" title="' . i18n::s('Update my calendar') . '" onmouseover="this.style.background=\'red\';" onmouseout="this.style.background=\'\'" alt="' . i18n::s('Update my calendar') . '" />', 'basic'); } $rows[] = array(i18n::s('Date'), Skin::build_date($this->attributes['date_stamp'], 'full') . $button); } // meeting duration if (isset($this->attributes['duration']) && $this->attributes['duration'] && $this->attributes['duration'] < 1440) { switch ($this->attributes['duration']) { case 60: $duration = i18n::s('one hour'); break; case 120: $duration = i18n::s('two hours'); break; default: $duration = sprintf(i18n::s('%d minutes'), $this->attributes['duration']); break; } $rows[] = array(i18n::s('Duration'), $duration); } // build a link to the owner page, if any if (isset($this->attributes['chairman']) && $this->attributes['chairman']) { if ($user = Users::get($this->attributes['chairman'])) { $label = Users::get_link($user['full_name'], NULL, $user['id']); } else { $label = $this->attributes['chairman']; } $rows[] = array(i18n::s('Chairman'), $label); } // finalize status if (is_callable(array($this, 'finalize_status'))) { $this->feed_back['status'] = $this->finalize_status($this->feed_back['status']); } // finalize menu if (is_callable(array($this, 'finalize_menu'))) { $this->feed_back['menu'] = $this->finalize_menu($this->feed_back['menu']); } // we have to refresh the page if ($this->feed_back['reload_this_page']) { $reload_through_javascript = '<img alt="*" src="' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/ajax/ajax_spinner.gif" style="vertical-align:-3px" /> '; Page::insert_script('window.location.reload(true);'); $rows[] = array(i18n::s('Status'), $reload_through_javascript); // display the status line and/or buttons } elseif (count($this->feed_back['status']) || count($this->feed_back['menu'])) { $status = ''; // embed status line if (count($this->feed_back['status'])) { $status .= implode(BR, $this->feed_back['status']); } // embed menu bar if (count($this->feed_back['menu'])) { $status .= Skin::finalize_list($this->feed_back['menu'], 'menu_bar'); } $rows[] = array(i18n::s('Status'), $status); } // display commands to page owner if (count($this->feed_back['commands'])) { $rows[] = array('', Skin::finalize_list($this->feed_back['commands'], 'menu_bar')); } // format text in a table $text = Skin::table(NULL, $rows, 'grid'); // finalize feed-back if ($this->feed_back['message']) { $text .= Skin::build_box($this->get_message_label(), $this->feed_back['message']); } // allow for extensions if (is_callable(array($this, 'get_view_text_extension'))) { $text .= $this->get_view_text_extension(); } // job done return $text; }
Safe::closedir($dir); } if ($text) { $context['text'] .= Skin::build_content(NULL, i18n::s('Use the library'), $text); } // display the current gravatar, if any if (isset($item['email']) && $item['email']) { $text = ''; // the gravatar url $url = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($item['email']); // it is already in use if (isset($item['avatar_url']) && $url == $item['avatar_url']) { $text .= '<p>' . sprintf(i18n::s('Your are using your %s as current picture.'), Skin::build_link('http://www.gravatar.com/', i18n::s('gravatar'), 'external')) . '</p>' . "\n"; } else { $text .= '<p>' . sprintf(i18n::s('I have a %s and %s'), Skin::build_link('http://www.gravatar.com/', i18n::s('gravatar'), 'external'), '<a href="' . $context['url_to_root'] . 'users/select_avatar.php?id=' . $id . '&avatar=' . urlencode($url) . '">' . i18n::s('would like to use it') . '</a>') . '</p>' . "\n"; } $context['text'] .= Skin::build_content(NULL, i18n::s('Use a gravatar'), $text); } // // bottom commands // $menu = array(); global $render_overlaid; if (!$render_overlaid) { $menu[] = Skin::build_link(Users::get_permalink($item), i18n::s('Cancel'), 'span'); } //$menu[] = Skin::build_link(Users::get_permalink($item), i18n::s('Cancel'), 'button'); $context['text'] .= Skin::finalize_list($menu, 'assistant_bar'); } // render the skin render_skin();
/** * list users * * @param resource the SQL result * @return array of resulting items (id => label), or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!($delta = SQL::count($result))) { return $items; } // build a list of users while ($item = SQL::fetch($result)) { // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private users if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View profile'); if (Surfer::is_member()) { $hover .= ' [user='******'id'] . ']'; } // the url to view this item $url = Users::get_permalink($item); // use full name, then nick name if (isset($item['full_name']) && $item['full_name']) { $title = $item['full_name']; } elseif (isset($item['nick_name'])) { $title = $item['nick_name']; } // show contact information if (Surfer::may_contact() && ($contacts = Users::build_presence($item))) { $suffix .= ' ' . $contacts; } // flag users updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG . ' '; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG . ' '; } // do not use description because of codes such as location, etc if (isset($item['introduction']) && $item['introduction']) { $suffix .= ' - ' . Codes::beautify($item['introduction']); } // display all tags // if($item['tags']) // $suffix .= ' <span class="details tags">'.Skin::build_tags($item['tags'], 'user:'******'id']).'</span>'; // the full label $label = $prefix . Skin::build_link($url, $title, 'basic', $hover) . $suffix; // use the avatar, if any $icon = ''; if (isset($item['avatar_url']) && $item['avatar_url']) { $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['avatar_url'] . '" alt=" " title="' . encode_field($hover) . '" style="float: left; max-width: 25px; max-height: 25px; margin-right: 4px;" /></a>'; } // list all components for this item --use basic link style to avoid prefix or suffix images, if any $items[$item['id']] = $icon . $label; } // end of processing SQL::free($result); // job done return $items; }
/** * reference another page at this site * * The function transforms a local reference (e.g;, [code][user=2][/code]) * to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]), * adds a title and, sometimes, set a description as well. * * @param string any string, maybe with a local reference in it * @return an array($url, $title, $description) or NULL * * @see images/view.php * @see links/edit.php * @see shared/codes.php */ public static function transform_reference($text) { global $context; // translate this reference to an internal link if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) { switch ($matches[1]) { // article link case 'article': if ($item = Articles::get($matches[2])) { return array(Articles::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // section link // section link case 'section': if ($item = Sections::get($matches[2])) { return array(Sections::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // file link // file link case 'file': if ($item = Files::get($matches[2])) { return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name']))); } return array('', $text, ''); // image link // image link case 'image': include_once $context['path_to_root'] . 'images/images.php'; if ($item = Images::get($matches[2])) { return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name']))); } return array('', $text, ''); // category link // category link case 'category': if ($item = Categories::get($matches[2])) { return array(Categories::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // user link // user link case 'user': if ($item = Users::get($matches[2])) { return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']); } return array('', $text, ''); } } return array('', $text, ''); }
/** * render a link to an object * * Following types are supported: * - article - link to an article page * - category - link to a category page * - comment - link to a comment page * - download - link to a download page * - file - link to a file page * - flash - display a file as a native flash object, or play a flash video * - go * - image - display an in-line image * - next - link to an article page * - previous - link to an article page * - section - link to a section page * - server - link to a server page * - user - link to a user page * * @param string the type * @param string the id, with possible options or variant * @return string the rendered text **/ public static function render_object($type, $id) { global $context; $id = Codes::fix_tags($id); // depending on type switch ($type) { // link to an article case 'article': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Articles::get($id))) { $output = '[article=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Articles::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, $type); } return $output; // insert article description // insert article description case 'article.description': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Articles::get($id))) { $output = '[article.description=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Articles::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, 'article'); // the introduction text, if any $output .= BR . Codes::beautify($item['introduction']); // load overlay, if any if (isset($item['overlay']) && $item['overlay']) { $overlay = Overlay::load($item, 'article:' . $item['id']); // get text related to the overlay, if any if (is_object($overlay)) { $output .= $overlay->get_text('view', $item); } } // the description, which is the actual page body $output .= '<div>' . Codes::beautify($item['description']) . '</div>'; } return $output; // link to a category // link to a category case 'category': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Categories::get($id))) { $output = '[category=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Categories::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, $type); } return $output; // insert category description // insert category description case 'category.description': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Categories::get($id))) { $output = '[category.description=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Categories::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, 'category'); // the introduction text, if any $output .= BR . Codes::beautify($item['introduction']); // load overlay, if any if (isset($item['overlay']) && $item['overlay']) { $overlay = Overlay::load($item, 'category:' . $item['id']); // get text related to the overlay, if any if (is_object($overlay)) { $output .= $overlay->get_text('view', $item); } } // the description, which is the actual page body $output .= '<div>' . Codes::beautify($item['description']) . '</div>'; } return $output; // link to a comment // link to a comment case 'comment': include_once $context['path_to_root'] . 'comments/comments.php'; // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Comments::get($id))) { $output = '[comment=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; } else { $text = i18n::s('View this comment'); } // make a link to the target page $url = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id']); // return a complete anchor $output =& Skin::build_link($url, $text, 'basic'); } return $output; // link to a download // link to a download case 'download': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Files::get($id))) { // file does not exist anymore if (isset($attributes[1]) && $attributes[1]) { $output = $attributes[1] . '<p class="details">' . i18n::s('[this file has been deleted]') . '</p>'; } else { $output = '[download=' . $id . ']'; } } else { // label for this file $prefix = $text = $suffix = ''; // signal restricted and private files if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // ensure we have a label for this link if (isset($attributes[1]) && $attributes[1]) { $text .= $attributes[1]; // this may describe a previous file, which has been replaced if ($item['edit_action'] != 'file:create' && $attributes[1] != $item['file_name']) { $text .= ' <p class="details">' . i18n::s('[this file has been replaced]') . '</p>'; $output = $prefix . $text . $suffix; return $output; } } else { $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name'])); } // flag files uploaded recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // always download the file $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']); // return a complete anchor $output = $prefix . Skin::build_link($url, $text, 'file') . $suffix; } return $output; // link to a file // link to a file case 'file': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database --ensure we get a fresh copy of the record, not a cached one if (!($item = Files::get($id, TRUE))) { // file does not exist anymore if (isset($attributes[1]) && $attributes[1]) { $output = $attributes[1] . '<p class="details">' . i18n::s('[this file has been deleted]') . '</p>'; } else { $output = '[file=' . $id . ']'; } } else { // maybe we want to illustrate this file if ($item['edit_action'] != 'file:create' && isset($attributes[1]) && $attributes[1] || !($output = Files::interact($item))) { // label for this file $output = $prefix = $text = $suffix = ''; // signal restricted and private files if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // ensure we have a label for this link if (isset($attributes[1]) && $attributes[1]) { $text .= $attributes[1]; // this may describe a previous file, which has been replaced if ($item['edit_action'] != 'file:create' && $attributes[1] != $item['file_name']) { $text .= '<p class="details">' . i18n::s('[this file has been replaced]') . '</p>'; $output = $prefix . $text . $suffix; return $output; } } else { $text .= Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name'])); } // flag files uploaded recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // make a link to the target page $url = Files::get_download_url($item); // return a complete anchor $output .= $prefix . Skin::build_link($url, $text, 'basic') . $suffix; } } return $output; // invoke the selector // invoke the selector case 'go': // extract the label, if any $attributes = preg_split("/\\s*,\\s*/", $id, 2); $name = $attributes[0]; // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; } else { $text = $name; } // return a complete anchor $output = Skin::build_link($context['url_to_home'] . $context['url_to_root'] . normalize_shortcut($name), $text, 'basic'); return $output; // embed an image // embed an image case 'image': include_once $context['path_to_root'] . 'images/images.php'; // get the variant, if any $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; if (isset($attributes[1])) { $variant = $attributes[1]; } else { $variant = 'inline'; } // get the image record if (!($image = Images::get($id))) { $output = '[image=' . $id . ']'; return $output; } // a title for the image --do not force a title if (isset($image['title'])) { $title = $image['title']; } else { $title = ''; } // provide thumbnail if not defined, or forced, or for large images if (!$image['use_thumbnail'] || $image['use_thumbnail'] == 'A' || $image['use_thumbnail'] == 'Y' && $image['image_size'] > $context['thumbnail_threshold']) { // not inline anymore, but thumbnail --preserve other variants if ($variant == 'inline') { $variant = 'thumbnail'; } // where to fetch the image file $href = Images::get_thumbnail_href($image); // to drive to plain image $link = Images::get_icon_href($image); // add an url, if any } elseif ($image['link_url']) { // flag large images if ($image['image_size'] > $context['thumbnail_threshold']) { $variant = rtrim('large ' . $variant); } // where to fetch the image file $href = Images::get_icon_href($image); // transform local references, if any include_once $context['path_to_root'] . '/links/links.php'; $attributes = Links::transform_reference($image['link_url']); if ($attributes[0]) { $link = $context['url_to_root'] . $attributes[0]; } else { $link = $image['link_url']; } // get the <img ... /> element } else { // do not append poor titles to inline images if ($variant == 'inline') { $title = ''; } // flag large images if ($image['image_size'] > $context['thumbnail_threshold']) { $variant = rtrim('large ' . $variant); } // where to fetch the image file $href = Images::get_icon_href($image); // no link $link = ''; } // use the skin if (Images::allow_modification($image['anchor'], $id)) { // build editable image $output =& Skin::build_image($variant, $href, $title, $link, $id); } else { $output =& Skin::build_image($variant, $href, $title, $link); } return $output; // embed a stack of images // embed a stack of images case 'images': include_once $context['path_to_root'] . 'images/images.php'; // get the list of ids $ids = preg_split("/\\s*,\\s*/", $id); if (!count($ids)) { $output = '[images=id1, id2, ...]'; return $output; } // build the list of images $items = array(); foreach ($ids as $id) { // get the image record if ($image = Images::get($id)) { // a title for the image --do not force a title if (isset($image['title'])) { $title = $image['title']; } else { $title = ''; } // provide thumbnail if not defined, or forced, or for large images $variant = 'inline'; if (!$image['use_thumbnail'] || $image['use_thumbnail'] == 'A' || $image['use_thumbnail'] == 'Y' && $image['image_size'] > $context['thumbnail_threshold']) { // not inline anymore, but thumbnail $variant = 'thumbnail'; // where to fetch the image file $href = Images::get_thumbnail_href($image); // to drive to plain image $link = $context['url_to_root'] . Images::get_url($id); // add an url, if any } elseif ($image['link_url']) { // flag large images if ($image['image_size'] > $context['thumbnail_threshold']) { $variant = rtrim('large ' . $variant); } // where to fetch the image file $href = Images::get_icon_href($image); // transform local references, if any include_once $context['path_to_root'] . '/links/links.php'; $attributes = Links::transform_reference($image['link_url']); if ($attributes[0]) { $link = $context['url_to_root'] . $attributes[0]; } else { $link = $image['link_url']; } // get the <img ... /> element } else { // flag large images if ($image['image_size'] > $context['thumbnail_threshold']) { $variant = rtrim('large ' . $variant); } // where to fetch the image file $href = Images::get_icon_href($image); // no link $link = ''; } // use the skin $label =& Skin::build_image($variant, $href, $title, $link); // add item to the stack $items[] = $label; } } // format the list $output = ''; if (count($items)) { // stack items $output = Skin::finalize_list($items, 'stack'); // rotate items $output = Skin::rotate($output); } // done return $output; // link to the next article // link to the next article case 'next': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Articles::get($id))) { $output = '[next=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Articles::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, 'next'); } return $output; // link to the previous article // link to the previous article case 'previous': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Articles::get($id))) { $output = '[previous=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Articles::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, 'previous'); } return $output; // link to a section // link to a section case 'section': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Sections::get($id))) { $output = '[section=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = Sections::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, $type); } return $output; // link to a server // link to a server case 'server': include_once $context['path_to_root'] . 'servers/servers.php'; // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Servers::get($id))) { $output = '[server=' . $id . ']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } else { $text = Skin::strip($item['title']); } // make a link to the target page $url = $context['url_to_home'] . $context['url_to_root'] . Servers::get_url($id); // return a complete anchor $output =& Skin::build_link($url, $text, $type); } return $output; // link to a user // link to a user case 'user': // maybe an alternate title has been provided $attributes = preg_split("/\\s*,\\s*/", $id, 2); $id = $attributes[0]; // load the record from the database if (!($item = Users::get($id))) { $output = '[user='******']'; } else { // ensure we have a label for this link if (isset($attributes[1])) { $text = $attributes[1]; $type = 'basic'; } elseif (isset($item['full_name']) && $item['full_name']) { $text = ucfirst($item['full_name']); } else { $text = ucfirst($item['nick_name']); } // make a link to the target page $url = Users::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text, $type); } return $output; // invalid type // invalid type default: $output = '[' . $type . ']'; return $output; } }