public function modify_posting($event) { if ($event['mode'] == 'post' && !$event['forum_id']) { $forum_ary = array(); $forum_read_ary = $this->auth->acl_getf('f_read'); foreach ($forum_read_ary as $forum_id => $allowed) { if ($allowed['f_read'] && $this->auth->acl_get('f_post', $forum_id)) { if (!$this->exclude_forum($forum_id, $this->config['newtopic_forum'])) { continue; } $forum_ary[] = (int) $forum_id; } } if (sizeof($forum_ary)) { // Fetching topics of public forums $sql = 'SELECT forum_id, forum_name, forum_type FROM ' . FORUMS_TABLE . "\n\t\t\t\t\tWHERE " . $this->db->sql_in_set('forum_id', $forum_ary) . "\n\t\t\t\t\t\tAND forum_type != " . FORUM_LINK; $result = $this->db->sql_query($sql); $forumrow = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); $s_forum_options = '<select id="f" name="f" onchange="this.form.submit();">'; foreach ($forumrow as $row) { $s_forum_options .= '<option value="' . $row['forum_id'] . '"' . ($row['forum_id'] == $forum_id ? ' selected="selected"' : '') . '' . ($row['forum_type'] == FORUM_CAT ? ' disabled="disabled" class="disabled-option"' : '') . '>' . ($row['forum_type'] != FORUM_CAT ? ' ' : '') . $row['forum_name'] . '</option>'; $forum_id = $row['forum_type'] == FORUM_POST ? $row['forum_id'] : ''; } $s_forum_options .= '</select>'; $this->template->assign_vars(array('S_FORUM_OPTIONS' => $s_forum_options, 'S_FORUM_OPT_TRUE' => $forum_id ? true : false)); $event['forum_id'] = $forum_id; } } }
public function viewtopic_modify_post_data($event) { $user_ids = array(); $rowset = $event['rowset']; $post_list = $event['post_list']; // Получаем список пользователей for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) { if (!isset($rowset[$post_list[$i]])) { continue; } $row = $rowset[$post_list[$i]]; $poster_id = $row['user_id']; // Исключаем гостей, скрытые/игнорируемые сообщения и повтор. if ($poster_id != ANONYMOUS && !$row['foe'] && !$row['hide_post'] && !in_array($poster_id, $user_ids)) { $user_ids[] = $poster_id; $this->medals_count[$poster_id] = 0; $this->nominated_medals[$poster_id] = false; } unset($rowset[$post_list[$i]]); } // Medals count and nominated if (sizeof($user_ids)) { $sql = "SELECT user_id, nominated\n\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\tWHERE " . $this->db->sql_in_set('user_id', $user_ids); $m_result = $this->db->sql_query($sql); $has_perms = $this->user->data['user_type'] == USER_FOUNDER || $this->auth->acl_get('u_award_medals'); while ($m_row = $this->db->sql_fetchrow($m_result)) { if ($has_perms && $m_row['nominated']) { $this->nominated_medals[$m_row['user_id']] = true; } else { if (!$m_row['nominated']) { $this->medals_count[$m_row['user_id']]++; } } } $this->db->sql_freeresult($m_result); } }
/** * Returns the users array */ private function view_state() { switch ($this->config['wwh_sort_by']) { case 0: case 1: $sql_order_by = 'username_clean'; break; case 4: case 5: $sql_order_by = 'user_id'; break; case 2: case 3: default: $sql_order_by = 'wwh_lastpage'; break; } $sql_ordering = $this->config['wwh_sort_by'] % 2 == 0 ? 'ASC' : 'DESC'; // Let's try another method, to deny duplicate appearance of usernames. $user_id_ary = array(); $sql = 'SELECT user_id, username, username_clean, user_colour, user_type, viewonline, wwh_lastpage, user_ip FROM ' . WWH_TABLE . "\n\t\t\tORDER BY {$sql_order_by} {$sql_ordering}"; $result = $this->db->sql_query($sql); $statrow = array(); while ($row = $this->db->sql_fetchrow($result)) { if (!in_array($row['user_id'], $user_id_ary)) { if ($row['viewonline'] || $row['user_type'] == USER_IGNORE) { if ($row['user_id'] != ANONYMOUS && ($this->config['wwh_disp_bots'] || $row['user_type'] != USER_IGNORE)) { $user_id_ary[] = $row['user_id']; } } else { if ($this->config['wwh_disp_hidden'] && $this->auth->acl_get('u_viewonline')) { $user_id_ary[] = $row['user_id']; } } $statrow[] = $row; } } $this->db->sql_freeresult($result); return $statrow; }
public function medal_row($user_id) { $s_nominate = false; if ($this->auth->acl_get('u_nominate_medals') && $user_id != $this->user->data['user_id']) { $s_nominate = true; } $is_mod = $this->user->data['user_type'] == USER_FOUNDER || $this->auth->acl_get('u_award_medals') ? true : false; $uid = $bitfield = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_smilies = true; $allow_urls = false; $m_flags = '3'; // 1 is bbcode, 2 is smiles, 4 is urls (add together to turn on more than one) // // Category // $sql = "SELECT id, name\n\t\t\tFROM " . $this->tb_medals_cats . "\n\t\t\tORDER BY order_id"; if (!($result = $this->db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query medal categories list', '', __LINE__, __FILE__, $sql); } $category_rows = array(); while ($row = $this->db->sql_fetchrow($result)) { $category_rows[] = $row; } $this->db->sql_freeresult($result); $sql = "SELECT m.medal_id, m.user_id\n\t\t\tFROM " . $this->tb_medals_awarded . " m\n\t\t\tWHERE m.user_id = {$user_id}\n\t\t\t\tAND m.nominated = 0"; if ($result = $this->db->sql_query($sql)) { $medal_list = $this->db->sql_fetchrowset($result); $medal_count = count($medal_list); if ($medal_count) { $this->template->assign_block_vars('switch_display_medal', array()); $this->template->assign_block_vars('switch_display_medal.medal', array('MEDAL_BUTTON' => '<input type="button" class="button2" onclick="hdr_toggle(\'toggle_medal\',\'medal_open_close\')" value="' . $this->user->lang['MEDALS_VIEW_BUTTON'] . '"/>')); } } $u_nominate = ''; if ($s_nominate) { $u_nominate = $this->helper->route('bb3mobi_medals_controller', array('m' => 'nominate', 'u' => $user_id)); } $u_can_award = ''; if ($this->auth->acl_get('a_user') || $is_mod) { $u_can_award = $this->helper->route('bb3mobi_medals_controller', array('m' => 'award', 'u' => $user_id)); } $this->template->assign_vars(array('USER_ID' => $user_id, 'U_NOMINATE' => $u_nominate, 'U_CAN_AWARD_MEDALS' => $u_can_award, 'L_USER_MEDAL' => $this->user->lang['MEDALS'], 'USER_MEDAL_COUNT' => $medal_count, 'L_MEDAL_INFORMATION' => $this->user->lang['MEDAL_INFORMATION'], 'L_MEDAL_NAME' => $this->user->lang['MEDAL'], 'L_MEDAL_DETAIL' => $this->user->lang['MEDAL_DETAIL'])); for ($i = 0; $i < count($category_rows); $i++) { $cat_id = $category_rows[$i]['id']; $sql = "SELECT m.id, m.name, m.description, m.image, m.device, m.dynamic, m.parent,\n\t\t\t\t\t\tma.nominated_reason, ma.time, ma.awarder_id, ma.awarder_un, ma.awarder_color, ma.bbuid, ma.bitfield,\n\t\t\t\t\t\tc.id as cat_id, c.name as cat_name\n\t\t\t\t\tFROM " . $this->tb_medal . " m, " . $this->tb_medals_awarded . " ma, " . $this->tb_medals_cats . " c\n\t\t\t\t\tWHERE ma.user_id = {$user_id}\n\t\t\t\t\t\tAND m.parent = c.id\n\t\t\t\t\t\tAND m.id = ma.medal_id\n\t\t\t\t\t\tAND ma.nominated = 0\n\t\t\t\t\tORDER BY c.order_id, m.order_id, ma.time"; if ($result = $this->db->sql_query($sql)) { $row = array(); $rowset = array(); $medal_time = $this->user->lang['AWARD_TIME'] . ': '; $medal_reason = $this->user->lang['MEDAL_AWARD_REASON'] . ': '; while ($row = $this->db->sql_fetchrow($result)) { if (empty($rowset[$row['name']])) { $rowset[$row['name']]['cat_id'] = $row['cat_id']; $rowset[$row['name']]['cat_name'] = $row['cat_name']; if (isset($rowset[$row['name']]['description'])) { $rowset[$row['name']]['description'] .= $row['description']; } else { $rowset[$row['name']]['description'] = $row['description']; } $rowset[$row['name']]['image'] = $this->phpbb_root_path . 'images/medals/' . $row['image']; $rowset[$row['name']]['device'] = $this->phpbb_root_path . 'images/medals/devices/' . $row['device']; $rowset[$row['name']]['dynamic'] = $row['dynamic']; } $row['nominated_reason'] = $row['nominated_reason'] ? $row['nominated_reason'] : $lang['Medal_no_reason']; $awarder_name = ""; if ($row['awarder_id']) { $awarder_name = "<br />" . $this->user->lang['AWARDED_BY'] . ": " . get_username_string('full', $row['awarder_id'], $row['awarder_un'], $row['awarder_color'], $row['awarder_un']); } //generate_text_for_storage($row['nominated_reason'], $uid, $bitfield, $m_flags, $allow_bbcode, $allow_urls, $allow_smilies); $reason = generate_text_for_display($row['nominated_reason'], $row['bbuid'], $row['bitfield'], $m_flags); if (isset($rowset[$row['name']]['medal_issue'])) { $rowset[$row['name']]['medal_issue'] .= $medal_time . $this->user->format_date($row['time']) . $awarder_name . '</td></tr><tr><td>' . $medal_reason . '<div class="content">' . $reason . '</div><hr />'; } else { $rowset[$row['name']]['medal_issue'] = $medal_time . $this->user->format_date($row['time']) . $awarder_name . '</td></tr><tr><td>' . $medal_reason . '<div class="content">' . $reason . '</div><hr />'; } if (isset($rowset[$row['name']]['medal_count'])) { $rowset[$row['name']]['medal_count'] += '1'; } else { $rowset[$row['name']]['medal_count'] = '1'; } } $medal_width = $this->config['medal_small_img_width'] ? ' width="' . $this->config['medal_small_img_width'] . '"' : ''; $medal_height = $this->config['medal_small_img_ht'] ? ' height="' . $this->config['medal_small_img_ht'] . '"' : ''; $medal_name = array(); $data = array(); // // Should we display this category/medal set? // $display_medal = 0; $numberofmedals = 0; $after_first_cat = 0; $newcat = 1; while (list($medal_name, $data) = @each($rowset)) { if ($cat_id == $data['cat_id']) { $display_medal = 1; } $display_across = $this->config['medal_profile_across'] ? $this->config['medal_profile_across'] : 5; if ($numberofmedals == $display_across) { $break = '<br />'; $numberofmedals = 0; } else { $break = ''; } if (!empty($newcat) && !empty($after_first_cat)) { $break = '<hr /> '; $numberofmedals = 0; } $numberofmedals++; if (!empty($display_medal)) { if ($data['medal_count'] > 1) { if ($data['dynamic']) { $img_medals = $this->helper->route('bb3mobi_medals_controller', array('m' => 'mi', 'med' => $data['image'], 'd' => $data['device'] . '-' . ($data['medal_count'] - 1) . '.gif')); $image = '<img src="' . $img_medals . '" alt="' . $medal_name . '" title="' . $medal_name . '" />'; $small_image = $break . '<img src="' . $img_medals . '" alt="' . $medal_name . '" title="' . $medal_name . '"' . $medal_width . $medal_height . ' />'; } else { $cluster = '-' . $data['medal_count']; $device_image = substr_replace($data['image'], $cluster, -4) . substr($data['image'], -4); if (file_exists($device_image)) { $data['image'] = $device_image; } $image = '<img src="' . $data['image'] . '" alt="' . $medal_name . '" title="' . $medal_name . '" />'; $small_image = $break . '<img src="' . $data['image'] . '" alt="' . $medal_name . '" title="' . $medal_name . '"' . $medal_width . $medal_height . ' />'; } } else { $image = '<img src="' . $data['image'] . '" alt="' . $medal_name . '" title="' . $medal_name . '" />'; $small_image = $break . '<img src="' . $data['image'] . '" alt="' . $medal_name . '" title="' . $medal_name . '"' . $medal_width . $medal_height . ' />'; } $this->template->assign_block_vars('switch_display_medal.details', array('ISMEDAL_CAT' => $newcat, 'MEDAL_CAT' => $data['cat_name'], 'MEDAL_NAME' => $medal_name, 'MEDAL_DESCRIPTION' => $data['description'], 'MEDAL_IMAGE' => $image, 'MEDAL_IMAGE_SMALL' => $small_image, 'MEDAL_ISSUE' => $data['medal_issue'], 'MEDAL_COUNT' => $this->user->lang['MEDAL_AMOUNT'] . ': ' . $data['medal_count'])); $display_medal = 0; $newcat = 0; } else { // New category lets put an hr between $newcat = 1; $after_first_cat = 1; } } } } }
/** * Fetching the user-list and putting the stuff into the template. */ public function display() { $this->user->add_lang_ext('bb3mobi/washere', 'lang_wwh'); if (!self::prune()) { // Error while purging the list, database is missing :-O $this->user->add_lang_ext('bb3mobi/washere', 'info_acp_wwh'); return; } self::$count_guests = self::$count_bot = self::$count_reg = self::$count_hidden = self::$count_total = 0; $wwh_username_colour = $wwh_username = $wwh_username_full = $users_list = ''; switch ($this->config['wwh_sort_by']) { case self::SORT_USERNAME_ASC: case self::SORT_USERNAME_DESC: $sql_order_by = 'username_clean'; break; case self::SORT_USERID_ASC: case self::SORT_USERID_DESC: $sql_order_by = 'user_id'; break; case self::SORT_LASTPAGE_ASC: case self::SORT_LASTPAGE_DESC: default: $sql_order_by = 'wwh_lastpage'; break; } $sql_ordering = $this->config['wwh_sort_by'] % 2 == self::SORT_ASC ? 'ASC' : 'DESC'; // Let's try another method, to deny duplicate appearance of usernames. $user_id_ary = array(); $sql = 'SELECT user_id, username, username_clean, user_colour, user_type, viewonline, wwh_lastpage, user_ip FROM ' . WWH_TABLE . "\n\t\t\tORDER BY {$sql_order_by} {$sql_ordering}"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { if (!in_array($row['user_id'], $user_id_ary)) { $wwh_username_full = get_username_string($row['user_type'] == USER_IGNORE ? 'no_profile' : 'full', $row['user_id'], $row['username'], $row['user_colour']); $hover_time = $this->config['wwh_disp_time'] == '2' ? $this->user->lang['WHO_WAS_HERE_LATEST1'] . ' ' . $this->user->format_date($row['wwh_lastpage'], $this->config['wwh_disp_time_format']) . $this->user->lang['WHO_WAS_HERE_LATEST2'] : ''; $hover_ip = $this->auth->acl_get('a_') && $this->config['wwh_disp_ip'] ? $this->user->lang['IP'] . ': ' . $row['user_ip'] : ''; $hover_info = $hover_time || $hover_ip ? ' title="' . $hover_time . ($hover_time && $hover_ip ? ' | ' : '') . $hover_ip . '"' : ''; $disp_time = $this->config['wwh_disp_time'] == '1' ? ' (' . $this->user->lang['WHO_WAS_HERE_LATEST1'] . ' ' . $this->user->format_date($row['wwh_lastpage'], $this->config['wwh_disp_time_format']) . $this->user->lang['WHO_WAS_HERE_LATEST2'] . ($hover_ip ? ' | ' . $hover_ip : '') . ')' : ''; if ($row['viewonline'] || $row['user_type'] == USER_IGNORE) { if ($row['user_id'] != ANONYMOUS && ($this->config['wwh_disp_bots'] || $row['user_type'] != USER_IGNORE)) { $users_list .= $this->user->lang['COMMA_SEPARATOR'] . '<span' . $hover_info . '>' . $wwh_username_full . '</span>' . $disp_time; $user_id_ary[] = $row['user_id']; } } else { if ($this->config['wwh_disp_hidden'] && $this->auth->acl_get('u_viewonline')) { $users_list .= $this->user->lang['COMMA_SEPARATOR'] . '<em' . $hover_info . '>' . $wwh_username_full . '</em>' . $disp_time; $user_id_ary[] = $row['user_id']; } } // At the end let's count them =) if ($row['user_id'] == ANONYMOUS) { self::$count_guests++; } else { if ($row['user_type'] == USER_IGNORE) { self::$count_bot++; self::$ids_bot[] = (int) $row['user_id']; } else { if ($row['viewonline'] == 1) { self::$count_reg++; self::$ids_reg[] = (int) $row['user_id']; } else { self::$count_hidden++; self::$ids_hidden[] = (int) $row['user_id']; } } } self::$count_total++; } } $users_list = utf8_substr($users_list, utf8_strlen($this->user->lang['COMMA_SEPARATOR'])); if ($users_list == '') { // User list is empty. $users_list = $this->user->lang['NO_ONLINE_USERS']; } if (!$this->config['wwh_disp_bots']) { self::$count_total -= self::$count_bot; } if (!$this->config['wwh_disp_guests']) { self::$count_total -= self::$count_guests; } if (!$this->config['wwh_disp_hidden']) { self::$count_total -= self::$count_hidden; } // Need to update the record? if ($this->config['wwh_record_ips'] < self::$count_total) { $this->config->set('wwh_record_ips', self::$count_total, true); $this->config->set('wwh_record_time', time(), true); } // Disabled, see comment on the method itself. //self::log(); $this->template->assign_vars(array('WHO_WAS_HERE_LIST' => $this->user->lang['USERS'] . ': ' . $users_list, 'WHO_WAS_HERE_TOTAL' => self::get_total_users_string($this->config['wwh_disp_hidden'], $this->config['wwh_disp_bots'], $this->config['wwh_disp_guests']), 'WHO_WAS_HERE_EXP' => self::get_explanation_string($this->config['wwh_version']), 'WHO_WAS_HERE_RECORD' => self::get_record_string($this->config['wwh_record'], $this->config['wwh_version']))); }