/**
  * Returns possible matches for the string input
  *
  * @access	private
  * @return	void		Outputs to screen
  */
 private function _getMemberNames()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $name = $this->convertAndMakeSafe(ipsRegistry::$request['name'], 0);
     //-----------------------------------------
     // Check length
     //-----------------------------------------
     if (IPSText::mbstrlen($name) < 3) {
         $this->returnJsonError('requestTooShort');
     }
     //-----------------------------------------
     // Try query...
     //-----------------------------------------
     $this->DB->build(array('select' => 'm.members_display_name, m.name, m.member_id, m.member_group_id', 'from' => array('members' => 'm'), 'where' => "LOWER(m.members_display_name) LIKE '" . $this->DB->addSlashes($name) . "%'", 'order' => $this->DB->buildLength('m.members_display_name') . ' ASC', 'limit' => array(0, 15), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id', 'type' => 'left'))));
     $this->DB->execute();
     //-----------------------------------------
     // Got any results?
     //-----------------------------------------
     if (!$this->DB->getTotalRows()) {
         $this->returnJsonArray(array());
     }
     $return = array();
     while ($r = $this->DB->fetch()) {
         $photo = IPSMember::buildProfilePhoto($r);
         $group = IPSLib::makeNameFormatted('', $r['member_group_id']);
         $return[$r['member_id']] = array('name' => $r['members_display_name'], 'showas' => '<strong>' . $r['members_display_name'] . '</strong> (' . $group . ')', 'img' => $photo['pp_thumb_photo'], 'img_w' => $photo['pp_mini_width'], 'img_h' => $photo['pp_mini_height']);
     }
     $this->returnJsonArray($return);
 }
 function __f__3ef85bd3791d32df62652eaa78601bc1($messages, $dirname, $pages, $currentFolderID, $jumpFolderHTML)
 {
     $_ips___x_retval = '';
     $__iteratorCount = 0;
     foreach ($messages as $id => $msg) {
         $__iteratorCount++;
         $_ips___x_retval .= "\r\n\t\t\t\t\t\t\t<tr id='{$msg['mt_id']}' class='" . ($msg['map_has_unread'] ? "unread" : "") . "'>\r\n\t\t\t\t\t\t\t\t<td class='col_m_photo altrow short'>\r\n\t\t\t\t\t\t\t\t\t" . ($msg['_starterMemberData']['member_id'] ? "\r\n\t\t\t\t\t\t\t\t\t\t<a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("showuser={$msg['_starterMemberData']['member_id']}", "public", ''), "{$msg['_starterMemberData']['members_seo_name']}", "showuser") . "' class='ipsUserPhotoLink'>\r\n\t\t\t\t\t\t\t\t\t\t\t<img src='{$msg['_starterMemberData']['pp_thumb_photo']}' class='ipsUserPhoto ipsUserPhoto_mini' />\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t" : "\r\n\t\t\t\t\t\t\t\t\t\t" . IPSMember::buildProfilePhoto(0, 'mini') . "\r\n\t\t\t\t\t\t\t\t\t") . "\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t<td class='col_m_subject'>\r\n\t\t\t\t\t\t\t\t\t" . (($msg['mt_is_deleted'] or $msg['map_user_banned']) ? "\r\n\t\t\t\t\t\t\t\t\t\t<span class='ipsBadge ipsBadge_red'>\r\n\t\t\t\t\t\t\t\t\t\t\t{$this->lang->words['msg_deleted']}\r\n\t\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t\t" : "") . "\r\n\t\t\t\t\t\t\t\t\t<h4>\r\n\t\t\t\t\t\t\t\t\t\t" . ($msg['map_has_unread'] ? "\r\n\t\t\t\t\t\t\t\t\t\t\t<a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&amp;module=messaging&amp;section=view&amp;do=findMessage&amp;topicID={$msg['mt_id']}&amp;msgID=__firstUnread__", "public", ''), "", "") . "' title='{$this->lang->words['first_unread_reply']}'>" . $this->registry->getClass('output')->getReplacement("f_newpost") . "</a>\r\n\t\t\t\t\t\t\t\t\t\t\t<strong>\r\n\t\t\t\t\t\t\t\t\t\t" : "") . "\r\n\t\t\t\t\t\t\t\t\t\t<a href='" . ($currentFolderID == 'drafts' ? "" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&amp;module=messaging&amp;section=send&amp;do=form&amp;topicID={$msg['mt_id']}", "public", ''), "", "") . "" : "" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&amp;module=messaging&amp;section=view&amp;do=showConversation&amp;topicID={$msg['mt_id']}", "public", ''), "", "") . "") . "' title='{$this->lang->words['msg_view_conversation']}'>\r\n\t\t\t\t\t\t\t\t\t\t{$msg['mt_title']}\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t\t" . ($msg['map_has_unread'] ? "</strong>" : "") . "\r\n\t\t\t\t\t\t\t\t\t</h4>\r\n\t\t\t\t\t\t\t\t\t" . ($msg['map_ignore_notification'] ? "\r\n\t\t\t\t\t\t\t\t\t\t<span class='ipsBadge ipsBadge_lightgrey'>\r\n\t\t\t\t\t\t\t\t\t\t\t{$this->lang->words['msg_no_notify']}\r\n\t\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t\t" : "") . "\r\n\t\t\t\t\t\t\t\t\t<br />\r\n\t\t\t\t\t\t\t\t\t<span class='desc lighter blend_links'>\r\n\t\t\t\t\t\t\t\t\t\t{$this->lang->words['msg_startedby']}\r\n\t\t\t\t\t\t\t\t\t\t" . ($msg['_starterMemberData']['members_display_name'] ? "\r\n\t\t\t\t\t\t\t\t\t\t\t" . (method_exists($this->registry->getClass('output')->getTemplate('global'), 'userHoverCard') ? $this->registry->getClass('output')->getTemplate('global')->userHoverCard($msg['_starterMemberData']) : '') . ",\r\n\t\t\t\t\t\t\t\t\t\t" : "\r\n\t\t\t\t\t\t\t\t\t\t\t<span class='desc'>{$this->lang->words['deleted_user']},</span>\r\n\t\t\t\t\t\t\t\t\t\t") . "\r\n\t\t\t\t\t\t\t\t\t\t<span class='desc lighter blend_links'>\r\n\t\t\t\t\t\t\t\t\t\t\t{$this->lang->words['msg_sentto']}\r\n\t\t\t\t\t\t\t\t\t\t\t" . ($msg['_toMemberData']['members_display_name'] ? "\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . (method_exists($this->registry->getClass('output')->getTemplate('global'), 'userHoverCard') ? $this->registry->getClass('output')->getTemplate('global')->userHoverCard($msg['_toMemberData']) : '') . "\r\n\t\t\t\t\t\t\t\t\t\t\t" : "\r\n\t\t\t\t\t\t\t\t\t\t\t\t<span class='desc'>{$this->lang->words['deleted_user']}</span>\r\n\t\t\t\t\t\t\t\t\t\t\t") . "\r\n\t\t\t\t\t\t\t\t\t\t\t" . ($msg['_otherInviteeCount'] > 0 ? "" . ($msg['_otherInviteeCount'] > 1 ? "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span title='" . implode(', ', $msg['_invitedMemberNames']) . "'>({$this->lang->words['pc_and']} {$msg['_otherInviteeCount']} {$this->lang->words['pc_others']})</span>\r\n\t\t\t\t\t\t\t\t\t\t\t\t" : "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span title='" . implode(', ', $msg['_invitedMemberNames']) . "'>({$this->lang->words['pc_and']} {$msg['_otherInviteeCount']} {$this->lang->words['pc_other']})</span>\r\n\t\t\t\t\t\t\t\t\t\t\t\t") . "" : "") . "\r\n\t\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t\t\t" . (in_array($currentFolderID, array('new')) ? "\r\n\t\t\t\t\t\t\t\t\t\t\t<p class='ipsType_small desc'>{$this->lang->words['folder_prefix']} {$msg['_folderName']}</p>\r\n\t\t\t\t\t\t\t\t\t\t" : "") . "\r\n\t\t\t\t\t\t\t\t\t</span>\t\r\n\t\t\t\t\t\t\t\t\t" . ((is_array($msg['pages']) and count($msg['pages'])) ? "\r\n\t\t\t\t\t\t\t\t\t\t<ul class='mini_pagination'>\r\n\t\t\t\t\t\t\t\t\t\t" . $this->__f__c968b6ba9ecaa79fff521ea4ef309c7f($messages, $dirname, $pages, $currentFolderID, $jumpFolderHTML, $id, $msg) . "\t\t\t\t\t\t\t\t\t\t</ul>\r\n\t\t\t\t\t\t\t\t\t" : "") . "\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t<td class='col_m_replies desc blend_links'>\r\n\t\t\t\t\t\t\t\t\t<ul>\r\n\t\t\t\t\t\t\t\t\t\t<li>" . ($msg['map_user_banned'] ? "-" : "" . sprintf($this->lang->words['msg_xreplies'], intval($msg['mt_replies'])) . "") . "</li>\r\n\t\t\t\t\t\t\t\t\t</ul>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t<td class='col_f_post'>\r\n\t\t\t\t\t\t\t\t\t" . ($msg['_lastMsgAuthor']['member_id'] ? "\r\n\t\t\t\t\t\t\t\t\t\t<a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("showuser={$msg['_lastMsgAuthor']['member_id']}", "public", ''), "{$msg['_lastMsgAuthor']['members_seo_name']}", "showuser") . "' class='ipsUserPhotoLink left'>\r\n\t\t\t\t\t\t\t\t\t\t\t<img src='{$msg['_lastMsgAuthor']['pp_thumb_photo']}' class='ipsUserPhoto ipsUserPhoto_mini' />\r\n\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t" : "\r\n\t\t\t\t\t\t\t\t\t\t<span class='left'>" . IPSMember::buildProfilePhoto(0, 'mini') . "</span>\r\n\t\t\t\t\t\t\t\t\t") . "\r\n\t\t\t\t\t\t\t\t\t<ul class='last_post ipsType_small'>\r\n\t\t\t\t\t\t\t\t\t\t" . ($msg['map_user_banned'] ? "\r\n\t\t\t\t\t\t\t\t\t\t\t<li><em>{$this->lang->words['info_not_available']}</em></li>\r\n\t\t\t\t\t\t\t\t\t\t" : "<li>{$this->lang->words['pc_by']} " . ($msg['_lastMsgAuthor']['members_display_name'] ? "" . (method_exists($this->registry->getClass('output')->getTemplate('global'), 'userHoverCard') ? $this->registry->getClass('output')->getTemplate('global')->userHoverCard($msg['_lastMsgAuthor']) : '') . "" : "<span class='desc'>{$this->lang->words['deleted_user']}</span>") . "</li>") . "\r\n\t\t\t\t\t\t\t\t\t\t<li class='desc'>\r\n\t\t\t\t\t\t\t\t\t\t\t<a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&amp;module=messaging&amp;section=view&amp;do=findMessage&amp;topicID={$msg['mt_id']}&amp;msgID={$msg['mt_last_msg_id']}", "public", ''), "", "") . "' title='{$this->lang->words['goto_last_post']}'>" . IPSText::htmlspecialchars($this->registry->getClass('class_localization')->getDate($msg['mt_last_post_time'], "DATE", 0)) . "</a>\r\n\t\t\t\t\t\t\t\t\t\t</li>\r\n\t\t\t\t\t\t\t\t\t</ul>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t<td class='col_m_mod short'>\r\n\t\t\t\t\t\t\t\t\t<input type='checkbox' class='input_check msg_check' name='msgid[{$msg['mt_id']}]' id='msg_check_{$msg['mt_id']}' />\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\r\n";
     }
     $_ips___x_retval .= '';
     unset($__iteratorCount);
     return $_ips___x_retval;
 }
示例#3
0
 /**
  * Builds an array of forum data for use in the output template
  *
  * @return	array
  */
 public function renderForum()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['page'] = $this->request['changefilters'] ? 0 : (isset($this->request['page']) ? intval($this->request['page']) : 0);
     $announce_data = array();
     $topic_data = array();
     $other_data = array();
     $multi_mod_data = array();
     $footer_filter = array();
     $member_ids = array();
     //-----------------------------------------
     // Show?
     //-----------------------------------------
     if (isset($this->request['show']) and $this->request['show'] == 'sinceLastVisit') {
         $this->request['prune_day'] = 200;
     }
     //-----------------------------------------
     // Are we actually a moderator for this forum?
     //-----------------------------------------
     $mod = $this->memberData['forumsModeratorData'];
     if (!$this->memberData['g_is_supmod']) {
         if (!isset($mod[$this->forum['id']]) or !is_array($mod[$this->forum['id']])) {
             $this->memberData['is_mod'] = 0;
         }
     }
     //-----------------------------------------
     // Announcements
     //-----------------------------------------
     if (is_array($this->registry->cache()->getCache('announcements')) and count($this->registry->cache()->getCache('announcements'))) {
         $announcements = array();
         foreach ($this->registry->cache()->getCache('announcements') as $announce) {
             $order = $announce['announce_start'] ? $announce['announce_start'] . ',' . $announce['announce_id'] : $announce['announce_id'];
             if ($announce['announce_forum'] == '*') {
                 $announcements[$order] = $announce;
             } else {
                 if (strstr(',' . $announce['announce_forum'] . ',', ',' . $this->forum['id'] . ',')) {
                     $announcements[$order] = $announce;
                 }
             }
         }
         if (count($announcements)) {
             //-----------------------------------------
             // sort by start date
             //-----------------------------------------
             krsort($announcements);
             foreach ($announcements as $announce) {
                 if ($announce['announce_start']) {
                     $announce['announce_start'] = $this->lang->getDate($announce['announce_start'], 'date');
                 } else {
                     $announce['announce_start'] = '--';
                 }
                 $announce['announce_title'] = IPSText::stripslashes($announce['announce_title']);
                 $announce['forum_id'] = $this->forum['id'];
                 $announce['announce_views'] = intval($announce['announce_views']);
                 $announce_data[] = $announce;
                 $member_ids[$announce['member_id']] = $announce['member_id'];
             }
             $this->forum['_showAnnouncementsBar'] = 1;
         }
     }
     //-----------------------------------------
     // Read topics
     //-----------------------------------------
     $First = $this->registry->class_forums->pageToSt(intval($this->request['page']));
     //-----------------------------------------
     // Sort options
     //-----------------------------------------
     $cookie_prune = IPSCookie::get($this->forum['id'] . "_prune_day");
     $cookie_sort = IPSCookie::get($this->forum['id'] . "_sort_key");
     $cookie_sortb = IPSCookie::get($this->forum['id'] . "_sort_by");
     $cookie_fill = IPSCookie::get($this->forum['id'] . "_topicfilter");
     $prune_value = $this->selectVariable(array(1 => !empty($this->request['prune_day']) ? $this->request['prune_day'] : NULL, 2 => !empty($cookie_prune) ? $cookie_prune : NULL, 3 => $this->forum['prune'], 4 => '100'));
     $sort_key = $this->selectVariable(array(1 => !empty($this->request['sort_key']) ? $this->request['sort_key'] : NULL, 2 => !empty($cookie_sort) ? $cookie_sort : NULL, 3 => $this->forum['sort_key'], 4 => 'last_post'));
     $sort_by = $this->selectVariable(array(1 => !empty($this->request['sort_by']) ? $this->request['sort_by'] : NULL, 2 => !empty($cookie_sortb) ? $cookie_sortb : NULL, 3 => $this->forum['sort_order'], 4 => 'Z-A'));
     $topicfilter = $this->selectVariable(array(1 => !empty($this->request['topicfilter']) ? $this->request['topicfilter'] : NULL, 2 => !empty($cookie_fill) ? $cookie_fill : NULL, 3 => $this->forum['topicfilter'], 4 => 'all'));
     if (!empty($this->request['remember'])) {
         if ($this->request['prune_day']) {
             IPSCookie::set($this->forum['id'] . "_prune_day", $this->request['prune_day']);
         }
         if ($this->request['sort_key']) {
             IPSCookie::set($this->forum['id'] . "_sort_key", $this->request['sort_key']);
         }
         if ($this->request['sort_by']) {
             IPSCookie::set($this->forum['id'] . "_sort_by", $this->request['sort_by']);
         }
         if ($this->request['topicfilter']) {
             IPSCookie::set($this->forum['id'] . "_topicfilter", $this->request['topicfilter']);
         }
     }
     //-----------------------------------------
     // Figure out sort order, day cut off, etc
     //-----------------------------------------
     $Prune = $prune_value < 100 ? time() - $prune_value * 60 * 60 * 24 : (($prune_value == 200 and $this->memberData['member_id']) ? $this->memberData['last_visit'] : 0);
     $sort_keys = array('last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views');
     $prune_by_day = array('1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', '200' => 'show_last_visit');
     $sort_by_keys = array('Z-A' => 'descending_order', 'A-Z' => 'ascending_order');
     $filter_keys = array('all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved');
     if ($this->memberData['member_id']) {
         $filter_keys['istarted'] = 'topicfilter_istarted';
         $filter_keys['ireplied'] = 'topicfilter_ireplied';
     }
     //-----------------------------------------
     // check for any form funny business by wanna-be hackers
     //-----------------------------------------
     if (!isset($filter_keys[$topicfilter]) or !isset($sort_keys[$sort_key]) or !isset($prune_by_day[$prune_value]) or !isset($sort_by_keys[strtoupper($sort_by)])) {
         $this->registry->getClass('output')->showError('forums_bad_filter', 10339);
     }
     $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
     //-----------------------------------------
     // If sorting by starter, add secondary..
     //-----------------------------------------
     $sort_key_chk = $sort_key;
     if ($sort_key == 'starter_name') {
         $sort_key = "starter_name {$r_sort_by}, t.last_post DESC";
         $r_sort_by = '';
     }
     //-----------------------------------------
     // Additional queries?
     //-----------------------------------------
     $add_query_array = array();
     $add_query = "";
     switch ($topicfilter) {
         case 'all':
             break;
         case 'open':
             $add_query_array[] = "t.state='open'";
             break;
         case 'hot':
             $add_query_array[] = "t.state='open' AND t.posts + 1 >= " . intval($this->settings['hot_topic']);
             break;
         case 'locked':
             $add_query_array[] = "t.state='closed'";
             break;
         case 'moved':
             $add_query_array[] = "t.state='link'";
             break;
         case 'poll':
             $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)";
             break;
         default:
             break;
     }
     if (!$this->memberData['g_other_topics'] or $topicfilter == 'istarted' or !$this->forum['can_view_others'] and !$this->memberData['is_mod']) {
         $add_query_array[] = "t.starter_id='" . $this->memberData['member_id'] . "'";
     }
     /* Answered / unanswered */
     if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) {
         if ($this->request['answered'] == 'true') {
             $add_query_array[] = 't.topic_answered_pid != 0';
         } else {
             if ($this->request['answered'] == 'false') {
                 $add_query_array[] = 't.topic_answered_pid = 0';
             }
         }
     }
     $_SQL_EXTRA = '';
     $_SQL_APPROVED = '';
     $_SQL_AGE_PRUNE = '';
     if (count($add_query_array)) {
         $_SQL_EXTRA = ' AND ' . implode(' AND ', $add_query_array);
     }
     //-----------------------------------------
     // Moderator?
     //-----------------------------------------
     $this->request['modfilter'] = isset($this->request['modfilter']) ? $this->request['modfilter'] : '';
     $modFilter = '';
     if ($this->memberData['is_mod']) {
         if ($this->request['modfilter'] == 'unapproved') {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('hidden'), 't.') . ' OR t.topic_queuedposts';
         } elseif ($this->permissions['TopicSoftDeleteSee']) {
             if ($this->request['modfilter'] == 'hidden') {
                 $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted'), 't.') . ' OR t.topic_deleted_posts';
             } else {
                 $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden', 'sdeleted'), 't.');
             }
         } else {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden'), 't.');
         }
     } else {
         if ($this->permissions['TopicSoftDeleteSee']) {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'sdeleted'), 't.');
         } else {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible'), 't.');
         }
     }
     if ($modFilter) {
         $_SQL_APPROVED = ' AND (' . $modFilter . ')';
     }
     if ($Prune) {
         if ($prune_value == 200) {
             /* Just new content, don't show pinned, please */
             if ($modFilter) {
                 $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune} AND ( {$modFilter} ) )";
             } else {
                 $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune})";
             }
         } else {
             if ($modFilter) {
                 $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune} AND ( {$modFilter} ) )";
             } else {
                 $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune})";
             }
         }
     }
     //-----------------------------------------
     // Query the database to see how many topics there are in the forum
     //-----------------------------------------
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         //-----------------------------------------
         $this->DB->build(array('select' => 'COUNT(' . $this->DB->buildDistinct('p.topic_id') . ') as max', 'from' => array('topics' => 't'), 'where' => "t.forum_id={$this->forum['id']} AND p.author_id=" . $this->memberData['member_id'] . " AND p.new_topic=0" . $_SQL_APPROVED . $_SQL_AGE_PRUNE, 'add_join' => array(array('from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid'))));
         $this->DB->execute();
         $total_possible = $this->DB->fetch();
     } else {
         if ($_SQL_EXTRA or $_SQL_AGE_PRUNE or $this->request['modfilter']) {
             $this->DB->build(array('select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA));
             $this->DB->execute();
             $total_possible = $this->DB->fetch();
         } else {
             $total_possible['max'] = $this->memberData['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics'];
             if ($this->permissions['TopicSoftDeleteSee'] and $this->forum['deleted_topics']) {
                 $total_possible['max'] += intval($this->forum['deleted_topics']);
             }
             $Prune = 0;
         }
     }
     //-----------------------------------------
     // Generate the forum page span links
     //-----------------------------------------
     $_extraStuff = '';
     if ($this->request['modfilter']) {
         $_extraStuff .= "&amp;modfilter=" . $this->request['modfilter'];
     }
     if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) {
         $_extraStuff .= "&amp;answered=" . $this->request['answered'];
     }
     $this->forum['SHOW_PAGES'] = $this->registry->getClass('output')->generatePagination(array('totalItems' => $total_possible['max'], 'itemsPerPage' => $this->settings['display_max_topics'], 'currentStartValue' => intval($this->request['page']), 'isPagesMode' => true, 'seoTitle' => $this->forum['name_seo'], 'disableSinglePage' => false, 'baseUrl' => "showforum=" . $this->forum['id'] . "&amp;prune_day={$prune_value}&amp;sort_by={$sort_by}&amp;sort_key={$sort_key_chk}&amp;topicfilter={$topicfilter}{$_extraStuff}"));
     //-----------------------------------------
     // Start printing the page
     //-----------------------------------------
     $other_data = array('forum_data' => $this->forum, 'hasMore' => $this->registry->class_forums->pageToSt($this->request['page']) + $this->settings['display_max_topics'] > $total_possible['max'] ? false : true, 'can_edit_topics' => $this->can_edit_topics, 'can_open_topics' => $this->can_open_topics, 'can_close_topics' => $this->can_close_topics, 'can_move_topics' => $this->can_move_topics);
     $total_topics_printed = 0;
     //-----------------------------------------
     // Get main topics
     //-----------------------------------------
     $topic_array = array();
     $topic_ids = array();
     $topic_sort = "";
     //-----------------------------------------
     // Cut off?
     //-----------------------------------------
     $modAll = ($this->memberData['g_is_supmod'] or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($this->memberData['forumsModeratorData'][$this->forum['id']]['delete_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['move_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['split_merge']));
     $parse_dots = 1;
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         // No point in getting dots again...
         //-----------------------------------------
         $parse_dots = 0;
         $_joins = array(array('select' => 't.*', 'from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid AND p.author_id=' . $this->memberData['member_id']));
         if ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) {
             $_joins[] = $this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'));
         }
         // For some reason, mySQL doesn't like the distinct + t.* being in reverse order...
         $this->DB->build(array('select' => $this->DB->buildDistinct('p.author_id'), 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . " AND p.new_topic=0", 'order' => "t.pinned desc,{$topic_sort} t.{$sort_key} {$r_sort_by}", 'limit' => array(intval($First), intval($this->settings['display_max_topics'])), 'add_join' => $_joins));
         $this->DB->execute();
     } else {
         $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA, 'order' => 't.pinned DESC, ' . $topic_sort . ' t.' . $sort_key . ' ' . $r_sort_by, 'limit' => array(intval($First), $this->settings['display_max_topics']), 'add_join' => ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) ? array($this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'))) : array()));
         $this->DB->execute();
     }
     while ($t = $this->DB->fetch()) {
         /* Should we display the moderate checkbox for this post? */
         $t['moddable'] = FALSE;
         if ($modAll or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($t['pinned'] == 0 and $this->memberData['forumsModeratorData'][$this->forum['id']]['pin_topic'] or $t['pinned'] == 1 and $this->memberData['forumsModeratorData'][$this->forum['id']]['unpin_topic'] or $t['state'] == 'open' and $this->memberData['forumsModeratorData'][$this->forum['id']]['close_topic'] or $t['state'] == 'closed' and $this->memberData['forumsModeratorData'][$this->forum['id']]['open_topic'])) {
             $t['moddable'] = TRUE;
         }
         /* Add to array */
         $topic_array[$t['tid']] = $t;
         $topic_ids[$t['tid']] = $t['tid'];
         if ($t['last_poster_id']) {
             $member_ids[$t['last_poster_id']] = $t['last_poster_id'];
         }
         if ($t['starter_id']) {
             $member_ids[$t['starter_id']] = $t['starter_id'];
         }
     }
     ksort($topic_ids);
     //-----------------------------------------
     // Are we dotty?
     //-----------------------------------------
     if ($this->settings['show_user_posted'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), '');
         $this->DB->build(array('select' => $this->DB->buildDistinct('topic_id'), 'from' => 'posts', 'where' => $_queued . ' AND author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['author_id'] = $this->memberData['member_id'];
             }
         }
     }
     //-----------------------------------------
     // Get needed members
     //-----------------------------------------
     if (count($member_ids)) {
         $_members = IPSMember::load($member_ids);
         //-----------------------------------------
         // Add member data to announcements
         //-----------------------------------------
         $new_announces = array();
         foreach ($announce_data as $announce) {
             $announce = array_merge($announce, IPSMember::buildDisplayData($_members[$announce['member_id']]));
             $new_announces[] = $announce;
         }
         $announce_data = $new_announces;
     }
     //-----------------------------------------
     // Show meh the topics!
     //-----------------------------------------
     $adCodeSet = false;
     foreach ($topic_array as $topic) {
         /* Add member */
         if ($topic['last_poster_id']) {
             $topic = array_merge(IPSMember::buildDisplayData($_members[$topic['last_poster_id']]), $topic);
         } else {
             $topic = array_merge(IPSMember::buildProfilePhoto(array()), $topic);
         }
         if ($topic['starter_id']) {
             $topic['_starter'] = $_members[$topic['starter_id']];
         }
         /* AD Code */
         if ($this->registry->getClass('IPSAdCode')->userCanViewAds() && !$adCodeSet) {
             $topic['_adCode'] = $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_forum_view_topic_code');
             if ($topic['_adCode']) {
                 $adCodeSet = true;
             }
         }
         if ($topic['pinned']) {
             $this->pinned_topic_count++;
         }
         $topic_data[$topic['tid']] = $this->renderEntry($topic);
         $total_topics_printed++;
     }
     //-----------------------------------------
     // Finish off the rest of the page  $filter_keys[$topicfilter]))
     //-----------------------------------------
     $sort_by_html = "";
     $sort_key_html = "";
     $prune_day_html = "";
     $filter_html = "";
     foreach ($sort_by_keys as $k => $v) {
         $sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n";
     }
     foreach ($sort_keys as $k => $v) {
         $sort_key_html .= $k == $sort_key_chk ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_keys[$k]]}</option>\n";
     }
     foreach ($prune_by_day as $k => $v) {
         $prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected='selected'>{$this->lang->words[$prune_by_day[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$prune_by_day[$k]]}</option>\n";
     }
     foreach ($filter_keys as $k => $v) {
         $filter_html .= $k == $topicfilter ? "<option value='{$k}' selected='selected'>{$this->lang->words[$filter_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$filter_keys[$k]]}</option>\n";
     }
     $footer_filter['sort_by'] = $sort_key_html;
     $footer_filter['sort_order'] = $sort_by_html;
     $footer_filter['sort_prune'] = $prune_day_html;
     $footer_filter['topic_filter'] = $filter_html;
     if ($this->memberData['is_mod']) {
         $count = 0;
         $other_pages = 0;
         if ($this->request['selectedtids'] != "") {
             $tids = explode(",", $this->request['selectedtids']);
             if (is_array($tids) and count($tids)) {
                 foreach ($tids as $tid) {
                     if ($tid != '') {
                         if (!isset($topic_array[$tid])) {
                             $other_pages++;
                         }
                         $count++;
                     }
                 }
             }
         }
         $this->lang->words['f_go'] .= " ({$count})";
         if ($other_pages) {
             $this->lang->words['f_go'] .= " ({$other_pages} " . $this->lang->words['jscript_otherpage'] . ")";
         }
     }
     //-----------------------------------------
     // Multi-moderation?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         $mm_array = $this->registry->getClass('class_forums')->getMultimod($this->forum['id']);
         if (is_array($mm_array) and count($mm_array)) {
             foreach ($mm_array as $m) {
                 $multi_mod_data[] = $m;
             }
         }
     }
     //-----------------------------------------
     // Need to update topics?
     //-----------------------------------------
     if (count($this->update_topics_open)) {
         $this->DB->update('topics', array('state' => 'open'), 'tid IN (' . implode(",", $this->update_topics_open) . ')');
     }
     if (count($this->update_topics_close)) {
         $this->DB->update('topics', array('state' => 'closed'), 'tid IN (' . implode(",", $this->update_topics_close) . ')');
     }
     /* Got soft delete tids? */
     if (is_array($this->_sdTids) and count($this->_sdTids)) {
         $other_data['sdData'] = IPSDeleteLog::fetchEntries($this->_sdTids, 'topic', false);
     }
     /* Fetch follow data */
     $other_data['follow_data'] = $this->_like->render('summary', $this->forum['id']);
     return array('announce_data' => $announce_data, 'topic_data' => $topic_data, 'other_data' => $other_data, 'multi_mod_data' => $multi_mod_data, 'footer_filter' => $footer_filter, 'active_users' => $this->_generateActiveUserData());
 }
