public function search(Search_SearchQuery $query, Search_SearchResults $search_results)
 {
     $user = UserManager::instance()->getCurrentUser();
     if ($user->isRestricted()) {
         $dao_results = $this->dao->searchGlobalPaginatedForRestrictedUsers($query->getWords(), $query->getOffset(), $query->getExact(), $user->getId(), $query->getNumberOfResults());
     } else {
         $dao_results = $this->dao->searchGlobalPaginated($query->getWords(), $query->getOffset(), $query->getExact(), $query->getNumberOfResults());
     }
     $results_count = count($dao_results);
     $maybe_more_results = $results_count < $query->getNumberOfResults() ? false : true;
     $search_results->setHasMore($maybe_more_results)->setCountResults($results_count);
     return $this->getSearchProjectResultPresenter($dao_results, $query->getWords(), $maybe_more_results);
 }
 public function search(Search_SearchQuery $query, Search_SearchResults $search_results)
 {
     $user_collection = $this->manager->getPaginatedUsersByUsernameOrRealname($query->getWords(), $query->getExact(), $query->getOffset(), $query->getNumberOfResults());
     $results_count = count($user_collection);
     $maybe_more_results = $results_count < $query->getNumberOfResults() ? false : true;
     $search_results->setHasMore($maybe_more_results)->setCountResults($results_count);
     return $this->getSearchPeopleResultPresenter($user_collection, $query->getWords(), $maybe_more_results);
 }
 public function search(Search_SearchQuery $query, Search_SearchResults $search_results)
 {
     $dao_results = $this->dao->searchGlobalPaginated($query->getWords(), $query->getExact(), $query->getOffset(), $query->getForumId(), $query->getNumberOfResults());
     $results_count = count($dao_results);
     $maybe_more_results = $results_count < $query->getNumberOfResults() ? false : true;
     $search_results->setHasMore($maybe_more_results)->setCountResults($results_count);
     return $this->getSearchForumResultPresenter($dao_results, $query->getWords(), $maybe_more_results);
 }
 public function search(Search_SearchQuery $query, Search_SearchResults $search_results)
 {
     include_once 'www/tracker/include/ArtifactTypeHtml.class.php';
     include_once 'www/tracker/include/ArtifactHtml.class.php';
     $project = $query->getProject();
     if ($project->isError()) {
         return;
     }
     $group_id = $project->getId();
     $words = $query->getWords();
     $exact = $query->getExact();
     $offset = $query->getOffset();
     $atid = $query->getTrackerV3Id();
     ob_start();
     //
     //      Create the ArtifactType object
     //
     $ath = new ArtifactTypeHtml($project, $atid);
     if (!$ath || !is_object($ath)) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('global', 'error'));
     }
     if ($ath->isError()) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $ath->getErrorMessage());
     }
     // Check if this tracker is valid (not deleted)
     if (!$ath->isValid()) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('global', 'error'));
     }
     $results = $this->dao->searchGlobalPaginated($words, $exact, $offset, $atid, UserManager::instance()->getCurrentUser()->getUgroups($group_id, $atid), $query->getNumberOfResults());
     $rows_returned = $this->dao->foundRows();
     $art_displayed = 0;
     if ($rows_returned < 1) {
         echo '<H2>' . $GLOBALS['Language']->getText('search_index', 'no_match_found', htmlentities(stripslashes($words), ENT_QUOTES, 'UTF-8')) . '</H2>';
     } else {
         // Create field factory
         $art_field_fact = new ArtifactFieldFactory($ath);
         echo '<H3>' . $GLOBALS['Language']->getText('search_index', 'search_res', array(htmlentities(stripslashes($words), ENT_QUOTES, 'UTF-8'), $rows_returned)) . "</H3><P>\n";
         $title_arr = array();
         $summary_field = $art_field_fact->getFieldFromName("summary");
         if ($summary_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'artifact_summary');
         }
         $submitted_field = $art_field_fact->getFieldFromName("submitted_by");
         if ($submitted_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'submitted_by');
         }
         $date_field = $art_field_fact->getFieldFromName("open_date");
         if ($date_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'date');
         }
         $status_field = $art_field_fact->getFieldFromName("status_id");
         if ($status_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('global', 'status');
         }
         echo html_build_list_table_top($title_arr);
         echo "\n";
         $rows = 0;
         foreach ($results as $arr) {
             $rows++;
             $curArtifact = new Artifact($ath, $arr['artifact_id']);
             if ($curArtifact->isStatusClosed($curArtifact->getStatusID())) {
                 $status = $GLOBALS['Language']->getText('global', 'closed');
             } else {
                 $status = $GLOBALS['Language']->getText('global', 'open');
             }
             // Only display artifacts that the user is allowed to see
             if ($curArtifact->userCanView(user_getid())) {
                 print "\n<TR class=\"" . html_get_alt_row_color($art_displayed) . "\">";
                 if ($summary_field->userCanRead($group_id, $atid)) {
                     print "<TD><A HREF=\"/tracker/?group_id={$group_id}&func=detail&atid={$atid}&aid=" . $arr['artifact_id'] . "\"><IMG SRC=\"" . util_get_image_theme('msg.png') . "\" BORDER=0 HEIGHT=12 WIDTH=10> " . $arr['summary'] . "</A></TD>";
                 }
                 if ($submitted_field->userCanRead($group_id, $atid)) {
                     print "<TD>" . $arr['user_name'] . "</TD>";
                 }
                 if ($date_field->userCanRead($group_id, $atid)) {
                     print "<TD>" . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $arr['open_date']) . "</TD>";
                 }
                 if ($status_field->userCanRead($group_id, $atid)) {
                     print "<TD>" . $status . "</TD>";
                 }
                 print "</TR>";
                 $art_displayed++;
                 if ($art_displayed > $query->getNumberOfResults()) {
                     break;
                 }
             }
         }
         echo "</TABLE>\n";
     }
     $maybe_more_results = $art_displayed < $query->getNumberOfResults() ? false : true;
     $search_results->setCountResults($art_displayed)->setHasMore($maybe_more_results);
     return new Search_SearchTrackerV3ResultPresenter(ob_get_clean());
 }