34include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
 
   36define(
'DEFAULT_SEARCH', 0);
 
   37define(
'ADVANCED_SEARCH', 1);
 
   38define(
'ADVANCED_MD_SEARCH', 4);
 
   72            $this->user_id = $a_user_id;
 
   74            $this->user_id = 
$ilUser->getId();
 
   87        $this->permission = $a_permission;
 
   98        $this->user_id = $a_user_id;
 
  107        return $this->entries ? $this->entries : array();
 
  112        return $this->limit_reached ? true : 
false;
 
  117        $this->max_hits = $a_max_hits;
 
  121        return $this->max_hits;
 
  133        return ($a_counter < $this->offset) ? false : 
true;
 
  149        if (!$this->entries[$a_obj_id]) {
 
  150            $this->entries[$a_obj_id][
'obj_id'] = $a_obj_id;
 
  151            $this->entries[$a_obj_id][
'type'] = 
$a_type;
 
  152            $this->entries[$a_obj_id][
'found'] = $found;
 
  153            $this->entries[$a_obj_id][
'child'] = [];
 
  155            if ($a_child_id and $a_child_id != $a_obj_id) {
 
  156                $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
 
  160            if ($a_child_id and $a_child_id != $a_obj_id) {
 
  161                $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
 
  166            foreach ($found as $position) {
 
  168                    $this->entries[$a_obj_id][
'found'][
$counter] = $position;
 
  194        foreach ($result_obj->getEntries() as $entry) {
 
  195            $this->
addEntry($entry[
'obj_id'], $entry[
'type'], $entry[
'found']);
 
  211        $this->entries = array();
 
  214        foreach ($this->search_cache->getCheckedItems() as $ref_id => $obj_id) {
 
  215            if (isset($new_entries[$obj_id])) {
 
  217                    $new_entries[$obj_id][
'obj_id'],
 
  218                    $new_entries[$obj_id][
'type'],
 
  219                    $new_entries[$obj_id][
'found']
 
  222                    $new_entries[$obj_id][
'obj_id'],
 
  223                    $new_entries[$obj_id][
'child']
 
  238        $this->entries = array();
 
  240        foreach ($result_obj->getEntries() as $entry) {
 
  241            $obj_id = $entry[
'obj_id'];
 
  242            if (isset($new_entries[$obj_id])) {
 
  244                    $new_entries[$obj_id][
'obj_id'],
 
  245                    $new_entries[$obj_id][
'type'],
 
  246                    $new_entries[$obj_id][
'found']
 
  250                    $new_entries[$obj_id][
'obj_id'],
 
  251                    $new_entries[$obj_id][
'child']
 
  269        $this->results[$a_ref_id][
'ref_id'] = $a_ref_id;
 
  270        $this->results[$a_ref_id][
'obj_id'] = $a_obj_id;
 
  271        $this->results[$a_ref_id][
'type']       = 
$a_type;
 
  276        return $this->results ? $this->results : array();
 
  290        return $ids ? $ids : array();
 
  296        foreach ($this->
getResults() as $ref_id => $res_data) {
 
  297            $tmp_res[$res_data[
'obj_id']][] = $ref_id;
 
  299        return $tmp_res ? $tmp_res : array();
 
  312        foreach ($this->results as 
$result) {
 
  313            if (in_array(
$result[
'obj_id'], $obj_ids)) {
 
  316            $obj_ids[] = 
$result[
'obj_id'];
 
  319        return $objects ? $objects : array();
 
  355    public function filter($a_root_node, $check_and)
 
  364            if ($check_and and in_array(0, $entry[
'found'])) {
 
  372                    if (is_array($entry[
'child'])) {
 
  377                        $this->limit_reached = 
true;
 
  386                if ($this->search_cache->isFailed($ref_id)) {
 
  390                if ($this->search_cache->isChecked($ref_id) and !$this->isOffsetReached($offset_counter)) {
 
  405                    $this->getRequiredPermission(),
 
  411                    if ($a_root_node == ROOT_FOLDER_ID or $tree->isGrandChild($a_root_node, $ref_id)) {
 
  413                        #if($this->callListeners($ref_id,$entry)) 
  416                            $this->search_cache->appendToChecked($ref_id, $entry[
'obj_id']);
 
  424                                $this->limit_reached = 
true;
 
  425                                $this->search_cache->setResults($this->results);
 
  432                $this->search_cache->appendToFailed($ref_id);
 
  435        $this->search_cache->setResults($this->results);
 
  449        $this->results = array();
 
  450        foreach ($tmp_results as 
$result) {
 
  451            if ($tree->isGrandChild($a_root_node, 
$result[
'ref_id']) and $tree->isInTree(
$result[
'ref_id'])) {
 
  469        $this->search_cache->save();
 
  480        $this->results = $this->search_cache->getResults();
 
  493        if ($this->entries[$a_obj_id] and is_array($a_childs)) {
 
  494            foreach ($a_childs as $child_id) {
 
  496                    $this->entries[$a_obj_id][
'child'][$child_id] = $child_id;
 
  512        if ($this->results[$a_ref_id] and is_array($a_childs)) {
 
  513            foreach ($a_childs as $child_id) {
 
  514                $this->results[$a_ref_id][
'child'][$child_id] = $child_id;
 
  525        include_once 
'Services/Search/classes/class.ilSearchSettings.php';
 
  529            $this->
setMaxHits($this->search_settings->getMaxHits());
 
  541        include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
 
  543        $this->offset = $this->
getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
 
  557        if (
null === $a_flag) {
 
  577        $this->observers[] = array(
'class' => $a_class,
 
  578                                   'method' => $a_method);
 
  583        foreach ($this->observers as $observer) {
 
  584            $class =&$observer[
'class'];
 
  585            $method = $observer[
'method'];
 
  587            if (!$class->$method($a_ref_id, $a_data)) {
 
An exception for terminatinating execution or to throw for unit testing.
checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_ref_id, $a_type="", $a_obj_id="", $a_tree_id="")
check access for an object (provide $a_type and $a_obj_id if available for better performance)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
addObserver(&$a_class, $a_method)
The observer is used to call functions for filtering result.
setRequiredPermission($a_permission)
Set the required permission for the rbac checks in function 'filter()'.
__construct($a_user_id=0)
Constructor @access public.
getUniqueResults()
Get unique results.
mergeEntries(&$result_obj)
merge entries of this instance and another result object
save($a_type=DEFAULT_SEARCH)
Save search results.
isOffsetReached($a_counter)
Check if offset is reached.
initUserSearchCache()
Init user search cache.
filterResults($a_root_node)
Filter search area of result set @access public.
getResultsForPresentation()
__initSearchSettingsObject()
$preventOverwritingMaxhits
diffEntriesFromResult(&$result_obj)
diff entries of this instance and another result object Used for search in results
filter($a_root_node, $check_and)
Filter search result.
numEntries()
Check number of entries @access public.
callListeners($a_ref_id, &$a_data)
addEntry($a_obj_id, $a_type, $found, $a_child_id=0)
add search result entry Entries are stored with 'obj_id'.
getResultIds()
get result ids
addResult($a_ref_id, $a_obj_id, $a_type)
add search result Results are stored with 'ref_id'.
__updateResultChilds($a_ref_id, $a_childs)
Update childs for a specific result.
read($a_type=DEFAULT_SEARCH)
read search results
__updateEntryChilds($a_obj_id, $a_childs)
Update childs for a specific entry.
preventOverwritingMaxhits($a_flag=null)
If you call this function and pass "true" the maxhits setting will not be overwritten in __initSearch...
intersectEntries(&$result_obj)
Build intersection of entries (all entries that are present in both result sets)
static _getInstance($a_usr_id)
Get singleton instance.
if(!array_key_exists('StateId', $_REQUEST)) $id
foreach($_POST as $key=> $value) $res