示例#4
0
 /**
  * Show the logged inline notifications
  *
  * @author	Brandon Farber
  * @param	string		Error message
  * @return	string		Processed HTML
  */
 public function showInlineNotifications($error = '')
 {
     /* Init */
     $start = intval($this->request['st']);
     $perPage = 50;
     //-----------------------------------------
     // Get class
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications');
     $notifyLibrary = new $classToLoad($this->registry);
     $notifyLibrary->setMember($this->memberData);
     /* Clear them? - used in mobile skin */
     if (isset($this->request['clear']) && trim($this->request['clear']) == 'true') {
         $this->DB->update('inline_notifications', array('notify_read' => 1), 'notify_to_id=' . $this->memberData['member_id']);
         $notifyLibrary->rebuildUnreadCount();
     }
     //-----------------------------------------
     // Turn off normal form
     //-----------------------------------------
     $this->hide_form_and_save_button = 1;
     //-----------------------------------------
     // Get notifications
     //-----------------------------------------
     $_notifications = array();
     $mids = array();
     $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as er', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->memberData['member_id']));
     if ($count['er']) {
         $this->DB->build(array('select' => '*', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->memberData['member_id'], 'limit' => array($start, $perPage), 'order' => 'notify_sent DESC'));
         $outer = $this->DB->execute();
         while ($r = $this->DB->fetch($outer)) {
             $r['notify_icon'] = $notifyLibrary->getNotificationIcon($r['notify_type_key']);
             $_notifications[] = $r;
             $mids[$r['notify_from_id']] = $r['notify_from_id'];
         }
         /* Get members */
         if (count($mids)) {
             $members = IPSMember::load(array_keys($mids), 'all');
             if (count($members)) {
                 foreach ($_notifications as $key => $data) {
                     if (isset($members[$data['notify_from_id']])) {
                         $_notifications[$key]['member'] = IPSMember::buildProfilePhoto($members[$data['notify_from_id']]);
                     }
                 }
             }
         }
     }
     $pages = $this->registry->getClass('output')->generatePagination(array('totalItems' => $count['er'], 'itemsPerPage' => $perPage, 'currentStartValue' => $start, 'baseUrl' => "app=core&amp;module=usercp&amp;tab=core&amp;area=notificationlog"));
     //-----------------------------------------
     // Send to template
     //-----------------------------------------
     return $this->registry->getClass('output')->getTemplate('ucp')->notificationsLog($_notifications, $error, $pages);
 }
