made some fixes

This commit is contained in:
katagia 2004-10-17 09:33:24 +00:00
parent e74999ea5b
commit e257ffcb5b
2 changed files with 73 additions and 61 deletions

View File

@ -567,7 +567,7 @@ class accountContainer {
if ($function) $errors['saveProfile'][] = array('INFO', _('Save profile'), _('New profile created.'));
else $errors['saveProfile'][] = array('ERROR', _('Save profile'), _('Wrong profilename given.'));
}
if (is_array($errors) && !$profile) $result = $errors;
if (is_array($errors)) $result = $errors;
else $result = 0;
}
}
@ -670,69 +670,63 @@ class accountContainer {
if ($this->subpage=='attributes') {
$modules = array_keys($this->module);
$table = array();
if (!$profile) {
$disabled = false;
foreach ($modules as $module) {
if (!$this->module[$module]->module_complete()) {
$disabled = true;
$table[] = array ( 0 => array ( 'kind' => 'message', 'type' => 'ERROR', 'headline' => _('Check module'),
'text' => sprintf(_('Please set up all required attributes on %s page.'), $this->module[$module]->get_alias()) ));
}
}
}
if (count($table)!=0) $return[] = array ( 0 => array ( 'kind' => 'table', 'value' => $table ) );
// loop through all suffixes
$rootsuffix = call_user_func(array(&$_SESSION['config'], 'get_' . ucfirst($this->type) . 'Suffix'));
foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) {
if ($this->dn == $suffix) $option_selected = $suffix;
$suffixes[] = $suffix;
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Suffix') ),
1 => array ( 'kind' => 'select', 'name' => 'suffix', 'options' => $suffixes,
'option_selected' => array($option_selected) ),
2 => array ('kind' => 'help', 'value' => 'suffix'));
if (!$profile) {
// Get list of profiles
$profilelist = getAccountProfiles($this->type);
if (count($profilelist)!=0) {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Load profile") ),
1 => array ( 'kind' => 'select', 'name' => 'selectLoadProfile', 'options' => $profilelist ),
2 => array ('kind' => 'help', 'value' => 'selectLoadProfile'));
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Save profile") ),
1 => array ( 'kind' => 'table', 'value' => array ( 0 => array (
0 => array ( 'kind' => 'input', 'name' => 'selectSaveProfile', 'type' => 'text', 'size' => '30',
'maxlength' => '255', ),
1 => array ('kind' => 'input', 'name' => 'saveProfile', 'type' => 'submit',
'value' => _('Save profile'), 'disabled' => $disabled))) ),
2 => array ('kind' => 'help', 'value' => 'saveProfile'));
if ($this->dn_orig!='') $text = _('Modify Account');
else $text = _('Create Account');
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => $text ),
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'create', 'value' => $text ),
2 => array ('kind' => 'help', 'value' => 'create'));
$disabled = false;
foreach ($modules as $module) {
if (!$this->module[$module]->module_complete()) {
$disabled = true;
$table[] = array ( 0 => array ( 'kind' => 'message', 'type' => 'ERROR', 'headline' => _('Check module'),
'text' => sprintf(_('Please set up all required attributes on %s page.'), $this->module[$module]->get_alias()) ));
}
}
}
if (count($table)!=0) $return[] = array ( 0 => array ( 'kind' => 'table', 'value' => $table ) );
// loop through all suffixes
$rootsuffix = call_user_func(array(&$_SESSION['config'], 'get_' . ucfirst($this->type) . 'Suffix'));
foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) {
if ($this->dn == $suffix) $option_selected = $suffix;
$suffixes[] = $suffix;
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Suffix') ),
1 => array ( 'kind' => 'select', 'name' => 'suffix', 'options' => $suffixes,
'option_selected' => array($option_selected) ),
2 => array ('kind' => 'help', 'value' => 'suffix'));
// Get list of profiles
$profilelist = getAccountProfiles($this->type);
if (count($profilelist)!=0) {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Load profile") ),
1 => array ( 'kind' => 'select', 'name' => 'selectLoadProfile', 'options' => $profilelist ),
2 => array ('kind' => 'help', 'value' => 'selectLoadProfile'));
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Save profile") ),
1 => array ( 'kind' => 'table', 'value' => array ( 0 => array (
0 => array ( 'kind' => 'input', 'name' => 'selectSaveProfile', 'type' => 'text', 'size' => '30',
'maxlength' => '255', ),
1 => array ('kind' => 'input', 'name' => 'saveProfile', 'type' => 'submit',
'value' => _('Save profile'), 'disabled' => $disabled))) ),
2 => array ('kind' => 'help', 'value' => 'saveProfile'));
if ($this->dn_orig!='') $text = _('Modify Account');
else $text = _('Create Account');
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => $text ),
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'create', 'value' => $text ),
2 => array ('kind' => 'help', 'value' => 'create'));
if ($this->subpage=='finish') {
// Show success message
if ($this->dn_orig=='') $kind = _('created');
else $kind = _('modified');
$text = sprintf(_('%s has been %s.'), ucfirst($this->type), $kind);
if (!$profile) {
$return[] = array ( 0 => array ( 'kind' => 'message', 'type' => 'INFO', 'headline' => _('LDAP operation successful.'),
'text' => $text ));
$return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'createagain',
'value' => sprintf(_('Create another %s'), $this->type) ),
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'outputpdf',
'value' => _('Create PDF file') ),
2 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'backmain',
'value' => sprintf (_('Back to %s list'), $this->type) ));
}
$return[] = array ( 0 => array ( 'kind' => 'message', 'type' => 'INFO', 'headline' => _('LDAP operation successful.'),
'text' => $text ));
$return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'createagain',
'value' => sprintf(_('Create another %s'), $this->type) ),
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'outputpdf',
'value' => _('Create PDF file') ),
2 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'backmain',
'value' => sprintf (_('Back to %s list'), $this->type) ));
}
}
}
else $return = call_user_func(array($this->module[$this->order[$this->current_page]], 'display_html_'.$this->subpage), &$post);
$this->parse_html($this->order[$this->current_page], $return);
// Display rest of html-page

