Applied patch by Sven Geuer for the bugs he reported
* Fixes #23, #24, #25, #26
This commit is contained in:
parent
120577d003
commit
d2bd1b0ef0
3 changed files with 18 additions and 9 deletions
|
@ -169,5 +169,7 @@ function cmp_by_usernames(&$user1, &$user2) {
|
|||
|
||||
$namemapdata = file_get_contents($davconfig['namemap.file']);
|
||||
$namemap = json_decode($namemapdata, true);
|
||||
if (is_array($namemap)) {
|
||||
uasort($namemap, "cmp_by_usernames");
|
||||
}
|
||||
?>
|
|
@ -102,7 +102,7 @@ function displayusereditor(title, userid, username, firstname, lastname, groups)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (!this.groups.value.match(/^([0-9a-zA-z]+[,\s]*)+$/)) {
|
||||
if (!this.groups.value.match(/^[0-9a-zA-z]+(\s*,\s*[0-9a-zA-z]+)*$/)) {
|
||||
alert(intl.translate("The groups field has to be a comma separated list of group names which must consist of letters or digits!"));
|
||||
this.groups.focus();
|
||||
return false;
|
||||
|
|
|
@ -123,7 +123,7 @@ function validateUserData(&$userdata, $forinsert) {
|
|||
if (empty($userdata['lastname'])) {
|
||||
$userdata['lastname'] = null;
|
||||
}
|
||||
if (!preg_match('/^([0-9a-zA-z]+[,\s]*)+$/', $userdata['groups'])) {
|
||||
if (!preg_match('/^[0-9a-zA-z]+(\s*,\s*[0-9a-zA-z]+)*$/', $userdata['groups'])) {
|
||||
array_push($errormsgs, _('Groups must be a list of group names separated by commas. Group names must consist of letters and digits.'));
|
||||
}
|
||||
return $errormsgs;
|
||||
|
@ -209,7 +209,12 @@ function updateGroups(&$userdata) {
|
|||
fprintf($fh, "%s: %s\n", $group, implode(" ", $users));
|
||||
$written[$group] = true;
|
||||
} else {
|
||||
fwrite($fh, $groupline);
|
||||
if (in_array($userdata['username'], $users)) {
|
||||
array_splice($users, array_search($userdata['username'], $users),1);
|
||||
}
|
||||
if (count($users) > 0 ) {
|
||||
fprintf($fh, "%s: %s\n", $group, implode(" ", $users));
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($written as $group => $done) {
|
||||
|
@ -286,8 +291,8 @@ function removeDigest($username) {
|
|||
$digests = file($GLOBALS['davconfig']['digest.file']);
|
||||
$fh = fopen($GLOBALS['davconfig']['digest.file'], 'w');
|
||||
foreach ($digests as $digest) {
|
||||
list($username, $realm, $data) = explode(":", $digest);
|
||||
if (!($username == $userdata['username']
|
||||
list($user, $realm, $data) = explode(":", $digest);
|
||||
if (!($user == $username
|
||||
&& $realm == $GLOBALS['davconfig']['dav.realm'])) {
|
||||
fwrite($fh, $digest);
|
||||
}
|
||||
|
@ -311,10 +316,12 @@ function removeFromGroups($username) {
|
|||
$users[$key] = trim($user);
|
||||
}
|
||||
if (in_array($username, $users)) {
|
||||
$users = array_splice($users, array_search($username, $users));
|
||||
array_splice($users, array_search($username, $users),1);
|
||||
}
|
||||
if (count($users) > 0 ) {
|
||||
fprintf($fh, "%s: %s\n", $group, implode(" ", $users));
|
||||
}
|
||||
}
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue