refactoring
This commit is contained in:
parent
2a10013f36
commit
077556a6a9
|
@ -57,9 +57,10 @@ include_once("html.inc");
|
||||||
$modulesINC_dirname = substr(__FILE__, 0, strlen(__FILE__) - 12) . "/modules";
|
$modulesINC_dirname = substr(__FILE__, 0, strlen(__FILE__) - 12) . "/modules";
|
||||||
$modulesINC_dir = dir($modulesINC_dirname);
|
$modulesINC_dir = dir($modulesINC_dirname);
|
||||||
// get module names.
|
// get module names.
|
||||||
while ($entry = $modulesINC_dir->read())
|
while ($entry = $modulesINC_dir->read()) {
|
||||||
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($modulesINC_dirname . '/'.$entry)) {
|
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($modulesINC_dirname . '/'.$entry)) {
|
||||||
include_once($modulesINC_dirname . '/'.$entry);
|
include_once($modulesINC_dirname . '/'.$entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1183,15 +1183,15 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errors[] = $error;
|
$errors[] = $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->get_scope()=='user') {
|
if (($this->get_scope() == 'user') && !get_preg($this->attributes['uid'][0], 'username')) {
|
||||||
// Check if Username contains only valid characters
|
// Check if Username contains only valid characters
|
||||||
if (!get_preg($this->attributes['uid'][0], 'username'))
|
|
||||||
$errors[] = $this->messages['uid'][2];
|
$errors[] = $this->messages['uid'][2];
|
||||||
}
|
}
|
||||||
if ($this->get_scope()=='host') {
|
if ($this->get_scope() == 'host') {
|
||||||
// Check if Hostname contains only valid characters
|
// Check if Hostname contains only valid characters
|
||||||
if (!get_preg($this->attributes['uid'][0], 'hostname'))
|
if (!get_preg($this->attributes['uid'][0], 'hostname')) {
|
||||||
$errors[] = $this->messages['uid'][4];
|
$errors[] = $this->messages['uid'][4];
|
||||||
|
}
|
||||||
if (!isset($this->attributes[$homedirAttrName][0])) {
|
if (!isset($this->attributes[$homedirAttrName][0])) {
|
||||||
$this->attributes[$homedirAttrName][0] = '/dev/null';
|
$this->attributes[$homedirAttrName][0] = '/dev/null';
|
||||||
}
|
}
|
||||||
|
|
|
@ -924,8 +924,9 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
$errors[] = $this->messages['cn'][0];
|
$errors[] = $this->messages['cn'][0];
|
||||||
}
|
}
|
||||||
// Check if Groupname contains only valid characters
|
// Check if Groupname contains only valid characters
|
||||||
if ( !get_preg($this->attributes['cn'][0],'groupname'))
|
if (!get_preg($this->attributes['cn'][0],'groupname')) {
|
||||||
$errors[] = $this->messages['cn'][2];
|
$errors[] = $this->messages['cn'][2];
|
||||||
|
}
|
||||||
// Create automatic useraccount with number if original user already exists
|
// Create automatic useraccount with number if original user already exists
|
||||||
// Reset name to original name if new name is in use
|
// Reset name to original name if new name is in use
|
||||||
// Set username back to original name if new group name is in use
|
// Set username back to original name if new group name is in use
|
||||||
|
@ -933,34 +934,36 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
$this->attributes['cn'][0] = $this->orig['cn'][0];
|
$this->attributes['cn'][0] = $this->orig['cn'][0];
|
||||||
}
|
}
|
||||||
// Change gid to a new gid until a free gid is found
|
// Change gid to a new gid until a free gid is found
|
||||||
else while ($this->groupNameExists($this->attributes['cn'][0])) {
|
else {
|
||||||
// get last character of group name
|
while ($this->groupNameExists($this->attributes['cn'][0])) {
|
||||||
$lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1);
|
// get last character of group name
|
||||||
// Last character is no number
|
$lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1);
|
||||||
if ( !preg_match('/^([0-9])+$/', $lastchar))
|
// Last character is no number
|
||||||
/* Last character is no number. Therefore we only have to
|
if ( !preg_match('/^([0-9])+$/', $lastchar))
|
||||||
* add "2" to it.
|
/* Last character is no number. Therefore we only have to
|
||||||
*/
|
* add "2" to it.
|
||||||
$this->attributes['cn'][0] = $this->attributes['cn'][0] . '2';
|
|
||||||
else {
|
|
||||||
/* Last character is a number -> we have to increase the number until we've
|
|
||||||
* found a groupname with trailing number which is not in use.
|
|
||||||
*
|
|
||||||
* $i will show us were we have to split groupname so we get a part
|
|
||||||
* with the groupname and a part with the trailing number
|
|
||||||
*/
|
*/
|
||||||
$i=strlen($this->attributes['cn'][0])-1;
|
$this->attributes['cn'][0] = $this->attributes['cn'][0] . '2';
|
||||||
$mark = false;
|
else {
|
||||||
// Set $i to the last character which is a number in $account_new->general_username
|
/* Last character is a number -> we have to increase the number until we've
|
||||||
while (!$mark) {
|
* found a groupname with trailing number which is not in use.
|
||||||
if (preg_match('/^([0-9])+$/',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--;
|
*
|
||||||
else $mark=true;
|
* $i will show us were we have to split groupname so we get a part
|
||||||
|
* with the groupname and a part with the trailing number
|
||||||
|
*/
|
||||||
|
$i=strlen($this->attributes['cn'][0])-1;
|
||||||
|
$mark = false;
|
||||||
|
// Set $i to the last character which is a number in $account_new->general_username
|
||||||
|
while (!$mark) {
|
||||||
|
if (preg_match('/^([0-9])+$/',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--;
|
||||||
|
else $mark=true;
|
||||||
|
}
|
||||||
|
// increase last number with one
|
||||||
|
$firstchars = substr($this->attributes['cn'][0], 0, $i+1);
|
||||||
|
$lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i);
|
||||||
|
// Put username together
|
||||||
|
$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
|
||||||
}
|
}
|
||||||
// increase last number with one
|
|
||||||
$firstchars = substr($this->attributes['cn'][0], 0, $i+1);
|
|
||||||
$lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i);
|
|
||||||
// Put username together
|
|
||||||
$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Show warning if lam has changed group name
|
// Show warning if lam has changed group name
|
||||||
|
|
|
@ -42,9 +42,10 @@ include_once("selfService.inc");
|
||||||
$typesINC_dirname = substr(__FILE__, 0, strlen(__FILE__) - 10) . "/types";
|
$typesINC_dirname = substr(__FILE__, 0, strlen(__FILE__) - 10) . "/types";
|
||||||
$typesINC_dir = dir($typesINC_dirname);
|
$typesINC_dir = dir($typesINC_dirname);
|
||||||
// get module names.
|
// get module names.
|
||||||
while ($entry = $typesINC_dir->read())
|
while ($entry = $typesINC_dir->read()) {
|
||||||
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($typesINC_dirname . '/'.$entry)) {
|
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($typesINC_dirname . '/'.$entry)) {
|
||||||
include_once($typesINC_dirname . '/'.$entry);
|
include_once($typesINC_dirname . '/'.$entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue