+ return asearch_opt_array('unop[' . $row_num . ']', $imap_asearch_unops, $unop)
+ . asearch_opt_array('where[' . $row_num . ']', $imap_asearch_options, $where);
+}
+
+/** Build the what text input
+ */
+function asearch_get_form_what($what, $row_num = 0)
+{
+ return function_exists('addInput') ? addInput('what[' . $row_num . ']', $what, '35')
+ : '<input type="text" size="35" name="what[' . $row_num . ']" value="' . htmlspecialchars($what) . '" />';
+}
+
+/** Build the Exclude criteria checkbox
+ */
+function asearch_get_form_exclude($exclude, $row_num = 0)
+{
+ return function_exists('addCheckBox') ? addCheckBox('exclude['.$row_num.']', $exclude)
+ : '<input type="checkbox" name="exclude[' . $row_num .']"' . ($exclude ? ' checked="checked"' : '') . ' />';
+}
+
+/** Print one advanced form row
+ */
+function asearch_print_form_row($imapConnection, &$boxes, $mailbox, $biop, $unop, $where, $what, $exclude, $sub, $row_num)
+{
+ global $imap_asearch_biops_in;
+ global $color;
+
+ echo html_tag('tr', '', '', $color[4]);
+
+//Binary operator
+ echo html_tag('td', $row_num ?
+ asearch_opt_array('biop[' . $row_num . ']', $imap_asearch_biops_in, $biop)
+ : '<b>' . _("In") . '</b>', 'center') . "\n";
+
+//Mailbox list and Include Subfolders
+ echo html_tag('td',
+ asearch_get_form_mailbox($imapConnection, $boxes, $mailbox, $row_num)
+ . _("and subfolders:") . asearch_get_form_sub($sub, $row_num), 'center') . "\n";
+
+//Unary operator and Search location
+ echo html_tag('td', asearch_get_form_location($unop, $where, $row_num), 'center') . "\n";
+
+//Text input
+ echo html_tag('td', asearch_get_form_what($what, $row_num), 'center') . "\n";
+
+//Exclude criteria
+ echo html_tag('td', _("Exclude Criteria:") . asearch_get_form_exclude($exclude, $row_num), 'center') . "\n";
+
+ echo "</tr>\n";
+}
+
+/** Print the advanced search form
+ */
+function asearch_print_form($imapConnection, &$boxes, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array)
+{
+ global $search_button_html, $add_criteria_button_html, $del_excluded_button_html, $del_all_button_html;
+ global $color;
+
+//Search Form
+ echo "<br />\n";
+ echo '<form action="' . asearch_get_href() . '" name="form_asearch">' . "\n";
+
+ echo html_tag('table', '', 'center', $color[9], 'width="100%" cellpadding="1" cellspacing="1" border="0"');
+ echo html_tag('tr', html_tag('td', asearch_get_title_display($color, _("Search Criteria")), 'center', $color[5], 'colspan=5'));
+ $row_count = count($where_array);
+ for ($row_num = 0; $row_num < $row_count; $row_num++) {
+ $mailbox = asearch_nz($mailbox_array[$row_num]);
+ $biop = strip_tags(asearch_nz($biop_array[$row_num]));
+ $unop = strip_tags(asearch_nz($unop_array[$row_num]));
+ $where = strip_tags(asearch_nz($where_array[$row_num]));
+ $what = asearch_nz($what_array[$row_num]);
+ $exclude = strip_tags(asearch_nz($exclude_array[$row_num]));
+ $sub = strip_tags(asearch_nz($sub_array[$row_num]));
+ asearch_print_form_row($imapConnection, $boxes, $mailbox, $biop, $unop, $where, $what, $exclude, $sub, $row_num);
+ }
+ echo '</table>' . "\n";
+
+//Submit buttons
+ echo html_tag('table', '', 'center', $color[9], 'width="100%" cellpadding="1" cellspacing="0" border="0"');
+ echo html_tag('tr',
+ html_tag('td', getButton('submit', 'submit', $search_button_html), 'center') . "\n"
+ . html_tag('td', getButton('submit', 'submit', $add_criteria_button_html), 'center') . "\n"
+ . html_tag('td', getButton('submit', 'submit', $del_all_button_html), 'center') . "\n"
+ . html_tag('td', getButton('submit', 'submit', $del_excluded_button_html), 'center') . "\n"
+ );
+ echo '</table>' . "\n";
+ echo '</form>' . "\n";
+}
+
+/** Print one basic form row
+ */
+function asearch_print_form_row_basic($imapConnection, &$boxes, $mailbox, $biop, $unop, $where, $what, $exclude, $sub, $row_num)
+{
+ global $search_button_html;
+ global $color;
+
+ echo html_tag('tr', '', '', $color[4]);
+
+//Mailbox list
+ echo html_tag('td', '<b>' . _("In") . '</b> ' . asearch_get_form_mailbox($imapConnection, $boxes, $mailbox), 'center') . "\n";
+
+//Unary operator and Search location
+ echo html_tag('td', asearch_get_form_location($unop, $where), 'center') . "\n";
+
+//Text input
+ echo html_tag('td', asearch_get_form_what($what), 'center') . "\n";
+
+//Submit button
+ echo html_tag('td', getButton('submit', 'submit', $search_button_html), 'center') . "\n";
+
+ echo "</tr>\n";
+}
+
+/** Print the basic search form
+ */
+function asearch_print_form_basic($imapConnection, &$boxes, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array)
+{
+ global $color;
+
+//Search Form
+ echo "<br />\n";
+ echo '<form action="' . asearch_get_href() . '" name="form_asearch">' . "\n";
+
+ echo html_tag('table', '', 'center', $color[9], 'width="100%" cellpadding="1" cellspacing="1" border="0"');
+ //echo html_tag('tr', html_tag('td', asearch_get_title_display($color, _("Search Criteria")), 'center', $color[5], 'colspan=4'));
+ $row_count = count($where_array);
+ for ($row_num = 0; $row_num < $row_count; $row_num++) {
+ $mailbox = asearch_nz($mailbox_array[$row_num]);
+ $biop = strip_tags(asearch_nz($biop_array[$row_num]));
+ $unop = strip_tags(asearch_nz($unop_array[$row_num]));
+ $where = strip_tags(asearch_nz($where_array[$row_num]));
+ $what = asearch_nz($what_array[$row_num]);
+ $exclude = strip_tags(asearch_nz($exclude_array[$row_num]));
+ $sub = strip_tags(asearch_nz($sub_array[$row_num]));
+ asearch_print_form_row_basic($imapConnection, $boxes, $mailbox, $biop, $unop, $where, $what, $exclude, $sub, $row_num);
+ }
+ echo '</table>' . "\n";
+ echo '</form>' . "\n";
+}
+
+/** Print the $msgs messages from $mailbox mailbox
+ */
+
+function asearch_print_mailbox_msgs($imapConnection, &$aMailbox, $color) {
+ global $javascript_on, $compact_paginator;
+ /**
+ * A mailbox can contain different sets with uid's. Default, for normal
+ * message list view we use '0' as setindex and for search a different
+ * setindex.
+ */
+ $iSetIndx = $aMailbox['SETINDEX'];
+
+ $mailbox_display = asearch_get_mailbox_display($aMailbox['NAME']);
+ $mailbox_title = '<b><big>' . _("Folder:") . ' '. $mailbox_display . ' </big></b>';
+
+ /**
+ * UIDSET contains the array with uid's returned by a search
+ */
+ $cnt = count($aMailbox['UIDSET'][$iSetIndx]);