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