- automatically sync topic_reported when deleting a post [Bug #2152]

- retrieve forum information in report.php
- don't update deleted topics
- proper permission check for "admin or moderator"
- allow changing poster while ip dropdown contains a different user [Bug #2190]
- fixed a typo in acp_styles [Bug #2188]
- allow inserting BBCode at the first position of the textarea [Bug #2078]
- allow the style name to be different than the style path


git-svn-id: file:///svn/phpbb/trunk@6063 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Nils Adermann 2006-06-14 18:59:12 +00:00
parent 771d9f21cb
commit c9e971759d
10 changed files with 53 additions and 52 deletions

View file

@ -141,7 +141,7 @@ if (!empty($load_extensions))
// Include files
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
require($phpbb_root_path . 'includes/acm/acm_main.' . $phpEx);
require($phpbb_root_path . 'includes/cache.' . $phpEx);
require($phpbb_root_path . 'includes/template.' . $phpEx);
require($phpbb_root_path . 'includes/session.' . $phpEx);
require($phpbb_root_path . 'includes/auth.' . $phpEx);

View file

@ -1383,7 +1383,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
$imgsize_bool = (!empty($imgname) && ($imgsize || preg_match('#\*\d+#', $$imgname))) ? true : false;
$img_info = explode('*', $$imgname);
$img_info = explode('*', $imgname);
$template->assign_vars(array(
'S_EDIT_IMAGESET' => true,
@ -1791,7 +1791,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
{
include($phpbb_root_path . 'includes/functions_compress.' . $phpEx);
$path = str_replace(' ', '_', $style_row[$mode . '_name']);
$path = $style_row[$mode . '_path'];
if ($format == 'zip')
{
@ -1947,12 +1947,6 @@ pagination_sep = \'{PAGINATION_SEP}\'
if (!sizeof($error))
{
// Check if the character set is allowed
if (!preg_match('/^[a-z0-9_\-\+ ]+$/i', $name))
{
$error[] = $user->lang[$l_type . '_ERR_NAME_CHARS'];
}
// Check length settings
if (strlen($name) > 30)
{
@ -2216,21 +2210,21 @@ pagination_sep = \'{PAGINATION_SEP}\'
/**
* Store template files into db
*/
function store_templates($mode, $style_id, $name, $filelist)
function store_templates($mode, $style_id, $template_path, $filelist)
{
global $phpbb_root_path, $phpEx, $db;
$path = str_replace(' ', '_', $name) . '/template/';
$template_path = $template_path . '/template/';
$includes = array();
foreach ($filelist as $pathfile => $file_ary)
{
foreach ($file_ary as $file)
{
if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile$file", 'r')))
if (!($fp = fopen("{$phpbb_root_path}styles/$template_path$pathfile$file", 'r')))
{
trigger_error("Could not open {$phpbb_root_path}styles/$path$pathfile$file");
trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file");
}
$template_data = fread($fp, filesize("{$phpbb_root_path}styles/$path$pathfile$file"));
$template_data = fread($fp, filesize("{$phpbb_root_path}styles/$template_path$pathfile$file"));
fclose($fp);
if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches))
@ -2257,10 +2251,10 @@ pagination_sep = \'{PAGINATION_SEP}\'
// heck of a lot of data ...
$sql_ary = array(
'template_id' => $style_id,
'template_filename' => "$pathfile$file",
'template_filename' => "$template_pathfile$file",
'template_included' => (isset($includes[$file])) ? implode(':', $includes[$file]) . ':' : '',
'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile$file"),
'template_data' => file_get_contents("{$phpbb_root_path}styles/$path$pathfile$file"),
'template_mtime' => filemtime("{$phpbb_root_path}styles/$template_path$pathfile$file"),
'template_data' => file_get_contents("{$phpbb_root_path}styles/$template_path$pathfile$file"),
);
if ($mode == 'insert')
@ -2447,11 +2441,11 @@ pagination_sep = \'{PAGINATION_SEP}\'
{
if ($mode == 'style')
{
$this->install_style($error, 'install', $root_path, $style_row['style_id'], $style_row['style_name'], $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row);
$this->install_style($error, 'install', $root_path, $style_row['style_id'], $style_row['style_name'], $install_path, $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row);
}
else
{
$style_row['store_db'] = $this->install_element($mode, $error, 'install', $root_path, $style_row[$mode . '_id'], $style_row[$mode . '_name'], $style_row[$mode . '_copyright'], $style_row['store_db']);
$style_row['store_db'] = $this->install_element($mode, $error, 'install', $root_path, $style_row[$mode . '_id'], $style_row[$mode . '_name'], $install_path, $style_row[$mode . '_copyright'], $style_row['store_db']);
}
if (!sizeof($error))
@ -2707,7 +2701,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
/**
* Install/Add style
*/
function install_style(&$error, $action, $root_path, &$id, $name, $copyright, $active, $default, &$style_row)
function install_style(&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row)
{
global $config, $db, $user;
@ -2718,12 +2712,6 @@ pagination_sep = \'{PAGINATION_SEP}\'
$error[] = $user->lang['STYLE_ERR_STYLE_NAME'];
}
// Check if the character set is allowed
if (!preg_match('/^[a-z0-9_\-\+ ]+$/i', $name))
{
$error[] = $user->lang['STYLE_ERR_NAME_CHARS'];
}
// Check length settings
if (strlen($name) > 30)
{
@ -2759,7 +2747,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
// and do the install if necessary
if (!$style_row[$element . '_id'])
{
$this->install_element($element, $error, $action, $root_path, $style_row[$element . '_id'], $style_row[$element . '_name'], $style_row[$element . '_copyright']);
$this->install_element($element, $error, $action, $root_path, $style_row[$element . '_id'], $style_row[$element . '_name'], $path, $style_row[$element . '_copyright']);
}
}
@ -2808,7 +2796,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
/**
* Install/add an element, doing various checks as we go
*/
function install_element($mode, &$error, $action, $root_path, &$id, $name, $copyright, $store_db = 0)
function install_element($mode, &$error, $action, $root_path, &$id, $name, $path, $copyright, $store_db = 0)
{
global $phpbb_root_path, $db, $user;
@ -2828,19 +2816,12 @@ pagination_sep = \'{PAGINATION_SEP}\'
}
$l_type = strtoupper($mode);
$path = str_replace(' ', '_', $name);
if (!$name)
{
$error[] = $user->lang[$l_type . '_ERR_STYLE_NAME'];
}
// Check if the character set is allowed
if (!preg_match('/^[a-z0-9_\-\+ ]+$/i', $name))
{
$error[] = $user->lang[$l_type . '_ERR_NAME_CHARS'];
}
// Check length settings
if (strlen($name) > 30)
{
@ -2930,7 +2911,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
if ($mode == 'template' && $store_db)
{
$filelist = filelist("{$root_path}template", '', 'html');
$this->store_templates('insert', $id, $name, $filelist);
$this->store_templates('insert', $id, $path, $filelist);
}
$db->sql_transaction('commit');

View file

@ -1157,7 +1157,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT DISTINCT(post_id)
FROM ' . REPORTS_TABLE . '
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
WHERE post_id IN (' . implode(', ', $post_ids) . ')
AND report_closed = 0';
$result = $db->sql_query($sql);
$post_ids = array();

View file

@ -18,10 +18,8 @@
* http://phpjabber.g-blog.net (not many doc comments in here, sorry)
*
* last modified: 27.04.2003 13:01:53 CET
*
*
* Modified by psoTFX, phpBB Group, 2003.
* Removed functions/support not critical to integration with phpBB
* Modified by members of the phpBB Group
*
* @package phpBB3
*/

View file

@ -1139,7 +1139,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
if (!delete_posts('post_id', array($post_id), false, false))
{
// Try to delete topic, we may had an previous error causing inconsistency
if ($post_mode = 'delete_topic')
if ($post_mode == 'delete_topic')
{
delete_topics('topic_id', array($topic_id), false);
}
@ -1148,7 +1148,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$db->sql_transaction('commit');
// Collect the necessary informations for updating the tables
// Collect the necessary information for updating the tables
$sql_data[FORUMS_TABLE] = '';
switch ($post_mode)
{
@ -1168,8 +1168,6 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
$sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
break;
case 'delete_first_post':
@ -1291,6 +1289,11 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
}
}
if ($data['post_reported'] && ($post_mode != 'delete_topic'))
{
sync('topic_reported', 'topic_id', array($topic_id));
}
return $next_post_id;
}

View file

@ -57,10 +57,16 @@ function mcp_post_details($id, $mode, $action)
case 'chgposter':
case 'chgposter_ip':
$username = request_var('username', '', true);
$new_user_id = request_var('u', 0);
$sql_where = ($new_user_id) ? 'user_id = ' . $new_user_id : "username = '" . $db->sql_escape($username) . "'";
if ($action == 'chgposter')
{
$username = request_var('username', '', true);
$sql_where = "username = '" . $db->sql_escape($username) . "'";
}
else
{
$new_user_id = request_var('u', 0);
$sql_where = 'user_id = ' . $new_user_id;
}
$sql = 'SELECT *
FROM ' . USERS_TABLE . '

View file

@ -1113,7 +1113,7 @@ class parse_message extends bbcode_firstpass
if ($submit && in_array($mode, array('post', 'reply', 'quote', 'edit')) && $upload_file)
{
if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_'))
if ($num_attachments < $cfg['max_attachments'] || $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id))
{
$filedata = upload_attachment($form_name, $forum_id, false, '', $is_message);
$error = $filedata['error'];

View file

@ -1256,6 +1256,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data)
'topic_approved' => $post_data['topic_approved'],
'topic_type' => $post_data['topic_type'],
'post_approved' => $post_data['post_approved'],
'post_reported' => $post_data['post_reported'],
'post_time' => $post_data['post_time'],
'poster_id' => $post_data['poster_id']
);

View file

@ -59,6 +59,17 @@ if (!$report_data)
$forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
$topic_id = (int) $report_data['topic_id'];
$sql = 'SELECT *
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql);
$forum_data = $db->sql_fetchrow($result);
if (!$forum_data)
{
trigger_error('FORUM_NOT_EXIST');
}
// Check required permissions
$acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
@ -140,7 +151,7 @@ $template->assign_vars(array(
'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false)
);
generate_forum_nav($report_data);
generate_forum_nav($forum_data);
// Start output of page
page_header($user->lang['REPORT_POST']);

View file

@ -147,12 +147,12 @@ function bbfontstyle(bbopen, bbclose)
*/
function insert_text(text)
{
if (document.forms[form_name].elements[text_name].createTextRange && document.forms[form_name].elements[text_name].caretPos)
if (document.forms[form_name].elements[text_name].createTextRange && !isNaN(document.forms[form_name].elements[text_name].caretPos))
{
var caretPos = document.forms[form_name].elements[text_name].caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
}
else if (document.forms[form_name].elements[text_name].selectionStart)
else if (!isNaN(document.forms[form_name].elements[text_name].selectionStart))
{
var selStart = document.forms[form_name].elements[text_name].selectionStart;
var selEnd = document.forms[form_name].elements[text_name].selectionEnd;