summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2014-03-14 17:58:53 +0000
committerChristopher Smith <chris@jalakai.co.uk>2014-03-14 17:58:53 +0000
commit06e3e0c7b506a637df1ea27c6a8a439756e7139d (patch)
tree99accf2efb7e3868a6d3356e612052ef24267fb9
parent792883c4aaba64146ea38cd62287c96cb8121c1f (diff)
downloadrpg-06e3e0c7b506a637df1ea27c6a8a439756e7139d.tar.gz
rpg-06e3e0c7b506a637df1ea27c6a8a439756e7139d.tar.bz2
use $requireGroups constants in auth classes; comments; code improvements
-rw-r--r--inc/common.php9
-rw-r--r--lib/plugins/auth.php4
-rw-r--r--lib/plugins/authmysql/auth.php10
3 files changed, 12 insertions, 11 deletions
diff --git a/inc/common.php b/inc/common.php
index 6851cdea3..9ed9e84d4 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1454,13 +1454,14 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') {
}
/**
- * Return the users realname or e-mail address for use
+ * Return the users real name or e-mail address for use
* in page footer and recent changes pages
*
* @author Andy Webber <dokuwiki AT andywebber DOT com>
*/
function editorinfo($username) {
global $conf;
+ /* @var DokuWiki_Auth_Plugin $auth */
global $auth;
switch($conf['showuseras']) {
@@ -1473,7 +1474,7 @@ function editorinfo($username) {
return hsc($username);
}
- if(isset($info) && $info) {
+ if(!empty($info)) {
switch($conf['showuseras']) {
case 'username':
return hsc($info['name']);
@@ -1485,9 +1486,9 @@ function editorinfo($username) {
default:
return hsc($username);
}
- } else {
- return hsc($username);
}
+
+ return hsc($username);
}
/**
diff --git a/lib/plugins/auth.php b/lib/plugins/auth.php
index f9e5cded9..9275611be 100644
--- a/lib/plugins/auth.php
+++ b/lib/plugins/auth.php
@@ -232,7 +232,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* at least these fields:
*
* name string full name of the user
- * mail string email addres of the user
+ * mail string email address of the user
* grps array list of groups the user is in
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -240,7 +240,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin {
* @param bool $requireGroups whether or not the returned data must include groups
* @return array containing user data or false
*/
- public function getUserData($user, $requireGroups=true) {
+ public function getUserData($user, $requireGroups=self::REQUIRE_GROUPS) {
if(!$this->cando['external']) msg("no valid authorisation system in use", -1);
return false;
}
diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php
index 0ddbff99b..d3906759b 100644
--- a/lib/plugins/authmysql/auth.php
+++ b/lib/plugins/authmysql/auth.php
@@ -182,7 +182,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
* when false, it maybe included, but is not required by the caller
* @return array|bool
*/
- public function getUserData($user, $requireGroups=true) {
+ public function getUserData($user, $requireGroups=DokuWiki_Auth_Plugin::REQUIRE_GROUPS) {
if($this->_cacheExists($user, $requireGroups)) {
return $this->cacheUserInfo[$user];
}
@@ -690,13 +690,13 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
*
* @return bool existence of required user information in the cache
*/
- protected function _cacheExists($user, $requireGroups=true) {
+ protected function _cacheExists($user, $requireGroups=DokuWiki_Auth_Plugin::REQUIRE_GROUPS) {
if (isset($this->cacheUserInfo[$user])) {
if (!is_array($this->cacheUserInfo[$user])) {
return true; // user doesn't exist
}
- if (!$requireGroups || isset($this->cacheUserInfo[$user]['grps'])) {
+ if ($requireGroups == DokuWiki_Auth_Plugin::IGNORE_GROUPS || isset($this->cacheUserInfo[$user]['grps'])) {
return true;
}
}
@@ -718,7 +718,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
* @return mixed false|array false if the user doesn't exist
* array containing user information if user does exist
*/
- protected function _getUserInfo($user, $requireGroups=true, $useCache=true) {
+ protected function _getUserInfo($user, $requireGroups=DokuWiki_Auth_Plugin::REQUIRE_GROUPS, $useCache=true) {
$info = null;
if ($useCache && isset($this->cacheUserInfo[$user])) {
@@ -729,7 +729,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
$info = $this->_retrieveUserInfo($user);
}
- if ($requireGroups && $info && !isset($info['grps'])) {
+ if (($requireGroups == DokuWiki_Auth_Plugin::REQUIRE_GROUPS) && $info && !isset($info['grps'])) {
$info['grps'] = $this->_getGroups($user);
}