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