* Mail/Sieve: Show mail sieve rules list in mail index with sidebox mailTree available

This commit is contained in:
Hadi Nategh 2014-05-22 14:46:50 +00:00
parent 090c6eb19f
commit 78a461b120
4 changed files with 119 additions and 126 deletions

View File

@ -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');
}
/**

View File

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

View File

@ -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<this.aclRights.length;i++)
{
var rightsWidget = this.et2.getWidgetById(rowId+'[acl_' + this.aclRights[i]+ ']');
@ -2845,12 +2829,47 @@ app.classes.mail = AppJS.extend(
edit_sieve: function(_action, _senders)
{
var acc_id = parseInt(_senders[0].id);
this.egw.open_link(this.egw.link('/index.php',
var url = this.egw.link('/index.php',{
'menuaction': 'mail.mail_sieve.index',
'acc_id': acc_id,
'ajax': 'true'
});
if (!this.loadIframe(url))
{
this.egw.open_link(url);
}
},
/**
* Load an url on an iframe
*
* @param {string} _url string egw url
* @param {iframe widget} _iFrame an iframe to be set if non, extra_iframe is default
*
* @return {boolean} return TRUE if success, and FALSE if iframe not given
*/
loadIframe: function (_url, _iFrame)
{
var mailSplitter = this.et2.getWidgetById('mailSplitter');
var quotaipercent = this.et2.getWidgetById('nm[quotainpercent]');
var iframe = _iFrame || this.et2.getWidgetById('extra_iframe');
if (typeof iframe != 'undefined')
{
if (_url)
{
'menuaction': 'mail.mail_sieve.index',
'acc_id': acc_id,
'ajax': 'true'
}));
iframe.set_src(_url);
}
if (typeof mailSplitter != 'undefined' && typeof quotaipercent != 'undefined')
{
mailSplitter.set_disabled(!!_url);
quotaipercent.set_disabled(!!_url);
iframe.set_disabled(!_url);
}
return true;
}
return false;
},
/**

View File

@ -113,5 +113,6 @@
</box>
</vbox>
</split>
<iframe frameborder="1" height="100%" id="extra_iframe" scrolling="auto" width="100%" disabled="true"/>
</template>
</overlay>