changed error message handling in posixGroup
This commit is contained in:
parent
25f5991ec0
commit
0aa6874931
|
@ -57,11 +57,12 @@ class baseModule {
|
||||||
/** contains all ldap attributes which are loaded from ldap */
|
/** contains all ldap attributes which are loaded from ldap */
|
||||||
var $orig;
|
var $orig;
|
||||||
|
|
||||||
/** contains the last error messages of the module.
|
/** contains all error messages wich were troggered*/
|
||||||
* Ths variable is needed because we don't want to make
|
|
||||||
* unnecesarry checks when a attributes wasn't changed */
|
|
||||||
var $errors;
|
var $errors;
|
||||||
|
|
||||||
|
/** contains all error messages of a module */
|
||||||
|
var $errormessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new base module class
|
* Creates a new base module class
|
||||||
*
|
*
|
||||||
|
@ -80,6 +81,8 @@ class baseModule {
|
||||||
*/
|
*/
|
||||||
function init($base) {
|
function init($base) {
|
||||||
$this->base = $base;
|
$this->base = $base;
|
||||||
|
// load error messages
|
||||||
|
$this->loadErrorMessages();
|
||||||
// Create Arrays with ldap attributes
|
// Create Arrays with ldap attributes
|
||||||
$this->attributes =& $_SESSION[$this->base]->get_module_attributes(get_class($this));
|
$this->attributes =& $_SESSION[$this->base]->get_module_attributes(get_class($this));
|
||||||
$this->orig =& $_SESSION[$this->base]->get_module_attributes(get_class($this), true);
|
$this->orig =& $_SESSION[$this->base]->get_module_attributes(get_class($this), true);
|
||||||
|
@ -97,6 +100,7 @@ class baseModule {
|
||||||
*/
|
*/
|
||||||
function load_ldap_attributes($attr) {
|
function load_ldap_attributes($attr) {
|
||||||
// Load attributes which are displayed
|
// Load attributes which are displayed
|
||||||
|
$objectClassName = $this->attributes['objectClass'];
|
||||||
// unset count entries
|
// unset count entries
|
||||||
unset ($attr['count']);
|
unset ($attr['count']);
|
||||||
$attributes = array_keys($attr);
|
$attributes = array_keys($attr);
|
||||||
|
@ -114,6 +118,10 @@ class baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->attributes['objectClass'] = $objectClassName;
|
||||||
|
if (in_array($objectClassName[0], $attr['objectClass']))
|
||||||
|
$this->orig['objectClass'] = $objectClassName;
|
||||||
|
else $this->orig['objectClass'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,6 +142,11 @@ class baseModule {
|
||||||
return $this->scope;
|
return $this->scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is needed to avoid error messages */
|
||||||
|
function loadErrorMessages() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this module fits for the current scope.
|
* Returns true if this module fits for the current scope.
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,6 +35,23 @@ class posixGroup extends baseModule {
|
||||||
parent::baseModule($scope);
|
parent::baseModule($scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** this functin fills the error message array with messages
|
||||||
|
**/
|
||||||
|
function loadErrorMessages() {
|
||||||
|
//$this->errormessages['minGID'][0] = array('ERROR', _('Minimum GID number'), _('Minimum GID number is invalid or empty!'));
|
||||||
|
//$this->errormessages['maxGID'][0] = array('ERROR', _('Maximum GID number'), _('Maximum GID number is invalid or empty!'));
|
||||||
|
//$this->errormessages['cmpGID'][1] = array('ERROR', _('Maximum GID number'), _('Maximum GID number must be greater than minimum GID number!'));
|
||||||
|
$this->errormessages['userPassword'][0] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
|
||||||
|
$this->errormessages['userPassword'][1] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
|
||||||
|
$this->errormessages['gidNumber'][0] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'));
|
||||||
|
$this->errormessages['gidNumber'][2] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'));
|
||||||
|
$this->errormessages['gidNumber'][3] = array('ERROR', _('ID-Number'), _('No free ID-Number!'));
|
||||||
|
$this->errormessages['gidNumber'][4] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
||||||
|
$this->errormessages['cn'][0] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
|
||||||
|
$this->errormessages['cn'][1] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'));
|
||||||
|
$this->errormessages['cn'][2] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns meta data that is interpreted by parent class
|
* Returns meta data that is interpreted by parent class
|
||||||
*
|
*
|
||||||
|
@ -347,8 +364,6 @@ class posixGroup extends baseModule {
|
||||||
/* Write variables into object and do some regexp checks
|
/* Write variables into object and do some regexp checks
|
||||||
*/
|
*/
|
||||||
function proccess_attributes($post, $profile=false) {
|
function proccess_attributes($post, $profile=false) {
|
||||||
if ($this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0])
|
|
||||||
$errors['gidNumber'][] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'));
|
|
||||||
// Load attributes
|
// Load attributes
|
||||||
$this->attributes['description'][0] = $post['description'];
|
$this->attributes['description'][0] = $post['description'];
|
||||||
if ($post['userPassword_no']) $this->userPassword_no=true;
|
if ($post['userPassword_no']) $this->userPassword_no=true;
|
||||||
|
@ -360,12 +375,12 @@ class posixGroup extends baseModule {
|
||||||
else $this->changegids=false;
|
else $this->changegids=false;
|
||||||
if (isset($post['userPassword'])) {
|
if (isset($post['userPassword'])) {
|
||||||
if ($post['userPassword'] != $post['userPassword2']) {
|
if ($post['userPassword'] != $post['userPassword2']) {
|
||||||
$errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
|
$errors['userPassword'][] = $this->errormessages['userPassword'][0];
|
||||||
unset ($post['userPassword2']);
|
unset ($post['userPassword2']);
|
||||||
}
|
}
|
||||||
else $this->userPassword($post['userPassword']);
|
else $this->userPassword($post['userPassword']);
|
||||||
if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
|
if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
|
||||||
$errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
|
$errors['userPassword'][] = $this->errormessages['userPassword'][1];
|
||||||
}
|
}
|
||||||
if ($post['genpass']) $this->userPassword(genpasswd());
|
if ($post['genpass']) $this->userPassword(genpasswd());
|
||||||
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->errors['gidNumber'][0]='ERROR')) {
|
if ($this->attributes['gidNumber'][0]!=$post['gidNumber'] || ($this->errors['gidNumber'][0]='ERROR')) {
|
||||||
|
@ -398,10 +413,10 @@ class posixGroup extends baseModule {
|
||||||
$i = intval($minID);
|
$i = intval($minID);
|
||||||
while (in_array($i, $gids)) $i++;
|
while (in_array($i, $gids)) $i++;
|
||||||
if ($i>$maxID)
|
if ($i>$maxID)
|
||||||
$errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('No free ID-Number!'));
|
$errors['gidNumber'][] = $this->errormessages['gidNumber'][3];
|
||||||
else {
|
else {
|
||||||
$this->attributes['gidNumber'][0] = $i;
|
$this->attributes['gidNumber'][0] = $i;
|
||||||
$errors['gidNumber'][] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'));
|
$errors['gidNumber'][] = $this->errormessages['gidNumber'][2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else $this->attributes['gidNumber'][0] = $minID;
|
else $this->attributes['gidNumber'][0] = $minID;
|
||||||
|
@ -420,7 +435,7 @@ class posixGroup extends baseModule {
|
||||||
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
||||||
// id-number is in use, account is existing account and id-number is not used by itself
|
// id-number is in use, account is existing account and id-number is not used by itself
|
||||||
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) {
|
if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) {
|
||||||
$errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
$errors['gidNumber'][] = $this->errormessages['gidNumber'][4];
|
||||||
$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,10 +444,10 @@ class posixGroup extends baseModule {
|
||||||
if ($this->attributes['cn'][0]!=$post['cn'] || ($this->errors['cn'][0]='ERROR')) {
|
if ($this->attributes['cn'][0]!=$post['cn'] || ($this->errors['cn'][0]='ERROR')) {
|
||||||
$this->attributes['cn'][0] = $post['cn'];
|
$this->attributes['cn'][0] = $post['cn'];
|
||||||
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
|
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
|
||||||
$errors['cn'][] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
|
$errors['cn'][] = $this->errormessages['cn'][0];
|
||||||
// Check if Groupname contains only valid characters
|
// Check if Groupname contains only valid characters
|
||||||
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0]))
|
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0]))
|
||||||
$errors['cn'][] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
|
$errors['cn'][] = $this->errormessages['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 username is in use
|
// Set username back to original name if new username is in use
|
||||||
|
@ -472,8 +487,11 @@ class posixGroup extends baseModule {
|
||||||
}
|
}
|
||||||
// Show warning if lam has changed username
|
// Show warning if lam has changed username
|
||||||
if ($this->attributes['cn'][0] != $post['cn']) {
|
if ($this->attributes['cn'][0] != $post['cn']) {
|
||||||
$errors['cn'][] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'));
|
$errors['cn'][] = $this->errormessages['cn'][0];
|
||||||
}
|
}
|
||||||
|
// show info when gidnumber has changed
|
||||||
|
if (($this->orig['gidNumber'][0]!=$this->attributes['gidNumber'][0]) && $this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0])
|
||||||
|
$errors['gidNumber'][] = $this->errormessages['gidNumber'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return error-messages
|
// Return error-messages
|
||||||
|
|
Loading…
Reference in New Issue