Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add post_login and post_logout hooks

  • Loading branch information...
commit b035e148ba44f335daee62a07e520c20a0628894 1 parent 0f78256
Dieter Plaetinck authored Dieterbe committed
36 hooks/functions/example.php
View
@@ -38,6 +38,42 @@ function example_post_session_init() {
add_hook('post_session_init','example_post_session_init');
/**
+ * The post_login function is called after the user has (tried to) login.
+ *
+ * Arguments available are:
+ * @param boolean Success
+ */
+function example_post_login() {
+ $args = func_get_args();
+
+ system_message(array(
+ 'title'=>sprintf('Hook called [%s]',__METHOD__),
+ 'body'=>sprintf('<i>Global Vars</i>: <small>%s</small>',join('| ',array_keys($GLOBALS))),
+ 'type'=>'info','special'=>true));
+
+ return true;
+}
+add_hook('post_login','example_post_login');
+
+/**
+ * The post_logout function is called after the user has (tried to) logout.
+ *
+ * Arguments available are:
+ * @param boolean Success
+ */
+function example_post_logout() {
+ $args = func_get_args();
+
+ system_message(array(
+ 'title'=>sprintf('Hook called [%s]',__METHOD__),
+ 'body'=>sprintf('<i>Global Vars</i>: <small>%s</small>',join('| ',array_keys($GLOBALS))),
+ 'type'=>'info','special'=>true));
+
+ return true;
+}
+add_hook('post_logout','example_post_logout');
+
+/**
* This pre_connect function is called before making a connection to the LDAP server.
* While PLA makes many calls to connect to the LDAP server, this is called only once
* when caching is turned on.
9 htdocs/login.php
View
@@ -22,16 +22,21 @@
'type'=>'warn'),
sprintf('cmd.php?cmd=login_form&server_id=%s',get_request('server_id','REQUEST')));
-if ($app['server']->login($user['login'],$user['password'],'user'))
+if ($app['server']->login($user['login'],$user['password'],'user')) {
+ if (function_exists('run_hook'))
+ run_hook('post_login',array('success'=> true));
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Successfully logged into server.'),
'type'=>'info'),
sprintf('cmd.php?server_id=%s',get_request('server_id','REQUEST')));
-else
+} else {
+ if (function_exists('run_hook'))
+ run_hook('post_login',array('success'=> false));
system_message(array(
'title'=>_('Failed to Authenticate to server'),
'body'=>_('Invalid Username or Password.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',get_request('server_id','REQUEST')));
+}
?>
2  htdocs/login_form.php
View
@@ -34,6 +34,8 @@
# When we pop up the basic athentication, we come back to this script, so try the login again.
if ($app['server']->isLoggedIn('user')) {
+ if (function_exists('run_hook'))
+ run_hook('post_login',array('success'=> true));
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Successfully logged into server.'),
9 htdocs/logout.php
View
@@ -11,16 +11,21 @@
require './common.php';
-if ($app['server']->logout())
+if ($app['server']->logout()) {
+ if (function_exists('run_hook'))
+ run_hook('post_logout',array('success'=> true));
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Successfully logged out of server.'),
'type'=>'info'),
sprintf('index.php?server_id=%s',$app['server']->getIndex()));
-else
+} else {
+ if (function_exists('run_hook'))
+ run_hook('post_logout',array('success'=> false));
system_message(array(
'title'=>_('Failed to Logout of server'),
'body'=>_('Please report this error to the admins.'),
'type'=>'error'),
sprintf('index.php?server_id=%s',$app['server']->getIndex()));
+}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.