From 78a461b1207927c37d2f919f20782b7ccc4fc79e Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 22 May 2014 14:46:50 +0000 Subject: [PATCH] * Mail/Sieve: Show mail sieve rules list in mail index with sidebox mailTree available --- mail/inc/class.mail_sieve.inc.php | 43 ++----- mail/inc/class.mail_ui.inc.php | 10 +- mail/js/app.js | 191 ++++++++++++++++-------------- mail/templates/default/index.xet | 1 + 4 files changed, 119 insertions(+), 126 deletions(-) diff --git a/mail/inc/class.mail_sieve.inc.php b/mail/inc/class.mail_sieve.inc.php index 09fb92cf3f..e9fcab8aaf 100644 --- a/mail/inc/class.mail_sieve.inc.php +++ b/mail/inc/class.mail_sieve.inc.php @@ -815,35 +815,15 @@ class mail_sieve $response->call('app.mail.sieve_refresh'); } - /** - * Ajax function to handle the server side content for refreshing the form - * - * @param type $execId - */ - function ajax_sieve_egw_refresh($execId) - { - //Need to read the template to use for refreshing the form - $response = egw_json_response::get(); - - $response->generic('assign',array( - 'etemplate_exec_id' => $execId, - 'id' => 'rg', - 'key' => 'value', - 'value' => array('content' => $this->get_rows()) - )); - //error_log(__METHOD__. "RESPONSE".array2string($response)); - } - /** * Ajax function to handle actions over sieve rules list on gd * - * @param {int|boolean} $exec_id template unique Id | false if we only wants to use serverside actions - * @param {string} $action name of action - * @param {string} $checked the selected rule id - * @param {string} $msg containing the message comming from the client-side + * @param string $action name of action + * @param string $checked the selected rule id + * @param string $msg containing the message comming from the client-side * */ - function ajax_action($exec_id, $action,$checked,$msg) + function ajax_action($action, $checked, $msg) { $this->getRules(null); @@ -876,22 +856,17 @@ class mail_sieve ob_start(); $result = $this->updateScript(); + + $response = egw_json_response::get(); + if($result) { - egw_json_response::get()->error($result); + $response->error($result); return; } $this->saveSessionData(); - //Refresh the grid - if ($exec_id) - { - $this->ajax_sieve_egw_refresh($exec_id,$msg); - } - else - { - return $msg; - } + $response->call('app.mail.sieve_refresh'); } /** diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 6054a9c085..2cb70798cf 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -230,8 +230,8 @@ class mail_ui * Subscribe or Unsubscribe to a folder * also it is consider if the folder is valid to un/subscribe * - * @param {boolean} $status subscribe if true and unsubscribe if false - * @param {string} $folderName folder name + * @param boolean $folderName subscribe if true and unsubscribe if false + * @param string $status folder name * * @example setSubscribe('INBOX', true) subscribe to folder INBOX * @@ -1042,7 +1042,7 @@ class mail_ui * @param array $data data to be processed * @param array &$out, out array * @param string $del needed as glue for parent/child operation / comparsion - * @param boolean $crea$createMissingParentste a missing parent, instead of throwing an exception + * @param boolean $createMissingParents a missing parent, instead of throwing an exception * @return void */ function setOutStructure($data, &$out, $del='.', $createMissingParents=true) @@ -1699,7 +1699,7 @@ class mail_ui * * @param string $_folderName used to ensure the uniqueness of the uid over all folders * @param string $message_uid the message_Uid to be used for creating the rowID - * @param boolean $$_prependAppflag to indicate that the app 'mail' is to be used for creating the rowID + * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid */ function createRowID($_folderName, $message_uid, $_prependApp=false) @@ -2416,8 +2416,6 @@ class mail_ui /** * emailAddressToHTML - * - * */ static function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true, $decode=true) { diff --git a/mail/js/app.js b/mail/js/app.js index a19cdd69a8..a4bc8067e7 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -92,86 +92,69 @@ app.classes.mail = AppJS.extend( * make sure to clean it up in destroy(). * * @param et2 etemplate2 Newly ready object + * @param {string} _name template name */ - et2_ready: function(et2) + et2_ready: function(et2, _name) { // call parent; somehow this function is called more often. (twice on a display and compose) why? this._super.apply(this, arguments); this.et2_obj = et2; - var isMainView = false; - var isDisplay = false; - var isCompose = false; - for (var t in et2.templates) - { - //alert(t); // as we iterate through this more than once, ... we separate trigger and action - switch (t) { - case 'mail.index': - this.mail_isMainWindow = isMainView=true; - break; - case 'mail.display': - this.mail_isMainWindow = false; - isDisplay=true; - this.mail_display(); - break; - case 'mail.compose': - this.mail_isMainWindow = false; - isCompose = true; - this.hide_cc_compose(); - break; - } - } - //alert('action about to go down'); - if (isMainView) - { - this.mail_disablePreviewArea(true); - // Bind to nextmatch refresh to update folder status - var nm = this.et2.getWidgetById(this.nm_index); - if(nm != null && (typeof jQuery._data(nm).events=='undefined'||typeof jQuery._data(nm).events.refresh == 'undefined')) - { - var self = this; - $j(nm).on('refresh',function() {self.mail_refreshFolderStatus.call(self,undefined,undefined,false);}); - } - var tree_wdg = this.et2.getWidgetById(this.nm_index+'[foldertree]'); - if (tree_wdg) - { - tree_wdg.set_onopenstart(jQuery.proxy(this.openstart_tree, this)); - tree_wdg.set_onopenend(jQuery.proxy(this.openend_tree, this)); - } - } - if (isDisplay) + switch (_name) { - var subject = this.et2.getWidgetById('mail_displaysubject'); - var body = this.et2.getWidgetById('mailDisplayBodySrc'); - body.node.parentNode.style.top=subject.node.offsetTop+40+'px'; - var app_registry = egw.link_get_registry('mail'); - var w=870; - if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' ) - { - var w_h =app_registry['view_popup'].split('x'); - if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()); - } - window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()))); - } - if (isCompose) - { - var app_registry = egw.link_get_registry('mail');//this.appname); - //console.log(app_registry); - w=870; - if (typeof app_registry['edit'] != 'undefined' && typeof app_registry['edit_popup'] != 'undefined' ) - { - var w_h =app_registry['edit_popup'].split('x'); - if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()); - } - //alert('resizing to'+(w_h[0]?w_h[0]:870)+','+(w_h[1]?w_h[1]:egw_getWindowOuterHeight())); - //window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()))); - window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight<800?screen.availHeight:800))); - this.compose_cc_expander(); - } - //Vacation By_date filter - if (typeof et2.templates['mail.sieve.vacation'] != 'undefined') - { - this.vacationFilterStatusChange(); + case 'mail.sieve.vacation': + this.vacationFilterStatusChange(); + break; + case 'mail.index': + var nm = this.et2.getWidgetById(this.nm_index); + this.mail_isMainWindow = true; + this.mail_disablePreviewArea(true); + + // Bind to nextmatch refresh to update folder status + if(nm != null && (typeof jQuery._data(nm).events=='undefined'||typeof jQuery._data(nm).events.refresh == 'undefined')) + { + var self = this; + $j(nm).on('refresh',function() {self.mail_refreshFolderStatus.call(self,undefined,undefined,false);}); + } + var tree_wdg = this.et2.getWidgetById(this.nm_index+'[foldertree]'); + if (tree_wdg) + { + tree_wdg.set_onopenstart(jQuery.proxy(this.openstart_tree, this)); + tree_wdg.set_onopenend(jQuery.proxy(this.openend_tree, this)); + } + break; + case 'mail.display': + var subject = this.et2.getWidgetById('mail_displaysubject'); + var body = this.et2.getWidgetById('mailDisplayBodySrc'); + this.mail_isMainWindow = false; + this.mail_display(); + body.node.parentNode.style.top=subject.node.offsetTop+40+'px'; + var app_registry = egw.link_get_registry('mail'); + var w=870; + if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' ) + { + var w_h =app_registry['view_popup'].split('x'); + if (w_h[1] == 'egw_getWindowOuterHeight()') + { + w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()); + } + } + window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()))); + break; + case 'mail.compose': + var app_registry = egw.link_get_registry('mail'); + this.mail_isMainWindow = false; + this.hide_cc_compose(); + + if (typeof app_registry['edit'] != 'undefined' && typeof app_registry['edit_popup'] != 'undefined' ) + { + var w_h =app_registry['edit_popup'].split('x'); + if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()); + } + + window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight<800?screen.availHeight:800))); + this.compose_cc_expander(); + break; } }, @@ -1417,7 +1400,10 @@ app.classes.mail = AppJS.extend( * @param {string} _previous - Previously selected node ID */ mail_changeFolder: function(_folder,_widget, _previous) { - + + // to reset iframes to the normal status + this.loadIframe(); + // Abort if user selected an un-selectable node // Use image over anything else because...? var img = _widget.getSelectedNode().images[0]; @@ -2759,21 +2745,17 @@ app.classes.mail = AppJS.extend( { if (_typeID && _data) { - var request = egw().json('mail.mail_sieve.ajax_action', [this.et2_obj.etemplate_exec_id, _typeID,_selectedID,_msg],null,null,true); + var request = egw().json('mail.mail_sieve.ajax_action', [_typeID,_selectedID,_msg],null,null,true); request.sendRequest(); } }, /** - * * Send ajax request to server to refresh the sieve grid - * - * */ sieve_refresh: function() { - var request = egw().json('mail.mail_sieve.ajax_sieve_egw_refresh', [this.et2_obj.etemplate_exec_id],null,this.et2_obj,true); - request.sendRequest(); + this.et2._inst.submit(); }, /** @@ -2786,7 +2768,9 @@ app.classes.mail = AppJS.extend( acl_common_rights_selector: function(event,widget) { var rowId = widget.id.replace(/[^0-9.]+/g, ''); - var rights = (widget.get_value() == "custom")?[]:(widget.get_value() == "aeiklprstwx")? widget.get_value().replace(/[k,x,t,e]/g,"cd").split(""):widget.get_value().split(""); + var rights = (widget.get_value() == "custom"?[]:widget.get_value() == "aeiklprstwx")? + widget.get_value().replace(/[k,x,t,e]/g,"cd").split(""):widget.get_value().split(""); + for (var i=0;i +