示例#5
0
 /**
  * @desc			Returns HTML code for member's photo.
  * @param	int		$userID User ID. If $userID is ommited, the last known member id is used.
  * @param	bool	$thumb true to activate thumbnail, otherwise false (default)
  * @return	string	HTML code for member photo
  * @author			Matthias Reuter
  * @sample
  * <code>
  * $ipbwi->member->photo(5,true);
  * </code>
  * @since			2.0
  */
 public function photo($userID = false, $thumb = false)
 {
     $member = $this->info($userID);
     $photo = IPSMember::buildProfilePhoto($member);
     if ($photo['pp_main_photo']) {
         if ($thumb === true && $photo['pp_thumb_photo']) {
             $photo = '<a href="' . $photo['pp_main_photo'] . '"><img src="' . $photo['pp_thumb_photo'] . '" width="' . $photo['pp_thumb_width'] . '" height="' . $photo['pp_thumb_height'] . '" alt="' . $this->id2displayname($userID) . '" /></a>';
         } else {
             $photo = '<img src="' . $photo['pp_main_photo'] . '" width="' . $photo['pp_main_width'] . '" height="' . $photo['pp_main_height'] . '" alt="' . $this->id2displayname($userID) . '" />';
         }
         return $photo;
     } else {
         return false;
     }
 }
示例#6
0
 /**
  * Returns the editor for viewing ...
  * @param unknown_type $member
  */
 public function getEditorHtml(array $member)
 {
     /* Fetch member data */
     $member = IPSMember::buildDisplayData(IPSMember::load($member['member_id'], 'all'));
     $p_w = "";
     $p_h = "";
     $cur_photo = "";
     $rand = urlencode(microtime());
     $data = array('currentPhoto' => array('tag' => ''), 'custom' => array('tag' => ''), 'gravatar' => array('tag' => ''), 'twitter' => array('tag' => ''));
     /* Photo type */
     $data['type'] = $member['pp_photo_type'] = $this->getPhotoType($member);
     /* Got gravatar? */
     $member['pp_gravatar'] = $member['pp_gravatar'] ? $member['pp_gravatar'] : $member['email'];
     /* Quick permission check */
     if (!IPSMember::canUploadPhoto($member, TRUE)) {
         return false;
     }
     /* Set the current photo */
     $data['currentPhoto']['tag'] = IPSMember::buildProfilePhoto($member, 'full', IPS_MEMBER_PHOTO_NO_CACHE);
     /* Set up custom */
     $data['custom']['tag'] = $member['pp_photo_type'] != 'custom' ? IPSMember::buildNoPhoto($member, 'thumb', false, true) : "<img src='" . $member['pp_thumb_photo'] . '?__rand=' . $rand . "' width='" . $member['pp_thumb_width'] . "' height='" . $member['pp_thumb_height'] . "' />";
     /* Set up Gravatar */
     $data['gravatar']['tag'] = "<img src='http://www.gravatar.com/avatar/" . md5($member['pp_gravatar']) . "?s=100' alt='' />";
     /* Twitter linked? */
     if (IPSLib::twitter_enabled() && $member['twitter_token'] && $member['twitter_secret']) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect');
         $twitter = new $classToLoad($this->registry, $member['twitter_token'], $member['twitter_secret']);
         $userData = $twitter->fetchUserData();
         if ($userData['profile_image_url']) {
             $data['twitter']['tag'] = "<img src='" . str_replace('_normal.', '.', $userData['profile_image_url']) . "' />";
         }
     }
     /* Facebook linked? */
     if (IPSLib::fbc_enabled() && $member['fb_uid']) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect');
         $facebook = new $classToLoad($this->registry);
         /* Now get the linked user */
         $linkedMemberData = IPSMember::load(intval($member['fb_uid']), 'all', 'fb_uid');
         $userData = $facebook->fetchUserData();
         if ($userData['pic_big']) {
             $data['facebook']['tag'] = "<img src='" . $userData['pic_big'] . "' />";
         } else {
             if ($userData['pic']) {
                 $data['facebook']['tag'] = "<img src='" . $userData['pic'] . "' />";
             }
         }
     }
     $this->uploadFormMax = 5000 * 1024;
     return $this->registry->getClass('output')->getTemplate('profile')->photoEditor($data, $member);
 }
