diff --git a/lam/lib/modules/kolabUser.inc b/lam/lib/modules/kolabUser.inc index f709dc7b..a378da5a 100644 --- a/lam/lib/modules/kolabUser.inc +++ b/lam/lib/modules/kolabUser.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) - Copyright (C) 2004 - 2006 Roland Gruber + Copyright (C) 2004 - 2008 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,6 +43,8 @@ class kolabUser extends baseModule { * @param string $scope account type (user, group, host) */ function __construct($scope) { + // call parent constructor + parent::__construct($scope); // list of invitation policies $this->invitationPolicies = array( 'ACT_ALWAYS_ACCEPT' => _('Always accept'), @@ -51,8 +53,7 @@ class kolabUser extends baseModule { 'ACT_REJECT_IF_CONFLICTS' => _('Reject if conflicts'), 'ACT_MANUAL_IF_CONFLICTS' => _('Manual if conflicts') ); - // call parent constructor - parent::__construct($scope); + $this->autoAddObjectClasses = false; } /** @@ -258,172 +259,160 @@ class kolabUser extends baseModule { $this->messages['quota'][1] = array('ERROR', _('Account %s:') . ' kolabUser_quota', _('Mail quota must be a number!')); } - /** - * Returns a list of modifications which have to be made to the LDAP account. - * - * @return array list of modifications - *
This function returns an array with 3 entries: - *
array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... ) - *
DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid) - *
"add" are attributes which have to be added to LDAP entry - *
"remove" are attributes which have to be removed from LDAP entry - *
"modify" are attributes which have to been modified in LDAP entry - */ - function save_attributes() { - // add object class if needed - if (!isset($this->attributes['objectClass']) || !in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) { - $this->attributes['objectClass'][] = 'kolabInetOrgPerson'; - } - return parent::save_attributes(); - } - /** * Returns the HTML meta data for the main account page. * * @return array HTML meta data */ function display_html_attributes() { - $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); - if ($this->getAccountContainer()->isNewAccount) { - if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { - $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); - if (!$attrsP['userPassword'][0]) { - StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('posixAccount')->get_alias())); - } - } - elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { - if (!$attrsI['userPassword'][0]) { - StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); - } - } - } - if (!$attrsI['mail'][0]) { - StatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); - } $return = array(); - // check if account is marked for deletion - if (isset($this->attributes['kolabDeleteflag'])) { - $return[] = array( - array('kind' => 'text', 'text' => _('This account is marked for deletion.'))); - return $return; - } - // country - $return[] = array( - array('kind' => 'text', 'text' => _('Country')), - array('kind' => 'input', 'name' => 'country', 'type' => 'text', 'value' => $this->attributes['c'][0]), - array('kind' => 'help', 'value' => 'country')); - // mailbox server - if (!isset($this->orig['kolabHomeServer'][0])) { // value currently not set - $return[] = array( - array('kind' => 'text', 'text' => _('Mailbox home server') . "*"), - array('kind' => 'input', 'name' => 'homeServer', 'type' => 'text', 'value' => $this->attributes['kolabHomeServer'][0]), - array('kind' => 'help', 'value' => 'homeServer')); - } - else { // input is unchangable when set - $return[] = array( - array('kind' => 'text', 'text' => _('Mailbox home server')), - array('kind' => 'text', 'text' => $this->orig['kolabHomeServer'][0]), - array('kind' => 'help', 'value' => 'homeServer')); - } - // Cyrus mail quota - $return[] = array( - array('kind' => 'text', 'text' => _('Mail quota')), - array('kind' => 'input', 'name' => 'quota', 'type' => 'text', 'value' => $this->attributes['cyrus-userquota'][0]), - array('kind' => 'help', 'value' => 'quota')); - // free/busy future - $return[] = array( - array('kind' => 'text', 'text' => _('Free/Busy interval')), - array('kind' => 'input', 'name' => 'freeBusy', 'type' => 'text', 'value' => $this->attributes['kolabFreeBusyFuture'][0]), - array('kind' => 'help', 'value' => 'freeBusy')); - // invitation policies - $returnPol = array(); - // default invitation policy - $defaultInvPol = $this->invitationPolicies['ACT_MANUAL']; - for ($i = 0; $i < sizeof($this->attributes['kolabInvitationPolicy']); $i++) { - $parts = split(":", $this->attributes['kolabInvitationPolicy'][$i]); - if (sizeof($parts) == 1) { - $defaultInvPol = $this->invitationPolicies[$this->attributes['kolabInvitationPolicy'][$i]]; - unset($this->attributes['kolabInvitationPolicy'][$i]); - $this->attributes['kolabInvitationPolicy'] = array_values($this->attributes['kolabInvitationPolicy']); - break; + if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) { + $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); + if ($this->getAccountContainer()->isNewAccount) { + if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { + $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); + if (!isset($attrsP['userPassword'][0]) || ($attrsP['userPassword'][0] == '')) { + StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('posixAccount')->get_alias())); + } + } + elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { + if (!isset($attrsI['userPassword'][0]) || ($attrsI['userPassword'][0] == '')) { + StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); + } + } } - } - $returnPol[] = array( - array('kind' => 'text', 'text' => _('Anyone')), - array('kind' => 'select', 'name' => 'defaultInvPol', 'options' => array_values($this->invitationPolicies), 'options_selected' => $defaultInvPol), - array('kind' => 'help', 'value' => 'invPol')); - // other invitation policies - for ($i = 0; $i < sizeof($this->attributes['kolabInvitationPolicy']); $i++) { - $parts = split(":", $this->attributes['kolabInvitationPolicy'][$i]); - if (sizeof($parts) == 2) { - $returnPol[] = array( - array('kind' => 'input', 'name' => 'invPol1' . $i, 'type' => 'text', 'value' => $parts[0]), - array('kind' => 'select', 'name' => 'invPol2' . $i, 'options' => array_values($this->invitationPolicies), 'options_selected' => $this->invitationPolicies[$parts[1]]), - array('kind' => 'input', 'type' => 'submit', 'name' => 'delInvPol' . $i, 'value' => _("Remove")), - array('kind' => 'help', 'value' => 'invPol')); + if (!$attrsI['mail'][0]) { + StatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); } - } - // input box for new invitation policy - $returnPol[] = array( - array('kind' => 'input', 'name' => 'invPol1', 'type' => 'text', 'value' => ''), - array('kind' => 'select', 'name' => 'invPol2', 'options' => array_values($this->invitationPolicies)), - array('kind' => 'input', 'type' => 'submit', 'name' => 'addInvPol', 'value' => _("Add")), - array('kind' => 'help', 'value' => 'invPol')); - $returnPol = array( - array('kind' => 'fieldset', 'legend' => _('Invitation policy'), 'value' => $returnPol, 'td' => array('colspan' => 3)) - ); - $return[] = $returnPol; - // mail aliases - $returnAliases = array(); - for ($i = 0; $i < sizeof($this->attributes['alias']); $i++) { + // check if account is marked for deletion + if (isset($this->attributes['kolabDeleteflag'])) { + $return[] = array( + array('kind' => 'text', 'text' => _('This account is marked for deletion.'))); + return $return; + } + // country + $return[] = array( + array('kind' => 'text', 'text' => _('Country')), + array('kind' => 'input', 'name' => 'country', 'type' => 'text', 'value' => $this->attributes['c'][0]), + array('kind' => 'help', 'value' => 'country')); + // mailbox server + if (!isset($this->orig['kolabHomeServer'][0])) { // value currently not set + $return[] = array( + array('kind' => 'text', 'text' => _('Mailbox home server') . "*"), + array('kind' => 'input', 'name' => 'homeServer', 'type' => 'text', 'value' => $this->attributes['kolabHomeServer'][0]), + array('kind' => 'help', 'value' => 'homeServer')); + } + else { // input is unchangable when set + $return[] = array( + array('kind' => 'text', 'text' => _('Mailbox home server')), + array('kind' => 'text', 'text' => $this->orig['kolabHomeServer'][0]), + array('kind' => 'help', 'value' => 'homeServer')); + } + // Cyrus mail quota + $return[] = array( + array('kind' => 'text', 'text' => _('Mail quota')), + array('kind' => 'input', 'name' => 'quota', 'type' => 'text', 'value' => $this->attributes['cyrus-userquota'][0]), + array('kind' => 'help', 'value' => 'quota')); + // free/busy future + $return[] = array( + array('kind' => 'text', 'text' => _('Free/Busy interval')), + array('kind' => 'input', 'name' => 'freeBusy', 'type' => 'text', 'value' => $this->attributes['kolabFreeBusyFuture'][0]), + array('kind' => 'help', 'value' => 'freeBusy')); + // invitation policies + $returnPol = array(); + // default invitation policy + $defaultInvPol = $this->invitationPolicies['ACT_MANUAL']; + for ($i = 0; $i < sizeof($this->attributes['kolabInvitationPolicy']); $i++) { + $parts = split(":", $this->attributes['kolabInvitationPolicy'][$i]); + if (sizeof($parts) == 1) { + $defaultInvPol = $this->invitationPolicies[$this->attributes['kolabInvitationPolicy'][$i]]; + unset($this->attributes['kolabInvitationPolicy'][$i]); + $this->attributes['kolabInvitationPolicy'] = array_values($this->attributes['kolabInvitationPolicy']); + break; + } + } + $returnPol[] = array( + array('kind' => 'text', 'text' => _('Anyone')), + array('kind' => 'select', 'name' => 'defaultInvPol', 'options' => array_values($this->invitationPolicies), 'options_selected' => $defaultInvPol), + array('kind' => 'help', 'value' => 'invPol')); + // other invitation policies + for ($i = 0; $i < sizeof($this->attributes['kolabInvitationPolicy']); $i++) { + $parts = split(":", $this->attributes['kolabInvitationPolicy'][$i]); + if (sizeof($parts) == 2) { + $returnPol[] = array( + array('kind' => 'input', 'name' => 'invPol1' . $i, 'type' => 'text', 'value' => $parts[0]), + array('kind' => 'select', 'name' => 'invPol2' . $i, 'options' => array_values($this->invitationPolicies), 'options_selected' => $this->invitationPolicies[$parts[1]]), + array('kind' => 'input', 'type' => 'submit', 'name' => 'delInvPol' . $i, 'value' => _("Remove")), + array('kind' => 'help', 'value' => 'invPol')); + } + } + // input box for new invitation policy + $returnPol[] = array( + array('kind' => 'input', 'name' => 'invPol1', 'type' => 'text', 'value' => ''), + array('kind' => 'select', 'name' => 'invPol2', 'options' => array_values($this->invitationPolicies)), + array('kind' => 'input', 'type' => 'submit', 'name' => 'addInvPol', 'value' => _("Add")), + array('kind' => 'help', 'value' => 'invPol')); + $returnPol = array( + array('kind' => 'fieldset', 'legend' => _('Invitation policy'), 'value' => $returnPol, 'td' => array('colspan' => 3)) + ); + $return[] = $returnPol; + // mail aliases + $returnAliases = array(); + for ($i = 0; $i < sizeof($this->attributes['alias']); $i++) { + $returnAliases[] = array( + array('kind' => 'input', 'name' => 'alias' . $i, 'type' => 'text', 'value' => $this->attributes['alias'][$i]), + array('kind' => 'input', 'type' => 'submit', 'name' => 'delAlias' . $i, 'value' => _("Remove")), + array('kind' => 'help', 'value' => 'alias')); + } + // input box for new mail alias $returnAliases[] = array( - array('kind' => 'input', 'name' => 'alias' . $i, 'type' => 'text', 'value' => $this->attributes['alias'][$i]), - array('kind' => 'input', 'type' => 'submit', 'name' => 'delAlias' . $i, 'value' => _("Remove")), + array('kind' => 'input', 'name' => 'alias', 'type' => 'text', 'value' => ''), + array('kind' => 'input', 'type' => 'submit', 'name' => 'addAlias', 'value' => _("Add")), array('kind' => 'help', 'value' => 'alias')); - } - // input box for new mail alias - $returnAliases[] = array( - array('kind' => 'input', 'name' => 'alias', 'type' => 'text', 'value' => ''), - array('kind' => 'input', 'type' => 'submit', 'name' => 'addAlias', 'value' => _("Add")), - array('kind' => 'help', 'value' => 'alias')); - $returnAliases = array( - array('kind' => 'fieldset', 'legend' => _('EMail aliases'), 'value' => $returnAliases, 'td' => array('colspan' => 3)) - ); - $return[] = $returnAliases; - // delegates - $delegates = array(); - $delegatesTemp = $_SESSION['cache']->get_cache('mail', 'inetOrgPerson', 'user'); - if (is_array($delegatesTemp)) { - $DNs = array_keys($delegatesTemp); - foreach ($DNs as $DN) { - $delegates[] = $delegatesTemp[$DN][0]; + $returnAliases = array( + array('kind' => 'fieldset', 'legend' => _('EMail aliases'), 'value' => $returnAliases, 'td' => array('colspan' => 3)) + ); + $return[] = $returnAliases; + // delegates + $delegates = array(); + $delegatesTemp = $_SESSION['cache']->get_cache('mail', 'inetOrgPerson', 'user'); + if (is_array($delegatesTemp)) { + $DNs = array_keys($delegatesTemp); + foreach ($DNs as $DN) { + $delegates[] = $delegatesTemp[$DN][0]; + } + sort($delegates); } - sort($delegates); - } - $returnDelegates = array(); - for ($i = 0; $i < sizeof($this->attributes['kolabDelegate']); $i++) { + $returnDelegates = array(); + for ($i = 0; $i < sizeof($this->attributes['kolabDelegate']); $i++) { + $returnDelegates[] = array( + array('kind' => 'select', 'name' => 'delegate' . $i, 'options' => $delegates, 'options_selected' => array($this->attributes['kolabDelegate'][$i])), + array('kind' => 'input', 'type' => 'submit', 'name' => 'delDelegate' . $i, 'value' => _("Remove")), + array('kind' => 'help', 'value' => 'delegate')); + } + // input box for new delegate $returnDelegates[] = array( - array('kind' => 'select', 'name' => 'delegate' . $i, 'options' => $delegates, 'options_selected' => array($this->attributes['kolabDelegate'][$i])), - array('kind' => 'input', 'type' => 'submit', 'name' => 'delDelegate' . $i, 'value' => _("Remove")), + array('kind' => 'select', 'name' => 'delegate', 'options' => $delegates), + array('kind' => 'input', 'type' => 'submit', 'name' => 'addDelegate', 'value' => _("Add")), array('kind' => 'help', 'value' => 'delegate')); + $returnDelegates = array( + array('kind' => 'fieldset', 'legend' => _('Delegates'), 'value' => $returnDelegates, 'td' => array('colspan' => 3)) + ); + $return[] = $returnDelegates; + // delete flag + if (!$this->getAccountContainer()->isNewAccount) { + $returnDelete = array( + array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_deleteUser_open'), + array('kind' => 'help', 'value' => 'deleteFlag')); + $return[] = array( + array('kind' => 'fieldset', 'legend' => _('Delete Kolab account'), 'value' => array($returnDelete), 'td' => array('colspan' => 3)) + ); + } } - // input box for new delegate - $returnDelegates[] = array( - array('kind' => 'select', 'name' => 'delegate', 'options' => $delegates), - array('kind' => 'input', 'type' => 'submit', 'name' => 'addDelegate', 'value' => _("Add")), - array('kind' => 'help', 'value' => 'delegate')); - $returnDelegates = array( - array('kind' => 'fieldset', 'legend' => _('Delegates'), 'value' => $returnDelegates, 'td' => array('colspan' => 3)) - ); - $return[] = $returnDelegates; - // delete flag - if (!$this->getAccountContainer()->isNewAccount) { - $returnDelete = array( - 0 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_deleteUser_open'), - 1 => array('kind' => 'help', 'value' => 'deleteFlag')); + else { $return[] = array( - array('kind' => 'fieldset', 'legend' => _('Delete Kolab account'), 'value' => array($returnDelete), 'td' => array('colspan' => 3)) - ); + array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_kolabUser_attributes_addObjectClass', 'value' => _('Add Kolab extension')) + ); } return $return; } @@ -436,140 +425,145 @@ class kolabUser extends baseModule { */ function process_attributes() { $errors = array(); - if ($_POST['form_subpage_kolabUser_deleteUser_open']) return array(); - $this->attributes['kolabInvitationPolicy'] = array(); - // country - if (isset($_POST['country'])) { - if (($_POST['country'] == "") || get_preg($_POST['country'], 'country')) { - $this->attributes['c'][0] = $_POST['country']; - } - else { - $message = $this->messages['country'][0]; - $message[] = $_POST['country']; - $errors[] = $message; - } + if (isset($_POST['form_subpage_kolabUser_attributes_addObjectClass'])) { + $this->attributes['objectClass'][] = 'kolabInetOrgPerson'; } - // mailbox server - if (isset($_POST['homeServer'])) { - if ($_POST['homeServer'] == "") { - $errors[] = $this->messages['homeServer'][2]; + else { + if ($_POST['form_subpage_kolabUser_deleteUser_open']) return array(); + $this->attributes['kolabInvitationPolicy'] = array(); + // country + if (isset($_POST['country'])) { + if (($_POST['country'] == "") || get_preg($_POST['country'], 'country')) { + $this->attributes['c'][0] = $_POST['country']; + } + else { + $message = $this->messages['country'][0]; + $message[] = $_POST['country']; + $errors[] = $message; + } } - elseif (get_preg($_POST['homeServer'], 'DNSname')) { - $this->attributes['kolabHomeServer'][0] = $_POST['homeServer']; + // mailbox server + if (isset($_POST['homeServer'])) { + if ($_POST['homeServer'] == "") { + $errors[] = $this->messages['homeServer'][2]; + } + elseif (get_preg($_POST['homeServer'], 'DNSname')) { + $this->attributes['kolabHomeServer'][0] = $_POST['homeServer']; + } + else { + $message = $this->messages['homeServer'][0]; + $message[] = $_POST['homeServer']; + $errors[] = $message; + } } - else { - $message = $this->messages['homeServer'][0]; - $message[] = $_POST['homeServer']; - $errors[] = $message; - } - } - // check old invitation policies - $policies = array_flip($this->invitationPolicies); - $targets = array(); - $i = 0; - while (isset($_POST['invPol1' . $i])) { - if (isset($_POST['delInvPol' . $i])) { + // check old invitation policies + $policies = array_flip($this->invitationPolicies); + $targets = array(); + $i = 0; + while (isset($_POST['invPol1' . $i])) { + if (isset($_POST['delInvPol' . $i])) { + $i++; + continue; + } + if (isset($_POST['invPol2' . $i]) && ($_POST['invPol1' . $i] != "") && !in_array($_POST['invPol1' . $i], $targets)) { + $targets[] = $_POST['invPol1' . $i]; + // check invitation policy + if (!get_preg($_POST['invPol1' . $i], 'email')) { + $message = $this->messages['invPol'][0]; + $message[] = $_POST['invPol1' . $i]; + $errors[] = $message; + } + else { + $this->attributes['kolabInvitationPolicy'][] = $_POST['invPol1' . $i] . ':' . $policies[$_POST['invPol2' . $i]]; + } + } $i++; - continue; } - if (isset($_POST['invPol2' . $i]) && ($_POST['invPol1' . $i] != "") && !in_array($_POST['invPol1' . $i], $targets)) { - $targets[] = $_POST['invPol1' . $i]; - // check invitation policy - if (!get_preg($_POST['invPol1' . $i], 'email')) { + // check new invitation policy + if (isset($_POST['invPol1']) && ($_POST['invPol1'] != "") && !in_array($_POST['invPol1'], $targets)) { + // check new invitation policy + if (!get_preg($_POST['invPol1'], 'email')) { $message = $this->messages['invPol'][0]; - $message[] = $_POST['invPol1' . $i]; + $message[] = $_POST['invPol1']; $errors[] = $message; } else { - $this->attributes['kolabInvitationPolicy'][] = $_POST['invPol1' . $i] . ':' . $policies[$_POST['invPol2' . $i]]; + $this->attributes['kolabInvitationPolicy'][] = $_POST['invPol1'] . ':' . $policies[$_POST['invPol2']]; } } - $i++; - } - // check new invitation policy - if (isset($_POST['invPol1']) && ($_POST['invPol1'] != "") && !in_array($_POST['invPol1'], $targets)) { - // check new invitation policy - if (!get_preg($_POST['invPol1'], 'email')) { - $message = $this->messages['invPol'][0]; - $message[] = $_POST['invPol1']; - $errors[] = $message; + // default invitation policy + if (isset($_POST['defaultInvPol']) && ($_POST['defaultInvPol'] != "")) { + $this->attributes['kolabInvitationPolicy'][] = $policies[$_POST['defaultInvPol']]; } - else { - $this->attributes['kolabInvitationPolicy'][] = $_POST['invPol1'] . ':' . $policies[$_POST['invPol2']]; - } - } - // default invitation policy - if (isset($_POST['defaultInvPol']) && ($_POST['defaultInvPol'] != "")) { - $this->attributes['kolabInvitationPolicy'][] = $policies[$_POST['defaultInvPol']]; - } - // check old mail aliases - $this->attributes['alias'] = array(); - $i = 0; - while (isset($_POST['alias' . $i])) { - if (isset($_POST['delAlias' . $i])) { + // check old mail aliases + $this->attributes['alias'] = array(); + $i = 0; + while (isset($_POST['alias' . $i])) { + if (isset($_POST['delAlias' . $i])) { + $i++; + continue; + } + if (isset($_POST['alias' . $i]) && ($_POST['alias' . $i] != "") && !in_array($_POST['alias' . $i], $this->attributes['alias'])) { + // check mail alias + if (!get_preg($_POST['alias' . $i], 'email')) { + $message = $this->messages['alias'][0]; + $message[] = $_POST['alias' . $i]; + $errors[] = $message; + } + $this->attributes['alias'][] = $_POST['alias' . $i]; + } $i++; - continue; } - if (isset($_POST['alias' . $i]) && ($_POST['alias' . $i] != "") && !in_array($_POST['alias' . $i], $this->attributes['alias'])) { - // check mail alias - if (!get_preg($_POST['alias' . $i], 'email')) { + // check new mail alias + if (isset($_POST['alias']) && ($_POST['alias'] != "")) { + // check new mail alias + if (!get_preg($_POST['alias'], 'email')) { $message = $this->messages['alias'][0]; - $message[] = $_POST['alias' . $i]; + $message[] = $_POST['alias']; $errors[] = $message; } - $this->attributes['alias'][] = $_POST['alias' . $i]; + else { + $this->attributes['alias'][] = $_POST['alias']; + } } - $i++; - } - // check new mail alias - if (isset($_POST['alias']) && ($_POST['alias'] != "")) { - // check new mail alias - if (!get_preg($_POST['alias'], 'email')) { - $message = $this->messages['alias'][0]; - $message[] = $_POST['alias']; - $errors[] = $message; - } - else { - $this->attributes['alias'][] = $_POST['alias']; - } - } - $this->attributes['alias'] = array_unique($this->attributes['alias']); - // check old delegates - $this->attributes['kolabDelegate'] = array(); - $i = 0; - while (isset($_POST['delegate' . $i])) { - if (isset($_POST['delDelegate' . $i])) { + $this->attributes['alias'] = array_unique($this->attributes['alias']); + // check old delegates + $this->attributes['kolabDelegate'] = array(); + $i = 0; + while (isset($_POST['delegate' . $i])) { + if (isset($_POST['delDelegate' . $i])) { + $i++; + continue; + } + $this->attributes['kolabDelegate'][] = $_POST['delegate' . $i]; $i++; - continue; } - $this->attributes['kolabDelegate'][] = $_POST['delegate' . $i]; - $i++; - } - // check new delegate - if (isset($_POST['addDelegate']) && ($_POST['delegate'] != "")) { - $this->attributes['kolabDelegate'][] = $_POST['delegate']; - } - $this->attributes['kolabDelegate'] = array_unique($this->attributes['kolabDelegate']); - // free/busy future - if (isset($_POST['freeBusy'])) { - if (($_POST['freeBusy'] == "") || get_preg($_POST['freeBusy'], 'digit')) { - $this->attributes['kolabFreeBusyFuture'][0] = $_POST['freeBusy']; + // check new delegate + if (isset($_POST['addDelegate']) && ($_POST['delegate'] != "")) { + $this->attributes['kolabDelegate'][] = $_POST['delegate']; } - else { - $message = $this->messages['freeBusy'][0]; - $message[] = $_POST['freeBusy']; - $errors[] = $message; + $this->attributes['kolabDelegate'] = array_unique($this->attributes['kolabDelegate']); + // free/busy future + if (isset($_POST['freeBusy'])) { + if (($_POST['freeBusy'] == "") || get_preg($_POST['freeBusy'], 'digit')) { + $this->attributes['kolabFreeBusyFuture'][0] = $_POST['freeBusy']; + } + else { + $message = $this->messages['freeBusy'][0]; + $message[] = $_POST['freeBusy']; + $errors[] = $message; + } } - } - // Cyrus mail quota - if (isset($_POST['quota'])) { - if (($_POST['quota'] == "") || get_preg($_POST['quota'], 'digit')) { - $this->attributes['cyrus-userquota'][0] = $_POST['quota']; - } - else { - $message = $this->messages['quota'][0]; - $message[] = $_POST['quota']; - $errors[] = $message; + // Cyrus mail quota + if (isset($_POST['quota'])) { + if (($_POST['quota'] == "") || get_preg($_POST['quota'], 'digit')) { + $this->attributes['cyrus-userquota'][0] = $_POST['quota']; + } + else { + $message = $this->messages['quota'][0]; + $message[] = $_POST['quota']; + $errors[] = $message; + } } } return $errors; @@ -581,12 +575,12 @@ class kolabUser extends baseModule { function display_html_deleteUser() { $return = array(); $return[] = array( - 0 => array('kind' => 'text', 'text' => _('Do you really want to mark this account for deletion?'), 'td' => array('colspan' => 2))); + array('kind' => 'text', 'text' => _('Do you really want to mark this account for deletion?'), 'td' => array('colspan' => 2))); $return[] = array( - 0 => array('kind' => 'text', 'text' => ' ', 'td' => array('colspan' => 2))); + array('kind' => 'text', 'text' => ' ', 'td' => array('colspan' => 2))); $return[] = array( - 0 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_attributes_confirm'), - 1 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Cancel'), 'name' => 'form_subpage_kolabUser_attributes_cancel')); + array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_attributes_confirm'), + array('kind' => 'input', 'type' => 'submit', 'value' => _('Cancel'), 'name' => 'form_subpage_kolabUser_attributes_cancel')); return $return; } @@ -606,15 +600,17 @@ class kolabUser extends baseModule { * @return true, if account can be saved */ function module_complete() { - $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); - $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); - if (!$attrsI['mail'][0]) return false; - if ($this->getAccountContainer()->isNewAccount) { - if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { - if (!$attrsP['userPassword'][0]) return false; - } - elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { - if (!$attrsI['userPassword'][0]) return false; + if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) { + $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); + $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); + if (!$attrsI['mail'][0]) return false; + if ($this->getAccountContainer()->isNewAccount) { + if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { + if (!$attrsP['userPassword'][0]) return false; + } + elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { + if (!$attrsI['userPassword'][0]) return false; + } } } return true;