34include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
 
   36define(
'DEFAULT_SEARCH', 0);
 
   37define(
'ADVANCED_SEARCH', 1);
 
   38define(
'ADVANCED_MD_SEARCH', 4);
 
   80        $this->logger = 
$DIC->logger()->src();
 
   84            $this->user_id = $a_user_id;
 
   86            $this->user_id = 
$ilUser->getId();
 
   99        $this->permission = $a_permission;
 
  110        $this->user_id = $a_user_id;
 
  119        return $this->entries ? $this->entries : array();
 
  124        return $this->limit_reached ? 
true : 
false;
 
  129        $this->max_hits = $a_max_hits;
 
  133        return $this->max_hits;
 
  145        return ($a_counter < $this->offset) ? false : 
true;
 
  158    public function addEntry($a_obj_id, $a_type, $found, $a_child_id = 0)
 
  161        if (!$this->entries[$a_obj_id]) {
 
  162            $this->entries[$a_obj_id][
'obj_id'] = $a_obj_id;
 
  163            $this->entries[$a_obj_id][
'type'] = $a_type;
 
  164            $this->entries[$a_obj_id][
'found'] = $found;
 
  165            $this->entries[$a_obj_id][
'child'] = [];
 
  167            if ($a_child_id and $a_child_id != $a_obj_id) {
 
  168                $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
 
  172            if ($a_child_id and $a_child_id != $a_obj_id) {
 
  173                $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
 
  178            foreach ($found as $position) {
 
  180                    $this->entries[$a_obj_id][
'found'][$counter] = $position;
 
  206        foreach ($result_obj->getEntries() as $entry) {
 
  207            $this->
addEntry($entry[
'obj_id'], $entry[
'type'], $entry[
'found']);
 
  223        $this->entries = array();
 
  226        foreach ($this->search_cache->getCheckedItems() as $ref_id => $obj_id) {
 
  227            if (isset($new_entries[$obj_id])) {
 
  229                    $new_entries[$obj_id][
'obj_id'],
 
  230                    $new_entries[$obj_id][
'type'],
 
  231                    $new_entries[$obj_id][
'found']
 
  234                    $new_entries[$obj_id][
'obj_id'],
 
  235                    $new_entries[$obj_id][
'child']
 
  250        $this->entries = array();
 
  252        foreach ($result_obj->getEntries() as $entry) {
 
  253            $obj_id = $entry[
'obj_id'];
 
  254            if (isset($new_entries[$obj_id])) {
 
  256                    $new_entries[$obj_id][
'obj_id'],
 
  257                    $new_entries[$obj_id][
'type'],
 
  258                    $new_entries[$obj_id][
'found']
 
  262                    $new_entries[$obj_id][
'obj_id'],
 
  263                    $new_entries[$obj_id][
'child']
 
  279    public function addResult($a_ref_id, $a_obj_id, $a_type)
 
  281        $this->results[$a_ref_id][
'ref_id'] = $a_ref_id;
 
  282        $this->results[$a_ref_id][
'obj_id'] = $a_obj_id;
 
  283        $this->results[$a_ref_id][
'type'] = $a_type;
 
  288        return $this->results ? $this->results : array();
 
  299        foreach ($this->
getResults() as $id => $tmp) {
 
  302        return $ids ? $ids : array();
 
  308        foreach ($this->
getResults() as $ref_id => $res_data) {
 
  309            $tmp_res[$res_data[
'obj_id']][] = $ref_id;
 
  311        return $tmp_res ? $tmp_res : array();
 
  324        foreach ($this->results as 
$result) {
 
  325            if (in_array(
$result[
'obj_id'], $obj_ids)) {
 
  328            $obj_ids[] = 
$result[
'obj_id'];
 
  331        return $objects ? $objects : array();
 
  348            $res[$row[
'obj_id']] = $row[
'child'];
 
  367    public function filter($a_root_node, $check_and)
 
  371        $tree = 
$DIC[
'tree'];
 
  378            if ($check_and and in_array(0, $entry[
'found'])) {
 
  386                    if (is_array($entry[
'child'])) {
 
  387                        $counter += count($entry[
'child']);
 
  391                        $this->limit_reached = 
true;
 
  400                if ($this->search_cache->isFailed($ref_id)) {
 
  404                if ($this->search_cache->isChecked($ref_id) and !$this->isOffsetReached($offset_counter)) {
 
  419                    $this->getRequiredPermission(),
 
  425                    if ($a_root_node == 
ROOT_FOLDER_ID or $tree->isGrandChild($a_root_node, $ref_id)) {
 
  427                        #if($this->callListeners($ref_id,$entry)) 
  430                            $this->search_cache->appendToChecked($ref_id, $entry[
'obj_id']);
 
  438                                $this->limit_reached = 
true;
 
  439                                $this->search_cache->setResults($this->results);
 
  446                $this->search_cache->appendToFailed($ref_id);
 
  449        $this->search_cache->setResults($this->results);
 
  462        $tree = 
$DIC[
'tree'];
 
  465        $this->results = array();
 
  466        foreach ($tmp_results as 
$result) {
 
  467            if ($tree->isGrandChild($a_root_node, 
$result[
'ref_id']) and $tree->isInTree(
$result[
'ref_id'])) {
 
  485        $this->search_cache->save();
 
  496        $this->results = $this->search_cache->getResults();
 
  509        if ($this->entries[$a_obj_id] and is_array($a_childs)) {
 
  510            foreach ($a_childs as $child_id) {
 
  512                    $this->entries[$a_obj_id][
'child'][$child_id] = $child_id;
 
  528        if ($this->results[$a_ref_id] and is_array($a_childs)) {
 
  529            foreach ($a_childs as $child_id) {
 
  530                $this->results[$a_ref_id][
'child'][$child_id] = $child_id;
 
  541        include_once 
'Services/Search/classes/class.ilSearchSettings.php';
 
  545            $this->
setMaxHits($this->search_settings->getMaxHits());
 
  557        include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
 
  559        $this->offset = $this->
getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
 
  573        if (
null === $a_flag) {
 
  593        $this->observers[] = array(
'class' => $a_class,
 
  594                                   'method' => $a_method);
 
  599        foreach ($this->observers as $observer) {
 
  600            $class = &$observer[
'class'];
 
  601            $method = $observer[
'method'];
 
  603            if (!$class->$method($a_ref_id, $a_data)) {
 
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
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.
foreach($_POST as $key=> $value) $res