Merge branch '3.1.x'

This commit is contained in:
Marc Alexander 2015-07-17 13:35:34 +02:00
commit 12f85a6a89

View file

@ -527,7 +527,7 @@ class session
*/ */
function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true)
{ {
global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx, $phpbb_container; global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher;
$this->data = array(); $this->data = array();
@ -902,6 +902,19 @@ class session
$_SID = ''; $_SID = '';
} }
$session_data = $sql_ary;
/**
* Event to send new session data to extension
* Read-only event
*
* @event core.session_create_after
* @var array session_data Associative array of session keys to be updated
* @since 3.1.6-RC1
*/
$vars = array('session_data');
extract($phpbb_dispatcher->trigger_event('core.session_create_after', compact($vars)));
unset($session_data);
return true; return true;
} }
@ -915,13 +928,30 @@ class session
*/ */
function session_kill($new_session = true) function session_kill($new_session = true)
{ {
global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx, $phpbb_container; global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher;
$sql = 'DELETE FROM ' . SESSIONS_TABLE . " $sql = 'DELETE FROM ' . SESSIONS_TABLE . "
WHERE session_id = '" . $db->sql_escape($this->session_id) . "' WHERE session_id = '" . $db->sql_escape($this->session_id) . "'
AND session_user_id = " . (int) $this->data['user_id']; AND session_user_id = " . (int) $this->data['user_id'];
$db->sql_query($sql); $db->sql_query($sql);
$user_id = (int) $this->data['user_id'];
$session_id = $this->session_id;
/**
* Event to send session kill information to extension
* Read-only event
*
* @event core.session_kill_after
* @var int user_id user_id of the session user.
* @var string session_id current user's session_id
* @var bool new_session should we create new session for user
* @since 3.1.6-RC1
*/
$vars = array('user_id', 'session_id', 'new_session');
extract($phpbb_dispatcher->trigger_event('core.session_kill_after', compact($vars)));
unset($user_id);
unset($session_id);
// Allow connecting logout with external auth method logout // Allow connecting logout with external auth method logout
/* @var $provider_collection \phpbb\auth\provider_collection */ /* @var $provider_collection \phpbb\auth\provider_collection */
$provider_collection = $phpbb_container->get('auth.provider_collection'); $provider_collection = $phpbb_container->get('auth.provider_collection');
@ -990,7 +1020,7 @@ class session
*/ */
function session_gc() function session_gc()
{ {
global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container; global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher;
$batch_size = 10; $batch_size = 10;
@ -1059,6 +1089,14 @@ class session
$db->sql_query($sql); $db->sql_query($sql);
} }
/**
* Event to trigger extension on session_gc
*
* @event core.session_gc_after
* @since 3.1.6-RC1
*/
$phpbb_dispatcher->dispatch('core.session_gc_after');
return; return;
} }
@ -1552,12 +1590,24 @@ class session
*/ */
public function update_session($session_data, $session_id = null) public function update_session($session_data, $session_id = null)
{ {
global $db; global $db, $phpbb_dispatcher;
$session_id = ($session_id) ? $session_id : $this->session_id; $session_id = ($session_id) ? $session_id : $this->session_id;
$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $session_data) . " $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $session_data) . "
WHERE session_id = '" . $db->sql_escape($session_id) . "'"; WHERE session_id = '" . $db->sql_escape($session_id) . "'";
$db->sql_query($sql); $db->sql_query($sql);
/**
* Event to send update session information to extension
* Read-only event
*
* @event core.update_session_after
* @var array session_data Associative array of session keys to be updated
* @var string session_id current user's session_id
* @since 3.1.6-RC1
*/
$vars = array('session_data', 'session_id');
extract($phpbb_dispatcher->trigger_event('core.update_session_after', compact($vars)));
} }
} }