function BoardIndex() { global $txt, $user_info, $sourcedir, $modSettings, $context, $settings, $scripturl, $boardurl, $boarddir; EoS_Smarty::loadTemplate('boardindex'); $context['is_board_index'] = true; $context['sidebar_template'] = 'sidebars/sidebar_on_index.tpl'; $context['show_sidebar'] = true; $context['sidebar_class'] = 'index'; GetSidebarVisibility('index'); // Set a canonical URL for this page. $context['canonical_url'] = $scripturl; $context['share_url'] = $boardurl; // Do not let search engines index anything if there is a random thing in $_GET. if (!empty($_GET)) { $context['robot_no_index'] = true; } // Retrieve the categories and boards. require_once $sourcedir . '/lib/Subs-BoardIndex.php'; $boardIndexOptions = array('include_categories' => true, 'base_level' => 0, 'parent_id' => 0, 'set_latest_post' => true, 'countChildPosts' => !empty($modSettings['countChildPosts'])); $context['categories'] = getBoardIndex($boardIndexOptions); // Get the user online list. require_once $sourcedir . '/lib/Subs-MembersOnline.php'; $membersOnlineOptions = array('show_hidden' => allowedTo('moderate_forum'), 'sort' => 'log_time', 'reverse_sort' => true); $context += getMembersOnlineStats($membersOnlineOptions); $context['show_buddies'] = !empty($user_info['buddies']); // Are we showing all membergroups on the board index? if (!empty($settings['show_group_key'])) { $context['membergroups'] = cache_quick_get('membergroup_list', 'lib/Subs-Membergroups.php', 'cache_getMembergroupList', array()); } // Track most online statistics? (Subs-MembersOnline.php) if (!empty($modSettings['trackStats'])) { trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); } // Retrieve the latest posts if the theme settings require it. if (isset($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1) { $latestPostOptions = array('number_posts' => $settings['number_recent_posts']); $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'lib/Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); } $settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0; $settings['show_member_bar'] &= allowedTo('view_mlist'); $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); $context['show_member_list'] = allowedTo('view_mlist'); $context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']); // Load the calendar? if (!empty($modSettings['cal_enabled']) && allowedTo('calendar_view')) { // Retrieve the calendar data (events, birthdays, holidays). $eventOptions = array('include_holidays' => $modSettings['cal_showholidays'] > 1, 'include_birthdays' => $modSettings['cal_showbdays'] > 1, 'include_events' => $modSettings['cal_showevents'] > 1, 'num_days_shown' => empty($modSettings['cal_days_for_index']) || $modSettings['cal_days_for_index'] < 1 ? 1 : $modSettings['cal_days_for_index']); $context += cache_quick_get('calendar_index_offset_' . ($user_info['time_offset'] + $modSettings['time_offset']), 'lib/Subs-Calendar.php', 'cache_getRecentEvents', array($eventOptions)); // Whether one or multiple days are shown on the board index. $context['calendar_only_today'] = $modSettings['cal_days_for_index'] == 1; // This is used to show the "how-do-I-edit" help. $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); } else { $context['show_calendar'] = false; } $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); $context['template_hooks']['boardindex'] = array('above_boardlisting' => '', 'below_boardlisting' => ''); if (isset($context['show_who'])) { $bracketList = array(); if ($context['show_buddies']) { $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); } if (!empty($context['num_spiders'])) { $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); } if (!empty($context['num_users_hidden'])) { $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . $txt['hidden']; } if (!empty($bracketList)) { $context['show_who_formatted'] = ' (' . implode(', ', $bracketList) . ')'; } } $context['mark_read_button'] = array('markread' => array('text' => 'mark_as_read', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=all;' . $context['session_var'] . '=' . $context['session_id'])); HookAPI::callHook('boardindex', array()); fetchNewsItems(0, 0); }
public static function messageindex(&$board_info) { global $context, $txt, $sourcedir, $user_info; loadLanguage('Activities'); // add our plugin directory to the list of directories to search for templates. EoS_Smarty::addTemplateDir(dirname(__FILE__)); // register two hook templates for the side bar top and bottom areas EoS_Smarty::getConfigInstance()->registerHookTemplate('sidebar_top', 'testplugin_sidebar_top'); EoS_Smarty::getConfigInstance()->registerHookTemplate('sidebar_bottom', 'testplugin_sidebar_bottom'); // register some global variable (that's optional though, it would be totally ok to use $context) // You should always assignByRef(), because it's faster and doesn't create a copy // of the variable EoS_Smarty::getSmartyInstance()->assignByRef('MYDATA', self::$mydata); // enable side bar in the message index display if ($user_info['is_admin'] && $board_info['allow_topics']) { $context['show_sidebar'] = true; $context['sidebar_template'] = 'sidebars/sidebar_on_messageindex.tpl'; $context['sidebar_class'] = 'messageindex'; GetSidebarVisibility('messageindex'); } else { $context['show_sidebar'] = false; } $ignoreusers = !empty($user_info['ignoreusers']) ? $user_info['ignoreusers'] : array(0); // .. and set the name of the template self::$mydata['testvalue'] = 'Foo'; @(require_once $sourcedir . '/lib/Subs-Activities.php'); $context['act_global'] = false; $request = smf_db_query('SELECT a.*, t.*, b.name AS board_name FROM {db_prefix}log_activities AS a LEFT JOIN {db_prefix}activity_types AS t ON (t.id_type = a.id_type) LEFT JOIN {db_prefix}boards AS b ON (b.id_board = a.id_board) WHERE a.id_board = {int:id_board} AND a.id_member NOT IN({array_int:ignoredusers}) ORDER BY a.id_act DESC LIMIT 5', array('id_board' => $context['current_board'], 'ignoredusers' => $ignoreusers)); aStreamOutput($request, false, true); /* if(isset($context['activities'])) { usort($context['activities'], function($a, $b) { if ($a['updated'] == $b['updated']) return 0; return ($a['updated'] < $b['updated']) ? -1 : 1; }); }*/ $request = smf_db_query('SELECT m.* FROM {db_prefix}messages AS m WHERE m.id_board = {int:id_board} AND m.id_member NOT IN ({array_int:ignoredusers}) ORDER BY m.id_msg DESC LIMIT 10', array('id_board' => $context['current_board'], 'ignoredusers' => $ignoreusers)); mysql_free_result($request); }