From ec1ad787659a5ea95e73a50f1e8aeab4a21e372d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 24 Aug 2010 12:42:14 +0000 Subject: [PATCH] Add possibility to include login method in a module --- .../triggers/interface_all_Demo.class.php-NORUN | 8 ++++++++ htdocs/main.inc.php | 14 ++++++++++---- htdocs/user/logout.php | 7 +++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN index 64153ce2e3a..c0af800d346 100644 --- a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN +++ b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN @@ -108,6 +108,10 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + elseif ($action == 'USER_UPDATE_SESSION') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } elseif ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -125,6 +129,10 @@ class InterfaceDemo dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } elseif ($action == 'USER_DELETE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'USER_LOGOUT') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index cedd4fce28d..c519e2c972e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -336,10 +336,7 @@ if (! defined('NOLOGIN')) if (is_array($conf->login_method_modules) && !empty($conf->login_method_modules)) { $login = getLoginMethod(); - if ($login) - { - $test=false; - } + if ($login) $test=false; } // Validation tests user / password @@ -486,6 +483,15 @@ if (! defined('NOLOGIN')) header('Location: '.DOL_URL_ROOT.'/index.php'); exit; } + else + { + // Call triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('USER_UPDATE_SESSION',$user,$user,$langs,$conf,(isset($_POST["entity"])?$_POST["entity"]:0)); + if ($result < 0) { $error++; } + // End call triggers + } } // Is it a new session ? diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 8dec41181c6..22b77af9774 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -41,6 +41,13 @@ if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuse die("Disconnection does not work when connection was made in mode ".$_SESSION["dol_authmode"]); } +// Appel des triggers +include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); +$interface=new Interfaces($db); +$result=$interface->run_triggers('USER_LOGOUT',$user,$user,$langs,$conf,$conf->entity); +if ($result < 0) { $error++; } +// Fin appel triggers + // Define url to go after disconnect $urlfrom=empty($_SESSION["urlfrom"])?'':$_SESSION["urlfrom"];