summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/plugins/auth.php146
1 files changed, 80 insertions, 66 deletions
diff --git a/lib/plugins/auth.php b/lib/plugins/auth.php
index 39d63d8a1..4c3c585cf 100644
--- a/lib/plugins/auth.php
+++ b/lib/plugins/auth.php
@@ -13,14 +13,14 @@ if(!defined('DOKU_INC')) die();
* @author Jan Schumann <js@jschumann-it.com>
*/
class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
- var $success = true;
+ public $success = true;
/**
- * Posible things an auth backend module may be able to
+ * Possible things an auth backend module may be able to
* do. The things a backend can do need to be set to true
* in the constructor.
*/
- var $cando = array (
+ protected $cando = array(
'addUser' => false, // can Users be created?
'delUser' => false, // can Users be deleted?
'modLogin' => false, // can login names be changed?
@@ -32,7 +32,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
'getUserCount'=> false, // can the number of users be retrieved?
'getGroups' => false, // can a list of available groups be retrieved?
'external' => false, // does the module do external auth checking?
- 'logout' => true, // can the user logout again? (eg. not possible with HTTP auth)
+ 'logout' => true, // can the user logout again? (eg. not possible with HTTP auth)
);
/**
@@ -46,7 +46,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
*
* @author Christopher Smith <chris@jalakai.co.uk>
*/
- function __construct() {
+ public function __construct() {
// the base class constructor does nothing, derived class
// constructors do the real work
}
@@ -62,29 +62,30 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* shortcut capabilities start with uppercase letter
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $cap the capability to check
* @return bool
*/
- function canDo($cap) {
- switch($cap){
+ public function canDo($cap) {
+ switch($cap) {
case 'Profile':
// can at least one of the user's properties be changed?
- return ( $this->cando['modPass'] ||
- $this->cando['modName'] ||
- $this->cando['modMail'] );
+ return ($this->cando['modPass'] ||
+ $this->cando['modName'] ||
+ $this->cando['modMail']);
break;
case 'UserMod':
// can at least anything be changed?
- return ( $this->cando['modPass'] ||
- $this->cando['modName'] ||
- $this->cando['modMail'] ||
- $this->cando['modLogin'] ||
- $this->cando['modGroups'] ||
- $this->cando['modMail'] );
+ return ($this->cando['modPass'] ||
+ $this->cando['modName'] ||
+ $this->cando['modMail'] ||
+ $this->cando['modLogin'] ||
+ $this->cando['modGroups'] ||
+ $this->cando['modMail']);
break;
default:
// print a helping message for developers
- if(!isset($this->cando[$cap])){
- msg("Check for unknown capability '$cap' - Do you use an outdated Plugin?",-1);
+ if(!isset($this->cando[$cap])) {
+ msg("Check for unknown capability '$cap' - Do you use an outdated Plugin?", -1);
}
return $this->cando[$cap];
}
@@ -99,10 +100,10 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
*
* @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
+ * @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) {
+ public function triggerUserMod($type, $params) {
$validTypes = array(
'create' => 'createUser',
'modify' => 'modifyUser',
@@ -111,9 +112,9 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
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 = 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();
@@ -130,7 +131,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* @see auth_logoff()
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function logOff(){
+ public function logOff() {
}
/**
@@ -166,7 +167,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* @param bool $sticky Cookie should not expire
* @return bool true on successful auth
*/
- function trustExternal($user,$pass,$sticky=false){
+ public function trustExternal($user, $pass, $sticky = false) {
/* some example:
global $USERINFO;
@@ -197,9 +198,11 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* May be ommited if trustExternal is used.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $user the user name
+ * @param string $pass the clear text password
* @return bool
*/
- function checkPass($user,$pass){
+ public function checkPass($user, $pass) {
msg("no valid authorisation system in use", -1);
return false;
}
@@ -215,9 +218,10 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* grps array list of groups the user is in
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $user the user name
* @return array containing user data or false
*/
- function getUserData($user) {
+ public function getUserData($user) {
if(!$this->cando['external']) msg("no valid authorisation system in use", -1);
return false;
}
@@ -234,8 +238,14 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* Set addUser capability when implemented
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $user
+ * @param string $pass
+ * @param string $name
+ * @param string $mail
+ * @param null|array $grps
+ * @return bool|null
*/
- function createUser($user,$pass,$name,$mail,$grps=null){
+ public function createUser($user, $pass, $name, $mail, $grps = null) {
msg("authorisation method does not allow creation of new users", -1);
return null;
}
@@ -246,11 +256,11 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* Set the mod* capabilities according to the implemented features
*
* @author Chris Smith <chris@jalakai.co.uk>
- * @param $user nick of the user to be changed
- * @param $changes array of field/value pairs to be changed (password will be clear text)
+ * @param string $user nick of the user to be changed
+ * @param array $changes array of field/value pairs to be changed (password will be clear text)
* @return bool
*/
- function modifyUser($user, $changes) {
+ public function modifyUser($user, $changes) {
msg("authorisation method does not allow modifying of user data", -1);
return false;
}
@@ -264,7 +274,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* @param array $users
* @return int number of users deleted
*/
- function deleteUsers($users) {
+ public function deleteUsers($users) {
msg("authorisation method does not allow deleting of users", -1);
return false;
}
@@ -275,9 +285,11 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
*
* Set getUserCount capability when implemented
*
- * @author Chris Smith <chris@jalakai.co.uk>
+ * @author Chris Smith <chris@jalakai.co.uk>
+ * @param array $filter array of field/pattern pairs, empty array for no filter
+ * @return int
*/
- function getUserCount($filter=array()) {
+ public function getUserCount($filter = array()) {
msg("authorisation method does not provide user counts", -1);
return 0;
}
@@ -288,12 +300,12 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* Set getUsers capability when implemented
*
* @author Chris Smith <chris@jalakai.co.uk>
- * @param start index of first user to be returned
- * @param limit max number of users to be returned
- * @param filter array of field/pattern pairs, null for no filter
- * @return array of userinfo (refer getUserData for internal userinfo details)
+ * @param int $start index of first user to be returned
+ * @param int $limit max number of users to be returned
+ * @param array $filter array of field/pattern pairs, null for no filter
+ * @return array list of userinfo (refer getUserData for internal userinfo details)
*/
- function retrieveUsers($start=0,$limit=-1,$filter=null) {
+ public function retrieveUsers($start = 0, $limit = -1, $filter = null) {
msg("authorisation method does not support mass retrieval of user data", -1);
return array();
}
@@ -304,9 +316,10 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* Set addGroup capability when implemented
*
* @author Chris Smith <chris@jalakai.co.uk>
+ * @param string $group
* @return bool
*/
- function addGroup($group) {
+ public function addGroup($group) {
msg("authorisation method does not support independent group creation", -1);
return false;
}
@@ -317,9 +330,11 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* Set getGroups capability when implemented
*
* @author Chris Smith <chris@jalakai.co.uk>
+ * @param int $start
+ * @param int $limit
* @return array
*/
- function retrieveGroups($start=0,$limit=0) {
+ public function retrieveGroups($start = 0, $limit = 0) {
msg("authorisation method does not support group list retrieval", -1);
return array();
}
@@ -329,8 +344,10 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
*
* When your backend is caseinsensitive (eg. you can login with USER and
* user) then you need to overwrite this method and return false
+ *
+ * @return bool
*/
- function isCaseSensitive(){
+ public function isCaseSensitive() {
return true;
}
@@ -344,10 +361,10 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* This should be used to enforce username restrictions.
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @param string $user - username
- * @param string - the cleaned username
+ * @param string $user username
+ * @return string the cleaned username
*/
- function cleanUser($user){
+ public function cleanUser($user) {
return $user;
}
@@ -363,14 +380,13 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* Groupnames are to be passed without a leading '@' here.
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @param string $group - groupname
- * @param string - the cleaned groupname
+ * @param string $group groupname
+ * @return string the cleaned groupname
*/
- function cleanGroup($group){
+ public function cleanGroup($group) {
return $group;
}
-
/**
* Check Session Cache validity [implement only where required/possible]
*
@@ -396,27 +412,25 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* @author Andreas Gohr <andi@splitbrain.org>
* @return bool
*/
- function useSessionCache($user){
+ public function useSessionCache($user) {
global $conf;
return ($_SESSION[DOKU_COOKIE]['auth']['time'] >= @filemtime($conf['cachedir'].'/sessionpurge'));
}
+ /**
+ * loadConfig()
+ * merges the plugin's default settings with any local settings
+ * this function is automatically called through getConf()
+ */
+ function loadConfig() {
+ global $conf;
- /**
- * loadConfig()
- * merges the plugin's default settings with any local settings
- * this function is automatically called through getConf()
- */
- function loadConfig(){
- global $conf;
-
- parent::loadConfig();
-
- $this->conf['debug'] = $conf['debug'];
- $this->conf['useacl'] = $conf['useacl'];
- $this->conf['disableactions'] = $conf['disableactions'];
- $this->conf['autopasswd'] = $conf['autopasswd'];
- $this->conf['passcrypt'] = $conf['ssha'];
- }
+ parent::loadConfig();
+ $this->conf['debug'] = $conf['debug'];
+ $this->conf['useacl'] = $conf['useacl'];
+ $this->conf['disableactions'] = $conf['disableactions'];
+ $this->conf['autopasswd'] = $conf['autopasswd'];
+ $this->conf['passcrypt'] = $conf['ssha'];
+ }
}