implemented profile loading interface
This commit is contained in:
parent
cec9d8cd4e
commit
630f65a639
|
@ -305,6 +305,22 @@ class baseModule {
|
|||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the values of an account profile into internal variables.
|
||||
*
|
||||
* @param array $profile hash array with profile values (identifier => value)
|
||||
*/
|
||||
function load_profile($profile) {
|
||||
if (isset($this->meta['profile_mappings'])) {
|
||||
$identifiers = array_keys($this->meta['profile_mappings']);
|
||||
for ($i = 0; $i < sizeof($identifiers); $i++) {
|
||||
if (isset($profile[$identifiers[$i]])) {
|
||||
$this->attributes[$this->meta['profile_mappings'][$identifiers[$i]]] = $profile[$identifiers[$i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of elements for the configuration.
|
||||
*
|
||||
|
|
|
@ -597,11 +597,10 @@ class accountContainer {
|
|||
|
||||
// load profile
|
||||
if ($post['selectLoadProfile'] && $post['loadProfile']) {
|
||||
// *** fixme load*Profile must return array in the same way ldap_get_attributes does.
|
||||
$newattributes = loadAccountProfile($post['selectLoadProfile'], $scope);
|
||||
// pass newattributes to each module
|
||||
$profile = loadAccountProfile($post['selectLoadProfile'], $this->type);
|
||||
// pass profile to each module
|
||||
$modules = array_keys($this->module);
|
||||
foreach ($modules as $module) $this->module[$module]->load_attributes($newattributes);
|
||||
foreach ($modules as $module) $this->module[$module]->load_profile($profile);
|
||||
$result = 0;
|
||||
}
|
||||
// save account
|
||||
|
@ -611,17 +610,6 @@ class accountContainer {
|
|||
// return name of subpage
|
||||
$result = 'finish';
|
||||
}
|
||||
// save profile
|
||||
if ($post['saveProfile']) {
|
||||
if ($post['selectSaveProfile']=='') $errors['saveProfile'][] = array('ERROR', _('Save profile'), _('No profilename given.'));
|
||||
else {
|
||||
//saveAccountProfile($scope); // TODO missing parameters, remove?
|
||||
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)) $result = $errors;
|
||||
else $result = 0;
|
||||
}
|
||||
}
|
||||
if ($this->subpage=='finish') {
|
||||
if ($post['createagain']) {
|
||||
|
@ -747,17 +735,15 @@ class accountContainer {
|
|||
// 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'));
|
||||
$return[] = array(
|
||||
0 => array('kind' => 'text', 'text' => _("Load profile")),
|
||||
1 => array('kind' => 'table', 'value' => array(0 => array(
|
||||
0 => array('kind' => 'select', 'name' => 'selectLoadProfile', 'options' => $profilelist),
|
||||
1 => array('kind' => 'input', 'type' => 'submit', 'name' => 'loadProfile', 'value' => _('Load profile'))
|
||||
)),
|
||||
2 => array('kind' => 'help', 'value' => 'selectLoadProfile'))
|
||||
);
|
||||
}
|
||||
if ($this->dn_orig!='') $text = _('Modify Account');
|
||||
else $text = _('Create Account');
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => $text ),
|
||||
|
|
|
@ -80,6 +80,10 @@ class inetLocalMailRecipient extends baseModule {
|
|||
'type' => 'ext_preg',
|
||||
'regex' => 'DNSname',
|
||||
'error_message' => $this->messages['host'][0]);
|
||||
// profile mappings
|
||||
$return['profile_mappings'] = array(
|
||||
'inetLocalMailRecipient_host' => 'mailHost'
|
||||
);
|
||||
// upload fields
|
||||
$return['upload_columns'] = array(
|
||||
array(
|
||||
|
@ -232,7 +236,7 @@ class inetLocalMailRecipient extends baseModule {
|
|||
if (isset($post['routingAdr']) && ($post['routingAdr'] != "")) {
|
||||
// check if address has correct format
|
||||
if (get_preg($post['routingAdr'], 'email')) {
|
||||
$this->attributes['mailRoutingAddress'][] = $post['routingAdr'];
|
||||
$this->attributes['mailRoutingAddress'][0] = $post['routingAdr'];
|
||||
}
|
||||
else {
|
||||
$message = $this->messages['routingAdr'][0];
|
||||
|
@ -244,7 +248,7 @@ class inetLocalMailRecipient extends baseModule {
|
|||
if (isset($post['host']) && ($post['host'] != "")) {
|
||||
// check if address has correct format
|
||||
if (get_preg($post['host'], 'DNSname')) {
|
||||
$this->attributes['mailHost'][] = $post['host'];
|
||||
$this->attributes['mailHost'][0] = $post['host'];
|
||||
}
|
||||
else {
|
||||
$message = $this->messages['host'][0];
|
||||
|
|
Loading…
Reference in New Issue