SHARE
TWEET

Untitled

a guest Feb 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function category_search($args = array()) {
  2.   // Get the category
  3.   $category = get_input_value('_srchcat', RCUBE_INPUT_GET);
  4.   // reset list_page and old search results
  5.   $this->rc->imap->set_page(1);
  6.   $this->rc->imap->set_search_set(NULL);
  7.   $_SESSION['page'] = 1;
  8.   $page = get_input_value('_page', RCUBE_INPUT_GET);
  9.  
  10.   // Get the page and id
  11.   $page = $page ? $page : 1;
  12.   $id = get_input_value('_id', RCUBE_INPUT_GET);
  13.  
  14.   // Check the sort settings
  15.   if ($sort = get_input_value('_sort', RCUBE_INPUT_GET)) {
  16.     list($sort_col, $sort_order) = explode('_', $sort);
  17.     // set session vars for sort (so next page and task switch know how to sort)
  18.     $save_arr = array();
  19.     $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col;
  20.     $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order;
  21.   } else {
  22.     // use session settings if set, defaults if not
  23.     $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $this->rc->config->get('message_sort_col');
  24.     $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $this->rc->config->get('message_sort_order');
  25.   }
  26.  
  27.   // Get the search terms
  28.   $filters = array();
  29.   $searchterms = $this->get_search_terms($category, $filters);
  30.  
  31.   // Set the search request id for the session
  32.   $search_request = md5('INBOX'.$filters.$searchterms);
  33.  
  34.   // Do the search
  35.   $result_h = $this->perform_category_search($searchterms, $filters);
  36.   $count = count($result_h);
  37.  
  38.   $_SESSION['search'] = $this->rc->imap->get_search_set();
  39.   $_SESSION['last_text_search'] = implode(',',$searchterms);
  40.   $_SESSION['search_request'] = $search_request;
  41.  
  42.   // Sort the results
  43.   //$this->sort_search_results();
  44.  
  45.   //print_r($result_h); //TODO: Delete line
  46.   // Display the list
  47.   if (!empty($result_h)) {
  48.     rcmail_js_message_list($result_h, TRUE);
  49.     $this->rc->output->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
  50.   } elseif ($err_code = $this->rc->imap->get_error_code()) {
  51.     rcmail_display_server_error();
  52.   } else {
  53.     // No results could be found, show the error results
  54.     $searchterms = $this->get_search_terms('Company A, Company B', $filters);
  55.     $result_h = $this->perform_category_search($searchterms, $filters);
  56.     //print_r($result_h); //TODO: Delete line
  57.     if (!empty($result_h)) rcmail_js_message_list($result_h, TRUE);
  58.     $this->rc->output->show_message('searchnomatch', 'notice');
  59.   }
  60.  
  61.   // Update the environment setings
  62.   $this->rc->output->set_env('search_request', $filters ? $search_request : '');
  63.   $this->rc->output->set_env('messagecount', $count);
  64.   $this->rc->output->set_env('pagecount', 1);
  65.   $this->rc->output->command('set_rowcount', rcmail_get_messagecount_text($count, $page));
  66.   $this->rc->output->send('mail');
  67.  
  68.   exit;
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top