Augmentation vers version 3.3.0
This commit is contained in:
205
install/update/old/includes/ucp/ucp_attachments.php
Normal file
205
install/update/old/includes/ucp/ucp_attachments.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ucp_attachments
|
||||
* User attachments
|
||||
*/
|
||||
class ucp_attachments
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request;
|
||||
|
||||
$start = $request->variable('start', 0);
|
||||
$sort_key = $request->variable('sk', 'a');
|
||||
$sort_dir = $request->variable('sd', 'a');
|
||||
|
||||
$delete = (isset($_POST['delete'])) ? true : false;
|
||||
$delete_ids = array_keys($request->variable('attachment', array(0)));
|
||||
|
||||
if ($delete && count($delete_ids))
|
||||
{
|
||||
// Validate $delete_ids...
|
||||
$sql = 'SELECT attach_id
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE poster_id = ' . $user->data['user_id'] . '
|
||||
AND is_orphan = 0
|
||||
AND ' . $db->sql_in_set('attach_id', $delete_ids);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$delete_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$delete_ids[] = $row['attach_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if ($delete && count($delete_ids))
|
||||
{
|
||||
$s_hidden_fields = array(
|
||||
'delete' => 1
|
||||
);
|
||||
|
||||
foreach ($delete_ids as $attachment_id)
|
||||
{
|
||||
$s_hidden_fields['attachment'][$attachment_id] = 1;
|
||||
}
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
/** @var \phpbb\attachment\manager $attachment_manager */
|
||||
$attachment_manager = $phpbb_container->get('attachment.manager');
|
||||
$attachment_manager->delete('attach', $delete_ids);
|
||||
unset($attachment_manager);
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = ((count($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, (count($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
|
||||
}
|
||||
}
|
||||
|
||||
// Select box eventually
|
||||
$sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']);
|
||||
$sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
|
||||
|
||||
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
|
||||
|
||||
$s_sort_key = '';
|
||||
foreach ($sort_key_text as $key => $value)
|
||||
{
|
||||
$selected = ($sort_key == $key) ? ' selected="selected"' : '';
|
||||
$s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
|
||||
}
|
||||
|
||||
$s_sort_dir = '';
|
||||
foreach ($sort_dir_text as $key => $value)
|
||||
{
|
||||
$selected = ($sort_dir == $key) ? ' selected="selected"' : '';
|
||||
$s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
|
||||
}
|
||||
|
||||
if (!isset($sort_key_sql[$sort_key]))
|
||||
{
|
||||
$sort_key = 'a';
|
||||
}
|
||||
|
||||
$order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
|
||||
|
||||
$sql = 'SELECT COUNT(attach_id) as num_attachments
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE poster_id = ' . $user->data['user_id'] . '
|
||||
AND is_orphan = 0';
|
||||
$result = $db->sql_query($sql);
|
||||
$num_attachments = $db->sql_fetchfield('num_attachments');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Ensure start is a valid value
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);
|
||||
|
||||
$sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
|
||||
FROM ' . ATTACHMENTS_TABLE . ' a
|
||||
LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
|
||||
LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)
|
||||
WHERE a.poster_id = ' . $user->data['user_id'] . "
|
||||
AND a.is_orphan = 0
|
||||
ORDER BY $order_by";
|
||||
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
||||
|
||||
$row_count = 0;
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_var('S_ATTACHMENT_ROWS', true);
|
||||
|
||||
do
|
||||
{
|
||||
if ($row['in_message'])
|
||||
{
|
||||
$view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}";
|
||||
}
|
||||
|
||||
$template->assign_block_vars('attachrow', array(
|
||||
'ROW_NUMBER' => $row_count + ($start + 1),
|
||||
'FILENAME' => $row['real_filename'],
|
||||
'COMMENT' => bbcode_nl2br($row['attach_comment']),
|
||||
'EXTENSION' => $row['extension'],
|
||||
'SIZE' => get_formatted_filesize($row['filesize']),
|
||||
'DOWNLOAD_COUNT' => $row['download_count'],
|
||||
'POST_TIME' => $user->format_date($row['filetime']),
|
||||
'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'],
|
||||
|
||||
'ATTACH_ID' => $row['attach_id'],
|
||||
'POST_ID' => $row['post_msg_id'],
|
||||
'TOPIC_ID' => $row['topic_id'],
|
||||
|
||||
'S_IN_MESSAGE' => $row['in_message'],
|
||||
|
||||
'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
|
||||
'U_VIEW_TOPIC' => $view_topic)
|
||||
);
|
||||
|
||||
$row_count++;
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir";
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'TOTAL_ATTACHMENTS' => $num_attachments,
|
||||
'NUM_ATTACHMENTS' => $user->lang('NUM_ATTACHMENTS', $num_attachments),
|
||||
|
||||
'L_TITLE' => $user->lang['UCP_ATTACHMENTS'],
|
||||
|
||||
'U_SORT_FILENAME' => $this->u_action . "&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
'U_SORT_FILE_COMMENT' => $this->u_action . "&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
'U_SORT_EXTENSION' => $this->u_action . "&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
'U_SORT_FILESIZE' => $this->u_action . "&sk=d&sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
'U_SORT_DOWNLOADS' => $this->u_action . "&sk=e&sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
'U_SORT_POST_TIME' => $this->u_action . "&sk=f&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||
|
||||
'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false,
|
||||
'S_DISPLAY_PAGINATION' => ($num_attachments) ? true : false,
|
||||
'S_UCP_ACTION' => $this->u_action,
|
||||
'S_SORT_OPTIONS' => $s_sort_key,
|
||||
'S_ORDER_SELECT' => $s_sort_dir)
|
||||
);
|
||||
|
||||
$this->tpl_name = 'ucp_attachments';
|
||||
$this->page_title = 'UCP_ATTACHMENTS';
|
||||
}
|
||||
}
|
||||
1137
install/update/old/includes/ucp/ucp_groups.php
Normal file
1137
install/update/old/includes/ucp/ucp_groups.php
Normal file
File diff suppressed because it is too large
Load Diff
435
install/update/old/includes/ucp/ucp_pm.php
Normal file
435
install/update/old/includes/ucp/ucp_pm.php
Normal file
@@ -0,0 +1,435 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private Message Class
|
||||
*
|
||||
* $_REQUEST['folder'] display folder with the id used
|
||||
* $_REQUEST['folder'] inbox|outbox|sentbox display folder with the associated name
|
||||
*
|
||||
* Display Messages (default to inbox) - mode=view
|
||||
* Display single message - mode=view&p=[msg_id] or &p=[msg_id] (short linkage)
|
||||
*
|
||||
* if the folder id with (&f=[folder_id]) is used when displaying messages, one query will be saved. If it is not used, phpBB needs to grab
|
||||
* the folder id first in order to display the input boxes and folder names and such things. ;) phpBB always checks this against the database to make
|
||||
* sure the user is able to view the message.
|
||||
*
|
||||
* Composing Messages (mode=compose):
|
||||
* To specific user (u=[user_id])
|
||||
* To specific group (g=[group_id])
|
||||
* Quoting a post (action=quotepost&p=[post_id])
|
||||
* Quoting a PM (action=quote&p=[msg_id])
|
||||
* Forwarding a PM (action=forward&p=[msg_id])
|
||||
*/
|
||||
class ucp_pm
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request;
|
||||
|
||||
if (!$user->data['is_registered'])
|
||||
{
|
||||
trigger_error('NO_MESSAGE');
|
||||
}
|
||||
|
||||
// Is PM disabled?
|
||||
if (!$config['allow_privmsg'])
|
||||
{
|
||||
trigger_error('PM_DISABLED');
|
||||
}
|
||||
|
||||
$user->add_lang('posting');
|
||||
$template->assign_var('S_PRIVMSGS', true);
|
||||
|
||||
// Folder directly specified?
|
||||
$folder_specified = $request->variable('folder', '');
|
||||
|
||||
if (!in_array($folder_specified, array('inbox', 'outbox', 'sentbox')))
|
||||
{
|
||||
$folder_specified = (int) $folder_specified;
|
||||
}
|
||||
else
|
||||
{
|
||||
$folder_specified = ($folder_specified == 'inbox') ? PRIVMSGS_INBOX : (($folder_specified == 'outbox') ? PRIVMSGS_OUTBOX : PRIVMSGS_SENTBOX);
|
||||
}
|
||||
|
||||
if (!$folder_specified)
|
||||
{
|
||||
$mode = (!$mode) ? $request->variable('mode', 'view') : $mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mode = 'view';
|
||||
}
|
||||
|
||||
if (!function_exists('get_folder'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
||||
}
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
// Compose message
|
||||
case 'compose':
|
||||
$action = $request->variable('action', 'post');
|
||||
|
||||
$user_folders = get_folder($user->data['user_id']);
|
||||
|
||||
if ($action != 'delete' && !$auth->acl_get('u_sendpm'))
|
||||
{
|
||||
// trigger_error('NO_AUTH_SEND_MESSAGE');
|
||||
$template->assign_vars(array(
|
||||
'S_NO_AUTH_SEND_MESSAGE' => true,
|
||||
'S_COMPOSE_PM_VIEW' => true,
|
||||
));
|
||||
|
||||
$tpl_file = 'ucp_pm_viewfolder';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!function_exists('compose_pm'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx);
|
||||
}
|
||||
compose_pm($id, $mode, $action, $user_folders);
|
||||
|
||||
$tpl_file = 'posting_body';
|
||||
break;
|
||||
|
||||
case 'options':
|
||||
set_user_message_limit();
|
||||
get_folder($user->data['user_id']);
|
||||
|
||||
if (!function_exists('message_options'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx);
|
||||
}
|
||||
message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions);
|
||||
|
||||
$tpl_file = 'ucp_pm_options';
|
||||
break;
|
||||
|
||||
case 'drafts':
|
||||
|
||||
get_folder($user->data['user_id']);
|
||||
$this->p_name = 'pm';
|
||||
|
||||
if (!class_exists('ucp_main'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx);
|
||||
}
|
||||
|
||||
$module = new ucp_main($this);
|
||||
$module->u_action = $this->u_action;
|
||||
$module->main($id, $mode);
|
||||
|
||||
$this->tpl_name = $module->tpl_name;
|
||||
$this->page_title = 'UCP_PM_DRAFTS';
|
||||
|
||||
unset($module);
|
||||
return;
|
||||
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
|
||||
set_user_message_limit();
|
||||
|
||||
if ($folder_specified)
|
||||
{
|
||||
$folder_id = $folder_specified;
|
||||
$action = 'view_folder';
|
||||
}
|
||||
else
|
||||
{
|
||||
$folder_id = $request->variable('f', PRIVMSGS_NO_BOX);
|
||||
$action = $request->variable('action', 'view_folder');
|
||||
}
|
||||
|
||||
$msg_id = $request->variable('p', 0);
|
||||
$view = $request->variable('view', '');
|
||||
|
||||
// View message if specified
|
||||
if ($msg_id)
|
||||
{
|
||||
$action = 'view_message';
|
||||
}
|
||||
|
||||
if (!$auth->acl_get('u_readpm'))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NO_AUTH_READ_MESSAGE');
|
||||
}
|
||||
|
||||
if ($view == 'print' && (!$config['print_pm'] || !$auth->acl_get('u_pm_printpm')))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NO_AUTH_PRINT_MESSAGE');
|
||||
}
|
||||
|
||||
// Do not allow hold messages to be seen
|
||||
if ($folder_id == PRIVMSGS_HOLD_BOX)
|
||||
{
|
||||
trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
|
||||
}
|
||||
|
||||
// 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->variable('mark_option', '');
|
||||
$dest_folder = $request->variable('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 ($move_pm)
|
||||
{
|
||||
$move_msg_ids = (isset($_POST['marked_msg_id'])) ? $request->variable('marked_msg_id', array(0)) : array();
|
||||
$cur_folder_id = $request->variable('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))
|
||||
{
|
||||
// Return to folder view if single message moved
|
||||
if ($action == 'view_message')
|
||||
{
|
||||
$msg_id = 0;
|
||||
$folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);
|
||||
$action = 'view_folder';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Message Mark Options
|
||||
if ($submit_mark)
|
||||
{
|
||||
handle_mark_actions($user->data['user_id'], $mark_option);
|
||||
}
|
||||
|
||||
// If new messages arrived, place them into the appropriate folder
|
||||
$num_not_moved = $num_removed = 0;
|
||||
$release = $request->variable('release', 0);
|
||||
|
||||
if ($user->data['user_new_privmsg'] && ($action == 'view_folder' || $action == 'view_message'))
|
||||
{
|
||||
$return = place_pm_into_folder($global_privmsgs_rules, $release);
|
||||
$num_not_moved = $return['not_moved'];
|
||||
$num_removed = $return['removed'];
|
||||
}
|
||||
|
||||
if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX)
|
||||
{
|
||||
$folder_id = PRIVMSGS_INBOX;
|
||||
}
|
||||
else if ($msg_id && $folder_id == PRIVMSGS_NO_BOX)
|
||||
{
|
||||
$sql = 'SELECT folder_id
|
||||
FROM ' . PRIVMSGS_TO_TABLE . "
|
||||
WHERE msg_id = $msg_id
|
||||
AND folder_id <> " . PRIVMSGS_NO_BOX . '
|
||||
AND user_id = ' . $user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_MESSAGE');
|
||||
}
|
||||
$folder_id = (int) $row['folder_id'];
|
||||
}
|
||||
|
||||
if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_pms_read'))
|
||||
{
|
||||
mark_folder_read($user->data['user_id'], $folder_id);
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang['PM_MARK_ALL_READ_SUCCESS'];
|
||||
|
||||
if ($request->is_ajax())
|
||||
{
|
||||
$json_response = new \phpbb\json_response();
|
||||
$json_response->send(array(
|
||||
'MESSAGE_TITLE' => $user->lang['INFORMATION'],
|
||||
'MESSAGE_TEXT' => $message,
|
||||
'success' => true,
|
||||
));
|
||||
}
|
||||
$message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
|
||||
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
$message_row = array();
|
||||
if ($action == 'view_message' && $msg_id)
|
||||
{
|
||||
// Get Message user want to see
|
||||
if ($view == 'next' || $view == 'previous')
|
||||
{
|
||||
$sql_condition = ($view == 'next') ? '>' : '<';
|
||||
$sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
|
||||
|
||||
$sql = 'SELECT t.msg_id
|
||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TABLE . " p2
|
||||
WHERE p2.msg_id = $msg_id
|
||||
AND t.folder_id = $folder_id
|
||||
AND t.user_id = " . $user->data['user_id'] . "
|
||||
AND t.msg_id = p.msg_id
|
||||
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)
|
||||
{
|
||||
$message = ($view == 'next') ? 'NO_NEWER_PM' : 'NO_OLDER_PM';
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg_id = $row['msg_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT t.*, p.*, u.*
|
||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||
WHERE t.user_id = ' . $user->data['user_id'] . "
|
||||
AND p.author_id = u.user_id
|
||||
AND t.folder_id = $folder_id
|
||||
AND t.msg_id = p.msg_id
|
||||
AND p.msg_id = $msg_id";
|
||||
$result = $db->sql_query($sql);
|
||||
$message_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$message_row)
|
||||
{
|
||||
trigger_error('NO_MESSAGE');
|
||||
}
|
||||
|
||||
// Update unread status
|
||||
update_unread_status($message_row['pm_unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id);
|
||||
}
|
||||
|
||||
$folder = get_folder($user->data['user_id'], $folder_id);
|
||||
|
||||
$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="sep"' : '') . ' 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;
|
||||
}
|
||||
clean_sentbox($folder[PRIVMSGS_SENTBOX]['num_messages']);
|
||||
|
||||
// Header for message view - folder and so on
|
||||
$folder_status = get_folder_status($folder_id, $folder);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'CUR_FOLDER_ID' => $folder_id,
|
||||
'CUR_FOLDER_NAME' => $folder_status['folder_name'],
|
||||
'NUM_NOT_MOVED' => $num_not_moved,
|
||||
'NUM_REMOVED' => $num_removed,
|
||||
'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '<a href="' . $this->u_action . '&folder=' . $folder_id . '&release=1">', '</a>'),
|
||||
'NOT_MOVED_MESSAGES' => $user->lang('NOT_MOVED_MESSAGES', (int) $num_not_moved),
|
||||
'RULE_REMOVED_MESSAGES' => $user->lang('RULE_REMOVED_MESSAGES', (int) $num_removed),
|
||||
|
||||
'S_FOLDER_OPTIONS' => $s_folder_options,
|
||||
'S_TO_FOLDER_OPTIONS' => $s_to_folder_options,
|
||||
'S_FOLDER_ACTION' => $this->u_action . '&action=view_folder',
|
||||
'S_PM_ACTION' => $this->u_action . '&action=' . $action,
|
||||
|
||||
'U_INBOX' => $this->u_action . '&folder=inbox',
|
||||
'U_OUTBOX' => $this->u_action . '&folder=outbox',
|
||||
'U_SENTBOX' => $this->u_action . '&folder=sentbox',
|
||||
'U_CREATE_FOLDER' => $this->u_action . '&mode=options',
|
||||
'U_CURRENT_FOLDER' => $this->u_action . '&folder=' . $folder_id,
|
||||
'U_MARK_ALL' => $this->u_action . '&folder=' . $folder_id . '&mark=all&token=' . generate_link_hash('mark_all_pms_read'),
|
||||
|
||||
'S_IN_INBOX' => ($folder_id == PRIVMSGS_INBOX) ? true : false,
|
||||
'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_REMAINING_MESSAGES' => $folder_status['remaining'],
|
||||
'FOLDER_PERCENT' => $folder_status['percent'])
|
||||
);
|
||||
|
||||
if ($action == 'view_folder')
|
||||
{
|
||||
if (!function_exists('view_folder'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx);
|
||||
}
|
||||
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,
|
||||
'L_RETURN_TO_FOLDER' => $user->lang('RETURN_TO', $folder_status['folder_name']),
|
||||
'MSG_ID' => $msg_id,
|
||||
));
|
||||
|
||||
if (!$msg_id)
|
||||
{
|
||||
trigger_error('NO_MESSAGE');
|
||||
}
|
||||
|
||||
if (!function_exists('view_message'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx);
|
||||
}
|
||||
view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row);
|
||||
|
||||
$tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error('NO_ACTION_MODE', E_USER_ERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'L_TITLE' => $user->lang['UCP_PM_' . strtoupper($mode)],
|
||||
'S_UCP_ACTION' => $this->u_action . ((isset($action)) ? "&action=$action" : ''))
|
||||
);
|
||||
|
||||
// Set desired template
|
||||
$this->tpl_name = $tpl_file;
|
||||
$this->page_title = 'UCP_PM_' . strtoupper($mode);
|
||||
}
|
||||
}
|
||||
1546
install/update/old/includes/ucp/ucp_pm_compose.php
Normal file
1546
install/update/old/includes/ucp/ucp_pm_compose.php
Normal file
File diff suppressed because it is too large
Load Diff
604
install/update/old/includes/ucp/ucp_pm_viewfolder.php
Normal file
604
install/update/old/includes/ucp/ucp_pm_viewfolder.php
Normal file
@@ -0,0 +1,604 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* View message folder
|
||||
* Called from ucp_pm with mode == 'view' && action == 'view_folder'
|
||||
*/
|
||||
function view_folder($id, $mode, $folder_id, $folder)
|
||||
{
|
||||
global $user, $template, $auth, $db, $cache, $request;
|
||||
global $phpbb_root_path, $config, $phpEx;
|
||||
|
||||
$submit_export = (isset($_POST['submit_export'])) ? true : false;
|
||||
|
||||
$folder_info = get_pm_from($folder_id, $folder, $user->data['user_id']);
|
||||
|
||||
if (!$submit_export)
|
||||
{
|
||||
$user->add_lang('viewforum');
|
||||
|
||||
// Grab icons
|
||||
$icons = $cache->obtain_icons();
|
||||
|
||||
$color_rows = array('message_reported', 'marked', 'replied');
|
||||
|
||||
$_module = new p_master();
|
||||
$_module->list_modules('ucp');
|
||||
$_module->set_active('zebra');
|
||||
|
||||
$zebra_enabled = ($_module->active_module === false) ? false : true;
|
||||
|
||||
unset($_module);
|
||||
|
||||
if ($zebra_enabled)
|
||||
{
|
||||
$color_rows = array_merge($color_rows, array('friend', 'foe'));
|
||||
}
|
||||
|
||||
foreach ($color_rows as $var)
|
||||
{
|
||||
$template->assign_block_vars('pm_colour_info', array(
|
||||
'IMG' => $user->img("pm_{$var}", ''),
|
||||
'CLASS' => "pm_{$var}_colour",
|
||||
'LANG' => $user->lang[strtoupper($var) . '_MESSAGE'])
|
||||
);
|
||||
}
|
||||
|
||||
$mark_options = array('mark_important', 'delete_marked');
|
||||
|
||||
// Minimise edits
|
||||
if (!$auth->acl_get('u_pm_delete') && $key = array_search('delete_marked', $mark_options))
|
||||
{
|
||||
unset($mark_options[$key]);
|
||||
}
|
||||
|
||||
$s_mark_options = '';
|
||||
foreach ($mark_options as $mark_option)
|
||||
{
|
||||
$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 = '';
|
||||
if ($folder_id != PRIVMSGS_NO_BOX && $folder_id != PRIVMSGS_OUTBOX)
|
||||
{
|
||||
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="sep"' : '') . ' 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
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ZEBRA_TABLE . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$friend[$row['zebra_id']] = $row['friend'];
|
||||
$foe[$row['zebra_id']] = $row['foe'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_MARK_OPTIONS' => $s_mark_options,
|
||||
'S_MOVE_MARKED_OPTIONS' => $s_folder_move_options)
|
||||
);
|
||||
|
||||
// Okay, lets dump out the page ...
|
||||
if (count($folder_info['pm_list']))
|
||||
{
|
||||
$address_list = array();
|
||||
|
||||
// Build Recipient List if in outbox/sentbox - max two additional queries
|
||||
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
|
||||
{
|
||||
$address_list = get_recipient_strings($folder_info['rowset']);
|
||||
}
|
||||
|
||||
foreach ($folder_info['pm_list'] as $message_id)
|
||||
{
|
||||
$row = &$folder_info['rowset'][$message_id];
|
||||
|
||||
$folder_img = ($row['pm_unread']) ? 'pm_unread' : 'pm_read';
|
||||
$folder_alt = ($row['pm_unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES';
|
||||
|
||||
// Generate all URIs ...
|
||||
$view_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=view&f=$folder_id&p=$message_id");
|
||||
$remove_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&action=delete&p=$message_id");
|
||||
|
||||
$row_indicator = '';
|
||||
foreach ($color_rows as $var)
|
||||
{
|
||||
if (($var !== 'friend' && $var !== 'foe' && $row[($var === 'message_reported') ? $var : "pm_{$var}"])
|
||||
||
|
||||
(($var === 'friend' || $var === 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
|
||||
{
|
||||
$row_indicator = $var;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send vars to template
|
||||
$template->assign_block_vars('messagerow', array(
|
||||
'PM_CLASS' => ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '',
|
||||
|
||||
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
|
||||
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
|
||||
'MESSAGE_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
|
||||
'U_MESSAGE_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
|
||||
|
||||
'FOLDER_ID' => $folder_id,
|
||||
'MESSAGE_ID' => $message_id,
|
||||
'SENT_TIME' => $user->format_date($row['message_time']),
|
||||
'SUBJECT' => censor_text($row['message_subject']),
|
||||
'FOLDER' => (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '',
|
||||
'U_FOLDER' => (isset($folder[$row['folder_id']])) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'folder=' . $row['folder_id']) : '',
|
||||
'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',
|
||||
'PM_ICON_URL' => (!empty($icons[$row['icon_id']])) ? $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : '',
|
||||
'FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
||||
'FOLDER_IMG_STYLE' => $folder_img,
|
||||
'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
|
||||
'S_PM_UNREAD' => ($row['pm_unread']) ? true : false,
|
||||
'S_PM_DELETED' => ($row['pm_deleted']) ? true : false,
|
||||
'S_PM_REPORTED' => (isset($row['report_id'])) ? true : false,
|
||||
'S_AUTHOR_DELETED' => ($row['author_id'] == ANONYMOUS) ? true : false,
|
||||
|
||||
'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url,
|
||||
'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '',
|
||||
'U_MCP_REPORT' => (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $row['report_id']) : '',
|
||||
'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode($user->lang['COMMA_SEPARATOR'], $address_list[$message_id]) : '')
|
||||
);
|
||||
}
|
||||
unset($folder_info['rowset']);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,
|
||||
'S_SHOW_COLOUR_LEGEND' => true,
|
||||
|
||||
'REPORTED_IMG' => $user->img('icon_topic_reported', 'PM_REPORTED'),
|
||||
'S_PM_ICONS' => ($config['enable_pm_icons']) ? true : false)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$export_type = $request->variable('export_option', '');
|
||||
$enclosure = $request->variable('enclosure', '');
|
||||
$delimiter = $request->variable('delimiter', '');
|
||||
|
||||
if ($export_type == 'CSV' && ($delimiter === '' || $enclosure === ''))
|
||||
{
|
||||
$template->assign_var('PROMPT', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Build Recipient List if in outbox/sentbox
|
||||
|
||||
$address_temp = $address = $data = array();
|
||||
|
||||
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
|
||||
{
|
||||
foreach ($folder_info['rowset'] as $message_id => $row)
|
||||
{
|
||||
$address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
|
||||
$address[$message_id] = array();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($folder_info['pm_list'] as $message_id)
|
||||
{
|
||||
$row = &$folder_info['rowset'][$message_id];
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
|
||||
$sql = 'SELECT p.message_text, p.bbcode_uid
|
||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||
WHERE t.user_id = ' . $user->data['user_id'] . "
|
||||
AND p.author_id = u.user_id
|
||||
AND t.folder_id = $folder_id
|
||||
AND t.msg_id = p.msg_id
|
||||
AND p.msg_id = $message_id";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$message_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$_types = array('u', 'g');
|
||||
foreach ($_types as $ug_type)
|
||||
{
|
||||
if (isset($address_temp[$message_id][$ug_type]) && count($address_temp[$message_id][$ug_type]))
|
||||
{
|
||||
if (!isset($address[$message_id][$ug_type]))
|
||||
{
|
||||
$address[$message_id][$ug_type] = array();
|
||||
}
|
||||
if ($ug_type == 'u')
|
||||
{
|
||||
$sql = 'SELECT user_id as id, username as name
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT group_id as id, group_name as name
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
WHERE ';
|
||||
}
|
||||
$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type])));
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($info_row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];
|
||||
unset($address_temp[$message_id][$ug_type][$info_row['id']]);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
// There is the chance that all recipients of the message got deleted. To avoid creating
|
||||
// exports without recipients, we add a bogus "undisclosed recipient".
|
||||
if (!(isset($address[$message_id]['g']) && count($address[$message_id]['g'])) &&
|
||||
!(isset($address[$message_id]['u']) && count($address[$message_id]['u'])))
|
||||
{
|
||||
$address[$message_id]['u'] = array();
|
||||
$address[$message_id]['u']['to'] = array();
|
||||
$address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT'];
|
||||
}
|
||||
|
||||
decode_message($message_row['message_text'], $message_row['bbcode_uid']);
|
||||
|
||||
$data[] = array(
|
||||
'subject' => censor_text($row['message_subject']),
|
||||
'sender' => $row['username'],
|
||||
// ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it.
|
||||
'date' => $user->format_date($row['message_time'], 'c', true),
|
||||
'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '',
|
||||
'message' => $message_row['message_text']
|
||||
);
|
||||
}
|
||||
|
||||
switch ($export_type)
|
||||
{
|
||||
case 'CSV':
|
||||
case 'CSV_EXCEL':
|
||||
$mimetype = 'text/csv';
|
||||
$filetype = 'csv';
|
||||
|
||||
if ($export_type == 'CSV_EXCEL')
|
||||
{
|
||||
$enclosure = '"';
|
||||
$delimiter = ',';
|
||||
$newline = "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$newline = "\n";
|
||||
}
|
||||
|
||||
$string = '';
|
||||
foreach ($data as $value)
|
||||
{
|
||||
$recipients = $value['to'];
|
||||
$value['to'] = $value['bcc'] = '';
|
||||
|
||||
if (is_array($recipients))
|
||||
{
|
||||
foreach ($recipients as $values)
|
||||
{
|
||||
$value['bcc'] .= (isset($values['bcc']) && is_array($values['bcc'])) ? ',' . implode(',', $values['bcc']) : '';
|
||||
$value['to'] .= (isset($values['to']) && is_array($values['to'])) ? ',' . implode(',', $values['to']) : '';
|
||||
}
|
||||
|
||||
// Remove the commas which will appear before the first entry.
|
||||
$value['to'] = substr($value['to'], 1);
|
||||
$value['bcc'] = substr($value['bcc'], 1);
|
||||
}
|
||||
|
||||
foreach ($value as $tag => $text)
|
||||
{
|
||||
$cell = str_replace($enclosure, $enclosure . $enclosure, $text);
|
||||
|
||||
if (strpos($cell, $enclosure) !== false || strpos($cell, $delimiter) !== false || strpos($cell, $newline) !== false)
|
||||
{
|
||||
$string .= $enclosure . $text . $enclosure . $delimiter;
|
||||
}
|
||||
else
|
||||
{
|
||||
$string .= $cell . $delimiter;
|
||||
}
|
||||
}
|
||||
$string = substr($string, 0, -1) . $newline;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'XML':
|
||||
$mimetype = 'application/xml';
|
||||
$filetype = 'xml';
|
||||
$string = '<?xml version="1.0"?>' . "\n";
|
||||
$string .= "<phpbb>\n";
|
||||
|
||||
foreach ($data as $value)
|
||||
{
|
||||
$string .= "\t<privmsg>\n";
|
||||
|
||||
if (is_array($value['to']))
|
||||
{
|
||||
foreach ($value['to'] as $key => $values)
|
||||
{
|
||||
foreach ($values as $type => $types)
|
||||
{
|
||||
foreach ($types as $name)
|
||||
{
|
||||
$string .= "\t\t<recipient type=\"$type\" status=\"$key\">$name</recipient>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($value['to']);
|
||||
|
||||
foreach ($value as $tag => $text)
|
||||
{
|
||||
$string .= "\t\t<$tag>$text</$tag>\n";
|
||||
}
|
||||
|
||||
$string .= "\t</privmsg>\n";
|
||||
}
|
||||
$string .= '</phpbb>';
|
||||
break;
|
||||
}
|
||||
|
||||
header('Cache-Control: private, no-cache');
|
||||
header("Content-Type: $mimetype; name=\"data.$filetype\"");
|
||||
header("Content-disposition: attachment; filename=data.$filetype");
|
||||
echo $string;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Messages from folder/user
|
||||
*/
|
||||
function get_pm_from($folder_id, $folder, $user_id)
|
||||
{
|
||||
global $user, $db, $template, $config, $auth, $phpbb_container, $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
|
||||
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
// Additional vars later, pm ordering is mostly different from post ordering. :/
|
||||
$sort_days = $request->variable('st', 0);
|
||||
$sort_key = $request->variable('sk', 't');
|
||||
$sort_dir = $request->variable('sd', 'd');
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
// PM ordering options
|
||||
$limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
|
||||
// No sort by Author for sentbox/outbox (already only author available)
|
||||
// Also, sort by msg_id for the time - private messages are not as prone to errors as posts are.
|
||||
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
|
||||
{
|
||||
$sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time'));
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
$folder_sql = 't.folder_id = ' . (int) $folder_id;
|
||||
|
||||
// Limit pms to certain time frame, obtain correct pm count
|
||||
if ($sort_days)
|
||||
{
|
||||
$min_post_time = time() - ($sort_days * 86400);
|
||||
|
||||
if (isset($_POST['sort']))
|
||||
{
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$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
|
||||
AND p.message_time >= $min_post_time";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$pm_count = (int) $db->sql_fetchfield('pm_count');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql_limit_time = "AND p.message_time >= $min_post_time";
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_count = (!empty($folder[$folder_id]['num_messages'])) ? $folder[$folder_id]['num_messages'] : 0;
|
||||
$sql_limit_time = '';
|
||||
}
|
||||
|
||||
$base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param");
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $pm_count);
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start);
|
||||
|
||||
$template_vars = array(
|
||||
'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count),
|
||||
|
||||
'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'),
|
||||
|
||||
'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'),
|
||||
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
||||
'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false,
|
||||
|
||||
'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '',
|
||||
'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id" . (($start !== 0) ? "&start=$start" : '')),
|
||||
);
|
||||
|
||||
/**
|
||||
* Modify template variables before they are assigned
|
||||
*
|
||||
* @event core.ucp_pm_view_folder_get_pm_from_template
|
||||
* @var int folder_id Folder ID
|
||||
* @var array folder Folder data
|
||||
* @var int user_id User ID
|
||||
* @var string base_url Pagination base URL
|
||||
* @var int start Pagination start
|
||||
* @var int pm_count Count of PMs
|
||||
* @var array template_vars Template variables to be assigned
|
||||
* @since 3.1.11-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'folder_id',
|
||||
'folder',
|
||||
'user_id',
|
||||
'base_url',
|
||||
'start',
|
||||
'pm_count',
|
||||
'template_vars',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_folder_get_pm_from_template', compact($vars)));
|
||||
|
||||
$template->assign_vars($template_vars);
|
||||
|
||||
// Grab all pm data
|
||||
$rowset = $pm_list = array();
|
||||
|
||||
// If the user is trying to reach late pages, start searching from the end
|
||||
$store_reverse = false;
|
||||
$sql_limit = $config['topics_per_page'];
|
||||
if ($start > $pm_count / 2)
|
||||
{
|
||||
$store_reverse = true;
|
||||
|
||||
// Select the sort order
|
||||
$direction = ($sort_dir == 'd') ? 'ASC' : 'DESC';
|
||||
$sql_limit = $pagination->reverse_limit($start, $sql_limit, $pm_count);
|
||||
$sql_start = $pagination->reverse_start($start, $sql_limit, $pm_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the sort order
|
||||
$direction = ($sort_dir == 'd') ? 'DESC' : 'ASC';
|
||||
$sql_start = $start;
|
||||
}
|
||||
|
||||
// Sql sort order
|
||||
if (is_array($sort_by_sql[$sort_key]))
|
||||
{
|
||||
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
|
||||
}
|
||||
|
||||
$sql_ary = array(
|
||||
'SELECT' => 't.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported',
|
||||
'FROM' => array(
|
||||
PRIVMSGS_TO_TABLE => 't',
|
||||
PRIVMSGS_TABLE => 'p',
|
||||
USERS_TABLE => 'u',
|
||||
),
|
||||
'WHERE' => "t.user_id = $user_id
|
||||
AND p.author_id = u.user_id
|
||||
AND $folder_sql
|
||||
AND t.msg_id = p.msg_id
|
||||
$sql_limit_time",
|
||||
'ORDER_BY' => $sql_sort_order,
|
||||
);
|
||||
|
||||
/**
|
||||
* Modify SQL before it is executed
|
||||
*
|
||||
* @event core.ucp_pm_view_folder_get_pm_from_sql
|
||||
* @var array sql_ary SQL array
|
||||
* @var int sql_limit SQL limit
|
||||
* @var int sql_start SQL start
|
||||
* @since 3.1.11-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'sql_ary',
|
||||
'sql_limit',
|
||||
'sql_start',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_folder_get_pm_from_sql', compact($vars)));
|
||||
|
||||
$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $sql_limit, $sql_start);
|
||||
|
||||
$pm_reported = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[$row['msg_id']] = $row;
|
||||
$pm_list[] = $row['msg_id'];
|
||||
if ($row['message_reported'])
|
||||
{
|
||||
$pm_reported[] = $row['msg_id'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Fetch the report_ids, if there are any reported pms.
|
||||
if (!empty($pm_reported) && $auth->acl_getf_global('m_report'))
|
||||
{
|
||||
$sql = 'SELECT pm_id, report_id
|
||||
FROM ' . REPORTS_TABLE . '
|
||||
WHERE report_closed = 0
|
||||
AND ' . $db->sql_in_set('pm_id', $pm_reported);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[$row['pm_id']]['report_id'] = $row['report_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list;
|
||||
|
||||
return array(
|
||||
'pm_count' => $pm_count,
|
||||
'pm_list' => $pm_list,
|
||||
'rowset' => $rowset
|
||||
);
|
||||
}
|
||||
847
install/update/old/includes/ucp/ucp_profile.php
Normal file
847
install/update/old/includes/ucp/ucp_profile.php
Normal file
@@ -0,0 +1,847 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ucp_profile
|
||||
* Changing profile settings
|
||||
*
|
||||
* @todo what about pertaining user_sig_options?
|
||||
*/
|
||||
class ucp_profile
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
||||
global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
|
||||
|
||||
$user->add_lang('posting');
|
||||
|
||||
$submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
|
||||
$error = $data = array();
|
||||
$s_hidden_fields = '';
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'reg_details':
|
||||
|
||||
$data = array(
|
||||
'username' => $request->variable('username', $user->data['username'], true),
|
||||
'email' => strtolower($request->variable('email', $user->data['user_email'])),
|
||||
'new_password' => $request->variable('new_password', '', true),
|
||||
'cur_password' => $request->variable('cur_password', '', true),
|
||||
'password_confirm' => $request->variable('password_confirm', '', true),
|
||||
);
|
||||
|
||||
/**
|
||||
* Modify user registration data on editing account settings in UCP
|
||||
*
|
||||
* @event core.ucp_profile_reg_details_data
|
||||
* @var array data Array with current or updated user registration data
|
||||
* @var bool submit Flag indicating if submit button has been pressed
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('data', 'submit');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars)));
|
||||
|
||||
add_form_key('ucp_reg_details');
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
// Do not check cur_password, it is the old one.
|
||||
$check_ary = array(
|
||||
'new_password' => array(
|
||||
array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
array('password')),
|
||||
'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
array('user_email')),
|
||||
);
|
||||
|
||||
if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
|
||||
{
|
||||
$check_ary['username'] = array(
|
||||
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
|
||||
array('username'),
|
||||
);
|
||||
}
|
||||
|
||||
$error = validate_data($data, $check_ary);
|
||||
|
||||
if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password'])
|
||||
{
|
||||
$error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
|
||||
}
|
||||
|
||||
// Instantiate passwords manager
|
||||
/* @var $passwords_manager \phpbb\passwords\manager */
|
||||
$passwords_manager = $phpbb_container->get('passwords.manager');
|
||||
|
||||
// Only check the new password against the previous password if there have been no errors
|
||||
if (!count($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password']))
|
||||
{
|
||||
$error[] = 'SAME_PASSWORD_ERROR';
|
||||
}
|
||||
|
||||
if (!$passwords_manager->check($data['cur_password'], $user->data['user_password']))
|
||||
{
|
||||
$error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
|
||||
}
|
||||
|
||||
if (!check_form_key('ucp_reg_details'))
|
||||
{
|
||||
$error[] = 'FORM_INVALID';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate user data on editing registration data in UCP
|
||||
*
|
||||
* @event core.ucp_profile_reg_details_validate
|
||||
* @var array data Array with user profile data
|
||||
* @var bool submit Flag indicating if submit button has been pressed
|
||||
* @var array error Array of any generated errors
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('data', 'submit', 'error');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars)));
|
||||
|
||||
if (!count($error))
|
||||
{
|
||||
$sql_ary = array(
|
||||
'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
|
||||
'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'],
|
||||
'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
|
||||
'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'],
|
||||
'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'],
|
||||
'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
|
||||
);
|
||||
|
||||
if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
|
||||
{
|
||||
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array(
|
||||
'reportee_id' => $user->data['user_id'],
|
||||
$user->data['username'],
|
||||
$data['username']
|
||||
));
|
||||
}
|
||||
|
||||
if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password']))
|
||||
{
|
||||
$user->reset_login_keys();
|
||||
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array(
|
||||
'reportee_id' => $user->data['user_id'],
|
||||
$user->data['username']
|
||||
));
|
||||
}
|
||||
|
||||
if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'])
|
||||
{
|
||||
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array(
|
||||
'reportee_id' => $user->data['user_id'],
|
||||
$user->data['username'],
|
||||
$user->data['user_email'],
|
||||
$data['email']
|
||||
));
|
||||
}
|
||||
|
||||
$message = 'PROFILE_UPDATED';
|
||||
|
||||
if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
|
||||
{
|
||||
$message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
|
||||
$server_url = generate_board_url();
|
||||
|
||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||
|
||||
$messenger = new messenger(false);
|
||||
|
||||
$template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
|
||||
$messenger->template($template_file, $user->data['user_lang']);
|
||||
|
||||
$messenger->to($data['email'], $data['username']);
|
||||
|
||||
$messenger->anti_abuse_headers($config, $user);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($data['username']),
|
||||
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
|
||||
);
|
||||
|
||||
$messenger->send(NOTIFY_EMAIL);
|
||||
|
||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
{
|
||||
$notifications_manager = $phpbb_container->get('notification_manager');
|
||||
$notifications_manager->add_notifications('notification.type.admin_activate_user', array(
|
||||
'user_id' => $user->data['user_id'],
|
||||
'user_actkey' => $user_actkey,
|
||||
'user_regdate' => time(), // Notification time
|
||||
));
|
||||
}
|
||||
|
||||
user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
|
||||
|
||||
// Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
|
||||
$sql_ary['user_actkey'] = $user_actkey;
|
||||
$sql_ary['user_newpasswd'] = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify user registration data before submitting it to the database
|
||||
*
|
||||
* @event core.ucp_profile_reg_details_sql_ary
|
||||
* @var array data Array with current or updated user registration data
|
||||
* @var array sql_ary Array with user registration data to submit to the database
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('data', 'sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars)));
|
||||
|
||||
if (count($sql_ary))
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Need to update config, forum, topic, posting, messages, etc.
|
||||
if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
|
||||
{
|
||||
user_update_name($user->data['username'], $data['username']);
|
||||
}
|
||||
|
||||
// Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
|
||||
if (!empty($sql_ary['user_actkey']))
|
||||
{
|
||||
meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
|
||||
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
|
||||
|
||||
// Because the user gets deactivated we log him out too, killing his session
|
||||
$user->session_kill();
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
}
|
||||
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = array_map(array($user, 'lang'), $error);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
|
||||
'USERNAME' => $data['username'],
|
||||
'EMAIL' => $data['email'],
|
||||
'PASSWORD_CONFIRM' => $data['password_confirm'],
|
||||
'NEW_PASSWORD' => $data['new_password'],
|
||||
'CUR_PASSWORD' => '',
|
||||
|
||||
'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])),
|
||||
'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])),
|
||||
|
||||
'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
|
||||
'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
|
||||
'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false,
|
||||
'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'profile_info':
|
||||
// Do not display profile information panel if not authed to do so
|
||||
if (!$auth->acl_get('u_chgprofileinfo'))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NO_AUTH_PROFILEINFO');
|
||||
}
|
||||
|
||||
/* @var $cp \phpbb\profilefields\manager */
|
||||
$cp = $phpbb_container->get('profilefields.manager');
|
||||
|
||||
$cp_data = $cp_error = array();
|
||||
|
||||
$data = array(
|
||||
'jabber' => $request->variable('jabber', $user->data['user_jabber'], true),
|
||||
);
|
||||
|
||||
if ($config['allow_birthdays'])
|
||||
{
|
||||
$data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
|
||||
|
||||
if ($user->data['user_birthday'])
|
||||
{
|
||||
list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
|
||||
}
|
||||
|
||||
$data['bday_day'] = $request->variable('bday_day', $data['bday_day']);
|
||||
$data['bday_month'] = $request->variable('bday_month', $data['bday_month']);
|
||||
$data['bday_year'] = $request->variable('bday_year', $data['bday_year']);
|
||||
$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify user data on editing profile in UCP
|
||||
*
|
||||
* @event core.ucp_profile_modify_profile_info
|
||||
* @var array data Array with user profile data
|
||||
* @var bool submit Flag indicating if submit button has been pressed
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('data', 'submit');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars)));
|
||||
|
||||
add_form_key('ucp_profile_info');
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$validate_array = array(
|
||||
'jabber' => array(
|
||||
array('string', true, 5, 255),
|
||||
array('jabber')),
|
||||
);
|
||||
|
||||
if ($config['allow_birthdays'])
|
||||
{
|
||||
$validate_array = array_merge($validate_array, array(
|
||||
'bday_day' => array('num', true, 1, 31),
|
||||
'bday_month' => array('num', true, 1, 12),
|
||||
'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50),
|
||||
'user_birthday' => array('date', true),
|
||||
));
|
||||
}
|
||||
|
||||
$error = validate_data($data, $validate_array);
|
||||
|
||||
// validate custom profile fields
|
||||
$cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
|
||||
|
||||
if (count($cp_error))
|
||||
{
|
||||
$error = array_merge($error, $cp_error);
|
||||
}
|
||||
|
||||
if (!check_form_key('ucp_profile_info'))
|
||||
{
|
||||
$error[] = 'FORM_INVALID';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate user data on editing profile in UCP
|
||||
*
|
||||
* @event core.ucp_profile_validate_profile_info
|
||||
* @var array data Array with user profile data
|
||||
* @var bool submit Flag indicating if submit button has been pressed
|
||||
* @var array error Array of any generated errors
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('data', 'submit', 'error');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars)));
|
||||
|
||||
if (!count($error))
|
||||
{
|
||||
$data['notify'] = $user->data['user_notify_type'];
|
||||
|
||||
if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
|
||||
{
|
||||
// User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
|
||||
// Disable notify by Jabber now for this user.
|
||||
$data['notify'] = NOTIFY_EMAIL;
|
||||
}
|
||||
|
||||
$sql_ary = array(
|
||||
'user_jabber' => $data['jabber'],
|
||||
'user_notify_type' => $data['notify'],
|
||||
);
|
||||
|
||||
if ($config['allow_birthdays'])
|
||||
{
|
||||
$sql_ary['user_birthday'] = $data['user_birthday'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify profile data in UCP before submitting to the database
|
||||
*
|
||||
* @event core.ucp_profile_info_modify_sql_ary
|
||||
* @var array cp_data Array with the user custom profile fields data
|
||||
* @var array data Array with user profile data
|
||||
* @var array sql_ary user options data we update
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('cp_data', 'data', 'sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars)));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Update Custom Fields
|
||||
$cp->update_profile_field_data($user->data['user_id'], $cp_data);
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = array_map(array($user, 'lang'), $error);
|
||||
}
|
||||
|
||||
if ($config['allow_birthdays'])
|
||||
{
|
||||
$s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
|
||||
for ($i = 1; $i < 32; $i++)
|
||||
{
|
||||
$selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
|
||||
$s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
|
||||
}
|
||||
|
||||
$s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
|
||||
for ($i = 1; $i < 13; $i++)
|
||||
{
|
||||
$selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
|
||||
$s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
|
||||
}
|
||||
|
||||
$now = getdate();
|
||||
$s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
|
||||
for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
|
||||
{
|
||||
$selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
|
||||
$s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
|
||||
}
|
||||
unset($now);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
|
||||
'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
|
||||
'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,
|
||||
'S_BIRTHDAYS_ENABLED' => true,
|
||||
));
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
'S_JABBER_ENABLED' => $config['jab_enable'],
|
||||
'JABBER' => $data['jabber'],
|
||||
));
|
||||
|
||||
// Get additional profile fields and assign them to the template block var 'profile_fields'
|
||||
$user->get_profile_fields($user->data['user_id']);
|
||||
|
||||
$cp->generate_profile_fields('profile', $user->get_iso_lang_id());
|
||||
|
||||
break;
|
||||
|
||||
case 'signature':
|
||||
|
||||
if (!$auth->acl_get('u_sig'))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NO_AUTH_SIGNATURE');
|
||||
}
|
||||
|
||||
if (!function_exists('generate_smilies'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
}
|
||||
|
||||
if (!function_exists('display_custom_bbcodes'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
$preview = $request->is_set_post('preview');
|
||||
|
||||
$enable_bbcode = ($config['allow_sig_bbcode']) ? $user->optionget('sig_bbcode') : false;
|
||||
$enable_smilies = ($config['allow_sig_smilies']) ? $user->optionget('sig_smilies') : false;
|
||||
$enable_urls = ($config['allow_sig_links']) ? $user->optionget('sig_links') : false;
|
||||
|
||||
$bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0);
|
||||
|
||||
$decoded_message = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $bbcode_flags);
|
||||
$signature = $request->variable('signature', $decoded_message['text'], true);
|
||||
$signature_preview = '';
|
||||
|
||||
if ($submit || $preview)
|
||||
{
|
||||
$enable_bbcode = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false;
|
||||
$enable_smilies = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false;
|
||||
$enable_urls = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false;
|
||||
|
||||
if (!check_form_key('ucp_sig'))
|
||||
{
|
||||
$error[] = 'FORM_INVALID';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify user signature on editing profile in UCP
|
||||
*
|
||||
* @event core.ucp_profile_modify_signature
|
||||
* @var bool enable_bbcode Whether or not bbcode is enabled
|
||||
* @var bool enable_smilies Whether or not smilies are enabled
|
||||
* @var bool enable_urls Whether or not urls are enabled
|
||||
* @var string signature Users signature text
|
||||
* @var array error Any error strings
|
||||
* @var bool submit Whether or not the form has been sumitted
|
||||
* @var bool preview Whether or not the signature is being previewed
|
||||
* @since 3.1.10-RC1
|
||||
* @changed 3.2.0-RC2 Removed message parser
|
||||
*/
|
||||
$vars = array(
|
||||
'enable_bbcode',
|
||||
'enable_smilies',
|
||||
'enable_urls',
|
||||
'signature',
|
||||
'error',
|
||||
'submit',
|
||||
'preview',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature', compact($vars)));
|
||||
|
||||
$bbcode_uid = $bbcode_bitfield = $bbcode_flags = '';
|
||||
$warn_msg = generate_text_for_storage(
|
||||
$signature,
|
||||
$bbcode_uid,
|
||||
$bbcode_bitfield,
|
||||
$bbcode_flags,
|
||||
$enable_bbcode,
|
||||
$enable_urls,
|
||||
$enable_smilies,
|
||||
$config['allow_sig_img'],
|
||||
$config['allow_sig_flash'],
|
||||
true,
|
||||
$config['allow_sig_links'],
|
||||
'sig'
|
||||
);
|
||||
|
||||
if (count($warn_msg))
|
||||
{
|
||||
$error += $warn_msg;
|
||||
}
|
||||
|
||||
if (!$submit)
|
||||
{
|
||||
// Parse it for displaying
|
||||
$signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!count($error))
|
||||
{
|
||||
$user->optionset('sig_bbcode', $enable_bbcode);
|
||||
$user->optionset('sig_smilies', $enable_smilies);
|
||||
$user->optionset('sig_links', $enable_urls);
|
||||
|
||||
$sql_ary = array(
|
||||
'user_sig' => $signature,
|
||||
'user_options' => $user->data['user_options'],
|
||||
'user_sig_bbcode_uid' => $bbcode_uid,
|
||||
'user_sig_bbcode_bitfield' => $bbcode_bitfield
|
||||
);
|
||||
|
||||
/**
|
||||
* Modify user registration data before submitting it to the database
|
||||
*
|
||||
* @event core.ucp_profile_modify_signature_sql_ary
|
||||
* @var array sql_ary Array with user signature data to submit to the database
|
||||
* @since 3.1.10-RC1
|
||||
*/
|
||||
$vars = array('sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature_sql_ary', compact($vars)));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = array_map(array($user, 'lang'), $error);
|
||||
|
||||
if ($request->is_set_post('preview'))
|
||||
{
|
||||
$decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags);
|
||||
}
|
||||
|
||||
/** @var \phpbb\controller\helper $controller_helper */
|
||||
$controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
'SIGNATURE' => $decoded_message['text'],
|
||||
'SIGNATURE_PREVIEW' => $signature_preview,
|
||||
|
||||
'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '',
|
||||
'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
|
||||
'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
|
||||
|
||||
'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'),
|
||||
'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
|
||||
'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
|
||||
'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
|
||||
'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
|
||||
'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'],
|
||||
|
||||
'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']),
|
||||
|
||||
'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'],
|
||||
'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'],
|
||||
'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false,
|
||||
'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false,
|
||||
'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false)
|
||||
);
|
||||
|
||||
add_form_key('ucp_sig');
|
||||
|
||||
// Build custom bbcodes array
|
||||
display_custom_bbcodes();
|
||||
|
||||
// Generate smiley listing
|
||||
generate_smilies('inline', 0);
|
||||
|
||||
break;
|
||||
|
||||
case 'avatar':
|
||||
|
||||
add_form_key('ucp_avatar');
|
||||
|
||||
$avatars_enabled = false;
|
||||
|
||||
if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar'))
|
||||
{
|
||||
/* @var $phpbb_avatar_manager \phpbb\avatar\manager */
|
||||
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
|
||||
$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
|
||||
|
||||
// This is normalised data, without the user_ prefix
|
||||
$avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user');
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
if (check_form_key('ucp_avatar'))
|
||||
{
|
||||
$driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
|
||||
|
||||
if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete'))
|
||||
{
|
||||
$driver = $phpbb_avatar_manager->get_driver($driver_name);
|
||||
$result = $driver->process_form($request, $template, $user, $avatar_data, $error);
|
||||
|
||||
if ($result && empty($error))
|
||||
{
|
||||
// Success! Lets save the result in the database
|
||||
$result = array(
|
||||
'user_avatar_type' => $driver_name,
|
||||
'user_avatar' => $result['avatar'],
|
||||
'user_avatar_width' => $result['avatar_width'],
|
||||
'user_avatar_height' => $result['avatar_height'],
|
||||
);
|
||||
|
||||
/**
|
||||
* Trigger events on successfull avatar change
|
||||
*
|
||||
* @event core.ucp_profile_avatar_sql
|
||||
* @var array result Array with data to be stored in DB
|
||||
* @since 3.1.11-RC1
|
||||
*/
|
||||
$vars = array('result');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_sql', compact($vars)));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $result) . '
|
||||
WHERE user_id = ' . (int) $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = 'FORM_INVALID';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle deletion of avatars
|
||||
if ($request->is_set_post('avatar_delete'))
|
||||
{
|
||||
if (!confirm_box(true))
|
||||
{
|
||||
confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array(
|
||||
'avatar_delete' => true,
|
||||
'i' => $id,
|
||||
'mode' => $mode))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_');
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
$selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type']));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'AVATAR_MIN_WIDTH' => $config['avatar_min_width'],
|
||||
'AVATAR_MAX_WIDTH' => $config['avatar_max_width'],
|
||||
'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'],
|
||||
'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'],
|
||||
));
|
||||
|
||||
foreach ($avatar_drivers as $current_driver)
|
||||
{
|
||||
$driver = $phpbb_avatar_manager->get_driver($current_driver);
|
||||
|
||||
$avatars_enabled = true;
|
||||
$template->set_filenames(array(
|
||||
'avatar' => $driver->get_template_name(),
|
||||
));
|
||||
|
||||
if ($driver->prepare_form($request, $template, $user, $avatar_data, $error))
|
||||
{
|
||||
$driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
|
||||
$driver_upper = strtoupper($driver_name);
|
||||
|
||||
$template->assign_block_vars('avatar_drivers', array(
|
||||
'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
|
||||
'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
|
||||
|
||||
'DRIVER' => $driver_name,
|
||||
'SELECTED' => $current_driver == $selected_driver,
|
||||
'OUTPUT' => $template->assign_display('avatar'),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = $phpbb_avatar_manager->localize_errors($user, $error);
|
||||
}
|
||||
|
||||
$avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
'AVATAR' => $avatar,
|
||||
|
||||
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
|
||||
|
||||
'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(),
|
||||
|
||||
'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled),
|
||||
));
|
||||
|
||||
break;
|
||||
|
||||
case 'autologin_keys':
|
||||
|
||||
add_form_key('ucp_autologin_keys');
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$keys = $request->variable('keys', array(''));
|
||||
|
||||
if (!check_form_key('ucp_autologin_keys'))
|
||||
{
|
||||
$error[] = 'FORM_INVALID';
|
||||
}
|
||||
|
||||
if (!count($error))
|
||||
{
|
||||
if (!empty($keys))
|
||||
{
|
||||
foreach ($keys as $key => $id)
|
||||
{
|
||||
$keys[$key] = $db->sql_like_expression($id . $db->get_any_char());
|
||||
}
|
||||
$sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')';
|
||||
$sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
|
||||
WHERE user_id = ' . (int) $user->data['user_id'] . '
|
||||
AND ' . $sql_where ;
|
||||
|
||||
$db->sql_query($sql);
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = array_map(array($user, 'lang'), $error);
|
||||
}
|
||||
|
||||
$sql = 'SELECT key_id, last_ip, last_login
|
||||
FROM ' . SESSIONS_KEYS_TABLE . '
|
||||
WHERE user_id = ' . (int) $user->data['user_id'] . '
|
||||
ORDER BY last_login ASC';
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('sessions', array(
|
||||
'KEY' => substr($row['key_id'], 0, 8),
|
||||
'IP' => $row['last_ip'],
|
||||
'LOGIN_TIME' => $user->format_date($row['last_login']),
|
||||
));
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
|
||||
'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
|
||||
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
||||
'S_UCP_ACTION' => $this->u_action)
|
||||
);
|
||||
|
||||
// Set desired template
|
||||
$this->tpl_name = 'ucp_profile_' . $mode;
|
||||
$this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
|
||||
}
|
||||
}
|
||||
709
install/update/old/includes/ucp/ucp_register.php
Normal file
709
install/update/old/includes/ucp/ucp_register.php
Normal file
@@ -0,0 +1,709 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ucp_register
|
||||
* Board registration
|
||||
*/
|
||||
class ucp_register
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $db, $user, $template, $phpbb_root_path, $phpEx;
|
||||
global $request, $phpbb_container, $phpbb_dispatcher;
|
||||
|
||||
//
|
||||
if ($config['require_activation'] == USER_ACTIVATION_DISABLE ||
|
||||
(in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)) && !$config['email_enable']))
|
||||
{
|
||||
trigger_error('UCP_REGISTER_DISABLE');
|
||||
}
|
||||
|
||||
$coppa = $request->is_set('coppa') ? (int) $request->variable('coppa', false) : false;
|
||||
$agreed = $request->variable('agreed', false);
|
||||
$submit = $request->is_set_post('submit');
|
||||
$change_lang = $request->variable('change_lang', '');
|
||||
$user_lang = $request->variable('lang', $user->lang_name);
|
||||
|
||||
/**
|
||||
* Add UCP register data before they are assigned to the template or submitted
|
||||
*
|
||||
* To assign data to the template, use $template->assign_vars()
|
||||
*
|
||||
* @event core.ucp_register_requests_after
|
||||
* @var bool coppa Is set coppa
|
||||
* @var bool agreed Did user agree to coppa?
|
||||
* @var bool submit Is set post submit?
|
||||
* @var string change_lang Change language request
|
||||
* @var string user_lang User language request
|
||||
* @since 3.1.11-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'coppa',
|
||||
'agreed',
|
||||
'submit',
|
||||
'change_lang',
|
||||
'user_lang',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_requests_after', compact($vars)));
|
||||
|
||||
if ($agreed)
|
||||
{
|
||||
add_form_key('ucp_register');
|
||||
}
|
||||
else
|
||||
{
|
||||
add_form_key('ucp_register_terms');
|
||||
}
|
||||
|
||||
if ($change_lang || $user_lang != $config['default_lang'])
|
||||
{
|
||||
$use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang);
|
||||
|
||||
if (!validate_language_iso_name($use_lang))
|
||||
{
|
||||
if ($change_lang)
|
||||
{
|
||||
$submit = false;
|
||||
|
||||
// Setting back agreed to let the user view the agreement in his/her language
|
||||
$agreed = false;
|
||||
}
|
||||
|
||||
$user_lang = $use_lang;
|
||||
}
|
||||
else
|
||||
{
|
||||
$change_lang = '';
|
||||
$user_lang = $user->lang_name;
|
||||
}
|
||||
}
|
||||
|
||||
/* @var $cp \phpbb\profilefields\manager */
|
||||
$cp = $phpbb_container->get('profilefields.manager');
|
||||
|
||||
$error = $cp_data = $cp_error = array();
|
||||
$s_hidden_fields = array();
|
||||
|
||||
// Handle login_link data added to $_hidden_fields
|
||||
$login_link_data = $this->get_login_link_data_array();
|
||||
|
||||
if (!empty($login_link_data))
|
||||
{
|
||||
// Confirm that we have all necessary data
|
||||
/* @var $provider_collection \phpbb\auth\provider_collection */
|
||||
$provider_collection = $phpbb_container->get('auth.provider_collection');
|
||||
$auth_provider = $provider_collection->get_provider($request->variable('auth_provider', ''));
|
||||
|
||||
$result = $auth_provider->login_link_has_necessary_data($login_link_data);
|
||||
if ($result !== null)
|
||||
{
|
||||
$error[] = $user->lang[$result];
|
||||
}
|
||||
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, $this->get_login_link_data_for_hidden_fields($login_link_data));
|
||||
}
|
||||
|
||||
if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable']))
|
||||
{
|
||||
$add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : '';
|
||||
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, array(
|
||||
'change_lang' => '',
|
||||
));
|
||||
|
||||
// If we change the language, we want to pass on some more possible parameter.
|
||||
if ($change_lang)
|
||||
{
|
||||
// We do not include the password
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, array(
|
||||
'username' => $request->variable('username', '', true),
|
||||
'email' => strtolower($request->variable('email', '')),
|
||||
'lang' => $user->lang_name,
|
||||
'tz' => $request->variable('tz', $config['board_timezone']),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
// Checking amount of available languages
|
||||
$sql = 'SELECT lang_id
|
||||
FROM ' . LANG_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$lang_row = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$lang_row[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($coppa === false && $config['coppa_enable'])
|
||||
{
|
||||
$now = getdate();
|
||||
$coppa_birthday = $user->create_datetime()
|
||||
->setDate($now['year'] - 13, $now['mon'], $now['mday'] - 1)
|
||||
->setTime(0, 0, 0)
|
||||
->format($user->lang['DATE_FORMAT'], true);
|
||||
unset($now);
|
||||
|
||||
$template_vars = array(
|
||||
'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '',
|
||||
'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday),
|
||||
'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday),
|
||||
|
||||
'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=0'),
|
||||
'U_COPPA_YES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=1'),
|
||||
|
||||
'S_SHOW_COPPA' => true,
|
||||
'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
|
||||
'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
|
||||
|
||||
'COOKIE_NAME' => $config['cookie_name'],
|
||||
'COOKIE_PATH' => $config['cookie_path'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_vars = array(
|
||||
'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '',
|
||||
'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()),
|
||||
|
||||
'S_SHOW_COPPA' => false,
|
||||
'S_REGISTRATION' => true,
|
||||
'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
|
||||
'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_coppa),
|
||||
|
||||
'COOKIE_NAME' => $config['cookie_name'],
|
||||
'COOKIE_PATH' => $config['cookie_path'],
|
||||
);
|
||||
}
|
||||
|
||||
$tpl_name = 'ucp_agreement';
|
||||
|
||||
/**
|
||||
* Allows to modify the agreements.
|
||||
*
|
||||
* @event core.ucp_register_agreement_modify_template_data
|
||||
* @var string tpl_name Template file
|
||||
* @var array template_vars Array with data about to be assigned to the template
|
||||
* @var array s_hidden_fields Array with hidden form elements
|
||||
* @var array lang_row Array with available languages, read only
|
||||
* @since 3.2.2-RC1
|
||||
*/
|
||||
$vars = array('tpl_name', 'template_vars', 's_hidden_fields', 'lang_row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_agreement_modify_template_data', compact($vars)));
|
||||
|
||||
unset($lang_row);
|
||||
|
||||
$template_vars = array_merge($template_vars, array(
|
||||
'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
|
||||
));
|
||||
|
||||
$template->assign_vars($template_vars);
|
||||
|
||||
/**
|
||||
* Allows to modify the agreements.
|
||||
*
|
||||
* To assign data to the template, use $template->assign_vars()
|
||||
*
|
||||
* @event core.ucp_register_agreement
|
||||
* @since 3.1.6-RC1
|
||||
* @deprecated 3.2.2-RC1 Replaced by core.ucp_register_agreement_modify_template_data and to be removed in 3.3.0-RC1
|
||||
*/
|
||||
$phpbb_dispatcher->dispatch('core.ucp_register_agreement');
|
||||
|
||||
$this->tpl_name = $tpl_name;
|
||||
return;
|
||||
}
|
||||
|
||||
// The CAPTCHA kicks in here. We can't help that the information gets lost on language change.
|
||||
if ($config['enable_confirm'])
|
||||
{
|
||||
$captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_REG);
|
||||
}
|
||||
|
||||
$timezone = $config['board_timezone'];
|
||||
|
||||
$data = array(
|
||||
'username' => $request->variable('username', '', true),
|
||||
'new_password' => $request->variable('new_password', '', true),
|
||||
'password_confirm' => $request->variable('password_confirm', '', true),
|
||||
'email' => strtolower($request->variable('email', '')),
|
||||
'lang' => basename($request->variable('lang', $user->lang_name)),
|
||||
'tz' => $request->variable('tz', $timezone),
|
||||
);
|
||||
/**
|
||||
* Add UCP register data before they are assigned to the template or submitted
|
||||
*
|
||||
* To assign data to the template, use $template->assign_vars()
|
||||
*
|
||||
* @event core.ucp_register_data_before
|
||||
* @var bool submit Do we display the form only
|
||||
* or did the user press submit
|
||||
* @var array data Array with current ucp registration data
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('submit', 'data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_before', compact($vars)));
|
||||
|
||||
// Check and initialize some variables if needed
|
||||
if ($submit)
|
||||
{
|
||||
$error = validate_data($data, array(
|
||||
'username' => array(
|
||||
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
|
||||
array('username', '')),
|
||||
'new_password' => array(
|
||||
array('string', false, $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
array('password')),
|
||||
'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
array('user_email')),
|
||||
'tz' => array('timezone'),
|
||||
'lang' => array('language_iso_name'),
|
||||
));
|
||||
|
||||
if (!check_form_key('ucp_register'))
|
||||
{
|
||||
$error[] = $user->lang['FORM_INVALID'];
|
||||
}
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = array_map(array($user, 'lang'), $error);
|
||||
|
||||
if ($config['enable_confirm'])
|
||||
{
|
||||
$vc_response = $captcha->validate($data);
|
||||
if ($vc_response !== false)
|
||||
{
|
||||
$error[] = $vc_response;
|
||||
}
|
||||
|
||||
if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts'])
|
||||
{
|
||||
$error[] = $user->lang['TOO_MANY_REGISTERS'];
|
||||
}
|
||||
}
|
||||
|
||||
// DNSBL check
|
||||
if ($config['check_dnsbl'])
|
||||
{
|
||||
if (($dnsbl = $user->check_dnsbl('register')) !== false)
|
||||
{
|
||||
$error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// validate custom profile fields
|
||||
$cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error);
|
||||
|
||||
if (!count($error))
|
||||
{
|
||||
if ($data['new_password'] != $data['password_confirm'])
|
||||
{
|
||||
$error[] = $user->lang['NEW_PASSWORD_ERROR'];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check UCP registration data after they are submitted
|
||||
*
|
||||
* @event core.ucp_register_data_after
|
||||
* @var bool submit Do we display the form only
|
||||
* or did the user press submit
|
||||
* @var array data Array with current ucp registration data
|
||||
* @var array cp_data Array with custom profile fields data
|
||||
* @var array error Array with list of errors
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('submit', 'data', 'cp_data', 'error');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_after', compact($vars)));
|
||||
|
||||
if (!count($error))
|
||||
{
|
||||
$server_url = generate_board_url();
|
||||
|
||||
// Which group by default?
|
||||
$group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED';
|
||||
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $db->sql_escape($group_name) . "'
|
||||
AND group_type = " . GROUP_SPECIAL;
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_GROUP');
|
||||
}
|
||||
|
||||
$group_id = $row['group_id'];
|
||||
|
||||
if (($coppa ||
|
||||
$config['require_activation'] == USER_ACTIVATION_SELF ||
|
||||
$config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable'])
|
||||
{
|
||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||
$user_type = USER_INACTIVE;
|
||||
$user_inactive_reason = INACTIVE_REGISTER;
|
||||
$user_inactive_time = time();
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_type = USER_NORMAL;
|
||||
$user_actkey = '';
|
||||
$user_inactive_reason = 0;
|
||||
$user_inactive_time = 0;
|
||||
}
|
||||
|
||||
// Instantiate passwords manager
|
||||
/* @var $passwords_manager \phpbb\passwords\manager */
|
||||
$passwords_manager = $phpbb_container->get('passwords.manager');
|
||||
|
||||
$user_row = array(
|
||||
'username' => $data['username'],
|
||||
'user_password' => $passwords_manager->hash($data['new_password']),
|
||||
'user_email' => $data['email'],
|
||||
'group_id' => (int) $group_id,
|
||||
'user_timezone' => $data['tz'],
|
||||
'user_lang' => $data['lang'],
|
||||
'user_type' => $user_type,
|
||||
'user_actkey' => $user_actkey,
|
||||
'user_ip' => $user->ip,
|
||||
'user_regdate' => time(),
|
||||
'user_inactive_reason' => $user_inactive_reason,
|
||||
'user_inactive_time' => $user_inactive_time,
|
||||
);
|
||||
|
||||
if ($config['new_member_post_limit'])
|
||||
{
|
||||
$user_row['user_new'] = 1;
|
||||
}
|
||||
/**
|
||||
* Add into $user_row before user_add
|
||||
*
|
||||
* user_add allows adding more data into the users table
|
||||
*
|
||||
* @event core.ucp_register_user_row_after
|
||||
* @var bool submit Do we display the form only
|
||||
* or did the user press submit
|
||||
* @var array cp_data Array with custom profile fields data
|
||||
* @var array user_row Array with current ucp registration data
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array('submit', 'cp_data', 'user_row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_user_row_after', compact($vars)));
|
||||
|
||||
// Register user...
|
||||
$user_id = user_add($user_row, $cp_data);
|
||||
|
||||
// This should not happen, because the required variables are listed above...
|
||||
if ($user_id === false)
|
||||
{
|
||||
trigger_error('NO_USER', E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Okay, captcha, your job is done.
|
||||
if ($config['enable_confirm'] && isset($captcha))
|
||||
{
|
||||
$captcha->reset();
|
||||
}
|
||||
|
||||
if ($coppa && $config['email_enable'])
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_COPPA'];
|
||||
$email_template = 'coppa_welcome_inactive';
|
||||
}
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable'])
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_INACTIVE'];
|
||||
$email_template = 'user_welcome_inactive';
|
||||
}
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable'])
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
|
||||
$email_template = 'admin_welcome_inactive';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_ADDED'];
|
||||
$email_template = 'user_welcome';
|
||||
}
|
||||
|
||||
if ($config['email_enable'])
|
||||
{
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
|
||||
$messenger = new messenger(false);
|
||||
|
||||
$messenger->template($email_template, $data['lang']);
|
||||
|
||||
$messenger->to($data['email'], $data['username']);
|
||||
|
||||
$messenger->anti_abuse_headers($config, $user);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
|
||||
'USERNAME' => htmlspecialchars_decode($data['username']),
|
||||
'PASSWORD' => htmlspecialchars_decode($data['new_password']),
|
||||
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey")
|
||||
);
|
||||
|
||||
if ($coppa)
|
||||
{
|
||||
$messenger->assign_vars(array(
|
||||
'FAX_INFO' => $config['coppa_fax'],
|
||||
'MAIL_INFO' => $config['coppa_mail'],
|
||||
'EMAIL_ADDRESS' => $data['email'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify messenger data before welcome mail is sent
|
||||
*
|
||||
* @event core.ucp_register_welcome_email_before
|
||||
* @var array user_row Array with user registration data
|
||||
* @var array cp_data Array with custom profile fields data
|
||||
* @var array data Array with current ucp registration data
|
||||
* @var string message Message to be displayed to the user after registration
|
||||
* @var string server_url Server URL
|
||||
* @var int user_id New user ID
|
||||
* @var string user_actkey User activation key
|
||||
* @var messenger messenger phpBB Messenger
|
||||
* @since 3.2.4-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'user_row',
|
||||
'cp_data',
|
||||
'data',
|
||||
'message',
|
||||
'server_url',
|
||||
'user_id',
|
||||
'user_actkey',
|
||||
'messenger',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars)));
|
||||
|
||||
$messenger->send(NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
{
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
$phpbb_notifications->add_notifications('notification.type.admin_activate_user', array(
|
||||
'user_id' => $user_id,
|
||||
'user_actkey' => $user_row['user_actkey'],
|
||||
'user_regdate' => $user_row['user_regdate'],
|
||||
));
|
||||
}
|
||||
|
||||
// Perform account linking if necessary
|
||||
if (!empty($login_link_data))
|
||||
{
|
||||
$login_link_data['user_id'] = $user_id;
|
||||
|
||||
$result = $auth_provider->link_account($login_link_data);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$message = $message . '<br /><br />' . $user->lang[$result];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform additional actions after user registration
|
||||
*
|
||||
* @event core.ucp_register_register_after
|
||||
* @var array user_row Array with user registration data
|
||||
* @var array cp_data Array with custom profile fields data
|
||||
* @var array data Array with current ucp registration data
|
||||
* @var string message Message to be displayed to the user after registration
|
||||
* @var string server_url Server URL
|
||||
* @var int user_id New user ID
|
||||
* @var string user_actkey User activation key
|
||||
* @since 3.2.4-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'user_row',
|
||||
'cp_data',
|
||||
'data',
|
||||
'message',
|
||||
'server_url',
|
||||
'user_id',
|
||||
'user_actkey',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars)));
|
||||
|
||||
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, array(
|
||||
'agreed' => 'true',
|
||||
'change_lang' => 0,
|
||||
));
|
||||
|
||||
if ($config['coppa_enable'])
|
||||
{
|
||||
$s_hidden_fields['coppa'] = $coppa;
|
||||
}
|
||||
|
||||
if ($config['enable_confirm'])
|
||||
{
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields());
|
||||
}
|
||||
|
||||
// Visual Confirmation - Show images
|
||||
if ($config['enable_confirm'])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
$l_reg_cond = '';
|
||||
switch ($config['require_activation'])
|
||||
{
|
||||
case USER_ACTIVATION_SELF:
|
||||
$l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE'];
|
||||
break;
|
||||
|
||||
case USER_ACTIVATION_ADMIN:
|
||||
$l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE'];
|
||||
break;
|
||||
}
|
||||
|
||||
// Assign template vars for timezone select
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
|
||||
$template_vars = array(
|
||||
'USERNAME' => $data['username'],
|
||||
'PASSWORD' => $data['new_password'],
|
||||
'PASSWORD_CONFIRM' => $data['password_confirm'],
|
||||
'EMAIL' => $data['email'],
|
||||
|
||||
'L_REG_COND' => $l_reg_cond,
|
||||
'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])),
|
||||
'L_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])),
|
||||
|
||||
'S_LANG_OPTIONS' => language_select($data['lang']),
|
||||
'S_TZ_PRESELECT' => !$submit,
|
||||
'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
|
||||
'S_REGISTRATION' => true,
|
||||
'S_COPPA' => $coppa,
|
||||
'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
|
||||
|
||||
'COOKIE_NAME' => $config['cookie_name'],
|
||||
'COOKIE_PATH' => $config['cookie_path'],
|
||||
);
|
||||
|
||||
$tpl_name = 'ucp_register';
|
||||
|
||||
/**
|
||||
* Modify template data on the registration page
|
||||
*
|
||||
* @event core.ucp_register_modify_template_data
|
||||
* @var array template_vars Array with template data
|
||||
* @var array data Array with user data, read only
|
||||
* @var array error Array with errors
|
||||
* @var array s_hidden_fields Array with hidden field elements
|
||||
* @var string tpl_name Template name
|
||||
* @since 3.2.2-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'template_vars',
|
||||
'data',
|
||||
'error',
|
||||
's_hidden_fields',
|
||||
'tpl_name',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_modify_template_data', compact($vars)));
|
||||
|
||||
$template_vars = array_merge($template_vars, array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
|
||||
));
|
||||
|
||||
$template->assign_vars($template_vars);
|
||||
|
||||
//
|
||||
$user->profile_fields = array();
|
||||
|
||||
// Generate profile fields -> Template Block Variable profile_fields
|
||||
$cp->generate_profile_fields('register', $user->get_iso_lang_id());
|
||||
|
||||
//
|
||||
$this->tpl_name = $tpl_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the login_link data array
|
||||
*
|
||||
* @return array Returns an array of all POST paramaters whose names
|
||||
* begin with 'login_link_'
|
||||
*/
|
||||
protected function get_login_link_data_array()
|
||||
{
|
||||
global $request;
|
||||
|
||||
$var_names = $request->variable_names(\phpbb\request\request_interface::POST);
|
||||
$login_link_data = array();
|
||||
$string_start_length = strlen('login_link_');
|
||||
|
||||
foreach ($var_names as $var_name)
|
||||
{
|
||||
if (strpos($var_name, 'login_link_') === 0)
|
||||
{
|
||||
$key_name = substr($var_name, $string_start_length);
|
||||
$login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::POST);
|
||||
}
|
||||
}
|
||||
|
||||
return $login_link_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends they key names of an associative array with 'login_link_' for
|
||||
* inclusion on the page as hidden fields.
|
||||
*
|
||||
* @param array $data The array to be modified
|
||||
* @return array The modified array
|
||||
*/
|
||||
protected function get_login_link_data_for_hidden_fields($data)
|
||||
{
|
||||
$new_data = array();
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
$new_data['login_link_' . $key] = $value;
|
||||
}
|
||||
|
||||
return $new_data;
|
||||
}
|
||||
}
|
||||
163
install/update/old/includes/ucp/ucp_resend.php
Normal file
163
install/update/old/includes/ucp/ucp_resend.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ucp_resend
|
||||
* Resending activation emails
|
||||
*/
|
||||
class ucp_resend
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $phpbb_root_path, $phpEx;
|
||||
global $db, $user, $auth, $template, $request;
|
||||
|
||||
$username = $request->variable('username', '', true);
|
||||
$email = strtolower($request->variable('email', ''));
|
||||
$submit = (isset($_POST['submit'])) ? true : false;
|
||||
|
||||
add_form_key('ucp_resend');
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
if (!check_form_key('ucp_resend'))
|
||||
{
|
||||
trigger_error('FORM_INVALID');
|
||||
}
|
||||
|
||||
$sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
|
||||
AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$user_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$user_row)
|
||||
{
|
||||
trigger_error('NO_EMAIL_USER');
|
||||
}
|
||||
|
||||
if ($user_row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
trigger_error('NO_USER');
|
||||
}
|
||||
|
||||
if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE)
|
||||
{
|
||||
trigger_error('ACCOUNT_ALREADY_ACTIVATED');
|
||||
}
|
||||
|
||||
if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL))
|
||||
{
|
||||
trigger_error('ACCOUNT_DEACTIVATED');
|
||||
}
|
||||
|
||||
// Determine coppa status on group (REGISTERED(_COPPA))
|
||||
$sql = 'SELECT group_name, group_type
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
WHERE group_id = ' . $user_row['group_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_GROUP');
|
||||
}
|
||||
|
||||
$coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false;
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
$messenger = new messenger(false);
|
||||
|
||||
if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
|
||||
{
|
||||
$messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
|
||||
$messenger->set_addresses($user_row);
|
||||
|
||||
$messenger->anti_abuse_headers($config, $user);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
|
||||
'USERNAME' => htmlspecialchars_decode($user_row['username']),
|
||||
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
|
||||
);
|
||||
|
||||
if ($coppa)
|
||||
{
|
||||
$messenger->assign_vars(array(
|
||||
'FAX_INFO' => $config['coppa_fax'],
|
||||
'MAIL_INFO' => $config['coppa_mail'],
|
||||
'EMAIL_ADDRESS' => $user_row['user_email'])
|
||||
);
|
||||
}
|
||||
|
||||
$messenger->send(NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
{
|
||||
// Grab an array of user_id's with a_user permissions ... these users can activate a user
|
||||
$admin_ary = $auth->acl_get_list(false, 'a_user', false);
|
||||
|
||||
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$messenger->template('admin_activate', $row['user_lang']);
|
||||
$messenger->set_addresses($row);
|
||||
|
||||
$messenger->anti_abuse_headers($config, $user);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($user_row['username']),
|
||||
'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
|
||||
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
|
||||
);
|
||||
|
||||
$messenger->send($row['user_notify_type']);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
||||
|
||||
$message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
|
||||
$message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'USERNAME' => $username,
|
||||
'EMAIL' => $email,
|
||||
'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act'))
|
||||
);
|
||||
|
||||
$this->tpl_name = 'ucp_resend';
|
||||
$this->page_title = 'UCP_RESEND';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user