mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-06 22:18:59 +01:00
new "session_created" hook
This commit is contained in:
parent
eb13a71027
commit
7ba77356d5
api/src
@ -17,7 +17,6 @@
|
||||
* @package api
|
||||
* @subpackage session
|
||||
* @author Ralf Becker <ralfbecker@outdoor-training.de> since 2003 on
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
namespace EGroupware\Api;
|
||||
@ -617,6 +616,21 @@ class Session
|
||||
}
|
||||
if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid");
|
||||
|
||||
// hook called once session is created
|
||||
Hooks::process(array(
|
||||
'location' => 'session_created',
|
||||
'sessionid' => $this->sessionid,
|
||||
'session_flags' => $this->session_flags,
|
||||
'account_id' => $this->account_id,
|
||||
'account_lid' => $this->account_lid,
|
||||
'passwd' => $this->passwd,
|
||||
'account_domain' => $this->account_domain,
|
||||
'user_ip' => $user_ip,
|
||||
'session_type' => Session\Type::get($_SERVER['REQUEST_URI'],
|
||||
$GLOBALS['egw_info']['flags']['current_app'],
|
||||
true), // true return WebGUI instead of login, as we are logged in now
|
||||
),'',true);
|
||||
|
||||
return $this->sessionid;
|
||||
}
|
||||
// catch all exceptions, as their (allways logged) trace (eg. on a database error) would contain the user password
|
||||
|
101
api/src/Session/Type.php
Normal file
101
api/src/Session/Type.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* EGroupware API: Session Type(s)
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @subpackage session
|
||||
* @author Ralf Becker <rb-at-egroupware.org>
|
||||
*/
|
||||
|
||||
namespace EGroupware\Api\Session;
|
||||
|
||||
/**
|
||||
* Determine type of session based on request-uri and currentapp
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Type
|
||||
{
|
||||
const LOGIN = 'login';
|
||||
const SYNCML = 'syncml';
|
||||
const GROUPDAV = 'groupdav';
|
||||
const ESYNC = 'esync';
|
||||
const WEBDAV = 'webdav';
|
||||
const WEBGUI = 'webgui';
|
||||
const SETUP = 'setup';
|
||||
const SITEMGR = 'sitemgr';
|
||||
const SHARING = 'sharing';
|
||||
const WOPI = 'wopi';
|
||||
|
||||
/**
|
||||
* Return the type of session, based on the $request_uri
|
||||
*
|
||||
* @param string $request_uri
|
||||
* @param string $currentapp
|
||||
* @param bolean $nologin =false true: return self::WEBGUI instead of self::LOGIN
|
||||
* @return string see above constants
|
||||
*/
|
||||
public static function get($request_uri, $currentapp, $nologin=false)
|
||||
{
|
||||
// sometimes the query makes an url unparseble, eg. /index.php?url=http://something.com/other.html
|
||||
if (!($script = @parse_url($request_uri,PHP_URL_PATH)))
|
||||
{
|
||||
list($script) = explode('?',$request_uri);
|
||||
if ($script[0] != '/') $script = parse_url($script,PHP_URL_PATH);
|
||||
}
|
||||
if (($e = strpos($script,'.php/')) !== false)
|
||||
{
|
||||
$script = substr($script,0,$e+4); // cut off WebDAV path
|
||||
}
|
||||
elseif (substr($script,-1) == '/')
|
||||
{
|
||||
$script .= 'index.php';
|
||||
}
|
||||
$script_name = basename($script);
|
||||
|
||||
if (!$nologin && ($script_name == 'login.php' || $script_name == 'logout.php'))
|
||||
{
|
||||
$type = self::LOGIN;
|
||||
}
|
||||
elseif($script_name == 'rpc.php')
|
||||
{
|
||||
$type = self::SYNCML;
|
||||
}
|
||||
elseif($script_name == 'groupdav.php')
|
||||
{
|
||||
$type = self::GROUPDAV;
|
||||
}
|
||||
elseif($script_name == 'webdav.php')
|
||||
{
|
||||
$type = self::WEBDAV;
|
||||
}
|
||||
elseif($script_name == 'share.php')
|
||||
{
|
||||
$type = self::SHARING;
|
||||
}
|
||||
elseif(basename(dirname($script)) == 'collabora' || $currentapp == 'collabora')
|
||||
{
|
||||
$type = self::WOPI;
|
||||
}
|
||||
elseif(basename(dirname($script)) == 'activesync' || $currentapp == 'activesync')
|
||||
{
|
||||
$type = self::ESYNC;
|
||||
}
|
||||
elseif(basename(dirname($script)) == 'setup' || $currentapp == 'setup')
|
||||
{
|
||||
$type = self::SETUP;
|
||||
}
|
||||
elseif ($currentapp == 'sitemgr-link')
|
||||
{
|
||||
$type = self::SITEMGR;
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = self::WEBGUI;
|
||||
}
|
||||
//error_log(__METHOD__."('$request_uri', '$currentapp', $nologin) --> '$type'");
|
||||
return $type;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user