[2] | 1 | /**************************************************************************\ |
---|
| 2 | Início |
---|
| 3 | \**************************************************************************/ |
---|
[832] | 4 | function searchE() |
---|
| 5 | { |
---|
[2] | 6 | this.searchW = new Array; |
---|
| 7 | this.name_box_search = ""; |
---|
| 8 | this.all_boxes = new Array; |
---|
| 9 | this.type = ""; |
---|
[1622] | 10 | this.txtfields = new Array("txt_ass","txt_de","txt_body","txt_para","txt_cc","txt_cco", |
---|
| 11 | "since_date", "before_date", "on_date"); |
---|
| 12 | this.selectFields = new Array("flagged", "seen", "answered", "recent"); |
---|
[2] | 13 | } |
---|
| 14 | |
---|
| 15 | //Monta os forms dentro da janela; |
---|
| 16 | searchE.prototype.showForms = function(value){ |
---|
| 17 | // Principal |
---|
| 18 | if(!Element("window_search")) { |
---|
| 19 | var form_search = document.createElement("DIV"); |
---|
| 20 | form_search.style.visibility = 'hidden'; |
---|
| 21 | form_search.style.top = '0px'; |
---|
| 22 | form_search.style.left = '0px'; |
---|
| 23 | form_search.id = "window_search"; |
---|
| 24 | document.body.appendChild(form_search); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | // Pesquisa |
---|
| 28 | if(!Element("div_form_search")){ |
---|
| 29 | var div_form_search = document.createElement("DIV"); |
---|
| 30 | div_form_search.id = "div_form_search"; |
---|
| 31 | div_form_search.style.position = "absolute"; |
---|
| 32 | div_form_search.style.left = "10px"; |
---|
| 33 | div_form_search.style.top = "10px"; |
---|
[1622] | 34 | div_form_search.style.width = "784px"; |
---|
| 35 | div_form_search.style.height = "418px"; |
---|
[2] | 36 | div_form_search.style.overflow = "hidden"; |
---|
| 37 | div_form_search.innerHTML = ""; |
---|
| 38 | var call_form_search = EsearchE.mount_form(); |
---|
| 39 | div_form_search.appendChild(call_form_search); |
---|
[156] | 40 | form_search.appendChild(div_form_search); |
---|
[2] | 41 | |
---|
[1622] | 42 | Calendar._TT['WEEKEND'] = '0,6'; // hack |
---|
| 43 | Calendar._TT['DAY_FIRST'] = 'Mostrar %s primeiro'; |
---|
| 44 | Calendar.setup({ |
---|
| 45 | inputField : 'since_date', |
---|
| 46 | button : 'since_date-trigger', |
---|
| 47 | ifFormat : '%d/%m/%Y', |
---|
| 48 | daFormat : '%d/%m/%Y' |
---|
| 49 | }); |
---|
| 50 | |
---|
| 51 | Calendar.setup({ |
---|
| 52 | inputField : 'before_date', |
---|
| 53 | button : 'before_date-trigger', |
---|
| 54 | ifFormat : '%d/%m/%Y', |
---|
| 55 | daFormat : '%d/%m/%Y' |
---|
| 56 | }); |
---|
| 57 | |
---|
| 58 | Calendar.setup({ |
---|
| 59 | inputField : 'on_date', |
---|
| 60 | button : 'on_date-trigger', |
---|
| 61 | ifFormat : '%d/%m/%Y', |
---|
| 62 | daFormat : '%d/%m/%Y' |
---|
| 63 | }); |
---|
| 64 | |
---|
[2] | 65 | } |
---|
| 66 | |
---|
| 67 | if(!Element("div_button_search")){ |
---|
| 68 | var div_button_search = document.createElement("DIV"); |
---|
| 69 | div_button_search.id = "div_button_search"; |
---|
| 70 | div_button_search.style.position = "absolute"; |
---|
[1622] | 71 | div_button_search.style.marginLeft = "430px"; |
---|
[2] | 72 | div_button_search.style.top = "223px"; |
---|
[1622] | 73 | div_button_search.style.width = "350px"; |
---|
[2] | 74 | div_button_search.style.height = "25px"; |
---|
[1622] | 75 | div_button_search.innerHTML = "<table style='width: 100%;' border='0' cellpadding='0' cellspacing='0' align='center'>"+ |
---|
[2] | 76 | "<tr>"+ |
---|
[1622] | 77 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Search') + " onclick='EsearchE.func_search()'></td>"+ |
---|
| 78 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Clean') + " onclick='EsearchE.func_clean()'></td>"+ |
---|
| 79 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Close') + " onclick='EsearchE.func_close(\"hidden\")'></td>"+ |
---|
[2] | 80 | "</tr>"+ |
---|
| 81 | "</table>"; |
---|
| 82 | form_search.appendChild(div_button_search); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | if(!Element("table_layer")){ |
---|
[67] | 86 | var table_layer = ""; |
---|
[2] | 87 | } |
---|
| 88 | |
---|
[67] | 89 | if(value == "") |
---|
[69] | 90 | EsearchE.showWindow(Element("window_search")); |
---|
| 91 | |
---|
[2] | 92 | // Cria as caixas postais; |
---|
| 93 | EsearchE.mount_folders(); |
---|
| 94 | |
---|
| 95 | if(value){ |
---|
| 96 | Element("check_all_msg").checked = true; |
---|
| 97 | EsearchE.all_mailboxes(); |
---|
| 98 | EsearchE.func_search(value); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | //Form |
---|
| 104 | searchE.prototype.mount_form = function(value){ |
---|
| 105 | var form_sch = document.createElement("FORM"); |
---|
| 106 | form_sch.id = "form_sch"; |
---|
[1415] | 107 | |
---|
[1622] | 108 | form_sch.innerHTML = '<fieldset style="width:400px; text-align:right; padding: 5px; position:absolute;">' |
---|
[1415] | 109 | + ' <legend>'+get_lang('Inform your search in the text fields')+'</legend>' |
---|
| 110 | + ' <label>'+get_lang("From")+':</label>' |
---|
[1622] | 111 | + ' <input style="margin-left: 6px;" type="text" id="txt_de" size="39">' |
---|
[1415] | 112 | + ' <br style="margin-bottom:15px"/>' |
---|
| 113 | + ' <label>'+get_lang('To')+':</label>' |
---|
[1622] | 114 | + ' <input style="margin-left: 6px;" type="text" id="txt_para" size="39">' |
---|
[1415] | 115 | + ' <br style="margin-bottom:15px"/>' |
---|
| 116 | + ' <label>'+get_lang('Cc')+':</label>' |
---|
[1622] | 117 | + ' <input style="margin-left: 6px;" type="text" id="txt_cc" size="39">' |
---|
[1415] | 118 | + ' <br style="margin-bottom:15px"/>' |
---|
| 119 | + ' <label>'+get_lang('Subject')+':</label>' |
---|
[1622] | 120 | + ' <input style="margin-left: 6px;" type="text" id="txt_ass" size="39">' |
---|
[1415] | 121 | + ' <br style="margin-bottom:15px"/>' |
---|
| 122 | + ' <label>'+get_lang('Message body')+':</label>' |
---|
[1622] | 123 | + ' <input style="margin-left: 6px;" type="text" id="txt_body" size="39">' |
---|
| 124 | |
---|
| 125 | + ' <br style="margin-bottom:30px"/>' |
---|
| 126 | + ' <label>'+get_lang("Since Date")+':</label>' |
---|
| 127 | + ' <input style="margin-left: 6px;" type="text" id="since_date" size="8">' |
---|
| 128 | + ' <img id="since_date-trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
| 129 | + ' <label style="margin-left: 20px;">'+get_lang('Before Date')+':</label>' |
---|
| 130 | + ' <input style="margin-left: 6px;" type="text" id="before_date" size="8">' |
---|
| 131 | + ' <img id="before_date-trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
| 132 | + ' <br style="margin-bottom:15px"/>' |
---|
| 133 | |
---|
| 134 | + ' <label>'+get_lang('On Date')+':</label>' |
---|
| 135 | + ' <input style="margin-left: 6px;" type="text" id="on_date" size="8">' |
---|
| 136 | + ' <img style="margin-right: -8px" id="on_date-trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/> </spam>' |
---|
| 137 | + ' <br style="margin-bottom:30px"/>' |
---|
| 138 | |
---|
| 139 | + ' <label>'+get_lang('Flags')+':</label>' |
---|
| 140 | + ' <select style="width:15em; margin-left: 6px" name="flagged" id="flagged">' |
---|
| 141 | + ' <option value=""/>' |
---|
| 142 | + ' <option value="FLAGGED">'+ get_lang("Flagged") +'</option>' |
---|
| 143 | + ' <option value="UNFLAGGED">'+ get_lang("Unflagged") +'</option>' |
---|
| 144 | + ' </select>' |
---|
| 145 | + ' <br style="margin-bottom:15px"/>' |
---|
| 146 | + ' <select style="width:15em;" name="seen" id="seen">' |
---|
| 147 | + ' <option value=""/>' |
---|
| 148 | + ' <option value="SEEN">'+ get_lang("Seen") +'</option>' |
---|
| 149 | + ' <option value="UNSEEN">'+ get_lang("Unseen") +'</option>' |
---|
| 150 | + ' </select>' |
---|
| 151 | + ' <br style="margin-bottom:15px"/>' |
---|
| 152 | + ' <select style="width:15em;" name="answered" id="answered">' |
---|
| 153 | + ' <option value=""/>' |
---|
| 154 | + ' <option value="ANSWERED">'+ get_lang('Answered/Forwarded') +'</option>' |
---|
| 155 | + ' <option value="UNANSWERED">'+ get_lang('Unanswered/Unforwarded') +'</option>' |
---|
| 156 | + ' </select>' |
---|
| 157 | + ' <br style="margin-bottom:15px"/>' |
---|
| 158 | + ' <select style="width:15em;" name="recent" id="recent">' |
---|
| 159 | + ' <option value=""/>' |
---|
| 160 | + ' <option value="RECENT">'+ get_lang('Recent') +'</option>' |
---|
| 161 | + ' <option value="OLD">'+ get_lang('Old') +'</option>' |
---|
| 162 | + ' </select>' |
---|
| 163 | |
---|
[1415] | 164 | + ' <br style="margin-bottom:60px"/>' |
---|
| 165 | + '</fieldset>' |
---|
[1622] | 166 | + '<fieldset style="width:350px; padding: 5px; position:absolute; margin-left: 414px">' |
---|
[1415] | 167 | + ' <legend>'+get_lang('Search the messages in these folders')+'</legend>' |
---|
| 168 | + ' <div id="folders" style="width:160px; height:150px;float:left;margin-bottom:10px;"></div>' |
---|
| 169 | + ' <div style="float:left;height:100px;padding-top:50px;margin: 0 3px;">' |
---|
| 170 | + ' <input type="button" id="incluir" name="incluir" value=">>" onclick="EsearchE.add_mailboxes()">' |
---|
| 171 | + ' <br style="margin-bottom:15px">' |
---|
| 172 | + ' <input type="button" id="excluir" name="excluir" value="<<" onclick="EsearchE.del_mailboxes()">' |
---|
| 173 | + ' </div>' |
---|
| 174 | + ' <div style="float:left;">' |
---|
| 175 | + ' <select multiple id="sel_search_nm_box1" name="sel_search_nm_box1" style="width:140px;height:150px;"></select>' |
---|
| 176 | + ' </div>' |
---|
| 177 | + ' <br clear="both">' |
---|
| 178 | + ' <input type="checkBox" id="check_all_msg" name="check_all_msg" onclick="EsearchE.all_mailboxes()">' |
---|
| 179 | + ' <b>'+get_lang('In all the folders')+'</b>' |
---|
| 180 | + '</fieldset>'; |
---|
| 181 | |
---|
[2] | 182 | return form_sch; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | // Pastas; |
---|
| 186 | searchE.prototype.mount_folders = function(){ |
---|
| 187 | connector.loadScript("TreeS"); |
---|
| 188 | |
---|
[69] | 189 | if( Element("div_folders_search") == null){ |
---|
[2] | 190 | var div_folders = document.createElement("DIV"); |
---|
| 191 | div_folders.id = "div_folders_search"; |
---|
| 192 | div_folders.style.width = "155px"; |
---|
| 193 | div_folders.style.height = "152px"; |
---|
| 194 | div_folders.style.borderStyle = "outset"; |
---|
| 195 | div_folders.style.borderColor = "black"; |
---|
| 196 | div_folders.style.borderWidth = "1px"; |
---|
| 197 | div_folders.style.background = "#F7F7F7"; |
---|
| 198 | div_folders.style.overflow = "auto"; |
---|
| 199 | div_folders.innerHTML = ""; |
---|
[69] | 200 | var dest_div = Element("folders"); |
---|
[2] | 201 | dest_div.appendChild(div_folders); |
---|
| 202 | } |
---|
| 203 | ttree.make_tree(folders,"div_folders_search","_folders_tree_search","","","",""); |
---|
| 204 | } |
---|
| 205 | |
---|
[156] | 206 | //This func returns the most recent date |
---|
| 207 | function date_comp(a,b) |
---|
| 208 | { |
---|
[645] | 209 | var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g); |
---|
[156] | 210 | data1 = data1[0].substr(0, data1[0].indexOf('--')) |
---|
| 211 | with ( data1 ) |
---|
| 212 | data1 = Date.UTC(substr(6), substr(3, 2), substr(0, 2)); |
---|
[645] | 213 | var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g); |
---|
[156] | 214 | data2 = data2[0].substr(0, data2[0].indexOf('--')) |
---|
| 215 | with ( data2 ) |
---|
| 216 | data2 = Date.UTC(substr(6), substr(3, 2), substr(0, 2)); |
---|
| 217 | return data2 - data1; |
---|
| 218 | } |
---|
[832] | 219 | function date_comp_reverse(a,b) |
---|
| 220 | { |
---|
| 221 | return date_comp(b,a); |
---|
| 222 | } |
---|
[156] | 223 | |
---|
| 224 | function box_comp(a,b) |
---|
| 225 | { |
---|
| 226 | var compare = []; |
---|
| 227 | compare[0] = a.substr(0, a.indexOf('--')); |
---|
| 228 | compare[0] = compare[0].toLowerCase(); |
---|
| 229 | var temp=compare[0]; |
---|
| 230 | compare[1] = b.substr(0, b.indexOf('--')) |
---|
| 231 | compare[1] = compare[1].toLowerCase(); |
---|
| 232 | compare.sort(); |
---|
| 233 | if (temp != compare[0]) |
---|
| 234 | return +1; |
---|
| 235 | else |
---|
| 236 | return -1; |
---|
| 237 | } |
---|
[832] | 238 | function box_comp_reverse(a,b) |
---|
| 239 | { |
---|
| 240 | return box_comp(b,a); |
---|
| 241 | } |
---|
[156] | 242 | |
---|
| 243 | function who_comp(a,b) |
---|
| 244 | { |
---|
| 245 | var compare = []; |
---|
| 246 | compare[0] = a.substr(a.indexOf('--')+2); |
---|
| 247 | compare[0] = compare[0].toLowerCase(); |
---|
| 248 | var temp=compare[0]; |
---|
| 249 | compare[1] = b.substr(b.indexOf('--')+2); |
---|
| 250 | compare[1] = compare[1].toLowerCase(); |
---|
| 251 | compare.sort(); |
---|
| 252 | if (temp != compare[0]) |
---|
| 253 | return +1; |
---|
| 254 | else |
---|
| 255 | return -1; |
---|
| 256 | } |
---|
[832] | 257 | function who_comp_reverse(a,b) |
---|
| 258 | { |
---|
| 259 | return who_comp(b,a); |
---|
| 260 | } |
---|
[156] | 261 | |
---|
| 262 | function subject_comp(a,b) |
---|
| 263 | { |
---|
| 264 | var compare = []; |
---|
| 265 | compare[0] = a.substr(a.indexOf('--')+2); |
---|
| 266 | compare[0] = compare[0].substr(compare[0].indexOf('--')+2); |
---|
| 267 | compare[0] = compare[0].toLowerCase(); |
---|
| 268 | var temp=compare[0]; |
---|
| 269 | compare[1] = b.substr(b.indexOf('--')+2); |
---|
| 270 | compare[1] = compare[1].substr(compare[1].indexOf('--')+2); |
---|
| 271 | compare[1] = compare[1].toLowerCase(); |
---|
| 272 | compare.sort(); |
---|
| 273 | if (temp != compare[0]) |
---|
| 274 | return +1; |
---|
| 275 | else |
---|
| 276 | return -1; |
---|
| 277 | } |
---|
[832] | 278 | function subject_comp_reverse(a,b) |
---|
| 279 | { |
---|
| 280 | return subject_comp(b,a); |
---|
| 281 | } |
---|
[156] | 282 | |
---|
| 283 | function size_comp(a,b) |
---|
| 284 | { |
---|
[645] | 285 | var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g); |
---|
[156] | 286 | data1 = data1[0].substr(data1[0].indexOf('--')+2) |
---|
| 287 | data1 = data1.substr(0,data1.indexOf('--')) |
---|
| 288 | var size_a = parseInt(data1.substr(0,data1.indexOf(' '))); |
---|
| 289 | if (data1.match("k")) |
---|
| 290 | size_a = size_a * 1024; |
---|
| 291 | else |
---|
| 292 | if (data1.match("m")) |
---|
| 293 | size_a = size_a * 1048576; |
---|
[645] | 294 | var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g); |
---|
[156] | 295 | data2 = data2[0].substr(data2[0].indexOf('--')+2) |
---|
| 296 | data2 = data2.substr(0,data2.indexOf('--')) |
---|
| 297 | var size_b = parseInt(data2.substr(0,data2.indexOf(' '))); |
---|
| 298 | if (data2.match("k")) |
---|
| 299 | size_b = size_b * 1024; |
---|
| 300 | else |
---|
| 301 | if (data2.match("m")) |
---|
| 302 | size_b = size_b * 1048576; |
---|
| 303 | return size_b - size_a; |
---|
| 304 | } |
---|
[832] | 305 | function size_comp_reverse(a,b) |
---|
| 306 | { |
---|
| 307 | return size_comp(b,a); |
---|
| 308 | } |
---|
[156] | 309 | |
---|
[832] | 310 | // Form resultado |
---|
[156] | 311 | searchE.prototype.mount_result = function(data,sort_type){ |
---|
[2] | 312 | var nw_array = new Array; |
---|
[156] | 313 | var var_tmp = data.substr(2, data.length - 4); |
---|
| 314 | var_tmp = var_tmp.split("####"); |
---|
[2] | 315 | var cont = parseInt(0); |
---|
[645] | 316 | switch (sort_type) |
---|
| 317 | { |
---|
| 318 | case 'SORTDATE': |
---|
| 319 | var_tmp.sort(date_comp); |
---|
| 320 | break; |
---|
[832] | 321 | case 'SORTDATE_REVERSE': |
---|
| 322 | var_tmp.sort(date_comp_reverse); |
---|
| 323 | break; |
---|
[645] | 324 | case 'SORTBOX': |
---|
| 325 | var_tmp.sort(box_comp); |
---|
| 326 | break; |
---|
[832] | 327 | case 'SORTBOX_REVERSE': |
---|
| 328 | var_tmp.sort(box_comp_reverse); |
---|
| 329 | break; |
---|
[645] | 330 | case 'SORTSUBJECT': |
---|
| 331 | var_tmp.sort(subject_comp); |
---|
| 332 | break; |
---|
[832] | 333 | case 'SORTSUBJECT_REVERSE': |
---|
| 334 | var_tmp.sort(subject_comp_reverse); |
---|
| 335 | break; |
---|
[645] | 336 | case 'SORTWHO': |
---|
| 337 | var_tmp.sort(who_comp); |
---|
| 338 | break; |
---|
[832] | 339 | case 'SORTWHO_REVERSE': |
---|
| 340 | var_tmp.sort(who_comp_reverse); |
---|
| 341 | break; |
---|
[645] | 342 | case 'SORTSIZE': |
---|
| 343 | var_tmp.sort(size_comp); |
---|
| 344 | break; |
---|
[832] | 345 | case 'SORTSIZE_REVERSE': |
---|
| 346 | var_tmp.sort(size_comp_reverse); |
---|
| 347 | break; |
---|
[645] | 348 | default: |
---|
| 349 | var showMsg = 1; |
---|
| 350 | } |
---|
| 351 | |
---|
[2] | 352 | for(var i=0; i < var_tmp.length; i++){ |
---|
[645] | 353 | if(var_tmp[i] != "") |
---|
| 354 | { |
---|
[2] | 355 | nw_array[cont] = var_tmp[i]; |
---|
| 356 | cont++; |
---|
| 357 | } |
---|
| 358 | } |
---|
[1614] | 359 | |
---|
| 360 | if( (preferences.search_result_number != '65536') && (nw_array.length > 0) && (nw_array.length >= preferences.search_result_number) ){ |
---|
| 361 | nw_array.length = preferences.search_result_number; |
---|
| 362 | write_msg(get_lang("More than %1 results. Please, try to refine your search.",preferences.search_result_number)); |
---|
| 363 | } |
---|
| 364 | else { |
---|
| 365 | write_msg(nw_array.length + " "+ get_lang('results found')); |
---|
| 366 | } |
---|
| 367 | |
---|
[320] | 368 | numBox++; |
---|
| 369 | var border_id = create_border(get_lang("Search Results"), "search_" + numBox); |
---|
[1604] | 370 | if (!border_id) |
---|
| 371 | { |
---|
| 372 | return; |
---|
| 373 | } |
---|
[832] | 374 | currentTab = border_id; |
---|
[1622] | 375 | openTab.content_id[currentTab] = Element('content_id_search_' + numBox); |
---|
[832] | 376 | openTab.type[currentTab] = 1; |
---|
[2] | 377 | var table = document.createElement("TABLE"); |
---|
[320] | 378 | table.id = "table_resultsearch_" + numBox; |
---|
[271] | 379 | table.frame = "void"; |
---|
| 380 | table.rules = "rows"; |
---|
| 381 | table.cellPadding = "0"; |
---|
| 382 | table.cellSpacing = "0"; |
---|
[667] | 383 | table.className = "table_box"; |
---|
[72] | 384 | |
---|
[2] | 385 | var tbody = document.createElement("TBODY"); |
---|
[832] | 386 | tbody.id = "tbody_box_" + numBox; |
---|
| 387 | |
---|
[2] | 388 | for( var i=0; i < nw_array.length; i++){ |
---|
| 389 | var tr = document.createElement("TR"); |
---|
[645] | 390 | tr.style.height = preferences.line_height; |
---|
[2] | 391 | |
---|
[645] | 392 | if (nw_array[i].match(/.*--.*--\w*--\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g) != null) //subject with "--" |
---|
[69] | 393 | { |
---|
[645] | 394 | var aux1 = nw_array[i].match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g); |
---|
[69] | 395 | aux1 = aux1[0].split("--"); |
---|
| 396 | nw_array[i] = nw_array[i].substr(0, nw_array[i].indexOf(aux1[0])-2); |
---|
| 397 | var aux = []; |
---|
| 398 | aux[0] = nw_array[i].substr(0, nw_array[i].indexOf('--')); |
---|
| 399 | nw_array[i] = nw_array[i].substr(nw_array[i].indexOf('--')+2); |
---|
| 400 | aux[1] = nw_array[i].substr(0, nw_array[i].indexOf('--')); |
---|
| 401 | aux[2] = nw_array[i].substr(nw_array[i].indexOf('--')+2); |
---|
| 402 | aux = aux.concat(aux1); |
---|
| 403 | } |
---|
| 404 | else |
---|
| 405 | { |
---|
[832] | 406 | var aux = nw_array[i].split("--"); |
---|
[69] | 407 | } |
---|
[1339] | 408 | |
---|
| 409 | var mailbox = aux[0]; |
---|
| 410 | var uid_msg = aux[6]; |
---|
[645] | 411 | var subject = aux[2]; |
---|
[1970] | 412 | tr.id = uid_msg+"_s"+global_search; |
---|
[1339] | 413 | |
---|
| 414 | // Keep the two lines together please |
---|
| 415 | tr.setAttribute('name',mailbox); |
---|
| 416 | tr.name = mailbox; |
---|
| 417 | |
---|
| 418 | if (aux[5].match("U")) |
---|
[976] | 419 | add_className(tr,'tr_msg_unread'); |
---|
| 420 | add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read'); |
---|
[1000] | 421 | var _onclick = function () { proxy_mensagens.get_msg(this.parentNode.id,url_encode(this.parentNode.getAttribute('name')),false,show_msg);}; |
---|
| 422 | for(var j=0 ; j < 10 ; j++) |
---|
[645] | 423 | { |
---|
[832] | 424 | var td = document.createElement("TD"); |
---|
[645] | 425 | if (j == 0) |
---|
| 426 | { |
---|
| 427 | td.style.width = "1%"; |
---|
| 428 | var td1 = '<input type="checkbox" id="check_box_message_'+uid_msg+'"></input>'; |
---|
[976] | 429 | |
---|
[645] | 430 | } |
---|
| 431 | if (j == 1) |
---|
| 432 | { |
---|
| 433 | td.style.width = "2%"; |
---|
[1339] | 434 | if (aux[5].match('T')) |
---|
[832] | 435 | { |
---|
[1339] | 436 | attachNum = parseInt(aux[5].substr(aux[5].indexOf('T')+1)); |
---|
[832] | 437 | td1 = "<img src='templates/"+template+"/images/clip.gif' title='"+attachNum +' '+ get_lang('attachment(s)')+"'>"; |
---|
| 438 | } |
---|
| 439 | else |
---|
| 440 | td1 = ''; |
---|
[645] | 441 | } |
---|
| 442 | if (j == 2) |
---|
| 443 | { |
---|
| 444 | td.style.width = "1%"; |
---|
| 445 | td.id = "td_message_answered_"+uid_msg; |
---|
[1339] | 446 | if (aux[5].match('X')) |
---|
[832] | 447 | td1 = '<img src=templates/'+template+'/images/forwarded.gif title=Forwarded>'; |
---|
| 448 | else |
---|
[1339] | 449 | if (aux[5].match('A')) |
---|
[832] | 450 | td1 = '<img src=templates/'+template+'/images/answered.gif>'; |
---|
| 451 | else |
---|
| 452 | td1 = ''; |
---|
[645] | 453 | } |
---|
| 454 | if (j == 3) |
---|
| 455 | { |
---|
| 456 | td.style.width = "1%"; |
---|
| 457 | td.id = "td_message_important_"+uid_msg; |
---|
[1339] | 458 | if (aux[5].match("F")) |
---|
[832] | 459 | { |
---|
[976] | 460 | add_className(tr, 'flagged_msg'); |
---|
| 461 | td.style.background = "url(templates/"+template+"/images/important.gif) no-repeat center"; |
---|
[832] | 462 | } |
---|
| 463 | else |
---|
| 464 | td1 = ''; |
---|
[645] | 465 | } |
---|
| 466 | if (j == 4) |
---|
| 467 | { |
---|
| 468 | td.style.width = "1%"; |
---|
| 469 | td.id = "td_message_sent_"+uid_msg; |
---|
| 470 | td1 = ''; |
---|
| 471 | } |
---|
| 472 | if (j == 5) |
---|
| 473 | { |
---|
[1339] | 474 | td.style.width = "14%"; |
---|
[832] | 475 | td.onclick = _onclick; |
---|
[645] | 476 | var nm_box = aux[0].split(cyrus_delimiter); |
---|
| 477 | var td1 = nm_box.pop(); |
---|
| 478 | td.setAttribute("NoWrap","true"); |
---|
| 479 | td.style.overflow = "hidden"; |
---|
| 480 | td.style.color = "#42795b"; |
---|
| 481 | td.style.fontWeight = "bold"; |
---|
[1631] | 482 | |
---|
| 483 | var td1 = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1); |
---|
[1747] | 484 | if ((tmp = translatedFolders.get(td1))) |
---|
| 485 | { |
---|
| 486 | td1 = tmp; |
---|
| 487 | } |
---|
[1339] | 488 | |
---|
[832] | 489 | if(proxy_mensagens.is_local_folder(td1)) { |
---|
| 490 | var td1 = this.aux_local_folder_display(td1); |
---|
[689] | 491 | } |
---|
[645] | 492 | } |
---|
| 493 | if( j == 6) |
---|
| 494 | { |
---|
[1339] | 495 | if (aux[1].length > 29) |
---|
| 496 | aux[1] = aux[1].substr(0,29) + "..."; |
---|
[832] | 497 | td.style.width = "20%"; |
---|
| 498 | td.onclick = _onclick; |
---|
| 499 | td.setAttribute("NoWrap","true"); |
---|
| 500 | td.style.overflow = "hidden"; |
---|
[645] | 501 | var td1 = '<div style="width:100%;overflow:hidden">'+aux[1]+"</div>"; |
---|
| 502 | } |
---|
| 503 | if( j == 7) |
---|
| 504 | { |
---|
| 505 | var subject_encode = url_encode(subject); |
---|
| 506 | if (! subject_encode) |
---|
| 507 | aux[2] = get_lang("no subject") + "..."; |
---|
[1339] | 508 | if (aux[2].length > 70) |
---|
[832] | 509 | aux[2] = aux[2].substr(0,70) + "..."; |
---|
| 510 | td.style.width = "35%"; |
---|
| 511 | td.onclick = _onclick; |
---|
| 512 | td.setAttribute("NoWrap","true"); |
---|
| 513 | td.style.overflow = "hidden"; |
---|
[1339] | 514 | var td1 = aux[2]; |
---|
[67] | 515 | |
---|
[2] | 516 | } |
---|
[645] | 517 | if( j == 8) |
---|
| 518 | { |
---|
[832] | 519 | td.style.width = "15%"; |
---|
[645] | 520 | td.align = "center"; |
---|
[832] | 521 | td.onclick = _onclick; |
---|
[1339] | 522 | var td1 = aux[3]; |
---|
[645] | 523 | } |
---|
| 524 | if( j == 9) |
---|
| 525 | { |
---|
| 526 | td.style.width = "10%"; |
---|
| 527 | td.align = "center"; |
---|
[832] | 528 | td.onclick = _onclick; |
---|
[1339] | 529 | var td1 = aux[4]; |
---|
[645] | 530 | } |
---|
| 531 | if (j == 10) |
---|
| 532 | { |
---|
[1339] | 533 | if (aux[5].match("U")) |
---|
[976] | 534 | add_className(tr, 'tr_msg_unread'); |
---|
[1339] | 535 | if (aux[5].match("F")) |
---|
[976] | 536 | add_className(tr, 'flagged_msg'); |
---|
[645] | 537 | var td1 = ''; |
---|
| 538 | } |
---|
| 539 | td.innerHTML = td1; |
---|
| 540 | tr.appendChild(td); |
---|
[2] | 541 | } |
---|
[569] | 542 | aux.splice(0,(aux.length)); |
---|
[271] | 543 | |
---|
[1339] | 544 | _dragArea.makeDragged(tr, uid_msg, subject, true, mailbox); |
---|
[271] | 545 | tbody.appendChild(tr); |
---|
[2] | 546 | } |
---|
[1970] | 547 | global_search++; //Tabs from search must not have the same id on its tr's |
---|
[2] | 548 | table.appendChild(tbody); |
---|
[832] | 549 | |
---|
| 550 | var content_search = Element('content_id_search_' + numBox); |
---|
[163] | 551 | // BEGIN MAKE THE SCROLL HEIGHT |
---|
[832] | 552 | var defaultWidth = document.body.offsetWidth - 31; |
---|
[163] | 553 | var menuHidden = Element("folderscol").style.display == 'none' ? true : false; |
---|
| 554 | if(!menuHidden) |
---|
| 555 | defaultWidth -= Element("folderscol").offsetWidth; |
---|
| 556 | var bar = Element("toolbar"); |
---|
| 557 | var offset = 0; |
---|
| 558 | if(bar.style.visibility != 'hidden') |
---|
| 559 | offset = bar.offsetHeight ? bar.offsetHeight : bar.clientHeight; |
---|
| 560 | var div_scroll_result = document.createElement("DIV"); |
---|
[320] | 561 | div_scroll_result.id = "divScrollMain_"+numBox; |
---|
[163] | 562 | div_scroll_result.style.height = document.body.clientHeight - offset - 120; |
---|
| 563 | content_search.style.height = document.body.clientHeight - offset - 80; |
---|
| 564 | div_scroll_result.style.overflow = "auto"; |
---|
| 565 | div_scroll_result.style.width = defaultWidth - (is_ie ? 7 : 0); |
---|
| 566 | // END MAKE THE SCROLL HEIGHT |
---|
| 567 | |
---|
| 568 | |
---|
[67] | 569 | if(is_ie) |
---|
[72] | 570 | Element("border_table").width = "99.5%"; |
---|
[67] | 571 | |
---|
[832] | 572 | // Put header |
---|
[67] | 573 | var table_element = document.createElement("TABLE"); |
---|
| 574 | var tbody_element = document.createElement("TBODY"); |
---|
| 575 | table_element.setAttribute("id", "table_message_header_box"); |
---|
| 576 | table_element.className = "table_message_header_box"; |
---|
| 577 | tr_element = document.createElement("TR"); |
---|
| 578 | tr_element.className = "message_header"; |
---|
[156] | 579 | td_element0 = document.createElement("TD"); |
---|
[1339] | 580 | td_element0.setAttribute("width", "1%"); |
---|
[156] | 581 | chk_box_element = document.createElement("INPUT"); |
---|
| 582 | chk_box_element.id = "chk_box_select_all_messages"; |
---|
| 583 | chk_box_element.setAttribute("type", "checkbox"); |
---|
| 584 | chk_box_element.className = "checkbox"; |
---|
[163] | 585 | chk_box_element.onclick = function(){select_all_search_messages(this.checked,content_search.id);}; |
---|
[156] | 586 | chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages.')}; |
---|
| 587 | chk_box_element.onkeydown = function (e){ |
---|
| 588 | if (is_ie) |
---|
| 589 | { |
---|
| 590 | if ((window.event.keyCode) == 46) |
---|
[832] | 591 | delete_msgs(current_folder,'selected','null'); |
---|
[156] | 592 | } |
---|
| 593 | else |
---|
| 594 | { |
---|
| 595 | if ((e.keyCode) == 46) |
---|
[832] | 596 | delete_msgs(current_folder,'selected','null'); |
---|
[156] | 597 | } |
---|
| 598 | }; |
---|
| 599 | |
---|
| 600 | td_element0.appendChild(chk_box_element); |
---|
[67] | 601 | td_element1 = document.createElement("TD"); |
---|
[163] | 602 | td_element1.setAttribute("width", "20%"); |
---|
[67] | 603 | td_element1.align = "left"; |
---|
[832] | 604 | if (sort_type == 'SORTBOX') |
---|
| 605 | { |
---|
| 606 | td_element1.onclick = function () { EsearchE.mount_result(data,'SORTBOX_REVERSE'); delete_border(border_id,false);}; |
---|
| 607 | td_element1.innerHTML ="<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
| 608 | } |
---|
| 609 | else |
---|
| 610 | { |
---|
| 611 | td_element1.onclick = function () { EsearchE.mount_result(data,'SORTBOX'); delete_border(border_id,false);}; |
---|
| 612 | if (sort_type == 'SORTBOX_REVERSE') |
---|
| 613 | td_element1.innerHTML ="<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
| 614 | else |
---|
| 615 | td_element1.innerHTML = get_lang("Folder"); |
---|
| 616 | } |
---|
[67] | 617 | td_element2 = document.createElement("TD"); |
---|
[73] | 618 | td_element2.setAttribute("width", "20%"); |
---|
[67] | 619 | td_element2.align = "left"; |
---|
[832] | 620 | if (sort_type == 'SORTWHO') |
---|
| 621 | { |
---|
| 622 | td_element2.onclick = function () { EsearchE.mount_result(data,'SORTWHO_REVERSE'); delete_border(border_id,false);}; |
---|
| 623 | td_element2.innerHTML ="<b>"+get_lang("who")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
| 624 | } |
---|
| 625 | else |
---|
| 626 | { |
---|
| 627 | td_element2.onclick = function () { EsearchE.mount_result(data,'SORTWHO'); delete_border(border_id,false);}; |
---|
| 628 | if (sort_type == 'SORTWHO_REVERSE') |
---|
| 629 | td_element2.innerHTML ="<b>"+get_lang("who")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
| 630 | else |
---|
| 631 | td_element2.innerHTML = get_lang("who"); |
---|
| 632 | } |
---|
[67] | 633 | td_element3 = document.createElement("TD"); |
---|
[645] | 634 | td_element3.setAttribute("width", "35%"); |
---|
[67] | 635 | td_element3.align = "left"; |
---|
[832] | 636 | if (sort_type == 'SORTSUBJECT') |
---|
| 637 | { |
---|
| 638 | td_element3.onclick = function () { EsearchE.mount_result(data,'SORTSUBJECT_REVERSE'); delete_border(border_id,false);}; |
---|
| 639 | td_element3.innerHTML ="<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
| 640 | } |
---|
| 641 | else |
---|
| 642 | { |
---|
| 643 | td_element3.onclick = function () { EsearchE.mount_result(data,'SORTSUBJECT'); delete_border(border_id,false);}; |
---|
| 644 | if (sort_type == 'SORTSUBJECT_REVERSE') |
---|
| 645 | td_element3.innerHTML ="<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
| 646 | else |
---|
| 647 | td_element3.innerHTML = get_lang("subject"); |
---|
| 648 | } |
---|
[67] | 649 | td_element4 = document.createElement("TD"); |
---|
[645] | 650 | td_element4.setAttribute("width", "15%"); |
---|
[67] | 651 | td_element4.align = "center"; |
---|
[832] | 652 | if (sort_type == 'SORTDATE') |
---|
| 653 | { |
---|
| 654 | td_element4.onclick = function () { EsearchE.mount_result(data,'SORTDATE_REVERSE'); delete_border(border_id,false);}; |
---|
| 655 | td_element4.innerHTML ="<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
| 656 | } |
---|
| 657 | else |
---|
| 658 | { |
---|
| 659 | td_element4.onclick = function () { EsearchE.mount_result(data,'SORTDATE'); delete_border(border_id,false);}; |
---|
| 660 | if (sort_type == 'SORTDATE_REVERSE') |
---|
| 661 | td_element4.innerHTML ="<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
| 662 | else |
---|
| 663 | td_element4.innerHTML = get_lang("Date"); |
---|
| 664 | } |
---|
[67] | 665 | td_element5 = document.createElement("TD"); |
---|
[645] | 666 | td_element5.setAttribute("width", "10%"); |
---|
[72] | 667 | td_element5.align = "center"; |
---|
[832] | 668 | if (sort_type == 'SORTSIZE') |
---|
| 669 | { |
---|
| 670 | td_element5.onclick = function () { EsearchE.mount_result(data,'SORTSIZE_REVERSE'); delete_border(border_id,false);}; |
---|
| 671 | td_element5.innerHTML ="<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
| 672 | } |
---|
| 673 | else |
---|
| 674 | { |
---|
| 675 | td_element5.onclick = function () { EsearchE.mount_result(data,'SORTSIZE'); delete_border(border_id,false);}; |
---|
| 676 | if (sort_type == 'SORTSIZE_REVERSE') |
---|
| 677 | td_element5.innerHTML ="<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
| 678 | else |
---|
| 679 | td_element5.innerHTML = get_lang("Size"); |
---|
| 680 | } |
---|
[156] | 681 | tr_element.appendChild(td_element0); |
---|
[67] | 682 | tr_element.appendChild(td_element1); |
---|
| 683 | tr_element.appendChild(td_element2); |
---|
| 684 | tr_element.appendChild(td_element3); |
---|
| 685 | tr_element.appendChild(td_element4); |
---|
| 686 | tr_element.appendChild(td_element5); |
---|
| 687 | tbody_element.appendChild(tr_element); |
---|
| 688 | table_element.appendChild(tbody_element); |
---|
[163] | 689 | content_search.appendChild(table_element); |
---|
[1121] | 690 | /*end of "put header"*/ |
---|
| 691 | |
---|
| 692 | if (!expresso_offline) { |
---|
[1294] | 693 | /* var span_options = document.createElement("SPAN"); |
---|
[1121] | 694 | if (span_options) |
---|
| 695 | span_options.innerHTML = '<span title="' + get_lang("Delete") + '" style="margin-top:3px;margin-left:8px" class="message_options" onclick="javascript:move_search_msgs(\'' + content_search.id + '\');">' + get_lang("Delete") + '</span> | ' + |
---|
| 696 | '<span title="' + |
---|
| 697 | get_lang("Move") + |
---|
| 698 | '" class="message_options" onclick=wfolders.makeWindowNew(\"' + |
---|
| 699 | content_search.id + |
---|
| 700 | '\",\"move_to\",true)>' + |
---|
| 701 | get_lang("Move") + |
---|
[1294] | 702 | '</span>';*/ |
---|
[1121] | 703 | div_scroll_result.appendChild(table); |
---|
| 704 | content_search.appendChild(div_scroll_result); |
---|
[1294] | 705 | /*if (span_options) |
---|
| 706 | content_search.appendChild(span_options);*/ |
---|
[1121] | 707 | } |
---|
| 708 | else { |
---|
| 709 | div_scroll_result.appendChild(table); |
---|
| 710 | content_search.appendChild(div_scroll_result); |
---|
| 711 | } |
---|
[2] | 712 | } |
---|
| 713 | |
---|
[1339] | 714 | searchE.prototype.open_msg = function(mailbox, uid_msg, subject){ |
---|
[2] | 715 | var handler_get_msg = function(data){ |
---|
| 716 | if(Element("border_id_" + uid_msg + "_r")){alert(get_lang("This message is already opened!"));} |
---|
| 717 | else{draw_message(data,create_border(url_decode(subject), uid_msg + "_r"));} |
---|
[673] | 718 | //set_msg_as_read(msgs_to_set[i], false); |
---|
[2] | 719 | } |
---|
[1339] | 720 | proxy_mensagens.get_msg(uid_msg,mailbox,false,handler_get_msg); |
---|
[689] | 721 | /*var args = "$this.imap_functions.get_info_msg"; |
---|
| 722 | var params = "msg_number=" + uid_msg + "&msg_folder=" + mailbox; |
---|
| 723 | cExecute(args,handler_get_msg,params);*/ |
---|
[2] | 724 | |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | // Adiciona caixas postais na busca; |
---|
| 728 | searchE.prototype.add_mailboxes = function(){ |
---|
[69] | 729 | var sel = Element("sel_search_nm_box1"); |
---|
[689] | 730 | if (!proxy_mensagens.is_local_folder(this.name_box_search)) { |
---|
| 731 | var name_box = this.name_box_search.split(cyrus_delimiter); |
---|
| 732 | if(this.name_box_search == "") |
---|
| 733 | return false; |
---|
| 734 | var name_box_def = ""; |
---|
| 735 | if(name_box.length != 1){ |
---|
| 736 | name_box_def = name_box[(name_box.length-1)]; |
---|
| 737 | }else{ |
---|
| 738 | name_box_def = get_lang("Inbox"); |
---|
| 739 | } |
---|
[2] | 740 | } |
---|
[689] | 741 | else { |
---|
| 742 | if(this.name_box_search=='local_root') |
---|
| 743 | return; |
---|
| 744 | if(this.name_box_search=='local_Inbox') |
---|
| 745 | name_box_def = get_lang("Inbox"); |
---|
[1477] | 746 | else if(this.name_box_search.indexOf("/")!="-1") { |
---|
| 747 | final_pos = this.name_box_search.lastIndexOf("/"); |
---|
| 748 | name_box_def = this.name_box_search.substr(final_pos+1); |
---|
| 749 | } |
---|
[689] | 750 | else |
---|
| 751 | name_box_def = this.name_box_search.substr(6);//Retira o 'local_' |
---|
| 752 | } |
---|
[2] | 753 | if( sel.length > 0){ |
---|
| 754 | for(var i=0; i < sel.options.length; i++){ |
---|
| 755 | if(sel.options[i].value == this.name_box_search){ |
---|
| 756 | alert(get_lang('This message is already selected!')); |
---|
| 757 | return false; |
---|
| 758 | } |
---|
| 759 | } |
---|
| 760 | } |
---|
[96] | 761 | var opt = new Option(lang_folder(name_box_def),this.name_box_search,false,true); |
---|
[2] | 762 | sel[sel.length] = opt; |
---|
| 763 | } |
---|
| 764 | // Remove as caixas postais na busca; |
---|
| 765 | searchE.prototype.del_mailboxes = function(){ |
---|
[69] | 766 | var sel = Element("sel_search_nm_box1"); |
---|
[2] | 767 | if(sel.length > 0){ |
---|
| 768 | for(var i=0; i < sel.options.length; i++){ |
---|
| 769 | if(sel.options[i].selected == true){ |
---|
| 770 | sel.options[i] = null; |
---|
| 771 | i--; |
---|
| 772 | } |
---|
| 773 | } |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | } |
---|
| 777 | // todas as caixas |
---|
| 778 | searchE.prototype.all_mailboxes = function(){ |
---|
[69] | 779 | var value = Element("check_all_msg").checked; |
---|
[2] | 780 | var cont = parseInt(0); |
---|
| 781 | if(value){ |
---|
| 782 | if(EsearchE.all_boxes.length > 0){ |
---|
| 783 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 784 | } |
---|
| 785 | for(var i=0; i < folders.length; i++){ |
---|
| 786 | EsearchE.all_boxes[cont] = folders[i].folder_id; |
---|
| 787 | cont++; |
---|
| 788 | } |
---|
| 789 | }else{ |
---|
| 790 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 791 | } |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | // Search; |
---|
| 795 | searchE.prototype.func_search = function(value){ |
---|
| 796 | var fields = "##"; |
---|
| 797 | // Verifica se os campos estão preenchidos; |
---|
[69] | 798 | if(trim(Element("txt_ass").value) != ""){ |
---|
[372] | 799 | fields += "SUBJECT " + "<=>" +url_encode(Element("txt_ass").value) + "##"; |
---|
[2] | 800 | } |
---|
[69] | 801 | if(trim(Element("txt_body").value) != ""){ |
---|
[372] | 802 | fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##"; |
---|
[2] | 803 | } |
---|
[69] | 804 | if(trim(Element("txt_de").value) != ""){ |
---|
[372] | 805 | fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##"; |
---|
[2] | 806 | } |
---|
[69] | 807 | if(trim(Element("txt_para").value) != ""){ |
---|
[372] | 808 | fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##"; |
---|
[2] | 809 | } |
---|
[69] | 810 | if(trim(Element("txt_cc").value) != ""){ |
---|
[372] | 811 | fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##"; |
---|
[2] | 812 | } |
---|
[1622] | 813 | if (trim(Element("since_date").value) != ""){ |
---|
| 814 | if (validate_date(Element("since_date").value)) |
---|
| 815 | { |
---|
| 816 | fields += "SINCE " + "<=>" + url_encode(Element("since_date").value) + "##"; |
---|
| 817 | } |
---|
| 818 | else |
---|
| 819 | { |
---|
| 820 | alert(get_lang('Invalid date on field %1'), get_lang('Since Date')); |
---|
| 821 | return false; |
---|
| 822 | } |
---|
| 823 | } |
---|
| 824 | if (trim(Element("before_date").value) != ""){ |
---|
| 825 | if (validate_date(Element("before_date").value)) |
---|
| 826 | { |
---|
| 827 | fields += "BEFORE " + "<=>" + url_encode(Element("before_date").value) + "##"; |
---|
| 828 | } |
---|
| 829 | else |
---|
| 830 | { |
---|
| 831 | alert(get_lang('Invalid date on field %1'), get_lang('Before Date')); |
---|
| 832 | return false; |
---|
| 833 | } |
---|
| 834 | } |
---|
| 835 | if(trim(Element("on_date").value) != ""){ |
---|
| 836 | if (validate_date(Element("on_date").value)) |
---|
| 837 | { |
---|
| 838 | fields += "ON " + "<=>" + url_encode(Element("on_date").value) + "##"; |
---|
| 839 | } |
---|
| 840 | else |
---|
| 841 | { |
---|
| 842 | alert(get_lang('Invalid date on field %1'), get_lang('On Date')); |
---|
| 843 | return false; |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | } |
---|
| 847 | if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != ""){ |
---|
| 848 | if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED"){ |
---|
| 849 | fields += "FLAGGED##"; |
---|
| 850 | } |
---|
| 851 | else { |
---|
| 852 | fields += "UNFLAGGED##"; |
---|
| 853 | } |
---|
| 854 | } |
---|
| 855 | if(trim(Element("seen").options[Element("seen").selectedIndex].value) != ""){ |
---|
| 856 | if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN"){ |
---|
| 857 | fields += "SEEN##"; |
---|
| 858 | } |
---|
| 859 | else { |
---|
| 860 | fields += "UNSEEN##"; |
---|
| 861 | } |
---|
| 862 | } |
---|
| 863 | if(trim(Element("answered").options[Element("answered").selectedIndex].value) != ""){ |
---|
| 864 | if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){ |
---|
| 865 | fields += "ANSWERED##"; |
---|
| 866 | } |
---|
| 867 | else { |
---|
| 868 | fields += "UNANSWERED##"; |
---|
| 869 | } |
---|
| 870 | } |
---|
| 871 | if(trim(Element("recent").options[Element("recent").selectedIndex].value) != ""){ |
---|
| 872 | if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT"){ |
---|
| 873 | fields += "RECENT##"; |
---|
| 874 | } |
---|
| 875 | else { |
---|
| 876 | fields += "OLD##"; |
---|
| 877 | } |
---|
| 878 | } |
---|
[2] | 879 | if(value) { |
---|
[372] | 880 | fields = "##ALL " + "<=>" +url_encode(value) + "##"; |
---|
[2] | 881 | } |
---|
[69] | 882 | |
---|
[372] | 883 | if(fields == "##"){ |
---|
[128] | 884 | alert(get_lang("Define some search parameters!")); |
---|
[2] | 885 | return false; |
---|
| 886 | } |
---|
[689] | 887 | var local_folders = new Array(); |
---|
| 888 | var temp; |
---|
[2] | 889 | |
---|
[69] | 890 | if(Element("check_all_msg").checked){ |
---|
[689] | 891 | this.all_mailboxes(); |
---|
[2] | 892 | var nm_box = new Array; |
---|
| 893 | for(var i=0; i < EsearchE.all_boxes.length; i++){ |
---|
| 894 | nm_box[i] = EsearchE.all_boxes[i] + fields; |
---|
| 895 | } |
---|
[689] | 896 | if (preferences.use_local_messages == 1) { |
---|
| 897 | temp = expresso_local_messages.list_local_folders(); |
---|
| 898 | for (var x in temp) { |
---|
| 899 | local_folders.push(temp[x][0]); |
---|
| 900 | } |
---|
| 901 | } |
---|
[2] | 902 | }else{ |
---|
| 903 | var nm_box = new Array; |
---|
[69] | 904 | var sel_combo = Element("sel_search_nm_box1"); |
---|
[2] | 905 | if( sel_combo.options.length <= 0){ |
---|
[118] | 906 | alert(get_lang("Define the boxes to search!")); |
---|
[2] | 907 | return false; |
---|
| 908 | } |
---|
| 909 | |
---|
| 910 | for(var i=0; i < sel_combo.options.length; i++){ |
---|
| 911 | sel_combo.options[i].selected = true; |
---|
| 912 | } |
---|
| 913 | for(var i=0; i < sel_combo.options.length; i++){ |
---|
| 914 | if(sel_combo.options[i].selected == true){ |
---|
[689] | 915 | if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value)) |
---|
| 916 | nm_box[nm_box.length] = sel_combo.options[i].value + fields; |
---|
| 917 | else |
---|
| 918 | local_folders.push(sel_combo.options[i].value.substr(6)); |
---|
[2] | 919 | } |
---|
| 920 | } |
---|
| 921 | } |
---|
| 922 | var handler = function(data){ |
---|
[689] | 923 | var tmp; |
---|
| 924 | var countTmp= new Array(); |
---|
[1614] | 925 | |
---|
| 926 | var dataTemp = data.split('=sumResults='); |
---|
| 927 | var sumResults = dataTemp[0]; |
---|
| 928 | |
---|
| 929 | var data = dataTemp[1] ? dataTemp[1] : dataTemp[0]; |
---|
| 930 | |
---|
[689] | 931 | if (local_folders.length > 0) { |
---|
| 932 | tmp = expresso_local_messages.search(local_folders, fields); |
---|
| 933 | if (tmp!=false) { |
---|
| 934 | var tmp2 = tmp.substr(2, data.length - 4); |
---|
| 935 | countTmp = tmp.split('####'); |
---|
| 936 | } |
---|
| 937 | } |
---|
[1614] | 938 | // if((data == "none") && (countTmp.length==0)){alert(get_lang("None result was found."));} |
---|
| 939 | // if (preferences.search_result_number == '65536' || (data != 'many results' && countTmp.length < preferences.search_result_number)) |
---|
| 940 | // { |
---|
| 941 | // EsearchE.mount_result((data=='none')?tmp:(countTmp.length==0)?data:data+tmp); |
---|
| 942 | // } |
---|
| 943 | // else if (data == 'many results' || countTmp.length >= preferences.search_result_number) |
---|
| 944 | // { |
---|
| 945 | // alert(get_lang("More than %1 results. Please, try to refine your search.",preferences.search_result_number)); |
---|
| 946 | // } |
---|
| 947 | |
---|
| 948 | if ((sumResults == "none") && (countTmp.length==0)){ |
---|
| 949 | alert(get_lang("None result was found.")); |
---|
[1608] | 950 | } |
---|
[1614] | 951 | else |
---|
[1608] | 952 | { |
---|
[1614] | 953 | EsearchE.mount_result((sumResults=='none')?tmp:(countTmp.length==0)?data:data+tmp); |
---|
[1608] | 954 | } |
---|
[1614] | 955 | |
---|
[2] | 956 | } |
---|
| 957 | var args = "$this.imap_functions.search_msg"; |
---|
| 958 | var params = "condition=" + nm_box; |
---|
[1121] | 959 | if(expresso_offline) |
---|
| 960 | handler('none'); |
---|
| 961 | else |
---|
| 962 | cExecute(args,handler,params); |
---|
[2] | 963 | } |
---|
| 964 | // clean; |
---|
| 965 | searchE.prototype.func_clean = function(){ |
---|
| 966 | // Limpa os campos; |
---|
[1622] | 967 | for(var i=0; i < this.txtfields.length; i++){ |
---|
| 968 | if(Element(this.txtfields[i]) != null){Element(this.txtfields[i]).value = "";} |
---|
| 969 | } |
---|
| 970 | |
---|
| 971 | for(i = 0; i < this.selectFields.length; i++) |
---|
| 972 | { |
---|
| 973 | if (Element(this.selectFields[i])) |
---|
| 974 | { |
---|
| 975 | Element(this.selectFields[i]).selectedIndex = 0; |
---|
| 976 | } |
---|
| 977 | } |
---|
[2] | 978 | if(Element("check_all_msg") != null){Element("check_all_msg").checked = false;} |
---|
| 979 | |
---|
| 980 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
[75] | 981 | EsearchE.del_mailboxes(); |
---|
[69] | 982 | } |
---|
[2] | 983 | |
---|
| 984 | // close |
---|
| 985 | searchE.prototype.func_close = function(type){ |
---|
| 986 | var _this = this; |
---|
| 987 | _this.name_box_search = ""; |
---|
| 988 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 989 | _this.type = type; |
---|
| 990 | _this.searchW['window_search'].close(); |
---|
| 991 | } |
---|
| 992 | // Monta a janela em tela; |
---|
| 993 | searchE.prototype.showWindow = function(div){ |
---|
| 994 | if(!this.searchW[div.id]) { |
---|
[1622] | 995 | div.style.width = "804px"; |
---|
| 996 | div.style.height = "440px"; |
---|
[2] | 997 | div.style.visibility = "hidden"; |
---|
| 998 | div.style.position = "absolute"; |
---|
[832] | 999 | div.style.zIndex = "10003"; |
---|
[128] | 1000 | var title = ":: "+ get_lang("Search")+" ::"; |
---|
[2] | 1001 | var wHeight = div.offsetHeight + "px"; |
---|
| 1002 | var wWidth = div.offsetWidth + "px"; |
---|
[832] | 1003 | |
---|
| 1004 | win = new dJSWin({ |
---|
[2] | 1005 | id: 'ccList'+div.id, |
---|
| 1006 | content_id: div.id, |
---|
| 1007 | width: wWidth, |
---|
| 1008 | height: wHeight, |
---|
| 1009 | title_color: '#3978d6', |
---|
| 1010 | bg_color: '#eee', |
---|
[832] | 1011 | title: title, |
---|
[2] | 1012 | title_text_color: 'white', |
---|
| 1013 | button_y_img: '../phpgwapi/images/win_min.gif', |
---|
| 1014 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 1015 | border: true }); |
---|
| 1016 | this.searchW[div.id] = win; |
---|
| 1017 | win.draw(); |
---|
| 1018 | }else{ |
---|
| 1019 | var _this = this; |
---|
| 1020 | win = this.searchW[div.id]; |
---|
| 1021 | if((_this.type == "close" && win.state == 0) || win.state == 2){EsearchE.func_clean();} |
---|
| 1022 | win.draw(); |
---|
| 1023 | } |
---|
| 1024 | win.open(); |
---|
| 1025 | } |
---|
[689] | 1026 | |
---|
| 1027 | searchE.prototype.aux_local_folder_display = function(folder) { |
---|
[1121] | 1028 | if(!expresso_offline) |
---|
| 1029 | return "(Local) " + lang_folder(folder.substr(6)); |
---|
| 1030 | else |
---|
| 1031 | return lang_folder(folder.substr(6)); |
---|
[689] | 1032 | } |
---|
| 1033 | |
---|
[2] | 1034 | // Cria o objeto |
---|
| 1035 | var EsearchE; |
---|
[569] | 1036 | EsearchE = new searchE(); |
---|