diff options
Diffstat (limited to 'lib/plugins/authmysql/auth.php')
-rw-r--r-- | lib/plugins/authmysql/auth.php | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php index 95c62f636..1b7d0bfa4 100644 --- a/lib/plugins/authmysql/auth.php +++ b/lib/plugins/authmysql/auth.php @@ -115,7 +115,8 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * Check if the given config strings are set * * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> - * @param array $keys + * + * @param string[] $keys * @param bool $wop is this a check for a write operation? * @return bool */ @@ -221,6 +222,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { if($this->_openDB()) { if(($info = $this->_getUserInfo($user)) !== false) { + msg($this->getLang('userexists'), -1); return false; // user already exists } @@ -234,7 +236,13 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { $rc = $this->_addUser($user, $pwd, $name, $mail, $grps); $this->_unlockTables(); $this->_closeDB(); - if($rc) return true; + if(!$rc) { + msg($this->getLang('writefail')); + return null; + } + return true; + } else { + msg($this->getLang('connectfail'), -1); } return null; // return error } @@ -278,13 +286,15 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { $rc = $this->_updateUserInfo($user, $changes); - if($rc && isset($changes['grps']) && $this->cando['modGroups']) { + if(!$rc) { + msg($this->getLang('usernotexists'), -1); + } elseif(isset($changes['grps']) && $this->cando['modGroups']) { $groups = $this->_getGroups($user); $grpadd = array_diff($changes['grps'], $groups); $grpdel = array_diff($groups, $changes['grps']); foreach($grpadd as $group) { - if(($this->_addUserToGroup($user, $group, 1)) == false) { + if(($this->_addUserToGroup($user, $group, true)) == false) { $rc = false; } } @@ -294,10 +304,14 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { $rc = false; } } + + if(!$rc) msg($this->getLang('writefail')); } $this->_unlockTables(); $this->_closeDB(); + } else { + msg($this->getLang('connectfail'), -1); } return $rc; } @@ -327,6 +341,8 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { $this->_unlockTables(); } $this->_closeDB(); + } else { + msg($this->getLang('connectfail'), -1); } return $count; } @@ -366,7 +382,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * * @param int $first index of first user to be returned * @param int $limit max number of users to be returned - * @param array|string $filter array of field/pattern pairs + * @param array $filter array of field/pattern pairs * @return array userinfo (refer getUserData for internal userinfo details) */ public function retrieveUsers($first = 0, $limit = 0, $filter = array()) { @@ -612,7 +628,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { if($uid) { foreach($grps as $group) { - $gid = $this->_addUserToGroup($user, $group, 1); + $gid = $this->_addUserToGroup($user, $group, true); if($gid === false) break; } @@ -668,7 +684,6 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * * @param string $user username of the user whose data is to be removed from the cache * if null, empty the whole cache - * @return none */ protected function _flushUserInfoCache($user=null) { if (is_null($user)) { @@ -750,7 +765,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * * @param string $user user's nick to get data for - * @return bool|array false on error, user info on success + * @return false|array false on error, user info on success */ protected function _retrieveUserInfo($user) { $sql = str_replace('%{user}', $this->_escape($user), $this->getConf('getUserInfo')); @@ -777,7 +792,6 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * * @param string $user user's nick being updated * @param array $changes array of items to change as pairs of item and value - * @param mixed $uid user id of dataset to change, must be unique in DB * @return bool true on success or false on error * * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> @@ -838,7 +852,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * * @param string $group group name which id is desired - * @return mixed group id + * @return false|string group id */ protected function _getGroupID($group) { if($this->dbcon) { @@ -911,7 +925,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * * @param string $query SQL string that contains the query - * @return array with the result table + * @return array|false with the result table */ protected function _queryDB($query) { if($this->getConf('debug') >= 2) { @@ -1002,6 +1016,8 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * abrogated. * * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> + * + * @return bool */ protected function _unlockTables() { if($this->dbcon) { |