1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #4905 from rxu/ticket/15324

[ticket/15324] Add more core and template events
This commit is contained in:
Máté Bartus
2017-09-07 14:39:39 +02:00
committed by GitHub
8 changed files with 112 additions and 7 deletions

View File

@@ -712,7 +712,7 @@ function posting_gen_inline_attachments(&$attachment_data)
*/
function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true)
{
global $template, $config, $phpbb_root_path, $phpEx, $user;
global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;
// Some default template variables
$template->assign_vars(array(
@@ -730,6 +730,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
foreach ($attachment_data as $count => $attach_row)
{
$hidden = '';
$attachrow_template_vars = array();
$attach_row['real_filename'] = utf8_basename($attach_row['real_filename']);
foreach ($attach_row as $key => $value)
@@ -739,7 +740,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false);
$template->assign_block_vars('attach_row', array(
$attachrow_template_vars[(int) $attach_row['attach_id']] = array(
'FILENAME' => utf8_basename($attach_row['real_filename']),
'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])),
'FILE_COMMENT' => $attach_row['attach_comment'],
@@ -749,9 +750,22 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
'FILESIZE' => get_formatted_filesize($attach_row['filesize']),
'U_VIEW_ATTACHMENT' => $download_link,
'S_HIDDEN' => $hidden)
'S_HIDDEN' => $hidden,
);
}
/**
* Modify inline attachments template vars
*
* @event core.modify_inline_attachments_template_vars
* @var array attachment_data Array containing attachments data
* @var array attachrow_template_vars Array containing attachments template vars
* @since 3.2.2-RC1
*/
$vars = array('attachment_data', 'attachrow_template_vars');
extract($phpbb_dispatcher->trigger_event('core.modify_inline_attachments_template_vars', compact($vars)));
$template->assign_block_vars_array('attach_row', $attachrow_template_vars);
}
return sizeof($attachment_data);

View File

@@ -734,9 +734,11 @@ function user_delete($mode, $user_ids, $retain_username = true)
* @var array user_ids IDs of the deleted user
* @var mixed retain_username True if username should be retained
* or false if not
* @var array user_rows Array containing data of the deleted users
* @since 3.1.0-a1
* @changed 3.2.2-RC1 Added user_rows
*/
$vars = array('mode', 'user_ids', 'retain_username');
$vars = array('mode', 'user_ids', 'retain_username', 'user_rows');
extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars)));
// Reset newest user info if appropriate

View File

@@ -1530,7 +1530,7 @@ class parse_message extends bbcode_firstpass
function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false)
{
global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request;
global $phpbb_container;
global $phpbb_container, $phpbb_dispatcher;
$error = array();
@@ -1598,6 +1598,20 @@ class parse_message extends bbcode_firstpass
);
$this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data);
/**
* Modify attachment data on submit
*
* @event core.modify_attachment_data_on_submit
* @var array attachment_data Array containing attachment data
* @since 3.2.2-RC1
*/
$attachment_data = $this->attachment_data;
$vars = array('attachment_data');
extract($phpbb_dispatcher->trigger_event('core.modify_attachment_data_on_submit', compact($vars)));
$this->attachment_data = $attachment_data;
unset($attachment_data);
$this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) {
return '[attachment='.($match[1] + 1).']' . $match[2] . '[/attachment]';
}, $this->message);
@@ -1719,6 +1733,20 @@ class parse_message extends bbcode_firstpass
);
$this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data);
/**
* Modify attachment data on upload
*
* @event core.modify_attachment_data_on_upload
* @var array attachment_data Array containing attachment data
* @since 3.2.2-RC1
*/
$attachment_data = $this->attachment_data;
$vars = array('attachment_data');
extract($phpbb_dispatcher->trigger_event('core.modify_attachment_data_on_upload', compact($vars)));
$this->attachment_data = $attachment_data;
unset($attachment_data);
$this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) {
return '[attachment=' . ($match[1] + 1) . ']' . $match[2] . '[/attachment]';
}, $this->message);