34 include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
36 define(
'DEFAULT_SEARCH',0);
37 define(
'ADVANCED_SEARCH',1);
38 define(
'ADVANCED_MD_SEARCH',4);
73 $this->user_id = $a_user_id;
77 $this->user_id = $ilUser->getId();
90 $this->permission = $a_permission;
101 $this->user_id = $a_user_id;
110 return $this->entries ? $this->entries :
array();
115 return $this->limit_reached ? true :
false;
120 $this->max_hits = $a_max_hits;
124 return $this->max_hits;
136 return ($a_counter < $this->offset) ? false :
true;
152 if(!$this->entries[$a_obj_id])
154 $this->entries[$a_obj_id][
'obj_id'] = $a_obj_id;
155 $this->entries[$a_obj_id][
'type'] =
$a_type;
156 $this->entries[$a_obj_id][
'found'] = $found;
158 if($a_child_id
and $a_child_id != $a_obj_id)
160 $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
166 if($a_child_id
and $a_child_id != $a_obj_id)
168 $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
173 foreach($found as $position)
177 $this->entries[$a_obj_id][
'found'][
$counter] = $position;
203 foreach($result_obj->getEntries() as $entry)
205 $this->
addEntry($entry[
'obj_id'],$entry[
'type'],$entry[
'found']);
221 $this->entries =
array();
224 foreach($this->search_cache->getCheckedItems() as
$ref_id => $obj_id)
226 if(isset($new_entries[$obj_id]))
228 $this->
addEntry($new_entries[$obj_id][
'obj_id'],
229 $new_entries[$obj_id][
'type'],
230 $new_entries[$obj_id][
'found']);
232 $new_entries[$obj_id][
'child']);
246 $this->entries =
array();
248 foreach($result_obj->getEntries() as $entry)
250 $obj_id = $entry[
'obj_id'];
251 if(isset($new_entries[$obj_id]))
253 $this->
addEntry($new_entries[$obj_id][
'obj_id'],
254 $new_entries[$obj_id][
'type'],
255 $new_entries[$obj_id][
'found']);
258 $new_entries[$obj_id][
'child']);
275 $this->results[$a_ref_id][
'ref_id'] = $a_ref_id;
276 $this->results[$a_ref_id][
'obj_id'] = $a_obj_id;
277 $this->results[$a_ref_id][
'type'] =
$a_type;
282 return $this->results ? $this->results :
array();
297 return $ids ? $ids :
array();
305 $tmp_res[$res_data[
'obj_id']][] =
$ref_id;
307 return $tmp_res ? $tmp_res :
array();
320 foreach($this->results as $result)
322 if(in_array($result[
'obj_id'],$obj_ids))
326 $obj_ids[] = $result[
'obj_id'];
329 return $objects ? $objects :
array();
338 $res[$result[
'ref_id']] = $result[
'obj_id'];
348 $res[$row[
'obj_id']] = $row[
'child'];
367 public function filter($a_root_node,$check_and)
377 if($check_and
and in_array(0,$entry[
'found']))
383 if($type ==
'rolt' or $type ==
'usr' or $type ==
'role')
387 $this->
addResult($entry[
'obj_id'],$entry[
'obj_id'],$type);
392 $this->limit_reached =
true;
402 if($this->search_cache->isFailed($ref_id))
407 if($this->search_cache->isChecked($ref_id)
and !$this->
isOffsetReached($offset_counter))
422 if($this->ilAccess->checkAccessOfUser($this->getUserId(),
429 if($a_root_node == ROOT_FOLDER_ID
or $tree->isGrandChild($a_root_node,$ref_id))
432 #if($this->callListeners($ref_id,$entry)) 435 $this->
addResult($ref_id,$entry[
'obj_id'],$type);
436 $this->search_cache->appendToChecked($ref_id,$entry[
'obj_id']);
445 $this->limit_reached =
true;
446 $this->search_cache->setResults($this->results);
453 $this->search_cache->appendToFailed($ref_id);
456 $this->search_cache->setResults($this->results);
470 $this->results =
array();
471 foreach($tmp_results as $result)
473 if($tree->isGrandChild($a_root_node,$result[
'ref_id'])
and $tree->isInTree($result[
'ref_id']))
475 $this->
addResult($result[
'ref_id'],$result[
'obj_id'],$result[
'type']);
492 $this->search_cache->save();
503 $this->results = $this->search_cache->getResults();
516 if($this->entries[$a_obj_id]
and is_array($a_childs))
518 foreach($a_childs as $child_id)
522 $this->entries[$a_obj_id][
'child'][$child_id] = $child_id;
538 if($this->results[$a_ref_id]
and is_array($a_childs))
540 foreach($a_childs as $child_id)
542 $this->results[$a_ref_id][
'child'][$child_id] = $child_id;
553 include_once
'Services/Search/classes/class.ilSearchSettings.php';
557 $this->
setMaxHits($this->search_settings->getMaxHits());
568 include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
570 $this->offset = $this->
getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
605 $this->observers[] =
array(
'class' => $a_class,
606 'method' => $a_method);
611 foreach($this->observers as $observer)
613 $class =& $observer[
'class'];
614 $method = $observer[
'method'];
616 if(!$class->$method($a_ref_id,$a_data))
read($a_type=DEFAULT_SEARCH)
read search results
isOffsetReached($a_counter)
Check if offset is reached.
getResultIds()
get result ids
addEntry($a_obj_id, $a_type, $found, $a_child_id=0)
add search result entry Entries are stored with 'obj_id'.
filterResults($a_root_node)
Filter search area of result set public.
initUserSearchCache()
Init user search cache.
addObserver(&$a_class, $a_method)
The observer is used to call functions for filtering result.
getResultsForPresentation()
getUniqueResults()
Get unique results.
static _getAllReferences($a_id)
get all reference ids of object
__construct($a_user_id=0)
Constructor public.
diffEntriesFromResult(&$result_obj)
diff entries of this instance and another result object Used for search in results ...
static _getInstance($a_usr_id)
Get singleton instance.
__initSearchSettingsObject()
__updateResultChilds($a_ref_id, $a_childs)
Update childs for a specific result.
addResult($a_ref_id, $a_obj_id, $a_type)
add search result Results are stored with 'ref_id'.
__updateEntryChilds($a_obj_id, $a_childs)
Update childs for a specific entry.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
intersectEntries(&$result_obj)
Build intersection of entries (all entries that are present in both result sets)
setRequiredPermission($a_permission)
Set the required permission for the rbac checks in function 'filter()'.
mergeEntries(&$result_obj)
merge entries of this instance and another result object
numEntries()
Check number of entries public.
filter($a_root_node, $check_and)
Filter search result.
$preventOverwritingMaxhits
callListeners($a_ref_id, &$a_data)
save($a_type=DEFAULT_SEARCH)
Save search results.
preventOverwritingMaxhits($a_flag=null)
If you call this function and pass "true" the maxhits setting will not be overwritten in __initSearch...