/** * Get avatar * * @param int $user_id User ID of the user you want to retrieve the avatar for * @param bool $query Should we query the database if this user has not yet been loaded? * Typically this should be left as false and you should make sure * you load users ahead of time with load_users() * @param bool @lazy If true, will be lazy loaded (requires JS) * @return string */ public function get_avatar($user_id, $query = false, $lazy = false) { if (!($user = $this->get_user($user_id, $query))) { return ''; } $row = array('avatar' => $user['user_avatar'], 'avatar_type' => $user['user_avatar_type'], 'avatar_width' => $user['user_avatar_width'], 'avatar_height' => $user['user_avatar_height']); return phpbb_get_avatar($row, 'USER_AVATAR', false, $lazy); }
/** * Get group avatar * * @param array $group_row Row from the groups table * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * @param bool $lazy If true, will be lazy loaded (requires JS) * * @return string Avatar html */ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false) { $row = \phpbb\avatar\manager::clean_row($user_row, 'group'); return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); }
/** * Get user avatar * * @deprecated 3.1.0-a1 (To be removed: 3.3.0) * * @param string $avatar Users assigned avatar name * @param int $avatar_type Type of avatar * @param string $avatar_width Width of users avatar * @param string $avatar_height Height of users avatar * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * * @return string Avatar image */ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) { // map arguments to new function phpbb_get_avatar() $row = array('avatar' => $avatar, 'avatar_type' => $avatar_type, 'avatar_width' => $avatar_width, 'avatar_height' => $avatar_height); return phpbb_get_avatar($row, $alt, $ignore_config); }
public function process_block_modules() { global $phpbb_root_path, $config, $table_prefix, $helper; global $db, $user, $avatar_img, $request, $template, $auth; global $k_config, $k_groups, $k_blocks, $page_header; global $phpbb_path_helper; $this->php_ext = $phpbb_path_helper->get_php_ext(); $block_cache_time = $k_config['k_block_cache_time_default']; $blocks_width = $config['blocks_width']; $blocks_enabled = $config['blocks_enabled']; $use_block_cookies = isset($k_config['use_block_cookies']) ? $k_config['use_block_cookies'] : 0; if (!$blocks_enabled) { $template->assign_vars(array('PORTAL_MESSAGE' => $user->lang('BLOCKS_DISABLED'))); } $all = ''; $show_center = $show_left = $show_right = false; $LB = $CB = $RB = array(); $active_blocks = array(); // if styles use large block images change path to images // $block_image_path = $phpbb_root_path . 'ext/phpbbireland/portal/images/block_images/block/'; $big_image_path = $phpbb_root_path . 'ext/phpbbireland/portal/images/block_images/large/'; $this_page = explode(".", $user->page['page']); $user_id = $user->data['user_id']; // $logo = sgp_get_rand_logo(); // var_dump($logo); $theme = rawurlencode($user->style['style_path']); $template->assign_vars(array('EXT_TEMPLATE_PATH' => $phpbb_root_path . 'ext/phpbbireland/portal/styles/' . $theme, 'EXT_IMAGE_PATH' => $phpbb_root_path . 'ext/phpbbireland/portal/images/', 'MOD_IMAGE_LANG_PATH' => $phpbb_root_path . 'ext/phpbbireland/portal/styles/' . $theme . '/theme/' . $user->data['user_lang'] . '/')); include_once $phpbb_root_path . 'ext/phpbbireland/portal/includes/sgp_functions.' . $this->php_ext; // Grab data for this user // $sql = "SELECT group_id, user_type, user_style, user_avatar, user_avatar_type, username, user_left_blocks, user_center_blocks, user_right_blocks\n\t\t\tFROM " . USERS_TABLE . "\n\t\t\tWHERE user_id = {$user_id}"; if ($result = $db->sql_query($sql)) { $row = $db->sql_fetchrow($result); $user_avatar = $row['user_avatar']; $user_style = $row['user_style']; $usertype = $row['user_type']; $groupid = $row['group_id']; $left = $row['user_left_blocks']; $LB = explode(',', $left); $center = $row['user_center_blocks']; $CB = explode(',', $center); $right = $row['user_right_blocks']; $RB = explode(',', $right); $LCR = array_merge((array) $LB, (array) $CB, (array) $RB); $left .= ','; $center .= ','; $all .= $left .= $center .= $right; } else { trigger_error($user->lang['ERROR_USER_TABLE']); } // Process block positions for members only // if ($row['group_id'] != ANONYMOUS) { if (isset($_COOKIE[$config['cookie_name'] . '_sgp_left']) || isset($_COOKIE[$config['cookie_name'] . '_sgp_center']) || isset($_COOKIE[$config['cookie_name'] . '_sgp_right']) && $use_block_cookies) { $left = $request->variable($config['cookie_name'] . '_sgp_left', '', false, true); $left = str_replace("left[]=", "", $left); $left = str_replace("&", ',', $left); $LBA = explode(',', $left); $center = $request->variable($config['cookie_name'] . '_sgp_center', '', false, true); $center = str_replace("center[]=", "", $center); $center = str_replace("&", ',', $center); $CBA = explode(',', $center); $right = $request->variable($config['cookie_name'] . '_sgp_right', '', false, true); $right = str_replace("right[]=", "", $right); $right = str_replace("&", ',', $right); $RBA = explode(',', $right); // store cookie data (block positions in user table) if (!empty($left)) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_left_blocks = ' . "'" . $db->sql_escape($left) . "'" . ', user_center_blocks = ' . "'" . $db->sql_escape($center) . "'" . ', user_right_blocks = ' . "'" . $db->sql_escape($right) . "'" . ' WHERE user_id = ' . (int) $user->data['user_id']; $db->sql_query($sql); // set switch clear cookies now that we have them stored (we use javascript)// $template->assign_vars(array('S_CLEAR_CACHE' => true)); } } if (empty($row['user_left_blocks'])) { $sql = "SELECT *\n\t\t\t\t\tFROM " . K_BLOCKS_TABLE . "\n\t\t\t\t\tWHERE active = 1\n\t\t\t\t\t\tAND (view_pages <> '0')\n\t\t\t\t\t\tORDER BY ndx ASC"; } else { $sql = "SELECT *\n\t\t\t\t\tFROM " . K_BLOCKS_TABLE . "\n\t\t\t\t\tWHERE active = 1\n\t\t\t\t\t\tAND (view_pages <> '0')\n\t\t\t\t\t\tAND " . $db->sql_in_set('id', $LCR) . "\n\t\t\t\t\tORDER BY find_in_set(id,'" . $all . "')"; } } else { $sql = "SELECT *\n\t\t\t\tFROM " . K_BLOCKS_TABLE . "\n\t\t\t\tWHERE active = 1\n\t\t\t\t\t\tAND (view_pages <> '0')\n\t\t\t\t\t\tORDER BY ndx ASC"; } $result = $db->sql_query($sql, $block_cache_time); while ($row = $db->sql_fetchrow($result)) { $active_blocks[] = $row; $arr[$row['id']] = explode(',', $row['view_pages']); } $this_page_name = $this->get_current_page(); $id = $request->variable('style', 0); if ($id) { if (strstr($this_page_name, 'portal')) { $page_id = get_page_id('portal'); } else { if (strstr($this_page_name, 'index')) { $page_id = get_page_id('index'); } else { $page_id = get_page_id($this_page_name); } } } else { $page_id = get_page_id($this_page_name); } //var_dump('RETURNED: ' . $this_page_name . ' ID: ' . $page_id); if ($page_id == 0) { $page_id = $this_page[0]; $page_id = get_page_id($this_page[0]); } foreach ($active_blocks as $active_block) { $filename = substr($active_block['html_file_name'], 0, strpos($active_block['html_file_name'], '.')); if (file_exists($phpbb_root_path . 'ext/phpbbireland/portal/blocks/' . $filename . '.' . $this->php_ext)) { if (in_array($page_id, $arr[$active_block['id']])) { //var_dump('process_block_modules > foreach returned' . $filename); include $phpbb_root_path . 'ext/phpbbireland/portal/blocks/' . $filename . '.' . $this->php_ext; } } } $db->sql_freeresult($result); if (!function_exists('group_memberships')) { include $phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } $memberships = array(); $memberships = group_memberships(false, $user->data['user_id'], false); // Main processing of block data here // if ($active_blocks) { $L = $R = $C = 0; foreach ($active_blocks as $row) { $block_position = $row['position']; // override default position with user designated position // if (in_array($row['id'], $LB)) { $block_position = 'L'; } else { if (in_array($row['id'], $CB)) { $block_position = 'C'; } else { if (in_array($row['id'], $RB)) { $block_position = 'R'; } } } $block_id = $row['id']; $block_ndx = $row['ndx']; $block_title = $row['title']; $block_active = $row['active']; $block_type = $row['type']; $block_view_groups = $row['view_groups']; $block_view_all = $row['view_all']; $block_scroll = $row['scroll']; $block_height = $row['block_height']; $html_file_name = $row['html_file_name']; $img_file_name = $row['img_file_name']; $view_pages = $row['view_pages']; $arr = explode(',', $view_pages); $grps = explode(",", $block_view_groups); $process_block = false; $block_title = get_menu_lang_name($row['title']); // process blocks for different groups // if (isset($memberships)) { foreach ($memberships as $member) { // First we check to see if the view_all over-ride is set (saves having to enter all groups) // if ($block_view_all) { $process_block = true; } else { for ($j = 0; $j < ($jcount = count($grps)); $j++) { if ($grps[$j] == $member['group_id']) { $process_block = true; } } } } //unset($memberships); } if ($process_block && in_array($page_id, $arr)) { switch ($block_position) { case 'L': $left_block_ary[$L] = $html_file_name; $left_block_id[$L] = $block_id; $left_block_ndx[$L] = $block_ndx; $left_block_title[$L] = $block_title; $left_block_img[$L] = $img_file_name; $left_block_scroll[$L] = $block_scroll; $left_block_height[$L] = $block_height; $L++; $show_left = true; //show_blocks($this_page_name, $block_position); break; case 'C': $center_block_ary[$C] = $html_file_name; $center_block_id[$C] = $block_id; $center_block_ndx[$C] = $block_ndx; $center_block_title[$C] = $block_title; $center_block_img[$C] = $img_file_name; $center_block_scroll[$C] = $block_scroll; $center_block_height[$C] = $block_height; $C++; $show_center = true; //show_blocks($this_page_name, $block_position); break; case 'R': $right_block_ary[$R] = $html_file_name; $right_block_id[$R] = $block_id; $right_block_ndx[$R] = $block_ndx; $right_block_title[$R] = $block_title; $right_block_img[$R] = $img_file_name; $right_block_scroll[$R] = $block_scroll; $right_block_height[$R] = $block_height; $R++; $show_right = true; //show_blocks($this_page_name, $block_position); break; default: } ///var_dump($html_file_name); } } } //unset($active_blocks); if (isset($left_block_ary) && $show_left) { foreach ($left_block_ary as $block => $value) { $template->assign_block_vars('left_block_files', array('LEFT_BLOCKS' => $this->build_block_modules($value), 'LEFT_BLOCK_ID' => 'L_' . $left_block_id[$block], 'LEFT_BLOCK_TITLE' => $left_block_title[$block], 'LEFT_BLOCK_SCROLL' => $left_block_scroll[$block], 'LEFT_BLOCK_HEIGHT' => $left_block_height[$block], 'LEFT_BLOCK_IMG' => $left_block_img[$block] ? $block_image_path . $left_block_img[$block] : $block_image_path . 'none.gif', 'LEFT_BLOCK_IMG_2' => file_exists($big_image_path . $left_block_img[$block]) ? $big_image_path . $left_block_img[$block] : $big_image_path . 'none.png', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left')); } } //unset($left_block_ary); if (isset($right_block_ary) && $show_right) { foreach ($right_block_ary as $block => $value) { $template->assign_block_vars('right_block_files', array('RIGHT_BLOCKS' => $this->build_block_modules($value), 'RIGHT_BLOCK_ID' => 'R_' . $right_block_id[$block], 'RIGHT_BLOCK_TITLE' => $right_block_title[$block], 'RIGHT_BLOCK_SCROLL' => $right_block_scroll[$block], 'RIGHT_BLOCK_HEIGHT' => $right_block_height[$block], 'RIGHT_BLOCK_IMG' => $right_block_img[$block] ? $block_image_path . $right_block_img[$block] : $block_image_path . 'none.gif', 'RIGHT_BLOCK_IMG_2' => file_exists($big_image_path . $right_block_img[$block]) ? $big_image_path . $right_block_img[$block] : $big_image_path . 'none.png', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left')); } } //unset($right_block_ary); if (isset($center_block_ary) && $show_center) { foreach ($center_block_ary as $block => $value) { $template->assign_block_vars('center_block_files', array('CENTER_BLOCKS' => $this->build_block_modules($value), 'CENTER_BLOCK_ID' => 'C_' . $center_block_id[$block], 'CENTER_BLOCK_TITLE' => $center_block_title[$block], 'CENTER_BLOCK_SCROLL' => $center_block_scroll[$block], 'CENTER_BLOCK_HEIGHT' => $center_block_height[$block], 'CENTER_BLOCK_IMG' => $center_block_img[$block] ? $block_image_path . $center_block_img[$block] : $block_image_path . 'none.gif', 'CENTER_BLOCK_IMG_2' => file_exists($big_image_path . $center_block_img[$block]) ? $big_image_path . $center_block_img[$block] : $big_image_path . 'none.png', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left')); } } //unset($center_block_ary); $avatar_data = array('avatar' => $user->data['user_avatar'], 'avatar_width' => $user->data['user_avatar_width'], 'avatar_height' => $user->data['user_avatar_height'], 'avatar_type' => $user->data['user_avatar_type']); $template->assign_vars(array('ASSETS_PATH' => $phpbb_root_path . 'ext/phpbbireland/portal/styles/' . rawurlencode($user->style['style_path']) . '/template/assets/', 'AVATAR' => phpbb_get_avatar($avatar_data, $user->lang['USER_AVATAR'], false), 'BLOCK_WIDTH' => $blocks_width . 'px', 'PORTAL_ACTIVE' => $config['portal_enabled'], 'PORTAL_BUILD' => $config['portal_build'], 'PORTAL_VERSION' => $config['portal_version'], 'READ_ARTICLE_IMG' => $user->img('btn_read_article', 'READ_ARTICLE'), 'POST_COMMENTS_IMG' => $user->img('btn_post_comments', 'POST_COMMENTS'), 'VIEW_COMMENTS_IMG' => $user->img('btn_view_comments', 'VIEW_COMMENTS'), 'SITE_NAME' => $config['sitename'], 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_SHOW_LEFT_BLOCKS' => $show_left, 'S_SHOW_RIGHT_BLOCKS' => $show_right, 'S_BLOCKS_ENABLED' => $blocks_enabled, 'S_K_FOOTER_IMAGES_ALLOW' => $k_config['k_footer_images_allow'] ? true : false, 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'USER_NAME' => $user->data['username'], 'USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$this->php_ext}"), 'U_PORTAL' => append_sid("{$phpbb_root_path}portal"), 'U_STAFF' => append_sid("{$phpbb_root_path}memberlist.{$this->php_ext}", 'mode=leaders'), 'U_SEARCH_BOOKMARKS' => append_sid("{$phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=bookmarks'), 'PORTAL_HEADER_BLOCKS' => false, 'PORTAL_FOOTER_BLOCKS' => false, 'U_PORTAL_ARRANGE' => append_sid("{$phpbb_root_path}portal.{$this->php_ext}", "arrange=1"), 'S_ARRANGE' => false, 'HIDE_IMG' => '<img src="ext/phpbbireland/portal/images/hide.png" alt="' . $user->lang['SHOWHIDE'] . '" title="' . $user->lang['SHOWHIDE'] . '" height="16" width="14" />', 'MOVE_IMG' => '<img src="ext/phpbbireland/portal/images/move.png" alt="' . $user->lang['MOVE'] . '" title="' . $user->lang['MOVE'] . '" height="16" width="14" />', 'SHOW_IMG' => '<img src="ext/phpbbireland/portal/images/show.png" alt="' . $user->lang['SHOW'] . '" title="' . $user->lang['SHOW'] . '" height="16" width="14" />')); }
/** * {@inheritdoc} */ public function get_template_side($module_id) { if (!function_exists('phpbb_get_user_rank')) { include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; } if ($this->user->data['is_registered']) { // // + new posts since last visit & you post number // $ex_fid_ary = array_unique(array_merge(array_keys($this->auth->acl_getf('!f_read', true)), array_keys($this->auth->acl_getf('!f_search', true)))); if ($this->auth->acl_get('m_approve')) { $m_approve_fid_sql = ''; } else { if ($this->auth->acl_getf_global('m_approve')) { $m_approve_fid_ary = array_diff(array_keys($this->auth->acl_getf('!m_approve', true)), $ex_fid_ary); $m_approve_fid_sql = ' AND (p.post_visibility = 1' . (sizeof($m_approve_fid_ary) ? ' OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')'; } else { $m_approve_fid_sql = ' AND p.post_visibility = 1'; } } $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total FROM ' . TOPICS_TABLE . ' t WHERE t.topic_last_post_time > ' . (int) $this->user->data['user_lastvisit'] . ' AND t.topic_moved_id = 0 ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' ' . (sizeof($ex_fid_ary) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); $result = $this->db->sql_query($sql, 600); $new_posts_count = (int) $this->db->sql_fetchfield('total'); $this->db->sql_freeresult($result); // unread posts $sql_where = 'AND t.topic_moved_id = 0 ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' ' . (sizeof($ex_fid_ary) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); $unread_list = get_unread_topics($this->user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC'); $unread_posts_count = sizeof($unread_list); // Get user avatar and rank $user_id = $this->user->data['user_id']; $username = $this->user->data['username']; $colour = $this->user->data['user_colour']; $avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($this->user->data, 'user'), 'USER_AVATAR'); $rank_data = phpbb_get_user_rank($this->user->data, $this->user->data['user_posts']); // Assign specific vars $this->template->assign_vars(array('L_NEW_POSTS' => $this->user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')', 'L_SELF_POSTS' => $this->user->lang['SEARCH_SELF'] . ' (' . $this->user->data['user_posts'] . ')', 'L_UNREAD_POSTS' => $this->user->lang['SEARCH_UNREAD'] . ' (' . $unread_posts_count . ')', 'B3P_AVATAR_IMG' => $avatar_img, 'B3P_RANK_TITLE' => $rank_data['title'], 'B3P_RANK_IMG' => $rank_data['img'], 'RANK_IMG_SRC' => $rank_data['img_src'], 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour), 'U_NEW_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=newposts'), 'U_SELF_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=egosearch'), 'U_UNREAD_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=unreadposts'), 'U_UM_BOOKMARKS' => $this->config['allow_bookmarks'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=bookmarks') : '', 'U_UM_MAIN_SUBSCRIBED' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=subscribed'), 'U_UM_MCP' => $this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_') ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&mode=front', true, $this->user->session_id) : '', 'S_DISPLAY_SUBSCRIPTIONS' => $this->config['allow_topic_notify'] || $this->config['allow_forum_notify'] ? true : false)); return 'user_menu_side.html'; } else { /* * Assign specific vars * Need to remove web root path as ucp.php will do the * redirect */ $this->template->assign_vars(array('U_PORTAL_REDIRECT' => $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_portal_controller')), 'S_DISPLAY_FULL_LOGIN' => true, 'S_AUTOLOGIN_ENABLED' => $this->config['allow_autologin'] ? true : false, 'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'mode=login'), 'S_SHOW_REGISTER' => $this->config['board3_user_menu_register_' . $module_id] ? true : false)); return 'login_box_side.html'; } }
/** * {@inheritdoc} */ public function get_template_side($module_id) { switch ($this->db->get_sql_layer()) { case 'postgres': $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_type <> ' . USER_IGNORE . ' AND user_type <> ' . USER_INACTIVE . ' ORDER BY RANDOM()'; break; case 'mssql': case 'mssql_odbc': $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_type <> ' . USER_IGNORE . ' AND user_type <> ' . USER_INACTIVE . ' ORDER BY NEWID()'; break; default: $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_type <> ' . USER_IGNORE . ' AND user_type <> ' . USER_INACTIVE . ' ORDER BY RAND()'; break; } $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); $avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($row, 'user'), 'USER_AVATAR'); $rank_data = phpbb_get_user_rank($row, $row['user_posts']); $username = $row['username']; $user_id = (int) $row['user_id']; $colour = $row['user_colour']; $this->template->assign_block_vars('random_member', array('USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour), 'USERNAME' => get_username_string('username', $user_id, $username, $colour), 'USER_COLOR' => get_username_string('colour', $user_id, $username, $colour), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour), 'RANK_TITLE' => $rank_data['title'], 'RANK_IMG' => $rank_data['img'], 'RANK_IMG_SRC' => $rank_data['img_src'], 'USER_POSTS' => (int) $row['user_posts'], 'AVATAR_IMG' => $avatar_img, 'JOINED' => $this->user->format_date($row['user_regdate']))); $this->db->sql_freeresult($result); return 'random_member_side.html'; }
/** * Refresher Read action * * @return bool */ private function readAction() { $sql = 'SELECT c.*, p.post_visibility, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height FROM ' . CHAT_TABLE . ' as c LEFT JOIN ' . USERS_TABLE . ' as u ON c.user_id = u.user_id LEFT JOIN ' . POSTS_TABLE . ' as p ON c.post_id = p.post_id WHERE c.message_id > ' . $this->last_id . ' ORDER BY c.message_id DESC'; $result = $this->db->sql_query_limit($sql, (int) $this->config['ajax_chat_chat_amount']); $rows = $this->db->sql_fetchrowset($result); if (!sizeof($rows) && time() - 60 < $this->last_time) { return; } foreach ($rows as $row) { if ($row['forum_id'] && !$row['post_visibility'] == ITEM_APPROVED && !$this->auth->acl_get('m_approve', $row['forum_id'])) { continue; } if ($row['forum_id'] && !$this->auth->acl_get('f_read', $row['forum_id'])) { continue; } $avatar = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => $row['user_avatar_height'], 'avatar_width' => $row['user_avatar_width']]; $avatar_thumb = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => '', 'avatar_width' => 35]; $row['avatar'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar, '') : ''; $row['avatar_thumb'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar_thumb, '') : ''; if ($this->count++ === 0) { if ($row['message_id'] !== null) { $this->last_id = $row['message_id']; } else { $this->last_id = 0; } $this->template->assign_vars(['SOUND_ENABLED' => true, 'SOUND_FILE' => 'sound']); } if ($this->config['ajax_chat_time_setting']) { $time = $this->config['ajax_chat_time_setting']; } else { $time = $this->user->data['user_dateformat']; } $this->template->assign_block_vars('chatrow', ['MESSAGE_ID' => $row['message_id'], 'USERNAME_FULL' => $this->clean_username(get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST'])), 'USERNAME_A' => $row['username'], 'USER_COLOR' => $row['user_colour'], 'MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'TIME' => $this->user->format_date($row['time'], $time), 'CLASS' => $row['message_id'] % 2 ? 1 : 2, 'USER_AVATAR' => $row['avatar'], 'USER_AVATAR_THUMB' => $row['avatar_thumb']]); } $this->db->sql_freeresult($result); if (time() - 60 > $this->last_time) { $sql_ary = ['username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'user_lastupdate' => time()]; $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n WHERE user_id = {$this->user->data['user_id']}"; $result = $this->db->sql_query($sql); } $this->get = true; return; }
/** * Get avatar * * @param int $user_id User ID of the user you want to retreive the avatar for * @param bool $query Should we query the database if this user has not yet been loaded? * Typically this should be left as false and you should make sure * you load users ahead of time with load_users() * @param bool @lazy If true, will be lazy loaded (requires JS) * @return string */ public function get_avatar($user_id, $query = false, $lazy = false) { if (!($user = $this->get_user($user_id, $query))) { return ''; } return phpbb_get_avatar(\phpbb\avatar\manager::clean_row($user, 'user'), 'USER_AVATAR', false, $lazy); }
/** * Modifies the forum index to add the chat */ public function index() { if ($this->config['prune_ajax_chat'] === true) { $this->prune(); } if (!defined('PHPBB_USE_BOARD_URL_PATH')) { define('PHPBB_USE_BOARD_URL_PATH', true); } $this->user->add_lang('posting'); $this->user->add_lang_ext('spaceace/ajaxchat', 'ajax_chat'); if (!defined('CHAT_TABLE')) { $chat_table = $this->table_prefix . 'ajax_chat'; define('CHAT_TABLE', $chat_table); } if (!defined('CHAT_SESSIONS_TABLE')) { $chat_session_table = $this->table_prefix . 'ajax_chat_sessions'; define('CHAT_SESSIONS_TABLE', $chat_session_table); } include_once $this->root_path . 'includes/functions_posting.' . $this->php_ext; include_once $this->root_path . 'includes/functions_display.' . $this->php_ext; $this->mode = $this->request->variable('mode', 'default'); $this->last_id = $this->request->variable('last_id', 0); $this->last_time = $this->request->variable('last_time', 0); $this->post_time = $this->request->variable('last_post', 0); $this->times = ['online' => $this->config['status_online_chat'], 'idle' => $this->config['status_idle_chat'], 'offline' => $this->config['status_offline_chat']]; $sql = 'SELECT c.*, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height FROM ' . CHAT_TABLE . ' as c LEFT JOIN ' . USERS_TABLE . ' as u ON c.user_id = u.user_id ORDER BY message_id DESC'; $result = $this->db->sql_query_limit($sql, (int) $this->config['ajax_chat_index_amount']); $rows = $this->db->sql_fetchrowset($result); if (!sizeof($rows) && time() - 60 < $this->last_time) { return; } foreach ($rows as $row) { if ($row['forum_id'] && !$this->auth->acl_get('f_read', $row['forum_id'])) { continue; } $avatar = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => $row['user_avatar_height'], 'avatar_width' => $row['user_avatar_width']]; $avatar_thumb = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => '', 'avatar_width' => 35]; $row['avatar'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar, '') : ''; $row['avatar_thumb'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar_thumb, '') : ''; if ($this->count++ == 0) { $this->last_id = $row['message_id']; } if ($this->config['ajax_chat_time_setting']) { $time = $this->config['ajax_chat_time_setting']; } else { $time = $this->user->data['user_dateformat']; } $this->template->assign_block_vars('chatrow', ['MESSAGE_ID' => $row['message_id'], 'USERNAME_FULL' => $this->clean_username(get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST'])), 'USERNAME_A' => $row['username'], 'USER_COLOR' => $row['user_colour'], 'MESSAGE' => make_clickable(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'TIME' => $this->user->format_date($row['time'], $time), 'CLASS' => $row['message_id'] % 2 ? 1 : 2, 'USER_AVATAR' => $row['avatar'], 'USER_AVATAR_THUMB' => $row['avatar_thumb']]); } $this->db->sql_freeresult($result); if ($this->user->data['user_type'] == USER_FOUNDER || $this->user->data['user_type'] == USER_NORMAL) { $sql = 'SELECT * FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_id = {$this->user->data['user_id']}"; $result1 = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result1); $this->db->sql_freeresult($result1); if ($row['user_id'] != $this->user->data['user_id']) { $sql_ary = ['user_id' => $this->user->data['user_id'], 'username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'user_login' => time(), 'user_lastupdate' => time()]; $sql = 'INSERT INTO ' . CHAT_SESSIONS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); } else { $sql_ary = ['username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'user_login' => time(), 'user_lastupdate' => time()]; $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$this->user->data['user_id']}"; $this->db->sql_query($sql); } } $bbcode_status = $this->config['allow_bbcode'] && $this->config['auth_bbcode_pm'] && $this->auth->acl_get('u_ajaxchat_bbcode') ? true : false; $smilies_status = $this->config['allow_smilies'] && $this->config['auth_smilies_pm'] && $this->auth->acl_get('u_pm_smilies') ? true : false; $img_status = $this->config['auth_img_pm'] && $this->auth->acl_get('u_pm_img') ? true : false; $flash_status = $this->config['auth_flash_pm'] && $this->auth->acl_get('u_pm_flash') ? true : false; $url_status = $this->config['allow_post_links'] ? true : false; $this->mode = strtoupper($this->mode); $sql = 'SELECT `user_lastpost` FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_id = {$this->user->data['user_id']}"; $result1 = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result1); $this->db->sql_freeresult($result1); if ($this->get_status($row['user_lastpost']) === 'online') { $refresh = $this->config['refresh_online_chat']; } else { if ($this->get_status($row['user_lastpost']) === 'idle') { $refresh = $this->config['refresh_idle_chat']; } else { if ($this->user->data['user_id'] === ANONYMOUS || $this->get_status($row['user_lastpost']) === 'offline') { $refresh = $this->config['refresh_offline_chat']; } else { $refresh = $this->config['refresh_offline_chat']; } } } if ($this->user->data['user_id'] === ANONYMOUS || $row['user_lastpost'] === null) { $last_post = 0; } else { $last_post = $row['user_lastpost']; } //Assign the features template variable $this->template->assign_vars(['BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_COMPOSE_PM' => true, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => false, 'S_BBCODE_URL' => $url_status, 'REFRESH_TIME' => $refresh, 'LAST_ID' => $this->last_id, 'LAST_POST' => $last_post, 'TIME' => time(), 'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'], 'EXT_STYLE_PATH' => '' . $this->ext_path_web . 'styles/', 'FILENAME' => $this->helper->route('spaceace_ajaxchat_chat'), 'S_GET_CHAT' => $this->get ? true : false, 'S_' . $this->mode => true]); // Generate smiley listing \generate_smilies('inline', 0); // Build custom bbcodes array \display_custom_bbcodes(); $this->whois_online(); }
/** * Add & read action * * @return bool */ private function addAction() { if (!$this->user->data['is_registered'] || $this->user->data['user_type'] == USER_INACTIVE || $this->user->data['user_type'] == USER_IGNORE) { redirect(append_sid("{$this->root_path}ucp.{$this->php_ext}", 'mode=login')); } $this->get = true; $message = utf8_normalize_nfc($this->request->variable('message', '', true)); if (!$message) { return; } $this->clean_message($message); $uid = $bitfield = $options = ''; $allow_bbcode = $this->auth->acl_get('u_ajaxchat_bbcode'); $allow_urls = $allow_smilies = true; generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $sql_ary = ['chat_id' => 1, 'user_id' => $this->user->data['user_id'], 'username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'message' => $message, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options, 'time' => time()]; $sql = 'INSERT INTO ' . CHAT_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); $sql_ary2 = ['username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'user_lastpost' => time(), 'user_lastupdate' => time()]; $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary2) . " WHERE user_id = {$this->user->data['user_id']}"; $result = $this->db->sql_query($sql); $sql = 'SELECT c.*, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height FROM ' . CHAT_TABLE . ' as c LEFT JOIN ' . USERS_TABLE . ' as u ON c.user_id = u.user_id WHERE c.message_id > ' . $this->last_id . ' ORDER BY message_id DESC'; $result = $this->db->sql_query_limit($sql, (int) $this->config['ajax_chat_chat_amount']); $rows = $this->db->sql_fetchrowset($result); if (!sizeof($rows) && time() - 60 < $this->last_time) { exit; } foreach ($rows as $row) { if ($row['forum_id'] && !$this->auth->acl_get('f_read', $row['forum_id'])) { continue; } $avatar = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => $row['user_avatar_height'], 'avatar_width' => $row['user_avatar_width']]; $avatar_thumb = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => '', 'avatar_width' => 35]; $row['avatar'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar, '') : ''; $row['avatar_thumb'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar_thumb, '') : ''; if ($this->count++ == 0) { $this->last_id = $row['message_id']; $this->template->assign_vars(['SOUND_ENABLED' => true, 'SOUND_FILE' => 'soundout']); } if ($this->config['ajax_chat_time_setting']) { $time = $this->config['ajax_chat_time_setting']; } else { $time = $this->user->data['user_dateformat']; } $this->template->assign_block_vars('chatrow', ['MESSAGE_ID' => $row['message_id'], 'USERNAME_FULL' => $this->clean_username(get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST'])), 'USERNAME_A' => $row['username'], 'USER_COLOR' => $row['user_colour'], 'MESSAGE' => make_clickable(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'TIME' => $this->user->format_date($row['time'], $time), 'CLASS' => $row['message_id'] % 2 ? 1 : 2, 'USER_AVATAR' => $row['avatar'], 'USER_AVATAR_THUMB' => $row['avatar_thumb']]); } $this->db->sql_freeresult($result); return; }
//$my_file_wide = str_replace('.html', '_wide.html', $my_file_wide); $my_file_wide = $style_path_ext = ''; if (file_exists($my_file_wide)) { $value = str_replace('.html', '_wide.html', $value); } else { $my_file_wide = "{$style_path_ext}common/template/blocks/" . $value; $my_file_wide = str_replace('.html', '_wide.html', $my_file_wide); if (file_exists($my_file_wide)) { $value = str_replace('.html', '_wide.html', $value); } } $template->assign_block_vars('center_block_files', array('CENTER_BLOCKS' => portal_block_template($value), 'CENTER_BLOCK_ID' => 'C_' . $center_block_id[$block], 'CENTER_BLOCK_TITLE' => $center_block_title[$block], 'CENTER_BLOCK_SCROLL' => $center_block_scroll[$block], 'CENTER_BLOCK_HEIGHT' => $center_block_height[$block], 'CENTER_BLOCK_IMG' => $center_block_img[$block] ? $block_image_path . $center_block_img[$block] : $block_image_path . 'none.gif', 'CENTER_BLOCK_IMG_2' => file_exists($big_image_path . $center_block_img[$block]) ? $big_image_path . $center_block_img[$block] : $big_image_path . 'none.png', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left')); } } $avatar_data = array('avatar' => $row['user_avatar'], 'avatar_width' => $row['user_avatar_width'], 'avatar_height' => $row['user_avatar_height'], 'avatar_type' => $row['user_avatar_type']); $ava = phpbb_get_avatar($avatar_data, $user->lang['USER_AVATAR'], false); //var_dump($phpbb_root_path . 'ext/phpbbireland/portal/style/' . rawurlencode($user->style['style_path']) . '/theme/images/'); $template->assign_vars(array('T_THEME_PATH' => $phpbb_root_path . 'ext/phpbbireland/portal/style/' . rawurlencode($user->style['style_path']) . '/theme/images/', 'AVATAR' => $ava, 'BLOCK_WIDTH' => $blocks_width . 'px', 'PORTAL_ACTIVE' => $config['portal_enabled'], 'PORTAL_BUILD' => $config['portal_build'], 'PORTAL_VERSION' => $config['portal_version'], 'READ_ARTICLE_IMG' => $user->img('btn_read_article', 'READ_ARTICLE'), 'POST_COMMENTS_IMG' => $user->img('btn_post_comments', 'POST_COMMENTS'), 'VIEW_COMMENTS_IMG' => $user->img('btn_view_comments', 'VIEW_COMMENTS'), 'SITE_NAME' => $config['sitename'], 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_SHOW_LEFT_BLOCKS' => $show_left, 'S_SHOW_RIGHT_BLOCKS' => $show_right, 'S_BLOCKS_ENABLED' => $blocks_enabled, 'S_K_FOOTER_IMAGES_ALLOW' => $k_config['k_footer_images_allow'] ? true : false, 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'USER_NAME' => $user->data['username'], 'USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_STAFF' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=leaders'), 'U_SEARCH_BOOKMARKS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=main&mode=bookmarks'))); /*** // process common data here // if ($this_page[0] == 'viewtopic') { global $phpEx, $phpbb_root_path; global $config, $user, $template, $k_quick_posting_mode, $forum_id, $post_data, $topic_id, $topic_data, $k_config; include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); if (!function_exists('get_user_avatar')) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); }