diff --git a/emailadmin/inc/class.emailadmin_imapbase.inc.php b/emailadmin/inc/class.emailadmin_imapbase.inc.php
index 745fad946d..d654118cbd 100644
--- a/emailadmin/inc/class.emailadmin_imapbase.inc.php
+++ b/emailadmin/inc/class.emailadmin_imapbase.inc.php
@@ -1020,7 +1020,7 @@ class emailadmin_imapbase
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer));
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, $expiration=60*60*24*5);
- return $_specialUseFolders[$this->icServer->ImapServerId];
+ return $_specialUseFolders[$this->icServer->ImapServerId];
}
/**
@@ -2181,42 +2181,6 @@ class emailadmin_imapbase
return true;
}
- /**
- * subscribe: do the subscription or unsubscribe on a given folder
- * returns a boolean on success or failure.
- *
- * @param string $_folderName
- * @param boolean $_status subscribe on true, unsubscribe on false
- * @return boolean
- */
- function subscribe($_folderName, $_status)
- {
- if (self::$debug) error_log(__METHOD__."::".($_status?"":"un")."subscribe:".$_folderName);
- if($_status === true) {
- try
- {
- $rv = $this->icServer->subscribeMailbox($_folderName);
- }
- catch (Exception $e)
- {
- error_log(__METHOD__."::".($_status?"":"un")."subscribe:".$_folderName." failed:".$e->getMessage);
- return false;
- }
- } else {
- try
- {
- $rv = $this->icServer->subscribeMailbox($_folderName,false);
- }
- catch (Exception $e)
- {
- error_log(__METHOD__."::".($_status?"":"un")."subscribe:".$_folderName." failed:".$e->getMessage);
- return false;
- }
- }
-
- return true;
- }
-
/**
* fetchUnSubscribedFolders: get unsubscribed IMAP folder list
*
@@ -2634,7 +2598,7 @@ class emailadmin_imapbase
if(!$_subscribedOnly) {
#echo $folderName."->".$type."
";
#_debug_array($foldersNameSpace[$type]['subscribed']);
- $folderObject->subscribed = in_array($folderName, $foldersNameSpace[$type]['subscribed']);
+ $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']);
}
if($_getCounters == true) {
diff --git a/etemplate/js/et2_widget_tree.js b/etemplate/js/et2_widget_tree.js
index 4ed5148739..f4868eed2d 100644
--- a/etemplate/js/et2_widget_tree.js
+++ b/etemplate/js/et2_widget_tree.js
@@ -818,6 +818,19 @@ var et2_tree = et2_inputWidget.extend(
}
},
+ /**
+ * Set state of node incl. it's children
+ *
+ * @param {string} _id id of node
+ * @param {boolean|string} _state or "toggle" to toggle state
+ */
+ setSubChecked: function(_id, _state)
+ {
+ if (_state === "toggle") _state = !this.input.isItemChecked(_id);
+
+ this.input.setSubChecked(_id, _state);
+ },
+
/**
* Get URL relative to image_path option
*
diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php
index b90e613933..6d2e8db8e4 100644
--- a/mail/inc/class.mail_ui.inc.php
+++ b/mail/inc/class.mail_ui.inc.php
@@ -230,87 +230,36 @@ class mail_ui
if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
}
- /**
- * Subscribe or Unsubscribe to a folder
- * also it is consider if the folder is valid to un/subscribe
- *
- * @param boolean $folderName subscribe if true and unsubscribe if false
- * @param string $status folder name
- *
- * @example setSubscribe('INBOX', true) subscribe to folder INBOX
- *
- */
- function setSubscribe ($folderName,$status=true)
- {
- $validFolder = true;
- $result = true;
- $nameSpaces = $this->mail_bo->_getNameSpaces();
-
- foreach($nameSpaces as &$value )
- {
- if (str_replace($value['delimiter'],"",$value['prefix']) == $folderName &&
- $value['type'] == 'others' || $value['type'] == 'shared')
- {
- $validFolder = false;
- }
- }
-
- if ($status && $validFolder)
- {
- try
- {
- $this->mail_bo->subscribe($folderName, $status);
- } catch (Exception $e)
- {
- $result = false;
- error_log(__METHOD__.__LINE__."() error ".$e->getMessage()." happend while subscribing to folder ". $folderName );
- }
-
- }
- else if($validFolder)
- {
- try
- {
- $this->mail_bo->subscribe($folderName, $status);
- } catch (Exception $e)
- {
- $result = false;
- error_log(__METHOD__.__LINE__."() error ".$e->getMessage()." happend while unsubscribing of folder ". $folderName );
- }
- }
- return $result;
- }
-
/**
* Subscription popup window
*
* @param array $content
* @param type $msg
*/
- function subscription(array $content=null ,$msg='')
+ function subscription(array $content=null ,$msg=null)
{
$stmpl = new etemplate_new('mail.subscribe');
- $profileId = $_GET['acc_id'];
-
- $allFolders = $this->mail_bo->getFolderObjects(false,false,false,false);
- $sel_options['foldertree'] = $this->getFolderTree(false, $profileId,false,false);
+ if(is_array($content))
+ {
+ $profileId = $content['profileId'];
+ }
+ elseif (!($profileId = (int)$_GET['acc_id']))
+ {
+ egw_framework::window_close('Missing acc_id!');
+ }
+ $sel_options['foldertree'] = $this->getFolderTree(false, $profileId, false, false);
if (!is_array($content))
{
- if ($profileId)
+ $content['foldertree'] = array();
+ $allFolders = $this->mail_bo->getFolderObjects(false,false,false,false);
+ foreach ($allFolders as $folder)
{
-
- $content['foldertree'] = array();
- $content['profileId'] = $profileId;
-
- foreach ($allFolders as $folder)
+ $folderName = $profileId . self::$delimiter . $folder->folderName;
+ if ($folder->subscribed)
{
- $folderName = $profileId . self::$delimiter . $folder->folderName;
- if ($folder->subscribed)
- {
- array_push($content['foldertree'], $folderName);
- }
+ array_push($content['foldertree'], $folderName);
}
}
}
@@ -322,48 +271,65 @@ class mail_ui
case 'save':
case 'apply':
{
- foreach ($allFolders as $folder)
+ // do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
+ $namespace_roots = array($profileId);
+ foreach($this->mail_bo->_getNameSpaces() as $namespace)
{
- $folderName = $content['profileId'] . self::$delimiter . $folder->folderName;
- if (!in_array($folderName, $content['foldertree']))
+ $namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
+ }
+ error_log(__METHOD__."() namespace_roots=".array2string($namespace_roots));
+ $to_subscribe = array_diff($content['foldertree'], $content['current_subscribed'], $namespace_roots);
+ $to_unsubscribe = array_diff($content['current_subscribed'], $content['foldertree'], $namespace_roots);
+ foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
+ {
+ $subscribe = in_array($mailbox, $to_subscribe);
+ list(,$mailbox) = explode(self::$delimiter, $mailbox); // remove profileId and delimiter
+ try {
+ $this->mail_bo->icServer->subscribeMailbox($mailbox, $subscribe);
+ }
+ catch (Exception $ex)
{
- if($this->setSubscribe($folder->folderName, false))
+ $msg_type = 'error';
+ if ($subscribe)
{
- $msg = lang('Subscription successfully saved!');
-
+ $msg .= lang('Failed to subscribe folder %1!', $mailbox).' '.$ex->getMessage();
}
else
{
- $msg = lang('Subscription faild!');
+ $msg .= lang('Failed to unsubscribe folder %1!', $mailbox).' '.$ex->getMessage();
}
}
+ }
+ if (!isset($msg))
+ {
+ $msg_type = 'success';
+ if ($to_subscribe || $to_unsubscribe)
+ {
+ $msg = lang('Subscription successfully saved.');
+ }
else
{
- if($this->setSubscribe($folder->folderName, true))
- {
- $msg = lang('Subscription successfully saved!');
- }
- else
- {
- $msg = lang('Subscription faild!');
- }
+ $msg = lang('Nothing to change.');
}
}
+ // update foldertree in main window
$parentFolder='INBOX';
-
$refreshData = array(
- $content['profileId'] => lang($parentFolder)
+ $profileId => lang($parentFolder)
);
-
- // Send full info back in the response
$response = egw_json_response::get();
foreach($refreshData as $folder => &$name)
{
- $name = $this->getFolderTree(true, $folder, true, true,false);
+ $name = $this->getFolderTree(true, $folder, true, true, false);
}
+ // give success/error message to opener and popup itself
$response->call('opener.app.mail.mail_reloadNode',$refreshData);
- egw_framework::refresh_opener($msg, 'mail');
- if ($button == 'apply') break;
+ egw_framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
+ if ($button == 'apply')
+ {
+ egw_framework::message($msg, $msg_type);
+ break;
+ }
}
case 'cancel':
{
@@ -372,10 +338,10 @@ class mail_ui
}
}
- $preserv['profileId'] = $content['profileId'];
+ $preserv['profileId'] = $profileId;
+ $preserv['current_subscribed'] = $content['foldertree'];
$readonlys = array();
-
$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
}
diff --git a/mail/js/app.js b/mail/js/app.js
index 05f436136b..50cca99a52 100644
--- a/mail/js/app.js
+++ b/mail/js/app.js
@@ -1068,7 +1068,7 @@ app.classes.mail = AppJS.extend(
// as jsonq is too fast wrap it to be delayed a bit, to ensure the folder actions
// are executed last of the queue
window.setTimeout(function() {
- egw.jsonq('mail.mail_ui.ajax_setFolderStatus',[_folders], function (){self.unlock_tree()});
+ egw.jsonq('mail.mail_ui.ajax_setFolderStatus',[_folders], function (){self.unlock_tree();});
}, 100);
},
@@ -1476,7 +1476,7 @@ app.classes.mail = AppJS.extend(
var self = this;
this.egw.message(this.egw.lang('empty trash'));
- egw.json('mail.mail_ui.ajax_emptyTrash',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree()})
+ egw.json('mail.mail_ui.ajax_emptyTrash',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree();})
.sendRequest(true);
// Directly delete any trash cache for selected server
@@ -3292,6 +3292,19 @@ app.classes.mail = AppJS.extend(
.sendRequest();
},
+ /**
+ * Onclick for node/foldername in subscription popup
+ *
+ * Used to (un)check node including all children
+ *
+ * @param {string} _id id of clicked node
+ * @param {et2_tree} _widget reference to tree widget
+ */
+ subscribe_onclick: function(_id, _widget)
+ {
+ _widget.setSubChecked(_id, "toggle");
+ },
+
/**
* Edit a folder acl for account(s)
*
diff --git a/mail/lang/egw_de.lang b/mail/lang/egw_de.lang
index 05ddc732be..0fc7db30aa 100644
--- a/mail/lang/egw_de.lang
+++ b/mail/lang/egw_de.lang
@@ -95,7 +95,7 @@ displaying plain messages is disabled mail de Die Anzeige von reinen Text E-Mail
do not auto create folders mail de Automatische Ordnererstellung verhindern für
do you really want to apply %1 to all messages in the current view? mail de Wollen Sie wirklich %1 auf alle Nachrichten in der aktuellen Ansicht anwenden?
do you really want to delete folder %1 ? mail de Wollen Sie den Ordner %1 wirklich löschen?
-do you really want to mark ALL messages as read in the current folder? mail de Wollen Sie wirklich alle eMails im aktuellen Ordner als gelesen markieren?
+do you really want to mark all messages as read in the current folder? mail de Wollen Sie wirklich alle eMails im aktuellen Ordner als gelesen markieren?
do you really want to toggle flag %1 for all messages in current view? mail de Wollen Sie wirklich den Wert für %1 für alle Nachrichten in der aktuellen Ansicht umschalten?
do you want to be asked for confirmation before attaching selected messages to new mail? mail de Möchten Sie vor dem Anhängen von einer oder mehreren (ausgewählten) E-Mails an eine neue E-Mail gefragt werden?
do you want to be asked for confirmation before moving selected messages to another folder? mail de Möchten Sie vor dem Verschieben von E-Mails in andere Ordner gefragt werden?
@@ -147,6 +147,8 @@ failed to delete %1 ! reason: %2 mail de Löschen von %1 fehlgeschlagen! Grund:
failed to delete %1. server responded: mail de Löschen von %1 fehlgeschlagen! Grund: %2
failed to move %1 ! reason: %2 mail de Verschieben von %1 fehlgeschlagen! Grund: %2
failed to rename %1 ! reason: %2 mail de Umbenenne zu %1 fehlgeschlagen! Grund: %2
+failed to subscribe folder %1! mail de Fehler beim Abonnieren des Folders %1!
+failed to unsubscribe folder %1! mail de Fehler beim Abbestellen des Folders %1!
file into mail de verschiebe nach
file into: mail de verschieben nach:
file rejected, no %2. is:%1 mail de Datei abgelehnt; die vorliegende Datei ist nicht vom Typ %2. Sie ist vom Typ %1
@@ -271,6 +273,7 @@ no text body supplied, check attachments for message text mail de Keine Text vor
no valid %1 folder configured! mail de Kein gültiger %1 Ordner eingestellt!
non mail de Kein
none, create all mail de keine, erstellt alle
+nothing to change. mail de Nichts zu Ändern.
notify about new mail in this folders mail de Über neue Mails in diesem Ordner benachrichtigen
notify when new mails arrive in these folders mail de Benachrichtigung, sobald neue E-Mails in den folgenden Ordnern ankommen
on mail de am
@@ -392,9 +395,8 @@ subject(a->z) mail de Betreff (A->Z)
subject(z->a) mail de Betreff (Z->A)
subscribe folder mail de Abonnieren
subscribe folder ... mail de Ordner abonieren ...
-subscription faild! mail de Das Abonnieren ist fehlgeschlagen.
subscription folders mail de Ordner Abonieren
-subscription successfully saved! mail de Das Abonnieren der Ordner wurde erfolgreich gespeichert.
+subscription successfully saved. mail de Das Abonnieren der Ordner wurde erfolgreich gespeichert.
successfully connected mail de erfolgreich verbunden
template folder mail de Vorlagen Ordner
templates mail de Vorlagen
diff --git a/mail/lang/egw_en.lang b/mail/lang/egw_en.lang
index f5131278e3..0c4552e82b 100644
--- a/mail/lang/egw_en.lang
+++ b/mail/lang/egw_en.lang
@@ -95,7 +95,7 @@ displaying plain messages is disabled mail en displaying plain messages is disab
do not auto create folders mail en do not auto create folders
do you really want to apply %1 to all messages in the current view? mail en Do you really want to apply %1 to ALL messages in the current view?
do you really want to delete folder %1 ? mail en Do you really want to DELETE Folder %1 ?
-do you really want to mark ALL messages as read in the current folder? mail en Do you really want to mark ALL messages as read in the current folder?
+do you really want to mark all messages as read in the current folder? mail en Do you really want to mark ALL messages as read in the current folder?
do you really want to toggle flag %1 for all messages in current view? mail en Do you really want to toggle flag %1 for ALL messages in current view?
do you want to be asked for confirmation before attaching selected messages to new mail? mail en Do you want to be asked for confirmation before attaching selected messages to new mail?
do you want to be asked for confirmation before moving selected messages to another folder? mail en Do you want to be asked for confirmation before moving selected messages to another folder?
@@ -147,6 +147,8 @@ failed to delete %1 ! reason: %2 mail en failed to delete %1 ! Reason: %2
failed to delete %1. server responded: mail en Failed to delete %1. Server responded:
failed to move %1 ! reason: %2 mail en failed to move %1 ! Reason: %2
failed to rename %1 ! reason: %2 mail en failed to rename %1 ! Reason: %2
+failed to subscribe folder %1! mail en Failed to subscribe folder %1!
+failed to unsubscribe folder %1! mail en Failed to unsubscribe folder %1!
file into mail en file into
file into: mail en File into:
file rejected, no %2. is:%1 mail en File rejected, no %2. Is:%1
@@ -271,6 +273,7 @@ no text body supplied, check attachments for message text mail en no text body s
no valid %1 folder configured! mail en No valid %1 folder configured!
non mail en Non
none, create all mail en none, create all
+nothing to change. mail en Nothing to change.
notify about new mail in this folders mail en Notify about new mail in this folders
notify when new mails arrive in these folders mail en notify when new mails arrive in these folders
on mail en on
@@ -392,9 +395,8 @@ subject(a->z) mail en subject(A->Z)
subject(z->a) mail en subject(Z->A)
subscribe folder mail en Subscribe folder
subscribe folder ... mail en Subscribe folder ...
-subscription faild! mail en Subscription faild!
subscription folders mail en Subscription folders
-subscription successfully saved! mail en Subscription successfully saved!
+subscription successfully saved. mail en Subscription successfully saved.
successfully connected mail en Successfully connected
template folder mail en template folder
templates mail en Templates
diff --git a/mail/lang/egw_it.lang b/mail/lang/egw_it.lang
index d03a7636c9..81a4162e37 100644
--- a/mail/lang/egw_it.lang
+++ b/mail/lang/egw_it.lang
@@ -380,7 +380,7 @@ subscribe folder mail it Sottoscrivi cartella
subscribe folder ... mail it Sottoscrivi cartella...
subscription faild! mail it Sottoscrizione fallita!
subscription folders mail it Cartelle da sottoscrivere
-subscription successfully saved! mail it Sottoscrizione salvata corretamente!
+subscription successfully saved. mail it Sottoscrizione salvata corretamente.
successfully connected mail it Connesso con successo
template folder mail it Cartella dei modelli
templates mail it Modelli
diff --git a/mail/lang/egw_pt.lang b/mail/lang/egw_pt.lang
index 32b8fa0c1d..9969509684 100644
--- a/mail/lang/egw_pt.lang
+++ b/mail/lang/egw_pt.lang
@@ -341,7 +341,7 @@ subscribe folder mail pt Assinar pasta
subscribe folder ... mail pt Assinar pasta ...
subscription faild! mail pt Faild Assinatura!
subscription folders mail pt Pastas de Subscrição
-subscription successfully saved! mail pt Assinatura salvo com sucesso!
+subscription successfully saved. mail pt Assinatura salvo com sucesso.
successfully connected mail pt Conectado com sucesso
template folder mail pt pasta de modelo
templates mail pt Templates
diff --git a/mail/templates/default/subscribe.xet b/mail/templates/default/subscribe.xet
index a99a2506f9..0ba47e61f0 100755
--- a/mail/templates/default/subscribe.xet
+++ b/mail/templates/default/subscribe.xet
@@ -12,7 +12,7 @@
-
+
@@ -20,7 +20,7 @@