1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

To all people having their bug status set to fixed: SF pserver CVS access is currently down, therefore the snapshots are still out of date.

- fix a bunch of bugs
- <!-- $Id$ --> is no longer allowed in template (.html) files
- changed layout of private message screens (folders are menu items)
- removed unread mode for private messages
- added new feature to template engine - "jump out of loop" or "loop another loop within my loop" :D (will be documented within the coding guidelines)
- added autologin field to sessions
- check session length checks
- added add_log statement to sessions to track session valid to invalid changes if ip/browser change depending on config settings (only debug)
- added multibyte support for various variables (exception at the moment is usernames which needs some discussion)
- hopefully not broke something. :/


git-svn-id: file:///svn/phpbb/trunk@5765 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2006-04-06 17:15:45 +00:00
parent 3933f0bab3
commit 431e494ae4
133 changed files with 613 additions and 661 deletions

View File

@@ -19,9 +19,8 @@ class ucp_pm_info
'title' => 'UCP_PM',
'version' => '1.0.0',
'modes' => array(
'view' => array('title' => 'UCP_PM_VIEW', 'auth' => 'cfg_allow_privmsg'),
'view' => array('title' => 'UCP_PM_VIEW', 'auth' => 'cfg_allow_privmsg', 'display' => false),
'compose' => array('title' => 'UCP_PM_COMPOSE', 'auth' => 'cfg_allow_privmsg'),
'unread' => array('title' => 'UCP_PM_UNREAD', 'auth' => 'cfg_allow_privmsg'),
'drafts' => array('title' => 'UCP_PM_DRAFTS', 'auth' => 'cfg_allow_privmsg'),
'options' => array('title' => 'UCP_PM_OPTIONS', 'auth' => 'cfg_allow_privmsg'),
'popup' => array('title' => 'UCP_PM_POPUP_TITLE', 'auth' => 'cfg_allow_privmsg', 'display' => false),

View File

@@ -486,26 +486,30 @@ class ucp_groups
}
}
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
// were made.
$group_attributes = array();
$test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height');
foreach ($test_variables as $test)
if (!sizeof($error))
{
if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test]))
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
// were made.
$group_attributes = array();
$test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height');
foreach ($test_variables as $test)
{
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test]))
{
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
}
}
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
{
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($user->lang[$message] . $return_page);
}
}
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
{
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($user->lang[$message] . $return_page);
}
else
if (sizeof($error))
{
$group_rank = $submit_ary['rank'];

View File

@@ -543,7 +543,7 @@ class ucp_main
// Get folder img, topic status/type related informations
$folder_img = $folder_alt = $topic_type = '';
$unread_topic = false; // TODO: get proper unread status
$unread_topic = false;
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
$view_topic_url = "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id";

View File

@@ -16,7 +16,6 @@
* @param inbox|outbox|sentbox display folder with the associated name
*
*
* Display Unread Messages - mode=unread
* Display Messages (default to inbox) - mode=view
* Display single message - mode=view&p=[msg_id] or &p=[msg_id] (short linkage)
*
@@ -101,7 +100,7 @@ class ucp_pm
);
$tpl_file = 'ucp_pm_popup';
break;
break;
// Compose message
case 'compose':
@@ -118,7 +117,7 @@ class ucp_pm
compose_pm($id, $mode, $action);
$tpl_file = 'posting_body';
break;
break;
case 'options':
$sql = 'SELECT group_message_limit
@@ -136,7 +135,7 @@ class ucp_pm
message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions);
$tpl_file = 'ucp_pm_options';
break;
break;
case 'drafts':
@@ -155,7 +154,6 @@ class ucp_pm
break;
case 'unread':
case 'view':
$sql = 'SELECT group_message_limit
@@ -181,7 +179,7 @@ class ucp_pm
$msg_id = request_var('p', 0);
$view = request_var('view', '');
// if ($msg_id && $action == 'view_folder')
// View message if specified
if ($msg_id)
{
$action = 'view_message';
@@ -200,12 +198,23 @@ class ucp_pm
// First Handle Mark actions and moving messages
$submit_mark = (isset($_POST['submit_mark'])) ? true : false;
$move_pm = (isset($_POST['move_pm'])) ? true : false;
$mark_option = request_var('mark_option', '');
$dest_folder = request_var('dest_folder', PRIVMSGS_NO_BOX);
// Is moving PM triggered through mark options?
if (!in_array($mark_option, array('mark_important', 'delete_marked')) && $submit_mark)
{
$move_pm = true;
$dest_folder = (int) $mark_option;
$submit_mark = false;
}
// Move PM
if (isset($_REQUEST['move_pm']))
if ($move_pm)
{
$move_msg_ids = (isset($_POST['marked_msg_id'])) ? array_map('intval', $_POST['marked_msg_id']) : array();
$dest_folder = request_var('dest_folder', PRIVMSGS_NO_BOX);
$cur_folder_id = request_var('cur_folder_id', PRIVMSGS_NO_BOX);
if (move_pm($user->data['user_id'], $user->data['message_limit'], $move_msg_ids, $dest_folder, $cur_folder_id))
@@ -221,9 +230,9 @@ class ucp_pm
}
// Message Mark Options
if (isset($_REQUEST['submit_mark']))
if ($submit_mark)
{
handle_mark_actions($user->data['user_id'], request_var('mark_option', ''));
handle_mark_actions($user->data['user_id'], $mark_option);
}
// If new messages arrived, place them into the appropiate folder
@@ -234,7 +243,7 @@ class ucp_pm
$num_not_moved = $user->data['user_new_privmsg'];
}
if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX && $mode != 'unread')
if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX)
{
$folder_id = PRIVMSGS_INBOX;
}
@@ -244,8 +253,11 @@ class ucp_pm
FROM ' . PRIVMSGS_TO_TABLE . "
WHERE msg_id = $msg_id
AND user_id = " . $user->data['user_id'];
$result = $db->sql_query_limit($sql, 1);
if (!($row = $db->sql_fetchrow($result)))
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row)
{
trigger_error('NO_MESSAGE');
}
@@ -256,7 +268,6 @@ class ucp_pm
if ($action == 'view_message' && $msg_id)
{
// Get Message user want to see
if ($view == 'next' || $view == 'previous')
{
$sql_condition = ($view == 'next') ? '>' : '<';
@@ -271,8 +282,10 @@ class ucp_pm
AND p.message_time $sql_condition p2.message_time
ORDER BY p.message_time $sql_ordering";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!($row = $db->sql_fetchrow($result)))
if (!$row)
{
$message = ($view == 'next') ? 'NO_NEWER_PM' : 'NO_OLDER_PM';
trigger_error($message);
@@ -290,9 +303,11 @@ class ucp_pm
AND t.folder_id = $folder_id
AND t.msg_id = p.msg_id
AND p.msg_id = $msg_id";
$result = $db->sql_query_limit($sql, 1);
$result = $db->sql_query($sql);
$message_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!($message_row = $db->sql_fetchrow($result)))
if (!$message_row)
{
trigger_error('NO_MESSAGE');
}
@@ -306,7 +321,7 @@ class ucp_pm
$s_folder_options = $s_to_folder_options = '';
foreach ($folder as $f_id => $folder_ary)
{
$option = '<option' . ((!in_array($f_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX))) ? ' class="blue"' : '') . ' value="' . $f_id . '"' . ((($f_id == $folder_id && $mode != 'unread') || ($f_id === 'unread' && $mode == 'unread')) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . '</option>';
$option = '<option' . ((!in_array($f_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX))) ? ' class="blue"' : '') . ' value="' . $f_id . '"' . (($f_id == $folder_id) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . '</option>';
$s_to_folder_options .= ($f_id != PRIVMSGS_OUTBOX && $f_id != PRIVMSGS_SENTBOX) ? $option : '';
$s_folder_options .= $option;
@@ -338,25 +353,25 @@ class ucp_pm
'S_IN_OUTBOX' => ($folder_id == PRIVMSGS_OUTBOX) ? true : false,
'S_IN_SENTBOX' => ($folder_id == PRIVMSGS_SENTBOX) ? true : false,
'FOLDER_STATUS' => $folder_status['message'],
'FOLDER_MAX_MESSAGES' => $folder_status['max'],
'FOLDER_CUR_MESSAGES' => $folder_status['cur'],
'FOLDER_STATUS' => $folder_status['message'],
'FOLDER_MAX_MESSAGES' => $folder_status['max'],
'FOLDER_CUR_MESSAGES' => $folder_status['cur'],
'FOLDER_REMAINING_MESSAGES' => $folder_status['remaining'],
'FOLDER_PERCENT' => $folder_status['percent'])
'FOLDER_PERCENT' => $folder_status['percent'])
);
if ($mode == 'unread' || $action == 'view_folder')
if ($action == 'view_folder')
{
include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.'.$phpEx);
view_folder($id, $mode, $folder_id, $folder, (($mode == 'unread') ? 'unread' : 'folder'));
view_folder($id, $mode, $folder_id, $folder);
$tpl_file = 'ucp_pm_viewfolder';
}
else if ($action == 'view_message')
{
$template->assign_vars(array(
'S_VIEW_MESSAGE'=> true,
'MSG_ID' => $msg_id)
'S_VIEW_MESSAGE' => true,
'MSG_ID' => $msg_id)
);
if (!$msg_id)
@@ -370,7 +385,7 @@ class ucp_pm
$tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage';
}
break;
break;
default:
trigger_error('NO_ACTION_MODE');

