mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
Merge remote-tracking branch 'nickvergessen/feature/php-events-4' into develop
This commit is contained in:
@@ -987,6 +987,16 @@ $sql_ary = array(
|
||||
AND u.user_id = p.poster_id',
|
||||
);
|
||||
|
||||
/**
|
||||
* Event to modify the SQL query before the post and poster data is retrieved
|
||||
*
|
||||
* @event core.viewtopic_get_post_data
|
||||
* @var array sql_ary The SQL array to get the data of posts and posters
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars)));
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -1063,7 +1073,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($poster_id == ANONYMOUS)
|
||||
{
|
||||
$user_cache[$poster_id] = array(
|
||||
$user_cache_data = array(
|
||||
'joined' => '',
|
||||
'posts' => '',
|
||||
'from' => '',
|
||||
@@ -1098,6 +1108,20 @@ while ($row = $db->sql_fetchrow($result))
|
||||
'allow_pm' => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
* Modify the guest user's data displayed with the posts
|
||||
*
|
||||
* @event core.viewtopic_cache_guest_data
|
||||
* @var array user_cache_data Array with the user's data
|
||||
* @var int poster_id Poster's user id
|
||||
* @var array row Array with original user and post data
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('user_cache_data', 'poster_id', 'row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars)));
|
||||
|
||||
$user_cache[$poster_id] = $user_cache_data;
|
||||
|
||||
get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
||||
}
|
||||
else
|
||||
@@ -1112,7 +1136,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||
|
||||
$id_cache[] = $poster_id;
|
||||
|
||||
$user_cache[$poster_id] = array(
|
||||
$user_cache_data = array(
|
||||
'joined' => $user->format_date($row['user_regdate']),
|
||||
'posts' => $row['user_posts'],
|
||||
'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
|
||||
@@ -1150,6 +1174,20 @@ while ($row = $db->sql_fetchrow($result))
|
||||
'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
|
||||
);
|
||||
|
||||
/**
|
||||
* Modify the users' data displayed with their posts
|
||||
*
|
||||
* @event core.viewtopic_cache_user_data
|
||||
* @var array user_cache_data Array with the user's data
|
||||
* @var int poster_id Poster's user id
|
||||
* @var array row Array with original user and post data
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('user_cache_data', 'poster_id', 'row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars)));
|
||||
|
||||
$user_cache[$poster_id] = $user_cache_data;
|
||||
|
||||
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
||||
|
||||
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
||||
@@ -1493,7 +1531,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
|
||||
)));
|
||||
|
||||
//
|
||||
$postrow = array(
|
||||
$post_row = array(
|
||||
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
||||
@@ -1569,13 +1607,28 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
|
||||
'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '',
|
||||
);
|
||||
|
||||
$user_poster_data = $user_cache[$poster_id];
|
||||
|
||||
/**
|
||||
* Modify the posts template block
|
||||
*
|
||||
* @event core.viewtopic_modify_post_row
|
||||
* @var array row Array with original post and user data
|
||||
* @var array cp_row Custom profile field data of the poster
|
||||
* @var array user_poster_data Poster's data from user cache
|
||||
* @var array post_row Template block array of the post
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('row', 'cp_row', 'user_poster_data', 'post_row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars)));
|
||||
|
||||
if (isset($cp_row['row']) && sizeof($cp_row['row']))
|
||||
{
|
||||
$postrow = array_merge($postrow, $cp_row['row']);
|
||||
$post_row = array_merge($post_row, $cp_row['row']);
|
||||
}
|
||||
|
||||
// Dump vars into template
|
||||
$template->assign_block_vars('postrow', $postrow);
|
||||
$template->assign_block_vars('postrow', $post_row);
|
||||
|
||||
if (!empty($cp_row['blockrow']))
|
||||
{
|
||||
@@ -1729,8 +1782,23 @@ if (!request_var('t', 0) && !empty($topic_id))
|
||||
$request->overwrite('t', $topic_id);
|
||||
}
|
||||
|
||||
$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : '');
|
||||
|
||||
/**
|
||||
* You can use this event to modify the page title of the viewtopic page
|
||||
*
|
||||
* @event core.viewtopic_modify_page_title
|
||||
* @var string page_title Title of the index page
|
||||
* @var array topic_data Array with topic data
|
||||
* @var int forum_id Forum ID of the topic
|
||||
* @var int start Start offset used to calculate the page
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('page_title', 'topic_data', 'forum_id', 'start');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));
|
||||
|
||||
// Output the page
|
||||
page_header($topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''), true, $forum_id);
|
||||
page_header($page_title, true, $forum_id);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
|
||||
|
Reference in New Issue
Block a user