From 94eddccd65a4fbb484c2cbc88e10455c680b3840 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 15 Jan 2008 07:42:24 +0000 Subject: [PATCH] Closes #316 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8338 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../personal/scalix/class_scalixAccount.inc | 89 ++++++++++++------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/gosa-core/plugins/personal/scalix/class_scalixAccount.inc b/gosa-core/plugins/personal/scalix/class_scalixAccount.inc index 96365949e..0a7b1c266 100644 --- a/gosa-core/plugins/personal/scalix/class_scalixAccount.inc +++ b/gosa-core/plugins/personal/scalix/class_scalixAccount.inc @@ -237,6 +237,45 @@ class scalixAccount extends plugin /* Save ldap attributes */ plugin::save_object(); + /* Check if given value is not empty */ + if ($_POST['email_address'] != ""){ + $valid= FALSE; + + /* Valid mail address */ + if( ($this->is_template && !tests::is_email($_POST['email_address'], TRUE)) || + (!$this->is_template && !tests::is_email($_POST['email_address'])) ){ + msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG); + }else{ + $valid = TRUE; + } + + /* Check write access */ + if(!$this->acl_is_writeable("scalixEmailAddress")){ + print_red(_("You are not allowed to modify alternate addresses")); + }else{ + + /* Mail address already in use ? */ + if ($valid && ($user= $this->addEmail ($_POST['email_address'])) != ""){ + $ui= get_userinfo(); + if ($user != $ui->username){ + msg_dialog::display(_("Error"), sprintf(_("Cannot add mail address: it is already used by user '%s'."), $user), + ERROR_DIALOG); + } + } + } + } + + /* Delete email addresses */ + if (isset($_POST['delete_email']) && isset ($_POST['emails_list'])){ + if(!$this->acl_is_writeable("scalixEmailAddress")){ + print_red(_("You are not allowed to modify alternate addresses")); + }else{ + if (count($_POST['emails_list'])){ + $this->delEmail ($_POST['emails_list']); + } + } + } + /* Save fakeBooleanAttributes*/ foreach ($this->fakeBooleanAttributes as $val){ if ($this->acl_is_writeable($val)) { @@ -427,42 +466,32 @@ class scalixAccount extends plugin /* Add email addresses */ if (isset($_POST['add_email'])){ - /* Check write access */ -# if(!$this->acl_is_writeable("scalixEmailAddress")){ -# print_red(_("You are not allowed to modify alternate addresses")); -# }else{ - - /* Check if given value is not empty */ - if ($_POST['email_address'] != ""){ - $valid= FALSE; - - /* Valid mail address */ - if( ($this->is_template && !tests::is_email($_POST['email_address'], TRUE)) || - (!$this->is_template && !tests::is_email($_POST['email_address'])) ){ - msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG); - }else{ - $valid = TRUE; - } + /* Check if given value is not empty */ + if ($_POST['email_address'] != ""){ + $valid= FALSE; + + /* Valid mail address */ + if( ($this->is_template && !tests::is_email($_POST['email_address'], TRUE)) || + (!$this->is_template && !tests::is_email($_POST['email_address'])) ){ + msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG); + }else{ + $valid = TRUE; + } - /* Mail address already in use ? */ - if ($valid && ($user= $this->addEmail ($_POST['email_address'])) != ""){ - $ui= get_userinfo(); - if ($user != $ui->username){ - msg_dialog::display(_("Error"), sprintf(_("Cannot add mail address: it is already used by user '%s'."), $user), ERROR_DIALOG); - } + /* Mail address already in use ? */ + if ($valid && ($user= $this->addEmail ($_POST['email_address'])) != ""){ + $ui= get_userinfo(); + if ($user != $ui->username){ + msg_dialog::display(_("Error"), sprintf(_("Cannot add mail address: it is already used by user '%s'."), $user), ERROR_DIALOG); } -# } + } } } - + /* Delete email addresses */ if (isset($_POST['delete_email']) && isset ($_POST['emails_list'])){ -# if(!$this->acl_is_writeable("scalixEmailAddress")){ -# print_red(_("You are not allowed to modify alternate addresses")); -# }else{ - if (count($_POST['emails_list'])){ - $this->delEmail ($_POST['emails_list']); -# } + if (count($_POST['emails_list'])){ + $this->delEmail ($_POST['emails_list']); } } } -- 2.30.2