public function display_tpotm($event) { $now = time(); $date_today = gmdate("Y-m-d", $now); list($year_cur, $month_cur, $day1) = split('-', $date_today); // Start time for current month $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur); $month_start = $month_start_cur; $month_end = $now; // group_id 5 = administrators // group_id 4 = global moderators // this groups belong to a Vanilla 3.1.x board $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, COUNT(p.post_id) AS total_posts FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p WHERE u.user_id > ' . ANONYMOUS . ' AND u.user_id = p.poster_id AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . ' AND (u.user_type <> ' . USER_FOUNDER . ') AND (u.group_id <> 5) AND (u.group_id <> 4) GROUP BY u.user_id ORDER BY total_posts DESC'; $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // let's go then.. // posts made into the selected elapsed time $topm_tp = $row['total_posts']; $topm_un = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); // there is not a Top Poster, usually happens with fresh installations, where only the FOUNDER made the first post/topic. Or no normal users already did it. //Here TOPM_UN reflects this state. $this->template->assign_vars(array('TOPM_UN' => $topm_tp < 1 ? $topm_un = $this->user->lang['TOP_USERNAME_NONE'] : $topm_un, 'L_TPOTM' => $this->user->lang['TOP_CAT'], 'L_TOPM_UNA_L' => $this->user->lang['TOP_USERNAME'], 'L_TOPM_UPO_L' => sprintf($this->user->lang['TOP_USER_MONTH_POSTS'], $topm_tp), 'L_TOPM_POSTS_L' => $topm_tp > 1 || $topm_tp == 0 ? $this->user->lang['TOP_POSTS'] : $this->user->lang['TOP_POST'])); }
public function search($start = 1) { if (!$this->auth->acl_get('u_usermap_search')) { trigger_error('NOT_AUTHORISED'); } $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang('USERMAP_TITLE'), 'U_VIEW_FORUM' => $this->helper->route('tas2580_usermap_index', array()))); $lon = substr($this->request->variable('lon', ''), 0, 10); $lat = substr($this->request->variable('lat', ''), 0, 10); $dst = $this->request->variable('dst', $this->config['tas2580_usermap_search_distance']); $alpha = 180 * $dst / (6378137 / 1000 * 3.14159); $min_lon = $this->db->sql_escape($lon - $alpha); $max_lon = $this->db->sql_escape($lon + $alpha); $min_lat = $this->db->sql_escape($lat - $alpha); $max_lat = $this->db->sql_escape($lat + $alpha); $where = " WHERE ( user_usermap_lon >= '{$min_lon}' AND user_usermap_lon <= '{$max_lon}') AND ( user_usermap_lat >= '{$min_lat}' AND user_usermap_lat<= '{$max_lat}')"; $limit = (int) $this->config['topics_per_page']; $sql = 'SELECT COUNT(user_id) AS num_users FROM ' . USERS_TABLE . $where; $result = $this->db->sql_query($sql); $total_users = (int) $this->db->sql_fetchfield('num_users'); $this->db->sql_freeresult($result); $sql = 'SELECT user_id, username, user_colour, user_regdate, user_posts, group_id, user_usermap_lon, user_usermap_lat FROM ' . USERS_TABLE . $where; $result = $this->db->sql_query_limit($sql, $limit, ($start - 1) * $limit); while ($row = $this->db->sql_fetchrow($result)) { $distance = $this->get_distance($lon, $lat, $row['user_usermap_lon'], $row['user_usermap_lat']); $this->template->assign_block_vars('memberrow', array('USER_ID' => $row['user_id'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'JOINED' => $this->user->format_date($row['user_regdate']), 'POSTS' => $row['user_posts'], 'GROUP_ID' => $row['group_id'], 'DISTANCE' => $distance)); } $this->pagination->generate_template_pagination(array('routes' => array('tas2580_usermap_search', 'tas2580_usermap_search_page'), 'params' => array()), 'pagination', 'start', $total_users, $limit, ($start - 1) * $limit); $this->template->assign_vars(array('TOTAL_USERS' => $this->user->lang('TOTAL_USERS', (int) $total_users), 'L_SEARCH_EXPLAIN' => $this->user->lang('SEARCH_EXPLAIN', $dst, $lon, $lat))); return $this->helper->render('usermap_search.html', $this->user->lang('USERMAP_SEARCH')); }
/** * Display reputation toplist * * @return null * @access public */ public function reputation_toplist() { if ($this->config['rs_enable'] && $this->config['rs_enable_toplist'] && $this->config['rs_toplist_num']) { $this->user->add_lang_ext('pico/reputation', 'reputation_toplist'); $sql = 'SELECT user_id, username, user_colour, user_reputation FROM ' . USERS_TABLE . ' WHERE user_reputation > 0 ORDER BY user_reputation DESC'; $result = $this->db->sql_query_limit($sql, $this->config['rs_toplist_num']); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('toplist', array('USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER_REPUTATION' => $row['user_reputation'], 'U_VIEW_USER_REPUTATION' => $this->helper->route('reputation_details_controller', array('uid' => $row['user_id'])), 'S_DIRECTION' => $this->config['rs_toplist_direction'] ? true : false)); } $this->db->sql_freeresult($result); $this->template->assign_vars(array('S_RS_TOPLIST' => true, 'S_VIEW_REPUTATION' => $this->auth->acl_get('u_rs_view') ? true : false)); } }
public function display_tpotm($event) { $now = time(); $date_today = gmdate("Y-m-d", $now); list($year_cur, $month_cur, $day1) = split('-', $date_today); /* Start time for current month */ $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur); $month_start = $month_start_cur; $month_end = $now; /* * group_id 5 = administrators * group_id 4 = global moderators * per default into a Vanilla 3.1.x board */ $group_ids = array(5, 4); /* * config time for cache, still to be fully implemented thus hardcoded * 900 = 15 minutes */ $config_time_cache = 900; /* Check cached data */ if (($row = $this->cache->get('_tpotm')) === false) { $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, p.poster_id, p.post_time, COUNT(p.post_id) AS total_posts FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p WHERE u.user_id > ' . ANONYMOUS . ' AND u.user_id = p.poster_id AND (u.user_type <> ' . USER_FOUNDER . ') AND ' . $this->db->sql_in_set('u.group_id', $group_ids, true) . ' AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . ' GROUP BY u.user_id ORDER BY total_posts DESC'; $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); /* caching this data improves performance */ $this->cache->put('_tpotm', $row, (int) $config_time_cache); } /* Let's show the Top Poster then */ $tpotm_tot_posts = (int) $row['total_posts']; $tpotm_un_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); /* Fresh installs or new Month starts give zero posts */ $tpotm_un_nobody = $this->user->lang['TPOTM_NOBODY']; $tpotm_post = $this->user->lang('TPOTM_POST', (int) $tpotm_tot_posts); $tpotm_name = $tpotm_tot_posts < 1 ? $tpotm_un_nobody : $tpotm_un_string; /* you know.. template stuffs */ $this->template->assign_vars(array('TPOTM_NAME' => $tpotm_name, 'L_TPOTM_CAT' => $this->user->lang['TPOTM_CAT'], 'L_TPOTM_NOW' => $this->user->lang['TPOTM_NOW'], 'L_TPOTM_POST' => $tpotm_post)); }
/** * Get top_flags * displayed on the index page */ public function top_flags() { // grab all the flags $sql_array = array('SELECT' => 'user_flag, COUNT(user_flag) AS fnum', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => $this->db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' AND user_flag > 0', 'GROUP_BY' => 'user_flag', 'ORDER_BY' => 'fnum DESC'); // we limit the number of flags to display to the number set in the ACP settings $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_array), $this->config['flags_num_display']); $count = 0; $flags = $this->cache->get('_user_flags'); while ($row = $this->db->sql_fetchrow($result)) { ++$count; $this->template->assign_block_vars('flag', array('FLAG' => $this->get_user_flag($row['user_flag']), 'FLAG_USERS' => $this->user->lang('FLAG_USERS', (int) $row['fnum']), 'U_FLAG' => $this->helper->route('rmcgirr83_nationalflags_getflags', array('flag_id' => $flags[$row['user_flag']]['flag_id'])))); } $this->db->sql_freeresult($result); if ($count) { $this->template->assign_vars(array('U_FLAGS' => $this->helper->route('rmcgirr83_nationalflags_display'), 'S_FLAGS' => true)); } }
/** * Display flag * * @param $flag_id int the id of the flag * @param $start int page number we start at * @param $limit int limit to display for pagination * @return null * @access public */ protected function display_flag($flag_id, $start, $limit) { //let's get the flag requested $sql = 'SELECT flag_id, flag_name, flag_image FROM ' . $this->flags_table . ' WHERE flag_id = ' . (int) $flag_id; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // now users that have the flag $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_flag = ' . (int) $row['flag_id'] . ' AND ' . $this->db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' ORDER BY username_clean'; $result = $this->db->sql_query_limit($sql, $limit, $start); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); // for counting of total flag users $result = $this->db->sql_query($sql); $row2 = $this->db->sql_fetchrowset($result); $total_users = (int) count($row2); $this->db->sql_freeresult($result); unset($row2); foreach ($rows as $userrow) { $user_id = $userrow['user_id']; $username = $this->auth->acl_get('u_viewprofile') ? get_username_string('full', $user_id, $userrow['username'], $userrow['user_colour']) : get_username_string('no_profile', $user_id, $userrow['username'], $userrow['user_colour']); $this->template->assign_block_vars('user_row', array('JOINED' => $this->user->format_date($userrow['user_regdate']), 'VISITED' => empty($userrow['user_lastvisit']) ? ' - ' : $this->user->format_date($userrow['user_lastvisit']), 'POSTS' => $userrow['user_posts'] ? $userrow['user_posts'] : 0, 'USERNAME_FULL' => $username, 'U_SEARCH_USER' => $this->auth->acl_get('u_search') ? append_sid("{$this->root_path}search.{$this->php_ext}", "author_id={$user_id}&sr=posts") : '')); } $this->pagination->generate_template_pagination(array('routes' => array('rmcgirr83_nationalflags_getflags', 'rmcgirr83_nationalflags_getflags_page'), 'params' => array('flag_id' => $flag_id)), 'pagination', 'page', $total_users, $limit, $start); $flag_image = $this->functions->get_user_flag($row['flag_id']); $users_count = $total_users; $total_users = $this->user->lang('FLAG_USERS', (int) $total_users); $this->template->assign_vars(array('FLAG' => html_entity_decode($row['flag_name']), 'FLAG_IMAGE' => $flag_image, 'TOTAL_USERS' => $total_users, 'S_VIEWONLINE' => $this->auth->acl_get('u_viewonline'), 'S_FLAGS' => true, 'S_FLAG_USERS' => !empty($users_count) ? true : false, 'MESSAGE_TEXT' => empty($users_count) ? $this->user->lang['NO_USER_HAS_FLAG'] : '')); // Assign breadcrumb template vars for the flags page $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('rmcgirr83_nationalflags_display'), 'FORUM_NAME' => $this->user->lang('NATIONAL_FLAGS'))); // Assign breadcrumb template vars for the flags page $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('rmcgirr83_nationalflags_getflags', array('flag_id' => $flag_id)), 'FORUM_NAME' => $row['flag_name'])); }
/** * Display the search page * * @param type $start * @return type */ public function search($start = 1) { if (!$this->auth->acl_get('u_usermap_search')) { trigger_error('NOT_AUTHORISED'); } $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang('USERMAP_TITLE'), 'U_VIEW_FORUM' => $this->helper->route('tas2580_usermap_index', array()))); $data = array('lon' => substr($this->request->variable('lon', ''), 0, 10), 'lat' => substr($this->request->variable('lat', ''), 0, 10), 'dst' => (int) $this->request->variable('dst', $this->config['tas2580_usermap_search_distance'])); $validate_array = array('lon' => array('match', false, self::REGEX_LON), 'lat' => array('match', false, self::REGEX_LAT)); if (!function_exists('validate_data')) { include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } $error = validate_data($data, $validate_array); if (sizeof($error)) { $error = array_map(array($this->user, 'lang'), $error); trigger_error(implode('<br>', $error) . '<br><br><a href="' . $this->helper->route('tas2580_usermap_index', array()) . '">' . $this->user->lang('BACK_TO_USERMAP') . '</a>'); } $alpha = 180 * $data['dst'] / (6378137 / 1000 * 3.14159); $min_lon = (double) ($data['lon'] - $alpha); $max_lon = (double) ($data['lon'] + $alpha); $min_lat = (double) ($data['lat'] - $alpha); $max_lat = (double) ($data['lat'] + $alpha); $where = " WHERE ( user_usermap_lon >= {$min_lon} AND user_usermap_lon <= {$max_lon}) AND ( user_usermap_lat >= {$min_lat} AND user_usermap_lat<= {$max_lat})"; $limit = (int) $this->config['topics_per_page']; $sql = 'SELECT COUNT(user_id) AS num_users FROM ' . USERS_TABLE . $where; $result = $this->db->sql_query($sql); $total_users = (int) $this->db->sql_fetchfield('num_users'); $this->db->sql_freeresult($result); $sql = 'SELECT user_id, username, user_colour, user_regdate, user_posts, group_id, user_usermap_lon, user_usermap_lat FROM ' . USERS_TABLE . $where; $result = $this->db->sql_query_limit($sql, $limit, ($start - 1) * $limit); while ($row = $this->db->sql_fetchrow($result)) { $distance = $this->get_distance($data['lon'], $data['lat'], $row['user_usermap_lon'], $row['user_usermap_lat']); $this->template->assign_block_vars('memberrow', array('USER_ID' => $row['user_id'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'JOINED' => $this->user->format_date($row['user_regdate']), 'POSTS' => $row['user_posts'], 'GROUP_ID' => $row['group_id'], 'DISTANCE' => $distance)); } $this->pagination->generate_template_pagination(array('routes' => array('tas2580_usermap_search', 'tas2580_usermap_search_page'), 'params' => array()), 'pagination', 'start', $total_users, $limit, ($start - 1) * $limit); $this->template->assign_vars(array('TOTAL_USERS' => $this->user->lang('TOTAL_USERS', (int) $total_users), 'L_SEARCH_EXPLAIN' => $this->user->lang('SEARCH_EXPLAIN', $data['dst'], $data['lon'], $data['lat']))); return $this->helper->render('usermap_search.html', $this->user->lang('USERMAP_SEARCH')); }
/** * {@inheritDoc} */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') { $this->entry_count = 0; $this->last_page_offset = $offset; $topic_id_list = $reportee_id_list = array(); $profile_url = $this->get_is_admin() && $this->phpbb_admin_path ? append_sid("{$this->phpbb_admin_path}index.{$this->php_ext}", 'i=users&mode=overview') : append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile'); switch ($mode) { case 'admin': $log_type = LOG_ADMIN; $sql_additional = ''; break; case 'mod': $log_type = LOG_MOD; $sql_additional = ''; if ($topic_id) { $sql_additional = 'AND l.topic_id = ' . (int) $topic_id; } else { if (is_array($forum_id)) { $sql_additional = 'AND ' . $this->db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); } else { if ($forum_id) { $sql_additional = 'AND l.forum_id = ' . (int) $forum_id; } } } break; case 'user': $log_type = LOG_USERS; $sql_additional = 'AND l.reportee_id = ' . (int) $user_id; break; case 'users': $log_type = LOG_USERS; $sql_additional = ''; break; case 'critical': $log_type = LOG_CRITICAL; $sql_additional = ''; break; default: $log_type = false; $sql_additional = ''; } /** * Overwrite log type and limitations before we count and get the logs * * NOTE: if log_type is false, no entries will be returned. * * @event core.get_logs_modify_type * @var string mode Mode of the entries we display * @var bool count_logs Do we count all matching entries? * @var int limit Limit the number of entries * @var int offset Offset when fetching the entries * @var mixed forum_id Limit entries to the forum_id, * can also be an array of forum_ids * @var int topic_id Limit entries to the topic_id * @var int user_id Limit entries to the user_id * @var int log_time Limit maximum age of log entries * @var string sort_by SQL order option * @var string keywords Will only return entries that have the * keywords in log_operation or log_data * @var string profile_url URL to the users profile * @var int log_type Limit logs to a certain type. If log_type * is false, no entries will be returned. * @var string sql_additional Additional conditions for the entries, * e.g.: 'AND l.forum_id = 1' * @since 3.1.0-a1 */ $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); extract($this->dispatcher->trigger_event('core.get_logs_modify_type', compact($vars))); if ($log_type === false) { $this->last_page_offset = 0; return array(); } $sql_keywords = ''; if (!empty($keywords)) { // Get the SQL condition for our keywords $sql_keywords = $this->generate_sql_keyword($keywords); } $get_logs_sql_ary = array('SELECT' => 'l.*, u.username, u.username_clean, u.user_colour', 'FROM' => array($this->log_table => 'l', USERS_TABLE => 'u'), 'WHERE' => 'l.log_type = ' . (int) $log_type . "\n\t\t\t\t\tAND l.user_id = u.user_id\n\t\t\t\t\t{$sql_keywords}\n\t\t\t\t\t{$sql_additional}", 'ORDER_BY' => $sort_by); if ($log_time) { $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } /** * Modify the query to obtain the logs data * * @event core.get_logs_main_query_before * @var array get_logs_sql_ary The array in the format of the query builder with the query * to get the log count and the log list * @var string mode Mode of the entries we display * @var bool count_logs Do we count all matching entries? * @var int limit Limit the number of entries * @var int offset Offset when fetching the entries * @var mixed forum_id Limit entries to the forum_id, * can also be an array of forum_ids * @var int topic_id Limit entries to the topic_id * @var int user_id Limit entries to the user_id * @var int log_time Limit maximum age of log entries * @var string sort_by SQL order option * @var string keywords Will only return entries that have the * keywords in log_operation or log_data * @var string profile_url URL to the users profile * @var int log_type Limit logs to a certain type. If log_type * is false, no entries will be returned. * @var string sql_additional Additional conditions for the entries, * e.g.: 'AND l.forum_id = 1' * @since 3.1.5-RC1 */ $vars = array('get_logs_sql_ary', 'mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); extract($this->dispatcher->trigger_event('core.get_logs_main_query_before', compact($vars))); if ($count_logs) { $count_logs_sql_ary = $get_logs_sql_ary; $count_logs_sql_ary['SELECT'] = 'COUNT(l.log_id) AS total_entries'; unset($count_logs_sql_ary['ORDER_BY']); $sql = $this->db->sql_build_query('SELECT', $count_logs_sql_ary); $result = $this->db->sql_query($sql); $this->entry_count = (int) $this->db->sql_fetchfield('total_entries'); $this->db->sql_freeresult($result); if ($this->entry_count == 0) { // Save the queries, because there are no logs to display $this->last_page_offset = 0; return array(); } // Return the user to the last page that is valid while ($this->last_page_offset >= $this->entry_count) { $this->last_page_offset = max(0, $this->last_page_offset - $limit); } } $sql = $this->db->sql_build_query('SELECT', $get_logs_sql_ary); $result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset); $i = 0; $log = array(); while ($row = $this->db->sql_fetchrow($result)) { $row['forum_id'] = (int) $row['forum_id']; if ($row['topic_id']) { $topic_id_list[] = (int) $row['topic_id']; } if ($row['reportee_id']) { $reportee_id_list[] = (int) $row['reportee_id']; } $log_entry_data = array('id' => (int) $row['log_id'], 'reportee_id' => (int) $row['reportee_id'], 'reportee_username' => '', 'reportee_username_full' => '', 'user_id' => (int) $row['user_id'], 'username' => $row['username'], 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, $profile_url), 'ip' => $row['log_ip'], 'time' => (int) $row['log_time'], 'forum_id' => (int) $row['forum_id'], 'topic_id' => (int) $row['topic_id'], 'viewforum' => $row['forum_id'] && $this->auth->acl_get('f_read', $row['forum_id']) ? append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']) : false, 'action' => isset($this->user->lang[$row['log_operation']]) ? $row['log_operation'] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'); /** * Modify the entry's data before it is returned * * @event core.get_logs_modify_entry_data * @var array row Entry data from the database * @var array log_entry_data Entry's data which is returned * @since 3.1.0-a1 */ $vars = array('row', 'log_entry_data'); extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', compact($vars))); $log[$i] = $log_entry_data; if (!empty($row['log_data'])) { $log_data_ary = unserialize($row['log_data']); $log_data_ary = $log_data_ary !== false ? $log_data_ary : array(); if (isset($this->user->lang[$row['log_operation']])) { // Check if there are more occurrences of % than // arguments, if there are we fill out the arguments // array. It doesn't matter if we add more arguments than // placeholders. $num_args = 0; if (!is_array($this->user->lang[$row['log_operation']])) { $num_args = substr_count($this->user->lang[$row['log_operation']], '%'); } else { foreach ($this->user->lang[$row['log_operation']] as $case => $plural_string) { $num_args = max($num_args, substr_count($plural_string, '%')); } } if ($num_args - sizeof($log_data_ary) > 0) { $log_data_ary = array_merge($log_data_ary, array_fill(0, $num_args - sizeof($log_data_ary), '')); } $lang_arguments = array_merge(array($log[$i]['action']), $log_data_ary); $log[$i]['action'] = call_user_func_array(array($this->user, 'lang'), $lang_arguments); // If within the admin panel we do not censor text out if ($this->get_is_admin()) { $log[$i]['action'] = bbcode_nl2br($log[$i]['action']); } else { $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); } } else { if (!empty($log_data_ary)) { $log[$i]['action'] .= '<br />' . implode('', $log_data_ary); } } /* Apply make_clickable... has to be seen if it is for good. :/ // Seems to be not for the moment, reconsider later... $log[$i]['action'] = make_clickable($log[$i]['action']); */ } else { $log[$i]['action'] = $this->user->lang($log[$i]['action']); } $i++; } $this->db->sql_freeresult($result); /** * Get some additional data after we got all log entries * * @event core.get_logs_get_additional_data * @var array log Array with all our log entries * @var array topic_id_list Array of topic ids, for which we * get the permission data * @var array reportee_id_list Array of additional user IDs we * get the username strings for * @since 3.1.0-a1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list'); extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', compact($vars))); if (sizeof($topic_id_list)) { $topic_auth = $this->get_topic_auth($topic_id_list); foreach ($log as $key => $row) { $log[$key]['viewtopic'] = isset($topic_auth['f_read'][$row['topic_id']]) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id']) : false; $log[$key]['viewlogs'] = isset($topic_auth['m_'][$row['topic_id']]) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $this->user->session_id) : false; } } if (sizeof($reportee_id_list)) { $reportee_data_list = $this->get_reportee_data($reportee_id_list); foreach ($log as $key => $row) { if (!isset($reportee_data_list[$row['reportee_id']])) { continue; } $log[$key]['reportee_username'] = $reportee_data_list[$row['reportee_id']]['username']; $log[$key]['reportee_username_full'] = get_username_string('full', $row['reportee_id'], $reportee_data_list[$row['reportee_id']]['username'], $reportee_data_list[$row['reportee_id']]['user_colour'], false, $profile_url); } } /** * Allow modifying or execute extra final filter on log entries * * @event core.get_logs_after * @var array log Array with all our log entries * @var array topic_id_list Array of topic ids, for which we * get the permission data * @var array reportee_id_list Array of additional user IDs we * get the username strings for * @var string mode Mode of the entries we display * @var bool count_logs Do we count all matching entries? * @var int limit Limit the number of entries * @var int offset Offset when fetching the entries * @var mixed forum_id Limit entries to the forum_id, * can also be an array of forum_ids * @var int topic_id Limit entries to the topic_id * @var int user_id Limit entries to the user_id * @var int log_time Limit maximum age of log entries * @var string sort_by SQL order option * @var string keywords Will only return entries that have the * keywords in log_operation or log_data * @var string profile_url URL to the users profile * @var int log_type The type of logs it was filtered * @since 3.1.3-RC1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list', 'mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type'); extract($this->dispatcher->trigger_event('core.get_logs_after', compact($vars))); return $log; }
/** * Main reputation details controller * * @param int $uid User ID taken from the URL * @param string $sort_key Sort key: id|username|time|point|action (default: id) * @param string $sort_dir Sort direction: dsc|asc (descending|ascending) (default: dsc) * @param int $page Page number taken from the URL * @return Symfony\Component\HttpFoundation\Response A Symfony Response object * @access public */ public function details($uid, $sort_key, $sort_dir, $page) { $this->user->add_lang_ext('pico/reputation', array('reputation_system', 'reputation_rating')); // Check user permissions - if user can not view reputation details, throw the error if (!$this->auth->acl_get('u_rs_view')) { $meta_info = append_sid("{$this->root_path}index.{$this->php_ext}", ""); $message = $user->lang['RS_VIEW_DISALLOWED'] . '<br /><br />' . $this->user->lang('RETURN_INDEX', '<a href="' . append_sid("{$this->root_path}index.{$this->php_ext}", "") . '">', '</a>'); meta_refresh(3, $meta_info); trigger_error($message); } // User data $sql = 'SELECT * FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_type <> 2\n\t\t\t\tAND user_id = {$uid}"; $result = $this->db->sql_query($sql); $user_row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // Check if an user exists - if not, throw the error and return to the index page if (empty($user_row)) { $meta_info = append_sid("{$this->root_path}index.{$this->php_ext}", ""); $message = $this->user->lang['RS_NO_USER_ID'] . '<br /><br />' . $this->user->lang('RETURN_INDEX', '<a href="' . append_sid("{$this->root_path}index.{$this->php_ext}", "") . '">', '</a>'); meta_refresh(3, $meta_info); trigger_error($message); } // Count reputation rows for the current user $sql = 'SELECT COUNT(reputation_id) AS total_reps FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$uid}"; $result = $this->db->sql_query($sql); $total_reps = (int) $this->db->sql_fetchfield('total_reps'); $this->db->sql_freeresult($result); // Sort keys $sort_key_sql = array('username' => 'u.username_clean', 'time' => 'r.reputation_time', 'point' => 'r.reputation_points', 'action' => 'rt.reputation_type_name', 'id' => 'r.reputation_id'); // Sql order depends on sort key $order_by = $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'dsc' ? 'DESC' : 'ASC'); // Start value - it is based on page $start = ($page - 1) * $this->config['rs_per_page']; $post_type_id = (int) $this->reputation_manager->get_reputation_type_id('post'); $sql_array = array('SELECT' => 'r.*, rt.reputation_type_name, u.group_id, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, p.post_id, p.forum_id, p.post_subject', 'FROM' => array($this->reputations_table => 'r', $this->reputation_types_table => 'rt'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'r.user_id_from = u.user_id '), array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => 'p.post_id = r.reputation_item_id AND r.reputation_type_id = ' . $post_type_id)), 'WHERE' => 'r.user_id_to = ' . $uid . ' AND r.reputation_type_id = rt.reputation_type_id', 'ORDER_BY' => $order_by); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $this->config['rs_per_page'], $start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('reputation', array('ID' => $row['reputation_id'], 'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']), 'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'), 'AVATAR' => phpbb_get_user_avatar($row), 'TIME' => $this->user->format_date($row['reputation_time']), 'COMMENT' => $row['reputation_comment'], 'POINTS' => $row['reputation_points'], 'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']), 'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']), 'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])), 'S_COMMENT' => !empty($row['reputation_comment']), 'S_DELETE' => $this->auth->acl_get('m_rs_moderate') || $row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete') ? true : false)); // Generate post url $this->reputation_manager->generate_post_link($row); } $this->db->sql_freeresult($result); // User reputation rank if (!function_exists('phpbb_get_user_rank')) { include $this->root_path . 'includes/functions_display.' . $this->php_ext; } $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']); // Reputation statistics $positive_count = $negative_count = 0; $positive_sum = $negative_sum = 0; $positive_week = $negative_week = 0; $positive_month = $negative_month = 0; $positive_6months = $negative_6months = 0; $post_count = $user_count = 0; $last_week = time() - 604800; $last_month = time() - 2678400; $last_6months = time() - 16070400; $user_type_id = (int) $this->reputation_manager->get_reputation_type_id('user'); $sql = 'SELECT reputation_time, reputation_type_id, reputation_points FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$uid}"; $result = $this->db->sql_query($sql); while ($reputation_vote = $this->db->sql_fetchrow($result)) { if ($reputation_vote['reputation_points'] > 0) { $positive_count++; $positive_sum += $reputation_vote['reputation_points']; if ($reputation_vote['reputation_time'] >= $last_week) { $positive_week++; } if ($reputation_vote['reputation_time'] >= $last_month) { $positive_month++; } if ($reputation_vote['reputation_time'] >= $last_6months) { $positive_6months++; } } else { if ($reputation_vote['reputation_points'] < 0) { $negative_count++; $negative_sum += $reputation_vote['reputation_points']; if ($reputation_vote['reputation_time'] >= $last_week) { $negative_week++; } if ($reputation_vote['reputation_time'] >= $last_month) { $negative_month++; } if ($reputation_vote['reputation_time'] >= $last_6months) { $negative_6months++; } } } if ($reputation_vote['reputation_type_id'] == $post_type_id) { $post_count += $reputation_vote['reputation_points']; } else { if ($reputation_vote['reputation_type_id'] == $user_type_id) { $user_count += $reputation_vote['reputation_points']; } } } $this->db->sql_freeresult($result); // User reputation power if ($this->config['rs_enable_power']) { $used_power = $this->reputation_power->used($user_row['user_id']); $user_max_voting_power = $this->reputation_power->get($user_row['user_posts'], $user_row['user_regdate'], $user_row['user_reputation'], $user_row['user_warnings'], $user_row['group_id']); $user_power_explain = $this->reputation_power->explain(); $voting_power_left = ''; if ($this->config['rs_power_renewal']) { $voting_power_left = $user_max_voting_power - $used_power; if ($voting_power_left < 0) { $voting_power_left = 0; } } $this->template->assign_vars(array('S_RS_POWER_EXPLAIN' => $this->config['rs_power_explain'] ? true : false, 'S_RS_GROUP_POWER' => isset($user_power_explain['GROUP_VOTING_POWER']) ? true : false, 'RS_POWER' => $user_max_voting_power, 'RS_POWER_LEFT' => $this->config['rs_power_renewal'] ? $this->user->lang('RS_VOTE_POWER_LEFT', $voting_power_left, $user_max_voting_power) : '', 'RS_CFG_TOTAL_POSTS' => $this->config['rs_total_posts'] ? true : false, 'RS_CFG_MEMBERSHIP_DAYS' => $this->config['rs_membership_days'] ? true : false, 'RS_CFG_REP_POINT' => $this->config['rs_power_rep_point'] ? true : false, 'RS_CFG_LOOSE_WARN' => $this->config['rs_power_lose_warn'] ? true : false)); $this->template->assign_vars($user_power_explain); } // Generate pagination $this->pagination->generate_template_pagination(array('routes' => 'reputation_details_controller', 'params' => array('uid' => $uid, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir)), 'pagination', 'page', $total_reps, $this->config['rs_per_page'], $start); $this->template->assign_vars(array('USER_ID' => $user_row['user_id'], 'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour'], true), 'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'REPUTATION' => $user_row['user_reputation'], 'AVATAR_IMG' => phpbb_get_user_avatar($user_row), 'RANK_IMG' => $user_rank_data['img'], 'RANK_IMG_SRC' => $user_rank_data['img_src'], 'RANK_TITLE' => $user_rank_data['title'], 'REPUTATION_CLASS' => $this->reputation_helper->reputation_class($user_row['user_reputation']), 'PAGE_NUMBER' => $this->pagination->on_page($total_reps, $this->config['rs_per_page'], $start), 'TOTAL_REPS' => $this->user->lang('LIST_REPUTATIONS', $total_reps), 'U_SORT_USERNAME' => $this->helper->route('reputation_details_controller', array('uid' => $uid, 'sort_key' => 'username', 'sort_dir' => $sort_key == 'username' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_TIME' => $this->helper->route('reputation_details_controller', array('uid' => $uid, 'sort_key' => 'time', 'sort_dir' => $sort_key == 'time' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_POINT' => $this->helper->route('reputation_details_controller', array('uid' => $uid, 'sort_key' => 'point', 'sort_dir' => $sort_key == 'point' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_ACTION' => $this->helper->route('reputation_details_controller', array('uid' => $uid, 'sort_key' => 'action', 'sort_dir' => $sort_key == 'action' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_CLEAR' => $this->helper->route('reputation_clear_user_controller', array('uid' => $uid)), 'POST_COUNT' => $post_count, 'USER_COUNT' => $user_count, 'POSITIVE_COUNT' => $positive_count, 'POSITIVE_SUM' => $positive_sum, 'POSITIVE_WEEK' => $positive_week, 'POSITIVE_MONTH' => $positive_month, 'POSITIVE_6MONTHS' => $positive_6months, 'NEGATIVE_COUNT' => $negative_count, 'NEGATIVE_SUM' => $negative_sum, 'NEGATIVE_WEEK' => $negative_week, 'NEGATIVE_MONTH' => $negative_month, 'NEGATIVE_6MONTHS' => $negative_6months, 'S_RS_POST_RATING' => $this->config['rs_post_rating'] ? true : false, 'S_RS_USER_RATING' => $this->config['rs_user_rating'] ? true : false, 'S_RS_AVATAR' => $this->config['rs_display_avatar'] ? true : false, 'S_RS_COMMENT' => $this->config['rs_enable_comment'] ? true : false, 'S_RS_NEGATIVE' => $this->config['rs_negative_point'] ? true : false, 'S_RS_POWER_ENABLE' => $this->config['rs_enable_power'] ? true : false, 'S_CLEAR' => $this->auth->acl_gets('m_rs_moderate') ? true : false)); return $this->helper->render('details.html', $this->user->lang('RS_DETAILS')); }