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