示例#7
0
文件: view.php 项目: mover5/imobackup
 /**
  * Class entry point
  *
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen/redirects]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Get HTML and skin
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_list'), 'members');
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info']) {
         $this->registry->output->showError('cannot_view_memberlist', 10221, null, null, 403);
     }
     //-----------------------------------------
     // Init variables
     //-----------------------------------------
     $see_groups = array();
     $the_filter = array('ALL' => $this->lang->words['show_all']);
     $the_members = array();
     $query = array("m.members_l_display_name !='' AND m.members_l_display_name " . $this->DB->buildIsNull(false));
     $url = array();
     $pp_rating_real = isset($this->request['pp_rating_real']) ? intval($this->request['pp_rating_real']) : 0;
     $this->first = isset($this->request['st']) ? intval($this->request['st']) : 0;
     $this->max_results = !empty($this->request['max_results']) ? $this->request['max_results'] : $this->max_results;
     $this->sort_key = !empty($this->request['sort_key']) ? $this->request['sort_key'] : 'members_display_name';
     $this->sort_order = !empty($this->request['sort_order']) ? $this->request['sort_order'] : 'asc';
     $this->filter = !empty($this->request['filter']) ? $this->request['filter'] == 'ALL' ? 'ALL' : intval($this->request['filter']) : 'ALL';
     $this->request['showall'] = isset($this->request['showall']) ? intval($this->request['showall']) : 0;
     $this->request['name_box'] = isset($this->request['name_box']) ? $this->request['name_box'] : '';
     $this->request['quickjump'] = isset($this->request['quickjump']) ? $this->request['quickjump'] : 0;
     $_queryPP = false;
     //-----------------------------------------
     // Set some of the URL params
     //-----------------------------------------
     if ($this->request['quickjump']) {
         $this->request['name_box'] = 'begins';
         $this->request['name'] = $this->request['quickjump'];
     }
     $url['app'] = "app=members&amp;module=list";
     $url['showall'] = 'showall=' . $this->request['showall'];
     $url['sort_key'] = "sort_key={$this->sort_key}";
     $url['sort_order'] = "sort_order={$this->sort_order}";
     $url['max_results'] = "max_results={$this->max_results}";
     $url['quickjump'] = "quickjump={$this->request['quickjump']}";
     $url['name_box'] = 'name_box=' . $this->request['name_box'];
     $url['name'] = isset($this->request['name']) ? "name={$this->request['name']}" : "name=";
     //-----------------------------------------
     // Sort the member group info
     //-----------------------------------------
     foreach ($this->caches['group_cache'] as $row) {
         if ($row['g_hide_from_list']) {
             if (!($this->memberData['g_access_cp'] and $this->request['showall'])) {
                 $hide_ids[] = $row['g_id'];
                 continue;
             }
         }
         $see_groups[] = $row['g_id'];
         $this->mem_groups[$row['g_id']] = array('TITLE' => $row['g_title'], 'ICON' => $row['g_icon']);
         if ($row['g_id'] == $this->settings['guest_group']) {
             continue;
         }
         $the_filter[$row['g_id']] = $row['g_title'];
     }
     //-----------------------------------------
     // Init some arrays
     //-----------------------------------------
     $the_sort_key = array('members_l_display_name' => 'sort_by_name', 'posts' => 'pcount', 'joined' => 'sort_by_joined', 'members_profile_views' => 'm_dd_views');
     $the_max_results = array(10 => '10', 20 => '20', 40 => '40', 60 => '60');
     $the_sort_order = array('desc' => 'descending_order', 'asc' => 'ascending_order');
     $dropdowns = array('filter' => $the_filter, 'sort_key' => $the_sort_key, 'sort_order' => $the_sort_order, 'max_results' => $the_max_results);
     $defaults = array('filter' => $this->filter, 'sort_key' => $this->sort_key, 'sort_order' => $this->sort_order, 'max_results' => $this->max_results, 'photoonly' => !empty($this->request['photoonly']) ? 1 : 0);
     //-----------------------------------------
     // Final vars for query
     //-----------------------------------------
     $this->sort_key = isset($the_sort_key[$this->sort_key]) ? $this->sort_key : 'members_l_display_name';
     $this->sort_order = isset($the_sort_order[$this->sort_order]) ? $this->sort_order : 'asc';
     $this->filter = isset($the_filter[$this->filter]) ? $this->filter : 'ALL';
     $this->max_results = isset($the_max_results[$this->max_results]) ? $this->max_results : 20;
     //-----------------------------------------
     // Get custom profile information
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $this->custom_fields = new $classToLoad();
     $this->custom_fields->initData('edit', 1);
     $this->custom_fields->parseToEdit('mlist');
     //-----------------------------------------
     // Member Groups...
     //-----------------------------------------
     if ($this->filter != 'ALL') {
         if (!in_array($this->filter, $see_groups)) {
             $query[] = 'm.member_group_id IN(' . implode(',', $see_groups) . ')';
         } else {
             $query[] = 'm.member_group_id=' . $this->filter;
         }
         $url['filter'] = 'filter=' . $this->filter;
     }
     //-----------------------------------------
     // NOT IN Member Groups...
     //-----------------------------------------
     if (count($hide_ids)) {
         $query[] = "m.member_group_id NOT IN(" . implode(",", $hide_ids) . ")";
     }
     /* Not banned */
     $query[] = "m.member_banned=0";
     /* Not a spammer */
     $query[] = '( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')';
     //-----------------------------------------
     // Build query
     //-----------------------------------------
     $dates = array('lastpost', 'lastvisit', 'joined');
     $mapit = array('posts' => 'm.posts', 'joined' => 'm.joined', 'lastpost' => 'm.last_post', 'lastvisit' => 'm.last_visit', 'signature' => 'pp.signature', 'name' => 'm.members_display_name', 'photoonly' => 'pp.pp_main_photo');
     //-----------------------------------------
     // Do search
     //-----------------------------------------
     foreach ($mapit as $in => $tbl) {
         /**
          * Leave isset && != '', can't use empty or 0 values are skipped as well
          * @link	http://community.invisionpower.com/tracker/issue-37350-sorting-members-by-post-count/
          */
         $this->request[$in] = isset($this->request[$in]) && $this->request[$in] != '' ? $this->request[$in] : '';
         $inbit = $this->request[$in] = IPSText::parseCleanValue(trim(urldecode(IPSText::stripslashes($this->request[$in]))));
         $url[$in] = $in . '=' . urlencode($this->request[$in]);
         //-----------------------------------------
         // Name...
         //-----------------------------------------
         if ($in == 'name' and $inbit != "") {
             if ($this->request['name_box'] == 'begins') {
                 $query[] = "m.members_l_display_name LIKE '" . strtolower($inbit) . "%'";
             } else {
                 $query[] = "m.members_l_display_name LIKE '%" . strtolower($inbit) . "%'";
             }
         } else {
             if ($in == 'posts' and is_numeric($inbit) and intval($inbit) > -1) {
                 $ltmt = $this->request[$in . '_ltmt'] == 'lt' ? '<' : '>';
                 $query[] = $tbl . ' ' . $ltmt . ' ' . intval($inbit);
                 $url[$in] = $in . '_ltmt=' . $this->request[$in . '_ltmt'] . '&posts=' . intval($inbit);
             } else {
                 if (in_array($in, $dates) and $inbit) {
                     if (preg_match('/\\d{2}-\\d{2}-\\d{4}/', $this->request[$in])) {
                         $_tmp = explode('-', $this->request[$in]);
                         $time_int = mktime(23, 59, 59, $_tmp[0], $_tmp[1], $_tmp[2]);
                     } else {
                         $time_int = strtotime($inbit);
                     }
                     if ($time_int) {
                         $ltmt = $this->request[$in . '_ltmt'] == 'lt' ? '<' : '>';
                         $query[] = $tbl . ' ' . $ltmt . ' ' . $time_int;
                         $url[$in . '_ltmt'] = $in . '_ltmt=' . $this->request[$in . '_ltmt'];
                     }
                 } else {
                     if ($in == 'photoonly') {
                         if ($this->request['photoonly'] == 1) {
                             $_queryPP = true;
                             $query[] = $tbl . "<> ''";
                             $url[] = 'photoonly=1';
                         }
                     } else {
                         if ($inbit != "" and $in != 'posts') {
                             $_queryPP = true;
                             $query[] = $tbl . " LIKE '%{$inbit}%'";
                         }
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Custom fields?
     //-----------------------------------------
     if (count($this->custom_fields->out_fields)) {
         foreach ($this->custom_fields->out_fields as $id => $data) {
             if (!empty($this->request['field_' . $id])) {
                 $_queryPP = true;
                 if (is_array($this->request['field_' . $id])) {
                     foreach ($this->request['field_' . $id] as $k => $v) {
                         $this->request['field_' . $id][$k] = urldecode($v);
                         $url['field_' . $id] = "field_{$id}[{$k}]=" . $v;
                     }
                 } else {
                     $url['field_' . $id] = "field_{$id}=" . $this->request['field_' . $id];
                     $this->request['field_' . $id] = urldecode($this->request['field_' . $id]);
                 }
                 if ($this->custom_fields->cache_data[$id]['pf_type'] == 'drop') {
                     $query[] = "p.field_{$id}='" . $this->request['field_' . $id] . "'";
                 } else {
                     if ($this->custom_fields->cache_data[$id]['pf_type'] == 'cbox') {
                         if (count($this->request['field_' . $id])) {
                             foreach ($this->request['field_' . $id] as $k => $v) {
                                 $query[] = "p.field_{$id} LIKE '%|{$k}|%'";
                             }
                         }
                     } else {
                         $query[] = $this->custom_fields->cache_data[$id]['pf_search_type'] == 'loose' ? "p.field_{$id} LIKE '%" . $this->request['field_' . $id] . "%'" : "p.field_{$id} = '" . $this->request['field_' . $id] . "'";
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Rating..
     //-----------------------------------------
     if ($pp_rating_real) {
         $_queryPP = true;
         $query[] = "pp.pp_rating_real > " . $pp_rating_real;
         $url['pp_rating_real'] = "pp_rating_real=" . $pp_rating_real;
     }
     //-----------------------------------------
     // Finish query
     //-----------------------------------------
     //$query[] = "m.members_l_display_name != ''";
     $joins = array();
     if ($_queryPP) {
         $joins[] = array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left');
         $joins[] = array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left');
     }
     //-----------------------------------------
     // Reputation
     //-----------------------------------------
     if (!ipsRegistry::isClassLoaded('repCache')) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
         ipsRegistry::setClass('repCache', new $classToLoad());
     }
     //-----------------------------------------
     // START THE LISTING
     //-----------------------------------------
     $notInMembers = 0;
     foreach ($query as $q) {
         if (!strstr($q, 'm.')) {
             $notInMembers++;
         }
     }
     /* Get the count */
     if ($notInMembers > 0 or $this->sort_key != 'members_l_display_name' or $this->request['request_method'] == 'post') {
         $_max = $this->DB->buildAndFetch(array('select' => 'COUNT( * ) as cnt', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'add_join' => $joins));
         $this->DB->build(array('select' => ' m.member_id', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'order' => 'm.' . $this->sort_key . ' ' . $this->sort_order, 'limit' => array($this->first, $this->max_results), 'add_join' => $joins));
     } else {
         $_max = $this->DB->buildAndFetch(array('select' => 'COUNT( * ) as cnt', 'from' => 'members m', 'where' => implode(" AND ", $query)));
         $this->DB->build(array('select' => 'm.member_id', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'order' => 'm.' . $this->sort_key . ' ' . $this->sort_order, 'limit' => array($this->first, $this->max_results)));
     }
     /* Fetch IDs */
     $mids = array();
     $this->DB->execute();
     while ($m = $this->DB->fetch()) {
         if ($m['member_id']) {
             $mids[] = $m['member_id'];
         }
     }
     if (count($mids)) {
         $members = array();
         $_members = IPSMember::load($mids, 'all');
         /* Make sure that we keep the ordering from the query */
         foreach ($mids as $id) {
             $members[$id] = $_members[$id];
         }
     }
     $max = $_max['cnt'];
     if (is_array($members) and count($members)) {
         foreach ($members as $id => $member) {
             /* Damn SQL thing with member_id */
             if (!$member['member_id']) {
                 $member['member_id'] = $member['member_table_id'];
             }
             $member['members_display_name'] = $member['members_display_name'] ? $member['members_display_name'] : $member['name'];
             $member['members_seo_name'] = IPSMember::fetchSeoName($member);
             $member['group'] = $this->mem_groups[$member['member_group_id']]['TITLE'];
             $member = IPSMember::buildProfilePhoto($member);
             $member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0;
             $member['author_reputation'] = ipsRegistry::getClass('repCache')->getReputation($member['pp_reputation_points']);
             /* Reputation */
             if ($this->settings['reputation_protected_groups']) {
                 if (in_array($member['member_group_id'], explode(",", $this->settings['reputation_protected_groups']))) {
                     $member['pp_reputation_points'] = null;
                     $member['author_reputation'] = null;
                 }
             }
             $the_members[] = $member;
         }
     }
     /* make sure URL doesn't contain empty params */
     $_url = $url;
     $url = array();
     foreach ($_url as $key => $bit) {
         if (strrpos($bit, '=') + 1 == strlen($bit)) {
             continue;
         }
         $url[] = $bit;
     }
     $pages = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $this->max_results, 'currentStartValue' => $this->first, 'seoTitle' => "false", 'seoTemplate' => 'members_list', 'baseUrl' => implode('&amp;', $url)));
     //-----------------------------------------
     // Print...
     //-----------------------------------------
     $this->output .= $this->registry->getClass('output')->getTemplate('mlist')->member_list_show($the_members, $pages, $dropdowns, $defaults, $this->custom_fields, implode('&amp;', $url));
     //-----------------------------------------
     // Push to print handler
     //-----------------------------------------
     $this->registry->output->addContent($this->output);
     $this->registry->output->setTitle($this->lang->words['page_title'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->output->addNavigation($this->lang->words['page_title'], 'app=members', "false", 'members_list');
     $this->registry->output->sendOutput();
 }
示例#8
0
 /**
  * Finalize public member
  *
  * Now that everything has loaded, lets do the final set up
  *
  * @return	@e void
  */
 public static function finalizePublicMember()
 {
     /* Build profile picture */
     self::$data_store = IPSMember::buildProfilePhoto(self::$data_store);
     /* SEO Name */
     if (!self::$data_store['members_seo_name']) {
         self::$data_store['members_seo_name'] = IPSMember::fetchSeoName(self::$data_store);
     }
     /* Rebuild messenger count if triggered */
     if (self::$data_store['msg_count_reset']) {
         /* Just instantiating the class will perform reset */
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('members') . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members');
         $messenger = new $classToLoad(ipsRegistry::instance());
     }
 }
示例#9
0
 /**
  * Builds an array of post data for output
  *
  * @param	array	$row	Array of post data
  * @return	array
  */
 public function parsePost(array $post)
 {
     /* Init */
     $topicData = $this->getTopicData();
     $forumData = $this->registry->getClass('class_forums')->getForumById($topicData['forum_id']);
     $permissionData = $this->getPermissionData();
     /* Start memory debug */
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $poster = array();
     /* Bitwise options */
     $_tmp = IPSBWOptions::thaw($post['post_bwoptions'], 'posts', 'forums');
     if (count($_tmp)) {
         foreach ($_tmp as $k => $v) {
             $post[$k] = $v;
         }
     }
     /* Is this a member? */
     if ($post['author_id'] != 0) {
         $poster = $this->parseMember($post);
     } else {
         /* Sort out guest */
         $post['author_name'] = $this->settings['guest_name_pre'] . $post['author_name'] . $this->settings['guest_name_suf'];
         $poster = IPSMember::setUpGuest($post['author_name']);
         $poster['members_display_name'] = $post['author_name'];
         $poster['_members_display_name'] = $post['author_name'];
         $poster['custom_fields'] = "";
         $poster['warn_img'] = "";
         $poster = IPSMember::buildProfilePhoto($poster);
     }
     /* Memory debug */
     IPSDebug::setMemoryDebugFlag("PID: " . $post['pid'] . " - Member Parsed", $_NOW);
     /* Update permission */
     $this->registry->getClass('class_forums')->setMemberData($this->getMemberData());
     $permissionData['softDelete'] = $this->registry->getClass('class_forums')->canSoftDeletePosts($topicData['forum_id'], $post);
     /* Soft delete */
     $post['_softDelete'] = $post['pid'] != $topicData['topic_firstpost'] ? $permissionData['softDelete'] : FALSE;
     $post['_softDeleteRestore'] = $permissionData['softDeleteRestore'];
     $post['_softDeleteSee'] = $permissionData['softDeleteSee'];
     $post['_softDeleteReason'] = $permissionData['softDeleteReason'];
     $post['_softDeleteContent'] = $permissionData['softDeleteContent'];
     $post['_isVisible'] = $this->registry->getClass('class_forums')->fetchHiddenType($post) == 'visible' ? true : false;
     $post['_isHidden'] = $this->registry->getClass('class_forums')->fetchHiddenType($post) == 'hidden' ? true : false;
     $post['_isDeleted'] = $this->registry->getClass('class_forums')->fetchHiddenType($post) == 'sdelete' ? true : false;
     /* Answered post */
     try {
         $post['_isMarkedAnswered'] = $this->postIsAnswer($post, $topicData) ? true : false;
     } catch (Exception $e) {
         $post['_isMarkedAnswered'] = false;
     }
     $post['_canMarkUnanswered'] = $post['_isMarkedAnswered'] === true && $this->canUnanswerTopic($topicData) ? true : false;
     $post['_canAnswer'] = $post['_isMarkedAnswered'] === false && $this->canAnswerTopic($topicData) ? true : false;
     $post['PermalinkUrlBit'] = '';
     /* Queued */
     if ($topicData['topic_firstpost'] == $post['pid'] and ($post['_isHidden'] or $topicData['_isHidden'])) {
         $post['queued'] = 1;
         $post['_isHidden'] = true;
     }
     if ($topicData['topic_queuedposts'] || $topicData['topic_deleted_posts']) {
         if ($topicData['topic_queuedposts'] && $topicData['Perms']['canQueuePosts']) {
             /* We have hidden data that is viewable */
             $post['PermalinkUrlBit'] = '&amp;p=' . $post['pid'];
         }
         if ($topicData['topic_deleted_posts'] && $post['_softDeleteSee']) {
             /* We have hidden data that is viewable */
             $post['PermalinkUrlBit'] = '&amp;p=' . $post['pid'];
         }
     }
     /* Edited stuff */
     $post['edit_by'] = "";
     if ($post['append_edit'] == 1 and $post['edit_time'] != "" and $post['edit_name'] != "") {
         $e_time = $this->registry->class_localization->getDate($post['edit_time'], 'LONG');
         $post['edit_by'] = sprintf($this->lang->words['edited_by'], $post['edit_name'], $e_time);
     }
     /* Now parse the post */
     if (!isset($post['cache_content']) or !$post['cache_content']) {
         $_NOW2 = IPSDebug::getMemoryDebugFlag();
         /* Grab the parser file */
         if ($this->_parser === null) {
             /* Load parser */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
             $this->_parser = new $classToLoad();
         }
         /* set up parser */
         $this->_parser->set(array('memberData' => array('member_id' => $post['member_id'], 'member_group_id' => $post['member_group_id'], 'mgroup_others' => $post['mgroup_others']), 'parseBBCode' => $forumData['use_ibc'], 'parseHtml' => ($forumData['use_html'] and $poster['g_dohtml'] and $post['post_htmlstate']) ? 1 : 0, 'parseEmoticons' => $post['use_emo'], 'parseArea' => 'topics'));
         $post['post'] = $this->_parser->display($post['post']);
         IPSDebug::setMemoryDebugFlag("topics::parsePostRow - bbcode parse - Completed", $_NOW2);
         IPSContentCache::update($post['pid'], 'post', $post['post']);
     } else {
         $post['post'] = '<!--cached-' . gmdate('r', $post['cache_updated']) . '-->' . $post['cache_content'];
     }
     /* Buttons */
     $post['_can_delete'] = $post['pid'] != $topicData['topic_firstpost'] ? $this->canDeletePost($post) : FALSE;
     $post['_can_edit'] = $this->canEditPost($post);
     $post['_show_ip'] = $this->canSeeIp();
     $post['_canReply'] = $this->getReplyStatus() == 'reply' ? true : false;
     /* Signatures */
     $post['signature'] = "";
     if (!empty($poster['signature'])) {
         if ($post['use_sig'] == 1) {
             if (!$this->memberData['view_sigs'] || $poster['author_id'] && $this->memberData['member_id'] && !empty($this->member->ignored_users[$poster['author_id']]['ignore_signatures']) && IPSMember::isIgnorable($poster['member_group_id'], $poster['mgroup_others'])) {
                 $post['signature'] = '<!--signature.hidden.' . $post['pid'] . '-->';
             } else {
                 $post['signature'] = $this->registry->output->getTemplate('global')->signature_separator($poster['signature'], $poster['author_id'], IPSMember::isIgnorable($poster['member_group_id'], $poster['mgroup_others']));
             }
         }
     }
     $post['forum_id'] = $topicData['forum_id'];
     /* Reputation */
     if ($this->settings['reputation_enabled'] and !$this->isArchived($topicData)) {
         /* Load the class */
         if (!$this->registry->isClassLoaded('repCache')) {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
             $this->registry->setClass('repCache', new $classToLoad());
         }
         $this->memberData['_members_cache']['rep_filter'] = isset($this->memberData['_members_cache']['rep_filter']) ? $this->memberData['_members_cache']['rep_filter'] : '*';
         $post['pp_reputation_points'] = $post['pp_reputation_points'] ? $post['pp_reputation_points'] : 0;
         $post['has_given_rep'] = $post['has_given_rep'] ? $post['has_given_rep'] : 0;
         $post['rep_points'] = $this->registry->repCache->getRepPoints(array('app' => 'forums', 'type' => 'pid', 'type_id' => $post['pid'], 'rep_points' => $post['rep_points']));
         $post['_repignored'] = 0;
         if (!($this->settings['reputation_protected_groups'] && in_array($this->memberData['member_group_id'], explode(',', $this->settings['reputation_protected_groups']))) && $this->memberData['_members_cache']['rep_filter'] !== '*') {
             if ($this->settings['reputation_show_content'] && $post['rep_points'] < $this->memberData['_members_cache']['rep_filter'] && $this->settings['reputation_point_types'] != 'like') {
                 $post['_repignored'] = 1;
             }
         }
         if ($this->registry->repCache->isLikeMode()) {
             $post['like'] = $this->registry->repCache->getLikeFormatted(array('app' => 'forums', 'type' => 'pid', 'id' => $post['pid'], 'rep_like_cache' => $post['rep_like_cache']));
         }
     }
     /* Ignore stuff */
     $post['_ignored'] = 0;
     if ($post['author_id'] && isset($topicData['ignoredUsers']) && is_array($topicData['ignoredUsers']) && count($topicData['ignoredUsers'])) {
         if (in_array($post['author_id'], $topicData['ignoredUsers'])) {
             if (!strstr($this->settings['cannot_ignore_groups'], ',' . $post['member_group_id'] . ',')) {
                 $post['_ignored'] = 1;
             }
         }
     }
     /* AD Code */
     $post['_adCode'] = '';
     if ($this->registry->getClass('IPSAdCode')->userCanViewAds() && !$this->getTopicData('adCodeSet') && !IPS_IS_AJAX) {
         $post['_adCode'] = $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_topic_view_code');
         if ($post['_adCode']) {
             $this->setTopicData('adCodeSet', true);
         }
     }
     /* Memory debug */
     IPSDebug::setMemoryDebugFlag("PID: " . $post['pid'] . " - Completed", $_NOW);
     /* Excerpt */
     $post['_excerpt'] = IPSText::truncate(str_replace(array('<br />', '<br>', "\n", '</p>', '<p>'), ' ', $post['post']), 500);
     return array('post' => $post, 'author' => $poster);
 }
示例#10
0
 /**
  * Archive Rules overview
  *
  * @return	@e void
  */
 protected function _archiveRules()
 {
     /* Get archive count so far */
     $counts = $this->archiveWriter->getArchivePossibleCount();
     $rules = $this->archiveWriter->getRulesFromDb();
     if ($counts['count'] < 1) {
         $textString = $this->lang->words['archive_no_query'];
     } else {
         $textString = sprintf($this->lang->words['archive_x_query'], $counts['percentage'], $this->lang->formatNumber($counts['count']), $this->lang->formatNumber($counts['total']));
     }
     /* Post process */
     foreach (array('archive', 'skip') as $type) {
         if (!empty($rules[$type]['forum']['text'])) {
             $ids = IPSLib::isSerialized($rules[$type]['forum']['text']) ? unserialize($rules[$type]['forum']['text']) : array();
             if (count($ids)) {
                 foreach ($ids as $fid) {
                     $data = $this->registry->class_forums->getForumbyId($fid);
                     if ($data['id']) {
                         $rules[$type]['forum']['_parseData'][$fid] = array('data' => $this->registry->class_forums->getForumbyId($fid), 'nav' => $this->html->buildForumNav($this->registry->class_forums->forumsBreadcrumbNav($fid, 'showforum=', true)));
                     }
                 }
             }
         }
         if (!empty($rules[$type]['member']['text'])) {
             $ids = IPSLib::isSerialized($rules[$type]['member']['text']) ? unserialize($rules[$type]['member']['text']) : array();
             if (count($ids)) {
                 $members = IPSMember::load($ids, 'all');
                 foreach ($members as $id => $data) {
                     $members[$id] = IPSMember::buildProfilePhoto($members[$id]);
                     $members[$id]['photoTag'] = IPSMember::buildPhotoTag($members[$id], 'inset');
                 }
                 foreach ($ids as $fid) {
                     $rules[$type]['member']['_parseData']['count'] = count($members);
                     $rules[$type]['member']['_parseData']['data'] = $members;
                 }
             }
         }
     }
     /* Show rules page */
     $this->registry->output->html .= $this->html->archiveRules(IPSText::jsonEncodeForTemplate($rules), $textString);
 }
示例#11
0
 /**
  * Returns a list (with buildProfilePhoto set) of users in an application
  *
  * @param	string		$app		Application folder/key
  * @param	array		$options	Array of options to add/override checks for the query
  * @return	@e array Array of found sessions (members, guests, bots, anons)
  *
  * <b>Filters:</b>
  * - cutoff:		Specify a different cutoff time rather than using the default setting
  * - addJoins:		Add more joins for the query
  * - addWhere:		Add more checks for the 'where' part of the query (everything is joined with ' AND ')
  * - overrideWhere:	Specify manually the 'where' part of the query, the query must be already compiled
  * - overrideGroup:	if set to true the check against the 'gbw_view_online_lists' group setting is skipped
  * - skipParsing:	If set to true the parseOnlineEntries from coreExtensions is NOT executed
  * - includeErrors:	If set to true the in_error=1 lines are loaded as well from the table
  * - excludeViewer:	If set to true skips loading the row for the current session_id, it is required to load the current member viewing the page as sessions table is not updated at this point yet but only on destruct
  * 
  * <b>Example Usage:</b>
  * @code
  * $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90 ) );
  * $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90, 'addJoins' => array( ... ), 'addWhere' => array( ... ) ) );
  * $onlineUsers = $this->getUsersIn( 'forums', array( 'overrideWhere' => "s.current_appcomponent='forums' AND (s.running_time > TIME_A OR s.running_time < TIME_B)" ) );
  * @endcode
  */
 public function getUsersIn($app, $options = array())
 {
     /* App we're checking is not even installed? */
     if (!IPSLib::appIsInstalled($app, false)) {
         return array();
     }
     /* Can't view online lists? */
     if (empty($options['overrideGroup']) && !$this->memberData['gbw_view_online_lists']) {
         return array();
     }
     /* Init vars and check options */
     $return = array('stats' => array('total' => 0, 'members' => 0, 'guests' => 0, 'bots' => 0, 'anon' => 0), 'rows' => array('members' => array(), 'bots' => array(), 'guests' => array(), 'anon' => array()), 'names' => array());
     $cutoff = empty($options['cutoff']) ? $this->settings['au_cutoff'] : $options['cutoff'];
     $limit = time() - $cutoff * 60;
     $rows = array();
     $NOWJIM = IPS_UNIX_TIME_NOW;
     $cached = array();
     /* Sort joins */
     $_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=s.member_id', 'type' => 'left'));
     if (isset($options['addJoins']) && is_array($options['addJoins']) && count($options['addJoins'])) {
         $_joins = array_merge($_joins, $options['addJoins']);
     }
     /* Sort where.. override? */
     if (!empty($options['overrideWhere']) && is_string($options['overrideWhere'])) {
         $where = $options['overrideWhere'];
     } else {
         /* Normal where */
         $where = array("s.current_appcomponent='" . $this->DB->addSlashes($app) . "'", 's.running_time > ' . $limit);
         /* Load error rows? */
         if (empty($options['includeErrors'])) {
             $where[] = 's.in_error=0';
         }
         /* Add more where parts */
         if (isset($options['addWhere']) && is_array($options['addWhere']) && count($options['addWhere'])) {
             $where = array_merge($where, $options['addWhere']);
         }
         $where = implode(' AND ', $where);
     }
     /* We're a viewer too? Get our session separately */
     $_extraWhere = empty($options['excludeViewer']) ? "s.id='{$this->member->session_id}' OR " : '';
     /* Dee bee */
     $this->DB->build(array('select' => 's.*, s.id as row_session_id', 'from' => array('sessions' => 's'), 'where' => "{$_extraWhere}({$where})", 'add_join' => $_joins));
     $this->DB->execute();
     while ($session = $this->DB->fetch()) {
         /* Reset for possible bad joins */
         $session['id'] = $session['row_session_id'];
         /* Update our own session properly? */
         if ($session['id'] == $this->member->session_id) {
             $session = array_merge($session, $this->member->sessionClass()->returnCurrentSession());
         }
         $rows[$session['running_time'] . '.' . $session['id']] = $session;
     }
     /* No rows? */
     if (!count($rows)) {
         return $return;
     }
     krsort($rows);
     /* Are we parsing online entries or want only the names */
     if (empty($options['skipParsing'])) {
         /* Process them */
         $filename = IPSLib::getAppDir($app) . '/extensions/coreExtensions.php';
         if (is_file($filename)) {
             $classToLoad = IPSLib::loadLibrary($filename, 'publicSessions__' . $app, $app);
             $loader = new $classToLoad();
             if (method_exists($loader, 'parseOnlineEntries')) {
                 $rows = $loader->parseOnlineEntries($rows);
             }
         }
         /* No rows? */
         if (!count($rows)) {
             return $return;
         }
     }
     /* Sort through */
     foreach ($rows as $id => $result) {
         $last_date = $this->registry->getClass('class_localization')->getTime($result['running_time']);
         /* ROBOT - or DODOT! */
         if (strstr($result['id'], '_session')) {
             $botname = preg_replace('/^(.+?)=/', "\\1", $result['id']);
             if (!$cached['srch_' . $result['member_name']]) {
                 $result = IPSMember::buildProfilePhoto($result);
                 $result['parsedMemberName'] = $result['member_name'];
                 $return['rows']['bots'][$result['id']] = $result;
                 $return['names'][$result['id']] = $result['parsedMemberName'];
                 $cached['srch_' . $result['member_name']]['count'] = 1;
             } else {
                 $cached['srch_' . $result['member_name']]['count']++;
             }
             $return['stats']['bots']++;
         } else {
             if (!$result['member_id']) {
                 $result = IPSMember::buildProfilePhoto(0);
                 $result['parsedMemberName'] = $this->lang->words['global_guestname'];
                 $return['rows']['guests'][$result['id']] = $result;
                 $return['stats']['guests']++;
             } else {
                 if (empty($cached[$result['member_id']])) {
                     $cached[$result['member_id']] = 1;
                     $result = IPSMember::buildProfilePhoto($result);
                     $result['parsedMemberName'] = IPSMember::makeNameFormatted($result['member_name'], $result['member_group']);
                     /* Reset login type in case the board/group setting got changed */
                     $result['login_type'] = IPSMember::isLoggedInAnon(array('login_anonymous' => $result['login_type']), $result['member_group_id']);
                     if ($result['login_type']) {
                         if ($this->memberData['g_access_cp'] || $this->memberData['member_id'] == $result['member_id']) {
                             $result['parsedMemberName'] = IPSMember::makeProfileLink($result['parsedMemberName'], $result['member_id'], $result['seo_name']);
                             $result['parsedMemberName'] .= '*';
                             # Add anonymous asterisk
                             $return['rows']['anon'][$result['id']] = $result;
                             $return['names'][$result['id']] = $result['parsedMemberName'];
                         }
                         $return['stats']['anon']++;
                     } else {
                         $result['parsedMemberName'] = IPSMember::makeProfileLink($result['parsedMemberName'], $result['member_id'], $result['seo_name']);
                         $return['rows']['members'][$result['id']] = $result;
                         $return['names'][$result['id']] = $result['parsedMemberName'];
                         $return['stats']['members']++;
                     }
                 }
             }
         }
     }
     /* Process bots */
     foreach ($cached as $name => $val) {
         if ($val['count'] && substr($name, 0, 5) == 'srch_') {
             foreach ($return['rows']['bots'] as $row) {
                 if ($row['parsedMemberName'] == substr($name, 5)) {
                     $return['rows']['bots'][$row['id']]['parsedMemberName'] .= ' (' . $val['count'] . ')';
                     $return['rows']['bots'][$row['id']]['member_name'] = $return['rows']['bots'][$row['id']]['parsedMemberName'];
                     $return['names'][$row['id']] = $return['rows']['bots'][$row['id']]['parsedMemberName'];
                     break;
                 }
             }
         }
     }
     $return['stats']['total'] = intval($return['stats']['bots']) + intval($return['stats']['guests']) + intval($return['stats']['anon']) + intval($return['stats']['members']);
     return $return;
 }
示例#12
0
 /**
  * Perform a MEMBER search.
  * Returns an array of a total count (total number of matches)
  * and an array of IDs ( 0 => 1203, 1 => 928, 2 => 2938 ).. matching the required number based on pagination. The ids returned would be based on the filters and type of search
  *
  * So if we had 1000 replies, and we are on page 2 of 25 per page, we'd return 25 items offset by 25
  *
  * @return array
  */
 public function _membersSearch()
 {
     /* Not allowed to see profile information */
     if (!$this->memberData['g_mem_info']) {
         return array('count' => 0, 'resultSet' => array());
     }
     /* INIT */
     $sort_by = IPSSearchRegistry::get('in.search_sort_by');
     $sort_order = IPSSearchRegistry::get('in.search_sort_order');
     $search_term = IPSSearchRegistry::get('in.clean_search_term');
     $sortKey = '';
     $rows = array();
     /* Sorting */
     switch ($sort_by) {
         default:
         case 'date':
             $sortKey = 'member_id';
             break;
         case 'title':
             $sortKey = 'members_l_display_name';
             break;
     }
     /* Query the count */
     $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as total_results', 'from' => array('members' => 'm'), 'where' => $this->_buildWhereStatement($search_term), 'add_join' => array(array('from' => array('profile_portal' => 'p'), 'where' => "p.pp_member_id=m.member_id", 'type' => 'left'))));
     /* Fetch data */
     $this->DB->build(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => $this->_buildWhereStatement($search_term), 'order' => $sortKey . ' ' . $sort_order, 'limit' => array(IPSSearchRegistry::get('in.start'), IPSSearchRegistry::get('opt.search_per_page')), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => "p.pp_member_id=m.member_id", 'type' => 'left'))));
     $this->DB->execute();
     /* Get results */
     while ($_row = $this->DB->fetch()) {
         $rows[] = IPSMember::buildProfilePhoto($_row);
     }
     /* Return it */
     return array('count' => $count['total_results'], 'resultSet' => $rows);
 }
 /**
  * Get data based on a relationship ID
  *
  * @param	array 	$data (id, type, app)
  * @return	mixed	Array of like data OR null
  */
 public function getDataByRelationshipId($data)
 {
     /* Init */
     $mids = array();
     $members = array();
     $rows = array();
     $where = !empty($data['rating']) ? " AND rep_rating=" . $data['rating'] : '';
     /* Fetch data */
     $this->DB->build(array('select' => '*', 'from' => 'reputation_index', 'where' => 'app=\'' . $data['app'] . "' AND type='" . $data['type'] . "' AND type_id=" . intval($data['id']) . $where, 'order' => 'rep_date DESC', 'limit' => array(0, 250)));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         $return[$row['member_id']] = $row;
         $mids[$row['member_id']] = intval($row['member_id']);
     }
     /* Just the one? */
     if (count($mids)) {
         $members = IPSMember::load($mids, 'all');
         foreach ($members as $i => $d) {
             $_m = IPSMember::buildProfilePhoto($d);
             $return[$i] = array_merge((array) $_m, (array) $return[$i]);
         }
     }
     return is_array($return) ? $return : null;
 }
示例#14
0
 /**
  * Fetch new PM notification
  *
  * @access	public
  * @param	int			Number if items to limit
  * @param	string		Sort column
  * @param	string		Sort order
  * @param	bool		Only get unread notifications
  * @param	bool		Run text through preDisplayParse
  * @return 	array 		Unread notifications
  */
 public function fetchUnreadNotifications($limit = 0, $sortKey = 'notify_sent', $sortOrder = 'desc', $unread = 1, $parseText = false, $keyNames = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $return = array();
     $limit = $limit ? array(0, intval($limit)) : array(0, 500);
     $members = array();
     $mids = array();
     $where = "";
     $unread = is_array($unread) ? $unread : array($unread);
     if (count($keyNames)) {
         $where = " AND notify_type_key IN ('" . implode("','", $keyNames) . "')";
     }
     //-----------------------------------------
     // Fetch unread notifications
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->_member['member_id'] . ' AND notify_read IN (' . implode(',', $unread) . ')' . $where, 'order' => $sortKey . ' ' . $sortOrder, 'limit' => $limit));
     $outer = $this->DB->execute();
     while ($row = $this->DB->fetch($outer)) {
         /* As the email template parser makes an attempt to reparse 'safe' HTML, we need to make it safe here */
         $row['notify_text'] = IPSText::htmlspecialchars($row['notify_text']);
         IPSText::getTextClass('bbcode')->parse_smilies = 1;
         IPSText::getTextClass('bbcode')->parse_nl2br = 1;
         IPSText::getTextClass('bbcode')->parse_html = 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'global';
         if ($parseText) {
             $row['notify_text'] = IPSText::getTextClass('bbcode')->preDisplayParse(nl2br($row['notify_text']));
         }
         $row['notify_icon'] = $this->getNotificationIcon($row['notify_type_key']);
         $return[$row['notify_sent'] . '.' . $row['notify_id']] = $row;
         /* Store member id */
         $mids[$row['notify_from_id']] = $row['notify_from_id'];
     }
     /* Got anything? */
     if (!count($return)) {
         return array();
     }
     if (count($mids)) {
         $members = IPSMember::load(array_keys($mids), 'all');
         if (count($members)) {
             foreach ($return as $key => $data) {
                 if (in_array($data['notify_from_id'], array_keys($members))) {
                     $return[$key]['member'] = IPSMember::buildProfilePhoto($members[$data['notify_from_id']]);
                 }
             }
         }
     }
     /* 3.1 didn't store notify_from_id so we need to catch that */
     foreach ($return as $key => $data) {
         if (!$data['member']['member_id']) {
             $return[$key]['member'] = IPSMember::buildProfilePhoto(0);
         }
     }
     /* Return 'em */
     return $return;
 }
示例#15
0
 /**
  * Returns possible matches for the string input
  *
  * @return	@e void		Outputs to screen
  */
 protected function _getMembers()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $name = IPSText::convertUnicode($this->convertAndMakeSafe($this->request['name'], 0), true);
     $name = IPSText::convertCharsets($name, 'utf-8', IPS_DOC_CHAR_SET);
     //-----------------------------------------
     // Check length
     //-----------------------------------------
     if (IPSText::mbstrlen($name) < 3) {
         $this->returnJsonError('requestTooShort');
     }
     //-----------------------------------------
     // Try query...
     //-----------------------------------------
     $this->DB->build(array('select' => 'm.members_display_name, m.member_id, m.members_seo_name, m.member_group_id', 'from' => array('members' => 'm'), 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes(strtolower($name)) . "%'", 'order' => $this->DB->buildLength('m.members_display_name') . ' ASC', 'limit' => array(0, 15), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id', 'type' => 'left'))));
     $this->DB->execute();
     //-----------------------------------------
     // Got any results?
     //-----------------------------------------
     if (!$this->DB->getTotalRows()) {
         $this->returnJsonArray(array());
     }
     $return = array();
     while ($r = $this->DB->fetch()) {
         $url = $this->registry->output->buildSEOUrl("app=core&amp;module=modcp&amp;do=editmember&amp;mid={$r['member_id']}", 'public');
         $photo = IPSMember::buildProfilePhoto($r);
         $group = IPSMember::makeNameFormatted('', $r['member_group_id']);
         $return[$r['member_id']] = array('name' => $r['members_display_name'], 'showas' => '<strong>' . $r['members_display_name'] . '</strong> (' . $group . ')', 'img' => $photo['pp_thumb_photo'], 'img_w' => $photo['pp_mini_width'], 'img_h' => $photo['pp_mini_height'], 'url' => $url);
     }
     $this->returnJsonArray($return);
 }
示例#16
0
 /**
  * Searches for matching members
  *
  * @param	string		Search term
  * @param	array 		Existing search results
  * @return	array 		New search results
  */
 protected function _getMembers($term, $results)
 {
     if (!$this->registry->getClass('class_permissions')->checkPermission('member_edit', 'members', 'members')) {
         $results['members'] = array();
         return $results;
     }
     $term = strtolower($term);
     $this->DB->build(array('select' => 'm.*, pp.*, g.g_title', 'from' => array('members' => 'm'), 'where' => "members_l_username LIKE '%{$term}%' OR members_l_display_name LIKE '%{$term}%' OR " . $this->DB->buildLower('email') . " LIKE '%{$term}%'", 'limit' => array(0, 250), 'add_join' => array(array('from' => array('groups' => 'g'), 'where' => 'g.g_id=m.member_group_id', 'type' => 'left'), array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $this->DB->execute();
     while ($member = $this->DB->fetch()) {
         $_matched = '';
         $member = $r = IPSMember::buildProfilePhoto($member);
         $r = array();
         if ($member['members_l_display_name'] and strpos($term, $member['members_l_display_name']) !== false) {
             $r['_matched'] = 'members_display_name';
         } else {
             if ($member['members_l_username'] and strpos($term, $member['members_l_username']) !== false) {
                 $r['_matched'] = 'name';
             } else {
                 $r['_matched'] = 'email';
             }
         }
         $r['name'] = $member['members_display_name'];
         $r['extra'] = $member['g_title'];
         $r['img'] = $member['pp_mini_photo'];
         $r['url'] = $this->settings['_base_url'] . "&amp;app=members&amp;module=members&amp;section=members&amp;do=viewmember&amp;member_id=" . $member['member_id'];
         /* Trim out what we don't need */
         $results['members'][] = $r;
     }
     return $results;
 }
 /**
  * Returns PM data based on spec
  *
  * @param	int 		Member ID
  * @param	string		Folder ID (eg: inbox, sent, etc)
  * @param	array 		Array of data ( array[ 'sort' => '', offsetStart' => '', 'offsetEnd' => '' )
  * @return	array 		Array of PMs indexed by PM ID
  */
 public function getPersonalTopicsList($memberID, $folderID, $searchAndSort)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $sortKey = '';
     $where = '';
     $memberID = intval($memberID);
     $_memberIDs = array();
     $folderID = IPSText::alphanumericalClean($folderID, '-_');
     $oStart = intval($searchAndSort['offsetStart']);
     $oEnd = intval($searchAndSort['offsetEnd']);
     $messages = array();
     //-----------------------------------------
     // Figure out sort key
     //-----------------------------------------
     switch ($searchAndSort['sort']) {
         case 'rdate':
             $sortKey = 'mm.map_last_topic_reply ASC';
             break;
         case 'title':
             $sortKey = 'mt.mt_title ASC';
             break;
         case 'nameTo':
             $sortKey = 'mem.members_display_name ASC';
             break;
         default:
             $sortKey = 'mm.map_last_topic_reply DESC';
             break;
     }
     //-----------------------------------------
     // Figure out where clause (no, not santa)
     //-----------------------------------------
     switch ($folderID) {
         default:
             if ($this->_folderFilter) {
                 if ($this->_folderFilter == 'in') {
                     $where = " AND mm.map_user_active=1 AND ( mm.map_folder_id='{$folderID}' AND mm.map_is_starter=0 )";
                 } else {
                     if ($this->_folderFilter == 'sent') {
                         $where = " AND mm.map_user_active=1 AND ( mm.map_folder_id='{$folderID}' AND mm.map_is_starter=1)";
                     }
                 }
             } else {
                 if ($folderID != 'all') {
                     $where = " AND mm.map_user_active=1 AND mm.map_folder_id='{$folderID}'";
                 } else {
                     $where = " AND mm.map_user_active=1";
                 }
             }
             break;
         case 'drafts':
             $where = " AND mm.map_user_active=1 AND mt.mt_is_draft=1";
             break;
         case 'new':
             $where = ' AND mm.map_user_active=1 AND mm.map_has_unread=1';
             break;
     }
     if (!$memberID or !$folderID) {
         return $messages;
     } else {
         $this->DB->build(array('select' => 'mm.*', 'from' => array('message_topic_user_map' => 'mm'), 'where' => "mm.map_user_id=" . $memberID . $where, 'order' => $sortKey, 'limit' => array($oStart, $oEnd), 'add_join' => array(array('select' => 'mt.*', 'from' => array('message_topics' => 'mt'), 'where' => 'mm.map_topic_id=mt.mt_id', 'type' => 'left'), array('select' => 'msg.*', 'from' => array('message_posts' => 'msg'), 'where' => 'msg.msg_id=mt.mt_last_msg_id', 'type' => 'left'), array('select' => 'mem.members_display_name', 'from' => array('members' => 'mem'), 'where' => 'mt.mt_to_member_id=mem.member_id', 'type' => 'left'))));
         $this->DB->execute();
         //-----------------------------------------
         // Get the messages
         //-----------------------------------------
         while ($row = $this->DB->fetch()) {
             $_toID = intval($row['mt_to_member_id']);
             $_startID = intval($row['mt_starter_id']);
             $_lastID = intval($row['msg_author_id']);
             /* Add member IDs */
             $_memberIDs[$_toID] = $_toID;
             $_memberIDs[$_startID] = $_startID;
             $_memberIDs[$_lastID] = $_lastID;
             /* Invited users */
             if ($row['mt_invited_members']) {
                 $row['_invitedMembers'] = unserialize($row['mt_invited_members']);
                 if (is_array($row['_invitedMembers']) and count($row['_invitedMembers'])) {
                     foreach ($row['_invitedMembers'] as $_mid) {
                         $_memberIDs[$_mid] = $_mid;
                     }
                 }
             }
             /* Pagination */
             if (($row['mt_replies'] + 1) % $this->messagesPerPage == 0) {
                 $pages = ($row['mt_replies'] + 1) / $this->messagesPerPage;
             } else {
                 $number = ($row['mt_replies'] + 1) / $this->messagesPerPage;
                 $pages = ceil($number);
             }
             if ($pages > 1) {
                 for ($i = 0; $i < $pages; ++$i) {
                     $real_no = $i * $this->messagesPerPage;
                     $page_no = $i + 1;
                     if ($page_no == 4 and $pages > 4) {
                         $row['pages'][] = array('last' => 1, 'st' => ($pages - 1) * $this->messagesPerPage, 'page' => $pages);
                         break;
                     } else {
                         $row['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no);
                     }
                 }
             }
             /* The rest */
             $row['_folderName'] = $this->_dirData[$row['map_folder_id']]['real'];
             $row['_otherInviteeCount'] = intval($row['mt_to_count'] - 1);
             $messages[$row['mt_id']] = $row;
         }
         $members = array();
         /* Got any members? */
         if (count($_memberIDs)) {
             $members = IPSMember::load($_memberIDs, 'all');
         }
         /* Let's sort out the ignore & photos at once for everyone */
         if (count($members)) {
             foreach ($members as $_mid => $_mdata) {
                 $_mdata['_canBeBlocked'] = IPSMember::isIgnorable($_mdata['member_group_id'], $_mdata['mgroup_others'], 'pm');
                 $members[$_mid] = IPSMember::buildProfilePhoto($_mdata);
             }
         }
         $members[0] = IPSMember::buildProfilePhoto(array('members_display_name' => $this->lang->words['deleted_user']));
         /* Now merge (in turn!) */
         foreach ($messages as $id => $row) {
             /* From */
             $messages[$id]['_starterMemberData'] = $members[$row['mt_starter_id']];
             /* To */
             $messages[$id]['_toMemberData'] = $members[$row['mt_to_member_id']];
             /* Last msg author */
             $messages[$id]['_lastMsgAuthor'] = $members[$row['msg_author_id']];
             /* Invitees */
             if (is_array($row['_invitedMembers']) and count($row['_invitedMembers'])) {
                 foreach ($row['_invitedMembers'] as $_mid) {
                     $messages[$id]['_invitedMemberData'][$_mid] = $members[$_mid];
                     $messages[$id]['_invitedMemberNames'][] = $members[$_mid]['members_display_name'];
                 }
             } else {
                 $row['_invitedMembers'] = array();
                 $messages[$id]['_invitedMemberData'] = array();
                 $messages[$id]['_invitedMemberNames'] = array();
             }
         }
     }
     return $messages;
 }
示例#18
0
 /**
  * Saves the add forum dialog
  */
 protected function _saveAddMemberDialog()
 {
     $type = trim($this->request['type']);
     $rules = $this->archiveWriter->getRulesFromDb();
     $int = $type == 'archive' ? 0 : 1;
     $return = array();
     /* INIT */
     $memberName = trim($this->request['addName']);
     /* Existing names */
     $current = IPSLib::isSerialized($rules[$type]['member']['text']) ? unserialize($rules[$type]['member']['text']) : array();
     /* Fetch from DB */
     $member = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "members_display_name = '" . $this->DB->addSlashes($memberName) . "'"));
     if ($member['member_id']) {
         $current[] = $member['member_id'];
     }
     $current = array_unique($current);
     /* Update DB */
     $this->DB->replace('core_archive_rules', array('archive_key' => md5('forums_member_' . $int), 'archive_app' => 'forums', 'archive_field' => 'member', 'archive_value' => '', 'archive_text' => serialize($current), 'archive_unit' => '', 'archive_skip' => $int), array('archive_key'));
     /* Update members */
     if (count($current)) {
         $members = IPSMember::load($current, 'all');
         foreach ($members as $id => $data) {
             $members[$id] = IPSMember::buildProfilePhoto($members[$id]);
             $members[$id]['photoTag'] = IPSMember::buildPhotoTag($members[$id], 'inset');
         }
     }
     $this->returnJsonArray(array('count' => count($members), 'data' => $members, 'ids' => serialize(array_keys($members))));
 }
示例#19
0
 /**
  * Get 12 random friends
  *
  * @param	array 	$member	Member data
  * @return	@e array
  */
 protected function _getRandomFriends($member)
 {
     # Get random number from member's friend cache... grab 10 random. array_rand( array, no.)
     # also fall back on last 10 if no cache
     $_member_ids = array();
     $friends = array();
     if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) {
         $member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']);
         if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) {
             foreach ($member['_cache']['friends'] as $id => $approved) {
                 $id = intval($id);
                 if ($approved and $id) {
                     $_member_ids[] = $id;
                 }
             }
             $member['_total_approved_friends'] = count($_member_ids);
             if (is_array($_member_ids) and $member['_total_approved_friends']) {
                 $_max = $member['_total_approved_friends'] > 12 ? 12 : $member['_total_approved_friends'];
                 $_rand = array_rand($_member_ids, $_max);
                 $_final = array();
                 # If viewing member is in list, let's show em
                 if (in_array($this->memberData['member_id'], $_member_ids)) {
                     $_final[] = $this->memberData['member_id'];
                     $new_mids = array();
                     foreach ($_member_ids as $mid) {
                         if ($mid == $this->memberData['member_id']) {
                             continue;
                         }
                         $new_mids[] = $mid;
                     }
                     $_member_ids = $new_mids;
                     unset($new_mids);
                     if (is_array($_rand)) {
                         if (count($_rand) >= 12) {
                             array_pop($_rand);
                         }
                     }
                 }
                 if (is_array($_rand) and count($_rand)) {
                     foreach ($_rand as $_id) {
                         $_final[] = $_member_ids[$_id];
                     }
                 }
                 if (count($_final)) {
                     $sql_extra = ' AND friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')';
                 }
             }
         }
         /* Fetch friends */
         $_memberIds = array();
         $_members = array();
         $_friends = array();
         $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id')), 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1' . ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')' . $sql_extra, 'limit' => array(0, 12), 'order' => 'friends_approved DESC'));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $_memberIds[] = $row['friends_friend_id'];
             $_friends[] = $row;
         }
         /* Got members? */
         $_members = IPSMember::load($_memberIds, 'core,extendedProfile');
         foreach ($_friends as $row) {
             if (!isset($_members[$row['friends_friend_id']])) {
                 continue;
             }
             $row = array_merge($row, $_members[$row['friends_friend_id']]);
             $row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT');
             $row = IPSMember::buildProfilePhoto($row);
             $friends[] = $row;
         }
     }
     return $friends;
 }
