summaryrefslogtreecommitdiff
path: root/inc/auth
diff options
context:
space:
mode:
authorGabriel Birke <Gabriel.Birke@delti.com>2008-08-17 16:11:21 +0200
committerGabriel Birke <Gabriel.Birke@delti.com>2008-08-17 16:11:21 +0200
commit7d3c8d4263d48bd16be068d3b134f70451afac94 (patch)
treebfed95742d29aca438887ddaa84869ed0adda5f7 /inc/auth
parente7835c601a9d31a48299c5cf122de0df6f61a08a (diff)
downloadrpg-7d3c8d4263d48bd16be068d3b134f70451afac94.tar.gz
rpg-7d3c8d4263d48bd16be068d3b134f70451afac94.tar.bz2
Wrap user modifications in events
Adds a wrapper function in the basic auth class which is used by the core code to modify the user database. The wrapper function signals events and delegates the action to the auth backend. darcs-hash:20080817141121-79ce3-3300a4342b62a7a18ebcc9a765d87b30a0264621.gz
Diffstat (limited to 'inc/auth')
-rw-r--r--inc/auth/basic.class.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/inc/auth/basic.class.php b/inc/auth/basic.class.php
index c3bb9d32e..c93e3d5c5 100644
--- a/inc/auth/basic.class.php
+++ b/inc/auth/basic.class.php
@@ -90,6 +90,38 @@ class auth_basic {
}
/**
+ * Trigger the AUTH_USERDATA_CHANGE event and call the modification function. [ DO NOT OVERRIDE ]
+ *
+ * You should use this function instead of calling createUser, modifyUser or
+ * deleteUsers directly. The event handlers can prevent the modification, for
+ * example for enforcing a user name schema.
+ *
+ * @author Gabriel Birke <birke@d-scribe.de>
+ * @param string $type Modification type ('create', 'modify', 'delete')
+ * @param array $params Parameters for the createUser, modifyUser or deleteUsers method. The content of this array depends on the modification type
+ * @return mixed Result from the modification function or false if an event handler has canceled the action
+ */
+ function triggerUserMod($type, $params)
+ {
+ $validTypes = array(
+ 'create' => 'createUser',
+ 'modify' => 'modifyUser',
+ 'delete' => 'deleteUsers'
+ );
+ if(empty($validTypes[$type]))
+ return false;
+ $eventdata = array('type' => $type, 'params' => $params, 'modification_result' => null);
+ $evt = new Doku_Event('AUTH_USER_CHANGE', $eventdata);
+ if ($evt->advise_before(true)) {
+ $result = call_user_func_array(array($this, $validTypes[$type]), $params);
+ $evt->data['modification_result'] = $result;
+ }
+ $evt->advise_after();
+ unset($evt);
+ return $result;
+ }
+
+ /**
* Log off the current user [ OPTIONAL ]
*
* Is run in addition to the ususal logoff method. Should
@@ -290,6 +322,7 @@ class auth_basic {
return array();
}
+
/**
* Check Session Cache validity [implement only where required/possible]
*