/** * @param $memID int member id * * show activities, notifications and settings on the profile page. The latter two * are only handled when viewing your own profile. * * This is here because Profile-View.php is already big enough :) */ function showActivitiesProfile($memID) { global $context, $user_info, $sourcedir, $user_profile, $txt, $modSettings, $options; $context['user']['is_owner'] = $memID == $user_info['id']; require_once $sourcedir . '/lib/Subs-Activities.php'; Eos_Smarty::loadTemplate('profile/profile_base'); loadLanguage('Activities'); $sa = isset($_GET['sa']) ? $_GET['sa'] : 'activities'; $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; if ($sa == 'settings') { return showActivitiesProfileSettings($memID); } Eos_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'profile/activities_display'); $context['page_title'] = $txt['showActivities'] . ' - ' . $user_profile[$memID]['real_name']; $context['pageindex_multiplier'] = commonAPI::getMessagesPerPage(); $context['act_results'] = 0; $context['rich_output'] = true; $context[$context['profile_menu_name']]['tab_data'] = array('title' => $txt['showActivities'], 'description' => $txt['showActivitiesMenu'], 'tabs' => array()); // these areas cannot be visited if it's not our own profile unless you are the mighty one if (($sa == 'notifications' || $sa == 'settings') && !$context['user']['is_owner'] && !$user_info['is_admin']) { fatal_lang_error('no_access'); } $result = 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 ({query_see_board} OR a.id_board = 0) AND (a.id_member = {int:id_user} OR a.id_owner = {int:id_user}) ORDER BY a.id_act DESC LIMIT {int:start}, 20', array('start' => $start, 'id_user' => $memID)); $context['act_global'] = true; aStreamOutput($result); $context['titletext'] = $context['page_title']; }
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); }