diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc
index 29ab414ef6034793c0fa24492f05dfa2ca416727..80f9ba64bea1bbf2f1d196d1bcecb9788627d22f 100644 (file)
*/
/* Load sieve support */
-require_once ("class_sieve.inc");
+require_once ("sieve/libsieve.inc");
/* Load mail methods */
global $BASE_DIR;
class mailAccount extends plugin
{
/* Definitions */
- var $plHeadline= "Mail";
- var $plDescription= "This does something";
- var $method= "mailMethod";
-
- /* CLI vars */
- var $cli_summary= "Manage users mail account";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+ var $plHeadline = "Mail";
+ var $plDescription = "This does something";
+ var $method = "mailMethod";
/* plugin specific values */
- var $mail= "";
- var $uid= "";
- var $gosaMailAlternateAddress= array();
- var $gosaMailForwardingAddress= array();
- var $gosaMailDeliveryMode= "[L ]";
- var $gosaMailServer= "";
- var $gosaMailQuota= "";
- var $gosaMailMaxSize= "";
- var $gosaVacationMessage= "";
- var $gosaSpamSortLevel= "";
- var $gosaSpamMailbox= "";
-
- var $quotaUsage= 0;
- var $forward_dialog= FALSE;
- var $folder_prefix= "";
- var $mailboxList= array();
- var $default_permissions= "none";
- var $member_permissions= "post";
- var $members= array();
- var $admins= array();
- var $vacations= array();
- var $perms= array( "lrs" => "read", "lrsp" => "post", "lrsip" => "append",
- "lrswipcd" => "write", "lrswipcda" => "all" );
+ var $mail = "";
+ var $uid = "";
+ var $gosaMailAlternateAddress = array();
+ var $gosaMailForwardingAddress = array();
+ var $gosaMailDeliveryMode = "[L ]";
+ var $gosaMailServer = "";
+ var $gosaMailQuota = "";
+ var $gosaMailMaxSize = "";
+ var $gosaVacationMessage = "";
+ var $gosaVacationStart = 0;
+ var $gosaVacationStop = 0;
+ var $gosaSpamSortLevel = "";
+ var $gosaSpamMailbox = "";
+
+ var $quotaUsage = 0;
+ var $forward_dialog = FALSE;
+ var $folder_prefix = "";
+ var $mailboxList = array("INBOX");
+ var $default_permissions = "none";
+ var $member_permissions = "post";
+ var $members = array();
+ var $admins = array();
+ var $vacations = array();
+ var $perms = array( "lrs" => "read",
+ "lrsp" => "post",
+ "lrsip" => "append",
+ "lrswipcd" => "write",
+ "lrswipcda" => "all" );
/* attribute list for save action */
var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress",
"gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress",
- "gosaVacationMessage", "uid", "gosaMailAlternateAddress", "gosaMailForwardingAddress");
+ "gosaVacationMessage", "gosaMailAlternateAddress", "gosaMailForwardingAddress", "gosaVacationStart", "gosaVacationStop");
var $objectclasses= array("gosaMailAccount");
+ var $sieve_management = NULL;
/* constructor, if 'dn' is set, the node loads the given
'dn' from LDAP */
- function mailAccount ($config, $dn= NULL)
+ function mailAccount ($config, $dn= NULL, $parent= NULL)
{
- /* Configuration is fine, allways */
- $this->config= $config;
-
/* Load bases attributes */
- plugin::plugin($config, $dn);
+ plugin::plugin($config, $dn, $parent);
+
+ if(isset($this->attrs['uid'])){
+ $this->uid = $this->attrs['uid'][0];
+ }
+
+ if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){
+ $this->gosaMailServer = $this->gosaMailServer[0];
+ }
+
+ /* Save initial account state */
+ $this->initially_was_account= $this->is_account;
- /* Set mailMethod to the one defined in gosa.conf */
+ /* Set mailMethod to the one defined in gosa.conf */
if (isset($this->config->current['MAILMETHOD'])){
$method= $this->config->current['MAILMETHOD'];
if (class_exists("mailMethod$method")){
}
}
- /* Preset folder prefix. Will change it later to respect
+ /* Create the account prefix user. user/
+ Preset folder prefix. Will change it later to respect
altnamespace. */
if (isset($this->config->current['CYRUSUNIXSTYLE']) && $this->config->current['CYRUSUNIXSTYLE'] == "true"){
$this->folder_prefix= "user/";
+ }elseif (isset($this->config->data['MAIN']['CYRUSUNIXSTYLE']) && $this->config->data['MAIN']['CYRUSUNIXSTYLE'] == "true"){
+ $this->folder_prefix= "user/";
} else {
$this->folder_prefix= "user.";
}
-
- if ($dn != NULL){
+
+ /* This is not a new account, parse additional attributes */
+ if (($dn != NULL) && ($dn != "new") && $this->is_account){
/* Load attributes containing arrays */
foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
}
}
+
/* Only do IMAP actions if gosaMailServer attribute is set */
if (isset ($this->attrs["gosaMailServer"][0])){
- $method= new $this->method($this->config);
- $id= $method->uattrib;
+ $method = new $this->method($this->config);
+ $id = $method->uattrib;
/* Adapt attributes if needed */
$method->fixAttributesOnLoad($this);
+
+ /* FixAttributesOnLoad possibly creates an array out of gosaMailServer.
+ If the mail tab wasn't opened once before saving, the account can't be saved */
+ if(is_array($this->gosaMailServer)){
+ $this->gosaMailServer = $this->gosaMailServer[0];
+ }
+
if ($method->connect($this->attrs["gosaMailServer"][0])){
- $quota= $method->getQuota($this->folder_prefix.$this->$id);
/* Update quota values */
- if ($quota['gosaMailQuota'] == 2147483647){
- $this->quotaUsage= "";
- $this->gosaMailQuota= "";
- } else {
- $this->quotaUsage= $quota['quotaUsage'];
- $this->gosaMailQuota= $quota['gosaMailQuota'];
+ $quota= $method->getQuota($this->folder_prefix.$this->$id);
+
+ if($quota){
+ if ($quota['gosaMailQuota'] == 2147483647){
+ $this->quotaUsage = "";
+ $this->gosaMailQuota = "";
+ } else {
+ $this->quotaUsage = $quota['quotaUsage'];
+ $this->gosaMailQuota = $quota['gosaMailQuota'];
+ }
+ }else{
+ $this->quotaUsage = "";
+ $this->gosaMailQuota = "";
+// print_red(sprintf(_("Can't get quota information for '%s'."),$this->folder_prefix.$this->$id));
}
- $this->mailboxList= $method->getMailboxList(
- $this->folder_prefix.$this->$id,
- $this->$id);
+
+ /* Get mailboxes / folder like INBOX ..*/
+ $this->mailboxList= $method->getMailboxList($this->folder_prefix.$this->$id,$this->$id);
+
$method->disconnect();
}else{
/* Could not connect to ldap.
}
}
+
+ /* Get vacation message */
+
/* Fill vacation array */
$this->vacation= array();
if (isset($this->config->current['VACATIONDIR'])){
}
}
+ /* Create sieve management class */
+ $method = new $this->method($this->config);
+ $id = $method->uattrib;
+ $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$id);
+
+ /* Create filter */
+
/* Get global filter config */
if (!is_global("mailfilter")){
$ui= get_userinfo();
"regex" => "*");
register_global("mailfilter", $mailfilter);
}
-
- if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){
- $this->gosaMailServer = $this->gosaMailServer[0];
- }
-
- /* Save initial account state */
- $this->initially_was_account= $this->is_account;
}
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Initialise vars */
/* Load templating engine */
$smarty= get_smarty();
$display= "";
+ /* Get available mailserver */
$mailserver= array();
foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
$mailserver[]= $key;
}
+
+ /*
+ * Sieve Management
+ */
+ if(isset($_POST['sieveManagement'])
+ && preg_match("/C/",$this->gosaMailDeliveryMode)
+ && chkacl($this->acl,"sieveManagement") == "") {
+ $this->dialog = $this->sieve_management;
+ }
+
+ /* Cancel sieve edit */
+ if(isset($_POST['sieve_cancel'])){
+ $this->dialog = NULL;
+ }
+
+ /* Save sieve changes */
+ if(isset($_POST['sieve_finish'])){
+ $this->sieve_management = $this->dialog;
+ $this->dialog = NULL;
+ }
+
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+
+ /* Handle account state */
+
/* Do we need to flip is_account state? */
if (isset($_POST['modify_state'])){
- $this->is_account= !$this->is_account;
- }
- /* Show main page */
- $mailserver= array();
- foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
- $mailserver[]= $key;
+ /* Onyl change account state if allowed */
+ if($this->is_account && $this->acl == "#all#" && !$this->accountDelegationsConfigured()){
+ $this->is_account= !$this->is_account;
+ }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){
+ $this->is_account= !$this->is_account;
+ }
}
/* Do we represent a valid account? */
/* Show tab dialog headers */
if ($this->parent != NULL){
if ($this->is_account){
- $display= $this->show_header(_("Remove mail account"),
- _("This account has mail features enabled. You can disable them by clicking below."));
+ if($this->accountDelegationsConfigured()){
+ $display= $this->show_header(_("Remove mail account"),
+ _("This account can't be removed while there are delegations configured. Remove those delegations first."),TRUE,TRUE);
+ }else{
+ $display= $this->show_header(_("Remove mail account"),
+ _("This account has mail features enabled. You can disable them by clicking below."));
+ }
} else {
$display= $this->show_header(_("Create mail account"), _("This account has mail features disabled. You can enable them by clicking below."));
return ($display);
}
}
+ /* Forwarder subdialog */
+
/* Trigger forward add dialog? */
if (isset($_POST['add_local_forwarder'])){
$this->forward_dialog= TRUE;
}
}
+
+ /* Alternate address handling */
+
/* Add alternate email addresses */
if (isset($_POST['add_alternate'])){
if ($_POST['alternate_address'] != "" &&
if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
$ui= get_userinfo();
- if ($user != $ui->username){
+ if ($user != $ui->username && !$this->is_template){
print_red (_("The address you're trying to add is already used by user")." '$user'.");
}
}
}
}
+
+ /* Vocation message */
+
/* Import vacation message? */
if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){
$contents= "";
}
/* Replace attributes */
- $attrs= $this->parent->by_object['user']->attributes;
- foreach ($attrs as $val){
- $contents= preg_replace("/%$val/",
- $this->parent->by_object['user']->$val, $contents);
+ $attrs = array();
+ $obj = NULL;
+ if(isset($this->parent->by_object['user'])){
+ $attrs = $this->parent->by_object['user']->attributes;
+ $obj = $this->parent->by_object['user'];
+ }else{
+ $obj = new user($this->config,$this->dn);
+ $attrs = $obj->attributes;
+ }
+
+ if($obj){
+ foreach ($attrs as $val){
+ if(preg_match("/dateOfBirth/",$val)){
+ if($obj->use_dob){
+ $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents);
+ }
+ }else {
+ $contents= preg_replace("/%$val/",
+ $obj->$val, $contents);
+ }
+
+ /* Replace vacation start and end time */
+ if(preg_match("/%start/",$contents)){
+ $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
+ }
+ if(preg_match("/%end/",$contents)){
+ $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
+ }
+ }
}
/* Save message */
$this->gosaVacationMessage= htmlspecialchars($contents);
}
+
+ /* Display forward dialog if requested above */
+
/* Show forward add dialog */
if ($this->forward_dialog){
$ldap= $this->config->get_ldap_link();
return ($display);
}
- $smarty->assign("mailServers", $mailserver);
- foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
- "gosaMailAlternateAddress", "gosaMailForwardingAddress",
- "gosaVacationMessage", "gosaMailDeliveryMode",
- "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){
+ /* Display mail account tab */
+ if($this->gosaVacationStart ==0){
+ $date= getdate(time());
+ $this->gosaVacationStart = time();
+ }else{
+ $date= getdate($this->gosaVacationStart);
+ }
+ $days= array();
+ for($d= 1; $d<32; $d++){
+ $days[$d]= $d;
+ }
+ $years= array();
+ for($y= $date['year']-10; $y<$date['year']+10; $y++){
+ $years[]= $y;
+ }
+ $months= array(_("January"), _("February"), _("March"), _("April"),
+ _("May"), _("June"), _("July"), _("August"), _("September"),
+ _("October"), _("November"), _("December"));
+ $smarty->assign("start_day", $date["mday"]);
+ $smarty->assign("days", $days);
+ $smarty->assign("months", $months);
+ $smarty->assign("start_month", $date["mon"]-1);
+ $smarty->assign("years", $years);
+ $smarty->assign("start_year", $date["year"]);
+
+ if($this->gosaVacationStop ==0){
+ $date= getdate(time());
+ $date["mday"]++;
+ $this->gosaVacationStop = time() + (60*60*24);
+ }else{
+ $date= getdate($this->gosaVacationStop);
+ }
+ $smarty->assign("end_day", $date["mday"]);
+ $smarty->assign("end_month", $date["mon"]-1);
+ $smarty->assign("end_year", $date["year"]);
- $smarty->assign("$val", $this->$val);
+ $smarty->assign("mailServers", $mailserver);
+ foreach(array(
+ "gosaMailServer",
+ "gosaMailQuota",
+ "perms",
+ "mail",
+ "gosaMailAlternateAddress",
+ "gosaMailForwardingAddress",
+
+ // gosaMailDeliveryMode Flags
+ "drop_own_mails", // No local delivery
+ "gosaMailMaxSize", // Enable - Drop mails > max size
+ "gosaSpamSortLevel", "gosaSpamMailbox", // Enable - Spam sort options
+ "gosaVacationMessage", // Enable - Vacation message
+ "gosaVacationStart",
+ "gosaVacationStop",
+ "custom_sieve", // Use custom sieve script
+ "only_local" // Send/receive local mails
+ ) as $val){
+ if(isset($this->$val)){
+ $smarty->assign("$val", $this->$val);
+ }
$smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
}
+ $smarty->assign("use_vacationACL", chkacl($this->acl,"use_vacation"));
+ $smarty->assign("gosaVacationTimerACL", chkacl($this->acl,"gosaVacationTimer"));
+ $smarty->assign("sieveManagementACL", chkacl($this->acl,"sieveManagement"));
+
+ if (preg_match('/V/', $this->gosaMailDeliveryMode)){
+ $smarty->assign('rangeEnabled', "");
+ } else {
+ $smarty->assign('rangeEnabled', "disabled");
+ }
+
if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
$smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
$smarty->assign("quotadefined", "true");
$smarty->assign("mailACL", "disabled");
}
- /* Fill checkboxes */
+
if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
$smarty->assign("drop_own_mails", "checked");
} else {
$smarty->assign("drop_own_mails", "");
}
+
+ $types = array(
+ "V"=>"use_vacation",
+ "S"=>"use_spam_filter",
+ "R"=>"use_mailsize_limit",
+ "I"=>"only_local",
+ "C"=>"own_script");
+
+ /* Fill checkboxes */
+ foreach($types as $option => $varname){
+ if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) {
+ $smarty->assign($varname, "checked");
+ } else {
+ $smarty->assign($varname, "");
+ }
+ }
+
if (preg_match("/V/", $this->gosaMailDeliveryMode)) {
$smarty->assign("use_vacation", "checked");
} else {
return ($display);
}
+ /* check if we have some delegations configured, those delegations must be removed first */
+ function accountDelegationsConfigured()
+ {
+ /* We are in administrational edit mode.
+ Check tab configurations directly */
+ if(isset($this->attrs)){
+ $checkArray = array("kolabInvitationPolicy","unrestrictedMailSize", "calFBURL","kolabDelegate","kolabFreeBusyFuture");
+ foreach($checkArray as $index){
+ if(isset($this->attrs[$index])){
+ return(true);
+ }
+ }
+ }
+ if(isset($this->parent->by_object['connectivity']->plugin['kolabAccount'])){
+ if($this->parent->by_object['connectivity']->plugin['kolabAccount']->is_account){
+ return(true);
+ }
+ }
+ return(false);
+ }
+
/* remove object from parent */
function remove_from_parent()
$method= new $this->method($this->config);
$method->fixAttributesOnRemove($this);
- /* Mailmethod wants us to remove the entry from LDAP. Keep uid! */
- #fixme: || kolab || is differs here, you can't delete all attrs specified in this plugin ....
- #fixme: there are some attributes we have to keep, i think.
- unset ($this->attrs['uid']);
-
-
-
- @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
- $this->attributes, "Save");
+ @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
}
}
+ /* Update shared folder membership, ACL may need to be updated */
+ $this->updateSharedFolder();
+
/* Optionally execute a command after we're done */
- $this->handle_post_events("remove");
+ $this->handle_post_events("remove", array('uid'=> $this->uid));
}
I: Only insider delivery */
$tmp= "";
- if (!isset($_POST["drop_own_mails"])){
- $tmp.= "L";
- }
- if (isset($_POST["use_mailsize_limit"])){
- $tmp.= "R";
- }
- if (isset($_POST["use_spam_filter"])){
- $tmp.= "S";
- }
- if (isset($_POST["use_vacation"])){
- $tmp.= "V";
+ $Flags = array(
+ "R" => array("ACL" => "gosaMailMaxSize", "POST" => "use_mailsize_limit"),
+ "V" => array("ACL" => "use_vacation", "POST" => "use_vacation"),
+ "C" => array("ACL" => "custom_sieve", "POST" => "own_script"),
+ "I" => array("ACL" => "only_local", "POST" => "only_local"));
+
+ /* Check acls and set new value if allowed.
+ If we do not have permission to change the value
+ check for the old value and use this */
+ foreach($Flags as $flag => $val){
+ $acl = $val['ACL'];
+ $post = $val['POST'];
+ if(chkacl($this->acl,$acl) ==""){
+ if (isset($_POST[$post])){
+ $tmp.= $flag;
+ }
+ }else{
+ if(preg_match("/".$flag."/",$this->gosaMailDeliveryMode)){
+ $tmp.= $flag ;
+ }
+ }
}
- if (isset($_POST["own_script"])){
- $tmp.= "C";
+
+ /* ! Inverse flag handling for drop_own_mails */
+ if(chkacl($this->acl,"drop_own_mails") == ""){
+ if (!isset($_POST['drop_own_mails'])){
+ $tmp.= "L";
+ }
+ }else{
+ if(preg_match("/L/",$this->gosaMailDeliveryMode)){
+ $tmp.= "L" ;
+ }
}
- if (isset($_POST["only_local"])){
- $tmp.= "I";
+
+ /* If one of these acls are given, we are allowed to enable disable the the spam settings */
+ if(chkacl($this->acl,"gosaSpamMailbox") == "" || chkacl($this->acl,"gosaSpamSortLevel") ==""){
+ if (isset($_POST["use_spam_filter"])){
+ $tmp.= "S";
+ }
+ }else{
+ if(preg_match("/S/",$this->gosaMailDeliveryMode)){
+ $tmp.= "S" ;
+ }
}
+
+ /* Check if something has changed an assign new gosaMailDeliveryMode */
$tmp= "[$tmp]";
+ if ($this->gosaMailDeliveryMode != $tmp){
+ $this->is_modified= TRUE;
+ }
+ $this->gosaMailDeliveryMode= $tmp;
- if (chkacl ($this->acl, "gosaMailDeliveryMode") == ""){
- if ($this->gosaMailDeliveryMode != $tmp){
- $this->is_modified= TRUE;
+ if(chkacl($this->acl,"gosaVacationTimer") == "" && preg_match("/V/",$this->gosaMailDeliveryMode)){
+ if(isset($_POST['gosaVacationStart'])){
+ $this->gosaVacationStart = $_POST['gosaVacationStart'];
+ }
+ if(isset($_POST['gosaVacationStop'])){
+ $this->gosaVacationStop = $_POST['gosaVacationStop'];
}
- $this->gosaMailDeliveryMode= $tmp;
}
}
}
/* Adapt attributes if needed */
$method= new $this->method($this->config);
$id= $method->uattrib;
+
$method->fixAttributesOnStore($this);
- /* Remove Mailquota if = "" */
- if((isset($this->attrs['gosaMailQuota']))&&($this->attrs['gosaMailQuota']=="")) {
- $this->attrs['gosaMailQuota']=array();
+ /* Remove Mailquota if = "" or "0" */
+ if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) {
+ $this->attrs['gosaMailQuota']=0;
}
if(empty($this->attrs['gosaSpamMailbox'])){
$this->attrs['mail'] = strtolower($this->attrs['mail']);
+ /* Remove attributes - if not needed */
+ if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
+ unset($this->attrs['gosaVacationStart']);
+ unset($this->attrs['gosaVacationStop']);
+ }
+
/* Save data to LDAP */
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
-
+
show_ldap_error($ldap->get_error(), _("Saving mail account failed"));
/* Only do IMAP actions if we are not a template */
if ($method->connect($this->gosaMailServer)){
$method->updateMailbox($this->folder_prefix.$this->$id);
+
$method->setQuota($this->folder_prefix.$this->$id, $this->gosaMailQuota);
$method->disconnect();
- /* Write sieve information only if not in C mode */
- if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
- $method->configureFilter($this->$id,
- $this->gosaMailDeliveryMode,
- $this->mail,
- $this->gosaMailAlternateAddress,
- $this->gosaMailMaxSize,
- $this->gosaSpamMailbox,
- $this->gosaSpamSortLevel,
- $this->gosaVacationMessage);
+ /* Only talk with sieve if the mail account already exists */
+ if($this->initially_was_account){
+
+ /* Write sieve information only if not in C mode */
+ if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
+ $method->configureFilter($this->$id,
+ $this->gosaMailDeliveryMode,
+ $this->mail,
+ $this->gosaMailAlternateAddress,
+ $this->gosaMailMaxSize,
+ $this->gosaSpamMailbox,
+ $this->gosaSpamSortLevel,
+ $this->gosaVacationMessage);
+ $this->is_modified = TRUE;
+ }else{
+ $this->sieve_management->save();
+ }
}
}
}
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
if ($this->is_modified){
- $this->handle_post_events("modify");
+ $this->handle_post_events("modify", array('uid'=> $this->uid));
}
} else {
- $this->handle_post_events("add");
+ $this->handle_post_events("add", array('uid'=>$this->uid));
}
+ $this->updateSharedFolder();
}
+
/* Check formular input */
function check()
{
if(!$this->is_account) return(array());
+
$ldap= $this->config->get_ldap_link();
/* Call common method to give check the hook */
}
}
$ldap->cd($this->config->current['BASE']);
- $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid"));
+ $filter = "(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))".
+ "(objectClass=gosaMailAccount)".
+ "(|(mail=".$this->mail.")(alias=".$this->mail.")(gosaMailAlternateAddress=".$this->mail.")))";
+
+ $ldap->search($filter,array("uid"));
if ($ldap->count() != 0){
$message[]= _("The primary address you've entered is already in use.");
}
$message[]= _("You specified Spam settings, but there is no Folder specified.");
}
+ if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
+ $message[]= _("Time interval to show vacation message is not valid.");
+ }
+
return ($message);
}
+
/* Adapt from template, using 'dn' */
function adapt_from_template($dn)
{
$this->mail= strtolower(rewrite($this->mail));
}
+
/* Add entry to forwarder list */
function addForwarder($address)
{
$this->gosaMailForwardingAddress[]= $address;
$this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
-
sort ($this->gosaMailForwardingAddress);
reset ($this->gosaMailForwardingAddress);
$this->is_modified= TRUE;
}
+
/* Remove list of addresses from forwarder list */
function delForwarder($addresses)
{
}
-
+ /* Add given mail address to the list of alternate adresses ,
+ check if this mal address is used, skip adding in this case */
function addAlternate($address)
{
$ldap= $this->config->get_ldap_link();
-
$address= strtolower($address);
-
+
/* Is this address already assigned in LDAP? */
$ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
+ $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
+ "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid"));
if ($ldap->count() > 0){
$attrs= $ldap->fetch ();
sort ($this->gosaMailAlternateAddress);
reset ($this->gosaMailAlternateAddress);
-
return ("");
}
if(isset($_POST['mail'])){
$this->mail = $_POST['mail'];
}
+ }
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ /* Reset alternate mail addresses */
+ $this->gosaMailAlternateAddress = array();
+ }
+
+
+ function allow_remove()
+ {
+ if (isset($this->config->current['MAILMETHOD'])){
+ $method= $this->config->current['MAILMETHOD'];
+ if(preg_match("/olab/i",$method)){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->cat($this->dn);
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ if(isset($attrs['kolabDeleteFlag'])){
+ return(_("Waiting for kolab to remove mail properties."));
+ }elseif(in_array("gosaMailAccount",$attrs['objectClass'])){
+ return(_("Please remove the mail account first, to allow kolab to call its remove methods."));
+ }
+ }
+ }
+ }
+ }
+ /* Upated shared folder ACLs
+ */
+ function updateSharedFolder()
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array('dn','cn'));
+ if(class_exists("grouptabs")){
+ while($attrs = $ldap->fetch()){
+ $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
+ if(isset($tmp->by_object['mailgroup'])){
+ $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid;
+ if(!$this->is_account){
+ $tmp->by_object['mailgroup']->removeUserAcl($this->uid);
+ $tmp->by_object['mailgroup']->removeUserAcl($this->mail);
+ }
+ $tmp->by_object['mailgroup']->save();
+ }
+ }
+ }
}
}