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