* 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'); $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 * 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} $action name of action * @param string $checked the selected rule id
* @param {string} $checked the selected rule id * @param string $msg containing the message comming from the client-side
* @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); $this->getRules(null);
@ -876,22 +856,17 @@ class mail_sieve
ob_start(); ob_start();
$result = $this->updateScript(); $result = $this->updateScript();
$response = egw_json_response::get();
if($result) if($result)
{ {
egw_json_response::get()->error($result); $response->error($result);
return; return;
} }
$this->saveSessionData(); $this->saveSessionData();
//Refresh the grid $response->call('app.mail.sieve_refresh');
if ($exec_id)
{
$this->ajax_sieve_egw_refresh($exec_id,$msg);
}
else
{
return $msg;
}
} }
/** /**

View File

@ -230,8 +230,8 @@ class mail_ui
* Subscribe or Unsubscribe to a folder * Subscribe or Unsubscribe to a folder
* also it is consider if the folder is valid to un/subscribe * also it is consider if the folder is valid to un/subscribe
* *
* @param {boolean} $status subscribe if true and unsubscribe if false * @param boolean $folderName subscribe if true and unsubscribe if false
* @param {string} $folderName folder name * @param string $status folder name
* *
* @example setSubscribe('INBOX', true) subscribe to folder INBOX * @example setSubscribe('INBOX', true) subscribe to folder INBOX
* *
@ -1042,7 +1042,7 @@ class mail_ui
* @param array $data data to be processed * @param array $data data to be processed
* @param array &$out, out array * @param array &$out, out array
* @param string $del needed as glue for parent/child operation / comparsion * @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 * @return void
*/ */
function setOutStructure($data, &$out, $del='.', $createMissingParents=true) 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 $_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 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 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
*/ */
function createRowID($_folderName, $message_uid, $_prependApp=false) function createRowID($_folderName, $message_uid, $_prependApp=false)
@ -2416,8 +2416,6 @@ class mail_ui
/** /**
* emailAddressToHTML * emailAddressToHTML
*
*
*/ */
static function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true, $decode=true) static function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true, $decode=true)
{ {

View File

@ -92,41 +92,25 @@ app.classes.mail = AppJS.extend(
* make sure to clean it up in destroy(). * make sure to clean it up in destroy().
* *
* @param et2 etemplate2 Newly ready object * @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? // call parent; somehow this function is called more often. (twice on a display and compose) why?
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.et2_obj = et2; this.et2_obj = et2;
var isMainView = false;
var isDisplay = false; switch (_name)
var isCompose = false;
for (var t in et2.templates)
{ {
//alert(t); // as we iterate through this more than once, ... we separate trigger and action case 'mail.sieve.vacation':
switch (t) { this.vacationFilterStatusChange();
break;
case 'mail.index': case 'mail.index':
this.mail_isMainWindow = isMainView=true; var nm = this.et2.getWidgetById(this.nm_index);
break; this.mail_isMainWindow = true;
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); this.mail_disablePreviewArea(true);
// Bind to nextmatch refresh to update folder status // 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')) if(nm != null && (typeof jQuery._data(nm).events=='undefined'||typeof jQuery._data(nm).events.refresh == 'undefined'))
{ {
var self = this; var self = this;
@ -138,40 +122,39 @@ app.classes.mail = AppJS.extend(
tree_wdg.set_onopenstart(jQuery.proxy(this.openstart_tree, this)); tree_wdg.set_onopenstart(jQuery.proxy(this.openstart_tree, this));
tree_wdg.set_onopenend(jQuery.proxy(this.openend_tree, this)); tree_wdg.set_onopenend(jQuery.proxy(this.openend_tree, this));
} }
} break;
if (isDisplay) case 'mail.display':
{
var subject = this.et2.getWidgetById('mail_displaysubject'); var subject = this.et2.getWidgetById('mail_displaysubject');
var body = this.et2.getWidgetById('mailDisplayBodySrc'); var body = this.et2.getWidgetById('mailDisplayBodySrc');
this.mail_isMainWindow = false;
this.mail_display();
body.node.parentNode.style.top=subject.node.offsetTop+40+'px'; body.node.parentNode.style.top=subject.node.offsetTop+40+'px';
var app_registry = egw.link_get_registry('mail'); var app_registry = egw.link_get_registry('mail');
var w=870; var w=870;
if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' ) if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' )
{ {
var w_h =app_registry['view_popup'].split('x'); 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()); 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()))); window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight())));
} break;
if (isCompose) case 'mail.compose':
{ var app_registry = egw.link_get_registry('mail');
var app_registry = egw.link_get_registry('mail');//this.appname); this.mail_isMainWindow = false;
//console.log(app_registry); this.hide_cc_compose();
w=870;
if (typeof app_registry['edit'] != 'undefined' && typeof app_registry['edit_popup'] != 'undefined' ) if (typeof app_registry['edit'] != 'undefined' && typeof app_registry['edit_popup'] != 'undefined' )
{ {
var w_h =app_registry['edit_popup'].split('x'); 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()); 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))); 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(); this.compose_cc_expander();
} break;
//Vacation By_date filter
if (typeof et2.templates['mail.sieve.vacation'] != 'undefined')
{
this.vacationFilterStatusChange();
} }
}, },
@ -1418,6 +1401,9 @@ app.classes.mail = AppJS.extend(
*/ */
mail_changeFolder: function(_folder,_widget, _previous) { mail_changeFolder: function(_folder,_widget, _previous) {
// to reset iframes to the normal status
this.loadIframe();
// Abort if user selected an un-selectable node // Abort if user selected an un-selectable node
// Use image over anything else because...? // Use image over anything else because...?
var img = _widget.getSelectedNode().images[0]; var img = _widget.getSelectedNode().images[0];
@ -2759,21 +2745,17 @@ app.classes.mail = AppJS.extend(
{ {
if (_typeID && _data) 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(); request.sendRequest();
} }
}, },
/** /**
*
* Send ajax request to server to refresh the sieve grid * Send ajax request to server to refresh the sieve grid
*
*
*/ */
sieve_refresh: function() 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); this.et2._inst.submit();
request.sendRequest();
}, },
/** /**
@ -2786,7 +2768,9 @@ app.classes.mail = AppJS.extend(
acl_common_rights_selector: function(event,widget) acl_common_rights_selector: function(event,widget)
{ {
var rowId = widget.id.replace(/[^0-9.]+/g, ''); 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++) for (var i=0;i<this.aclRights.length;i++)
{ {
var rightsWidget = this.et2.getWidgetById(rowId+'[acl_' + this.aclRights[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) edit_sieve: function(_action, _senders)
{ {
var acc_id = parseInt(_senders[0].id); 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', 'menuaction': 'mail.mail_sieve.index',
'acc_id': acc_id, 'acc_id': acc_id,
'ajax': 'true' '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)
{
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> </box>
</vbox> </vbox>
</split> </split>
<iframe frameborder="1" height="100%" id="extra_iframe" scrolling="auto" width="100%" disabled="true"/>
</template> </template>
</overlay> </overlay>