示例#20
0
 /**
  * Get data based on an area and last sent greater than date [unix timestampe]
  *
  * @param	integer		$date			Unix timestamp
  * @param	array		$types			Array of notification types (optional)
  * @param	array		$parseMembers	Parse extra data for each member and build display photo (false is default)
  * @param	integer		$sendMax	Null (use ipsRegistry::$setting or send INT only)
  * @return	@e mixed	Array of likes data OR null
  * @see		allowedFrequencies()	 
  */
 public function getDataByAreaAndLastSentOlderThanDate($date, $types = array(), $parseMembers = false, $sendMax = null)
 {
     /* Init */
     $mids = array();
     $members = array();
     $rows = array();
     $joins = array();
     $where = is_array($types) ? ' AND l.like_notify_freq IN (\'' . implode("','", $types) . '\')' : '';
     $sendMax = $sendMax !== null ? $sendMax : ipsRegistry::$settings['like_notifications_limit'];
     /* figure out joins */
     $joins[] = array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=l.like_member_id', 'type' => 'left');
     $moreJoins = $this->getDataJoins();
     if (is_array($moreJoins) and count($moreJoins)) {
         foreach ($moreJoins as $join) {
             $joins[] = $join;
         }
     }
     /* Prevent it going back EONS AND EONS */
     $oldestPossDate = 0;
     if (in_array('weekly', $types)) {
         $oldestPossDate = $date - 86400 * 7;
     } else {
         $oldestPossDate = $date - 86400;
     }
     if ($oldestPossDate) {
         $where .= ' AND ( CASE WHEN l.like_notify_sent > 0 THEN l.like_notify_sent ELSE l.like_added END ) < ' . intval($oldestPossDate);
     }
     /* Fetch data */
     $this->DB->build(array('select' => 'l.*', 'from' => array('core_like' => 'l'), 'where' => 'l.like_notify_do=1 AND l.like_app=\'' . classes_like_registry::getApp() . '\' AND l.like_area=\'' . classes_like_registry::getArea() . '\' AND l.like_visible=1 AND ( CASE WHEN l.like_notify_sent > 0 THEN l.like_notify_sent ELSE l.like_added END ) < ' . intval($date) . $where, 'order' => 'l.like_notify_sent ASC', 'limit' => array(0, $sendMax), 'add_join' => $joins));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         $row['like_member_id'] = intval($row['like_member_id']);
         $mids[$row['like_member_id']] = $row['like_member_id'];
         /* Need to apply secondary groups and grab g_perm_id if $parseMembers is false (default)
         			@link http://community.invisionpower.com/tracker/issue-34691-digest-notifications-not-going-out/ */
         $row['mgroup_others'] = $row['mgroup_others'] != '' ? IPSText::cleanPermString($row['mgroup_others']) : '';
         //by denchu
         if (is_array($this->caches['group_cache'][$row['member_group_id']])) {
             $row = array_merge($row, $this->caches['group_cache'][$row['member_group_id']]);
         }
         $row = $this->registry->member()->setUpSecondaryGroups($row);
         if ($row['topic_last_post']) {
             $row['last_post'] = $row['topic_last_post'];
         }
         /* @link http://community.invisionpower.com/tracker/issue-32204-dailyweekly-notifications */
         $data[$row['like_member_id']][$row['like_id']] = $row;
     }
     /* Just the one? */
     if ($parseMembers && count($mids)) {
         $members = IPSMember::load($mids, 'all');
         foreach ($members as $i => $d) {
             $_m = IPSMember::buildProfilePhoto($d);
             foreach ($data[$i] as $likeId => $likeData) {
                 $data[$i][$likeId] = array_merge((array) $_m, (array) $data[$i][$likeId]);
             }
         }
     }
     return is_array($data) ? $data : null;
 }
 /**
  * Modern profile
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _viewModern()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($this->request['id']) ? intval($this->request['id']) : intval($this->request['MID']);
     $member_id = $member_id ? $member_id : $this->memberData['member_id'];
     $tab = substr(IPSText::alphanumericalClean(str_replace('..', '', trim($this->request['tab']))), 0, 20);
     $firsttab = '';
     $member = array();
     $comments = array();
     $comments_html = "";
     $friends = array();
     $visitors = array();
     $comment_perpage = 5;
     $pips = 0;
     $tabs = array();
     $_tabs = array();
     $_positions = array(0 => 0);
     $custom_path = IPSLib::getAppDir('members') . '/sources/tabs';
     $_member_ids = array();
     $sql_extra = '';
     $pass = 0;
     $mod = 0;
     $_todays_date = getdate();
     $time_adjust = $this->settings['time_adjust'] == "" ? 0 : $this->settings['time_adjust'];
     $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies'];
     //-----------------------------------------
     // Check input..
     //-----------------------------------------
     if (!$member_id) {
         $this->registry->output->silentRedirect($this->settings['base_url']);
     }
     //-----------------------------------------
     // Configure tabs
     //-----------------------------------------
     if (is_dir($custom_path)) {
         foreach (new DirectoryIterator($custom_path) as $f) {
             if (!$f->isDot() && !$f->isDir()) {
                 $file = $f->getFileName();
                 if ($file[0] == '.') {
                     continue;
                 }
                 if (preg_match("#\\.conf\\.php\$#i", $file)) {
                     $classname = str_replace(".conf.php", "", $file);
                     require $custom_path . '/' . $file;
                     //-------------------------------
                     // Allowed to use?
                     //-------------------------------
                     if ($CONFIG['plugin_enabled']) {
                         if (in_array($this->settings['search_method'], array('traditional', 'sphinx')) && $CONFIG['plugin_key'] == 'recentActivity') {
                             continue;
                         }
                         $_position = in_array($CONFIG['plugin_order'], $_positions) ? count($_positions) + 1 : $CONFIG['plugin_order'];
                         $_tabs[$_position] = $CONFIG;
                         $_positions[$_position] = $_position;
                     }
                 }
             }
         }
     }
     ksort($_tabs);
     foreach ($_tabs as $_pos => $data) {
         if (!$firsttab) {
             $firsttab = $data['plugin_key'];
         }
         $data['_lang'] = isset($this->lang->words[$data['plugin_lang_bit']]) ? $this->lang->words[$data['plugin_lang_bit']] : $data['plugin_name'];
         $tabs[$data['plugin_key']] = $data;
     }
     if ($tab != 'comments' and $tab != 'settings' and !file_exists($custom_path . '/' . $tab . '.php')) {
         $tab = $firsttab;
     }
     //-----------------------------------------
     // Grab all data...
     //-----------------------------------------
     $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups', 'id');
     if (!$member['member_id']) {
         $this->registry->output->showError('profiles_no_member', 10246);
     }
     /* Check USER permalink... */
     $this->registry->getClass('output')->checkPermalink($member['members_seo_name'] ? $member['members_seo_name'] : IPSText::makeSeoTitle($member['members_display_name']));
     /* Build data */
     $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile', 'checkFormat' => 1, 'cfGetGroupData' => 1, 'signature' => 1));
     //-----------------------------------------
     // Recent visitor?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id']) {
         list($be_anon, $loggedin) = explode('&', $this->memberData['login_anonymous']);
         if (!$be_anon) {
             $this->_addRecentVisitor($member, $this->memberData['member_id']);
         }
     }
     //-----------------------------------------
     // DST?
     //-----------------------------------------
     if ($member['dst_in_use'] == 1) {
         $member['time_offset'] += 1;
     }
     //-----------------------------------------
     // Format extra user data
     //-----------------------------------------
     $member['_age'] = $member['bday_year'] ? date('Y') - $member['bday_year'] : 0;
     if ($member['bday_month'] > date('n')) {
         $member['_age'] -= 1;
     } else {
         if ($member['bday_month'] == date('n')) {
             if ($member['bday_day'] > date('j')) {
                 $member['_age'] -= 1;
             }
         }
     }
     $member['_local_time'] = $member['time_offset'] != "" ? gmstrftime($this->settings['clock_long'], time() + $member['time_offset'] * 3600 + $time_adjust * 60) : '';
     $member['g_title'] = IPSLib::makeNameFormatted($member['g_title'], $member['g_id'], $member['prefix'], $member['suffix']);
     $member['_posts_day'] = 0;
     $member['_total_pct'] = 0;
     $member['_bday_month'] = $member['bday_month'] ? $this->lang->words['M_' . $member['bday_month']] : 0;
     //-----------------------------------------
     // BIO
     //-----------------------------------------
     $member['pp_bio_content'] = IPSText::getTextClass('bbcode')->stripBadWords($member['pp_bio_content']);
     $member['pp_bio_content'] = IPSText::wordwrap($member['pp_bio_content'], '25', ' ');
     if (!$this->settings['disable_profile_stats']) {
         $posts = $this->DB->buildAndFetch(array('select' => "COUNT(*) as total_posts", 'from' => "posts", 'where' => "author_id=" . $member['member_id']));
         $member['posts'] = $posts['total_posts'];
         //-----------------------------------------
         // Total posts
         //-----------------------------------------
         if ($member['posts'] and $board_posts) {
             $member['_posts_day'] = round($member['posts'] / ((time() - $member['joined']) / 86400), 2);
             # Fix the issue when there is less than one day
             $member['_posts_day'] = $member['_posts_day'] > $member['posts'] ? $member['posts'] : $member['_posts_day'];
             $member['_total_pct'] = sprintf('%.2f', $member['posts'] / $board_posts * 100);
         }
         $member['_posts_day'] = floatval($member['_posts_day']);
         //-----------------------------------------
         // Most active in
         //-----------------------------------------
         $favorite = $this->DB->buildAndFetch(array('select' => 'COUNT(p.author_id) as f_posts', 'from' => array('posts' => 'p'), 'where' => 'p.author_id=' . $member['member_id'] . ' AND ' . $this->registry->permissions->buildPermQuery('i'), 'order' => 'f_posts DESC', 'group' => 't.forum_id', 'add_join' => array(array('select' => 't.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id'), array('from' => array('permission_index' => 'i'), 'where' => "i.perm_type='forum' AND i.perm_type_id=t.forum_id"))));
         $member['favorite_id'] = $favorite['forum_id'];
         $member['_fav_posts'] = $favorite['f_posts'];
         if ($member['posts']) {
             $member['_fav_percent'] = round($favorite['f_posts'] / $member['posts'] * 100);
         }
     }
     //-----------------------------------------
     // Comments
     //-----------------------------------------
     if ($member['pp_setting_count_comments']) {
         require_once IPSLib::getAppDir('members') . '/sources/comments.php';
         $comment_lib = new profileCommentsLib($this->registry);
         $comment_html = $comment_lib->buildComments($member);
     }
     //-----------------------------------------
     // Visitors
     //-----------------------------------------
     if ($member['pp_setting_count_visitors']) {
         $_pp_last_visitors = unserialize($member['pp_last_visitors']);
         $_visitor_info = array();
         $_count = 1;
         if (is_array($_pp_last_visitors)) {
             krsort($_pp_last_visitors);
             $_members = IPSMember::load(array_values($_pp_last_visitors), 'extendedProfile');
             foreach ($_members as $_id => $_member) {
                 $_visitor_info[$_id] = IPSMember::buildDisplayData($_member, 0);
             }
             foreach ($_pp_last_visitors as $_time => $_id) {
                 if ($_count > $member['pp_setting_count_visitors']) {
                     break;
                 }
                 $_count++;
                 if (!$_visitor_info[$_id]['members_display_name_short']) {
                     $_visitor_info[$_id] = IPSMember::setUpGuest();
                 }
                 $_visitor_info[$_id]['_visited_date'] = ipsRegistry::getClass('class_localization')->getDate($_time, 'TINY');
                 $_visitor_info[$_id]['members_display_name_short'] = $_visitor_info[$_id]['members_display_name_short'] ? $_visitor_info[$_id]['members_display_name_short'] : $this->lang->words['global_guestname'];
                 $visitors[] = $_visitor_info[$_id];
             }
         }
     }
     //-----------------------------------------
     // Friends
     //-----------------------------------------
     # Get random number from member's friend cache... grab 10 random. array_rand( array, no.)
     # also fall back on last 10 if no cache
     if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) {
         $member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']);
         if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) {
             foreach ($member['_cache']['friends'] as $id => $approved) {
                 $id = intval($id);
                 if ($approved and $id) {
                     $_member_ids[] = $id;
                 }
             }
             $member['_total_approved_friends'] = count($_member_ids);
             if (is_array($_member_ids) and count($_member_ids)) {
                 $_max = count($_member_ids) > 50 ? 50 : count($_member_ids);
                 $_rand = array_rand($_member_ids, $_max);
                 $_final = array();
                 # If viewing member is in list, let's show em
                 if (in_array($this->memberData['member_id'], $_member_ids)) {
                     $_final[] = $this->memberData['member_id'];
                     $new_mids = array();
                     foreach ($_member_ids as $mid) {
                         if ($mid == $this->memberData['member_id']) {
                             continue;
                         }
                         $new_mids[] = $mid;
                     }
                     $_member_ids = $new_mids;
                     unset($new_mids);
                     if (is_array($_rand)) {
                         if (count($_rand) >= 50) {
                             array_pop($_rand);
                         }
                     }
                 }
                 if (is_array($_rand) and count($_rand)) {
                     foreach ($_rand as $_id) {
                         $_final[] = $_member_ids[$_id];
                     }
                 }
                 if (count($_final)) {
                     $sql_extra = ' AND pf.friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')';
                 }
             }
         }
         $this->DB->build(array('select' => 'pf.*', 'from' => array('profile_friends' => 'pf'), 'where' => 'pf.friends_member_id=' . $member_id . ' AND pf.friends_approved=1' . $sql_extra, 'limit' => array(0, 50), 'order' => 'm.members_display_name ASC', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pf.friends_friend_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
         $outer = $this->DB->execute();
         while ($row = $this->DB->fetch($outer)) {
             $row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT');
             $row['_location'] = $row['location'] ? $row['location'] : $this->lang->words['no_info'];
             $row = IPSMember::buildProfilePhoto($row);
             $row['members_display_name_short'] = IPSText::truncate($row['members_display_name'], 13);
             $friends[] = $row;
         }
     }
     $member['_total_displayed_friends'] = count($friends);
     //-----------------------------------------
     // Online location
     //-----------------------------------------
     $member = IPSMember::getLocation($member);
     //-----------------------------------------
     // Add profile view
     //-----------------------------------------
     $this->DB->insert('profile_portal_views', array('views_member_id' => $member['member_id']), true);
     //-----------------------------------------
     // Grab default tab...
     //-----------------------------------------
     $tab_html = '';
     if ($tab != 'comments' and $tab != 'settings') {
         if (file_exists($custom_path . '/' . $tab . '.php')) {
             require $custom_path . '/pluginParentClass.php';
             require $custom_path . '/' . $tab . '.php';
             $_func_name = 'profile_' . $tab;
             $plugin = new $_func_name($this->registry);
             $tab_html = $plugin->return_html_block($member);
         }
     }
     //-----------------------------------------
     // Set description tag
     //-----------------------------------------
     $_desc = $member['pp_about_me'] ? $member['pp_about_me'] : $member['signature'];
     if ($_desc) {
         $this->registry->output->addMetaTag('description', $member['members_display_name'] . ': ' . IPSText::getTextClass('bbcode')->stripAllTags($_desc));
     }
     //-----------------------------------------
     // Add to output
     //-----------------------------------------
     $this->member_name = $member['members_display_name'];
     $this->output = $this->registry->getClass('output')->getTemplate('profile')->profileModern($tabs, $member, $comment_html, $friends, $visitors, $tab, $tab_html, $fields);
 }
