aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/ucp.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/ucp.php')
-rw-r--r--phpBB/ucp.php133
1 files changed, 89 insertions, 44 deletions
diff --git a/phpBB/ucp.php b/phpBB/ucp.php
index 520ab3caad..5cd602bab5 100644
--- a/phpBB/ucp.php
+++ b/phpBB/ucp.php
@@ -1,10 +1,13 @@
<?php
/**
*
-* @package ucp
-* @version $Id$
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* 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.
*
*/
@@ -22,7 +25,7 @@ require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
$id = request_var('i', '');
$mode = request_var('mode', '');
-if (in_array($mode, array('login', 'logout', 'confirm', 'sendpassword', 'activate')))
+if (in_array($mode, array('login', 'login_link', 'logout', 'confirm', 'sendpassword', 'activate')))
{
define('IN_LOGIN', true);
}
@@ -81,22 +84,30 @@ switch ($mode)
login_box(request_var('redirect', "index.$phpEx"));
break;
+ case 'login_link':
+ if ($user->data['is_registered'])
+ {
+ redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ }
+
+ $module->load('ucp', 'login_link');
+ $module->display($user->lang['UCP_LOGIN_LINK']);
+ break;
+
case 'logout':
- if ($user->data['user_id'] != ANONYMOUS && isset($_GET['sid']) && !is_array($_GET['sid']) && $_GET['sid'] === $user->session_id)
+ if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id)
{
$user->session_kill();
- $user->session_begin();
- $message = $user->lang['LOGOUT_REDIRECT'];
}
- else
+ else if ($user->data['user_id'] != ANONYMOUS)
{
- $message = ($user->data['user_id'] == ANONYMOUS) ? $user->lang['LOGOUT_REDIRECT'] : $user->lang['LOGOUT_FAILED'];
- }
- meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
+ meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
- $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
- trigger_error($message);
+ $message = $user->lang['LOGOUT_FAILED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
+ trigger_error($message);
+ }
+ redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
break;
case 'terms':
@@ -120,7 +131,7 @@ switch ($mode)
);
// Disable online list
- page_header($user->lang[$title], false);
+ page_header($user->lang[$title]);
$template->assign_vars(array(
'S_AGREEMENT' => true,
@@ -141,8 +152,10 @@ switch ($mode)
{
$set_time = time() - 31536000;
- foreach ($_COOKIE as $cookie_name => $cookie_data)
+ foreach ($request->variable_names(\phpbb\request\request_interface::COOKIE) as $cookie_name)
{
+ $cookie_data = $request->variable($cookie_name, '', true, \phpbb\request\request_interface::COOKIE);
+
// Only delete board cookies, no other ones...
if (strpos($cookie_name, $config['cookie_name'] . '_') !== 0)
{
@@ -151,6 +164,22 @@ switch ($mode)
$cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name);
+ /**
+ * Event to save custom cookies from deletion
+ *
+ * @event core.ucp_delete_cookies
+ * @var string cookie_name Cookie name to checking
+ * @var bool retain_cookie Do we retain our cookie or not, true if retain
+ * @since 3.1.3-RC1
+ */
+ $retain_cookie = false;
+ $vars = array('cookie_name', 'retain_cookie');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_delete_cookies', compact($vars)));
+ if ($retain_cookie)
+ {
+ continue;
+ }
+
// Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_
if (strpos($cookie_name, 'poll_') !== 0)
{
@@ -208,6 +237,19 @@ switch ($mode)
add_log('admin', 'LOG_ACL_TRANSFER_PERMISSIONS', $user_row['username']);
$message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
+
+ /**
+ * Event to run code after permissions are switched
+ *
+ * @event core.ucp_switch_permissions
+ * @var int user_id User ID to switch permission to
+ * @var array user_row User data
+ * @var string message Success message
+ * @since 3.1.11-RC1
+ */
+ $vars = array('user_id', 'user_row', 'message');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_switch_permissions', compact($vars)));
+
trigger_error($message);
break;
@@ -231,6 +273,18 @@ switch ($mode)
add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username);
$message = $user->lang['PERMISSIONS_RESTORED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
+
+ /**
+ * Event to run code after permissions are restored
+ *
+ * @event core.ucp_restore_permissions
+ * @var string username User name
+ * @var string message Success message
+ * @since 3.1.11-RC1
+ */
+ $vars = array('username', 'message');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_restore_permissions', compact($vars)));
+
trigger_error($message);
break;
@@ -272,19 +326,19 @@ if ($module->is_active('zebra', 'friends'))
// Output listing of friends online
$update_time = $config['load_online_time'] * 60;
- $sql = $db->sql_build_query('SELECT_DISTINCT', array(
+ $sql_ary = array(
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
'FROM' => array(
USERS_TABLE => 'u',
- ZEBRA_TABLE => 'z'
+ ZEBRA_TABLE => 'z',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(SESSIONS_TABLE => 's'),
- 'ON' => 's.session_user_id = z.zebra_id'
- )
+ 'ON' => 's.session_user_id = z.zebra_id',
+ ),
),
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
@@ -294,8 +348,9 @@ if ($module->is_active('zebra', 'friends'))
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username',
'ORDER_BY' => 'u.username_clean ASC',
- ));
+ );
+ $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -320,6 +375,18 @@ if (!$config['allow_topic_notify'] && !$config['allow_forum_notify'])
$module->set_display('main', 'subscribed', false);
}
+/**
+* Use this event to enable and disable additional UCP modules
+*
+* @event core.ucp_display_module_before
+* @var p_master module Object holding all modules and their status
+* @var mixed id Active module category (can be the int or string)
+* @var string mode Active module
+* @since 3.1.0-a1
+*/
+$vars = array('module', 'id', 'mode');
+extract($phpbb_dispatcher->trigger_event('core.ucp_display_module_before', compact($vars)));
+
// Select the active module
$module->set_active($id, $mode);
@@ -330,26 +397,4 @@ $module->load_active();
$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx"));
// Generate the page, do not display/query online list
-$module->display($module->get_page_title(), false);
-
-/**
-* Function for assigning a template var if the zebra module got included
-*/
-function _module_zebra($mode, &$module_row)
-{
- global $template;
-
- $template->assign_var('S_ZEBRA_ENABLED', true);
-
- if ($mode == 'friends')
- {
- $template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true);
- }
-
- if ($mode == 'foes')
- {
- $template->assign_var('S_ZEBRA_FOES_ENABLED', true);
- }
-}
-
-?> \ No newline at end of file
+$module->display($module->get_page_title());