fixed error handling

This commit is contained in:
Roland Gruber 2006-05-16 15:38:55 +00:00
parent 45490e0cc2
commit ef43685e7d
3 changed files with 24 additions and 47 deletions

View File

@ -174,7 +174,7 @@ class inetLocalMailRecipient extends baseModule {
* @return array list of info/error messages
*/
function process_attributes(&$post) {
$this->triggered_messages = array();
$errors = array();
$this->attributes['mailRoutingAddress'] = array();
$this->attributes['mailLocalAddress'] = array();
$this->attributes['mailHost'] = array();
@ -187,7 +187,7 @@ class inetLocalMailRecipient extends baseModule {
else {
$message = $this->messages['routingAdr'][0];
$message[] = $post['routingAdr'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
// check mail server
@ -199,7 +199,7 @@ class inetLocalMailRecipient extends baseModule {
else {
$message = $this->messages['host'][0];
$message[] = $post['host'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
// check old local addresses
@ -211,7 +211,7 @@ class inetLocalMailRecipient extends baseModule {
if (!get_preg($post['localAdr' . $i], 'mailLocalAddress')) {
$message = $this->messages['localAdr'][0];
$message[] = $post['localAdr' . $i];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
$this->attributes['mailLocalAddress'][] = $post['localAdr' . $i];
}
@ -226,16 +226,11 @@ class inetLocalMailRecipient extends baseModule {
else {
$message = $this->messages['localAdr'][0];
$message[] = $post['localAdr'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
$this->attributes['mailLocalAddress'] = array_unique($this->attributes['mailLocalAddress']);
if (sizeof($this->triggered_messages) > 0) {
return $this->triggered_messages;
}
else {
return array();
}
return $errors;
}
/**

View File

@ -34,9 +34,6 @@ $Id$
*/
class kolabUser extends baseModule {
/** used for account pages, true if input data is correct */
var $inputCorrect = false;
/** list of invitation policies */
var $invitationPolicies;
@ -412,8 +409,8 @@ class kolabUser extends baseModule {
* @return array list of info/error messages
*/
function process_attributes(&$post) {
$errors = array();
if ($post['form_subpage_kolabUser_deleteUser_open']) return;
$this->triggered_messages = array();
$this->attributes['kolabInvitationPolicy'] = array();
// country
if (isset($post['country'])) {
@ -423,13 +420,13 @@ class kolabUser extends baseModule {
else {
$message = $this->messages['country'][0];
$message[] = $post['country'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
// mailbox server
if (isset($post['homeServer'])) {
if ($post['homeServer'] == "") {
$this->triggered_messages[] = array($this->messages['homeServer'][2]);
$errors[] = array($this->messages['homeServer'][2]);
}
elseif (get_preg($post['homeServer'], 'DNSname')) {
$this->attributes['kolabHomeServer'][0] = $post['homeServer'];
@ -437,7 +434,7 @@ class kolabUser extends baseModule {
else {
$message = $this->messages['homeServer'][0];
$message[] = $post['homeServer'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
// check old invitation policies
@ -455,7 +452,7 @@ class kolabUser extends baseModule {
if (!get_preg($post['invPol1' . $i], 'email')) {
$message = $this->messages['invPol'][0];
$message[] = $post['invPol1' . $i];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
else {
$this->attributes['kolabInvitationPolicy'][] = $post['invPol1' . $i] . ':' . $policies[$post['invPol2' . $i]];
@ -469,7 +466,7 @@ class kolabUser extends baseModule {
if (!get_preg($post['invPol1'], 'email')) {
$message = $this->messages['invPol'][0];
$message[] = $post['invPol1'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
else {
$this->attributes['kolabInvitationPolicy'][] = $post['invPol1'] . ':' . $policies[$post['invPol2']];
@ -492,7 +489,7 @@ class kolabUser extends baseModule {
if (!get_preg($post['alias' . $i], 'email')) {
$message = $this->messages['alias'][0];
$message[] = $post['alias' . $i];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
$this->attributes['alias'][] = $post['alias' . $i];
}
@ -504,7 +501,7 @@ class kolabUser extends baseModule {
if (!get_preg($post['alias'], 'email')) {
$message = $this->messages['alias'][0];
$message[] = $post['alias'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
else {
$this->attributes['alias'][] = $post['alias'];
@ -535,7 +532,7 @@ class kolabUser extends baseModule {
else {
$message = $this->messages['freeBusy'][0];
$message[] = $post['freeBusy'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
// Cyrus mail quota
@ -546,17 +543,10 @@ class kolabUser extends baseModule {
else {
$message = $this->messages['quota'][0];
$message[] = $post['quota'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
// check if all was correct
if (sizeof($this->triggered_messages) > 0) {
$this->inputCorrect = false;
return $this->triggered_messages;
}
else {
$this->inputCorrect = true;
}
return $errors;
}
/**
@ -597,12 +587,9 @@ class kolabUser extends baseModule {
if (!$_SESSION[$this->base]->module['inetOrgPerson']->attributes['mail'][0]) return false;
if ($_SESSION[$this->base]->isNewAccount) {
if (isset($_SESSION[$this->base]->module['posixAccount']) && !$_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) return false;
elseif (isset($_SESSION[$this->base]->module['inetOrgPerson']) && !$_SESSION[$this->base]->module['inetOrgPerson']->attributes['userPassword'][0]) return false;
return $this->inputCorrect;
}
else {
return true;
if (isset($_SESSION[$this->base]->module['inetOrgPerson']) && !$_SESSION[$this->base]->module['inetOrgPerson']->attributes['userPassword'][0]) return false;
}
return true;
}
/**

View File

@ -161,7 +161,7 @@ class nisMailAlias extends baseModule {
* @return array list of info/error messages
*/
function process_attributes(&$post) {
$this->triggered_messages = array();
$errors = array();
$this->attributes['cn'] = array();
$this->attributes['rfc822MailMember'] = array();
// check alias name
@ -171,7 +171,7 @@ class nisMailAlias extends baseModule {
else {
$message = $this->messages['alias'][0];
$message[] = $post['cn'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
// check old recipients
if (isset($post['rec_number'])) {
@ -182,7 +182,7 @@ class nisMailAlias extends baseModule {
if (!get_preg($post['rfc822MailMember' . $i], 'nis_recipient')) {
$message = $this->messages['recipient'][0];
$message[] = $post['rfc822MailMember' . $i];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
$this->attributes['rfc822MailMember'][] = $post['rfc822MailMember' . $i];
}
@ -197,16 +197,11 @@ class nisMailAlias extends baseModule {
else {
$message = $this->messages['recipient'][0];
$message[] = $post['rfc822MailMember'];
$this->triggered_messages[] = array($message);
$errors[] = array($message);
}
}
$this->attributes['rfc822MailMember'] = array_unique($this->attributes['rfc822MailMember']);
if (sizeof($this->triggered_messages) > 0) {
return $this->triggered_messages;
}
else {
return array();
}
return $errors;
}
/**