[2] | 1 | /**************************************************************************\ |
---|
[3802] | 2 | Início |
---|
[2] | 3 | \**************************************************************************/ |
---|
[832] | 4 | function searchE() |
---|
| 5 | { |
---|
[4834] | 6 | this.totalPages = 1; |
---|
| 7 | this.numPages = 5; |
---|
| 8 | this.lastPage = 0; |
---|
[3842] | 9 | this.searchW = []; |
---|
| 10 | this.condition = ""; |
---|
| 11 | this.sort_type = ""; |
---|
[4834] | 12 | //this.page = 0; |
---|
[2] | 13 | this.name_box_search = ""; |
---|
[3842] | 14 | this.all_boxes = []; |
---|
| 15 | this.type = ""; |
---|
| 16 | this.txtfields = new Array("txt_ass","txt_de","txt_body","txt_para","txt_cc","txt_cco", "since_date", "before_date", "on_date"); |
---|
| 17 | this.selectFields = new Array("flagged", "seen", "answered", "recent"); |
---|
[2] | 18 | } |
---|
[3380] | 19 | |
---|
[2] | 20 | //Monta os forms dentro da janela; |
---|
[3842] | 21 | searchE.prototype.showForms = function(value) |
---|
| 22 | { |
---|
[2] | 23 | // Principal |
---|
[3842] | 24 | if(!Element("window_search")) |
---|
| 25 | { |
---|
[2] | 26 | var form_search = document.createElement("DIV"); |
---|
| 27 | form_search.style.visibility = 'hidden'; |
---|
| 28 | form_search.style.top = '0px'; |
---|
| 29 | form_search.style.left = '0px'; |
---|
| 30 | form_search.id = "window_search"; |
---|
[3380] | 31 | document.body.appendChild(form_search); |
---|
[2] | 32 | } |
---|
[3380] | 33 | |
---|
[2] | 34 | // Pesquisa |
---|
[3842] | 35 | if(!Element("div_form_search")) |
---|
| 36 | { |
---|
[2] | 37 | var div_form_search = document.createElement("DIV"); |
---|
| 38 | div_form_search.id = "div_form_search"; |
---|
| 39 | div_form_search.style.position = "absolute"; |
---|
| 40 | div_form_search.style.left = "10px"; |
---|
| 41 | div_form_search.style.top = "10px"; |
---|
[3380] | 42 | div_form_search.style.borderStyle = "outset"; |
---|
| 43 | div_form_search.style.borderColor = "black"; |
---|
| 44 | div_form_search.style.borderWidth = "1px"; |
---|
[1622] | 45 | div_form_search.style.width = "784px"; |
---|
| 46 | div_form_search.style.height = "418px"; |
---|
[2] | 47 | div_form_search.style.overflow = "hidden"; |
---|
| 48 | div_form_search.innerHTML = ""; |
---|
| 49 | var call_form_search = EsearchE.mount_form(); |
---|
| 50 | div_form_search.appendChild(call_form_search); |
---|
[156] | 51 | form_search.appendChild(div_form_search); |
---|
[2] | 52 | |
---|
[1622] | 53 | Calendar._TT['WEEKEND'] = '0,6'; // hack |
---|
| 54 | Calendar._TT['DAY_FIRST'] = 'Mostrar %s primeiro'; |
---|
| 55 | Calendar.setup({ |
---|
| 56 | inputField : 'since_date', |
---|
| 57 | button : 'since_date-trigger', |
---|
| 58 | ifFormat : '%d/%m/%Y', |
---|
| 59 | daFormat : '%d/%m/%Y' |
---|
| 60 | }); |
---|
| 61 | |
---|
| 62 | Calendar.setup({ |
---|
| 63 | inputField : 'before_date', |
---|
| 64 | button : 'before_date-trigger', |
---|
| 65 | ifFormat : '%d/%m/%Y', |
---|
| 66 | daFormat : '%d/%m/%Y' |
---|
| 67 | }); |
---|
| 68 | |
---|
| 69 | Calendar.setup({ |
---|
| 70 | inputField : 'on_date', |
---|
| 71 | button : 'on_date-trigger', |
---|
| 72 | ifFormat : '%d/%m/%Y', |
---|
| 73 | daFormat : '%d/%m/%Y' |
---|
| 74 | }); |
---|
| 75 | |
---|
[3380] | 76 | } |
---|
| 77 | |
---|
[2] | 78 | if(!Element("div_button_search")){ |
---|
| 79 | var div_button_search = document.createElement("DIV"); |
---|
| 80 | div_button_search.id = "div_button_search"; |
---|
| 81 | div_button_search.style.position = "absolute"; |
---|
[1622] | 82 | div_button_search.style.marginLeft = "430px"; |
---|
[2] | 83 | div_button_search.style.top = "223px"; |
---|
[1622] | 84 | div_button_search.style.width = "350px"; |
---|
[2] | 85 | div_button_search.style.height = "25px"; |
---|
[1622] | 86 | div_button_search.innerHTML = "<table style='width: 100%;' border='0' cellpadding='0' cellspacing='0' align='center'>"+ |
---|
[2] | 87 | "<tr>"+ |
---|
[1622] | 88 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Search') + " onclick='EsearchE.func_search()'></td>"+ |
---|
| 89 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Clean') + " onclick='EsearchE.func_clean()'></td>"+ |
---|
| 90 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Close') + " onclick='EsearchE.func_close(\"hidden\")'></td>"+ |
---|
[2] | 91 | "</tr>"+ |
---|
| 92 | "</table>"; |
---|
| 93 | form_search.appendChild(div_button_search); |
---|
| 94 | } |
---|
[3380] | 95 | |
---|
[2] | 96 | if(!Element("table_layer")){ |
---|
[67] | 97 | var table_layer = ""; |
---|
[2] | 98 | } |
---|
[3380] | 99 | |
---|
[67] | 100 | if(value == "") |
---|
[69] | 101 | EsearchE.showWindow(Element("window_search")); |
---|
[3380] | 102 | |
---|
[2] | 103 | // Cria as caixas postais; |
---|
| 104 | EsearchE.mount_folders(); |
---|
| 105 | |
---|
[3842] | 106 | if(value) |
---|
| 107 | { |
---|
[2] | 108 | Element("check_all_msg").checked = true; |
---|
| 109 | EsearchE.all_mailboxes(); |
---|
[5172] | 110 | EsearchE.func_search(value, null, 'SORTDATE_REVERSE'); |
---|
[2] | 111 | } |
---|
| 112 | |
---|
| 113 | } |
---|
[3802] | 114 | |
---|
[2] | 115 | //Form |
---|
[3842] | 116 | searchE.prototype.mount_form = function(value) |
---|
| 117 | { |
---|
[2] | 118 | var form_sch = document.createElement("FORM"); |
---|
[3842] | 119 | form_sch.id = "form_sch"; |
---|
[1415] | 120 | |
---|
[3842] | 121 | form_sch.innerHTML = '<fieldset style="width:400px; text-align:right; padding: 5px; position:absolute;">' |
---|
| 122 | + ' <legend>'+get_lang('Inform your search in the text fields')+'</legend>' |
---|
| 123 | + ' <label>'+get_lang("From")+':</label>' |
---|
| 124 | + ' <input style="margin-left: 6px;" type="text" id="txt_de" size="39">' |
---|
| 125 | + ' <br style="margin-bottom:15px"/>' |
---|
| 126 | + ' <label>'+get_lang('To')+':</label>' |
---|
| 127 | + ' <input style="margin-left: 6px;" type="text" id="txt_para" size="39">' |
---|
| 128 | + ' <br style="margin-bottom:15px"/>' |
---|
| 129 | + ' <label>'+get_lang('Cc')+':</label>' |
---|
| 130 | + ' <input style="margin-left: 6px;" type="text" id="txt_cc" size="39">' |
---|
| 131 | + ' <br style="margin-bottom:15px"/>' |
---|
| 132 | + ' <label>'+get_lang('Subject')+':</label>' |
---|
| 133 | + ' <input style="margin-left: 6px;" type="text" id="txt_ass" size="39">' |
---|
| 134 | + ' <br style="margin-bottom:15px"/>' |
---|
| 135 | + ' <label>'+get_lang('Message body')+':</label>' |
---|
| 136 | + ' <input style="margin-left: 6px;" type="text" id="txt_body" size="39">' |
---|
[1622] | 137 | |
---|
[3842] | 138 | + ' <br style="margin-bottom:30px"/>' |
---|
| 139 | + ' <label>'+get_lang("Since Date")+':</label>' |
---|
[3925] | 140 | + ' <input style="margin-left: 6px;" type="text" id="since_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
[3842] | 141 | + ' <img id="since_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
| 142 | + ' <label style="margin-left: 20px;">'+get_lang('Before Date')+':</label>' |
---|
[3925] | 143 | + ' <input style="margin-left: 6px;" type="text" id="before_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
[3842] | 144 | + ' <img id="before_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
| 145 | + ' <br style="margin-bottom:15px"/>' |
---|
[1622] | 146 | |
---|
[3842] | 147 | + ' <label>'+get_lang('On Date')+':</label>' |
---|
[3925] | 148 | + ' <input style="margin-left: 6px;" type="text" id="on_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
| 149 | + ' <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;"/><span> </span>' |
---|
[3842] | 150 | + ' <br style="margin-bottom:30px"/>' |
---|
[1622] | 151 | |
---|
[3842] | 152 | + ' <label>'+get_lang('Flags')+':</label>' |
---|
| 153 | + ' <select style="width:15em; margin-left: 6px" name="flagged" id="flagged">' |
---|
| 154 | + ' <option value=""/>' |
---|
| 155 | + ' <option value="FLAGGED">'+ get_lang("Flagged") +'</option>' |
---|
| 156 | + ' <option value="UNFLAGGED">'+ get_lang("Unflagged") +'</option>' |
---|
| 157 | + ' </select>' |
---|
| 158 | + ' <br style="margin-bottom:15px"/>' |
---|
| 159 | + ' <select style="width:15em;" name="seen" id="seen">' |
---|
| 160 | + ' <option value=""/>' |
---|
| 161 | + ' <option value="SEEN">'+ get_lang("Seen") +'</option>' |
---|
| 162 | + ' <option value="UNSEEN">'+ get_lang("Unseen") +'</option>' |
---|
| 163 | + ' </select>' |
---|
| 164 | + ' <br style="margin-bottom:15px"/>' |
---|
| 165 | + ' <select style="width:15em;" name="answered" id="answered">' |
---|
| 166 | + ' <option value=""/>' |
---|
| 167 | + ' <option value="ANSWERED">'+ get_lang('Answered/Forwarded') +'</option>' |
---|
| 168 | + ' <option value="UNANSWERED">'+ get_lang('Unanswered/Unforwarded') +'</option>' |
---|
| 169 | + ' </select>' |
---|
| 170 | + ' <br style="margin-bottom:15px"/>' |
---|
[4750] | 171 | + ' <select style="width:15em;visibility:hidden;" name="recent" id="recent">' |
---|
[3842] | 172 | + ' <option value=""/>' |
---|
| 173 | + ' <option value="RECENT">'+ get_lang('Recent') +'</option>' |
---|
| 174 | + ' <option value="OLD">'+ get_lang('Old') +'</option>' |
---|
| 175 | + ' </select>' |
---|
[1622] | 176 | |
---|
[3842] | 177 | + ' <br style="margin-bottom:60px"/>' |
---|
| 178 | + '</fieldset>' |
---|
| 179 | + '<fieldset style="width:350px; padding: 5px; position:absolute; margin-left: 414px">' |
---|
| 180 | + ' <legend>'+get_lang('Search the messages in these folders')+'</legend>' |
---|
| 181 | + ' <div id="folders" style="width:160px; height:150px;float:left;margin-bottom:10px;"></div>' |
---|
| 182 | + ' <div style="float:left;height:100px;padding-top:50px;margin: 0 3px;">' |
---|
| 183 | + ' <input type="button" id="incluir" name="incluir" value=">>" onclick="EsearchE.add_mailboxes()">' |
---|
| 184 | + ' <br style="margin-bottom:15px">' |
---|
| 185 | + ' <input type="button" id="excluir" name="excluir" value="<<" onclick="EsearchE.del_mailboxes()">' |
---|
| 186 | + ' </div>' |
---|
| 187 | + ' <div style="float:left;">' |
---|
| 188 | + ' <select multiple id="sel_search_nm_box1" name="sel_search_nm_box1" style="width:140px;height:150px;"></select>' |
---|
| 189 | + ' </div>' |
---|
| 190 | + ' <br clear="both">' |
---|
| 191 | + ' <input type="checkBox" id="check_all_msg" name="check_all_msg" onclick="EsearchE.all_mailboxes()">' |
---|
| 192 | + ' <b>'+get_lang('In all the folders')+'</b>' |
---|
| 193 | + '</fieldset>'; |
---|
[3380] | 194 | |
---|
[2] | 195 | return form_sch; |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | // Pastas; |
---|
[3842] | 199 | searchE.prototype.mount_folders = function() |
---|
| 200 | { |
---|
[2] | 201 | connector.loadScript("TreeS"); |
---|
| 202 | |
---|
[3842] | 203 | if( Element("div_folders_search") == null) |
---|
| 204 | { |
---|
[2] | 205 | var div_folders = document.createElement("DIV"); |
---|
| 206 | div_folders.id = "div_folders_search"; |
---|
| 207 | div_folders.style.width = "155px"; |
---|
| 208 | div_folders.style.height = "152px"; |
---|
| 209 | div_folders.style.borderStyle = "outset"; |
---|
| 210 | div_folders.style.borderColor = "black"; |
---|
| 211 | div_folders.style.borderWidth = "1px"; |
---|
| 212 | div_folders.style.background = "#F7F7F7"; |
---|
| 213 | div_folders.style.overflow = "auto"; |
---|
| 214 | div_folders.innerHTML = ""; |
---|
[69] | 215 | var dest_div = Element("folders"); |
---|
[2] | 216 | dest_div.appendChild(div_folders); |
---|
[3380] | 217 | } |
---|
[2] | 218 | ttree.make_tree(folders,"div_folders_search","_folders_tree_search","","","",""); |
---|
| 219 | } |
---|
[3842] | 220 | |
---|
| 221 | function openpage(data) |
---|
| 222 | { |
---|
| 223 | var _data = [3]; |
---|
| 224 | var _gears = []; |
---|
| 225 | var local_folders = []; |
---|
| 226 | |
---|
| 227 | // Gears - local |
---|
[5134] | 228 | if ( preferences.use_local_messages == 1 ) |
---|
[3842] | 229 | { |
---|
| 230 | temp = expresso_local_messages.list_local_folders(); |
---|
| 231 | for (var x in temp) |
---|
| 232 | { |
---|
| 233 | local_folders.push(temp[x][0]); |
---|
| 234 | } |
---|
[5134] | 235 | } |
---|
| 236 | |
---|
[4928] | 237 | if ( local_folders.length > 0 ) |
---|
[3842] | 238 | _gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter() ); |
---|
| 239 | |
---|
| 240 | _data['data'] = data['data']; |
---|
| 241 | _data['num_msgs'] = data['num_msgs']; |
---|
[5134] | 242 | _data['gears_num_msgs'] = _gears.length; |
---|
[3842] | 243 | |
---|
[4158] | 244 | delete_border( data['currentTab'], false); |
---|
[3842] | 245 | |
---|
| 246 | EsearchE.mount_result(_data); |
---|
[3223] | 247 | } |
---|
[156] | 248 | |
---|
[3842] | 249 | searchE.prototype.show_paging = function(size) |
---|
| 250 | { |
---|
| 251 | var span_pg = Element("span_paging"+currentTab); |
---|
| 252 | |
---|
| 253 | if( span_pg == null ) |
---|
[3223] | 254 | { |
---|
[3842] | 255 | span_pg = document.createElement('span'); |
---|
| 256 | span_pg.id = "span_paging"+currentTab; |
---|
| 257 | } |
---|
| 258 | else |
---|
| 259 | span_pg.innerHTML = ""; |
---|
[4834] | 260 | |
---|
| 261 | if(size > parseInt(preferences.max_email_per_page)) { |
---|
[5134] | 262 | this.totalPages = Math.ceil(size/preferences.max_email_per_page); |
---|
[4834] | 263 | if((size/preferences.max_email_per_page) > this.totalPages) |
---|
| 264 | this.totalPages++; |
---|
| 265 | } |
---|
| 266 | |
---|
[5285] | 267 | if(this.page != 0 && this.page != null) { |
---|
[4834] | 268 | _link = document.createElement("A"); |
---|
[5134] | 269 | if( this.value ) |
---|
| 270 | _link.href = 'javascript:EsearchE.quickSearchMail( false, '+0+', false, "'+currentTab+'" )'; |
---|
| 271 | else{ |
---|
[4834] | 272 | _link.href = 'javascript:EsearchE.page=0;'; |
---|
| 273 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page=0¤t_tab='+currentTab+'");'; |
---|
| 274 | } |
---|
[5134] | 275 | } |
---|
[4834] | 276 | else { |
---|
| 277 | _link = document.createElement("SPAN"); |
---|
| 278 | } |
---|
| 279 | span_pg.appendChild(_link); |
---|
| 280 | |
---|
| 281 | _link.innerHTML = "<<"; |
---|
| 282 | _link.title = get_lang("First"); |
---|
| 283 | span_pg.innerHTML += " "; |
---|
| 284 | |
---|
| 285 | if(this.page == this.lastPage + (this.numPages)) |
---|
| 286 | { |
---|
| 287 | this.lastPage = this.page - 1; |
---|
| 288 | } |
---|
| 289 | else if((this.lastPage != 0 && this.lastPage == this.page) || this.page == (this.totalPages-1)) |
---|
| 290 | { |
---|
| 291 | this.lastPage = this.page - (this.numPages - 1); |
---|
| 292 | } |
---|
| 293 | else if(this.page == 0) |
---|
| 294 | { |
---|
| 295 | this.lastPage = 0; |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | if(this.lastPage < 0) |
---|
| 299 | this.lastPage = 0; |
---|
| 300 | else if(this.lastPage > 0 && (this.lastPage > (this.totalPages -(this.numPages - 1)))) |
---|
| 301 | this.lastPage = this.totalPages -(this.numPages); |
---|
| 302 | |
---|
| 303 | var hasMarked = false; |
---|
[5285] | 304 | if(this.page == null){ |
---|
| 305 | this.page = 0; |
---|
| 306 | } |
---|
[4834] | 307 | for(i = this.lastPage; i <= this.totalPages; i++) |
---|
| 308 | { |
---|
| 309 | if( ( i * preferences.max_email_per_page ) > size) |
---|
| 310 | { |
---|
| 311 | break; |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | if( this.page == i || (i == this.totalPages && !hasMarked) ) |
---|
| 315 | { |
---|
| 316 | var _link = document.createElement('span'); |
---|
| 317 | _link.setAttribute("style", "font-weight:bold; color:red") |
---|
| 318 | _link.innerHTML = ( this.page + 1 ) + " "; |
---|
| 319 | } |
---|
| 320 | else |
---|
| 321 | { |
---|
| 322 | var _page = i; |
---|
| 323 | var _link = document.createElement('A'); |
---|
| 324 | _link.innerHTML = ( _page + 1 ) + " "; |
---|
[5134] | 325 | if( this.value ) |
---|
| 326 | _link.href = 'javascript: EsearchE.quickSearchMail( false, '+i+', false, "'+currentTab+'" )'; |
---|
| 327 | else{ |
---|
[4834] | 328 | _link.href = 'javascript:EsearchE.page='+i+';'; |
---|
| 329 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+_page+'¤t_tab='+currentTab+'");'; |
---|
[5285] | 330 | } |
---|
[4834] | 331 | } |
---|
| 332 | _link.innerHTML = " ... "; |
---|
| 333 | if(i == (this.lastPage + this.numPages)) |
---|
| 334 | { |
---|
| 335 | span_pg.appendChild( _link ); |
---|
| 336 | break; |
---|
| 337 | } |
---|
| 338 | else if(this.lastPage == 0 || i != this.lastPage) |
---|
| 339 | { |
---|
| 340 | _link.innerHTML = " "+( i + 1 )+" "; |
---|
| 341 | } |
---|
| 342 | //span_pg.innerHTML += " "; |
---|
| 343 | |
---|
| 344 | span_pg.appendChild( _link ); |
---|
[5285] | 345 | } |
---|
[4834] | 346 | |
---|
| 347 | if(this.page != (this.totalPages - 1)) { |
---|
| 348 | _link = document.createElement("A"); |
---|
[5134] | 349 | if( this.value ) |
---|
| 350 | _link.href = 'javascript: EsearchE.quickSearchMail( false, '+(this.totalPages-1)+', false, "'+currentTab+'" )'; |
---|
| 351 | else{ |
---|
[4834] | 352 | _link.href = 'javascript:EsearchE.page='+(this.totalPages-1)+';'; |
---|
| 353 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+(this.totalPages-1)+'¤t_tab='+currentTab+'");'; |
---|
[5285] | 354 | } |
---|
[4834] | 355 | } |
---|
| 356 | else { |
---|
| 357 | _link = document.createElement("SPAN"); |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | span_pg.innerHTML += " "; |
---|
| 361 | span_pg.appendChild(_link); |
---|
| 362 | |
---|
| 363 | _link.title = get_lang("Last"); |
---|
| 364 | _link.innerHTML += ">>"; |
---|
| 365 | |
---|
| 366 | Element("div_menu_c3").appendChild(span_pg); |
---|
[5285] | 367 | } |
---|
[3842] | 368 | |
---|
| 369 | searchE.prototype.searchFor = function( borderID, sortType ) |
---|
| 370 | { |
---|
| 371 | var border_id = borderID; |
---|
| 372 | var sort_type = sortType; |
---|
[5219] | 373 | var is_local = border_id.match('.*_local_.*'); |
---|
| 374 | if(!is_local) |
---|
| 375 | if( this.value ) |
---|
| 376 | return this.quickSearchMail( document.getElementsByName(currentTab)[0].value, false, sortType, border_id ); |
---|
[5134] | 377 | |
---|
[3842] | 378 | var args = "$this.imap_functions.search_msg"; |
---|
| 379 | var params = "condition="+EsearchE.condition+"&page="+EsearchE.page+"&sort_type="+sort_type; |
---|
| 380 | |
---|
| 381 | var handler = function( data ) |
---|
| 382 | { |
---|
| 383 | var allMsg = [3]; |
---|
| 384 | var gears = []; |
---|
| 385 | var local_folders = []; |
---|
| 386 | |
---|
[4796] | 387 | if ( preferences.use_local_messages == 1 && is_local) |
---|
[3842] | 388 | { |
---|
| 389 | temp = expresso_local_messages.list_local_folders(); |
---|
| 390 | |
---|
| 391 | for (var x in temp) |
---|
| 392 | { |
---|
| 393 | local_folders.push( temp[x][0] ); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | |
---|
[4796] | 397 | if ( local_folders.length > 0 ){ |
---|
[5215] | 398 | var currentSearch = document.getElementsByName(currentTab); |
---|
[4796] | 399 | expresso_local_messages.setSortType(sortType); |
---|
[5215] | 400 | gears = expresso_local_messages.search( local_folders, "##ALL <=>"+currentSearch[0].value +"##" ); |
---|
[4796] | 401 | } |
---|
[3842] | 402 | } |
---|
[5219] | 403 | if (!is_local) |
---|
[3842] | 404 | { |
---|
[5219] | 405 | if( data['num_msgs']) |
---|
| 406 | { |
---|
| 407 | allMsg['data'] = data['data']; |
---|
| 408 | allMsg['num_msgs'] = data['num_msgs']; |
---|
| 409 | |
---|
| 410 | } |
---|
| 411 | } |
---|
[4796] | 412 | |
---|
| 413 | if (gears.length > 0) |
---|
| 414 | { |
---|
| 415 | allMsg['data_gears'] = gears; |
---|
| 416 | } |
---|
[3842] | 417 | |
---|
[5219] | 418 | var currentSearch = document.getElementsByName(currentTab)[0].value; |
---|
| 419 | |
---|
[3842] | 420 | delete_border( border_id, false ); |
---|
| 421 | |
---|
[5219] | 422 | EsearchE.mount_result( allMsg , sort_type, null, null, null, currentSearch ); |
---|
[3842] | 423 | }; |
---|
[4796] | 424 | |
---|
| 425 | if (is_local) |
---|
| 426 | { |
---|
| 427 | eval("handler('none')"); |
---|
| 428 | } |
---|
| 429 | else |
---|
| 430 | { |
---|
| 431 | cExecute(args,handler,params); |
---|
| 432 | } |
---|
[3842] | 433 | } |
---|
| 434 | |
---|
| 435 | searchE.prototype.viewLocalMessage = function() |
---|
| 436 | { |
---|
| 437 | var data = [2]; |
---|
| 438 | var gears = []; |
---|
| 439 | var local_folders = []; |
---|
| 440 | |
---|
| 441 | // Gears - local |
---|
| 442 | if ( preferences.use_local_messages == 1 ) |
---|
| 443 | { |
---|
| 444 | temp = expresso_local_messages.list_local_folders(); |
---|
| 445 | |
---|
| 446 | for (var x in temp) |
---|
[3223] | 447 | { |
---|
[3842] | 448 | local_folders.push( temp[x][0] ); |
---|
[3223] | 449 | } |
---|
[3842] | 450 | |
---|
[5215] | 451 | if ( local_folders.length > 0 ){ |
---|
| 452 | var currentSearch = document.getElementsByName(currentTab); |
---|
[5267] | 453 | if(currentSearch[0].value != ''){ |
---|
| 454 | gears = expresso_local_messages.search( local_folders, "##ALL <=>"+currentSearch[0].value +"##"); |
---|
| 455 | }else{ |
---|
| 456 | if(openTab.condition[currentTab]){ |
---|
| 457 | var condit = openTab.condition[currentTab][0].split(','); |
---|
| 458 | var filter = condit[0].split('##'); |
---|
| 459 | gears = expresso_local_messages.search( local_folders, '##'+filter[1]+'##'); |
---|
| 460 | |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | } |
---|
[5215] | 464 | } |
---|
[3842] | 465 | |
---|
| 466 | data['data_gears'] = gears; |
---|
| 467 | data['num_msgs'] = gears.length; |
---|
| 468 | |
---|
[5215] | 469 | if(data['num_msgs'] != undefined) |
---|
| 470 | write_msg( data['num_msgs'] + " " + get_lang("results found") ); |
---|
| 471 | |
---|
[4796] | 472 | EsearchE.mount_result( data, 'SORTDATE' ); |
---|
[3223] | 473 | } |
---|
[3802] | 474 | } |
---|
[3842] | 475 | |
---|
[4821] | 476 | searchE.prototype.make_tr_message = function(aux,border_id,i) { |
---|
| 477 | var tr = document.createElement("TR"); |
---|
| 478 | if(typeof(preferences.line_height) != 'undefined') |
---|
| 479 | tr.style.height = preferences.line_height; |
---|
| 480 | |
---|
| 481 | var mailbox = aux.boxname; |
---|
| 482 | var uid_msg = aux.uid; |
---|
| 483 | var subject = aux.subject; |
---|
| 484 | |
---|
| 485 | tr.id = uid_msg+"_s"+numBox; |
---|
| 486 | |
---|
| 487 | // Keep the two lines together please |
---|
| 488 | tr.setAttribute('name',mailbox); |
---|
| 489 | tr.name = mailbox; |
---|
| 490 | |
---|
| 491 | if ( aux.flag.match("U") ) |
---|
| 492 | add_className(tr,'tr_msg_unread'); |
---|
| 493 | |
---|
| 494 | add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read'); |
---|
| 495 | |
---|
| 496 | var _onclick = function() |
---|
| 497 | { |
---|
| 498 | proxy_mensagens.get_msg(this.parentNode.id,url_encode(this.parentNode.getAttribute('name')),false,show_msg); |
---|
| 499 | }; |
---|
| 500 | |
---|
| 501 | for(var j=0 ; j <= 10 ; j++) |
---|
| 502 | { |
---|
| 503 | var td = document.createElement("TD"); |
---|
[5134] | 504 | add_className(td, 'td_msg'); |
---|
[4821] | 505 | if (j == 0) |
---|
| 506 | { |
---|
| 507 | td.setAttribute("width", colSizes[1][0]); |
---|
| 508 | var chk_onclick; |
---|
| 509 | if (is_ie) |
---|
| 510 | chk_onclick = "changeBgColor(window.event,"+uid_msg+");"; |
---|
| 511 | else |
---|
[5134] | 512 | chk_onclick = "changeBgColor(event,"+uid_msg+");"; //'search_' + numBox |
---|
| 513 | var td1 = '<input type="checkbox" onclick="' + chk_onclick + '" id="' + border_id + '_check_box_message_'+uid_msg+'"></input>'; |
---|
[4821] | 514 | |
---|
| 515 | } |
---|
| 516 | if (j == 1) |
---|
| 517 | { |
---|
| 518 | td.setAttribute("width", colSizes[1][1]); |
---|
| 519 | if (aux.flag.match('T')) |
---|
| 520 | { |
---|
| 521 | attachNum = parseInt(aux.flag.substr(aux.flag.indexOf('T')+1)); |
---|
| 522 | td1 = "<img src='templates/"+template+"/images/clip.gif' title='"+attachNum +' '+ get_lang('attachment(s)')+"'>"; |
---|
| 523 | } |
---|
| 524 | else |
---|
| 525 | td1 = ''; |
---|
| 526 | } |
---|
| 527 | if (j == 2) |
---|
| 528 | { |
---|
| 529 | td.setAttribute("width", colSizes[1][2]); |
---|
| 530 | td.id = "td_message_answered_"+uid_msg; |
---|
| 531 | if (aux.flag.match('X')) |
---|
| 532 | td1 = '<img src=templates/'+template+'/images/forwarded.gif title="'+get_lang('Forwarded')+'">'; |
---|
| 533 | else |
---|
| 534 | if (aux.flag.match('A')) |
---|
| 535 | td1 = '<img src=templates/'+template+'/images/answered.gif title="'+get_lang('Answered')+'">'; |
---|
| 536 | else |
---|
| 537 | td1 = ''; |
---|
| 538 | } |
---|
| 539 | if (j == 3) |
---|
| 540 | { |
---|
| 541 | td.setAttribute("width", colSizes[1][3]); |
---|
[5134] | 542 | td.id = "td_message_important_"+uid_msg; |
---|
[4821] | 543 | if (aux.flag.match("F")) |
---|
| 544 | { |
---|
| 545 | add_className(tr, 'flagged_msg'); |
---|
| 546 | td1 = "<img src='templates/"+template+"/images/important.gif' title='"+get_lang('Flagged')+"'>"; |
---|
| 547 | } |
---|
| 548 | else |
---|
| 549 | td1 = ''; |
---|
| 550 | } |
---|
| 551 | if (j == 4) |
---|
| 552 | { |
---|
| 553 | td.setAttribute("width", colSizes[1][4]); |
---|
| 554 | td.id = "td_message_sent_"+uid_msg; |
---|
| 555 | td1 = ''; |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | if ( j == 5 ) |
---|
| 559 | { |
---|
| 560 | td.setAttribute("width", colSizes[1][5]); |
---|
| 561 | td.className = "td_resizable"; |
---|
| 562 | td.onclick = _onclick; |
---|
| 563 | var nm_box = aux.boxname.split(cyrus_delimiter); |
---|
| 564 | var td1 = nm_box.pop(); |
---|
| 565 | td.setAttribute("NoWrap","true"); |
---|
| 566 | td.style.overflow = "hidden"; |
---|
| 567 | td.style.color = "#42795b"; |
---|
| 568 | td.style.fontWeight = "bold"; |
---|
| 569 | |
---|
| 570 | var td1 = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1); |
---|
| 571 | |
---|
| 572 | td1 = translateFolder(td1); |
---|
| 573 | |
---|
| 574 | |
---|
| 575 | if( proxy_mensagens.is_local_folder(td1)) |
---|
| 576 | { |
---|
| 577 | var td1 = this.aux_local_folder_display(td1); |
---|
| 578 | } |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | if( j == 6 ) |
---|
| 582 | { |
---|
[5134] | 583 | if ( aux.from !== null && aux.from.length > 29) |
---|
[4821] | 584 | aux.from = aux.from.substr(0,29) + "..."; |
---|
| 585 | |
---|
| 586 | td.setAttribute("width", colSizes[1][6]); |
---|
| 587 | td.className = "td_resizable"; |
---|
| 588 | td.onclick = _onclick; |
---|
| 589 | td.setAttribute("NoWrap","true"); |
---|
| 590 | td.style.overflow = "hidden"; |
---|
| 591 | var td1 = '<div style="width:100%;overflow:hidden">'+aux.from+"</div>"; |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | if( j == 7 ) |
---|
| 595 | { |
---|
| 596 | var subject_encode = url_encode(subject); |
---|
| 597 | |
---|
| 598 | if (! subject_encode) |
---|
| 599 | aux.subject = get_lang("no subject") + "..."; |
---|
| 600 | if (aux.subject.length > 70) |
---|
| 601 | aux.subject = aux.subject.substr(0,70) + "..."; |
---|
| 602 | |
---|
| 603 | td.setAttribute("width", colSizes[1][7]); |
---|
| 604 | td.className = "td_resizable"; |
---|
| 605 | td.onclick = _onclick; |
---|
| 606 | td.setAttribute("NoWrap","true"); |
---|
| 607 | td.style.overflow = "hidden"; |
---|
| 608 | |
---|
| 609 | var td1 = aux.subject; |
---|
| 610 | } |
---|
| 611 | |
---|
| 612 | if( j == 8 ) |
---|
| 613 | { |
---|
| 614 | td.setAttribute("width", colSizes[1][8]); |
---|
| 615 | td.className = "td_resizable"; |
---|
| 616 | td.align = "center"; |
---|
| 617 | td.onclick = _onclick; |
---|
| 618 | |
---|
| 619 | if( validate_date( aux.udate ) ) |
---|
| 620 | { |
---|
| 621 | var td1 = aux.udate; |
---|
| 622 | } |
---|
| 623 | else |
---|
| 624 | { |
---|
| 625 | var dt = new Date( aux.udate * 1000 ); |
---|
| 626 | var td1 = dt.getDate() + "/"; |
---|
| 627 | |
---|
| 628 | if( !( dt.getMonth() + 1 ).toString().match(/\d{2}/) ) |
---|
| 629 | td1 += "0"+( dt.getMonth() + 1 ) + "/"; |
---|
| 630 | else |
---|
| 631 | td1 += ( dt.getMonth() + 1 ) + "/"; |
---|
| 632 | |
---|
| 633 | td1 += dt.getFullYear(); |
---|
| 634 | } |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | if( j == 9 ) |
---|
| 638 | { |
---|
[5235] | 639 | td.setAttribute("width", "9.4%");//alinhamento dos campos data e tamanho |
---|
[4821] | 640 | td.className = "td_resizable"; |
---|
| 641 | td.align = "center"; |
---|
| 642 | td.onclick = _onclick; |
---|
| 643 | var td1 = borkb(aux.size); |
---|
| 644 | } |
---|
| 645 | |
---|
| 646 | if( j == 10 ) |
---|
| 647 | { |
---|
| 648 | if (aux.flag.match("U")) |
---|
| 649 | add_className(tr, 'tr_msg_unread'); |
---|
| 650 | if (aux.flag.match("F")) |
---|
| 651 | add_className(tr, 'flagged_msg'); |
---|
| 652 | var td1 = ''; |
---|
| 653 | } |
---|
| 654 | if (j<10) { |
---|
| 655 | td.innerHTML = td1; |
---|
| 656 | tr.appendChild(td); |
---|
| 657 | } |
---|
| 658 | } |
---|
| 659 | |
---|
| 660 | _dragArea.makeDragged(tr, uid_msg, subject, true, mailbox); |
---|
| 661 | |
---|
| 662 | return tr; |
---|
| 663 | } |
---|
| 664 | |
---|
[3802] | 665 | // Form resultado |
---|
[5219] | 666 | searchE.prototype.mount_result = function( Data, sort_type, keep_border, keep_filled, division, actualSearch ) |
---|
[3842] | 667 | { |
---|
| 668 | var data = ( Data['data'] ) ? Data['data'] : Data['data_gears']; |
---|
| 669 | |
---|
| 670 | if ( data == undefined ) |
---|
[3802] | 671 | return; |
---|
[3842] | 672 | |
---|
[3802] | 673 | var cont = parseInt(0); |
---|
[3018] | 674 | |
---|
[3842] | 675 | if ( typeof(sort_type) != 'undefined') |
---|
[3802] | 676 | this.sort_type = sort_type; |
---|
| 677 | else |
---|
| 678 | sort_type = this.sort_type; |
---|
| 679 | |
---|
[4821] | 680 | if ( keep_border ) { |
---|
| 681 | var border_id = currentTab; |
---|
| 682 | } |
---|
| 683 | else { |
---|
[5172] | 684 | if(isNaN(numBox)){ |
---|
| 685 | var aux = numBox.split("_"); |
---|
| 686 | numBox = parseInt(aux[0]) + 1; |
---|
[5215] | 687 | }else{ |
---|
| 688 | inc_abas_search++; |
---|
| 689 | numBox = inc_abas_search; |
---|
| 690 | } |
---|
[4821] | 691 | if( Data['data'] ) |
---|
[5219] | 692 | if(!actualSearch) |
---|
| 693 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox); |
---|
| 694 | else |
---|
| 695 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox, actualSearch); |
---|
[4821] | 696 | if( Data['data_gears']) |
---|
[5219] | 697 | if(!actualSearch) |
---|
| 698 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox); |
---|
| 699 | else |
---|
| 700 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox, actualSearch); |
---|
[4821] | 701 | } |
---|
| 702 | |
---|
[3682] | 703 | if (!border_id) |
---|
| 704 | return; |
---|
| 705 | |
---|
| 706 | currentTab = border_id; |
---|
[5134] | 707 | openTab.content_id[currentTab] = Element('content_id_search_' + numBox); |
---|
[3682] | 708 | openTab.type[currentTab] = 1; |
---|
[4821] | 709 | openTab.condition[currentTab] = this.condition; |
---|
| 710 | |
---|
| 711 | if ( keep_border ) { |
---|
| 712 | var content_search = Element('content_id_' + border_id); |
---|
[5134] | 713 | var div_scroll_result = Element("divScrollMain_"+numBox); |
---|
| 714 | |
---|
[4821] | 715 | content_search.removeChild(div_scroll_result); |
---|
[5134] | 716 | |
---|
| 717 | if( !keep_filled ) |
---|
| 718 | div_scroll_result = false; |
---|
[4821] | 719 | } |
---|
| 720 | |
---|
[2] | 721 | var table = document.createElement("TABLE"); |
---|
[5134] | 722 | table.id = "table_resultsearch_" + numBox; |
---|
[3842] | 723 | table.frame = "void"; |
---|
| 724 | table.rules = "rows"; |
---|
| 725 | table.cellPadding = "0"; |
---|
| 726 | table.cellSpacing = "0"; |
---|
| 727 | table.className = "table_box"; |
---|
[72] | 728 | |
---|
[3682] | 729 | var tbody = document.createElement("TBODY"); |
---|
[5134] | 730 | tbody.id = "tbody_box_" + numBox; |
---|
[3380] | 731 | |
---|
[3842] | 732 | for( var i=0; i < data.length; i++) |
---|
| 733 | { |
---|
[5134] | 734 | if(data[i] !== null){ |
---|
[4821] | 735 | var tr = EsearchE.make_tr_message(data[i],border_id,i); |
---|
[3842] | 736 | tbody.appendChild(tr); |
---|
[2] | 737 | } |
---|
[5134] | 738 | } |
---|
[3842] | 739 | |
---|
[4802] | 740 | //global_search++; //Tabs from search must not have the same id on its tr's // use numBox instead of this! |
---|
[3802] | 741 | |
---|
[2] | 742 | table.appendChild(tbody); |
---|
[832] | 743 | |
---|
[4062] | 744 | var colgr_element = buildColGroup(1); |
---|
[5134] | 745 | colgr_element.setAttribute("id","colgroup_main_"+numBox); |
---|
[4062] | 746 | table.appendChild(colgr_element); |
---|
| 747 | |
---|
[4807] | 748 | var content_search = Element('content_id_' + border_id); |
---|
[5134] | 749 | |
---|
| 750 | if( !div_scroll_result ) |
---|
| 751 | { |
---|
[3842] | 752 | var div_scroll_result = document.createElement("DIV"); |
---|
[5134] | 753 | div_scroll_result.id = "divScrollMain_"+numBox; |
---|
[4062] | 754 | div_scroll_result.style.overflowY = "scroll"; |
---|
| 755 | div_scroll_result.style.overflowX = "hidden"; |
---|
| 756 | div_scroll_result.style.width ="100%"; |
---|
[3842] | 757 | |
---|
[4062] | 758 | if (is_mozilla){ |
---|
| 759 | div_scroll_result.style.overflow = "-moz-scrollbars-vertical"; |
---|
| 760 | div_scroll_result.style.width ="100%"; |
---|
| 761 | } |
---|
[5134] | 762 | } |
---|
| 763 | if( division ) |
---|
| 764 | { |
---|
| 765 | var _div = document.createElement("div"); |
---|
| 766 | _div.className = 'local-messages-search-warning'; |
---|
| 767 | _div.innerHTML = division; |
---|
| 768 | div_scroll_result.appendChild(_div); |
---|
| 769 | } |
---|
[4062] | 770 | |
---|
[67] | 771 | if(is_ie) |
---|
[72] | 772 | Element("border_table").width = "99.5%"; |
---|
[3380] | 773 | |
---|
[832] | 774 | // Put header |
---|
[67] | 775 | var table_element = document.createElement("TABLE"); |
---|
| 776 | var tbody_element = document.createElement("TBODY"); |
---|
[4062] | 777 | if (is_ie) |
---|
| 778 | { |
---|
| 779 | table_element.attachEvent("onmousemove",changeCursorState); |
---|
| 780 | table_element.attachEvent("onmousedown",startColResize); |
---|
| 781 | } |
---|
| 782 | else { |
---|
| 783 | table_element.addEventListener("mousemove",changeCursorState,false); |
---|
| 784 | table_element.addEventListener("mousedown",startColResize,false); |
---|
| 785 | } |
---|
[5134] | 786 | table_element.setAttribute("id", "table_message_header_box_"+numBox); |
---|
[67] | 787 | table_element.className = "table_message_header_box"; |
---|
[4062] | 788 | if (!is_ie) |
---|
| 789 | table_element.style.width = "98.8%"; |
---|
| 790 | table_element.emptyBody = false; |
---|
| 791 | |
---|
[67] | 792 | tr_element = document.createElement("TR"); |
---|
| 793 | tr_element.className = "message_header"; |
---|
[4062] | 794 | td_element0 = createTDElement(1,0); |
---|
[156] | 795 | chk_box_element = document.createElement("INPUT"); |
---|
[5264] | 796 | if(border_id.indexOf('local') > 0) |
---|
| 797 | chk_box_element.id = "chk_box_select_all_messages_search_local"; |
---|
| 798 | else |
---|
| 799 | chk_box_element.id = "chk_box_select_all_messages_search"; |
---|
[156] | 800 | chk_box_element.setAttribute("type", "checkbox"); |
---|
| 801 | chk_box_element.className = "checkbox"; |
---|
[163] | 802 | chk_box_element.onclick = function(){select_all_search_messages(this.checked,content_search.id);}; |
---|
[156] | 803 | chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages.')}; |
---|
[3842] | 804 | chk_box_element.onkeydown = function (e) |
---|
| 805 | { |
---|
[156] | 806 | if (is_ie) |
---|
| 807 | { |
---|
| 808 | if ((window.event.keyCode) == 46) |
---|
[832] | 809 | delete_msgs(current_folder,'selected','null'); |
---|
[156] | 810 | } |
---|
| 811 | else |
---|
| 812 | { |
---|
| 813 | if ((e.keyCode) == 46) |
---|
[832] | 814 | delete_msgs(current_folder,'selected','null'); |
---|
[156] | 815 | } |
---|
| 816 | }; |
---|
[3380] | 817 | |
---|
[156] | 818 | td_element0.appendChild(chk_box_element); |
---|
[4062] | 819 | td_element01 = createTDElement(1,1); |
---|
| 820 | td_element02 = createTDElement(1,2); |
---|
| 821 | td_element03 = createTDElement(1,3); |
---|
| 822 | td_element04 = createTDElement(1,4); |
---|
| 823 | td_element1 = createTDElement(1,5,"th_resizable","left"); |
---|
[3842] | 824 | |
---|
| 825 | var arrow_ascendant = function(Text) |
---|
[832] | 826 | { |
---|
[3842] | 827 | return "<b>" + Text + "</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
[832] | 828 | } |
---|
[3842] | 829 | |
---|
| 830 | // Ordernar Pasta |
---|
[5134] | 831 | if ( sort_type == 'SORTBOX' /*|| sort_type == 'SORTBOX_REVERSE'*/ ) |
---|
[3842] | 832 | { |
---|
| 833 | if( Data['data'] ) |
---|
| 834 | { |
---|
| 835 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); }; |
---|
[3846] | 836 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 837 | } |
---|
| 838 | else |
---|
| 839 | { |
---|
[4796] | 840 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); }; |
---|
| 841 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 842 | } |
---|
| 843 | } |
---|
[832] | 844 | else |
---|
| 845 | { |
---|
[3842] | 846 | if( Data['data'] ) |
---|
| 847 | { |
---|
| 848 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX'); }; |
---|
| 849 | } |
---|
[832] | 850 | else |
---|
[3842] | 851 | { |
---|
[4796] | 852 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX'); }; |
---|
[3842] | 853 | } |
---|
| 854 | td_element1.innerHTML = ( sort_type == 'SORTBOX_REVERSE' ) ? arrow_ascendant(get_lang("Folder")) : get_lang("Folder"); |
---|
[832] | 855 | } |
---|
[3842] | 856 | |
---|
| 857 | // Ordernar Quem |
---|
[4062] | 858 | td_element2 = createTDElement(1,6,"th_resizable","left"); |
---|
[3842] | 859 | |
---|
[5134] | 860 | if (sort_type == 'SORTFROM' || sort_type == 'SORTWHO' /*|| sort_type == 'SORTWHO_REVERSE' || sort_type == 'SORTFROM_REVERSE'*/ ) |
---|
[832] | 861 | { |
---|
[3842] | 862 | if(Data['data']) |
---|
| 863 | { |
---|
[4771] | 864 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTFROM_REVERSE'); }; |
---|
| 865 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 866 | } |
---|
| 867 | else |
---|
| 868 | { |
---|
[4796] | 869 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO_REVERSE'); }; |
---|
[5197] | 870 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 871 | } |
---|
[832] | 872 | } |
---|
| 873 | else |
---|
| 874 | { |
---|
[3842] | 875 | if( Data['data'] ) |
---|
| 876 | { |
---|
| 877 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO'); }; |
---|
| 878 | } |
---|
[832] | 879 | else |
---|
[3842] | 880 | { |
---|
[4796] | 881 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO'); }; |
---|
[3842] | 882 | } |
---|
[5197] | 883 | td_element2.innerHTML = ( sort_type == 'SORTWHO_REVERSE' ) ? arrow_ascendant(get_lang("From")) : get_lang("From"); |
---|
[832] | 884 | } |
---|
[3842] | 885 | |
---|
| 886 | // Ordernar Subject |
---|
[4062] | 887 | td_element3 = createTDElement(1,7,"th_resizable","left"); |
---|
[3842] | 888 | |
---|
[5134] | 889 | if (sort_type == 'SORTSUBJECT' /*|| sort_type == 'SORTSUBJECT_REVERSE'*/) |
---|
[832] | 890 | { |
---|
[3842] | 891 | if( Data['data']) |
---|
| 892 | { |
---|
| 893 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); }; |
---|
[3846] | 894 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 895 | } |
---|
| 896 | else |
---|
| 897 | { |
---|
[4796] | 898 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); }; |
---|
| 899 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 900 | } |
---|
[832] | 901 | } |
---|
| 902 | else |
---|
| 903 | { |
---|
[3842] | 904 | if( Data['data'] ) |
---|
| 905 | { |
---|
| 906 | td_element3.onclick = function(){ EsearchE.searchFor( border_id, 'SORTSUBJECT'); }; |
---|
| 907 | } |
---|
[832] | 908 | else |
---|
[3842] | 909 | { |
---|
[4796] | 910 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT'); }; |
---|
[3842] | 911 | } |
---|
| 912 | td_element3.innerHTML = ( sort_type == 'SORTSUBJECT_REVERSE' ) ? arrow_ascendant(get_lang("subject")) : get_lang("subject"); |
---|
[832] | 913 | } |
---|
[3842] | 914 | |
---|
| 915 | // Ordernar Data |
---|
[4062] | 916 | td_element4 = createTDElement(1,8,"th_resizable","center"); |
---|
[3842] | 917 | |
---|
[5134] | 918 | if ( sort_type == 'SORTDATE' /*|| sort_type == 'SORTDATE_REVERSE'*/ ) |
---|
[832] | 919 | { |
---|
[3842] | 920 | if( Data['data'] ) |
---|
| 921 | { |
---|
| 922 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); }; |
---|
[3846] | 923 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 924 | } |
---|
| 925 | else |
---|
| 926 | { |
---|
[4796] | 927 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); }; |
---|
| 928 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 929 | } |
---|
[832] | 930 | } |
---|
| 931 | else |
---|
| 932 | { |
---|
[3842] | 933 | if( Data['data'] ) |
---|
| 934 | { |
---|
| 935 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE'); }; |
---|
| 936 | } |
---|
[832] | 937 | else |
---|
[3842] | 938 | { |
---|
[4796] | 939 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE'); }; |
---|
[3842] | 940 | } |
---|
| 941 | td_element4.innerHTML = ( sort_type == 'SORTDATE_REVERSE' ) ? arrow_ascendant(get_lang("Date")) : get_lang("Date"); |
---|
| 942 | } |
---|
| 943 | |
---|
| 944 | // Ordernar Tamanho |
---|
[4062] | 945 | td_element5 = createTDElement(1,9,"th_resizable","center"); |
---|
[3842] | 946 | |
---|
[5134] | 947 | if ( sort_type == 'SORTSIZE' /*|| sort_type == 'SORTSIZE_REVERSE'*/ ) |
---|
[832] | 948 | { |
---|
[3842] | 949 | if( Data['data'] ) |
---|
| 950 | { |
---|
| 951 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); }; |
---|
[3846] | 952 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 953 | } |
---|
| 954 | else |
---|
| 955 | { |
---|
[4796] | 956 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); }; |
---|
| 957 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 958 | } |
---|
[832] | 959 | } |
---|
| 960 | else |
---|
| 961 | { |
---|
[3842] | 962 | if( Data['data'] ) |
---|
| 963 | { |
---|
| 964 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE'); }; |
---|
| 965 | } |
---|
[832] | 966 | else |
---|
[3842] | 967 | { |
---|
[4796] | 968 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE'); }; |
---|
[3842] | 969 | } |
---|
| 970 | td_element5.innerHTML = ( sort_type == 'SORTSIZE_REVERSE' ) ? arrow_ascendant(get_lang("size")) : get_lang("size"); |
---|
[832] | 971 | } |
---|
[3842] | 972 | |
---|
[156] | 973 | tr_element.appendChild(td_element0); |
---|
[4062] | 974 | tr_element.appendChild(td_element01); |
---|
| 975 | tr_element.appendChild(td_element02); |
---|
| 976 | tr_element.appendChild(td_element03); |
---|
| 977 | tr_element.appendChild(td_element04); |
---|
[67] | 978 | tr_element.appendChild(td_element1); |
---|
| 979 | tr_element.appendChild(td_element2); |
---|
| 980 | tr_element.appendChild(td_element3); |
---|
| 981 | tr_element.appendChild(td_element4); |
---|
| 982 | tr_element.appendChild(td_element5); |
---|
| 983 | tbody_element.appendChild(tr_element); |
---|
| 984 | table_element.appendChild(tbody_element); |
---|
[3842] | 985 | |
---|
[4062] | 986 | var colgr_element = buildColGroup(1); |
---|
[5134] | 987 | colgr_element.setAttribute("id","colgroup_head_"+numBox); |
---|
[4062] | 988 | table_element.appendChild(colgr_element); |
---|
| 989 | |
---|
[5134] | 990 | if( parseInt( Data['gears_num_msgs'] ) > 0 && !keep_filled) |
---|
[3842] | 991 | { |
---|
[5219] | 992 | var messagesWarning = document.getElementById("local-messages-search-warning_"+border_id); |
---|
| 993 | if(!messagesWarning){ |
---|
| 994 | var _div_gears = document.createElement("div"); |
---|
| 995 | _div_gears.id = "local-messages-search-warning_"+border_id; |
---|
| 996 | _div_gears.onclick = function(){ EsearchE.viewLocalMessage(); }; |
---|
| 997 | _div_gears.className = 'local-messages-search-warning'; |
---|
| 998 | _div_gears.innerHTML = get_lang("The search has% 1 messages stored locally. Want to see them ? Click here.", Data['gears_num_msgs']); |
---|
| 999 | content_search.appendChild(_div_gears); |
---|
| 1000 | } |
---|
[3842] | 1001 | } |
---|
| 1002 | |
---|
[5134] | 1003 | var _divScroll = document.getElementById("divScrollHead_"+numBox); |
---|
| 1004 | |
---|
| 1005 | if( _divScroll ){ |
---|
| 1006 | content_search.removeChild(_divScroll); |
---|
| 1007 | _divScroll = false; |
---|
| 1008 | } |
---|
[3842] | 1009 | |
---|
[4062] | 1010 | _divScroll = document.createElement("DIV"); |
---|
[5134] | 1011 | _divScroll.id = "divScrollHead_"+numBox; |
---|
[4062] | 1012 | _divScroll.style.overflowY = "hidden"; |
---|
| 1013 | _divScroll.style.overflowX = "hidden"; |
---|
| 1014 | _divScroll.style.width ="100%"; |
---|
| 1015 | |
---|
| 1016 | if (is_mozilla){ |
---|
| 1017 | _divScroll.style.width ="99.3%"; |
---|
| 1018 | } |
---|
| 1019 | _divScroll.appendChild(table_element); |
---|
| 1020 | content_search.appendChild(_divScroll); |
---|
[5134] | 1021 | |
---|
[1121] | 1022 | /*end of "put header"*/ |
---|
[3842] | 1023 | if ( !expresso_offline ) |
---|
| 1024 | { |
---|
[1121] | 1025 | div_scroll_result.appendChild(table); |
---|
| 1026 | content_search.appendChild(div_scroll_result); |
---|
| 1027 | } |
---|
[3842] | 1028 | else |
---|
| 1029 | { |
---|
[1121] | 1030 | div_scroll_result.appendChild(table); |
---|
| 1031 | content_search.appendChild(div_scroll_result); |
---|
| 1032 | } |
---|
[3842] | 1033 | |
---|
[3223] | 1034 | resizeWindow(); |
---|
[4799] | 1035 | if(typeof(Data.data_gears)=="undefined") |
---|
| 1036 | EsearchE.show_paging( Data['num_msgs'] ); |
---|
[2] | 1037 | } |
---|
| 1038 | |
---|
[3842] | 1039 | searchE.prototype.open_msg = function(mailbox, uid_msg, subject) |
---|
| 1040 | { |
---|
| 1041 | var handler_get_msg = function(data) |
---|
| 1042 | { |
---|
| 1043 | if( Element("border_id_" + uid_msg + "_r") ) |
---|
| 1044 | alert(get_lang("This message is already opened!")); |
---|
| 1045 | else |
---|
| 1046 | draw_message( data, create_border(url_decode(subject), uid_msg + "_r") ); |
---|
[2] | 1047 | } |
---|
[3842] | 1048 | |
---|
[3802] | 1049 | proxy_mensagens.get_msg(uid_msg,mailbox,false,handler_get_msg); |
---|
[2] | 1050 | } |
---|
| 1051 | |
---|
| 1052 | // Adiciona caixas postais na busca; |
---|
[3842] | 1053 | searchE.prototype.add_mailboxes = function() |
---|
| 1054 | { |
---|
[69] | 1055 | var sel = Element("sel_search_nm_box1"); |
---|
[689] | 1056 | if (!proxy_mensagens.is_local_folder(this.name_box_search)) { |
---|
| 1057 | var name_box = this.name_box_search.split(cyrus_delimiter); |
---|
| 1058 | if(this.name_box_search == "") |
---|
| 1059 | return false; |
---|
| 1060 | var name_box_def = ""; |
---|
| 1061 | if(name_box.length != 1){ |
---|
| 1062 | name_box_def = name_box[(name_box.length-1)]; |
---|
| 1063 | }else{ |
---|
[3380] | 1064 | name_box_def = get_lang("Inbox"); |
---|
[689] | 1065 | } |
---|
[2] | 1066 | } |
---|
[689] | 1067 | else { |
---|
| 1068 | if(this.name_box_search=='local_root') |
---|
| 1069 | return; |
---|
| 1070 | if(this.name_box_search=='local_Inbox') |
---|
| 1071 | name_box_def = get_lang("Inbox"); |
---|
[3802] | 1072 | else if(this.name_box_search.indexOf("/")!="-1") { |
---|
| 1073 | final_pos = this.name_box_search.lastIndexOf("/"); |
---|
| 1074 | name_box_def = this.name_box_search.substr(final_pos+1); |
---|
| 1075 | } |
---|
[689] | 1076 | else |
---|
| 1077 | name_box_def = this.name_box_search.substr(6);//Retira o 'local_' |
---|
| 1078 | } |
---|
[2] | 1079 | if( sel.length > 0){ |
---|
| 1080 | for(var i=0; i < sel.options.length; i++){ |
---|
| 1081 | if(sel.options[i].value == this.name_box_search){ |
---|
| 1082 | alert(get_lang('This message is already selected!')); |
---|
| 1083 | return false; |
---|
| 1084 | } |
---|
| 1085 | } |
---|
| 1086 | } |
---|
[4749] | 1087 | name_box_def = translateFolder(name_box_def); |
---|
[96] | 1088 | var opt = new Option(lang_folder(name_box_def),this.name_box_search,false,true); |
---|
[2] | 1089 | sel[sel.length] = opt; |
---|
| 1090 | } |
---|
[3842] | 1091 | |
---|
| 1092 | // Remove as caixas postais na busca; |
---|
| 1093 | searchE.prototype.del_mailboxes = function() |
---|
| 1094 | { |
---|
[69] | 1095 | var sel = Element("sel_search_nm_box1"); |
---|
[3842] | 1096 | if(sel.length > 0) |
---|
| 1097 | { |
---|
| 1098 | for(var i=0; i < sel.options.length; i++) |
---|
| 1099 | { |
---|
| 1100 | if(sel.options[i].selected == true) |
---|
| 1101 | { |
---|
[2] | 1102 | sel.options[i] = null; |
---|
| 1103 | i--; |
---|
| 1104 | } |
---|
| 1105 | } |
---|
| 1106 | } |
---|
[3380] | 1107 | |
---|
[2] | 1108 | } |
---|
[3842] | 1109 | |
---|
[2] | 1110 | // todas as caixas |
---|
[3842] | 1111 | searchE.prototype.all_mailboxes = function() |
---|
| 1112 | { |
---|
[69] | 1113 | var value = Element("check_all_msg").checked; |
---|
[2] | 1114 | var cont = parseInt(0); |
---|
[3842] | 1115 | if(value) |
---|
| 1116 | { |
---|
| 1117 | if(EsearchE.all_boxes.length > 0) |
---|
| 1118 | { |
---|
[3380] | 1119 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
[2] | 1120 | } |
---|
[3842] | 1121 | for(var i=0; i < folders.length; i++) |
---|
| 1122 | { |
---|
| 1123 | EsearchE.all_boxes[cont++] = folders[i].folder_id; |
---|
[2] | 1124 | } |
---|
[3842] | 1125 | } |
---|
| 1126 | else |
---|
| 1127 | { |
---|
[2] | 1128 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 1129 | } |
---|
| 1130 | } |
---|
| 1131 | |
---|
| 1132 | // Search; |
---|
[5134] | 1133 | searchE.prototype.func_search_complex = function() |
---|
[3842] | 1134 | { |
---|
[2] | 1135 | var fields = "##"; |
---|
| 1136 | // Verifica se os campos estão preenchidos; |
---|
[69] | 1137 | if(trim(Element("txt_ass").value) != ""){ |
---|
[3802] | 1138 | fields += "SUBJECT " + "<=>" +url_encode(Element("txt_ass").value) + "##"; |
---|
[2] | 1139 | } |
---|
[69] | 1140 | if(trim(Element("txt_body").value) != ""){ |
---|
[3802] | 1141 | fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##"; |
---|
[2] | 1142 | } |
---|
[69] | 1143 | if(trim(Element("txt_de").value) != ""){ |
---|
[3802] | 1144 | fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##"; |
---|
[2] | 1145 | } |
---|
[69] | 1146 | if(trim(Element("txt_para").value) != ""){ |
---|
[3802] | 1147 | fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##"; |
---|
[2] | 1148 | } |
---|
[69] | 1149 | if(trim(Element("txt_cc").value) != ""){ |
---|
[3802] | 1150 | fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##"; |
---|
[2] | 1151 | } |
---|
[3842] | 1152 | if (trim(Element("since_date").value) != "") |
---|
| 1153 | { |
---|
| 1154 | if (validate_date(Element("since_date").value)) |
---|
| 1155 | { |
---|
| 1156 | fields += "SINCE " + "<=>" + url_encode(Element("since_date").value) + "##"; |
---|
| 1157 | } |
---|
| 1158 | else |
---|
| 1159 | { |
---|
[3925] | 1160 | alert(get_lang('Invalid date on field %1', get_lang('Since Date'))); |
---|
[3842] | 1161 | return false; |
---|
| 1162 | } |
---|
| 1163 | } |
---|
[1622] | 1164 | |
---|
[3842] | 1165 | if (trim(Element("before_date").value) != "") |
---|
| 1166 | { |
---|
| 1167 | if (validate_date(Element("before_date").value)) |
---|
| 1168 | { |
---|
| 1169 | fields += "BEFORE " + "<=>" + url_encode(Element("before_date").value) + "##"; |
---|
| 1170 | } |
---|
| 1171 | else |
---|
| 1172 | { |
---|
[3925] | 1173 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
[3842] | 1174 | return false; |
---|
| 1175 | } |
---|
| 1176 | } |
---|
[5134] | 1177 | if ((trim(Element("since_date").value) != "") && (trim(Element("before_date").value) != "")){ |
---|
| 1178 | if(!(validate_date_order(trim(Element("since_date").value), trim(Element("before_date").value)))){ |
---|
| 1179 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
| 1180 | return false; |
---|
| 1181 | } |
---|
| 1182 | } |
---|
[3842] | 1183 | if(trim(Element("on_date").value) != "") |
---|
| 1184 | { |
---|
| 1185 | if (validate_date(Element("on_date").value)) |
---|
| 1186 | { |
---|
| 1187 | fields += "ON " + "<=>" + url_encode(Element("on_date").value) + "##"; |
---|
| 1188 | } |
---|
| 1189 | else |
---|
| 1190 | { |
---|
[3925] | 1191 | alert(get_lang('Invalid date on field %1', get_lang('On Date'))); |
---|
[3842] | 1192 | return false; |
---|
| 1193 | } |
---|
| 1194 | |
---|
| 1195 | } |
---|
| 1196 | |
---|
| 1197 | if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != "") |
---|
| 1198 | { |
---|
| 1199 | if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED") |
---|
| 1200 | { |
---|
| 1201 | fields += "FLAGGED##"; |
---|
| 1202 | } |
---|
| 1203 | else |
---|
| 1204 | { |
---|
| 1205 | fields += "UNFLAGGED##"; |
---|
| 1206 | } |
---|
| 1207 | } |
---|
| 1208 | |
---|
| 1209 | if(trim(Element("seen").options[Element("seen").selectedIndex].value) != "") |
---|
| 1210 | { |
---|
| 1211 | if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN") |
---|
| 1212 | { |
---|
| 1213 | fields += "SEEN##"; |
---|
| 1214 | } |
---|
| 1215 | else |
---|
| 1216 | { |
---|
| 1217 | fields += "UNSEEN##"; |
---|
| 1218 | } |
---|
| 1219 | } |
---|
| 1220 | |
---|
| 1221 | if(trim(Element("answered").options[Element("answered").selectedIndex].value) != "") |
---|
| 1222 | { |
---|
| 1223 | if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){ |
---|
| 1224 | fields += "ANSWERED##"; |
---|
| 1225 | } |
---|
| 1226 | else { |
---|
| 1227 | fields += "UNANSWERED##"; |
---|
| 1228 | } |
---|
| 1229 | } |
---|
| 1230 | |
---|
| 1231 | if(trim(Element("recent").options[Element("recent").selectedIndex].value) != "") |
---|
| 1232 | { |
---|
| 1233 | if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT") |
---|
| 1234 | { |
---|
| 1235 | fields += "RECENT##"; |
---|
| 1236 | } |
---|
| 1237 | else |
---|
| 1238 | { |
---|
| 1239 | fields += "OLD##"; |
---|
| 1240 | } |
---|
| 1241 | } |
---|
| 1242 | |
---|
| 1243 | if(fields == "##") |
---|
| 1244 | { |
---|
[3711] | 1245 | alert(get_lang("Define some search parameters!")); |
---|
| 1246 | return false; |
---|
| 1247 | } |
---|
[3842] | 1248 | |
---|
[3711] | 1249 | var local_folders = new Array(); |
---|
| 1250 | var temp; |
---|
| 1251 | |
---|
[3842] | 1252 | if( Element("check_all_msg").checked ) |
---|
| 1253 | { |
---|
[3711] | 1254 | this.all_mailboxes(); |
---|
| 1255 | var nm_box = new Array; |
---|
[3842] | 1256 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
| 1257 | { |
---|
[3711] | 1258 | nm_box[i] = EsearchE.all_boxes[i] + fields; |
---|
| 1259 | } |
---|
[3842] | 1260 | if (preferences.use_local_messages == 1) |
---|
| 1261 | { |
---|
[3711] | 1262 | temp = expresso_local_messages.list_local_folders(); |
---|
[3842] | 1263 | for (var x in temp) |
---|
| 1264 | { |
---|
[3711] | 1265 | local_folders.push(temp[x][0]); |
---|
| 1266 | } |
---|
| 1267 | } |
---|
[3842] | 1268 | } |
---|
| 1269 | else |
---|
| 1270 | { |
---|
[3711] | 1271 | var nm_box = new Array; |
---|
| 1272 | var sel_combo = Element("sel_search_nm_box1"); |
---|
[3842] | 1273 | |
---|
| 1274 | if( sel_combo.options.length <= 0) |
---|
| 1275 | { |
---|
[3711] | 1276 | alert(get_lang("Define the boxes to search!")); |
---|
[2] | 1277 | return false; |
---|
| 1278 | } |
---|
[3380] | 1279 | |
---|
[3842] | 1280 | for(var i=0; i < sel_combo.options.length; i++) |
---|
| 1281 | { |
---|
[3711] | 1282 | sel_combo.options[i].selected = true; |
---|
[2] | 1283 | } |
---|
[3842] | 1284 | |
---|
| 1285 | for(var i=0; i < sel_combo.options.length; i++) |
---|
| 1286 | { |
---|
| 1287 | if( sel_combo.options[i].selected == true ) |
---|
| 1288 | { |
---|
[3711] | 1289 | if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value)) |
---|
| 1290 | nm_box[nm_box.length] = sel_combo.options[i].value + fields; |
---|
| 1291 | else |
---|
| 1292 | local_folders.push(sel_combo.options[i].value.substr(6)); |
---|
[2] | 1293 | } |
---|
| 1294 | } |
---|
[3711] | 1295 | } |
---|
[3842] | 1296 | |
---|
[4853] | 1297 | var handler = function( data ) |
---|
| 1298 | { |
---|
| 1299 | var allMsg = [3]; |
---|
[5134] | 1300 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
[4853] | 1301 | var tmp = []; |
---|
[3711] | 1302 | |
---|
[4853] | 1303 | // Gears - local |
---|
| 1304 | if ( local_folders.length > 0 ){ |
---|
| 1305 | expresso_local_messages.setSortType('SORTDATE'); |
---|
| 1306 | tmp = expresso_local_messages.search( local_folders, fields ); |
---|
| 1307 | } |
---|
[5134] | 1308 | |
---|
[4853] | 1309 | if( data['num_msgs'] ) |
---|
| 1310 | { |
---|
| 1311 | allMsg['data'] = data['data']; |
---|
| 1312 | allMsg['num_msgs'] = data['num_msgs']; |
---|
| 1313 | } |
---|
[3842] | 1314 | |
---|
[4853] | 1315 | if( tmp.length > 0 ) |
---|
| 1316 | { |
---|
| 1317 | allMsg['gears_num_msgs'] = tmp.length ; |
---|
| 1318 | } |
---|
| 1319 | |
---|
[5134] | 1320 | if( ( data['num_msgs'] ) == 0 ) |
---|
[4853] | 1321 | { |
---|
| 1322 | alert( get_lang("None result was found.") ); |
---|
| 1323 | } |
---|
| 1324 | else |
---|
| 1325 | { |
---|
[5134] | 1326 | if( (tmp.length > 0) && (!data['num_msgs']) ) |
---|
[4853] | 1327 | { |
---|
[5134] | 1328 | EsearchE.viewLocalMessage(); |
---|
[4853] | 1329 | } |
---|
[5134] | 1330 | else |
---|
| 1331 | { |
---|
| 1332 | if(count > 0) |
---|
| 1333 | EsearchE.func_clean(); |
---|
[4928] | 1334 | write_msg( count + " " + get_lang("results found") ); |
---|
[4853] | 1335 | EsearchE.mount_result( allMsg, 'SORTDATE' ); |
---|
| 1336 | } |
---|
[3842] | 1337 | } |
---|
[5134] | 1338 | } |
---|
[3842] | 1339 | |
---|
[4853] | 1340 | this.condition = nm_box; |
---|
| 1341 | this.page = 0; |
---|
| 1342 | var args = "$this.imap_functions.search_msg"; |
---|
| 1343 | var params = "condition=" + nm_box+ "&page=0"+ "&sort_type=SORTDATE"; |
---|
| 1344 | |
---|
| 1345 | if( expresso_offline ) |
---|
| 1346 | handler('none'); |
---|
| 1347 | else |
---|
| 1348 | cExecute( args, handler, params); |
---|
[5134] | 1349 | } |
---|
| 1350 | |
---|
| 1351 | searchE.prototype.func_search = function(value, page, sort, border_id) |
---|
| 1352 | { |
---|
| 1353 | if( !value ) |
---|
| 1354 | this.func_search_complex(); |
---|
| 1355 | else |
---|
| 1356 | this.quickSearchMail( value, page, sort, border_id ); |
---|
| 1357 | } |
---|
| 1358 | |
---|
| 1359 | searchE.prototype.quickSearchMail = function(value, page, sort, border_id) |
---|
| 1360 | { |
---|
| 1361 | var local_folders = new Array(); |
---|
| 1362 | var temp; |
---|
| 1363 | var not_found_corrent_folder = true; |
---|
| 1364 | |
---|
| 1365 | // if( Element("check_all_msg").checked ) |
---|
| 1366 | // { |
---|
| 1367 | this.all_mailboxes(); |
---|
| 1368 | var nm_box = new Array; |
---|
| 1369 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
| 1370 | { |
---|
| 1371 | nm_box[i] = EsearchE.all_boxes[i]/* + fields*/; |
---|
| 1372 | } |
---|
| 1373 | if (preferences.use_local_messages == 1) |
---|
| 1374 | { |
---|
| 1375 | temp = expresso_local_messages.list_local_folders(); |
---|
| 1376 | for (var x in temp) |
---|
| 1377 | { |
---|
| 1378 | local_folders.push(temp[x][0]); |
---|
| 1379 | } |
---|
| 1380 | } |
---|
| 1381 | this.sort = sort || this.sort || "SORTDATE"; |
---|
| 1382 | this.page = isNaN(page) ? ( value ? 0 : this.page ) : page; |
---|
| 1383 | this.value = value || this.value || false; |
---|
[5219] | 1384 | |
---|
[5134] | 1385 | if( !this.value ) |
---|
| 1386 | return alert( "Busca sem caracteres." ); |
---|
| 1387 | |
---|
| 1388 | var args = "$this.imap_functions.quickSearchMail"; |
---|
| 1389 | var params = { page: this.page, sort: this.sort, search: this.value }; |
---|
| 1390 | |
---|
| 1391 | var selection1 = [], selection2 = []; |
---|
| 1392 | |
---|
| 1393 | for( var i = 0; i < nm_box.length; i++ ) |
---|
| 1394 | if( nm_box[i] === current_folder ) |
---|
| 1395 | continue; |
---|
| 1396 | else if( /^user/.test(nm_box[i]) ) |
---|
| 1397 | selection2[selection2.length] = nm_box[i]; |
---|
| 1398 | else |
---|
| 1399 | selection1[selection1.length] = nm_box[i]; |
---|
| 1400 | |
---|
| 1401 | if( expresso_offline ) |
---|
| 1402 | handler('none'); |
---|
| 1403 | else |
---|
| 1404 | { |
---|
| 1405 | var url = [], labels = []; |
---|
| 1406 | |
---|
| 1407 | params['folder'] = current_folder; |
---|
| 1408 | url[0] = args + "&" + $.param( params ); |
---|
| 1409 | labels[0] = "mensagem na sua pasta atual"; |
---|
| 1410 | |
---|
| 1411 | if(selection1.length) |
---|
| 1412 | { |
---|
| 1413 | params['folder'] = selection1; |
---|
| 1414 | url[1] = args + "&" + $.param( params ); |
---|
| 1415 | labels[1] = "mensagens nas suas outras pastas"; |
---|
| 1416 | } |
---|
| 1417 | if(selection2.length) |
---|
| 1418 | { |
---|
| 1419 | params['folder'] = selection2; |
---|
| 1420 | url[2] = args + "&" + $.param( params ); |
---|
| 1421 | labels[2] = "mensagens nas suas pastas compartilhadas"; |
---|
| 1422 | } |
---|
| 1423 | var link = ' <a href="#" onclick="connector.cancelRequest(); clean_msg(); return false;">cancelar<a/>'; |
---|
| 1424 | |
---|
| 1425 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
| 1426 | |
---|
| 1427 | var keepFilled = false; |
---|
| 1428 | |
---|
| 1429 | var handler = function( data ) |
---|
| 1430 | { |
---|
| 1431 | data = $.parseJSON( Base64.decode(data) ); |
---|
[4853] | 1432 | |
---|
[5134] | 1433 | var allMsg = { |
---|
| 1434 | num_msgs: ( data['num_msgs'] || 0 ), |
---|
| 1435 | data: ( data['data'] || data['msgs'] || data ) |
---|
| 1436 | }; |
---|
| 1437 | |
---|
| 1438 | // Gears - local |
---|
| 1439 | if ( local_folders.length > 0 ){ |
---|
| 1440 | expresso_local_messages.setSortType('SORTDATE'); |
---|
| 1441 | var tmp = expresso_local_messages.search( local_folders, "##ALL <=>" + url_encode(value) + "##" ); |
---|
| 1442 | |
---|
| 1443 | if( tmp.length > 0 ) |
---|
| 1444 | if( !allMsg['num_msgs'] ){ |
---|
| 1445 | clean_msg(); |
---|
| 1446 | not_found_corrent_folder = false; |
---|
| 1447 | if(tmp.length) |
---|
| 1448 | allMsg['gears_num_msgs'] = tmp.length; |
---|
| 1449 | }else |
---|
| 1450 | allMsg['gears_num_msgs'] = tmp.length; |
---|
[4853] | 1451 | } |
---|
[5134] | 1452 | |
---|
| 1453 | if( !allMsg['num_msgs'] && !url.length && not_found_corrent_folder){ |
---|
| 1454 | clean_msg(); |
---|
| 1455 | //alert( get_lang("None result was found.") ); |
---|
| 1456 | return EsearchE.viewLocalMessage(); |
---|
| 1457 | } |
---|
| 1458 | |
---|
| 1459 | if( allMsg['num_msgs'] ) |
---|
| 1460 | EsearchE.total = allMsg['num_msgs'] = Math.max( (EsearchE.total || 0), allMsg['num_msgs'] ); |
---|
| 1461 | |
---|
| 1462 | EsearchE.mount_result( allMsg, EsearchE.sort, ( keepFilled || border_id === currentTab ), keepFilled, "Foram encontradas " + data['msgs'].length + " "+labels.shift()+"." ); |
---|
| 1463 | |
---|
| 1464 | keepFilled = true; |
---|
| 1465 | |
---|
| 1466 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
| 1467 | |
---|
| 1468 | if( url.length ) |
---|
| 1469 | cExecute( url.shift(), handler ); |
---|
| 1470 | else |
---|
| 1471 | clean_msg(); |
---|
| 1472 | } |
---|
| 1473 | |
---|
| 1474 | cExecute( url.shift(), handler ); |
---|
| 1475 | } |
---|
| 1476 | } |
---|
| 1477 | |
---|
| 1478 | // clean; |
---|
[3842] | 1479 | searchE.prototype.func_clean = function() |
---|
| 1480 | { |
---|
[2] | 1481 | // Limpa os campos; |
---|
[3842] | 1482 | for( var i=0; i < this.txtfields.length; i++ ) |
---|
| 1483 | { |
---|
| 1484 | if( Element(this.txtfields[i]) != null ) |
---|
| 1485 | Element(this.txtfields[i]).value = ""; |
---|
[3380] | 1486 | } |
---|
[1622] | 1487 | |
---|
[3842] | 1488 | for(i = 0; i < this.selectFields.length; i++) |
---|
| 1489 | { |
---|
| 1490 | if (Element(this.selectFields[i])) |
---|
| 1491 | Element(this.selectFields[i]).selectedIndex = 0; |
---|
| 1492 | } |
---|
| 1493 | |
---|
| 1494 | if( Element("check_all_msg") != null ) |
---|
| 1495 | Element("check_all_msg").checked = false; |
---|
[2] | 1496 | |
---|
| 1497 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
[75] | 1498 | EsearchE.del_mailboxes(); |
---|
[69] | 1499 | } |
---|
[2] | 1500 | |
---|
| 1501 | // close |
---|
[3842] | 1502 | searchE.prototype.func_close = function(type) |
---|
| 1503 | { |
---|
[2] | 1504 | var _this = this; |
---|
| 1505 | _this.name_box_search = ""; |
---|
| 1506 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 1507 | _this.type = type; |
---|
| 1508 | _this.searchW['window_search'].close(); |
---|
| 1509 | } |
---|
| 1510 | // Monta a janela em tela; |
---|
[3842] | 1511 | searchE.prototype.showWindow = function(div) |
---|
| 1512 | { |
---|
| 1513 | if(!this.searchW[div.id]) |
---|
| 1514 | { |
---|
[1622] | 1515 | div.style.width = "804px"; |
---|
| 1516 | div.style.height = "440px"; |
---|
[2] | 1517 | div.style.visibility = "hidden"; |
---|
| 1518 | div.style.position = "absolute"; |
---|
[4817] | 1519 | div.style.zIndex = "10"; |
---|
[128] | 1520 | var title = ":: "+ get_lang("Search")+" ::"; |
---|
[2] | 1521 | var wHeight = div.offsetHeight + "px"; |
---|
| 1522 | var wWidth = div.offsetWidth + "px"; |
---|
[832] | 1523 | |
---|
| 1524 | win = new dJSWin({ |
---|
[2] | 1525 | id: 'ccList'+div.id, |
---|
| 1526 | content_id: div.id, |
---|
| 1527 | width: wWidth, |
---|
| 1528 | height: wHeight, |
---|
| 1529 | title_color: '#3978d6', |
---|
| 1530 | bg_color: '#eee', |
---|
[832] | 1531 | title: title, |
---|
[2] | 1532 | title_text_color: 'white', |
---|
| 1533 | button_y_img: '../phpgwapi/images/win_min.gif', |
---|
| 1534 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
[3380] | 1535 | border: true}); |
---|
[2] | 1536 | this.searchW[div.id] = win; |
---|
| 1537 | win.draw(); |
---|
[3842] | 1538 | } |
---|
| 1539 | else |
---|
| 1540 | { |
---|
[2] | 1541 | var _this = this; |
---|
| 1542 | win = this.searchW[div.id]; |
---|
| 1543 | if((_this.type == "close" && win.state == 0) || win.state == 2){EsearchE.func_clean();} |
---|
| 1544 | win.draw(); |
---|
| 1545 | } |
---|
| 1546 | win.open(); |
---|
| 1547 | } |
---|
[3380] | 1548 | |
---|
[3842] | 1549 | searchE.prototype.aux_local_folder_display = function(folder) |
---|
| 1550 | { |
---|
[1121] | 1551 | if(!expresso_offline) |
---|
| 1552 | return "(Local) " + lang_folder(folder.substr(6)); |
---|
| 1553 | else |
---|
| 1554 | return lang_folder(folder.substr(6)); |
---|
[689] | 1555 | } |
---|
[3380] | 1556 | |
---|
[4821] | 1557 | searchE.prototype.refresh = function(alert_new_msg){ |
---|
| 1558 | var handler_refresh = function(data){ |
---|
| 1559 | var allMsg = [3]; |
---|
| 1560 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
| 1561 | |
---|
| 1562 | if( data['num_msgs'] ) |
---|
| 1563 | { |
---|
| 1564 | allMsg['data'] = data['data']; |
---|
| 1565 | allMsg['num_msgs'] = data['num_msgs']; |
---|
| 1566 | } |
---|
| 1567 | |
---|
| 1568 | if( ( data['num_msgs'] ) == 0 ) |
---|
| 1569 | { |
---|
| 1570 | alert( get_lang("None result was found.") ); |
---|
| 1571 | } |
---|
| 1572 | else |
---|
| 1573 | { |
---|
| 1574 | if( data['num_msgs'] ) |
---|
| 1575 | { |
---|
| 1576 | write_msg( count + " " + get_lang("results found") ); |
---|
| 1577 | EsearchE.mount_result( allMsg, 'SORTDATE', true ); |
---|
| 1578 | } |
---|
| 1579 | } |
---|
| 1580 | } |
---|
| 1581 | |
---|
| 1582 | this.condition = openTab.condition[currentTab]; |
---|
| 1583 | |
---|
| 1584 | var sort_type = (this.sort_type ? this.sort_type : 'SORTDATE'); |
---|
| 1585 | |
---|
| 1586 | if( expresso_offline ) |
---|
| 1587 | handler('none'); |
---|
| 1588 | else |
---|
| 1589 | cExecute( "$this.imap_functions.search_msg", handler_refresh, "condition="+openTab.condition[currentTab]+"&page="+EsearchE.page+"&sort_type="+sort_type); |
---|
| 1590 | } |
---|
| 1591 | |
---|
| 1592 | |
---|
[2] | 1593 | // Cria o objeto |
---|
| 1594 | var EsearchE; |
---|
[3939] | 1595 | EsearchE = new searchE(); |
---|