From 4c699e0d0acc0aafab37e36206a92b1919282dac Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 19:29:28 -0700 Subject: [feature/avatars] Modularized Avatars A modularized avatar system that easily allows plugins to be created for various avatar services, such as Gravatar. This inital commit includes module support and is backwards compatible with 3.0 avatars, but does notcontain ACP or UCP modules for manipulating new avatars. PHPBB3-10018 --- phpBB/includes/functions_display.php | 128 ++++++++++++++++++++++++++++++----- 1 file changed, 110 insertions(+), 18 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9335cabc15..eba123be9d 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1272,52 +1272,144 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank /** * Get user avatar * -* @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 array $user_row Row from the users 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 * -* @return string Avatar image +* @return string Avatar html */ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - global $user, $config, $phpbb_root_path, $phpEx; + global $user, $config, $cache, $phpbb_root_path, $phpEx; - if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) + if (!$config['allow_avatar'] && !$ignore_config) { return ''; } - $avatar_img = ''; - - switch ($avatar_type) + $avatar_data = array( + 'src' => $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + + switch ($user_row['user_avatar_type']) { case AVATAR_UPLOAD: + // Compatibility with old avatars if (!$config['allow_avatar_upload'] && !$ignore_config) { - return ''; + $avatar_data['src'] = ''; + } + else + { + $avatar_data['src'] = $phpbb_root_path . "download/file.$phpEx?avatar=" . $avatar_data['src']; + $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); } - $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar="; break; case AVATAR_GALLERY: + // Compatibility with old avatars if (!$config['allow_avatar_local'] && !$ignore_config) { - return ''; + $avatar_data['src'] = ''; + } + else + { + $avatar_data['src'] = $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_data['src']; + $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); } - $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; break; case AVATAR_REMOTE: + // Compatibility with old avatars if (!$config['allow_avatar_remote'] && !$ignore_config) { - return ''; + $avatar_data['src'] = ''; + } + else + { + $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); } break; + + default: + $class = 'phpbb_avatar_' . $user_row['user_avatar_type']; + + if (!class_exists($class)) + { + $avatar_types = $cache->get('avatar_types'); + + if (empty($avatar_types)) + { + $avatar_types = array(); + + if ($dh = @opendir($phpbb_root_path . 'includes/avatars')) + { + while ($file = @readdir($dh)) + { + if (preg_match("/avatar_(.*)\.$phpEx/", $file, $match)) + { + $avatar_types[] = $match[1]; + } + } + + @closedir($dh); + + sort($avatar_types); + $cache->put('avatar_types', $avatar_types); + } + } + + if (in_array($user_row['user_avatar_type'], $avatar_types)) + { + require_once($phpbb_root_path . 'includes/avatars/avatar_' . $user_row['user_avatar_type'] . '.' . $phpEx); + } + } + + $avatar = new $class($user_row); + + if ($avatar->custom_html) + { + return $avatar->get_custom_html($ignore_config); + } + + $avatar_data = $avatar->get_data($ignore_config); + + break; + } + + $html = ''; + + if (!empty($avatar_data['src'])) + { + $html = ''; } - $avatar_img .= $avatar; - return '' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . ''; + return $html; +} + +/** +* 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 +* +* @return string Avatar html +*/ +function get_group_avatar(&$group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +{ + // Kind of abusing this functionality... + $avatar_row = array( + 'user_avatar' => $group_row['group_avatar'], + 'user_avatar_type' => $group_row['group_avatar_type'], + 'user_avatar_width' => $group_row['group_avatar_width'], + 'user_avatar_height' => $group_row['group_avatar_height'], + ); + + return get_user_avatar($group_row, $alt, $ignore_config); } -- cgit v1.2.1 From 1bd3d40121960c203d0dabb4b1a04c16c564b6f1 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 19:29:41 -0700 Subject: [feature/avatars] Refactor avatars to use manager Manager now stores singletons of each driver to speed loading. PHPBB3-10018 --- phpBB/includes/functions_display.php | 51 +++++++++++------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index eba123be9d..3aeee5f704 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1278,10 +1278,12 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * * @return string Avatar html */ -function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; + static $avatar_manager = null; + if (!$config['allow_avatar'] && !$ignore_config) { return ''; @@ -1334,48 +1336,27 @@ function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = fals break; default: - $class = 'phpbb_avatar_' . $user_row['user_avatar_type']; - - if (!class_exists($class)) + if (empty($avatar_manager)) { - $avatar_types = $cache->get('avatar_types'); - - if (empty($avatar_types)) - { - $avatar_types = array(); - - if ($dh = @opendir($phpbb_root_path . 'includes/avatars')) - { - while ($file = @readdir($dh)) - { - if (preg_match("/avatar_(.*)\.$phpEx/", $file, $match)) - { - $avatar_types[] = $match[1]; - } - } - - @closedir($dh); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); + } - sort($avatar_types); - $cache->put('avatar_types', $avatar_types); - } - } + $avatar = $avatar_manager->get_singleton($user_row['user_avatar_type']); - if (in_array($user_row['user_avatar_type'], $avatar_types)) + if ($avatar) + { + if ($avatar->custom_html) { - require_once($phpbb_root_path . 'includes/avatars/avatar_' . $user_row['user_avatar_type'] . '.' . $phpEx); + return $avatar->get_html($user_row, $ignore_config); } - } - - $avatar = new $class($user_row); - if ($avatar->custom_html) + $avatar_data = $avatar->get_data($user_row, $ignore_config); + } + else { - return $avatar->get_custom_html($ignore_config); + $avatar_data['src'] = ''; } - $avatar_data = $avatar->get_data($ignore_config); - break; } @@ -1401,7 +1382,7 @@ function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = fals * * @return string Avatar html */ -function get_group_avatar(&$group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +function get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { // Kind of abusing this functionality... $avatar_row = array( -- cgit v1.2.1 From f102d9a631d6de464abefe2089ff1e6e13ed044d Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Mon, 18 Apr 2011 10:44:29 -0700 Subject: [feature/avatars] Various cosmetic changes Various small changes based on feedback from nn- * Renaming $php_ext to $phpEx * Fixing copyright years * Explain $ignore_config * Explain Regex * Copypasta package error * rename get_singleton PHPBB3-10018 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 3aeee5f704..23900dfd88 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1341,7 +1341,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); } - $avatar = $avatar_manager->get_singleton($user_row['user_avatar_type']); + $avatar = $avatar_manager->get_driver($user_row['user_avatar_type']); if ($avatar) { -- cgit v1.2.1 From a06380c69a154659f4f9985238008640670669e0 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sat, 18 Jun 2011 22:50:52 -0700 Subject: [feature/avatars] Make avatars generic Adding a cleaning function for data coming from the users/groups tables so drivers only deal with clean data (ideally). Refactored get_user_avatar() and get_group_avatar() to use an underlying get_avatar() function. PHPBB3-10018 --- phpBB/includes/functions_display.php | 66 ++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 23900dfd88..b82f004505 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1279,6 +1279,36 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * @return string Avatar html */ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) +{ + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_USER); + return get_avatar($row, $alt, $ignore_config); +} + +/** +* 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 +* +* @return string Avatar html +*/ +function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +{ + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_GROUP); + return get_avatar($row, $alt, $ignore_config); +} + +/** +* Get avatar +* +* @param array $row Row cleaned by phpbb_avatar_driver::clean_row +* @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 html +*/ +function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; @@ -1290,12 +1320,12 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false } $avatar_data = array( - 'src' => $user_row['user_avatar'], - 'width' => $user_row['user_avatar_width'], - 'height' => $user_row['user_avatar_height'], + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], ); - switch ($user_row['user_avatar_type']) + switch ($row['avatar_type']) { case AVATAR_UPLOAD: // Compatibility with old avatars @@ -1341,16 +1371,16 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); } - $avatar = $avatar_manager->get_driver($user_row['user_avatar_type']); + $avatar = $avatar_manager->get_driver($row['avatar_type']); if ($avatar) { if ($avatar->custom_html) { - return $avatar->get_html($user_row, $ignore_config); + return $avatar->get_html($row, $ignore_config); } - $avatar_data = $avatar->get_data($user_row, $ignore_config); + $avatar_data = $avatar->get_data($row, $ignore_config); } else { @@ -1372,25 +1402,3 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false return $html; } - -/** -* 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 -* -* @return string Avatar html -*/ -function get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) -{ - // Kind of abusing this functionality... - $avatar_row = array( - 'user_avatar' => $group_row['group_avatar'], - 'user_avatar_type' => $group_row['group_avatar_type'], - 'user_avatar_width' => $group_row['group_avatar_width'], - 'user_avatar_height' => $group_row['group_avatar_height'], - ); - - return get_user_avatar($group_row, $alt, $ignore_config); -} -- cgit v1.2.1 From e861bb0e04c08b03366ec7c58473b630acc91181 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Apr 2012 19:19:13 +0200 Subject: [feature/avatars] Use request object in avatar drivers PHPBB3-10018 --- phpBB/includes/functions_display.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 1c1663f2cc..c59805dacd 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1312,6 +1312,7 @@ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = fal function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; + global $request; static $avatar_manager = null; @@ -1369,7 +1370,7 @@ function get_avatar($row, $alt, $ignore_config = false) default: if (empty($avatar_manager)) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); } $avatar = $avatar_manager->get_driver($row['avatar_type']); -- cgit v1.2.1 From eea2ec50521e274b928d23f710108f37797cb22c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 16:27:09 +0200 Subject: [feature/avatars] Introduce global phpbb_avatar_manager PHPBB3-10018 --- phpBB/includes/functions_display.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index c59805dacd..e1dd67aeaf 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1313,8 +1313,7 @@ function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; global $request; - - static $avatar_manager = null; + global $phpbb_avatar_manager; if (!$config['allow_avatar'] && !$ignore_config) { @@ -1368,12 +1367,7 @@ function get_avatar($row, $alt, $ignore_config = false) break; default: - if (empty($avatar_manager)) - { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); - } - - $avatar = $avatar_manager->get_driver($row['avatar_type']); + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); if ($avatar) { -- cgit v1.2.1 From 81fb4268cd141259fe5b3bc9ad51adf2e29e0772 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 16:40:19 +0200 Subject: [feature/avatars] Introduce an avatar driver interface PHPBB3-10018 --- phpBB/includes/functions_display.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index e1dd67aeaf..82638b7f2b 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1281,7 +1281,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank */ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_USER); + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER); return get_avatar($row, $alt, $ignore_config); } @@ -1296,7 +1296,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false */ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_GROUP); + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_GROUP); return get_avatar($row, $alt, $ignore_config); } -- cgit v1.2.1 From 3b71e81cfba726043063b05cb793e18186143252 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 21:29:52 +0200 Subject: [feature/avatars] Simplify clean_row, move it to avatar manager PHPBB3-10018 --- phpBB/includes/functions_display.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 82638b7f2b..619c30ada5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1281,7 +1281,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank */ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER); + $row = phpbb_avatar_manager::clean_row($user_row); return get_avatar($row, $alt, $ignore_config); } @@ -1296,7 +1296,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false */ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_GROUP); + $row = phpbb_avatar_manager::clean_row($user_row); return get_avatar($row, $alt, $ignore_config); } -- cgit v1.2.1 From a1132fc5c7e990d73cbc8ac7abf4502a1bbe7216 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 21:45:51 +0200 Subject: [feature/avatars] Update avatars in database_update PHPBB3-10018 --- phpBB/includes/functions_display.php | 70 +++++++----------------------------- 1 file changed, 13 insertions(+), 57 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 619c30ada5..291d92387f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1325,72 +1325,28 @@ function get_avatar($row, $alt, $ignore_config = false) 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); - - switch ($row['avatar_type']) - { - case AVATAR_UPLOAD: - // Compatibility with old avatars - if (!$config['allow_avatar_upload'] && !$ignore_config) - { - $avatar_data['src'] = ''; - } - else - { - $avatar_data['src'] = $phpbb_root_path . "download/file.$phpEx?avatar=" . $avatar_data['src']; - $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); - } - break; - case AVATAR_GALLERY: - // Compatibility with old avatars - if (!$config['allow_avatar_local'] && !$ignore_config) - { - $avatar_data['src'] = ''; - } - else - { - $avatar_data['src'] = $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_data['src']; - $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); - } - break; - - case AVATAR_REMOTE: - // Compatibility with old avatars - if (!$config['allow_avatar_remote'] && !$ignore_config) - { - $avatar_data['src'] = ''; - } - else - { - $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); - } - break; + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); - default: - $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); - - if ($avatar) - { - if ($avatar->custom_html) - { - return $avatar->get_html($row, $ignore_config); - } - - $avatar_data = $avatar->get_data($row, $ignore_config); - } - else - { - $avatar_data['src'] = ''; - } + if ($avatar) + { + if ($avatar->custom_html) + { + return $avatar->get_html($row, $ignore_config); + } - break; + $avatar_data = $avatar->get_data($row, $ignore_config); + } + else + { + $avatar_data['src'] = ''; } $html = ''; if (!empty($avatar_data['src'])) { - $html = ''; -- cgit v1.2.1 From c03d692a98fafa921a832e063c76a3d844632ca7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 Aug 2012 22:57:00 +0200 Subject: [feature/soft-delete] Fix some more usages of _approved column names PHPBB3-9657 --- phpBB/includes/functions_display.php | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 881c95907b..2781f1a7bb 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -987,33 +987,25 @@ function display_user_activity(&$userdata) $forum_ary = array(); - // Do not include those forums the user is not having read access to... - $forum_read_ary = $auth->acl_getf('!f_read'); - - foreach ($forum_read_ary as $forum_id => $not_allowed) + $forum_read_ary = $auth->acl_getf('f_read'); + foreach ($forum_read_ary as $forum_id => $allowed) { - if ($not_allowed['f_read']) + if ($allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } - $forum_ary = array_unique($forum_ary); - $forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : ''; - - $fid_m_approve = $auth->acl_getf('m_approve', true); - $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : ''; + $forum_ary = array_diff($forum_ary, $user->get_passworded_forums());; // Obtain active forum $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata['user_id'] . " + WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND (post_approved = 1 - $sql_m_approve) - $forum_sql + AND ' . phpbb_content_visibility::get_visibility_sql_forums('post', $forum_ary) . ' GROUP BY forum_id - ORDER BY num_posts DESC"; + ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); $active_f_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1035,13 +1027,11 @@ function display_user_activity(&$userdata) $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata['user_id'] . " + WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND (post_approved = 1 - $sql_m_approve) - $forum_sql_topic + AND ' . phpbb_content_visibility::get_visibility_sql_forums('post', $forum_ary) . ' GROUP BY topic_id - ORDER BY num_posts DESC"; + ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); $active_t_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); -- cgit v1.2.1 From 4a65940e6206aef6b85a0aacfb5324ecabf76e12 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 1 Oct 2012 22:14:04 +0200 Subject: [feature/soft-delete] Add unit tests for get_forums_visibility_sql() PHPBB3-9657 --- phpBB/includes/functions_display.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 2781f1a7bb..5849f5cf4c 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1003,7 +1003,7 @@ function display_user_activity(&$userdata) FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_visibility_sql_forums('post', $forum_ary) . ' + AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' GROUP BY forum_id ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); @@ -1029,7 +1029,7 @@ function display_user_activity(&$userdata) FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_visibility_sql_forums('post', $forum_ary) . ' + AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' GROUP BY topic_id ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); -- cgit v1.2.1 From 2841ecc44f2c9773fe3eb19134f52bfcf4beb05e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 Oct 2012 12:08:17 +0200 Subject: [feature/soft-delete] Fix display_user_activity() The Logic of $forum_ary was inverted, so if the array is empty, we can skip the queries. We also should not merge passworded forums into the $forum_ary as we removed them from that array right before that. PHPBB3-9567 --- phpBB/includes/functions_display.php | 84 ++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 5849f5cf4c..10f07bfbf1 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -996,54 +996,54 @@ function display_user_activity(&$userdata) } } - $forum_ary = array_diff($forum_ary, $user->get_passworded_forums());; - - // Obtain active forum - $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata['user_id'] . ' - AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' - GROUP BY forum_id - ORDER BY num_posts DESC'; - $result = $db->sql_query_limit($sql, 1); - $active_f_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $forum_ary = array_diff($forum_ary, $user->get_passworded_forums()); - if (!empty($active_f_row)) + $active_f_row = $active_t_row = array(); + if (!empty($forum_ary)) { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $active_f_row['forum_id']; - $result = $db->sql_query($sql, 3600); - $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); + // Obtain active forum + $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts + FROM ' . POSTS_TABLE . ' + WHERE poster_id = ' . $userdata['user_id'] . ' + AND post_postcount = 1 + AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' + GROUP BY forum_id + ORDER BY num_posts DESC'; + $result = $db->sql_query_limit($sql, 1); + $active_f_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - } - // Obtain active topic - // We need to exclude passworded forums here so we do not leak the topic title - $forum_ary_topic = array_unique(array_merge($forum_ary, $user->get_passworded_forums())); - $forum_sql_topic = (!empty($forum_ary_topic)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary_topic, true) : ''; - - $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata['user_id'] . ' - AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' - GROUP BY topic_id - ORDER BY num_posts DESC'; - $result = $db->sql_query_limit($sql, 1); - $active_t_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + if (!empty($active_f_row)) + { + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $active_f_row['forum_id']; + $result = $db->sql_query($sql, 3600); + $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); + $db->sql_freeresult($result); + } - if (!empty($active_t_row)) - { - $sql = 'SELECT topic_title - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $active_t_row['topic_id']; - $result = $db->sql_query($sql); - $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); + // Obtain active topic + $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts + FROM ' . POSTS_TABLE . ' + WHERE poster_id = ' . $userdata['user_id'] . ' + AND post_postcount = 1 + AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' + GROUP BY topic_id + ORDER BY num_posts DESC'; + $result = $db->sql_query_limit($sql, 1); + $active_t_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); + + if (!empty($active_t_row)) + { + $sql = 'SELECT topic_title + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $active_t_row['topic_id']; + $result = $db->sql_query($sql); + $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); + $db->sql_freeresult($result); + } } $userdata['active_t_row'] = $active_t_row; -- cgit v1.2.1 From 6c39563e9f7fad18f1425292dca652861f5e1cb6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 21 Oct 2012 23:38:55 +0200 Subject: [feature/soft-delete] Add a function to calculate the actual post/topic count PHPBB3-9567 --- phpBB/includes/functions_display.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 10f07bfbf1..ed91d9ad1c 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -200,8 +200,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } // Count the difference of real to public topics, so we can display an information to moderators - $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0; - $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; + $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; + $row['forum_posts'] = phpbb_content_visibility::get_count('forum_posts', $row, $forum_id); + $row['forum_topics'] = phpbb_content_visibility::get_count('forum_topics', $row, $forum_id); // Display active topics from this forum? if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) -- cgit v1.2.1 From 334265fc839f95d24cce44ec675ae8cef7b4bfaa Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 Nov 2012 22:57:49 +0100 Subject: [feature/soft-delete] Fix displaying the button/permission When the post is already softdeleted the options should only be available if *_delete is granted. PHPBB3-9567 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index ed91d9ad1c..6f166e2a14 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -788,7 +788,7 @@ function gen_forum_auth_level($mode, $forum_id, $forum_status) ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'], ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'], ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'], - ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], + ($user->data['is_registered'] && ($auth->acl_gets('f_delete', 'm_delete', $forum_id) || $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], ); if ($config['allow_attachments']) -- cgit v1.2.1 From 076785d76a1412394636095f0b296964419e2a4f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 14 Nov 2012 20:04:02 +0100 Subject: [feature/avatars] Add support for custom avatar HTML code PHPBB3-10018 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f84652fc50..bf1611a5de 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1372,7 +1372,7 @@ function get_avatar($row, $alt, $ignore_config = false) { if ($avatar->custom_html) { - return $avatar->get_html($row, $ignore_config); + return $avatar->get_custom_html($row, $ignore_config, $alt); } $avatar_data = $avatar->get_data($row, $ignore_config); -- cgit v1.2.1 From 67c2e48d15d6e4ddd244dd2e126f906ed25be1ef Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 14:33:13 +0100 Subject: [feature/avatars] Only create avatar objects if necessary PHPBB3-10018 --- phpBB/includes/functions_display.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index bf1611a5de..669641de70 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1353,7 +1353,7 @@ function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; global $request; - global $phpbb_avatar_manager; + global $phpbb_container; if (!$config['allow_avatar'] && !$ignore_config) { @@ -1366,6 +1366,7 @@ function get_avatar($row, $alt, $ignore_config = false) 'height' => $row['avatar_height'], ); + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); if ($avatar) -- cgit v1.2.1 From 81a1a21185abfc230097a355216d6c6b99511b20 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 Nov 2012 23:08:29 +0100 Subject: [feature/avatars] Properly implement custom HTML in the interface Previously the driver class added a variable that defined wether an avatar driver would return custom HTML. The existence of this variable was implied in the interface. It's also not needed which is why it has been removed. PHPBB3-10018 --- phpBB/includes/functions_display.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 669641de70..a7b28acac1 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1368,12 +1368,14 @@ function get_avatar($row, $alt, $ignore_config = false) $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); + $html = ''; if ($avatar) { - if ($avatar->custom_html) + $html = $avatar->get_custom_html($row, $ignore_config, $alt); + if (!empty($html)) { - return $avatar->get_custom_html($row, $ignore_config, $alt); + return $html; } $avatar_data = $avatar->get_data($row, $ignore_config); @@ -1383,8 +1385,6 @@ function get_avatar($row, $alt, $ignore_config = false) $avatar_data['src'] = ''; } - $html = ''; - if (!empty($avatar_data['src'])) { $html = ' Date: Fri, 30 Nov 2012 15:12:34 +0100 Subject: [feature/avatars] Let avatar manager handle $ignore_config The avatar manager already handles if avatars are enabled. It should also handle ignoring the config settings. PHPBB3-10018 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index a7b28acac1..f88d8c9054 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1367,7 +1367,7 @@ function get_avatar($row, $alt, $ignore_config = false) ); $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config); $html = ''; if ($avatar) -- cgit v1.2.1 From 33b98dc5ba0b690fdae72acfd676dae5a897cb6a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Nov 2012 16:46:11 +0100 Subject: [feature/avatars] Fix variable names PHPBB3-10018 --- phpBB/includes/functions_display.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f88d8c9054..6b267bc901 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1367,18 +1367,18 @@ function get_avatar($row, $alt, $ignore_config = false) ); $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config); + $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config); $html = ''; - if ($avatar) + if ($driver) { - $html = $avatar->get_custom_html($row, $ignore_config, $alt); + $html = $driver->get_custom_html($row, $ignore_config, $alt); if (!empty($html)) { return $html; } - $avatar_data = $avatar->get_data($row, $ignore_config); + $avatar_data = $driver->get_data($row, $ignore_config); } else { -- cgit v1.2.1 From 7ce009f2e29045b2bd29dd670c900b79f7f3bd70 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 12:46:20 +0100 Subject: [ticket/10954] Mark forums read without popup or page refresh PHPBB3-10954 --- phpBB/includes/functions_display.php | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 73129803ee..9745d493c4 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -61,10 +61,23 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { markread('all', false, false, request_var('mark_time', 0)); - trigger_error( - $user->lang['FORUMS_MARKED'] . '

' . - sprintf($user->lang['RETURN_INDEX'], '', '') - ); + if (!$request->is_ajax()) + { + trigger_error( + $user->lang['FORUMS_MARKED'] . '

' . + sprintf($user->lang['RETURN_INDEX'], '', '') + ); + } + else + { + // Tell the ajax script what language vars need to be replaced + $data = array( + 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + ); + $json_response = new phpbb_json_response(); + $json_response->send($data); + } } else { @@ -313,7 +326,20 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); - trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); + if (!$request->is_ajax()) + { + trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); + } + else + { + // Tell the ajax script what language vars need to be replaced + $data = array( + 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + ); + $json_response = new phpbb_json_response(); + $json_response->send($data); + } } else { -- cgit v1.2.1 From 7efc37d1f9d4a4335fc91af147cd059c17b7d45e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 19:09:18 +0100 Subject: [ticket/10954] Modify is_ajax check for consistency PHPBB3-10954 --- phpBB/includes/functions_display.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9745d493c4..f3198bc1e5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -61,14 +61,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { markread('all', false, false, request_var('mark_time', 0)); - if (!$request->is_ajax()) - { - trigger_error( - $user->lang['FORUMS_MARKED'] . '

' . - sprintf($user->lang['RETURN_INDEX'], '', '') - ); - } - else + if ($request->is_ajax()) { // Tell the ajax script what language vars need to be replaced $data = array( @@ -78,6 +71,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $json_response = new phpbb_json_response(); $json_response->send($data); } + + trigger_error( + $user->lang['FORUMS_MARKED'] . '

' . + sprintf($user->lang['RETURN_INDEX'], '', '') + ); } else { @@ -326,11 +324,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); - if (!$request->is_ajax()) - { - trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); - } - else + if ($request->is_ajax()) { // Tell the ajax script what language vars need to be replaced $data = array( @@ -340,6 +334,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $json_response = new phpbb_json_response(); $json_response->send($data); } + + trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); } else { -- cgit v1.2.1 From 16c021e98667fe353e6b3a6cb0bbf3b8f2319f98 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Dec 2012 15:46:45 +0100 Subject: [ticket/10954] Change behavior of marking topics/forums It will now display a popup message for 3 seconds which will confirm the taken action. The amount of DOM traversals have been significantly reduced and jQuery.each is now used instead of for loops. Additionally, it is now possible to click on the mark topics/forums read links without triggering an AJAX error. PHPBB3-10954 --- phpBB/includes/functions_display.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f3198bc1e5..cd4c901b58 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -63,10 +63,13 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod if ($request->is_ajax()) { - // Tell the ajax script what language vars need to be replaced + // Tell the ajax script what language vars and URL need to be replaced $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], + 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] ); $json_response = new phpbb_json_response(); $json_response->send($data); @@ -326,10 +329,13 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod if ($request->is_ajax()) { - // Tell the ajax script what language vars need to be replaced + // Tell the ajax script what language vars and URL need to be replaced $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], + 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] ); $json_response = new phpbb_json_response(); $json_response->send($data); -- cgit v1.2.1 From 7256a2d944df10ef649794c6174fea5ca69adea3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Jan 2013 15:10:43 +0100 Subject: [feature/avatars] Add phpbb prefix to new functions Although get_user_avatar() is not new, the phpbb prefix was prepended. This is due to the fact that it was entirely rewritten and is therefore more or less a completely new function. PHPBB3-10018 --- phpBB/includes/functions_display.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index cf56250296..0a288127a4 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1347,10 +1347,10 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * * @return string Avatar html */ -function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) +function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { $row = phpbb_avatar_manager::clean_row($user_row); - return get_avatar($row, $alt, $ignore_config); + return phpbb_get_avatar($row, $alt, $ignore_config); } /** @@ -1362,10 +1362,10 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false * * @return string Avatar html */ -function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { $row = phpbb_avatar_manager::clean_row($user_row); - return get_avatar($row, $alt, $ignore_config); + return phpbb_get_avatar($row, $alt, $ignore_config); } /** @@ -1377,7 +1377,7 @@ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = fal * * @return string Avatar html */ -function get_avatar($row, $alt, $ignore_config = false) +function phpbb_get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; global $request; -- cgit v1.2.1 From 8778c9c945e388c2b727f1b7cd057dd67a091441 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 8 Jan 2013 15:34:20 +0100 Subject: [feature/avatars] Pass phpbb_user object to get_custom_html() Pass the phpbb_user object to function get_custom_html(). This object is used in that method. Also fixed incorrect arguments to get_custom_html() in phpbb_get_avatar(). PHPBB3-10018 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 0a288127a4..9854cd6d70 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1400,7 +1400,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false) if ($driver) { - $html = $driver->get_custom_html($row, $ignore_config, $alt); + $html = $driver->get_custom_html($user, $row, $alt); if (!empty($html)) { return $html; -- cgit v1.2.1 From 9aed758c1397c31b979f4aca51249c73d21bd6f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 14:24:07 +0200 Subject: [ticket/9657] Use the service instead of the static class PHPBB3-9657 --- phpBB/includes/functions_display.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 797ca718d8..143813e4ed 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -22,7 +22,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { global $db, $auth, $user, $template; global $phpbb_root_path, $phpEx, $config; - global $request, $phpbb_dispatcher; + global $request, $phpbb_dispatcher, $phpbb_container; $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); $parent_id = $visible_forums = 0; @@ -149,6 +149,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + while ($row = $db->sql_fetchrow($result)) { /** @@ -215,8 +217,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod // Count the difference of real to public topics, so we can display an information to moderators $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; - $row['forum_posts'] = phpbb_content_visibility::get_count('forum_posts', $row, $forum_id); - $row['forum_topics'] = phpbb_content_visibility::get_count('forum_topics', $row, $forum_id); + $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); + $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); // Display active topics from this forum? if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) @@ -1006,7 +1008,7 @@ function display_reasons($reason_id = 0) function display_user_activity(&$userdata) { global $auth, $template, $db, $user; - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_container; // Do not display user activity for users having more than 5000 posts... if ($userdata['user_posts'] > 5000) @@ -1030,12 +1032,14 @@ function display_user_activity(&$userdata) $active_f_row = $active_t_row = array(); if (!empty($forum_ary)) { + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // Obtain active forum $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' + AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' GROUP BY forum_id ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); @@ -1057,7 +1061,7 @@ function display_user_activity(&$userdata) FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' + AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' GROUP BY topic_id ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); -- cgit v1.2.1 From 081350678dcfd88104d885385674b8f4a382aa91 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 14:57:31 -0400 Subject: [ticket/9649] Display information on index for moderators on unapproved posts PHPBB3-9649 --- phpBB/includes/functions_display.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 143813e4ed..b1dac64bec 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -215,8 +215,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } - // Count the difference of real to public topics, so we can display an information to moderators + // Lets check whether there are unapproved topics/posts, so we can display an information to moderators $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; + $row['forum_id_unapproved_posts'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved']) ? $forum_id : 0; $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); @@ -281,6 +282,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; } + if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts']) + { + $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id; + } + $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; // Do not list redirects in LINK Forums as Posts. @@ -548,6 +554,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_MODERATOR_STR' => $l_moderator, 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', + 'U_UNAPPROVED_POSTS' => ($row['forum_id_unapproved_posts']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts&f=' . $row['forum_id_unapproved_posts']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url, @@ -587,6 +594,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), + 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED'), )); if ($return_moderators) -- cgit v1.2.1