mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-14 20:14:11 +01:00
* Mail: fixed sometimes not working (un)subscribe of mailboxes, added better diagnostic and automatic (de)select children
This commit is contained in:
parent
4a850f63d9
commit
c1275309ab
@ -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."<br>";
|
||||
#_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) {
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -230,80 +230,30 @@ 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);
|
||||
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();
|
||||
$content['profileId'] = $profileId;
|
||||
|
||||
$allFolders = $this->mail_bo->getFolderObjects(false,false,false,false);
|
||||
foreach ($allFolders as $folder)
|
||||
{
|
||||
$folderName = $profileId . self::$delimiter . $folder->folderName;
|
||||
@ -313,7 +263,6 @@ class mail_ui
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list($button) = @each($content['button']);
|
||||
@ -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)
|
||||
{
|
||||
if($this->setSubscribe($folder->folderName, false))
|
||||
$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)
|
||||
{
|
||||
$msg = lang('Subscription successfully saved!');
|
||||
|
||||
$msg_type = 'error';
|
||||
if ($subscribe)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -12,7 +12,7 @@
|
||||
</row>
|
||||
<row>
|
||||
<box scrolling="auto">
|
||||
<tree id="foldertree" onclick="" multiple="true"/>
|
||||
<tree id="foldertree" onclick="app.mail.subscribe_onclick" multiple="true"/>
|
||||
</box>
|
||||
</row>
|
||||
</rows>
|
||||
@ -20,7 +20,7 @@
|
||||
<hbox class="dialogFooterToolbar">
|
||||
<button statustext="Saves subscription changes" label="Save" id="button[save]"/>
|
||||
<button statustext="Applies the changes made" label="Apply" id="button[apply]"/>
|
||||
<button label="Cancel" id="button[cancel]"/>
|
||||
<button label="Cancel" id="button[cancel]" onclick="window.close()"/>
|
||||
</hbox>
|
||||
</template>
|
||||
</overlay>
|
||||
|
Loading…
Reference in New Issue
Block a user