protected function search_pts(&$user, $search)
 {
     $json['pts']['msg']['name'] = 'search_results';
     if (strlen($search) < 3) {
         $json['pts']['status']['error'] = 'Longer search query needed; at least three characters required.';
         $this->send_json_data($user->socket, $json);
         return false;
     } else {
         if (is_numeric($search)) {
             $json['pts']['status']['error'] = 'An alpha-numeric string is needed to perform this search.';
             $this->send_json_data($user->socket, $json);
             return false;
         }
     }
     $test_matches = pts_openbenchmarking_client::search_tests($search, true);
     $json['pts']['msg']['exact_hits'] = 0;
     $json['pts']['msg']['search_query'] = $search;
     if (count($test_matches) > 0) {
         $json['pts']['msg']['test_profiles'] = array();
         $json['pts']['msg']['exact_hits'] = 1;
         $json['pts']['msg']['tests'] = array();
         for ($i = 0; $i < count($test_matches); $i++) {
             $json['pts']['msg']['tests'][] = $test_matches[$i];
             $tp = new pts_test_profile($test_matches[$i]);
             $json['pts']['msg']['test_profiles'][] = base64_encode($tp->to_json());
         }
     } else {
         // DO MORE BROAD SEARCH, NOT A TEST...
         $test_matches = pts_openbenchmarking_client::search_tests($search, false);
         $json['pts']['msg']['test_profiles'] = array();
         $json['pts']['msg']['tests'] = array();
         for ($i = 0; $i < count($test_matches); $i++) {
             $json['pts']['msg']['tests'][] = $test_matches[$i];
             $tp = new pts_test_profile($test_matches[$i]);
             $json['pts']['msg']['test_profiles'][] = base64_encode($tp->to_json());
         }
         // SEARCH TEST PROFILES
     }
     $json['pts']['msg']['results'] = array();
     $json['pts']['msg']['result_files'] = array();
     if (count($test_matches) > 0) {
         $result_matches = pts_tests::search_test_results($search, 'RESULTS');
         foreach ($result_matches as $result) {
             $result_file = new pts_result_file($result);
             $json['pts']['msg']['results'][] = $result;
             $json['pts']['msg']['result_files'][] = base64_encode($result_file->to_json());
         }
     } else {
         $result_matches = pts_tests::search_test_results($search, 'ALL');
         foreach ($result_matches as $result) {
             $result_file = new pts_result_file($result);
             $json['pts']['msg']['results'][] = $result;
             $json['pts']['msg']['result_files'][] = base64_encode($result_file->to_json());
         }
     }
     $this->send_json_data($user->socket, $json);
 }