[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 + "?")){ |
---|
[8082] | 441 | var has_folder_spam = false; |
---|
| 442 | var folder_spam = "INBOX"+cyrus_delimiter+"Spam"; |
---|
| 443 | $.each(cp_tree1, function(index, value){ |
---|
| 444 | if(value.id == folder_spam){ |
---|
| 445 | has_folder_spam = true; |
---|
| 446 | return; |
---|
| 447 | } |
---|
| 448 | }); |
---|
| 449 | if(!has_folder_spam){ |
---|
| 450 | connector.loadScript('TreeS'); |
---|
| 451 | create_new_folder("Spam","INBOX"); |
---|
| 452 | } |
---|
[6452] | 453 | DataLayer.put( 'filter', idd, |
---|
| 454 | { name: email, isExact: false, |
---|
[5630] | 455 | criteria:{ 0: {value: email, operator: "=", field: "from"} }, |
---|
[8082] | 456 | actions: { 0: {parameter: folder_spam, type: "fileinto"}}, |
---|
[6452] | 457 | enabled: true, |
---|
[5630] | 458 | id: email, |
---|
[6452] | 459 | block: true |
---|
[5630] | 460 | }); |
---|
[5762] | 461 | DataLayer.commit("filter", false, function(){ |
---|
[7609] | 462 | $.Zebra_Dialog(get_lang("User") + " " + email + " " + get_lang("blocked"),{ |
---|
| 463 | 'overlay_opacity': '0.5', |
---|
| 464 | 'custom_class': 'custom-zebra-filter' |
---|
| 465 | }); |
---|
[5762] | 466 | list_filters(); |
---|
[6487] | 467 | getFromAlertRules(); |
---|
[5762] | 468 | }); |
---|
[6452] | 469 | |
---|
[5762] | 470 | } |
---|
[5630] | 471 | } |
---|
| 472 | |
---|
[6443] | 473 | |
---|
| 474 | DataLayer.codec( 'message', 'jqGrid', { |
---|
[6452] | 475 | |
---|
[6443] | 476 | encoder: function( data ){ |
---|
| 477 | |
---|
| 478 | return( data ); |
---|
| 479 | |
---|
| 480 | } |
---|
| 481 | }); |
---|
| 482 | |
---|
[7948] | 483 | DataLayer.codec( 'message', 'jqGridSearch', { |
---|
| 484 | |
---|
| 485 | encoder: function( data ){ |
---|
| 486 | |
---|
| 487 | return( data ); |
---|
| 488 | |
---|
| 489 | } |
---|
| 490 | }); |
---|
| 491 | |
---|
[6487] | 492 | /* Gerencia o grid das mensagens da caixa de entrada |
---|
| 493 | * Mostra o grid de mensagens para aplicar a regra nas mensagens da caixa de entrada. |
---|
| 494 | */ |
---|
[6048] | 495 | function showGridMessages(thiss) { |
---|
| 496 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
| 497 | var criteria_operator_list = list_container.find('[name="criteriaOperator[]"]'); |
---|
| 498 | var criteria_value = ""; |
---|
| 499 | var criteria = ""; |
---|
| 500 | $.each(criteria_list, function(index, value){ |
---|
| 501 | criteria += $.trim($(criteria_list[index]).val()) + ","; |
---|
| 502 | }); |
---|
| 503 | var criteria_ = criteria.split(","); |
---|
| 504 | var criteria_operator = ""; |
---|
| 505 | $.each(criteria_operator_list, function(index, value){ |
---|
| 506 | criteria_operator += $.trim($(criteria_list[index]).val()) != "" ? index + "," : ","; |
---|
| 507 | criteria_value += $.trim($(criteria_operator_list[index]).val()) + ","; |
---|
| 508 | }); |
---|
| 509 | var criteria_operator_ = criteria_operator.split(","); |
---|
| 510 | var criteria_value_ = criteria_value.split(","); |
---|
| 511 | var options = ["from", "to", "subject", "body", "size"]; |
---|
| 512 | var criterias_ = new Array(); |
---|
[6443] | 513 | |
---|
[7856] | 514 | var isExact = (list_container.find('[name="isExact"]:checked').val() == 'and') ? 'yes' : 'no'; |
---|
| 515 | |
---|
[6443] | 516 | for (i in criteria_) |
---|
| 517 | if(criteria_[i] != "") |
---|
[6452] | 518 | 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] | 519 | |
---|
[6048] | 520 | showGridButton = thiss.parent(); |
---|
[6443] | 521 | |
---|
[6452] | 522 | showGridButton.siblings("#filtergrid-container").block({ |
---|
| 523 | message: '<div id="loading-content"><div class="image"></div></div>', |
---|
| 524 | css: { |
---|
| 525 | backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)', |
---|
| 526 | backgroundRepeat: 'no-repeat', |
---|
| 527 | backgroundPosition: 'center', |
---|
| 528 | backgroundColor: 'transparent', |
---|
| 529 | width: '32px', |
---|
| 530 | height: '32px', |
---|
| 531 | border:'none' |
---|
| 532 | }, |
---|
| 533 | overlayCSS: { |
---|
| 534 | backgroundColor: '#CCC', |
---|
| 535 | opacity: 0.5 |
---|
| 536 | } |
---|
[6443] | 537 | }); |
---|
[6387] | 538 | |
---|
[7856] | 539 | var data = DataLayer.get( 'message', { filter: criterias_, criteria: { isExact: isExact , properties: { context: { folder: 'INBOX' } } } }, true ); |
---|
[7719] | 540 | if(DataLayer.criterias['message:jqGrid']){ |
---|
| 541 | delete DataLayer.criterias['message:jqGrid']; |
---|
| 542 | } |
---|
[6452] | 543 | |
---|
[6443] | 544 | DataLayer.register( 'criterias', 'message:jqGrid', function( crit ){ |
---|
[6048] | 545 | |
---|
[6443] | 546 | crit.properties = { context: { folder: 'INBOX' } }; |
---|
[6452] | 547 | |
---|
[6443] | 548 | return { filter: [ "msgNumber", "IN", data ], criteria: crit }; |
---|
| 549 | }); |
---|
| 550 | |
---|
| 551 | allMessages = data; |
---|
[6452] | 552 | |
---|
| 553 | if (typeof grid !== "undefined") { |
---|
| 554 | grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' ); |
---|
[6443] | 555 | //return; |
---|
| 556 | } |
---|
| 557 | grid = showGridButton.siblings("#filtergrid-container").removeClass('empty-container') |
---|
| 558 | .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>') |
---|
| 559 | .children(".fields-search-messages-grid, .fields-search-messages-grid-pager").removeClass('hidden').filter(".fields-search-messages-grid").trigger( 'reloadGrid' ).jqGrid({ |
---|
| 560 | url: 'message:jqGrid', |
---|
| 561 | datatype: "json", |
---|
| 562 | mtype: 'GET', |
---|
| 563 | colNames:['#', 'De', 'Assunto', 'Data', 'Tamanho'], |
---|
| 564 | colModel:[ |
---|
| 565 | {name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false}, |
---|
| 566 | {name:'from.email',index:'msg_number', width:130, sortable:false}, |
---|
| 567 | {name:'subject',index:'subject', width:250, sortable:false}, |
---|
| 568 | {name:'timestamp',index:'timestamp', width:65, align:"center", sortable:false, formatter:date2Time}, |
---|
| 569 | {name:'size',index:'size', width:50, align:"right", sortable:false, formatter:bytes2Size} |
---|
| 570 | ], |
---|
| 571 | jsonReader : { |
---|
| 572 | root:"rows", |
---|
| 573 | page: "page", |
---|
| 574 | total: "total", |
---|
| 575 | records: "records", |
---|
| 576 | repeatitems: false, |
---|
| 577 | id: "0" |
---|
| 578 | }, |
---|
| 579 | rowNum:10, |
---|
| 580 | //rowList:[10,25,50], |
---|
| 581 | rowList:[10], |
---|
| 582 | pager: '#fields-search-messages-grid-pager', |
---|
| 583 | sortname: 'id', |
---|
| 584 | viewrecords: true, |
---|
| 585 | sortorder: "desc", |
---|
| 586 | multiselect: true, |
---|
| 587 | autowidth: true, |
---|
| 588 | reloadAfterEdit: true, |
---|
| 589 | reloadAfterSubmit: true, |
---|
| 590 | height:200, |
---|
| 591 | loadComplete: function(data) { |
---|
[7719] | 592 | // aplica o contador |
---|
| 593 | jQuery('.timable').each(function (i) { |
---|
| 594 | jQuery(this).countdown({ |
---|
| 595 | since: new Date(parseInt(this.title)), |
---|
| 596 | significant: 1, |
---|
| 597 | layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', |
---|
| 598 | description: ' atrás' |
---|
| 599 | }); |
---|
| 600 | }); |
---|
[6443] | 601 | }, |
---|
| 602 | onSelectRow: function (id, selected) { |
---|
[6452] | 603 | if( selected ) |
---|
[6443] | 604 | { |
---|
| 605 | selectedMessages[ id ] = true; |
---|
[6048] | 606 | } |
---|
[6443] | 607 | else |
---|
| 608 | { |
---|
| 609 | delete selectedMessages[ id ]; |
---|
| 610 | } |
---|
| 611 | }, |
---|
[6452] | 612 | onSelectAll: function (id, selected) { |
---|
[6443] | 613 | for (i in id) { |
---|
| 614 | if(selected) |
---|
| 615 | selectedMessages[id[i]] = true; |
---|
| 616 | else |
---|
[6452] | 617 | delete selectedMessages[id[i]]; |
---|
[6443] | 618 | } |
---|
| 619 | }, |
---|
| 620 | caption: 'Mensagens que atendem aos critérios' |
---|
| 621 | }); // end jqGrid |
---|
[6048] | 622 | } |
---|
| 623 | |
---|
[6392] | 624 | /* Gerencia a listagem de filtros do usuário */ |
---|
[6487] | 625 | /* |
---|
| 626 | * Lista os filtros para o usuário |
---|
| 627 | */ |
---|
[7892] | 628 | function list_filters(html) { |
---|
[6021] | 629 | outOfficeVerify(); |
---|
[7892] | 630 | for (var index in selectedMessages) |
---|
| 631 | { |
---|
[6392] | 632 | delete selectedMessages[index]; |
---|
| 633 | } |
---|
[7892] | 634 | |
---|
| 635 | initialize_container(html); // Inicializa o container do diálogo de filtros |
---|
| 636 | |
---|
| 637 | list_container = create_filter_dialog(); // Cria a estrutura básica do diálogo |
---|
| 638 | |
---|
[5598] | 639 | var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true)); |
---|
| 640 | list_container.html(list).find(".button").button(); |
---|
[8068] | 641 | list_container.find(".alldelete").button("disable"); |
---|
| 642 | list_container.find(".alldisable").button("disable"); |
---|
| 643 | list_container.find(".allenable").button("disable"); |
---|
| 644 | |
---|
[5543] | 645 | list_container.find(".rule-list").selectable({ |
---|
| 646 | selecting: function(event, ui) { |
---|
| 647 | $(ui.selecting).find(':checkbox').attr('checked', true); |
---|
| 648 | }, |
---|
| 649 | unselecting: function(event, ui) { |
---|
| 650 | $(ui.unselecting).find(':checkbox').attr('checked', false); |
---|
| 651 | } |
---|
| 652 | }); |
---|
[6452] | 653 | |
---|
[8071] | 654 | list_container.find(".rule-list li").click(function(){ |
---|
[8068] | 655 | if(list_container.find(".select").children("input:checked").length){ |
---|
| 656 | list_container.find(".alldelete").button("enable"); |
---|
| 657 | list_container.find(".alldisable").button("enable"); |
---|
| 658 | list_container.find(".allenable").button("enable"); |
---|
| 659 | } else { |
---|
| 660 | list_container.find(".alldelete").button("disable"); |
---|
| 661 | list_container.find(".alldisable").button("disable"); |
---|
| 662 | list_container.find(".allenable").button("disable"); |
---|
| 663 | } |
---|
| 664 | }); |
---|
| 665 | |
---|
[5598] | 666 | list_container.find( ".menu-control .button" ).filter(".update").button({ |
---|
[5543] | 667 | icons: { |
---|
| 668 | primary: "ui-icon-pencil" |
---|
| 669 | }, |
---|
| 670 | text: false |
---|
| 671 | }).click(function(){ |
---|
[5627] | 672 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5543] | 673 | var filters = DataLayer.get( 'filter', true); |
---|
| 674 | for(var i =0; i < filters.length; i++){ |
---|
| 675 | if(filters[i].id == id){ |
---|
| 676 | filters = filters[i]; |
---|
| 677 | break; |
---|
[6452] | 678 | } |
---|
[5543] | 679 | } |
---|
[5801] | 680 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5543] | 681 | var details_container = $(".expresso-window-filters").html(html); |
---|
| 682 | if(filters.name != "vacation"){ |
---|
| 683 | form = container.find("form"); |
---|
| 684 | criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' ); |
---|
| 685 | actions = details_container.find( 'fieldset input[name="actionType[]"]' ); |
---|
| 686 | nameObj = details_container.find( 'input[name="name"]' ); |
---|
| 687 | isExact = details_container.find( 'input[name="isExact"]' ); |
---|
| 688 | showDetails(filters); |
---|
[5598] | 689 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 690 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5539] | 691 | accord.accordion('activate',1); |
---|
[5930] | 692 | }).end().filter(".forth2").click(function(){ |
---|
| 693 | accord.accordion('activate',2); |
---|
[5539] | 694 | }).end().filter(".back").click(function(){ |
---|
| 695 | accord.accordion('activate',0); |
---|
[5930] | 696 | }).end().filter(".back2").click(function(){ |
---|
| 697 | accord.accordion('activate',1); |
---|
[5539] | 698 | }).end().filter(".cancel").click(function(){ |
---|
| 699 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 700 | }).end().filter(".submit").click(function(){ |
---|
[5543] | 701 | if(nameObj) |
---|
| 702 | nameObj.attr("disabled", "false"); |
---|
[5591] | 703 | if(valid_save()) |
---|
| 704 | $(this).submit(); |
---|
| 705 | else |
---|
| 706 | return; |
---|
[6487] | 707 | DataLayer.commit( 'filter', false,function(data){ |
---|
| 708 | if(filters['alertMessage'] == "true"){ |
---|
| 709 | if(filters['alertMessage'] != $('.alertMessage').is(':checked').toString()){ |
---|
| 710 | /**RETIRA FLAG*/ |
---|
| 711 | removeMessagesFlag(filters['id']); |
---|
| 712 | } |
---|
| 713 | } |
---|
[6452] | 714 | if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { |
---|
[6392] | 715 | for (var index in selectedMessages) { |
---|
| 716 | set_message_flag(index, action, false); |
---|
| 717 | } |
---|
| 718 | } |
---|
[5662] | 719 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 720 | getFromAlertRules(); |
---|
[7903] | 721 | cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box); |
---|
[5662] | 722 | }); |
---|
[7717] | 723 | |
---|
[6452] | 724 | }).end().filter('.button.search').click(function() { |
---|
[6392] | 725 | /* Valida se o usuário preencheu as informações */ |
---|
| 726 | if(valid_save()) |
---|
| 727 | showGridMessages($(this)); |
---|
| 728 | else |
---|
| 729 | return; |
---|
| 730 | }) |
---|
[5543] | 731 | }else{ |
---|
[5598] | 732 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 733 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 734 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5539] | 735 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 736 | }).end().filter(".submit").click(function(){ |
---|
[7621] | 737 | if(list_container.find(".vacation-details-container .filter-textarea").val().length <= 0){ |
---|
| 738 | $.Zebra_Dialog(get_lang('Write a message'),{ |
---|
| 739 | 'overlay_opacity': '0.5', |
---|
| 740 | 'custom_class': 'custom-zebra-filter' |
---|
| 741 | }); |
---|
| 742 | list_container.find(".vacation-details-container .filter-textarea").focus(); |
---|
| 743 | }else{ |
---|
| 744 | $(this).submit(); |
---|
| 745 | DataLayer.commit( 'filter',false,function(){ |
---|
| 746 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 747 | getFromAlertRules(); |
---|
| 748 | }); |
---|
| 749 | } |
---|
[5539] | 750 | }); |
---|
[5543] | 751 | details_container.find('[name="vacation"]').val(filters.actions[0].parameter); |
---|
| 752 | } |
---|
[5539] | 753 | }); |
---|
[5543] | 754 | }).end() |
---|
| 755 | .filter(".enable").button({ |
---|
| 756 | icons: { |
---|
[5648] | 757 | primary: "ui-icon-circle-close" |
---|
[5543] | 758 | }, |
---|
| 759 | text: false |
---|
| 760 | }).click(function(){ |
---|
[6452] | 761 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 762 | DataLayer.put( 'filter', id, { enabled: false }); |
---|
[6487] | 763 | /**RETIRA FLAG*/ |
---|
| 764 | removeMessagesFlag(id); |
---|
[5627] | 765 | DataLayer.commit("filter", false,function(){ |
---|
| 766 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 767 | getFromAlertRules(); |
---|
[5627] | 768 | }); |
---|
[5543] | 769 | }).end() |
---|
| 770 | |
---|
| 771 | .filter(".disable").button({ |
---|
| 772 | icons: { |
---|
[5648] | 773 | primary: "ui-icon-circle-check" |
---|
[5543] | 774 | }, |
---|
| 775 | text: false |
---|
| 776 | }).click(function(){ |
---|
[5627] | 777 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 778 | DataLayer.put( 'filter', id, { enabled: true }); |
---|
[5627] | 779 | DataLayer.commit("filter", false,function(){ |
---|
| 780 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 781 | getFromAlertRules(); |
---|
[5627] | 782 | }); |
---|
[5543] | 783 | }).end() |
---|
[6452] | 784 | |
---|
[5543] | 785 | .filter(".close").button({ |
---|
| 786 | icons: { |
---|
| 787 | primary: "ui-icon-close" |
---|
| 788 | }, |
---|
| 789 | text: false |
---|
[5648] | 790 | }).click(function(event){ |
---|
[5662] | 791 | var filter_name = $(event.target).parents("li.rule").find('.id').val(); |
---|
[5902] | 792 | var filter_screen_name = $(event.target).parents("li.rule").find('.title').html(); |
---|
| 793 | $.Zebra_Dialog(get_lang("Are you sure to delete the filter") + ": <strong>"+filter_screen_name+"</strong>",{ |
---|
[5662] | 794 | 'type': 'question', |
---|
[5801] | 795 | 'title': get_lang("Exclusion Confirmation"), |
---|
[5662] | 796 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
[7609] | 797 | 'overlay_opacity': '0.5', |
---|
| 798 | 'custom_class': 'custom-zebra-filter', |
---|
[5662] | 799 | 'onClose': function(caption) { |
---|
| 800 | if(caption == get_lang('Yes')){ |
---|
[5762] | 801 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 802 | DataLayer.remove('filter', false); |
---|
| 803 | DataLayer.get('filter'); |
---|
[6487] | 804 | /**RETIRA FLAG*/ |
---|
| 805 | removeMessagesFlag(filter_name); |
---|
[5662] | 806 | DataLayer.remove( 'filter', filter_name); |
---|
[6487] | 807 | |
---|
[5662] | 808 | DataLayer.commit("filter", false,function(){ |
---|
| 809 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 810 | getFromAlertRules(); |
---|
[5662] | 811 | }); |
---|
| 812 | }else{ |
---|
| 813 | $(event.target).removeClass("ui-selected").parent().removeClass("ui-selected"); |
---|
| 814 | } |
---|
| 815 | } |
---|
[5543] | 816 | }); |
---|
| 817 | }).end().removeClass("ui-button-icon-only"); |
---|
[6452] | 818 | |
---|
[6021] | 819 | $(".button.allenable").click(function(){ |
---|
[7753] | 820 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('input.id').each(function(i,o){ |
---|
| 821 | DataLayer.put( 'filter', o.value, { enabled: true }); |
---|
[5987] | 822 | }); |
---|
| 823 | DataLayer.commit("filter", false, function(){ |
---|
| 824 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 825 | getFromAlertRules(); |
---|
[5987] | 826 | }); |
---|
| 827 | }); |
---|
[6452] | 828 | |
---|
[6021] | 829 | $(".button.alldisable").click(function(){ |
---|
[7753] | 830 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('input.id').each(function(i,o){ |
---|
| 831 | DataLayer.put( 'filter', o.value, { enabled: false }); |
---|
[6487] | 832 | /**RETIRA FLAG*/ |
---|
[7753] | 833 | removeMessagesFlag(urlencode(o.innerHTML)); |
---|
[5987] | 834 | }); |
---|
| 835 | DataLayer.commit("filter", false, function(){ |
---|
| 836 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 837 | getFromAlertRules(); |
---|
[5987] | 838 | }); |
---|
| 839 | }); |
---|
[6452] | 840 | |
---|
[6021] | 841 | $(".button.alldelete").click(function(){ |
---|
[5985] | 842 | $.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{ |
---|
| 843 | 'type': 'question', |
---|
| 844 | 'title': get_lang("Exclusion Confirmation"), |
---|
| 845 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
[7609] | 846 | 'overlay_opacity': '0.5', |
---|
| 847 | 'custom_class': 'custom-zebra-filter', |
---|
[5985] | 848 | 'onClose': function(caption) { |
---|
| 849 | if(caption == get_lang('Yes')){ |
---|
| 850 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 851 | DataLayer.remove('filter', false); |
---|
| 852 | DataLayer.get('filter'); |
---|
[7484] | 853 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('input.id').each(function(i,o){ |
---|
[6487] | 854 | /**RETIRA FLAG*/ |
---|
[7484] | 855 | removeMessagesFlag(urlencode(o.innerHTML)); |
---|
| 856 | //filter_name = urlencode(o.innerHTML.replace(".", "_")); |
---|
| 857 | filter_name = o.value; |
---|
| 858 | DataLayer.remove( 'filter', filter_name ); |
---|
[5985] | 859 | }); |
---|
[7484] | 860 | DataLayer.commit("filter", false, function(){ |
---|
[5985] | 861 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 862 | getFromAlertRules(); |
---|
[5985] | 863 | }); |
---|
| 864 | }else{ |
---|
| 865 | return true; |
---|
| 866 | } |
---|
| 867 | } |
---|
| 868 | }); |
---|
| 869 | }); |
---|
[6452] | 870 | |
---|
[5930] | 871 | var aa = 0; |
---|
[6452] | 872 | |
---|
[5598] | 873 | list_container.parent().find(".button.add:first").click(function(){ |
---|
[7892] | 874 | render_new_rule(); // Renderiza a tela de criação de nova regra de filtragem. |
---|
[5543] | 875 | }); |
---|
[5598] | 876 | list_container.parent().find(".button.add.vacation").click(function(){ |
---|
[6452] | 877 | |
---|
[5598] | 878 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 879 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 880 | list_container.html(html); |
---|
| 881 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 882 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 883 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5543] | 884 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6452] | 885 | }).end().filter(".submit").click(function(){ |
---|
[6392] | 886 | if(list_container.find(".vacation-details-container .filter-textarea").val().length <= 0){ |
---|
[7609] | 887 | $.Zebra_Dialog(get_lang('Write a message'),{ |
---|
| 888 | 'overlay_opacity': '0.5', |
---|
| 889 | 'custom_class': 'custom-zebra-filter' |
---|
| 890 | }); |
---|
[6392] | 891 | list_container.find(".vacation-details-container .filter-textarea").focus(); |
---|
| 892 | }else{ |
---|
| 893 | $(this).submit(); |
---|
| 894 | DataLayer.commit( 'filter',false,function(){ |
---|
| 895 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6487] | 896 | getFromAlertRules(); |
---|
[6392] | 897 | }); |
---|
| 898 | } |
---|
[5543] | 899 | }); |
---|
[6452] | 900 | }); |
---|
[5543] | 901 | }); |
---|
[5539] | 902 | } |
---|
[6284] | 903 | |
---|
[7892] | 904 | /* |
---|
| 905 | Inicializa o container do diálogo de gerenciamento de filtros. |
---|
| 906 | */ |
---|
| 907 | function initialize_container (html) { |
---|
| 908 | if(html) |
---|
| 909 | { |
---|
| 910 | if(!$(".filters-windows").length) |
---|
| 911 | { |
---|
| 912 | container = $('.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html(html).find(".expresso-window-container"); |
---|
| 913 | } |
---|
| 914 | } |
---|
| 915 | } |
---|
| 916 | |
---|
| 917 | /* |
---|
| 918 | Cria a estrutura básica do diálogo de gerenciamento de filtros. |
---|
| 919 | */ |
---|
| 920 | function create_filter_dialog () { |
---|
| 921 | var dialog = $(".expresso-window-filters").dialog( |
---|
| 922 | { |
---|
| 923 | title: get_lang('Filters'), |
---|
| 924 | width: 700, |
---|
| 925 | modal: true, |
---|
| 926 | resizable: false, |
---|
| 927 | closeOnEscape: true, |
---|
| 928 | close: function(event, ui) |
---|
| 929 | { |
---|
| 930 | event.stopPropagation(); |
---|
| 931 | if(list_container.find(".cancel").length) list_container.find(".cancel").trigger('click'); |
---|
| 932 | $(".dialog-head-buttonpane").hide(); |
---|
| 933 | }, |
---|
| 934 | open: function() |
---|
| 935 | { |
---|
| 936 | $(".ui-dialog .ui-dialog-titlebar").append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>').find('.ui-dialog-titlebar-minimize').click(function() |
---|
| 937 | { |
---|
| 938 | $(".ui-dialog-buttonpane, .ui-dialog-content").toggle(); |
---|
| 939 | $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin'); |
---|
| 940 | }); |
---|
| 941 | $(".dialog-head-buttonpane").show(); |
---|
| 942 | }, |
---|
| 943 | autoOpen: false, |
---|
| 944 | buttons: [ |
---|
| 945 | { |
---|
| 946 | text: get_lang("Close"), |
---|
| 947 | click: function() |
---|
| 948 | { |
---|
| 949 | $(this).dialog("close"); |
---|
| 950 | } |
---|
| 951 | }] |
---|
| 952 | }); |
---|
| 953 | |
---|
| 954 | $(".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>"); |
---|
| 955 | $(".dialog-head-buttonpane").css("padding", "5px"). |
---|
| 956 | 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(); |
---|
| 957 | $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE"); |
---|
| 958 | |
---|
| 959 | return dialog; |
---|
| 960 | } |
---|
| 961 | |
---|
| 962 | /* |
---|
| 963 | Renderiza a tela de adição de uma nova regra de filtragem, |
---|
| 964 | dentro do diálogo de gerenciamento de filtros. |
---|
| 965 | */ |
---|
| 966 | function render_new_rule (from, subject) { |
---|
| 967 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
| 968 | var data = { |
---|
| 969 | folders: DataLayer.get("folder", true), |
---|
| 970 | delimiter: cyrus_delimiter, |
---|
| 971 | from: from, |
---|
| 972 | subject: subject ? html_entities(subject) : subject |
---|
| 973 | } |
---|
| 974 | |
---|
| 975 | DataLayer.render(BASE_PATH + 'modules/filters/edit-filter.ejs', data, function(html) |
---|
| 976 | { |
---|
| 977 | list_container.html(html); |
---|
| 978 | var accord = list_container.find(".rule-details-container").accordion( |
---|
| 979 | { |
---|
| 980 | autoHeight: false |
---|
| 981 | }); |
---|
| 982 | list_container.find(".button").button().filter(".forth").click(function() |
---|
| 983 | { |
---|
| 984 | accord.accordion('activate', 1); |
---|
| 985 | }).end().filter(".forth2").click(function() |
---|
| 986 | { |
---|
| 987 | accord.accordion('activate', 2); |
---|
| 988 | }).end().filter(".back").click(function() |
---|
| 989 | { |
---|
| 990 | accord.accordion('activate', 0); |
---|
| 991 | }).end().filter(".back2").click(function() |
---|
| 992 | { |
---|
| 993 | accord.accordion('activate', 1); |
---|
| 994 | }).end().filter(".cancel").click(function() |
---|
| 995 | { |
---|
| 996 | DataLayer.render(BASE_PATH + 'modules/filters/init.ejs', {}, list_filters); |
---|
| 997 | }).end().filter(".submit").click(function() |
---|
| 998 | { |
---|
| 999 | if(valid_save()) $(this).submit(); |
---|
| 1000 | else return; |
---|
| 1001 | DataLayer.commit('filter', false, function() |
---|
| 1002 | { |
---|
| 1003 | if($('#gbox_fields-search-messages-grid').length > 0 && action != '') |
---|
| 1004 | { |
---|
| 1005 | for(var index in selectedMessages) |
---|
| 1006 | { |
---|
| 1007 | set_message_flag(index, action, false); |
---|
| 1008 | } |
---|
| 1009 | } |
---|
| 1010 | DataLayer.render(BASE_PATH + 'modules/filters/init.ejs', {}, list_filters); |
---|
| 1011 | getFromAlertRules(); |
---|
| 1012 | }); |
---|
| 1013 | }).end().filter('.button.search').click(function() |
---|
| 1014 | { |
---|
| 1015 | if(valid_save()) showGridMessages($(this)); |
---|
| 1016 | else return; |
---|
| 1017 | }); // end function click |
---|
| 1018 | }); // end DataLayer.render |
---|
| 1019 | } |
---|
[6487] | 1020 | |
---|
| 1021 | /* Inicializa os filtros e chama o list_filters |
---|
| 1022 | * Inicia a funcionalidade de filtros de mensagens |
---|
| 1023 | */ |
---|
[5782] | 1024 | function init_filters(){ |
---|
| 1025 | var html = DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {}); |
---|
| 1026 | list_filters(html); |
---|
| 1027 | } |
---|
[6487] | 1028 | |
---|
| 1029 | /* |
---|
| 1030 | * Ao excluir filtro, desabilitar filtro ou retirar a ação Alerta de um filtro |
---|
| 1031 | * esta função é chamada para retirar as flags que caracterizam uma mensagem como alertada pelos Filtros por Remetente |
---|
| 1032 | */ |
---|
| 1033 | function removeMessagesFlag(id){ |
---|
[6564] | 1034 | var filters_c = DataLayer.get('filter', urlencode(id)); |
---|
[6487] | 1035 | var folder = ''; |
---|
[6564] | 1036 | var from = ''; |
---|
[6620] | 1037 | if(filters_c['actions']) |
---|
[6487] | 1038 | for(var i=0; i < filters_c['actions'].length; i++){ |
---|
| 1039 | if(filters_c['actions'][i].type == 'fileinto'){ |
---|
| 1040 | folder = filters_c['actions'][i].parameter; |
---|
| 1041 | } |
---|
| 1042 | } |
---|
| 1043 | $.each(fromRules, function(index, value) { |
---|
| 1044 | if(value == folder){ |
---|
| 1045 | for(var i=0; i < filters_c['criteria'].length; i++){ |
---|
| 1046 | if(filters_c['criteria'][i].field == 'from'){ |
---|
| 1047 | from = filters_c['criteria'][i].value; |
---|
| 1048 | } |
---|
| 1049 | } |
---|
| 1050 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&from="+from, function(){}); |
---|
| 1051 | return false; |
---|
| 1052 | } |
---|
| 1053 | }); |
---|
| 1054 | } |
---|