| | |
| | | rcmail.add_element(tab, 'tabs'); |
| | | } |
| | | |
| | | if (rcmail.env.task == 'mail' || rcmail.env.action.indexOf('plugin.managesieve') != -1) { |
| | | if (rcmail.env.task == 'mail' || rcmail.env.action.startsWith('plugin.managesieve')) { |
| | | // Create layer for form tips |
| | | if (!rcmail.env.framed) { |
| | | rcmail.env.ms_tip_layer = $('<div id="managesieve-tip" class="popupmenu"></div>'); |
| | |
| | | rcmail.register_command('plugin.managesieve-setact', function() { rcmail.managesieve_setact() }); |
| | | rcmail.register_command('plugin.managesieve-setget', function() { rcmail.managesieve_setget() }); |
| | | |
| | | if (rcmail.env.action == 'plugin.managesieve' || rcmail.env.action == 'plugin.managesieve-save') { |
| | | if (rcmail.env.action.startsWith('plugin.managesieve')) { |
| | | if (rcmail.gui_objects.sieveform) { |
| | | rcmail.enable_command('plugin.managesieve-save', true); |
| | | |
| | |
| | | var id = this.filters_list.get_single_selection(); |
| | | if (confirm(this.get_label('managesieve.filterdeleteconfirm'))) { |
| | | var lock = this.set_busy(true, 'loading'); |
| | | this.http_post('plugin.managesieve', |
| | | this.http_post('plugin.managesieve-action', |
| | | '_act=delete&_fid='+this.filters_list.rows[id].uid, lock); |
| | | } |
| | | }; |
| | |
| | | var id = this.filters_list.get_single_selection(), |
| | | lock = this.set_busy(true, 'loading'); |
| | | |
| | | this.http_post('plugin.managesieve', |
| | | this.http_post('plugin.managesieve-action', |
| | | '_act=act&_fid='+this.filters_list.rows[id].uid, lock); |
| | | }; |
| | | |
| | |
| | | this.show_contentframe(false); |
| | | this.filters_list.clear(true); |
| | | this.enable_command('plugin.managesieve-setdel', list.rowcount > 1); |
| | | this.enable_command( 'plugin.managesieve-setact', 'plugin.managesieve-setget', true); |
| | | this.enable_command('plugin.managesieve-setact', 'plugin.managesieve-setget', true); |
| | | |
| | | var id = list.get_single_selection(); |
| | | if (id != null) |
| | |
| | | { |
| | | var i, rows = this.filters_list.rows; |
| | | |
| | | for (i=0; i<rows.length; i++) |
| | | for (i in rows) |
| | | if (rows[i] != null && rows[i].uid == id) |
| | | return i; |
| | | }; |
| | |
| | | { |
| | | var lock = this.set_busy(true, 'loading'); |
| | | |
| | | this.http_post('plugin.managesieve', '_act=list&_set='+urlencode(script), lock); |
| | | this.http_post('plugin.managesieve-action', '_act=list&_set='+urlencode(script), lock); |
| | | }; |
| | | |
| | | // Script download request |
| | |
| | | var id = this.filtersets_list.get_single_selection(), |
| | | script = this.env.filtersets[id]; |
| | | |
| | | location.href = this.env.comm_path+'&_action=plugin.managesieve&_act=setget&_set='+urlencode(script); |
| | | location.href = this.env.comm_path+'&_action=plugin.managesieve-action&_act=setget&_set='+urlencode(script); |
| | | }; |
| | | |
| | | // Set activate/deactivate request |
| | |
| | | script = this.env.filtersets[id], |
| | | action = $('#rcmrow'+id).hasClass('disabled') ? 'setact' : 'deact'; |
| | | |
| | | this.http_post('plugin.managesieve', '_act='+action+'&_set='+urlencode(script), lock); |
| | | this.http_post('plugin.managesieve-action', '_act='+action+'&_set='+urlencode(script), lock); |
| | | }; |
| | | |
| | | // Set delete request |
| | |
| | | lock = this.set_busy(true, 'loading'), |
| | | script = this.env.filtersets[id]; |
| | | |
| | | this.http_post('plugin.managesieve', '_act=setdel&_set='+urlencode(script), lock); |
| | | this.http_post('plugin.managesieve-action', '_act=setdel&_set='+urlencode(script), lock); |
| | | }; |
| | | |
| | | // Set add request |
| | |
| | | if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { |
| | | var lock = this.set_busy(true, 'loading'); |
| | | target = window.frames[this.env.contentframe]; |
| | | target.location.href = this.env.comm_path+'&_action=plugin.managesieve&_framed=1&_newset=1&_unlock='+lock; |
| | | target.location.href = this.env.comm_path+'&_action=plugin.managesieve-action&_framed=1&_newset=1&_unlock='+lock; |
| | | } |
| | | }; |
| | | |
| | |
| | | var i, row = $('#rcmrow'+this.managesieve_rowid(o.id)); |
| | | |
| | | if (o.name) |
| | | $('td', row).html(o.name); |
| | | $('td', row).text(o.name); |
| | | if (o.disabled) |
| | | row.addClass('disabled'); |
| | | else |
| | |
| | | var list = this.filters_list, |
| | | row = $('<tr><td class="name"></td></tr>'); |
| | | |
| | | $('td', row).html(o.name); |
| | | $('td', row).text(o.name); |
| | | row.attr('id', 'rcmrow'+o.id); |
| | | if (o.disabled) |
| | | row.addClass('disabled'); |
| | |
| | | tr = document.createElement('TR'); |
| | | td = document.createElement('TD'); |
| | | |
| | | td.innerHTML = el.name; |
| | | $(td).text(el.name); |
| | | td.className = 'name'; |
| | | tr.id = 'rcmrow' + el.id; |
| | | if (el['class']) |
| | |
| | | list = this.filtersets_list, |
| | | row = $('<tr class="disabled"><td class="name"></td></tr>'); |
| | | |
| | | $('td', row).html(o.name); |
| | | $('td', row).text(o.name); |
| | | row.attr('id', 'rcmrow'+id); |
| | | |
| | | this.env.filtersets[id] = o.name; |
| | |
| | | if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { |
| | | target = window.frames[this.env.contentframe]; |
| | | var msgid = this.set_busy(true, 'loading'); |
| | | target.location.href = this.env.comm_path+'&_action=plugin.managesieve&_framed=1' |
| | | target.location.href = this.env.comm_path+'&_action=plugin.managesieve-action&_framed=1' |
| | | +(has_id ? '&_fid='+id : '')+'&_unlock='+msgid; |
| | | } |
| | | }; |
| | |
| | | var lock = this.set_busy(true, 'loading'); |
| | | |
| | | this.show_contentframe(false); |
| | | this.http_post('plugin.managesieve', '_act=move&_fid='+this.drag_filter |
| | | this.http_post('plugin.managesieve-action', '_act=move&_fid='+this.drag_filter |
| | | +'&_to='+this.drag_filter_target, lock); |
| | | } |
| | | this.drag_active = false; |
| | |
| | | // Operations on filters form |
| | | rcube_webmail.prototype.managesieve_ruleadd = function(id) |
| | | { |
| | | this.http_post('plugin.managesieve', '_act=ruleadd&_rid='+id); |
| | | this.http_post('plugin.managesieve-action', '_act=ruleadd&_rid='+id); |
| | | }; |
| | | |
| | | rcube_webmail.prototype.managesieve_rulefill = function(content, id, after) |
| | |
| | | |
| | | rcube_webmail.prototype.managesieve_actionadd = function(id) |
| | | { |
| | | this.http_post('plugin.managesieve', '_act=actionadd&_aid='+id); |
| | | this.http_post('plugin.managesieve-action', '_act=actionadd&_aid='+id); |
| | | }; |
| | | |
| | | rcube_webmail.prototype.managesieve_actionfill = function(content, id, after) |
| | |
| | | var obj = document.getElementById('header' + id), |
| | | size = document.getElementById('rule_size' + id), |
| | | op = document.getElementById('rule_op' + id), |
| | | header = document.getElementById('custom_header' + id), |
| | | header = document.getElementById('custom_header' + id + '_list'), |
| | | mod = document.getElementById('rule_mod' + id), |
| | | trans = document.getElementById('rule_trans' + id), |
| | | comp = document.getElementById('rule_comp' + id); |
| | | comp = document.getElementById('rule_comp' + id), |
| | | datepart = document.getElementById('rule_date_part' + id), |
| | | dateheader = document.getElementById('rule_date_header_div' + id), |
| | | h = obj.value; |
| | | |
| | | if (obj.value == 'size') { |
| | | if (h == 'size') { |
| | | size.style.display = 'inline'; |
| | | op.style.display = 'none'; |
| | | header.style.display = 'none'; |
| | | mod.style.display = 'none'; |
| | | trans.style.display = 'none'; |
| | | comp.style.display = 'none'; |
| | | $.each([op, header, mod, trans, comp], function() { this.style.display = 'none'; }); |
| | | } |
| | | else { |
| | | header.style.display = obj.value != '...' ? 'none' : 'inline-block'; |
| | | header.style.display = h != '...' ? 'none' : 'inline-block'; |
| | | size.style.display = 'none'; |
| | | op.style.display = 'inline'; |
| | | comp.style.display = ''; |
| | | mod.style.display = obj.value == 'body' ? 'none' : 'block'; |
| | | trans.style.display = obj.value == 'body' ? 'block' : 'none'; |
| | | mod.style.display = h == 'body' || h == 'currentdate' || h == 'date' ? 'none' : 'block'; |
| | | trans.style.display = h == 'body' ? 'block' : 'none'; |
| | | } |
| | | |
| | | rule_op_select(op, id, obj.value); |
| | | obj.style.width = obj.value == '...' ? '40px' : ''; |
| | | if (datepart) |
| | | datepart.style.display = h == 'currentdate' || h == 'date' ? 'inline' : 'none'; |
| | | if (dateheader) |
| | | dateheader.style.display = h == 'date' ? '' : 'none'; |
| | | |
| | | rule_op_select(op, id, h); |
| | | rule_mod_select(id, h); |
| | | obj.style.width = h == '...' ? '40px' : ''; |
| | | }; |
| | | |
| | | function rule_op_select(obj, id, header) |
| | | { |
| | | var target = document.getElementById('rule_target' + id + '_list'), |
| | | style = obj.value == 'exists' || obj.value == 'notexists' || header == 'size' ? 'none' : 'inline-block'; |
| | | var target = document.getElementById('rule_target' + id + '_list'); |
| | | |
| | | target.style.display = style; |
| | | if (!header) |
| | | header = document.getElementById('header' + id).value; |
| | | |
| | | target.style.display = obj.value == 'exists' || obj.value == 'notexists' || header == 'size' ? 'none' : 'inline-block'; |
| | | }; |
| | | |
| | | function rule_trans_select(id) |
| | |
| | | target.style.display = obj.value != 'content' ? 'none' : 'inline'; |
| | | }; |
| | | |
| | | function rule_mod_select(id) |
| | | function rule_mod_select(id, header) |
| | | { |
| | | var obj = document.getElementById('rule_mod_op' + id), |
| | | target = document.getElementById('rule_mod_type' + id); |
| | | target = document.getElementById('rule_mod_type' + id), |
| | | index = document.getElementById('rule_index_div' + id); |
| | | |
| | | if (!header) |
| | | header = document.getElementById('header' + id).value; |
| | | |
| | | target.style.display = obj.value != 'address' && obj.value != 'envelope' ? 'none' : 'inline'; |
| | | |
| | | if (index) |
| | | index.style.display = header != 'body' && header != 'currentdate' && header != 'size' && obj.value != 'envelope' ? '' : 'none'; |
| | | }; |
| | | |
| | | function rule_join_radio(value) |
| | |
| | | function action_type_select(id) |
| | | { |
| | | var obj = document.getElementById('action_type' + id), |
| | | enabled = {}, |
| | | v = obj.value, enabled = {}, |
| | | elems = { |
| | | mailbox: document.getElementById('action_mailbox' + id), |
| | | target: document.getElementById('action_target' + id), |
| | | target: document.getElementById('redirect_target' + id), |
| | | target_area: document.getElementById('action_target_area' + id), |
| | | flags: document.getElementById('action_flags' + id), |
| | | vacation: document.getElementById('action_vacation' + id), |
| | |
| | | notify: document.getElementById('action_notify' + id) |
| | | }; |
| | | |
| | | if (obj.value == 'fileinto' || obj.value == 'fileinto_copy') { |
| | | if (v == 'fileinto' || v == 'fileinto_copy') { |
| | | enabled.mailbox = 1; |
| | | } |
| | | else if (obj.value == 'redirect' || obj.value == 'redirect_copy') { |
| | | else if (v == 'redirect' || v == 'redirect_copy') { |
| | | enabled.target = 1; |
| | | } |
| | | else if (obj.value.match(/^reject|ereject$/)) { |
| | | else if (v.match(/^reject|ereject$/)) { |
| | | enabled.target_area = 1; |
| | | } |
| | | else if (obj.value.match(/^(add|set|remove)flag$/)) { |
| | | else if (v.match(/^(add|set|remove)flag$/)) { |
| | | enabled.flags = 1; |
| | | } |
| | | else if (obj.value == 'vacation') { |
| | | else if (v == 'vacation') { |
| | | enabled.vacation = 1; |
| | | } |
| | | else if (obj.value == 'set') { |
| | | else if (v == 'set') { |
| | | enabled.set = 1; |
| | | } |
| | | else if (obj.value == 'notify') { |
| | | else if (v == 'notify') { |
| | | enabled.notify = 1; |
| | | } |
| | | |
| | |
| | | { |
| | | // build row element content |
| | | var input, content = '<span class="listelement">' |
| | | + '<span class="actions"><span class="add"></span><span class="reset"></span></span>' |
| | | + '<input type="text"></span>', |
| | | + '<span class="reset"></span><input type="text"></span>', |
| | | elem = $(content), |
| | | attrs = {value: value, name: name + '[]'}; |
| | | |
| | | if (size) |
| | | attrs.size = size; |
| | | |
| | | input = $('input', elem).attr(attrs) |
| | | .keydown(function(e) { if (e.which == 13) $('span[class="add"]', elem).click(); }); |
| | | input = $('input', elem).attr(attrs).keydown(function(e) { |
| | | var input = $(this); |
| | | // element creation event (on Enter) |
| | | if (e.which == 13) { |
| | | var name = input.attr('name').replace(/\[\]$/, ''), |
| | | dt = (new Date()).getTime(), |
| | | elem = smart_field_row('', name, dt, size); |
| | | |
| | | // element creation event |
| | | $('span[class="add"]', elem).click(function() { |
| | | var span = $(this.parentNode.parentNode), |
| | | input = $('input', span), |
| | | name = input.attr('name').replace(/\[\]$/, ''), |
| | | dt = (new Date()).getTime(), |
| | | elem = smart_field_row('', name, dt, size); |
| | | |
| | | span.after(elem); |
| | | $('input', elem).focus(); |
| | | input.parent().after(elem); |
| | | $('input', elem).focus(); |
| | | } |
| | | }); |
| | | |
| | | // element deletion event |
| | | $('span[class="reset"]', elem).click(function() { |
| | | var span = $(this.parentNode.parentNode); |
| | | var span = $(this.parentNode); |
| | | |
| | | if (span.parent().children().length > 1) |
| | | span.remove(); |