示例#22
0
 /**
  * Show the online list
  *
  * @return	@e void		[Stores HTML in $this->output]
  */
 protected function _listAll()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->first = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
     $final = array();
     $modules = array();
     $memberIDs = array();
     if (!$this->settings['au_cutoff']) {
         $this->settings['au_cutoff'] = 15;
     }
     $defaults = array('show_mem' => ($this->request['show_mem'] and in_array($this->request['show_mem'], array('reg', 'guest', 'all'))) ? $this->request['show_mem'] : 'all', 'sort_order' => ($this->request['sort_order'] and in_array($this->request['sort_order'], array('desc', 'asc'))) ? $this->request['sort_order'] : 'asc', 'sort_key' => ($this->request['sort_key'] and in_array($this->request['sort_key'], array('click', 'name'))) ? $this->request['sort_key'] : 'click');
     //-----------------------------------------
     // Sort the db query
     //-----------------------------------------
     $cut_off = $this->settings['au_cutoff'] * 60;
     $t_time = time() - $cut_off;
     $db_order = $defaults['sort_order'] == 'asc' ? 'asc' : 'desc';
     $db_key = $defaults['sort_key'] == 'click' ? 'running_time' : 'member_name';
     $wheres = array('running_time > ' . $t_time);
     switch ($defaults['show_mem']) {
         case 'reg':
             $wheres[] = "member_id > 0";
             $wheres[] = "member_group != " . $this->settings['guest_group'];
             break;
         case 'guest':
             $wheres[] = "member_group = " . $this->settings['guest_group'];
             break;
     }
     if (!$this->settings['spider_active'] and !$this->memberData['g_access_cp']) {
         $wheres[] = $this->DB->buildRight('id', 8) . " != '_session'";
     }
     if (!$this->memberData['g_access_cp']) {
         $wheres[] = "login_type != 1";
     }
     //-----------------------------------------
     // Grab all the current sessions.
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'sessions', 'where' => implode(' AND ', $wheres), 'calcRows' => TRUE, 'order' => $db_key . ' ' . $db_order, 'limit' => array($this->first, $this->perpage)));
     $outer = $this->DB->execute();
     $max = $this->DB->fetchCalculatedRows();
     if (!$this->DB->getTotalRows($outer) && $this->first > 0) {
         // We are request page 2 - but there is no page 2 now...
         $this->registry->output->silentRedirect($this->settings['base_url'] . "app=members&amp;section=online&amp;module=online&amp;sortkey={$defaults['sort_key']}&amp;show_mem={$defaults['show_mem']}&amp;sort_order={$defaults['sort_order']}");
     }
     //-----------------------------------------
     // Put results into array
     //-----------------------------------------
     while ($r = $this->DB->fetch($outer)) {
         if (strstr($r['id'], '_session')) {
             $r['is_bot'] = 1;
         }
         $r['where_line'] = '';
         $r['where_link'] = '';
         //-----------------------------------------
         // Sessions aren't updated until shutdown
         // so reset our session now
         //-----------------------------------------
         if ($this->memberData['member_id'] and $r['member_id'] == $this->memberData['member_id']) {
             $r['current_appcomponent'] = 'members';
             $r['current_module'] = 'online';
             $r['current_section'] = 'online';
         }
         //-----------------------------------------
         // Is this a member?
         //-----------------------------------------
         if ($r['member_id']) {
             $memberIDs[] = $r['member_id'];
         }
         //-----------------------------------------
         // Don't parse if in an error
         //-----------------------------------------
         if ($r['in_error']) {
             $r['current_appcomponent'] = 'core';
         }
         $final[$r['id']] = $r;
         //-----------------------------------------
         // Module?
         //-----------------------------------------
         $modules[$r['current_section']] = array('app' => $r['current_appcomponent']);
     }
     $links = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $this->perpage, 'currentStartValue' => $this->first, 'baseUrl' => "app=members&amp;section=online&amp;module=online&amp;sort_key={$defaults['sort_key']}&amp;sort_order={$defaults['sort_order']}&amp;show_mem={$defaults['show_mem']}"));
     //-----------------------------------------
     // Pass off entries to modules..
     //-----------------------------------------
     if (count($modules)) {
         foreach ($modules as $module_array) {
             if (IPSLib::appIsInstalled($module_array['app'])) {
                 $module_array['app'] = IPSText::alphanumericalClean($module_array['app']);
                 $filename = IPSLib::getAppDir($module_array['app']) . '/extensions/coreExtensions.php';
                 if (is_file($filename)) {
                     $classToLoad = IPSLib::loadLibrary($filename, 'publicSessions__' . $module_array['app'], $module_array['app']);
                     $loader = new $classToLoad();
                     if (method_exists($loader, 'parseOnlineEntries')) {
                         $final = $loader->parseOnlineEntries($final);
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Finally, members...
     //-----------------------------------------
     if (count($memberIDs)) {
         $members = IPSMember::load($memberIDs, 'all');
     }
     $newFinal = array();
     if (is_array($final) and count($final)) {
         foreach ($final as $id => $data) {
             if ($data['member_id']) {
                 $newFinal['member-' . $data['member_id']] = $data;
                 $newFinal['member-' . $data['member_id']]['memberData'] = $members[$data['member_id']];
                 $newFinal['member-' . $data['member_id']]['_memberData'] = IPSMember::buildProfilePhoto($members[$data['member_id']]);
             } else {
                 $newFinal[$data['id']] = $data;
                 $newFinal[$data['id']]['memberData'] = array();
                 $newFinal[$data['id']]['_memberData'] = IPSMember::buildProfilePhoto(0);
             }
         }
     }
     //-----------------------------------------
     // Set defaults
     //-----------------------------------------
     foreach (array('sort_key', 'sort_order', 'show_mem') as $k) {
         if (!$this->request[$k]) {
             $this->request[$k] = $defaults[$k];
         }
     }
     //-----------------------------------------
     // Output
     //-----------------------------------------
     $this->output .= $this->registry->getClass('output')->getTemplate('online')->showOnlineList($newFinal, $links, $defaults);
 }
 /**
  * Execute plugin
  *
  * @param	array 	$permissions	Moderator permissions
  * @return	@e string
  */
 public function executePlugin($permissions)
 {
     //-----------------------------------------
     // Check permissions
     //-----------------------------------------
     if (!$this->canView($permissions)) {
         return '';
     }
     //-----------------------------------------
     // Load reasons
     //-----------------------------------------
     $reasons = array();
     $this->DB->build(array('select' => '*', 'from' => 'members_warn_reasons', 'order' => 'wr_order'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $reasons[$row['wr_id']] = $row;
     }
     //-----------------------------------------
     // Get last 10 warnings
     //-----------------------------------------
     $st = intval($this->request['st']);
     $total = $this->DB->buildAndFetch(array('select' => 'count(*) as warns', 'from' => 'members_warn_logs'));
     $warnings = array();
     $this->DB->build(array('select' => 'w.*', 'from' => array('members_warn_logs' => 'w'), 'order' => 'w.wl_date DESC', 'limit' => array($st, 10), 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=w.wl_member', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left'), array('select' => 'mm.member_id as punisher_id, mm.member_group_id as punisher_group, mm.members_display_name as punisher_name, mm.members_seo_name as punisher_seo_name', 'from' => array('members' => 'mm'), 'where' => 'mm.member_id=w.wl_moderator', 'type' => 'left'), array('select' => 'ppp.pp_main_photo as punisher_check, ppp.pp_thumb_photo as punisher_photo, ppp.pp_thumb_width as punisher_width, ppp.pp_thumb_height as punisher_height', 'from' => array('profile_portal' => 'ppp'), 'where' => 'mm.member_id=ppp.pp_member_id', 'type' => 'left'))));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         /* Sort out punisher */
         $r['punisherMember'] = array('member_id' => $r['punisher_id'], 'member_group_id' => $r['punisher_group'], 'members_display_name' => $r['punisher_name'], 'members_seo_name' => $r['punisher_seo_name']);
         $r['punisher_photo'] = IPSMember::buildProfilePhoto(array('pp_main_photo' => $r['punisher_check'], 'pp_thumb_photo' => $r['punisher_photo'], 'pp_thumb_width' => $r['punisher_width'], 'pp_thumb_height' => $r['punisher_height']), 'mini');
         $r['wl_reason'] = $r['wl_reason'] ? $reasons[$r['wl_reason']]['wr_name'] : '--';
         $warnings[] = IPSMember::buildDisplayData($r, array('reputation' => 0, 'warn' => 0));
     }
     //-----------------------------------------
     // Page links
     //-----------------------------------------
     $pages = $this->registry->output->generatePagination(array('totalItems' => $total['warns'], 'itemsPerPage' => 10, 'currentStartValue' => $st, 'baseUrl' => "app=core&amp;module=modcp&amp;fromapp=members&amp;tab=warn"));
     return $this->registry->output->getTemplate('modcp')->latestWarnLogs($warnings, $pages);
 }