View File

@@ -413,16 +413,14 @@ function compose_pm($id, $mode, $action)
if ($submit || $preview || $refresh)
{
$subject = request_var('subject', '');
$subject = request_var('subject', '', true);
if (strcmp($subject, strtoupper($subject)) == 0 && $subject)
{
$subject = strtolower($subject);
}
$subject = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $subject);
$message_parser->message = (isset($_POST['message'])) ? htmlspecialchars(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message'])) : '';
$message_parser->message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $message_parser->message);
$message_parser->message = request_var('message', '', true);
$icon_id = request_var('icon', 0);
@@ -502,7 +500,7 @@ function compose_pm($id, $mode, $action)
unset($message_parser);
// ((!$message_subject) ? $subject : $message_subject)
$msg_id = submit_pm($action, $subject, $pm_data, $update_message);
$msg_id = submit_pm($action, $subject, $pm_data, true);
$return_message_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=view&amp;p=" . $msg_id;
$return_folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=outbox";

View File

@@ -56,7 +56,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
// Add Folder
if (isset($_POST['addfolder']))
{
$folder_name = request_var('foldername', '');
$folder_name = request_var('foldername', '', true);
if ($folder_name)
{
@@ -97,7 +97,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
// Rename folder
if (isset($_POST['rename_folder']))
{
$new_folder_name = request_var('new_folder_name', '');
$new_folder_name = request_var('new_folder_name', '', true);
$rename_folder_id= request_var('rename_folder_id', 0);
if (!$new_folder_name)
@@ -240,7 +240,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$rule_option = request_var('rule_option', 0);
$cond_option = request_var('cond_option', '');
$action_option = explode('|', request_var('action_option', ''));
$rule_string = ($cond_option != 'none') ? request_var('rule_string', '') : '';
$rule_string = ($cond_option != 'none') ? request_var('rule_string', '', true) : '';
$rule_user_id = ($cond_option != 'none') ? request_var('rule_user_id', 0) : 0;
$rule_group_id = ($cond_option != 'none') ? request_var('rule_group_id', 0) : 0;
@@ -620,7 +620,7 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
switch ($condition)
{
case 'text':
$rule_string = request_var('rule_string', '');
$rule_string = request_var('rule_string', '', true);
$template->assign_vars(array(
'S_TEXT_CONDITION' => true,
@@ -634,7 +634,7 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
case 'user':
$rule_user_id = request_var('rule_user_id', 0);
$rule_string = request_var('rule_string', '');
$rule_string = request_var('rule_string', '', true);
if ($rule_string && !$rule_user_id)
{
@@ -677,7 +677,7 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
case 'group':
$rule_group_id = request_var('rule_group_id', 0);
$rule_string = request_var('rule_string', '');
$rule_string = request_var('rule_string', '', true);
$sql_and = ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? '<> ' . GROUP_SPECIAL : 'NOT IN (' . GROUP_SPECIAL . ', ' . GROUP_HIDDEN . ')';
$sql = 'SELECT group_id, group_name, group_type

View File

@@ -12,14 +12,14 @@
* View message folder
* Called from ucp_pm with mode == 'view' && action == 'view_folder'
*/
function view_folder($id, $mode, $folder_id, $folder, $type)
function view_folder($id, $mode, $folder_id, $folder)
{
global $user, $template, $auth, $db, $cache;
global $phpbb_root_path, $config, $phpEx, $SID;
$submit_export = (isset($_POST['submit_export'])) ? true : false;
$folder_info = get_pm_from($folder_id, $folder, $user->data['user_id'], "{$phpbb_root_path}ucp.$phpEx$SID", $type);
$folder_info = get_pm_from($folder_id, $folder, $user->data['user_id'], "{$phpbb_root_path}ucp.$phpEx$SID");
if (!$submit_export)
{
@@ -48,6 +48,20 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
$s_mark_options .= '<option value="' . $mark_option . '">' . $user->lang[strtoupper($mark_option)] . '</option>';
}
// We do the folder moving options here too, for template authors to use...
$s_folder_move_options = '';
foreach ($folder as $f_id => $folder_ary)
{
if ($f_id == PRIVMSGS_OUTBOX || $f_id == PRIVMSGS_SENTBOX || $f_id == $folder_id)
{
continue;
}
$s_folder_move_options .= '<option' . (($f_id != PRIVMSGS_INBOX) ? ' class="blue"' : '') . ' value="' . $f_id . '">';
$s_folder_move_options .= sprintf($user->lang['MOVE_MARKED_TO_FOLDER'], $folder_ary['folder_name']);
$s_folder_move_options .= (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . '</option>';
}
$friend = $foe = array();
// Get friends and foes
@@ -64,8 +78,8 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_UNREAD' => ($type == 'unread'),
'S_MARK_OPTIONS'=> $s_mark_options)
'S_MARK_OPTIONS' => $s_mark_options,
'S_MOVE_MARKED_OPTIONS' => $s_folder_move_options)
);
// Okay, lets dump out the page ...
@@ -344,10 +358,8 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
/**
* Get Messages from folder/user
*
* @param unread|new|folder $type type of message
*/
function get_pm_from($folder_id, $folder, $user_id, $url, $type = 'folder')
function get_pm_from($folder_id, $folder, $user_id, $url)
{
global $user, $db, $template, $config, $auth, $_POST;
@@ -368,16 +380,7 @@ function get_pm_from($folder_id, $folder, $user_id, $url, $type = 'folder')
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
if ($type != 'folder')
{
$folder_sql = ($type == 'unread') ? 't.unread = 1' : 't.new = 1';
$folder_sql .= ' AND t.folder_id NOT IN (' . PRIVMSGS_HOLD_BOX . ', ' . PRIVMSGS_NO_BOX . ')';
$folder_id = PRIVMSGS_INBOX;
}
else
{
$folder_sql = 't.folder_id = ' . (int) $folder_id;
}
$folder_sql = 't.folder_id = ' . (int) $folder_id;
// Limit pms to certain time frame, obtain correct pm count
if ($sort_days)
@@ -404,32 +407,7 @@ function get_pm_from($folder_id, $folder, $user_id, $url, $type = 'folder')
}
else
{
if ($type == 'folder')
{
$pm_count = $folder[$folder_id]['num_messages'];
}
else
{
if (in_array($folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)))
{
$sql = 'SELECT COUNT(t.msg_id) AS pm_count
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p
WHERE $folder_sql
AND t.user_id = $user_id
AND t.msg_id = p.msg_id";
}
else
{
$sql = 'SELECT pm_count
FROM ' . PRIVMSGS_FOLDER_TABLE . "
WHERE folder_id = $folder_id
AND user_id = $user_id";
}
$result = $db->sql_query_limit($sql, 1);
$pm_count = ($row = $db->sql_fetchrow($result)) ? $row['pm_count'] : 0;
$db->sql_freeresult($result);
}
$pm_count = $folder[$folder_id]['num_messages'];
$sql_limit_time = '';
}

View File

@@ -255,7 +255,7 @@ class ucp_profile
foreach ($var_ary as $var => $default)
{
$data[$var] = request_var($var, $default);
$data[$var] = (in_array($var, array('location', 'occupation', 'interests'))) ? request_var($var, $default, true) : request_var($var, $default);
}
$var_ary = array(
@@ -407,7 +407,7 @@ class ucp_profile
$enable_bbcode = ($config['allow_sig_bbcode']) ? request_var('enable_bbcode', $user->optionget('bbcode')) : false;
$enable_smilies = ($config['allow_sig_smilies']) ? request_var('enable_smilies', $user->optionget('smilies')) : false;
$enable_urls = request_var('enable_urls', true);
$signature = request_var('signature', $user->data['user_sig']);
$signature = request_var('signature', $user->data['user_sig'], true);
if ($submit || $preview)
{

View File

@@ -27,7 +27,6 @@ class ucp_register
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
// Do not alter this first one to use request_var!
$confirm_id = request_var('confirm_id', '');
$coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false;
$agreed = (!empty($_POST['agreed'])) ? 1 : 0;