diff --git a/gosa-plugins/mail/personal/mail/class_mailAccount.inc b/gosa-plugins/mail/personal/mail/class_mailAccount.inc
index 147802851934d2613dc958147301fb05976c17ea..295ab5747b801bd6eb374b0fabd985551664e8f1 100644 (file)
var $gosaSpamMailbox = "";
/* The methods defaults */
+ var $quotaUsage = -1; // Means unknown
+
var $mailMethod = NULL;
var $MailDomain = "";
var $sieveManagementUsed = FALSE;
var $multiple_support = TRUE;
+ var $uid = "";
+ var $cn = "";
+
+
/*! \brief Initialize the mailAccount
*/
function __construct (&$config, $dn= NULL)
{
plugin::plugin($config,$dn);
+ /* Get attributes from parent object
+ */
+ foreach(array("uid","cn") as $attr){
+ if(isset($this->parent->by_object['group']) && isset($this->parent->by_object['group']->$attr)){
+ $this->$attr = &$this->parent->by_object['group']->$attr;
+ }elseif(isset($this->attrs[$attr])){
+ $this->$attr = $this->attrs[$attr][0];
+ }
+ }
+
/* Intialize the used mailMethod
*/
$tmp = new mailMethod($config,$this);
/* Read quota */
$this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
+ $this->quotaUsage = $this->mailMethod->getQuotaUsage($this->quotaUsage);
if($this->mailMethod->is_error()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}
/* Read mailboxes */
$this->MailBoxes = $this->mailMethod->getMailboxList($this->MailBoxes);
if($this->mailMethod->is_error()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot get list of mailboxes! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot get list of mailboxes: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}
}elseif(!$this->mailMethod->is_connected()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Mail method cannot connect: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}elseif(!$this->mailMethod->account_exists()){
- msg_dialog::display(_("Mail error"), sprintf(_("Mailbox '%s' doesn't exists on mail server: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Mailbox '%s' doesn't exists on mail server: %s"),
$this->mailMethod->get_account_id(),$this->gosaMailServer), ERROR_DIALOG);
}
function execute()
{
+
/* Call parent execute */
$display = plugin::execute();
****************/
$smarty = get_smarty();
$smarty->assign("initially_was_account", $this->initially_was_account);
- $smarty->assign("isModifyableMail", $this->mailMethod->isModifyableMail());
+ $smarty->assign("isModifyableMail" , $this->mailMethod->isModifyableMail());
+ $smarty->assign("isModifyableServer", $this->mailMethod->isModifyableServer());
$smarty->assign("mailEqualsCN", $this->mailMethod->mailEqualsCN());
$SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
$smarty->assign($attr,$this->$attr);
}
$smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
- if($this->mailMethod->is_connected()){
- $smarty->assign("quotaUsage", $this->mailMethod->getQuotaUsage());
- }else{
- $smarty->assign("quotaUsage", _("Unknown"));
+ if($this->mailMethod->quotaEnabled()){
+ $smarty->assign("quotaUsage", mailMethod::quota_to_image($this->quotaUsage,$this->gosaMailQuota));
+ $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
}
- $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
$smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
$smarty->assign("MailDomains", $this->mailDomainParts);
$smarty->assign("MailDomain" , $this->mailDomainPart);
if (isset($_POST['mailTab'])){
/* Save ldap attributes */
- $mail = $this->mail;
+ $mail = $this->mail;
+ $server = $this->gosaMailServer;
plugin::save_object();
+ if(!$this->mailMethod->isModifyableServer() && $this->initially_was_account){
+ $this->gosaMailServer = $server;
+ }
+
if(!$this->mailMethod->isModifyableMail() && $this->initially_was_account){
$this->mail = $mail;
}else{
$this->mail = $this->mail."@".$this->mailDomainPart;
}
+ /* Update sharedFolder dependencies.
+ Open each shared folder and remove this account.
+ Then Save the group to ensure that all necessary
+ actions will be taken (imap acls updated aso.).
+ */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array("dn"));
+ while($attrs = $ldap->fetch()){
+ $grp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
+ if(isset($grp->by_object['mailgroup']) && isset($grp->by_object['group'])){
+ $grp->by_object['group']->removeUser($this->uid);
+
+ /* Do not save the complete group! This will quit the complete membership
+ */
+ $grp->by_object['mailgroup']->save();
+ }
+ }
+
/* Remove GOsa attributes */
plugin::remove_from_parent();
if (!$this->is_template){
if(!$this->mailMethod->connect()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Mail method cannot connect: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}else{
if(!$this->mailMethod->deleteMailbox()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot remove mailbox! Error was: %s."),
- $this->mailMethod->get_error()), ERROR_DIALOG);
- }
- if(!$this->mailMethod->updateSharedFolder()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot remove mailbox: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}
}
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
-
-
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
if (!$this->is_template){
$this->mailMethod->connect();
if(!$this->mailMethod->is_connected()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Mail method cannot connect: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}else{
if(!$this->mailMethod->updateMailbox()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot update mailbox! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update mailbox: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}
if(!$this->mailMethod->setQuota($this->gosaMailQuota)){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot write quota settings! Error was: %s."),
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot write quota settings: %s"),
$this->mailMethod->get_error()), ERROR_DIALOG);
}
if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
-
/* Do not write sieve settings if this account is new and
doesn't seem to exist.
*/
}
}
}else{
-
echo "Check sieve management here";
-
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,
"User uses an own sieve script, skipping sieve update.".$str."</b>","");
}
+ }
+ }
+ $this->mailMethod->disconnect();
- if(!$this->mailMethod->updateSharedFolder()){
- msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."),
- $this->mailMethod->get_error()), ERROR_DIALOG);
+ /* Update sharedFolder dependencies.
+ Open each shared folder and remove this account.
+ Then Save the group to ensure that all necessary
+ actions will be taken (imap acls updated aso.).
+ */
+ if(!$this->initially_was_account){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array("dn"));
+ while($attrs = $ldap->fetch()){
+ $grp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
+ if(isset($grp->by_object['mailgroup'])){
+ /* Do not save the complete group! This will quit the complete membership
+ */
+ $grp->by_object['mailgroup']->save();
}
}
}
- $this->mailMethod->disconnect();
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
}
+ function allow_remove()
+ {
+ $resason = "";
+ if(!$this->mailMethod->allow_remove($reason)){
+ return($reason);
+ }
+ return("");
+ }
+
+
+
/*! \brief ACL settings
*/
static function plInfo()