fixed error handling
This commit is contained in:
parent
d135ac54a2
commit
32a0888530
|
@ -37,6 +37,14 @@
|
||||||
*/
|
*/
|
||||||
class posixAccount extends baseModule {
|
class posixAccount extends baseModule {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds error messages
|
||||||
|
* @todo remove this function, StatusMessage can handle parameters
|
||||||
|
*
|
||||||
|
* @param unknown_type $attribute
|
||||||
|
* @param unknown_type $id
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
function dynamic_Message($attribute, $id) {
|
function dynamic_Message($attribute, $id) {
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case 'homeDirectory': switch ($id) {
|
case 'homeDirectory': switch ($id) {
|
||||||
|
@ -583,7 +591,7 @@ class posixAccount extends baseModule {
|
||||||
* @return array list of info/error messages
|
* @return array list of info/error messages
|
||||||
*/
|
*/
|
||||||
function process_attributes(&$post) {
|
function process_attributes(&$post) {
|
||||||
$triggered_messages = array();
|
$errors = array();
|
||||||
$groups = $_SESSION['cache']->findgroups(); // list of all groupnames
|
$groups = $_SESSION['cache']->findgroups(); // list of all groupnames
|
||||||
if (count($groups)==0) {
|
if (count($groups)==0) {
|
||||||
return array(array(array("ERROR", _('No Unix groups found in LDAP! Please create one first.'), '')));
|
return array(array(array("ERROR", _('No Unix groups found in LDAP! Please create one first.'), '')));
|
||||||
|
@ -594,13 +602,13 @@ class posixAccount extends baseModule {
|
||||||
if (isset($post['createhomedir'])) $this->createhomedir = true;
|
if (isset($post['createhomedir'])) $this->createhomedir = true;
|
||||||
else $this->createhomedir = false;
|
else $this->createhomedir = false;
|
||||||
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
|
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
|
||||||
$triggered_messages['uid'][] = $this->messages['uid'][0];
|
$errors['uid'][] = $this->messages['uid'][0];
|
||||||
if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
|
if ($this->orig['gidNumber'][0]!='' && $_SESSION['cache']->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
|
||||||
$triggered_messages['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
|
$errors['gidNumber'][] = $this->dynamic_Message('gidNumber',0);
|
||||||
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
|
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
|
||||||
$triggered_messages['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
|
$errors['uidNumber'][] = $this->dynamic_Message('uidNumber',0);
|
||||||
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
|
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
|
||||||
$triggered_messages['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
|
$errors['homeDirectory'][] = $this->dynamic_Message('homeDirectory',0);
|
||||||
// Load attributes
|
// Load attributes
|
||||||
$this->attributes['uid'][0] = $post['uid'];
|
$this->attributes['uid'][0] = $post['uid'];
|
||||||
$this->attributes['cn'][0] = $post['cn'];
|
$this->attributes['cn'][0] = $post['cn'];
|
||||||
|
@ -624,7 +632,7 @@ class posixAccount extends baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!get_preg($this->attributes['cn'][0], 'cn')) {
|
if (!get_preg($this->attributes['cn'][0], 'cn')) {
|
||||||
$triggered_messages['cn'][] = $this->messages['cn'][0];
|
$errors['cn'][] = $this->messages['cn'][0];
|
||||||
}
|
}
|
||||||
$this->attributes['uidNumber'][0] = $post['uidNumber'];
|
$this->attributes['uidNumber'][0] = $post['uidNumber'];
|
||||||
$this->attributes['gidNumber'][0] = $_SESSION['cache']->getgid($post['gidNumber']);
|
$this->attributes['gidNumber'][0] = $_SESSION['cache']->getgid($post['gidNumber']);
|
||||||
|
@ -648,12 +656,12 @@ class posixAccount extends baseModule {
|
||||||
// No id-number given
|
// No id-number given
|
||||||
if ($this->orig['uidNumber'][0]=='') {
|
if ($this->orig['uidNumber'][0]=='') {
|
||||||
// new account -> we have to find a free id-number
|
// new account -> we have to find a free id-number
|
||||||
$newUID = $this->getNextUIDs(1, $triggered_messages);
|
$newUID = $this->getNextUIDs(1, $errors);
|
||||||
if (is_array($newUID)) {
|
if (is_array($newUID)) {
|
||||||
$this->attributes['uidNumber'][0] = $newUID[0];
|
$this->attributes['uidNumber'][0] = $newUID[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][3];
|
$errors['uidNumber'][] = $this->messages['uidNumber'][3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
||||||
|
@ -662,28 +670,28 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
// Check manual ID
|
// Check manual ID
|
||||||
// id-number is out of valid range
|
// id-number is out of valid range
|
||||||
if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $triggered_messages['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
|
if (!is_numeric($this->attributes['uidNumber'][0]) || ($this->attributes['uidNumber'][0] < $minID) || ($this->attributes['uidNumber'][0] > $maxID)) $errors['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
|
||||||
// $uids is allways an array but not if no entries were found
|
// $uids is allways an array but not if no entries were found
|
||||||
if (is_array($uids)) {
|
if (is_array($uids)) {
|
||||||
// id-number is in use and account is a new account
|
// id-number is in use and account is a new account
|
||||||
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $triggered_messages['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
|
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors['uidNumber'][] = 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['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
|
if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
|
||||||
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][3];
|
$errors['uidNumber'][] = $this->messages['uidNumber'][3];
|
||||||
$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_SESSION[$this->base]->type=='user') {
|
if ($_SESSION[$this->base]->type=='user') {
|
||||||
if (($this->attributes['uid'][0] != $post['uid']) && !get_preg($post['uid'], '!upper'))
|
if (($this->attributes['uid'][0] != $post['uid']) && !get_preg($post['uid'], '!upper'))
|
||||||
$triggered_messages['uid'][] = $this->messages['uid'][1];
|
$errors['uid'][] = $this->messages['uid'][1];
|
||||||
if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' ))
|
if ( !get_preg($this->attributes['homeDirectory'][0], 'homeDirectory' ))
|
||||||
$triggered_messages['homeDirecotry'][] = $this->messages['homeDirectory'][0];
|
$errors['homeDirecotry'][] = $this->messages['homeDirectory'][0];
|
||||||
}
|
}
|
||||||
if ((isset($post['userPassword_lock']) && isset($post['userPassword_invalid'])) ||
|
if ((isset($post['userPassword_lock']) && isset($post['userPassword_invalid'])) ||
|
||||||
(isset($post['userPassword_nopassword']) && isset($post['userPassword_invalid']))) {
|
(isset($post['userPassword_nopassword']) && isset($post['userPassword_invalid']))) {
|
||||||
// found invalid password parameter combination
|
// found invalid password parameter combination
|
||||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][3];
|
$errors['userPassword'][] = $this->messages['userPassword'][3];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isset($post['userPassword_nopassword'])) {
|
if (isset($post['userPassword_nopassword'])) {
|
||||||
|
@ -707,10 +715,10 @@ class posixAccount extends baseModule {
|
||||||
if (isset($post['genpass'])) $this->attributes['userPassword'][0] = genpasswd();
|
if (isset($post['genpass'])) $this->attributes['userPassword'][0] = genpasswd();
|
||||||
elseif ($_SESSION[$this->base]->isNewAccount) {
|
elseif ($_SESSION[$this->base]->isNewAccount) {
|
||||||
if ($post['userPassword'] != $post['userPassword2'])
|
if ($post['userPassword'] != $post['userPassword2'])
|
||||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][0];
|
$errors['userPassword'][] = $this->messages['userPassword'][0];
|
||||||
else $this->attributes['userPassword'][0] = $post['userPassword'];
|
else $this->attributes['userPassword'][0] = $post['userPassword'];
|
||||||
if (!get_preg($this->attributes['userPassword'][0], 'password'))
|
if (!get_preg($this->attributes['userPassword'][0], 'password'))
|
||||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
||||||
}
|
}
|
||||||
if (isset($post['userPassword_lock'])) $this->userPassword_lock=true;
|
if (isset($post['userPassword_lock'])) $this->userPassword_lock=true;
|
||||||
else $this->userPassword_lock=false;
|
else $this->userPassword_lock=false;
|
||||||
|
@ -720,10 +728,10 @@ class posixAccount extends baseModule {
|
||||||
$this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]);
|
$this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]);
|
||||||
if ($this->attributes['uid'][0] != '')
|
if ($this->attributes['uid'][0] != '')
|
||||||
$this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]);
|
$this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]);
|
||||||
if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $triggered_messages['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
|
if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
|
||||||
// Check if Username contains only valid characters
|
// Check if Username contains only valid characters
|
||||||
if ( !get_preg($this->attributes['uid'][0], 'username') && !$profile)
|
if ( !get_preg($this->attributes['uid'][0], 'username'))
|
||||||
$triggered_messages['uid'][] = $this->messages['uid'][2];
|
$errors['uid'][] = $this->messages['uid'][2];
|
||||||
}
|
}
|
||||||
if ($_SESSION[$this->base]->type=='host') {
|
if ($_SESSION[$this->base]->type=='host') {
|
||||||
// add "$" to uid if needed
|
// add "$" to uid if needed
|
||||||
|
@ -733,7 +741,7 @@ class posixAccount extends baseModule {
|
||||||
}
|
}
|
||||||
// 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'))
|
||||||
$triggered_messages['uid'][] = $this->messages['uid'][4];
|
$errors['uid'][] = $this->messages['uid'][4];
|
||||||
if (!$this->attributes['homeDirectory'][0]) {
|
if (!$this->attributes['homeDirectory'][0]) {
|
||||||
$this->attributes['homeDirectory'][0] = '/dev/null';
|
$this->attributes['homeDirectory'][0] = '/dev/null';
|
||||||
}
|
}
|
||||||
|
@ -782,21 +790,17 @@ class posixAccount extends baseModule {
|
||||||
}
|
}
|
||||||
// Show warning if lam has changed username
|
// Show warning if lam has changed username
|
||||||
if ($this->attributes['uid'][0] != $post['uid']) {
|
if ($this->attributes['uid'][0] != $post['uid']) {
|
||||||
if ($_SESSION[$this->base]->type=='user') $triggered_messages['uid'][] = $this->messages['uid'][5];
|
if ($_SESSION[$this->base]->type=='user') $errors['uid'][] = $this->messages['uid'][5];
|
||||||
if ($_SESSION[$this->base]->type=='host') $triggered_messages['uid'][] = $this->messages['uid'][6];
|
if ($_SESSION[$this->base]->type=='host') $errors['uid'][] = $this->messages['uid'][6];
|
||||||
}
|
}
|
||||||
if ($_SESSION[$this->base]->isNewAccount && !get_preg($this->attributes['userPassword'][0], 'password'))
|
if ($_SESSION[$this->base]->isNewAccount && !get_preg($this->attributes['userPassword'][0], 'password'))
|
||||||
$triggered_messages['userPassword'][] = $this->messages['userPassword'][1];
|
$errors['userPassword'][] = $this->messages['userPassword'][1];
|
||||||
}
|
}
|
||||||
$temp = $this->input_check();
|
$temp = $this->input_check();
|
||||||
// TODO is this really OK?
|
// TODO is this really OK?
|
||||||
if (is_array($temp)) $triggered_messages = array_merge_recursive($triggered_messages, $temp);
|
if (is_array($temp)) $errors = array_merge_recursive($errors, $temp);
|
||||||
// Return error-messages
|
// Return error-messages
|
||||||
if (count($triggered_messages)!=0) {
|
return $errors;
|
||||||
$this->triggered_messages = $triggered_messages;
|
|
||||||
return $triggered_messages;
|
|
||||||
}
|
|
||||||
else $this->triggered_messages = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -806,7 +810,7 @@ class posixAccount extends baseModule {
|
||||||
* @param array $post HTTP-POST values
|
* @param array $post HTTP-POST values
|
||||||
* @return array list of info/error messages
|
* @return array list of info/error messages
|
||||||
*/
|
*/
|
||||||
function process_group(&$post) {
|
function process_group($post) {
|
||||||
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
|
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
|
||||||
// Add new group
|
// Add new group
|
||||||
$this->groups = @array_merge($this->groups, $post['addgroups']);
|
$this->groups = @array_merge($this->groups, $post['addgroups']);
|
||||||
|
@ -823,7 +827,7 @@ class posixAccount extends baseModule {
|
||||||
* @param array $post HTTP-POST values
|
* @param array $post HTTP-POST values
|
||||||
* @return array list of info/error messages
|
* @return array list of info/error messages
|
||||||
*/
|
*/
|
||||||
function process_password(&$post) {
|
function process_password($post) {
|
||||||
if ($post['form_subpage_posixAccount_attributes_back']) return;
|
if ($post['form_subpage_posixAccount_attributes_back']) return;
|
||||||
$messages = array();
|
$messages = array();
|
||||||
if ($post['userPassword'] != $post['userPassword2']) {
|
if ($post['userPassword'] != $post['userPassword2']) {
|
||||||
|
@ -847,7 +851,7 @@ class posixAccount extends baseModule {
|
||||||
* to show a page with all attributes.
|
* to show a page with all attributes.
|
||||||
* It will output a complete html-table
|
* It will output a complete html-table
|
||||||
*/
|
*/
|
||||||
function display_html_attributes(&$post) {
|
function display_html_attributes($post) {
|
||||||
// check password format if called the first time
|
// check password format if called the first time
|
||||||
if (!isset($this->userPassword_invalid)) {
|
if (!isset($this->userPassword_invalid)) {
|
||||||
if (isset($this->attributes['userPassword'][0])) {
|
if (isset($this->attributes['userPassword'][0])) {
|
||||||
|
@ -947,7 +951,7 @@ class posixAccount extends baseModule {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_html_delete(&$post) {
|
function display_html_delete($post) {
|
||||||
if ($this->scope == 'user' && isset($_SESSION['config']->scriptPath)) {
|
if ($this->scope == 'user' && isset($_SESSION['config']->scriptPath)) {
|
||||||
$return[] = array (
|
$return[] = array (
|
||||||
0 => array('kind' => 'text', 'text' => _('Delete home directory')),
|
0 => array('kind' => 'text', 'text' => _('Delete home directory')),
|
||||||
|
@ -963,7 +967,7 @@ class posixAccount extends baseModule {
|
||||||
* @param array $post HTTP-POST
|
* @param array $post HTTP-POST
|
||||||
* @return array meta HTML code
|
* @return array meta HTML code
|
||||||
*/
|
*/
|
||||||
function display_html_group(&$post) {
|
function display_html_group($post) {
|
||||||
// load list with all groups
|
// load list with all groups
|
||||||
$dn_groups = $_SESSION['cache']->get_cache('cn', 'posixGroup', 'group');
|
$dn_groups = $_SESSION['cache']->get_cache('cn', 'posixGroup', 'group');
|
||||||
$DNs = array_keys($dn_groups);
|
$DNs = array_keys($dn_groups);
|
||||||
|
@ -1009,7 +1013,7 @@ class posixAccount extends baseModule {
|
||||||
* @param array $post HTTP-POST
|
* @param array $post HTTP-POST
|
||||||
* @return array meta HTML code
|
* @return array meta HTML code
|
||||||
*/
|
*/
|
||||||
function display_html_password(&$post) {
|
function display_html_password($post) {
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
0 => array('kind' => 'text', 'text' => _('Password') ),
|
0 => array('kind' => 'text', 'text' => _('Password') ),
|
||||||
1 => array('kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => ""),
|
1 => array('kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => ""),
|
||||||
|
@ -1195,7 +1199,7 @@ class posixAccount extends baseModule {
|
||||||
* @return array list of error messages if any
|
* @return array list of error messages if any
|
||||||
*/
|
*/
|
||||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
|
||||||
$triggered_messages = array();
|
$errors = array();
|
||||||
$needAutoUID = array();
|
$needAutoUID = array();
|
||||||
// get list of existing users
|
// get list of existing users
|
||||||
$dnUsers = $_SESSION['cache']->get_cache('uid', 'posixAccount', array('user', 'host'));
|
$dnUsers = $_SESSION['cache']->get_cache('uid', 'posixAccount', array('user', 'host'));
|
||||||
|
@ -1228,7 +1232,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uidNumber'][4];
|
$errMsg = $this->messages['uidNumber'][4];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// GID number
|
// GID number
|
||||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'digit')) {
|
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'digit')) {
|
||||||
|
@ -1242,13 +1246,13 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gidNumber'][0];
|
$errMsg = $this->messages['gidNumber'][0];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gidNumber'][1];
|
$errMsg = $this->messages['gidNumber'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// GECOS
|
// GECOS
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_gecos']] != "") {
|
if ($rawAccounts[$i][$ids['posixAccount_gecos']] != "") {
|
||||||
|
@ -1258,7 +1262,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gecos'][0];
|
$errMsg = $this->messages['gecos'][0];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1281,7 +1285,7 @@ class posixAccount extends baseModule {
|
||||||
$groups = explode(",", $rawAccounts[$i][$ids['posixAccount_additionalGroups']]);
|
$groups = explode(",", $rawAccounts[$i][$ids['posixAccount_additionalGroups']]);
|
||||||
for ($g = 0; $g < sizeof($groups); $g++) {
|
for ($g = 0; $g < sizeof($groups); $g++) {
|
||||||
if (!in_array($groups[$g], $existingGroups)) {
|
if (!in_array($groups[$g], $existingGroups)) {
|
||||||
$triggered_messages[] = array('ERROR', _('Unable to find group in LDAP.'), $groups[$g]);
|
$errors[] = array('ERROR', _('Unable to find group in LDAP.'), $groups[$g]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1293,7 @@ class posixAccount extends baseModule {
|
||||||
if (in_array($rawAccounts[$i][$ids['posixAccount_userName']], $existingUsers)) {
|
if (in_array($rawAccounts[$i][$ids['posixAccount_userName']], $existingUsers)) {
|
||||||
$errMsg = $this->messages['uid'][9];
|
$errMsg = $this->messages['uid'][9];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_userName']], 'username')) {
|
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_userName']], 'username')) {
|
||||||
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_userName']];
|
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_userName']];
|
||||||
|
@ -1297,7 +1301,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uid'][7];
|
$errMsg = $this->messages['uid'][7];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// home directory
|
// home directory
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_homedir']] == "") {
|
if ($rawAccounts[$i][$ids['posixAccount_homedir']] == "") {
|
||||||
|
@ -1309,7 +1313,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['homeDirectory'][2];
|
$errMsg = $this->messages['homeDirectory'][2];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// login shell
|
// login shell
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_shell']] == "") {
|
if ($rawAccounts[$i][$ids['posixAccount_shell']] == "") {
|
||||||
|
@ -1321,7 +1325,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['shell'][0];
|
$errMsg = $this->messages['shell'][0];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
$pwd_enabled = true;
|
$pwd_enabled = true;
|
||||||
// password enabled/disabled
|
// password enabled/disabled
|
||||||
|
@ -1335,7 +1339,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['passwordDisabled'][0];
|
$errMsg = $this->messages['passwordDisabled'][0];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// password
|
// password
|
||||||
if (($rawAccounts[$i][$ids['posixAccount_password']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_password']], 'password'))) {
|
if (($rawAccounts[$i][$ids['posixAccount_password']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_password']], 'password'))) {
|
||||||
|
@ -1344,7 +1348,7 @@ class posixAccount extends baseModule {
|
||||||
elseif ($rawAccounts[$i][$ids['posixAccount_password']] != "") {
|
elseif ($rawAccounts[$i][$ids['posixAccount_password']] != "") {
|
||||||
$errMsg = $this->messages['userPassword'][4];
|
$errMsg = $this->messages['userPassword'][4];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// description
|
// description
|
||||||
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
|
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
|
||||||
|
@ -1364,7 +1368,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['cn'][1];
|
$errMsg = $this->messages['cn'][1];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1385,7 +1389,7 @@ class posixAccount extends baseModule {
|
||||||
if (in_array($rawAccounts[$i][$ids['posixAccount_hostName']], $existingUsers)) {
|
if (in_array($rawAccounts[$i][$ids['posixAccount_hostName']], $existingUsers)) {
|
||||||
$errMsg = $this->messages['uid'][10];
|
$errMsg = $this->messages['uid'][10];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_hostName']], 'hostname')) {
|
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_hostName']], 'hostname')) {
|
||||||
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
|
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
|
||||||
|
@ -1394,7 +1398,7 @@ class posixAccount extends baseModule {
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uid'][8];
|
$errMsg = $this->messages['uid'][8];
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
$triggered_messages[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// description
|
// description
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_description']] && ($rawAccounts[$i][$ids['posixAccount_description']] != '')) {
|
if ($rawAccounts[$i][$ids['posixAccount_description']] && ($rawAccounts[$i][$ids['posixAccount_description']] != '')) {
|
||||||
|
@ -1417,10 +1421,10 @@ class posixAccount extends baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$triggered_messages[] = $this->messages['uidNumber'][2];
|
$errors[] = $this->messages['uidNumber'][2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $triggered_messages;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1516,10 +1520,10 @@ class posixAccount extends baseModule {
|
||||||
* Returns one or more free UID numbers.
|
* Returns one or more free UID numbers.
|
||||||
*
|
*
|
||||||
* @param integer $count Number of needed free UIDs.
|
* @param integer $count Number of needed free UIDs.
|
||||||
* @param array $triggered_messages list of error messages where errors can be added
|
* @param array $errors list of error messages where errors can be added
|
||||||
* @return mixed Null if no UIDs are free else an array of free UIDs.
|
* @return mixed Null if no UIDs are free else an array of free UIDs.
|
||||||
*/
|
*/
|
||||||
function getNextUIDs($count, &$triggered_messages) {
|
function getNextUIDs($count, &$errors) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if ($this->scope == "user") {
|
if ($this->scope == "user") {
|
||||||
$minID = intval($this->moduleSettings['posixAccount_minUID'][0]);
|
$minID = intval($this->moduleSettings['posixAccount_minUID'][0]);
|
||||||
|
@ -1564,7 +1568,7 @@ class posixAccount extends baseModule {
|
||||||
sort ($uids, SORT_NUMERIC);
|
sort ($uids, SORT_NUMERIC);
|
||||||
}
|
}
|
||||||
// show warning message
|
// show warning message
|
||||||
$triggered_messages['uidNumber'][] = $this->messages['uidNumber'][2];
|
$errors['uidNumber'][] = $this->messages['uidNumber'][2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue