aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php83
1 files changed, 65 insertions, 18 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index d460497669..b2b891be66 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1159,7 +1159,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
/**
* This event is used for performing actions directly before marking forums,
* topics or posts as read.
- *
+ *
* It is also possible to prevent the marking. For that, the $should_markread parameter
* should be set to FALSE.
*
@@ -1258,6 +1258,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
{
$forum_id = array($forum_id);
}
+ else
+ {
+ $forum_id = array_unique($forum_id);
+ }
$phpbb_notifications = $phpbb_container->get('notification_manager');
@@ -4260,10 +4264,14 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum'
if (sizeof($online_users['online_users']))
{
- $sql = 'SELECT username, username_clean, user_id, user_type, user_allow_viewonline, user_colour
- FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $online_users['online_users']) . '
- ORDER BY username_clean ASC';
+ $sql_ary = array(
+ 'SELECT' => 'u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour',
+ 'FROM' => array(
+ USERS_TABLE => 'u',
+ ),
+ 'WHERE' => $db->sql_in_set('u.user_id', $online_users['online_users']),
+ 'ORDER BY' => 'u.username_clean ASC',
+ );
/**
* Modify SQL query to obtain online users data
@@ -4275,13 +4283,14 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum'
* @var string item Restrict online users to a certain
* session item, e.g. forum for
* session_forum_id
- * @var string sql SQL query to obtain users online data
+ * @var string sql_ary SQL query to obtain users online data
* @since 3.1.4-RC1
+ * @changed 3.1.7-RC1 Change sql query into array and adjust var accordingly. Allows extension authors the ability to adjust the sql_ary.
*/
- $vars = array('online_users', 'item_id', 'item', 'sql');
+ $vars = array('online_users', 'item_id', 'item', 'sql_ary');
extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_sql', compact($vars)));
- $result = $db->sql_query($sql);
+ $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$rowset = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
@@ -4295,7 +4304,7 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum'
$row['username'] = '<em>' . $row['username'] . '</em>';
}
- if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline'))
+ if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline') || $row['user_id'] === $user->data['user_id'])
{
$user_online_link[$row['user_id']] = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
}
@@ -4779,13 +4788,14 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
* @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
+* @param bool $lazy If true, will be lazy loaded (requires JS)
*
* @return string Avatar html
*/
-function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false)
+function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false)
{
$row = \phpbb\avatar\manager::clean_row($user_row, 'user');
- return phpbb_get_avatar($row, $alt, $ignore_config);
+ return phpbb_get_avatar($row, $alt, $ignore_config, $lazy);
}
/**
@@ -4794,13 +4804,14 @@ function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config =
* @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)
+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);
+ return phpbb_get_avatar($row, $alt, $ignore_config, $lazy);
}
/**
@@ -4809,14 +4820,15 @@ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config
* @param array $row Row cleaned by \phpbb\avatar\manager::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
+* @param bool $lazy If true, will be lazy loaded (requires JS)
*
* @return string Avatar html
*/
-function phpbb_get_avatar($row, $alt, $ignore_config = false)
+function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
global $request;
- global $phpbb_container;
+ global $phpbb_container, $phpbb_dispatcher;
if (!$config['allow_avatar'] && !$ignore_config)
{
@@ -4830,7 +4842,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false)
);
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
- $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config);
+ $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], !$ignore_config);
$html = '';
if ($driver)
@@ -4841,7 +4853,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false)
return $html;
}
- $avatar_data = $driver->get_data($row, $ignore_config);
+ $avatar_data = $driver->get_data($row);
}
else
{
@@ -4850,12 +4862,47 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false)
if (!empty($avatar_data['src']))
{
- $html = '<img src="' . $avatar_data['src'] . '" ' .
+ if ($lazy)
+ {
+ // Determine board url - we may need it later
+ $board_url = generate_board_url() . '/';
+ // This path is sent with the base template paths in the assign_vars()
+ // call below. We need to correct it in case we are accessing from a
+ // controller because the web paths will be incorrect otherwise.
+ $phpbb_path_helper = $phpbb_container->get('path_helper');
+ $corrected_path = $phpbb_path_helper->get_web_root_path();
+
+ $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
+
+ $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';
+
+ $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"';
+ }
+ else
+ {
+ $src = 'src="' . $avatar_data['src'] . '"';
+ }
+
+ $html = '<img class="avatar" ' . $src . ' ' .
($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') .
($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
+ /**
+ * Event to modify HTML <img> tag of avatar
+ *
+ * @event core.get_avatar_after
+ * @var array row Row cleaned by \phpbb\avatar\manager::clean_row
+ * @var string alt Optional language string for alt tag within image, can be a language key or text
+ * @var bool ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
+ * @var array avatar_data The HTML attributes for avatar <img> tag
+ * @var string html The HTML <img> tag of generated avatar
+ * @since 3.1.6-RC1
+ */
+ $vars = array('row', 'alt', 'ignore_config', 'avatar_data', 'html');
+ extract($phpbb_dispatcher->trigger_event('core.get_avatar_after', compact($vars)));
+
return $html;
}