* Mail: fixed sometimes not working (un)subscribe of mailboxes, added better diagnostic and automatic (de)select children

This commit is contained in:
Ralf Becker 2014-08-15 11:22:43 +00:00
parent 49f9086420
commit e47db95be7
8 changed files with 133 additions and 133 deletions

View File

@ -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
*

View File

@ -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);
}
@ -4067,7 +4033,7 @@ class mail_ui
$response->call('app.mail.lock_tree');
}
$this->mail_bo->compressFolder($trashFolder);
$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
$fStatus = array(

View File

@ -191,7 +191,7 @@ app.classes.mail = AppJS.extend(
var that = this;
this.mail_isMainWindow = false;
this.compose_fieldExpander_hide();
/* Control focus actions on subject to handle expanders properly.*/
jQuery("#mail-compose_subject").on({
focus:function(){
@ -203,7 +203,7 @@ app.classes.mail = AppJS.extend(
jQuery('#mail-compose').load ('load', function() {that.compose_resizeHandler();});
this.compose_fieldExpander();
//Call drag_n_drop initialization for emails on compose
this.init_dndCompose();
break;
@ -1139,7 +1139,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);
},
@ -1547,7 +1547,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
@ -3097,8 +3097,9 @@ app.classes.mail = AppJS.extend(
tmp = aliases.concat(addr.get_value());
// returns de-duplicate items of an array
var deDuplicator = function (item,pos){
return tmp.indexOf(item) == pos
var deDuplicator = function (item,pos)
{
return tmp.indexOf(item) == pos;
};
aliases = tmp.filter(deDuplicator);
@ -3374,6 +3375,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)
*
@ -3661,16 +3675,16 @@ app.classes.mail = AppJS.extend(
vacation_change_account: function (_egw, _widget)
{
_widget.getInstanceManager().submit();
},
},
/**
* Set email items draggable
* Set email items draggable
**/
set_dragging_dndCompose: function ()
{
var zIndex = 100;
var self = this;
jQuery('div.ms-sel-item:not(div.ui-draggable)').draggable({
appendTo:'body',
//Performance wise better to not add ui-draggable class to items since we are not using that class
@ -3679,9 +3693,9 @@ app.classes.mail = AppJS.extend(
cursor:'move',
cursorAt:{left:2},
//cancel dragging on close button to avoid conflict with close action
cancel:'.ms-close-btn',
cancel:'.ms-close-btn',
/**
* function to act on draggable item on revert's event
* function to act on draggable item on revert's event
* @returns {Boolean} return true
*/
revert: function (){
@ -3690,6 +3704,9 @@ app.classes.mail = AppJS.extend(
},
/**
* function to act as draggable starts dragging
*
* @param {type} event
* @param {type} ui
*/
start:function(event, ui)
{
@ -3703,7 +3720,7 @@ app.classes.mail = AppJS.extend(
jQuery(this).css('position','absolute');
},
/**
*
*
* @param {type} event
* @param {type} ui
*/
@ -3713,27 +3730,27 @@ app.classes.mail = AppJS.extend(
}
});
},
/**
* Initialize dropping targets for draggable emails
* -
*/
*/
init_dndCompose: function ()
{
var self = this;
//Call to make new items draggable
jQuery('#mail-compose_to,#mail-compose_cc,#mail-compose_bcc').hover(function(){
self.set_dragging_dndCompose();
});
//Make used email-tag list widgets in mail compose droppable
//Make used email-tag list widgets in mail compose droppable
jQuery('#mail-compose_to,#mail-compose_cc,#mail-compose_bcc').droppable({
access:'.ms-sel-item',
/**
* Run after a draggable email item dropped over one of the email-taglists
* -Set the dropped item to the dropped current target widget
*
*
* @param {type} event
* @param {type} ui
*/
@ -3743,22 +3760,22 @@ app.classes.mail = AppJS.extend(
var emails = [];
var fromWidget = {};
var draggedValue = ui.draggable.text();
if (typeof widget != 'undefined')
{
emails = widget.get_value();
if (emails) emails = emails.concat([draggedValue])
if (emails) emails = emails.concat([draggedValue]);
widget.set_value(emails);
var parentWidgetDOM = ui.draggable.parentsUntil('div[id^="mail-compoe_"]','.ui-droppable');
if (parentWidgetDOM != 'undefined' && parentWidgetDOM.length > 0)
{
fromWidget = self.et2.getWidgetById(parentWidgetDOM.attr('name'));
}
if (!jQuery.isEmptyObject(fromWidget)
if (!jQuery.isEmptyObject(fromWidget)
&& !(ui.draggable.attr('class').search('mailCompose_copyEmail') > -1))
{
if (!_removeDragged(fromWidget, draggedValue))
@ -3773,16 +3790,16 @@ app.classes.mail = AppJS.extend(
.removeClass('mailCompose_copyEmail')
.css('cursor','move');
}
//Destroy draggables after dropping, we need to enable them again
jQuery('div.ms-sel-item').draggable('destroy');
}
},
}
});
/**
* Remove dragged item from the widget which the item was dragged
*
*
* @param {type} _widget
* @param {type} _value
* @return {boolean} true if successul | false unsuccessul
@ -3804,7 +3821,7 @@ app.classes.mail = AppJS.extend(
}
}
return true;
}
};
}
});

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>