X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fadmin%2Fogroups%2Fclass_mailogroup.inc;h=cddc5b07d2c13cc15a6a1e237cf45c467c1f53c7;hb=1a1cd62339c5c255de11b0d5b78649e067e7bc34;hp=699934f3fd0633834c963a612ff5c62afb0d7995;hpb=80ddd3991dd84b50ff87a05f26eae3b6e32a52a2;p=gosa.git diff --git a/plugins/admin/ogroups/class_mailogroup.inc b/plugins/admin/ogroups/class_mailogroup.inc index 699934f3f..cddc5b07d 100644 --- a/plugins/admin/ogroups/class_mailogroup.inc +++ b/plugins/admin/ogroups/class_mailogroup.inc @@ -9,53 +9,172 @@ class mailogroup extends plugin /* attribute list for save action */ var $attributes= array("mail"); var $objectclasses= array("kolabGroupOfNames"); - var $members= array(); - function mailogroup ($config, $dn= NULL) + + function mailogroup ($config, $dn= NULL, $parent= NULL) { - plugin::plugin($config, $dn); + plugin::plugin($config, $dn, $parent); /* Include config object */ $this->config= $config; + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; } + function execute() { + /* Call parent execute */ + plugin::execute(); + + /* Do we need to flip is_account state? */ + if(isset($_POST['modify_state'])){ + if($this->is_account && $this->acl_is_removeable()){ + $this->is_account= FALSE; + }elseif(!$this->is_account && $this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + + /* Show tab dialog headers */ + if ($this->parent != NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove mail account"), + _("This group has mail features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create mail account"), _("This group has mail features disabled. You can enable them by clicking below.")); + return ($display); + } + } + /* Initialize templating engine */ $smarty= get_smarty(); + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl("mail")); + } + /* Assign mail attribute */ $smarty->assign("mail", $this->mail); - $smarty->assign("mailACL", chkacl($this->acl, "mail")); /* Show main page */ - return ($smarty->fetch (get_template_path('mail.tpl', TRUE))); + return ($display.$smarty->fetch (get_template_path('mail.tpl', TRUE))); } + /* Check formular input */ function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if ($this->is_account){ + $ldap= $this->config->get_ldap_link(); + + /* Check if mail address is valid */ + if (!is_email($this->mail) || $this->mail == ""){ + $message[]= _("Please enter a valid email address in 'Primary address' field."); + } + + /* Check if mail address is already in use */ + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(|(mail=".$this->mail. ")(gosaMailAlternateAddress=".$this->mail."))(!(cn=".$this->cn.")))", array("uid")); + if ($ldap->count() != 0){ + $message[]= _("The primary address you've entered is already in use."); + } + } + + return ($message); + } + + + function save() { $ldap= $this->config->get_ldap_link(); - $message= array(); + /* Call parents save to prepare $this->attrs */ + plugin::save(); - /* Check if mail address is valid */ - if (!is_email($this->mail)){ - $message[]= _("Please enter a valid email address in 'Primary address' field."); + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/mail with dn '%s' failed."),$this->dn)); + + /* 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"); + } + } else { + $this->handle_post_events("add"); } + } - /* Check if mail address is already in use */ - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(|(mail=".$this->mail. ")(gosaMailAlternateAddress=".$this->mail."))(!(cn=".$this->cn.")))", array("uid")); - if ($ldap->count() != 0){ - $message[]= _("The primary address you've entered is already in use."); + + /* remove object from parent */ + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; } - - return ($message); + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/mail with dn '%s' failed."),$this->dn)); + } + + + function getCopyDialog() + { + $str = ""; + $str .= _("Phone number"); + $str .= " "; + return($str); } + + function saveCopyDialog() + { + if(isset($_POST['mail'])){ + $this->mail = $_POST['mail']; + } + } + + + function plInfo() + { + return (array( + "plShortName" => _("Mail"), + "plDescription" => _("Mail group"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("ogroups"), + "plProvidedAcls"=> array( + "mail" => _("Mail address")) + )); + } + + + + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: