[6487] | 1 | /* |
---|
| 2 | * Retorna as regras por remetente e que o usuário deseja ser avisado |
---|
| 3 | */ |
---|
| 4 | function getFromAlertRules() { |
---|
| 5 | var filters = DataLayer.get("filter"); |
---|
| 6 | fromRules = []; |
---|
| 7 | var alertMessage; |
---|
| 8 | var active; |
---|
| 9 | for (var index in filters) { |
---|
| 10 | alertMessage = filters[index]['alertMessage']; |
---|
| 11 | active = filters[index]['enabled']; |
---|
| 12 | for(var criterias in filters[index]['actions']) { |
---|
| 13 | if (filters[index]['actions'][criterias]['type'] == 'fileinto' && alertMessage == 'true' && active == 'true') |
---|
| 14 | fromRules[fromRules.length] = filters[index]['actions'][criterias]['parameter']; |
---|
| 15 | } |
---|
| 16 | } |
---|
| 17 | return fromRules; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | /* |
---|
| 21 | * Verifica se a regra Fora de escritório está ativa |
---|
| 22 | */ |
---|
| 23 | function outOfficeVerify() { |
---|
[5950] | 24 | DataLayer.remove('filter', false); |
---|
| 25 | var filters = DataLayer.get("filter"); |
---|
| 26 | var outoffice_active = false; |
---|
[6021] | 27 | outoffice = false; |
---|
[5950] | 28 | for(var index in filters){ |
---|
| 29 | if(filters[index].id == "vacation") |
---|
| 30 | outoffice = true; |
---|
| 31 | if(filters[index].id == "vacation" && filters[index].enabled == "true"){ |
---|
[6452] | 32 | write_msg(get_lang("Attention, you are in out of office mode."), true); |
---|
[5950] | 33 | outoffice_active = true; |
---|
| 34 | break; |
---|
| 35 | } |
---|
| 36 | } |
---|
[6021] | 37 | if(!outoffice_active) |
---|
| 38 | clean_msg(); |
---|
[5950] | 39 | } |
---|
| 40 | |
---|
[6487] | 41 | /* |
---|
| 42 | * Valida os campos do formulário da tela de filtros para salvar. |
---|
| 43 | */ |
---|
[5591] | 44 | valid_save = function(){ |
---|
[5662] | 45 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
[5598] | 46 | if(list_container.find('[name="name"]').attr("disabled") != "disabled") |
---|
[5591] | 47 | { |
---|
[5598] | 48 | if($.trim(list_container.find('[name="name"]').val()) == ""){ |
---|
[5801] | 49 | $.Zebra_Dialog(get_lang("No name filled"),{ |
---|
[5662] | 50 | 'onClose': function(caption) { |
---|
| 51 | list_container.find('[name="name"]').focus(); |
---|
| 52 | } |
---|
| 53 | }); |
---|
| 54 | accord.accordion('activate',0); |
---|
[5591] | 55 | return false; |
---|
[5598] | 56 | }else if($.trim(list_container.find('[name="name"]').val()) == "vacation"){ |
---|
[5801] | 57 | $.Zebra_Dialog(get_lang("Invalid name, 'vacation' is a reserved word"),{ |
---|
[5662] | 58 | 'onClose': function(caption) { |
---|
| 59 | list_container.find('[name="name"]').val("").focus(); |
---|
| 60 | } |
---|
| 61 | }); |
---|
| 62 | accord.accordion('activate',0); |
---|
[5591] | 63 | return false; |
---|
| 64 | }else{ |
---|
| 65 | filter_list = DataLayer.get("filter", true); |
---|
| 66 | var error = false; |
---|
| 67 | $.each(filter_list, function(index, value){ |
---|
[5598] | 68 | if(filter_list[index].name == list_container.find('[name="name"]').val()){ |
---|
[5801] | 69 | $.Zebra_Dialog(get_lang("There is already a filter with this name"),{ |
---|
[5662] | 70 | 'onClose': function(caption) { |
---|
| 71 | list_container.find('[name="name"]').val("").focus(); |
---|
| 72 | } |
---|
| 73 | }); |
---|
| 74 | accord.accordion('activate',0); |
---|
[5591] | 75 | error = true; |
---|
| 76 | return; |
---|
[6452] | 77 | } |
---|
[5591] | 78 | }); |
---|
| 79 | if(error){ |
---|
| 80 | return false; |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | var criteria = ""; |
---|
[5598] | 85 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
[6126] | 86 | var er_num = /^[0-9]+$/; |
---|
[6452] | 87 | |
---|
[6126] | 88 | if($(".sizeRule").val() != "" && er_num.test($(".sizeRule").val()) == false) { |
---|
| 89 | $.Zebra_Dialog(get_lang("Size rule must be a number"),{ |
---|
| 90 | 'onClose': function(caption) { |
---|
| 91 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 92 | } |
---|
| 93 | }); |
---|
| 94 | accord.accordion('activate',0); |
---|
| 95 | return false; |
---|
| 96 | } |
---|
[5591] | 97 | $.each(criteria_list, function(index, value){ |
---|
| 98 | criteria += $.trim($(criteria_list[index]).val()); |
---|
| 99 | }); |
---|
[6144] | 100 | if(criteria == ""){ |
---|
[5801] | 101 | $.Zebra_Dialog(get_lang("No criteria filled"),{ |
---|
[5662] | 102 | 'onClose': function(caption) { |
---|
| 103 | list_container.find('[name="criteriaValue[]"]:first').focus(); |
---|
| 104 | } |
---|
| 105 | }); |
---|
| 106 | accord.accordion('activate',0); |
---|
[5591] | 107 | return false; |
---|
| 108 | } |
---|
[5598] | 109 | if(list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").length){ |
---|
| 110 | if($.trim(list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").val()) == ""){ |
---|
[5801] | 111 | $.Zebra_Dialog(get_lang("Fill the action value"),{ |
---|
[5662] | 112 | 'onClose': function(caption) { |
---|
| 113 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 114 | } |
---|
| 115 | }); |
---|
[5591] | 116 | return false; |
---|
| 117 | } |
---|
[6126] | 118 | var er_mail = RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/); |
---|
[6392] | 119 | if(er_mail.test($.trim(list_container.find('[value="redirect"]:checked').parent().find("input:text").val())) == false && list_container.find('[name="actionType[]"]:checked').val() == 'redirect'){ |
---|
[6126] | 120 | $.Zebra_Dialog(get_lang("Invalid mail"),{ |
---|
| 121 | 'onClose': function(caption) { |
---|
| 122 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 123 | } |
---|
| 124 | }); |
---|
| 125 | return false; |
---|
| 126 | } |
---|
[5591] | 127 | } |
---|
[6487] | 128 | var criteria_operator_list = list_container.find('[name="criteriaOperator[]"]'); |
---|
| 129 | if(list_container.find('.alertMessage').is(':checked')){ |
---|
| 130 | if($(criteria_list[0]).val() != "" && $('.select-folderlist').find('[type="radio"]').is(':checked') && $(criteria_operator_list[0]).find('option:selected').val() != "!*"){ |
---|
| 131 | var hasValue = false; |
---|
| 132 | $.each(criteria_list, function(index, value){ |
---|
| 133 | if(($(criteria_list[index]).val() != "" && index != 0 && index != 5) || ($(criteria_list[index]).is(':checked'))){ |
---|
| 134 | if($('.fields-isexact').find(':checked').val() == 'or'){ |
---|
| 135 | hasValue = true; |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | }); |
---|
| 139 | if(hasValue){ |
---|
[6488] | 140 | $.Zebra_Dialog('<strong>'+get_lang('Filter with alert')+'</strong><br>'+get_lang('If more than one criterion for the filter, the "Meeting all the criteria" must be selected')); |
---|
[6487] | 141 | return false; |
---|
| 142 | } |
---|
| 143 | }else{ |
---|
[6488] | 144 | $.Zebra_Dialog('<strong>'+get_lang('Filter with alert')+'</strong><br>'+get_lang('The filter should be set as a criteria "Sender" and action "Archive folder"')); |
---|
[6487] | 145 | return false; |
---|
| 146 | } |
---|
| 147 | } |
---|
[5591] | 148 | return true; |
---|
| 149 | }; |
---|
| 150 | |
---|
[6392] | 151 | function urlencode (str) { |
---|
| 152 | str = (str + '').toString(); |
---|
| 153 | return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28'). |
---|
| 154 | replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+'); |
---|
| 155 | } |
---|
| 156 | |
---|
[5341] | 157 | bytes2Size = function(bytes) { |
---|
| 158 | var sizes = ['B', 'KB', 'MB', 'GB', 'TB']; |
---|
| 159 | if (bytes === 0) return 'n/a'; |
---|
| 160 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); |
---|
| 161 | var size = (i<2) ? Math.round((bytes / Math.pow(1024, i))) : Math.round((bytes / Math.pow(1024, i)) * 100)/100; |
---|
| 162 | return size + ' ' + sizes[i]; |
---|
| 163 | }; |
---|
| 164 | |
---|
| 165 | flags2Class = function(cellvalue) { |
---|
| 166 | var flags_enum = cellvalue.split(','); |
---|
| 167 | var classes = ''; |
---|
| 168 | for (var i=0; i<flags_enum.length; i++){ |
---|
| 169 | classes += '<span class="icon-'+flags_enum[i].toLowerCase()+'"> </span>'; |
---|
| 170 | } |
---|
| 171 | return classes; |
---|
| 172 | }; |
---|
| 173 | |
---|
| 174 | date2Time = function (timestamp) { |
---|
| 175 | var date = new Date(); |
---|
[6452] | 176 | if( typeof timestamp === "string" ) |
---|
| 177 | timestamp = parseInt( timestamp, 10 ); |
---|
[5341] | 178 | if ((date.getTime() - timestamp) < (24*60*60*1000)) { |
---|
| 179 | return '<span class="timable" title="'+timestamp+'"> </span>'; |
---|
| 180 | } else { |
---|
| 181 | date = new Date(timestamp); |
---|
| 182 | var b = date.toISOString().split("T")[0].split("-"); |
---|
| 183 | var c = b[2] + "/" + b[1] + "/" + b[0]; |
---|
| 184 | return '<span class="datable">' + c + '</span>'; |
---|
| 185 | } |
---|
| 186 | }; |
---|
| 187 | |
---|
| 188 | keys = function( object ){ |
---|
[6452] | 189 | |
---|
[5341] | 190 | var array = []; |
---|
[6452] | 191 | |
---|
[5341] | 192 | for( var key in object ) |
---|
| 193 | array[ array.length ] = key; |
---|
[6452] | 194 | |
---|
[5341] | 195 | return( array ); |
---|
| 196 | |
---|
| 197 | } |
---|
| 198 | |
---|
[6487] | 199 | /* |
---|
| 200 | * Preenche o formulário de filtros com as informações originais para edição |
---|
| 201 | */ |
---|
[5341] | 202 | showDetails = function( filter ){ |
---|
[6452] | 203 | |
---|
[5341] | 204 | form.get(0).reset(); |
---|
| 205 | |
---|
| 206 | nameObj.val( filter.name ); |
---|
[5539] | 207 | nameObj.attr("disabled", "disabled"); |
---|
[5341] | 208 | for( var i = 0; i < filter.criteria.length; i++ ){ |
---|
[6348] | 209 | if(filter.criteria[i].field == 'hasAttachment') { |
---|
| 210 | $(".hasAttachment").attr("checked", "True"); |
---|
| 211 | continue; |
---|
| 212 | } |
---|
[5630] | 213 | criterias.filter( '[value="' + filter.criteria[i].field + '"]' ) |
---|
| 214 | .siblings( '[name="criteriaOperator[]"]' ).val( filter.criteria[i].operator ).end() |
---|
| 215 | .siblings( '[name="criteriaValue[]"]' ).val( filter.criteria[i].value ); |
---|
[5341] | 216 | } |
---|
| 217 | for( var i = 0; i < filter.actions.length; i++ ){ |
---|
[5539] | 218 | actions.filter( '[value="' + filter.actions[i].type + '"]' ).attr("checked", "True"); |
---|
| 219 | actions.filter( '[value="' + filter.actions[i].type + '"]' ).val( filter.actions[i].type ) |
---|
| 220 | .siblings( '[name="actionParameter[]"]' ).val( filter.actions[i].parameter ); |
---|
| 221 | if(filter.actions[i].type == "redirect") |
---|
| 222 | actions.siblings('[name="addressRedirect"]').val(filter.actions[i].parameter); |
---|
[6452] | 223 | if(filter.actions[i].type == "reject") |
---|
[5539] | 224 | actions.siblings('[name="messageReject"]').val(filter.actions[i].parameter); |
---|
[5632] | 225 | if(filter.actions[i].type == "fileinto" || filter.actions[i].type == "setflag") |
---|
| 226 | actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected"); |
---|
[5341] | 227 | } |
---|
[6452] | 228 | isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True"); |
---|
[6487] | 229 | |
---|
| 230 | if (filter.alertMessage == 'true') $('.alertMessage').attr('checked', 'True'); |
---|
[5341] | 231 | } |
---|
| 232 | |
---|
| 233 | |
---|
| 234 | DataLayer.codec( "filter", "detail", { |
---|
[6452] | 235 | |
---|
[5341] | 236 | decoder: function( form ){ |
---|
[6487] | 237 | if( form.vacation ) |
---|
[5341] | 238 | return { |
---|
[5539] | 239 | criteria: [{ value: "vacation", operator: "", field: "vacation" }], |
---|
| 240 | actions: [{ parameter: form.vacation, type: "vacation" }], |
---|
[5341] | 241 | id: "vacation", |
---|
| 242 | name: "vacation", |
---|
[5627] | 243 | isExact: false, |
---|
| 244 | applyMessages : "", |
---|
[5902] | 245 | enabled : true |
---|
[5341] | 246 | } |
---|
| 247 | |
---|
[6143] | 248 | var apply_messages_ = keys(selectedMessages); |
---|
[6452] | 249 | |
---|
[6392] | 250 | action = ''; |
---|
[6452] | 251 | |
---|
[6143] | 252 | return { |
---|
[6168] | 253 | name: form.name ? form.name.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') : nameObj.val().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), |
---|
[5341] | 254 | isExact: ( form.isExact === "and" ), |
---|
[6452] | 255 | criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){ |
---|
[5341] | 256 | return (!form.criteriaValue[i]) ? null: |
---|
[6452] | 257 | { |
---|
[6168] | 258 | value: form.criteriaValue[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), |
---|
[6143] | 259 | operator: criteriaOperator, |
---|
[6168] | 260 | field: form.criteriaType[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') |
---|
[6143] | 261 | }; |
---|
[5341] | 262 | }), |
---|
| 263 | actions: $.map( form.actionType || [], function( type, i ){ |
---|
[5539] | 264 | var the_parameter = form.actionParameter[i]; |
---|
[6452] | 265 | |
---|
[5539] | 266 | !the_parameter ? the_parameter = form.actionParameter[i+1] : ""; |
---|
[6487] | 267 | |
---|
| 268 | if (type == 'alertMessage') { |
---|
| 269 | //if(!$('[value="alertMessage"]').parent().hasClass("hidden")){ |
---|
| 270 | type = 'addflag'; |
---|
| 271 | the_parameter = '$FilteredMessage'; |
---|
| 272 | //}else{ |
---|
| 273 | // return; |
---|
| 274 | //} |
---|
| 275 | } |
---|
| 276 | if (type == 'fileinto') { |
---|
[5539] | 277 | the_parameter = form.valueFileInto; |
---|
| 278 | } |
---|
| 279 | if (type == 'reject') { |
---|
| 280 | the_parameter = form.messageReject; |
---|
| 281 | } |
---|
[6452] | 282 | if (type == 'fileintoInbox') { |
---|
[5591] | 283 | if(!$('[value="fileintoInbox"]').parent().hasClass("hidden")){ |
---|
| 284 | type = 'fileinto'; |
---|
| 285 | the_parameter = 'INBOX'; |
---|
| 286 | }else{ |
---|
| 287 | return; |
---|
| 288 | } |
---|
[5539] | 289 | } |
---|
| 290 | if (type == 'fileintoTrash') { |
---|
| 291 | type = 'fileinto'; |
---|
[6363] | 292 | the_parameter = 'INBOX' + cyrus_delimiter + 'Trash'; |
---|
[5539] | 293 | } |
---|
| 294 | if (type == 'redirect') { |
---|
| 295 | the_parameter = form.addressRedirect; |
---|
| 296 | } |
---|
[6452] | 297 | if (type == 'setflag') { |
---|
[5539] | 298 | the_parameter = form.valueSetFlag; |
---|
[6392] | 299 | action = form.valueSetFlag; |
---|
[5539] | 300 | } |
---|
[5341] | 301 | return (!type) ? null: |
---|
[5539] | 302 | {parameter: the_parameter, type: type }; |
---|
[5341] | 303 | |
---|
| 304 | }), |
---|
[5902] | 305 | enabled : true, |
---|
[6487] | 306 | alertMessage: $('.alertMessage').is(':checked'), |
---|
| 307 | //applyMessages: allMessages? !$.isEmptyObject( selectedMessages ) ? |
---|
| 308 | //keys( selectedMessages ) : allMessages : "" |
---|
| 309 | applyMessages: apply_messages_ |
---|
| 310 | //applyMessages: "" |
---|
[6143] | 311 | }; |
---|
[5341] | 312 | }, |
---|
[6452] | 313 | |
---|
[5341] | 314 | encoder: function( filters ){ |
---|
| 315 | var rules = []; |
---|
| 316 | |
---|
| 317 | for( var id in filters ) |
---|
| 318 | rules[ rules.length ] = filters[id]; |
---|
| 319 | |
---|
| 320 | return { rules: rules }; |
---|
| 321 | |
---|
| 322 | } |
---|
[6452] | 323 | |
---|
[5341] | 324 | }); |
---|
| 325 | |
---|
[6392] | 326 | /* Codec do datalayer */ |
---|
[5341] | 327 | DataLayer.codec( "folder", "select", { |
---|
[6452] | 328 | |
---|
[5341] | 329 | decoder:function(){ |
---|
[6452] | 330 | |
---|
[5341] | 331 | }, |
---|
| 332 | encoder:function( data ){ |
---|
[6452] | 333 | |
---|
[5341] | 334 | var tree1 = [], tree2 = [], tree3 = []; |
---|
| 335 | |
---|
| 336 | for (var i=0; i<data.length; i++) { |
---|
| 337 | |
---|
| 338 | if (/^INBOX/.test(data[i].id)) { |
---|
| 339 | if (!unorphanize(tree1, data[i])) { |
---|
| 340 | data[i].children = []; |
---|
| 341 | tree1.push(data[i]); |
---|
| 342 | } |
---|
| 343 | } |
---|
| 344 | else if (/^user/.test(data[i].id)) { |
---|
| 345 | if (!unorphanize(tree2, data[i])) { |
---|
| 346 | data[i].children = []; |
---|
| 347 | tree2.push(data[i]); |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | else if (/^local_messages/.test(data[i].id)) { |
---|
| 351 | if (!unorphanize(tree3, data[i])) { |
---|
| 352 | data[i].children = []; |
---|
| 353 | tree3.push(data[i]); |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | } |
---|
[6452] | 358 | |
---|
[5341] | 359 | return {folders: [ tree1, tree2, tree3 ]}; |
---|
| 360 | |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | }); |
---|
| 364 | |
---|
[6487] | 365 | |
---|
| 366 | fromRules = getFromAlertRules(); |
---|
| 367 | |
---|
[5341] | 368 | var BASE_PATH = '../prototype/'; |
---|
| 369 | |
---|
| 370 | DataLayer.basePath = BASE_PATH + "REST.php?q="; |
---|
| 371 | DataLayer.dispatchPath = BASE_PATH; |
---|
| 372 | |
---|
| 373 | var selectedMessages = {}; |
---|
| 374 | var allMessages = false; |
---|
| 375 | |
---|
[6487] | 376 | /* |
---|
| 377 | * Bloqueia usuário por email - utilizado na tela de mensagens do ExpressoMail |
---|
| 378 | */ |
---|
[6452] | 379 | function block_user_email(email) { |
---|
[6392] | 380 | delete selectedMessages; |
---|
| 381 | var idd = urlencode(email); |
---|
[5762] | 382 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 383 | DataLayer.remove('filter', false); |
---|
| 384 | var filters = DataLayer.get('filter'); |
---|
[5654] | 385 | for(var index in filters){ |
---|
| 386 | if(filters[index].name == email) { |
---|
[5801] | 387 | if(confirm(get_lang("This user is already blocked. Would you like to unlock it?"))) { |
---|
[5655] | 388 | DataLayer.remove( 'filter', filters[index].id ); |
---|
[5762] | 389 | DataLayer.commit("filter", false, function(){ |
---|
[5801] | 390 | $.Zebra_Dialog(get_lang("Lock User") + " " + email + " " + get_lang("removed")); |
---|
[5762] | 391 | list_filters(); |
---|
[6487] | 392 | getFromAlertRules(); |
---|
[5762] | 393 | }); |
---|
[5654] | 394 | return true; |
---|
[5662] | 395 | }else |
---|
| 396 | return true; |
---|
[5654] | 397 | } |
---|
| 398 | } |
---|
[5801] | 399 | if(confirm(get_lang("Want to block the user") + " " + email + "?")){ |
---|
[6452] | 400 | DataLayer.put( 'filter', idd, |
---|
| 401 | { name: email, isExact: false, |
---|
[5630] | 402 | criteria:{ 0: {value: email, operator: "=", field: "from"} }, |
---|
[6452] | 403 | actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}}, |
---|
| 404 | enabled: true, |
---|
[5630] | 405 | id: email, |
---|
[6452] | 406 | block: true |
---|
[5630] | 407 | }); |
---|
[5762] | 408 | DataLayer.commit("filter", false, function(){ |
---|
[5801] | 409 | $.Zebra_Dialog(get_lang("User") + " " + email + " " + get_lang("blocked")); |
---|
[5762] | 410 | list_filters(); |
---|
[6487] | 411 | getFromAlertRules(); |
---|
[5762] | 412 | }); |
---|
[6452] | 413 | |
---|
[5762] | 414 | } |
---|
[5630] | 415 | } |
---|
| 416 | |
---|
[6443] | 417 | |
---|
| 418 | DataLayer.codec( 'message', 'jqGrid', { |
---|
[6452] | 419 | |
---|
[6443] | 420 | encoder: function( data ){ |
---|
| 421 | |
---|
| 422 | return( data ); |
---|
| 423 | |
---|
| 424 | } |
---|
| 425 | }); |
---|
| 426 | |
---|
[6487] | 427 | /* Gerencia o grid das mensagens da caixa de entrada |
---|
| 428 | * Mostra o grid de mensagens para aplicar a regra nas mensagens da caixa de entrada. |
---|
| 429 | */ |
---|
[6048] | 430 | function showGridMessages(thiss) { |
---|
| 431 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
| 432 | var criteria_operator_list = list_container.find('[name="criteriaOperator[]"]'); |
---|
| 433 | var criteria_value = ""; |
---|
| 434 | var criteria = ""; |
---|
| 435 | $.each(criteria_list, function(index, value){ |
---|
| 436 | criteria += $.trim($(criteria_list[index]).val()) + ","; |
---|
| 437 | }); |
---|
| 438 | var criteria_ = criteria.split(","); |
---|
| 439 | var criteria_operator = ""; |
---|
| 440 | $.each(criteria_operator_list, function(index, value){ |
---|
| 441 | criteria_operator += $.trim($(criteria_list[index]).val()) != "" ? index + "," : ","; |
---|
| 442 | criteria_value += $.trim($(criteria_operator_list[index]).val()) + ","; |
---|
| 443 | }); |
---|
| 444 | var criteria_operator_ = criteria_operator.split(","); |
---|
| 445 | var criteria_value_ = criteria_value.split(","); |
---|
| 446 | var options = ["from", "to", "subject", "body", "size"]; |
---|
| 447 | var criterias_ = new Array(); |
---|
[6443] | 448 | |
---|
| 449 | for (i in criteria_) |
---|
| 450 | if(criteria_[i] != "") |
---|
[6452] | 451 | criterias_.push( criterias_.length ? {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]} : {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} ); |
---|
[6443] | 452 | |
---|
[6048] | 453 | showGridButton = thiss.parent(); |
---|
[6443] | 454 | |
---|
[6452] | 455 | showGridButton.siblings("#filtergrid-container").block({ |
---|
| 456 | message: '<div id="loading-content"><div class="image"></div></div>', |
---|
| 457 | css: { |
---|
| 458 | backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)', |
---|
| 459 | backgroundRepeat: 'no-repeat', |
---|
| 460 | backgroundPosition: 'center', |
---|
| 461 | backgroundColor: 'transparent', |
---|
| 462 | width: '32px', |
---|
| 463 | height: '32px', |
---|
| 464 | border:'none' |
---|
| 465 | }, |
---|
| 466 | overlayCSS: { |
---|
| 467 | backgroundColor: '#CCC', |
---|
| 468 | opacity: 0.5 |
---|
| 469 | } |
---|
[6443] | 470 | }); |
---|
[6387] | 471 | |
---|
[6443] | 472 | var data = DataLayer.get( 'message', { filter: criterias_, criteria: { properties: { context: { folder: 'INBOX' } } } }, true ); |
---|
[6452] | 473 | |
---|
[6443] | 474 | DataLayer.register( 'criterias', 'message:jqGrid', function( crit ){ |
---|
[6048] | 475 | |
---|
[6443] | 476 | crit.properties = { context: { folder: 'INBOX' } }; |
---|
[6452] | 477 | |
---|
[6443] | 478 | return { filter: [ "msgNumber", "IN", data ], criteria: crit }; |
---|
| 479 | }); |
---|
| 480 | |
---|
| 481 | allMessages = data; |
---|
[6452] | 482 | |
---|
| 483 | if (typeof grid !== "undefined") { |
---|
| 484 | grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' ); |
---|
[6443] | 485 | //return; |
---|
| 486 | } |
---|
| 487 | grid = showGridButton.siblings("#filtergrid-container").removeClass('empty-container') |
---|
| 488 | .html('<table class="hidden fields-search-messages-grid" id="fields-search-messages-grid"><tr><td/></tr></table><div class="hidden fields-search-messages-grid-pager" id="fields-search-messages-grid-pager"></div>') |
---|
| 489 | .children(".fields-search-messages-grid, .fields-search-messages-grid-pager").removeClass('hidden').filter(".fields-search-messages-grid").trigger( 'reloadGrid' ).jqGrid({ |
---|
| 490 | url: 'message:jqGrid', |
---|
| 491 | datatype: "json", |
---|
| 492 | mtype: 'GET', |
---|
| 493 | colNames:['#', 'De', 'Assunto', 'Data', 'Tamanho'], |
---|
| 494 | colModel:[ |
---|
| 495 | {name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false}, |
---|
| 496 | {name:'from.email',index:'msg_number', width:130, sortable:false}, |
---|
| 497 | {name:'subject',index:'subject', width:250, sortable:false}, |
---|
| 498 | {name:'timestamp',index:'timestamp', width:65, align:"center", sortable:false, formatter:date2Time}, |
---|
| 499 | {name:'size',index:'size', width:50, align:"right", sortable:false, formatter:bytes2Size} |
---|
| 500 | ], |
---|
| 501 | jsonReader : { |
---|
| 502 | root:"rows", |
---|
| 503 | page: "page", |
---|
| 504 | total: "total", |
---|
| 505 | records: "records", |
---|
| 506 | repeatitems: false, |
---|
| 507 | id: "0" |
---|
| 508 | }, |
---|
| 509 | rowNum:10, |
---|
| 510 | //rowList:[10,25,50], |
---|
| 511 | rowList:[10], |
---|
| 512 | pager: '#fields-search-messages-grid-pager', |
---|
| 513 | sortname: 'id', |
---|
| 514 | viewrecords: true, |
---|
| 515 | sortorder: "desc", |
---|
| 516 | multiselect: true, |
---|
| 517 | autowidth: true, |
---|
| 518 | reloadAfterEdit: true, |
---|
| 519 | reloadAfterSubmit: true, |
---|
| 520 | height:200, |
---|
| 521 | loadComplete: function(data) { |
---|
| 522 | // // aplica o contador |
---|
| 523 | // jQuery('.timable').each(function (i) { |
---|
| 524 | // jQuery(this).countdown({ |
---|
[6452] | 525 | // since: new Date(parseInt(this.title)), |
---|
[6443] | 526 | // significant: 1, |
---|
[6452] | 527 | // layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', |
---|
[6443] | 528 | // description: ' atrás' |
---|
| 529 | // }); |
---|
| 530 | // }); |
---|
| 531 | }, |
---|
| 532 | onSelectRow: function (id, selected) { |
---|
[6452] | 533 | if( selected ) |
---|
[6443] | 534 | { |
---|
| 535 | selectedMessages[ id ] = true; |
---|
[6048] | 536 | } |
---|
[6443] | 537 | else |
---|
| 538 | { |
---|
| 539 | delete selectedMessages[ id ]; |
---|
| 540 | } |
---|
| 541 | }, |
---|
[6452] | 542 | onSelectAll: function (id, selected) { |
---|
[6443] | 543 | for (i in id) { |
---|
| 544 | if(selected) |
---|
| 545 | selectedMessages[id[i]] = true; |
---|
| 546 | else |
---|
[6452] | 547 | delete selectedMessages[id[i]]; |
---|
[6443] | 548 | } |
---|
| 549 | }, |
---|
| 550 | caption: 'Mensagens que atendem aos critérios' |
---|
| 551 | }); // end jqGrid |
---|
[6048] | 552 | } |
---|
| 553 | |
---|
[6392] | 554 | /* Gerencia a listagem de filtros do usuário */ |
---|
[6487] | 555 | /* |
---|
| 556 | * Lista os filtros para o usuário |
---|
| 557 | */ |
---|
[5539] | 558 | function list_filters(html){ |
---|
[6021] | 559 | outOfficeVerify(); |
---|
[6392] | 560 | for (var index in selectedMessages) { |
---|
| 561 | delete selectedMessages[index]; |
---|
| 562 | } |
---|
[5539] | 563 | if(html){ |
---|
| 564 | if( ! $(".filters-windows").length ) |
---|
[5761] | 565 | container = $('.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html( html ).find(".expresso-window-container"); |
---|
| 566 | list_container = $('.expressomail-module-container').find(".rule-list-container"); |
---|
[5539] | 567 | } |
---|
| 568 | list_container = $(".expresso-window-filters").dialog({ |
---|
[6487] | 569 | title: get_lang('Filters'), |
---|
[5539] | 570 | width:700, |
---|
| 571 | modal: true, |
---|
| 572 | resizable: false, |
---|
| 573 | closeOnEscape:true, |
---|
| 574 | close:function(event, ui) { |
---|
| 575 | event.stopPropagation(); |
---|
[5598] | 576 | if(list_container.find(".cancel").length) |
---|
[6452] | 577 | list_container.find(".cancel").trigger('click'); |
---|
[5627] | 578 | $(".dialog-head-buttonpane").hide(); |
---|
[5539] | 579 | }, |
---|
| 580 | open: function () { |
---|
| 581 | $(".ui-dialog .ui-dialog-titlebar") |
---|
| 582 | .append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>') |
---|
| 583 | .find('.ui-dialog-titlebar-minimize').click(function() { |
---|
| 584 | $(".ui-dialog-buttonpane, .ui-dialog-content").toggle(); |
---|
| 585 | $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin'); |
---|
| 586 | }); |
---|
[5627] | 587 | $(".dialog-head-buttonpane").show(); |
---|
[5539] | 588 | }, |
---|
| 589 | autoOpen: false, |
---|
| 590 | buttons: [{ |
---|
[5801] | 591 | text : get_lang("Close"), |
---|
[5539] | 592 | click : function() { |
---|
| 593 | $( this ).dialog( "close" ); |
---|
| 594 | } |
---|
| 595 | }] |
---|
| 596 | }); |
---|
| 597 | $(".ui-dialog-titlebar").after("<div class='dialog-head-buttonpane ui-dialog-buttonpane ui-widget-content ui-helper-clearfix' style='background-color: rgb(224, 238, 238); '><div class='ui-dialog-buttonset header-buttonpane'></div></div>"); |
---|
| 598 | $(".dialog-head-buttonpane").css("padding", "5px"). |
---|
[5801] | 599 | find(".header-buttonpane").html("<a href='#' class='button add' title='"+get_lang("Add new rule")+"'>"+get_lang("New rule")+"</a>"+(!outoffice ? "<a href='#' class='button add vacation' title='"+get_lang("Add rule out of office")+"'>"+get_lang("Out of office")+"</a>" : "")).find(".button").button(); |
---|
[6452] | 600 | |
---|
[5539] | 601 | $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE"); |
---|
[5598] | 602 | var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true)); |
---|
| 603 | list_container.html(list).find(".button").button(); |
---|
[6452] | 604 | |
---|
[5543] | 605 | list_container.find(".rule-list").selectable({ |
---|
| 606 | selecting: function(event, ui) { |
---|
| 607 | $(ui.selecting).find(':checkbox').attr('checked', true); |
---|
| 608 | }, |
---|
| 609 | unselecting: function(event, ui) { |
---|
| 610 | $(ui.unselecting).find(':checkbox').attr('checked', false); |
---|
| 611 | } |
---|
| 612 | }); |
---|
[6452] | 613 | |
---|
[5598] | 614 | list_container.find( ".menu-control .button" ).filter(".update").button({ |
---|
[5543] | 615 | icons: { |
---|
| 616 | primary: "ui-icon-pencil" |
---|
| 617 | }, |
---|
| 618 | text: false |
---|
| 619 | }).click(function(){ |
---|
[5627] | 620 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5543] | 621 | var filters = DataLayer.get( 'filter', true); |
---|
| 622 | for(var i =0; i < filters.length; i++){ |
---|
| 623 | if(filters[i].id == id){ |
---|
| 624 | filters = filters[i]; |
---|
| 625 | break; |
---|
[6452] | 626 | } |
---|
[5543] | 627 | } |
---|
[5801] | 628 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5543] | 629 | var details_container = $(".expresso-window-filters").html(html); |
---|
| 630 | if(filters.name != "vacation"){ |
---|
| 631 | form = container.find("form"); |
---|
| 632 | criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' ); |
---|
| 633 | actions = details_container.find( 'fieldset input[name="actionType[]"]' ); |
---|
| 634 | nameObj = details_container.find( 'input[name="name"]' ); |
---|
| 635 | isExact = details_container.find( 'input[name="isExact"]' ); |
---|
| 636 | showDetails(filters); |
---|
[5598] | 637 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 638 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5539] | 639 | accord.accordion('activate',1); |
---|
[5930] | 640 | }).end().filter(".forth2").click(function(){ |
---|
| 641 | accord.accordion('activate',2); |
---|
[5539] | 642 | }).end().filter(".back").click(function(){ |
---|
| 643 | accord.accordion('activate',0); |
---|
[5930] | 644 | }).end().filter(".back2").click(function(){ |
---|
| 645 | accord.accordion('activate',1); |
---|
[5539] | 646 | }).end().filter(".cancel").click(function(){ |
---|
| 647 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 648 | }).end().filter(".submit").click(function(){ |
---|
[5543] | 649 | if(nameObj) |
---|
| 650 | nameObj.attr("disabled", "false"); |
---|
[5591] | 651 | if(valid_save()) |
---|
| 652 | $(this).submit(); |
---|
| 653 | else |
---|
| 654 | return; |
---|
[6487] | 655 | DataLayer.commit( 'filter', false,function(data){ |
---|
| 656 | if(filters['alertMessage'] == "true"){ |
---|
| 657 | if(filters['alertMessage'] != $('.alertMessage').is(':checked').toString()){ |
---|
| 658 | /**RETIRA FLAG*/ |
---|
| 659 | removeMessagesFlag(filters['id']); |
---|
| 660 | } |
---|
| 661 | } |
---|
[6452] | 662 | if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { |
---|
[6392] | 663 | for (var index in selectedMessages) { |
---|
| 664 | set_message_flag(index, action, false); |
---|
| 665 | } |
---|
| 666 | } |
---|
[5662] | 667 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 668 | getFromAlertRules(); |
---|
[5662] | 669 | }); |
---|
[6452] | 670 | }).end().filter('.button.search').click(function() { |
---|
[6392] | 671 | /* Valida se o usuário preencheu as informações */ |
---|
| 672 | if(valid_save()) |
---|
| 673 | showGridMessages($(this)); |
---|
| 674 | else |
---|
| 675 | return; |
---|
| 676 | }) |
---|
[5543] | 677 | }else{ |
---|
[5598] | 678 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 679 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 680 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5539] | 681 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 682 | }).end().filter(".submit").click(function(){ |
---|
| 683 | $(this).submit(); |
---|
[5662] | 684 | DataLayer.commit( 'filter', false,function(){ |
---|
| 685 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 686 | getFromAlertRules(); |
---|
[5662] | 687 | }); |
---|
[5539] | 688 | }); |
---|
[5543] | 689 | details_container.find('[name="vacation"]').val(filters.actions[0].parameter); |
---|
| 690 | } |
---|
[5539] | 691 | }); |
---|
[5543] | 692 | }).end() |
---|
| 693 | .filter(".enable").button({ |
---|
| 694 | icons: { |
---|
[5648] | 695 | primary: "ui-icon-circle-close" |
---|
[5543] | 696 | }, |
---|
| 697 | text: false |
---|
| 698 | }).click(function(){ |
---|
[6452] | 699 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 700 | DataLayer.put( 'filter', id, { enabled: false }); |
---|
[6487] | 701 | /**RETIRA FLAG*/ |
---|
| 702 | removeMessagesFlag(id); |
---|
[5627] | 703 | DataLayer.commit("filter", false,function(){ |
---|
| 704 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 705 | getFromAlertRules(); |
---|
[5627] | 706 | }); |
---|
[5543] | 707 | }).end() |
---|
| 708 | |
---|
| 709 | .filter(".disable").button({ |
---|
| 710 | icons: { |
---|
[5648] | 711 | primary: "ui-icon-circle-check" |
---|
[5543] | 712 | }, |
---|
| 713 | text: false |
---|
| 714 | }).click(function(){ |
---|
[5627] | 715 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 716 | DataLayer.put( 'filter', id, { enabled: true }); |
---|
[5627] | 717 | DataLayer.commit("filter", false,function(){ |
---|
| 718 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 719 | getFromAlertRules(); |
---|
[5627] | 720 | }); |
---|
[5543] | 721 | }).end() |
---|
[6452] | 722 | |
---|
[5543] | 723 | .filter(".close").button({ |
---|
| 724 | icons: { |
---|
| 725 | primary: "ui-icon-close" |
---|
| 726 | }, |
---|
| 727 | text: false |
---|
[5648] | 728 | }).click(function(event){ |
---|
[5662] | 729 | var filter_name = $(event.target).parents("li.rule").find('.id').val(); |
---|
[5902] | 730 | var filter_screen_name = $(event.target).parents("li.rule").find('.title').html(); |
---|
| 731 | $.Zebra_Dialog(get_lang("Are you sure to delete the filter") + ": <strong>"+filter_screen_name+"</strong>",{ |
---|
[5662] | 732 | 'type': 'question', |
---|
[5801] | 733 | 'title': get_lang("Exclusion Confirmation"), |
---|
[5662] | 734 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
| 735 | 'onClose': function(caption) { |
---|
| 736 | if(caption == get_lang('Yes')){ |
---|
[5762] | 737 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 738 | DataLayer.remove('filter', false); |
---|
| 739 | DataLayer.get('filter'); |
---|
[6487] | 740 | /**RETIRA FLAG*/ |
---|
| 741 | removeMessagesFlag(filter_name); |
---|
[5662] | 742 | DataLayer.remove( 'filter', filter_name); |
---|
[6487] | 743 | |
---|
[5662] | 744 | DataLayer.commit("filter", false,function(){ |
---|
| 745 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 746 | getFromAlertRules(); |
---|
[5662] | 747 | }); |
---|
| 748 | }else{ |
---|
| 749 | $(event.target).removeClass("ui-selected").parent().removeClass("ui-selected"); |
---|
| 750 | } |
---|
| 751 | } |
---|
[5543] | 752 | }); |
---|
| 753 | }).end().removeClass("ui-button-icon-only"); |
---|
[6452] | 754 | |
---|
[6021] | 755 | $(".button.allenable").click(function(){ |
---|
[5987] | 756 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[5995] | 757 | DataLayer.put( 'filter', o.innerHTML, { enabled: true }); |
---|
[5987] | 758 | }); |
---|
| 759 | DataLayer.commit("filter", false, function(){ |
---|
| 760 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 761 | getFromAlertRules(); |
---|
[5987] | 762 | }); |
---|
| 763 | }); |
---|
[6452] | 764 | |
---|
[6021] | 765 | $(".button.alldisable").click(function(){ |
---|
[5987] | 766 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[5995] | 767 | DataLayer.put( 'filter', o.innerHTML, { enabled: false }); |
---|
[6487] | 768 | /**RETIRA FLAG*/ |
---|
| 769 | removeMessagesFlag(o.innerHTML); |
---|
[5987] | 770 | }); |
---|
| 771 | DataLayer.commit("filter", false, function(){ |
---|
| 772 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 773 | getFromAlertRules(); |
---|
[5987] | 774 | }); |
---|
| 775 | }); |
---|
[6452] | 776 | |
---|
[6021] | 777 | $(".button.alldelete").click(function(){ |
---|
[5985] | 778 | $.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{ |
---|
| 779 | 'type': 'question', |
---|
| 780 | 'title': get_lang("Exclusion Confirmation"), |
---|
| 781 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
| 782 | 'onClose': function(caption) { |
---|
| 783 | if(caption == get_lang('Yes')){ |
---|
| 784 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 785 | DataLayer.remove('filter', false); |
---|
| 786 | DataLayer.get('filter'); |
---|
[6452] | 787 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[6487] | 788 | /**RETIRA FLAG*/ |
---|
| 789 | removeMessagesFlag(urlencode(o.innerHTML)); |
---|
[6392] | 790 | DataLayer.remove( 'filter', urlencode(o.innerHTML) ); |
---|
[6487] | 791 | |
---|
| 792 | |
---|
[5985] | 793 | }); |
---|
| 794 | DataLayer.commit("filter", false,function(){ |
---|
| 795 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 796 | getFromAlertRules(); |
---|
[5985] | 797 | }); |
---|
| 798 | }else{ |
---|
| 799 | return true; |
---|
| 800 | } |
---|
| 801 | } |
---|
| 802 | }); |
---|
| 803 | }); |
---|
[6452] | 804 | |
---|
[5930] | 805 | var aa = 0; |
---|
[6452] | 806 | |
---|
[5598] | 807 | list_container.parent().find(".button.add:first").click(function(){ |
---|
| 808 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 809 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 810 | list_container.html(html); |
---|
| 811 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 812 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5543] | 813 | accord.accordion('activate',1); |
---|
[5930] | 814 | }).end().filter(".forth2").click(function(){ |
---|
| 815 | accord.accordion('activate',2); |
---|
[5543] | 816 | }).end().filter(".back").click(function(){ |
---|
| 817 | accord.accordion('activate',0); |
---|
[5930] | 818 | }).end().filter(".back2").click(function(){ |
---|
| 819 | accord.accordion('activate',1); |
---|
[5543] | 820 | }).end().filter(".cancel").click(function(){ |
---|
| 821 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[5862] | 822 | }).end().filter(".submit").click(function() { |
---|
[5591] | 823 | if(valid_save()) |
---|
| 824 | $(this).submit(); |
---|
| 825 | else |
---|
| 826 | return; |
---|
[5627] | 827 | DataLayer.commit( 'filter',false,function(){ |
---|
[6452] | 828 | if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { |
---|
[6392] | 829 | for (var index in selectedMessages) { |
---|
| 830 | set_message_flag(index, action, false); |
---|
| 831 | } |
---|
| 832 | } |
---|
[5627] | 833 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 834 | getFromAlertRules(); |
---|
[5627] | 835 | }); |
---|
[6452] | 836 | }).end().filter('.button.search').click(function() { |
---|
[5862] | 837 | if(valid_save()) |
---|
[6048] | 838 | showGridMessages($(this)); |
---|
[5862] | 839 | else |
---|
| 840 | return; |
---|
| 841 | }); // end function click |
---|
| 842 | }); // end DataLayer.render |
---|
[5543] | 843 | }); |
---|
[5598] | 844 | list_container.parent().find(".button.add.vacation").click(function(){ |
---|
[6452] | 845 | |
---|
[5598] | 846 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 847 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 848 | list_container.html(html); |
---|
| 849 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 850 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 851 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5543] | 852 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6452] | 853 | }).end().filter(".submit").click(function(){ |
---|
[6392] | 854 | if(list_container.find(".vacation-details-container .filter-textarea").val().length <= 0){ |
---|
| 855 | $.Zebra_Dialog(get_lang('Write a message')); |
---|
| 856 | list_container.find(".vacation-details-container .filter-textarea").focus(); |
---|
| 857 | }else{ |
---|
| 858 | $(this).submit(); |
---|
| 859 | DataLayer.commit( 'filter',false,function(){ |
---|
| 860 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 861 | getFromAlertRules(); |
---|
[6392] | 862 | }); |
---|
| 863 | } |
---|
[5543] | 864 | }); |
---|
[6452] | 865 | }); |
---|
[5543] | 866 | }); |
---|
[5539] | 867 | } |
---|
[6284] | 868 | |
---|
[6487] | 869 | |
---|
| 870 | /* Inicializa os filtros e chama o list_filters |
---|
| 871 | * Inicia a funcionalidade de filtros de mensagens |
---|
| 872 | */ |
---|
[5782] | 873 | function init_filters(){ |
---|
| 874 | var html = DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {}); |
---|
| 875 | list_filters(html); |
---|
| 876 | } |
---|
[6487] | 877 | |
---|
| 878 | /* |
---|
| 879 | * Ao excluir filtro, desabilitar filtro ou retirar a ação Alerta de um filtro |
---|
| 880 | * esta função é chamada para retirar as flags que caracterizam uma mensagem como alertada pelos Filtros por Remetente |
---|
| 881 | */ |
---|
| 882 | function removeMessagesFlag(id){ |
---|
| 883 | var filters_c = DataLayer.get('filter', id); |
---|
| 884 | var folder = ''; |
---|
| 885 | var from = ''; |
---|
| 886 | |
---|
| 887 | for(var i=0; i < filters_c['actions'].length; i++){ |
---|
| 888 | if(filters_c['actions'][i].type == 'fileinto'){ |
---|
| 889 | folder = filters_c['actions'][i].parameter; |
---|
| 890 | } |
---|
| 891 | } |
---|
| 892 | $.each(fromRules, function(index, value) { |
---|
| 893 | if(value == folder){ |
---|
| 894 | for(var i=0; i < filters_c['criteria'].length; i++){ |
---|
| 895 | if(filters_c['criteria'][i].field == 'from'){ |
---|
| 896 | from = filters_c['criteria'][i].value; |
---|
| 897 | } |
---|
| 898 | } |
---|
| 899 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&from="+from, function(){}); |
---|
| 900 | return false; |
---|
| 901 | } |
---|
| 902 | }); |
---|
| 903 | } |
---|