Exemplo n.º 1
0
 /**
  * Do the search itself.
  * Only the items with readAccess are returned.
  *
  * @param string  $words Some words separated by space
  * @param integer $count Limit query.
  *
  * @uses
  *      $search = Phprojekt_Loader::getLibraryClass('Phprojekt_Search');
  *      $search->search('text1 text2 text3', 10);
  *
  * @return array Array with results.
  */
 public function search($words, $count = null)
 {
     if (strstr($words, " ")) {
         $wordOperator = 'equal';
         $wordCount = 0;
         $relationOperator = 'AND';
     } else {
         $wordOperator = 'like';
         $wordCount = $count;
         $relationOperator = 'OR';
     }
     $result = $this->_words->searchWords($words, $wordOperator, $wordCount);
     $tmpFoundResults = $this->_wordModule->searchModuleByWordId($result, $relationOperator, $count);
     $dataForDisplay = array();
     // Limit the number of ocurrences per module to 3
     if ($count > 0) {
         $results = array();
         foreach ($tmpFoundResults as $moduleData) {
             if (!isset($results[$moduleData['module_id']])) {
                 $results[$moduleData['module_id']] = 0;
             }
             $results[$moduleData['module_id']]++;
             if ($results[$moduleData['module_id']] <= 3) {
                 $dataForDisplay[$moduleData['module_id']][] = $moduleData['item_id'];
             }
         }
     } else {
         // Convert result to array and add the display data
         foreach ($tmpFoundResults as $moduleData) {
             $dataForDisplay[$moduleData['module_id']][] = $moduleData['item_id'];
         }
     }
     return $this->_display->getDisplay($dataForDisplay);
 }
Exemplo n.º 2
0
 /**
  * Extension of the Abstract Record to delete an item.
  *
  * @return void
  */
 public function delete()
 {
     $moduleId = Phprojekt_Module::getId($this->getModelName());
     $this->deleteUploadFiles();
     $this->_history->saveFields($this, 'delete');
     $this->_search->deleteObjectItem($this);
     $this->_rights->saveRights($moduleId, $this->id, array());
     parent::delete();
 }