示例#1
0
 /**
  * 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;
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
文件: surfer.php 项目: rair/yacs
 /**
  * can this surfer mail other users?
  *
  * @return TRUE if alowed, FALSE otherwise
  */
 public static function may_mail()
 {
     global $context;
     // email has to be activated
     if (!isset($context['with_email'])) {
         return FALSE;
     }
     if ($context['with_email'] != 'Y') {
         return FALSE;
     }
     // only members can send e-mail
     if (!Surfer::is_member()) {
         return FALSE;
     }
     return Surfer::may_contact();
 }
示例#4
0
 /**
  * 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;
 }
示例#5
0
 /**
  * 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 .= ' -&nbsp;' . Codes::beautify($item['introduction']);
             } else {
                 $suffix .= ' -&nbsp;' . $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;
 }
示例#6
0
文件: view.php 项目: rair/yacs
     $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']));
     }
     // a clickable jabber address
     if (isset($item['jabber_address']) && $item['jabber_address']) {
         $rows[] = array(i18n::s('Jabber'), Skin::build_presence($item['jabber_address'], 'jabber') . ' ' . $item['jabber_address']);
     }
     // a clickable skype address
     if (isset($item['skype_address']) && $item['skype_address']) {
         $rows[] = array(i18n::s('Skype'), Skin::build_presence($item['skype_address'], 'skype') . ' ' . $item['skype_address']);
     }
     // a clickable yahoo address -- the on-line status indicator requires to be connected to the Internet