Utilisation de la classe hooks au lieu des if(method_exist())
This commit is contained in:
parent
c76d1916ce
commit
d3701cc0fa
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
// EXPERIMENTAL : user data export.
|
||||
die('Proof of concept');
|
||||
|
||||
include("config.php");
|
||||
|
||||
|
@ -10,14 +12,18 @@ $mem->su($id);
|
|||
|
||||
$dom->lock();
|
||||
|
||||
/*
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_export")) {
|
||||
$GLOBALS[$c]->alternc_export("/tmp");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$hooks->invoke("alternc_export",array("/tmp"));
|
||||
|
||||
$dom->unlock();
|
||||
|
||||
$mem->unsu();
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -355,11 +355,14 @@ class m_admin {
|
|||
// Triggering hooks
|
||||
$mem->su($uid);
|
||||
// TODO: old hook method FIXME: when unused remove this
|
||||
/*
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_add_member")) {
|
||||
$GLOBALS[$c]->alternc_add_member();
|
||||
}
|
||||
}
|
||||
*/
|
||||
$hooks->invoke("alternc_add_member");
|
||||
// New hook way
|
||||
$hooks->invoke("hook_admin_add_member");
|
||||
$mem->unsu();
|
||||
|
@ -544,11 +547,14 @@ EOF;
|
|||
$dom->hook_admin_del_member();
|
||||
|
||||
// TODO: old hook method, FIXME: remove when unused
|
||||
/*
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_del_member")) {
|
||||
$GLOBALS[$c]->alternc_del_member();
|
||||
}
|
||||
}
|
||||
*/
|
||||
$hooks->invoke("alternc_del_member");
|
||||
$hooks->invoke("hook_admin_del_member");
|
||||
|
||||
if (($db->query("DELETE FROM membres WHERE uid='$uid';")) &&
|
||||
|
@ -984,14 +990,16 @@ EOF;
|
|||
* @return array an indexed array of associative array from the MySQL "policy" table
|
||||
*/
|
||||
function listPasswordPolicies() {
|
||||
global $db,$classes;
|
||||
global $db,$classes,$hooks;
|
||||
$tmp1=array();
|
||||
$tmp2=array();
|
||||
$tmp3=array();
|
||||
$policies=array();
|
||||
$db->query("SELECT * FROM policy;");
|
||||
while ($db->next_record()) {
|
||||
$tmp1[$db->Record["name"]]=$db->Record;
|
||||
}
|
||||
/* * /
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_password_policy")) {
|
||||
$res=$GLOBALS[$c]->alternc_password_policy(); // returns an array
|
||||
|
@ -1000,6 +1008,13 @@ EOF;
|
|||
}
|
||||
}
|
||||
}
|
||||
/* */
|
||||
$tmp3=$hooks->invoke("alternc_password_policy");
|
||||
foreach ($tmp3 as $v) {
|
||||
foreach ($v as $l=>$m) {
|
||||
$tmp2[$l]=$m;
|
||||
}
|
||||
}
|
||||
foreach($tmp2 as $k=>$v) {
|
||||
if (!isset($tmp1[$k])) {
|
||||
// Default policy :
|
||||
|
|
|
@ -293,7 +293,7 @@ class m_mem {
|
|||
* @return boolean TRUE si la session a bien été détruite, FALSE sinon.
|
||||
*/
|
||||
function del_session() {
|
||||
global $db,$user,$err,$cuid,$classes;
|
||||
global $db,$user,$err,$cuid,$classes,$hooks;
|
||||
$err->log("mem","del_session");
|
||||
$_COOKIE["session"]=addslashes(isset($_COOKIE["session"])?$_COOKIE["session"]:'');
|
||||
setcookie("session","",0,"/");
|
||||
|
@ -322,11 +322,15 @@ class m_mem {
|
|||
$err->error=0;
|
||||
|
||||
# Invoker le logout dans toutes les autres classes
|
||||
/*
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_del_session")) {
|
||||
$GLOBALS[$c]->alternc_del_session();
|
||||
}
|
||||
}
|
||||
*/
|
||||
$hooks->invoke("alternc_del_session");
|
||||
|
||||
session_unset();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue