[5950] | 1 | function outOfficeVerify() { |
---|
| 2 | DataLayer.remove('filter', false); |
---|
| 3 | var filters = DataLayer.get("filter"); |
---|
| 4 | var outoffice_active = false; |
---|
[6021] | 5 | outoffice = false; |
---|
[5950] | 6 | for(var index in filters){ |
---|
| 7 | if(filters[index].id == "vacation") |
---|
| 8 | outoffice = true; |
---|
| 9 | if(filters[index].id == "vacation" && filters[index].enabled == "true"){ |
---|
| 10 | write_msg(get_lang("Attention, you are in out of office mode."), true); |
---|
| 11 | outoffice_active = true; |
---|
| 12 | break; |
---|
| 13 | } |
---|
| 14 | } |
---|
[6021] | 15 | if(!outoffice_active) |
---|
| 16 | clean_msg(); |
---|
[5950] | 17 | } |
---|
| 18 | |
---|
[5591] | 19 | valid_save = function(){ |
---|
[5662] | 20 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
[5598] | 21 | if(list_container.find('[name="name"]').attr("disabled") != "disabled") |
---|
[5591] | 22 | { |
---|
[5598] | 23 | if($.trim(list_container.find('[name="name"]').val()) == ""){ |
---|
[5801] | 24 | $.Zebra_Dialog(get_lang("No name filled"),{ |
---|
[5662] | 25 | 'onClose': function(caption) { |
---|
| 26 | list_container.find('[name="name"]').focus(); |
---|
| 27 | } |
---|
| 28 | }); |
---|
| 29 | accord.accordion('activate',0); |
---|
[5591] | 30 | return false; |
---|
[5598] | 31 | }else if($.trim(list_container.find('[name="name"]').val()) == "vacation"){ |
---|
[5801] | 32 | $.Zebra_Dialog(get_lang("Invalid name, 'vacation' is a reserved word"),{ |
---|
[5662] | 33 | 'onClose': function(caption) { |
---|
| 34 | list_container.find('[name="name"]').val("").focus(); |
---|
| 35 | } |
---|
| 36 | }); |
---|
| 37 | accord.accordion('activate',0); |
---|
[5591] | 38 | return false; |
---|
| 39 | }else{ |
---|
| 40 | filter_list = DataLayer.get("filter", true); |
---|
| 41 | var error = false; |
---|
| 42 | $.each(filter_list, function(index, value){ |
---|
[5598] | 43 | if(filter_list[index].name == list_container.find('[name="name"]').val()){ |
---|
[5801] | 44 | $.Zebra_Dialog(get_lang("There is already a filter with this name"),{ |
---|
[5662] | 45 | 'onClose': function(caption) { |
---|
| 46 | list_container.find('[name="name"]').val("").focus(); |
---|
| 47 | } |
---|
| 48 | }); |
---|
| 49 | accord.accordion('activate',0); |
---|
[5591] | 50 | error = true; |
---|
| 51 | return; |
---|
| 52 | } |
---|
| 53 | }); |
---|
| 54 | if(error){ |
---|
| 55 | return false; |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | var criteria = ""; |
---|
[5598] | 60 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
[6126] | 61 | var er_num = /^[0-9]+$/; |
---|
| 62 | |
---|
| 63 | if($(".sizeRule").val() != "" && er_num.test($(".sizeRule").val()) == false) { |
---|
| 64 | $.Zebra_Dialog(get_lang("Size rule must be a number"),{ |
---|
| 65 | 'onClose': function(caption) { |
---|
| 66 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 67 | } |
---|
| 68 | }); |
---|
| 69 | accord.accordion('activate',0); |
---|
| 70 | return false; |
---|
| 71 | } |
---|
[5591] | 72 | $.each(criteria_list, function(index, value){ |
---|
| 73 | criteria += $.trim($(criteria_list[index]).val()); |
---|
| 74 | }); |
---|
[6144] | 75 | if(criteria == ""){ |
---|
[5801] | 76 | $.Zebra_Dialog(get_lang("No criteria filled"),{ |
---|
[5662] | 77 | 'onClose': function(caption) { |
---|
| 78 | list_container.find('[name="criteriaValue[]"]:first').focus(); |
---|
| 79 | } |
---|
| 80 | }); |
---|
| 81 | accord.accordion('activate',0); |
---|
[5591] | 82 | return false; |
---|
| 83 | } |
---|
[5598] | 84 | if(list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").length){ |
---|
| 85 | if($.trim(list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").val()) == ""){ |
---|
[5801] | 86 | $.Zebra_Dialog(get_lang("Fill the action value"),{ |
---|
[5662] | 87 | 'onClose': function(caption) { |
---|
| 88 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 89 | } |
---|
| 90 | }); |
---|
[5591] | 91 | return false; |
---|
| 92 | } |
---|
[6126] | 93 | var er_mail = RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/); |
---|
| 94 | if(er_mail.test($.trim(list_container.find('[value="redirect"]:checked').parent().find("input:text, textarea").val())) == false){ |
---|
| 95 | $.Zebra_Dialog(get_lang("Invalid mail"),{ |
---|
| 96 | 'onClose': function(caption) { |
---|
| 97 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 98 | } |
---|
| 99 | }); |
---|
| 100 | return false; |
---|
| 101 | } |
---|
[5591] | 102 | } |
---|
| 103 | return true; |
---|
| 104 | }; |
---|
| 105 | |
---|
[5341] | 106 | bytes2Size = function(bytes) { |
---|
| 107 | var sizes = ['B', 'KB', 'MB', 'GB', 'TB']; |
---|
| 108 | if (bytes === 0) return 'n/a'; |
---|
| 109 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); |
---|
| 110 | var size = (i<2) ? Math.round((bytes / Math.pow(1024, i))) : Math.round((bytes / Math.pow(1024, i)) * 100)/100; |
---|
| 111 | return size + ' ' + sizes[i]; |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | flags2Class = function(cellvalue) { |
---|
| 115 | var flags_enum = cellvalue.split(','); |
---|
| 116 | var classes = ''; |
---|
| 117 | for (var i=0; i<flags_enum.length; i++){ |
---|
| 118 | classes += '<span class="icon-'+flags_enum[i].toLowerCase()+'"> </span>'; |
---|
| 119 | } |
---|
| 120 | return classes; |
---|
| 121 | }; |
---|
| 122 | |
---|
| 123 | date2Time = function (timestamp) { |
---|
| 124 | var date = new Date(); |
---|
| 125 | if ((date.getTime() - timestamp) < (24*60*60*1000)) { |
---|
| 126 | return '<span class="timable" title="'+timestamp+'"> </span>'; |
---|
| 127 | } else { |
---|
| 128 | date = new Date(timestamp); |
---|
| 129 | var b = date.toISOString().split("T")[0].split("-"); |
---|
| 130 | var c = b[2] + "/" + b[1] + "/" + b[0]; |
---|
| 131 | return '<span class="datable">' + c + '</span>'; |
---|
| 132 | } |
---|
| 133 | }; |
---|
| 134 | |
---|
| 135 | keys = function( object ){ |
---|
| 136 | |
---|
| 137 | var array = []; |
---|
| 138 | |
---|
| 139 | for( var key in object ) |
---|
| 140 | array[ array.length ] = key; |
---|
| 141 | |
---|
| 142 | return( array ); |
---|
| 143 | |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | showDetails = function( filter ){ |
---|
| 147 | |
---|
| 148 | form.get(0).reset(); |
---|
| 149 | |
---|
| 150 | nameObj.val( filter.name ); |
---|
[5539] | 151 | nameObj.attr("disabled", "disabled"); |
---|
[5341] | 152 | for( var i = 0; i < filter.criteria.length; i++ ){ |
---|
[5630] | 153 | criterias.filter( '[value="' + filter.criteria[i].field + '"]' ) |
---|
| 154 | .siblings( '[name="criteriaOperator[]"]' ).val( filter.criteria[i].operator ).end() |
---|
| 155 | .siblings( '[name="criteriaValue[]"]' ).val( filter.criteria[i].value ); |
---|
[5341] | 156 | } |
---|
| 157 | for( var i = 0; i < filter.actions.length; i++ ){ |
---|
[5539] | 158 | actions.filter( '[value="' + filter.actions[i].type + '"]' ).attr("checked", "True"); |
---|
| 159 | actions.filter( '[value="' + filter.actions[i].type + '"]' ).val( filter.actions[i].type ) |
---|
| 160 | .siblings( '[name="actionParameter[]"]' ).val( filter.actions[i].parameter ); |
---|
| 161 | if(filter.actions[i].type == "redirect") |
---|
| 162 | actions.siblings('[name="addressRedirect"]').val(filter.actions[i].parameter); |
---|
| 163 | if(filter.actions[i].type == "reject") |
---|
| 164 | actions.siblings('[name="messageReject"]').val(filter.actions[i].parameter); |
---|
[5632] | 165 | if(filter.actions[i].type == "fileinto" || filter.actions[i].type == "setflag") |
---|
| 166 | actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected"); |
---|
[5341] | 167 | } |
---|
[5539] | 168 | //isExact.val( filter.isExact != "false"? "and" : "or" ); |
---|
| 169 | isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True"); |
---|
[5341] | 170 | } |
---|
| 171 | |
---|
| 172 | /* --- ------ --- */ |
---|
| 173 | |
---|
| 174 | DataLayer.codec( "filter", "detail", { |
---|
| 175 | |
---|
| 176 | decoder: function( form ){ |
---|
| 177 | if( form.vacation ) |
---|
| 178 | return { |
---|
[5539] | 179 | criteria: [{ value: "vacation", operator: "", field: "vacation" }], |
---|
| 180 | actions: [{ parameter: form.vacation, type: "vacation" }], |
---|
[5341] | 181 | id: "vacation", |
---|
| 182 | name: "vacation", |
---|
[5627] | 183 | isExact: false, |
---|
| 184 | applyMessages : "", |
---|
[5902] | 185 | enabled : true |
---|
[5341] | 186 | } |
---|
| 187 | |
---|
[6143] | 188 | var apply_messages_ = keys(selectedMessages); |
---|
| 189 | delete selectedMessages; |
---|
[5862] | 190 | |
---|
[6143] | 191 | return { |
---|
[5539] | 192 | //id: form.name, |
---|
[6168] | 193 | name: form.name ? form.name.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') : nameObj.val().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), |
---|
[5341] | 194 | isExact: ( form.isExact === "and" ), |
---|
[5539] | 195 | criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){ |
---|
[5341] | 196 | return (!form.criteriaValue[i]) ? null: |
---|
[6143] | 197 | { |
---|
[6168] | 198 | value: form.criteriaValue[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), |
---|
[6143] | 199 | operator: criteriaOperator, |
---|
[6168] | 200 | field: form.criteriaType[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') |
---|
[6143] | 201 | }; |
---|
[5341] | 202 | }), |
---|
| 203 | actions: $.map( form.actionType || [], function( type, i ){ |
---|
[5539] | 204 | var the_parameter = form.actionParameter[i]; |
---|
| 205 | |
---|
| 206 | !the_parameter ? the_parameter = form.actionParameter[i+1] : ""; |
---|
| 207 | if (type == 'fileinto') { |
---|
| 208 | the_parameter = form.valueFileInto; |
---|
| 209 | } |
---|
| 210 | if (type == 'reject') { |
---|
| 211 | the_parameter = form.messageReject; |
---|
| 212 | } |
---|
| 213 | if (type == 'fileintoInbox') { |
---|
[5591] | 214 | if(!$('[value="fileintoInbox"]').parent().hasClass("hidden")){ |
---|
| 215 | type = 'fileinto'; |
---|
| 216 | the_parameter = 'INBOX'; |
---|
| 217 | }else{ |
---|
| 218 | return; |
---|
| 219 | } |
---|
[5539] | 220 | } |
---|
| 221 | if (type == 'fileintoTrash') { |
---|
| 222 | type = 'fileinto'; |
---|
| 223 | the_parameter = 'INBOX/Trash'; |
---|
| 224 | } |
---|
| 225 | if (type == 'redirect') { |
---|
| 226 | the_parameter = form.addressRedirect; |
---|
| 227 | } |
---|
| 228 | if (type == 'setflag') { |
---|
| 229 | the_parameter = form.valueSetFlag; |
---|
| 230 | } |
---|
[5341] | 231 | return (!type) ? null: |
---|
[5539] | 232 | {parameter: the_parameter, type: type }; |
---|
[5341] | 233 | |
---|
| 234 | }), |
---|
[5902] | 235 | enabled : true, |
---|
[5862] | 236 | //applyMessages: allMessages? !$.isEmptyObject( selectedMessages ) ? |
---|
| 237 | //keys( selectedMessages ) : allMessages : "" |
---|
| 238 | applyMessages: apply_messages_ |
---|
| 239 | //applyMessages: "" |
---|
[6143] | 240 | }; |
---|
[5341] | 241 | }, |
---|
| 242 | |
---|
| 243 | encoder: function( filters ){ |
---|
| 244 | var rules = []; |
---|
| 245 | |
---|
| 246 | for( var id in filters ) |
---|
| 247 | rules[ rules.length ] = filters[id]; |
---|
| 248 | |
---|
| 249 | return { rules: rules }; |
---|
| 250 | |
---|
| 251 | } |
---|
[5862] | 252 | |
---|
[5341] | 253 | }); |
---|
| 254 | |
---|
| 255 | DataLayer.codec( "folder", "select", { |
---|
| 256 | |
---|
| 257 | decoder:function(){ |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | }, |
---|
| 262 | encoder:function( data ){ |
---|
| 263 | |
---|
| 264 | var tree1 = [], tree2 = [], tree3 = []; |
---|
| 265 | |
---|
| 266 | for (var i=0; i<data.length; i++) { |
---|
| 267 | |
---|
| 268 | if (/^INBOX/.test(data[i].id)) { |
---|
| 269 | if (!unorphanize(tree1, data[i])) { |
---|
| 270 | data[i].children = []; |
---|
| 271 | tree1.push(data[i]); |
---|
| 272 | } |
---|
| 273 | } |
---|
| 274 | else if (/^user/.test(data[i].id)) { |
---|
| 275 | if (!unorphanize(tree2, data[i])) { |
---|
| 276 | data[i].children = []; |
---|
| 277 | tree2.push(data[i]); |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | else if (/^local_messages/.test(data[i].id)) { |
---|
| 281 | if (!unorphanize(tree3, data[i])) { |
---|
| 282 | data[i].children = []; |
---|
| 283 | tree3.push(data[i]); |
---|
| 284 | } |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | return {folders: [ tree1, tree2, tree3 ]}; |
---|
| 290 | |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | }); |
---|
| 294 | |
---|
[5630] | 295 | |
---|
| 296 | |
---|
| 297 | |
---|
[5341] | 298 | var BASE_PATH = '../prototype/'; |
---|
| 299 | |
---|
| 300 | DataLayer.basePath = BASE_PATH + "REST.php?q="; |
---|
| 301 | DataLayer.dispatchPath = BASE_PATH; |
---|
| 302 | |
---|
| 303 | var selectedMessages = {}; |
---|
| 304 | var allMessages = false; |
---|
| 305 | |
---|
[5630] | 306 | function block_user_email(email) { |
---|
| 307 | //var id = "block_"+email; |
---|
| 308 | var idd = email; |
---|
[5762] | 309 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 310 | DataLayer.remove('filter', false); |
---|
| 311 | var filters = DataLayer.get('filter'); |
---|
| 312 | //var filters = DataLayer.get("filter", true); |
---|
[5654] | 313 | for(var index in filters){ |
---|
| 314 | if(filters[index].name == email) { |
---|
[5801] | 315 | if(confirm(get_lang("This user is already blocked. Would you like to unlock it?"))) { |
---|
[5655] | 316 | DataLayer.remove( 'filter', filters[index].id ); |
---|
[5762] | 317 | DataLayer.commit("filter", false, function(){ |
---|
[5801] | 318 | $.Zebra_Dialog(get_lang("Lock User") + " " + email + " " + get_lang("removed")); |
---|
[5762] | 319 | list_filters(); |
---|
| 320 | }); |
---|
[5654] | 321 | return true; |
---|
[5662] | 322 | }else |
---|
| 323 | return true; |
---|
[5654] | 324 | } |
---|
| 325 | } |
---|
[5801] | 326 | if(confirm(get_lang("Want to block the user") + " " + email + "?")){ |
---|
[5762] | 327 | DataLayer.put( 'filter', idd, |
---|
[5630] | 328 | { name: email, isExact: false, |
---|
| 329 | criteria:{ 0: {value: email, operator: "=", field: "from"} }, |
---|
[6176] | 330 | actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}}, |
---|
[5630] | 331 | enabled: true, |
---|
| 332 | id: email, |
---|
| 333 | block: true |
---|
| 334 | }); |
---|
[5762] | 335 | DataLayer.commit("filter", false, function(){ |
---|
[5801] | 336 | $.Zebra_Dialog(get_lang("User") + " " + email + " " + get_lang("blocked")); |
---|
[5762] | 337 | list_filters(); |
---|
| 338 | }); |
---|
| 339 | |
---|
| 340 | } |
---|
[5630] | 341 | } |
---|
| 342 | |
---|
[6048] | 343 | function showGridMessages(thiss) { |
---|
| 344 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
| 345 | var criteria_operator_list = list_container.find('[name="criteriaOperator[]"]'); |
---|
| 346 | var criteria_value = ""; |
---|
| 347 | var criteria = ""; |
---|
| 348 | $.each(criteria_list, function(index, value){ |
---|
| 349 | criteria += $.trim($(criteria_list[index]).val()) + ","; |
---|
| 350 | }); |
---|
| 351 | var criteria_ = criteria.split(","); |
---|
| 352 | var criteria_operator = ""; |
---|
| 353 | $.each(criteria_operator_list, function(index, value){ |
---|
| 354 | criteria_operator += $.trim($(criteria_list[index]).val()) != "" ? index + "," : ","; |
---|
| 355 | criteria_value += $.trim($(criteria_operator_list[index]).val()) + ","; |
---|
| 356 | }); |
---|
| 357 | var criteria_operator_ = criteria_operator.split(","); |
---|
| 358 | var criteria_value_ = criteria_value.split(","); |
---|
| 359 | var options = ["from", "to", "subject", "body", "size"]; |
---|
| 360 | var criterias_ = new Array(); |
---|
| 361 | var j = 0; |
---|
| 362 | for (i in criteria_) { |
---|
| 363 | if(criteria_[i] != "") { |
---|
| 364 | (j == 0) ? criterias_[j] = {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} : criterias_[j] = {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]}; |
---|
| 365 | j++; |
---|
| 366 | } |
---|
| 367 | } |
---|
| 368 | showGridButton = thiss.parent(); |
---|
| 369 | $.ajax({ |
---|
| 370 | url: DataLayer.basePath + 'folder/INBOX/message&' + $.param( {"filter": criterias_} ), |
---|
| 371 | dataType: 'json', |
---|
| 372 | success: function(data){ |
---|
| 373 | allMessages = data; |
---|
| 374 | |
---|
| 375 | var parametro = { "filter": ( data != false ? [ "msgNumber", "IN", data ] : criterias_ ) }; |
---|
| 376 | |
---|
| 377 | if (typeof grid !== "undefined") { |
---|
| 378 | grid.jqGrid( 'setGridParam', { url: DataLayer.basePath + 'folder/INBOX/message&' + $.param( parametro ) } ).trigger( 'reloadGrid' ); |
---|
| 379 | //return; |
---|
| 380 | } |
---|
| 381 | grid = showGridButton.siblings(".fields-search-messages-grid, .fields-search-messages-grid-pager") |
---|
| 382 | .removeClass('hidden').filter(".fields-search-messages-grid").trigger( 'reloadGrid' ).jqGrid({ |
---|
| 383 | //url: DataLayer.basePath + 'folder/INBOX/message&' + $.param( {"filter": [ "msgNumber", "IN", data ]} ), |
---|
| 384 | url: DataLayer.basePath + 'folder/INBOX/message&' + $.param( parametro ), |
---|
| 385 | datatype: "json", |
---|
| 386 | mtype: 'GET', |
---|
[6143] | 387 | colNames:['#', 'De', 'Assunto', 'Data', 'Tamanho'], |
---|
[6048] | 388 | colModel:[ |
---|
| 389 | {name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false}, |
---|
[6143] | 390 | {name:'from.email',index:'msg_number', width:130, sortable:false}, |
---|
[6048] | 391 | {name:'subject',index:'subject', width:250, sortable:false}, |
---|
| 392 | {name:'timestamp',index:'timestamp', width:65, align:"center", sortable:false, formatter:date2Time}, |
---|
| 393 | {name:'size',index:'size', width:50, align:"right", sortable:false, formatter:bytes2Size} |
---|
| 394 | ], |
---|
| 395 | jsonReader : { |
---|
| 396 | root:"rows", |
---|
| 397 | page: "page", |
---|
| 398 | total: "total", |
---|
| 399 | records: "records", |
---|
| 400 | repeatitems: false, |
---|
| 401 | id: "0" |
---|
| 402 | }, |
---|
| 403 | rowNum:10, |
---|
| 404 | //rowList:[10,25,50], |
---|
| 405 | rowList:[10], |
---|
| 406 | pager: '#fields-search-messages-grid-pager', |
---|
| 407 | sortname: 'id', |
---|
| 408 | viewrecords: true, |
---|
| 409 | sortorder: "desc", |
---|
| 410 | multiselect: true, |
---|
| 411 | autowidth: true, |
---|
| 412 | reloadAfterEdit: true, |
---|
| 413 | reloadAfterSubmit: true, |
---|
| 414 | height:200, |
---|
| 415 | loadComplete: function(data) { |
---|
| 416 | // // aplica o contador |
---|
| 417 | // jQuery('.timable').each(function (i) { |
---|
| 418 | // jQuery(this).countdown({ |
---|
| 419 | // since: new Date(parseInt(this.title)), |
---|
| 420 | // significant: 1, |
---|
| 421 | // layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', |
---|
| 422 | // description: ' atrás' |
---|
| 423 | // }); |
---|
| 424 | // }); |
---|
| 425 | }, |
---|
| 426 | onSelectRow: function (id, selected) { |
---|
| 427 | if( selected ) |
---|
| 428 | { |
---|
| 429 | selectedMessages[ id ] = true; |
---|
| 430 | } |
---|
| 431 | else |
---|
| 432 | { |
---|
| 433 | delete selectedMessages[ id ]; |
---|
| 434 | } |
---|
| 435 | }, |
---|
| 436 | caption: 'Mensagens que atendem aos critérios' |
---|
| 437 | }); // end jqGrid |
---|
| 438 | } // end success |
---|
| 439 | }); // end ajax |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | |
---|
[5539] | 443 | function list_filters(html){ |
---|
[6021] | 444 | outOfficeVerify(); |
---|
[5539] | 445 | if(html){ |
---|
| 446 | if( ! $(".filters-windows").length ) |
---|
[5761] | 447 | container = $('.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html( html ).find(".expresso-window-container"); |
---|
| 448 | list_container = $('.expressomail-module-container').find(".rule-list-container"); |
---|
[5539] | 449 | } |
---|
| 450 | list_container = $(".expresso-window-filters").dialog({ |
---|
| 451 | width:700, |
---|
| 452 | modal: true, |
---|
| 453 | resizable: false, |
---|
| 454 | closeOnEscape:true, |
---|
| 455 | close:function(event, ui) { |
---|
| 456 | event.stopPropagation(); |
---|
[5598] | 457 | if(list_container.find(".cancel").length) |
---|
[5627] | 458 | list_container.find(".cancel").trigger('click'); |
---|
| 459 | $(".dialog-head-buttonpane").hide(); |
---|
[5539] | 460 | }, |
---|
| 461 | open: function () { |
---|
| 462 | $(".ui-dialog .ui-dialog-titlebar") |
---|
| 463 | .append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>') |
---|
| 464 | .find('.ui-dialog-titlebar-minimize').click(function() { |
---|
| 465 | $(".ui-dialog-buttonpane, .ui-dialog-content").toggle(); |
---|
| 466 | $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin'); |
---|
| 467 | }); |
---|
[5627] | 468 | $(".dialog-head-buttonpane").show(); |
---|
[5539] | 469 | }, |
---|
| 470 | autoOpen: false, |
---|
| 471 | buttons: [{ |
---|
[5801] | 472 | text : get_lang("Close"), |
---|
[5539] | 473 | click : function() { |
---|
| 474 | $( this ).dialog( "close" ); |
---|
| 475 | } |
---|
| 476 | }] |
---|
| 477 | }); |
---|
| 478 | $(".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>"); |
---|
| 479 | $(".dialog-head-buttonpane").css("padding", "5px"). |
---|
[5801] | 480 | 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(); |
---|
[5539] | 481 | |
---|
| 482 | $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE"); |
---|
[5598] | 483 | var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true)); |
---|
| 484 | list_container.html(list).find(".button").button(); |
---|
[5543] | 485 | |
---|
| 486 | list_container.find(".rule-list").selectable({ |
---|
| 487 | selecting: function(event, ui) { |
---|
| 488 | $(ui.selecting).find(':checkbox').attr('checked', true); |
---|
| 489 | }, |
---|
| 490 | unselecting: function(event, ui) { |
---|
| 491 | $(ui.unselecting).find(':checkbox').attr('checked', false); |
---|
| 492 | } |
---|
| 493 | }); |
---|
| 494 | |
---|
[5598] | 495 | list_container.find( ".menu-control .button" ).filter(".update").button({ |
---|
[5543] | 496 | icons: { |
---|
| 497 | primary: "ui-icon-pencil" |
---|
| 498 | }, |
---|
| 499 | text: false |
---|
| 500 | }).click(function(){ |
---|
[5627] | 501 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5543] | 502 | var filters = DataLayer.get( 'filter', true); |
---|
| 503 | for(var i =0; i < filters.length; i++){ |
---|
| 504 | if(filters[i].id == id){ |
---|
| 505 | filters = filters[i]; |
---|
| 506 | break; |
---|
| 507 | } |
---|
| 508 | } |
---|
[5801] | 509 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5543] | 510 | var details_container = $(".expresso-window-filters").html(html); |
---|
| 511 | if(filters.name != "vacation"){ |
---|
| 512 | form = container.find("form"); |
---|
| 513 | criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' ); |
---|
| 514 | actions = details_container.find( 'fieldset input[name="actionType[]"]' ); |
---|
| 515 | nameObj = details_container.find( 'input[name="name"]' ); |
---|
| 516 | isExact = details_container.find( 'input[name="isExact"]' ); |
---|
| 517 | showDetails(filters); |
---|
[5598] | 518 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 519 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5539] | 520 | accord.accordion('activate',1); |
---|
[5930] | 521 | }).end().filter(".forth2").click(function(){ |
---|
| 522 | accord.accordion('activate',2); |
---|
[5539] | 523 | }).end().filter(".back").click(function(){ |
---|
| 524 | accord.accordion('activate',0); |
---|
[5930] | 525 | }).end().filter(".back2").click(function(){ |
---|
| 526 | accord.accordion('activate',1); |
---|
[5539] | 527 | }).end().filter(".cancel").click(function(){ |
---|
| 528 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 529 | }).end().filter(".submit").click(function(){ |
---|
[5543] | 530 | if(nameObj) |
---|
| 531 | nameObj.attr("disabled", "false"); |
---|
[5591] | 532 | if(valid_save()) |
---|
| 533 | $(this).submit(); |
---|
| 534 | else |
---|
| 535 | return; |
---|
[5662] | 536 | DataLayer.commit( 'filter', false,function(){ |
---|
| 537 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 538 | }); |
---|
[6048] | 539 | }).end().filter('.button.search').click(function() { |
---|
| 540 | /* Valida se o usuário preencheu as informações */ |
---|
| 541 | if(valid_save()) |
---|
| 542 | showGridMessages($(this)); |
---|
| 543 | else |
---|
| 544 | return; |
---|
| 545 | }) |
---|
[5543] | 546 | }else{ |
---|
[5598] | 547 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 548 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 549 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5539] | 550 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 551 | }).end().filter(".submit").click(function(){ |
---|
| 552 | $(this).submit(); |
---|
[5662] | 553 | DataLayer.commit( 'filter', false,function(){ |
---|
| 554 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 555 | }); |
---|
[5539] | 556 | }); |
---|
[5543] | 557 | details_container.find('[name="vacation"]').val(filters.actions[0].parameter); |
---|
| 558 | } |
---|
[5539] | 559 | }); |
---|
[5543] | 560 | }).end() |
---|
| 561 | .filter(".enable").button({ |
---|
| 562 | icons: { |
---|
[5648] | 563 | primary: "ui-icon-circle-close" |
---|
[5543] | 564 | }, |
---|
| 565 | text: false |
---|
| 566 | }).click(function(){ |
---|
[6021] | 567 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 568 | DataLayer.put( 'filter', id, { enabled: false }); |
---|
[5627] | 569 | DataLayer.commit("filter", false,function(){ |
---|
| 570 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 571 | }); |
---|
[5543] | 572 | }).end() |
---|
| 573 | |
---|
| 574 | .filter(".disable").button({ |
---|
| 575 | icons: { |
---|
[5648] | 576 | primary: "ui-icon-circle-check" |
---|
[5543] | 577 | }, |
---|
| 578 | text: false |
---|
| 579 | }).click(function(){ |
---|
[5627] | 580 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 581 | DataLayer.put( 'filter', id, { enabled: true }); |
---|
[5627] | 582 | DataLayer.commit("filter", false,function(){ |
---|
| 583 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 584 | }); |
---|
[5543] | 585 | }).end() |
---|
| 586 | |
---|
| 587 | .filter(".close").button({ |
---|
| 588 | icons: { |
---|
| 589 | primary: "ui-icon-close" |
---|
| 590 | }, |
---|
| 591 | text: false |
---|
[5648] | 592 | }).click(function(event){ |
---|
[5662] | 593 | var filter_name = $(event.target).parents("li.rule").find('.id').val(); |
---|
[5902] | 594 | var filter_screen_name = $(event.target).parents("li.rule").find('.title').html(); |
---|
| 595 | $.Zebra_Dialog(get_lang("Are you sure to delete the filter") + ": <strong>"+filter_screen_name+"</strong>",{ |
---|
[5662] | 596 | 'type': 'question', |
---|
[5801] | 597 | 'title': get_lang("Exclusion Confirmation"), |
---|
[5662] | 598 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
| 599 | 'onClose': function(caption) { |
---|
| 600 | if(caption == get_lang('Yes')){ |
---|
[5762] | 601 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 602 | DataLayer.remove('filter', false); |
---|
| 603 | DataLayer.get('filter'); |
---|
[5662] | 604 | DataLayer.remove( 'filter', filter_name); |
---|
| 605 | DataLayer.commit("filter", false,function(){ |
---|
| 606 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 607 | }); |
---|
| 608 | }else{ |
---|
| 609 | $(event.target).removeClass("ui-selected").parent().removeClass("ui-selected"); |
---|
| 610 | } |
---|
| 611 | } |
---|
[5543] | 612 | }); |
---|
| 613 | }).end().removeClass("ui-button-icon-only"); |
---|
| 614 | |
---|
[6021] | 615 | $(".button.allenable").click(function(){ |
---|
[5987] | 616 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[5995] | 617 | DataLayer.put( 'filter', o.innerHTML, { enabled: true }); |
---|
[5987] | 618 | }); |
---|
| 619 | DataLayer.commit("filter", false, function(){ |
---|
| 620 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 621 | }); |
---|
| 622 | }); |
---|
[5985] | 623 | |
---|
[6021] | 624 | $(".button.alldisable").click(function(){ |
---|
[5987] | 625 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[5995] | 626 | DataLayer.put( 'filter', o.innerHTML, { enabled: false }); |
---|
[5987] | 627 | }); |
---|
| 628 | DataLayer.commit("filter", false, function(){ |
---|
| 629 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 630 | }); |
---|
| 631 | }); |
---|
| 632 | |
---|
| 633 | |
---|
| 634 | |
---|
[6021] | 635 | $(".button.alldelete").click(function(){ |
---|
[5985] | 636 | $.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{ |
---|
| 637 | 'type': 'question', |
---|
| 638 | 'title': get_lang("Exclusion Confirmation"), |
---|
| 639 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
| 640 | 'onClose': function(caption) { |
---|
| 641 | if(caption == get_lang('Yes')){ |
---|
| 642 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 643 | DataLayer.remove('filter', false); |
---|
| 644 | DataLayer.get('filter'); |
---|
| 645 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
| 646 | DataLayer.remove( 'filter', o.innerHTML ); |
---|
| 647 | }); |
---|
| 648 | DataLayer.commit("filter", false,function(){ |
---|
| 649 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 650 | }); |
---|
| 651 | }else{ |
---|
| 652 | return true; |
---|
| 653 | } |
---|
| 654 | } |
---|
| 655 | }); |
---|
| 656 | }); |
---|
| 657 | |
---|
[5930] | 658 | var aa = 0; |
---|
| 659 | |
---|
[5598] | 660 | list_container.parent().find(".button.add:first").click(function(){ |
---|
| 661 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 662 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 663 | list_container.html(html); |
---|
| 664 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 665 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5543] | 666 | accord.accordion('activate',1); |
---|
[5930] | 667 | }).end().filter(".forth2").click(function(){ |
---|
| 668 | accord.accordion('activate',2); |
---|
[5543] | 669 | }).end().filter(".back").click(function(){ |
---|
| 670 | accord.accordion('activate',0); |
---|
[5930] | 671 | }).end().filter(".back2").click(function(){ |
---|
| 672 | accord.accordion('activate',1); |
---|
[5543] | 673 | }).end().filter(".cancel").click(function(){ |
---|
| 674 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[5862] | 675 | }).end().filter(".submit").click(function() { |
---|
[5591] | 676 | if(valid_save()) |
---|
| 677 | $(this).submit(); |
---|
| 678 | else |
---|
| 679 | return; |
---|
[5627] | 680 | DataLayer.commit( 'filter',false,function(){ |
---|
| 681 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 682 | }); |
---|
[5862] | 683 | }).end().filter('.button.search').click(function() { |
---|
| 684 | if(valid_save()) |
---|
[6048] | 685 | showGridMessages($(this)); |
---|
[5862] | 686 | else |
---|
| 687 | return; |
---|
| 688 | }); // end function click |
---|
| 689 | }); // end DataLayer.render |
---|
[5543] | 690 | }); |
---|
[5598] | 691 | list_container.parent().find(".button.add.vacation").click(function(){ |
---|
| 692 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 693 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 694 | list_container.html(html); |
---|
| 695 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 696 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 697 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5543] | 698 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 699 | }).end().filter(".submit").click(function(){ |
---|
| 700 | $(this).submit(); |
---|
[5627] | 701 | DataLayer.commit( 'filter',false,function(){ |
---|
| 702 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 703 | }); |
---|
[5543] | 704 | }); |
---|
| 705 | }); |
---|
| 706 | }); |
---|
[5539] | 707 | } |
---|
[5782] | 708 | function init_filters(){ |
---|
| 709 | var html = DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {}); |
---|
| 710 | list_filters(html); |
---|
| 711 | } |
---|