View File

@ -431,7 +431,23 @@ class posixAccount extends baseModule {
*/
function save_attributes() {
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
// fill gecos with correct attributes frm inetOrgPerson when they are set
// TODO do we have t use 7bit ascci only?
// TODO change gecos evertime something in inetOrgPerson has changes
if (isset($_SESSION[$this->base]->modules['inetOrgPerson'])) {
if (isset($return[$_SESSION[$this->base]->dn]['add']['gecos']))
$return[$_SESSION[$this->base]->dn]['add']['gecos'] = $_SESSION[$this->base]->modules['inetOrgPerson']->attributes['givenName'][0] .
" " . $_SESSION[$this->base]->modules['inetOrgPerson']->attributes['sn'][0] . "," .
$_SESSION[$this->base]->modules['inetOrgPerson']->attributes['roomNumber'][0] . "," .
$_SESSION[$this->base]->modules['inetOrgPerson']->attributes['telephoneNumber'][0] . "," .
$_SESSION[$this->base]->modules['inetOrgPerson']->attributes['homePhone'][0] ;
if (isset($return[$_SESSION[$this->base]->dn]['modify']['gecos']))
$return[$_SESSION[$this->base]->dn]['modify']['gecos'] = $_SESSION[$this->base]->modules['inetOrgPerson']->attributes['givenName'][0] .
" " . $_SESSION[$this->base]->modules['inetOrgPerson']->attributes['sn'][0] . "," .
$_SESSION[$this->base]->modules['inetOrgPerson']->attributes['roomNumber'][0] . "," .
$_SESSION[$this->base]->modules['inetOrgPerson']->attributes['telephoneNumber'][0] . "," .
$_SESSION[$this->base]->modules['inetOrgPerson']->attributes['homePhone'][0] ;
}
// unset password when needed
if (isset($return[$_SESSION[$this->base]->dn]['add']['userPassword']))
unset($return[$_SESSION[$this->base]->dn]['add']['userPassword']);
@ -545,7 +561,7 @@ class posixAccount extends baseModule {
function proccess_attributes($post) {
$this->attributes['homeDirectory'][0] = $post['homeDirectory'];
$this->attributes['loginShell'][0] = $post['loginShell'];
$this->attributes['gecos'][0] = $post['gecos'];
if (isset($post['gecos'])) $this->attributes['gecos'][0] = $post['gecos'];
if ($post['createhomedir']) $this->createhomedir = true;
else $this->createhomedir = false;
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
@ -773,9 +789,11 @@ class posixAccount extends baseModule {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('UID number').'*' ),
1 => array ( 'kind' => 'input', 'name' => 'uidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['uidNumber'][0]),
2 => array ('kind' => 'help', 'value' => 'uidNumber'));
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Gecos') ),
1 => array ( 'kind' => 'input', 'name' => 'gecos', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['gecos'][0]),
2 => array ('kind' => 'help', 'value' => 'gecos'));
if (!isset($_SESSION[$this->base]->modules['inetOrgPerson'])) {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Gecos') ),
1 => array ( 'kind' => 'input', 'name' => 'gecos', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['gecos'][0]),
2 => array ('kind' => 'help', 'value' => 'gecos'));
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Primary group').'*' ),
1 => array ( 'kind' => 'select', 'name' => 'gidNumber', 'options' => $groups, 'options_selected' =>
array ($_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]))),