57 $this->
logger = $DIC->logger()->src();
59 $this->db =
$DIC->database();
60 $this->tree =
$DIC->repositoryTree();
61 $this->
user = $DIC->user();
64 $this->user_id = $a_user_id;
66 $this->user_id = $this->
user->getId();
77 $this->permission = $a_permission;
87 $this->user_id = $a_user_id;
106 $this->max_hits = $a_max_hits;
131 public function addEntry(
int $a_obj_id,
string $a_type, array $found,
int $a_child_id = 0): void
134 if (!isset($this->entries[$a_obj_id])) {
135 $this->entries[$a_obj_id][
'obj_id'] = $a_obj_id;
136 $this->entries[$a_obj_id][
'type'] = $a_type;
137 $this->entries[$a_obj_id][
'found'] = $found;
138 $this->entries[$a_obj_id][
'child'] = [];
140 if ($a_child_id and $a_child_id != $a_obj_id) {
141 $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
145 if ($a_child_id and $a_child_id != $a_obj_id) {
146 $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
149 foreach ($found as $position) {
151 $this->entries[$a_obj_id][
'found'][
$counter] = $position;
169 foreach ($result_obj->
getEntries() as $obj_id => $entry) {
170 $this->
addEntry($entry[
'obj_id'], $entry[
'type'], $entry[
'found']);
182 $this->entries = array();
185 foreach ($this->search_cache->getCheckedItems() as
$ref_id => $obj_id) {
186 if (isset($new_entries[$obj_id])) {
188 $new_entries[$obj_id][
'obj_id'],
189 $new_entries[$obj_id][
'type'],
190 $new_entries[$obj_id][
'found']
193 $new_entries[$obj_id][
'obj_id'],
194 $new_entries[$obj_id][
'child']
207 foreach ($result_obj->
getEntries() as $entry) {
208 $obj_id = $entry[
'obj_id'];
209 if (isset($new_entries[$obj_id])) {
211 $new_entries[$obj_id][
'obj_id'],
212 $new_entries[$obj_id][
'type'],
213 $new_entries[$obj_id][
'found']
217 $new_entries[$obj_id][
'obj_id'],
218 $new_entries[$obj_id][
'child']
224 public function addResult(
int $a_ref_id,
int $a_obj_id,
string $a_type): void
226 $this->results[$a_ref_id][
'ref_id'] = $a_ref_id;
227 $this->results[$a_ref_id][
'obj_id'] = $a_obj_id;
228 $this->results[$a_ref_id][
'type'] = $a_type;
252 $tmp_res[$res_data[
'obj_id']][] =
$ref_id;
265 foreach ($this->results as $result) {
266 if (in_array($result[
'obj_id'], $obj_ids)) {
269 $obj_ids[] = $result[
'obj_id'];
270 $objects[] = $result;
279 if (!is_array($result)) {
283 $res[(
int) $result[
'ref_id']] = (
int) $result[
'obj_id'];
292 $res[$row[
'obj_id']] = $row[
'child'] ?? [];
305 ?
ilDate $creation_filter_date_start =
null,
306 ?
ilDate $creation_filter_date_end =
null
313 if ($check_and and in_array(0, $entry[
'found'])) {
318 if ($type ==
'rolt' or $type ==
'usr' or $type ==
'role') {
320 $this->
addResult($entry[
'obj_id'], $entry[
'obj_id'], $type);
321 if (is_array($entry[
'child'])) {
326 $this->limit_reached =
true;
337 if (!is_null($creation_filter_date_start) || !is_null($creation_filter_date_end)) {
344 $creation_date =
new ilDate(
345 date(
'Y-m-d', strtotime($creation_date_string)),
349 if ($creation_filter_date_start && is_null($creation_filter_date_end)) {
350 if (!
ilDate::_after($creation_date, $creation_filter_date_start)) {
353 } elseif ($creation_filter_date_end && is_null($creation_filter_date_start)) {
357 } elseif (!
ilDate::_within($creation_date, $creation_filter_date_start, $creation_filter_date_end)) {
365 if ($this->search_cache->isFailed(
$ref_id)) {
369 if ($this->search_cache->isChecked(
$ref_id) and !$this->isOffsetReached($offset_counter)) {
384 $this->getRequiredPermission(),
392 #if($this->callListeners($ref_id,$entry))
394 $this->
addResult($ref_id, $entry[
'obj_id'], $type);
395 $this->search_cache->appendToChecked(
$ref_id, $entry[
'obj_id']);
403 $this->limit_reached =
true;
404 $this->search_cache->setResults($this->results);
411 $this->search_cache->appendToFailed(
$ref_id);
414 $this->search_cache->setResults($this->results);
423 $tmp_results = $this->getResults();
424 $this->results = array();
425 foreach ($tmp_results as $result) {
426 if (isset($result[
'ref_id']) && $this->tree->isGrandChild($a_root_node, $result[
'ref_id']) && $this->tree->isInTree($result[
'ref_id'])) {
427 $this->addResult($result[
'ref_id'], $result[
'obj_id'], $result[
'type']);
428 $this->__updateResultChilds($result[
'ref_id'], $result[
'child'] ?? []);
435 $this->search_cache->save();
440 $this->results = $this->search_cache->getResults();
450 if ($this->entries[$a_obj_id] and is_array($a_childs)) {
451 foreach ($a_childs as $child_id) {
453 $this->entries[$a_obj_id][
'child'][$child_id] = $child_id;
466 if ($this->results[$a_ref_id] and is_array($a_childs)) {
467 foreach ($a_childs as $child_id) {
468 $this->results[$a_ref_id][
'child'][$child_id] = $child_id;
478 if (!$this->preventOverwritingMaxhits()) {
479 $this->setMaxHits($this->search_settings->getMaxHits());
486 $this->offset = $this->getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
498 if (
null === $a_flag) {
499 return $this->preventOverwritingMaxhits;
502 $this->preventOverwritingMaxhits = $a_flag;
515 public function addObserver(
object $a_class,
string $a_method): bool
517 $this->observers[] = array(
'class' => $a_class,
518 'method' => $a_method);
525 foreach ($this->observers as $observer) {
526 $class = &$observer[
'class'];
527 $method = $observer[
'method'];
529 if (!$class->$method($a_ref_id, $a_data)) {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class ilAccessHandler Checks access for ILIAS objects.
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=0, ?int $a_tree_id=0)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check whether an date is within a date duration given by start and end.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Component logger with individual log levels by component id.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupCreationDate(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setUserId(int $a_user_id)
isOffsetReached(int $a_counter)
Check if offset is reached.
setRequiredPermission(string $a_permission)
Set the required permission for the rbac checks in function 'filter()'.
getUniqueResults()
Get unique results.
callListeners(int $a_ref_id, array $a_data)
read(int $a_type=ilUserSearchCache::DEFAULT_SEARCH)
addResult(int $a_ref_id, int $a_obj_id, string $a_type)
__construct(int $a_user_id=0)
__updateEntryChilds(int $a_obj_id, array $a_childs)
addEntry(int $a_obj_id, string $a_type, array $found, int $a_child_id=0)
add search result entry Entries are stored with 'obj_id'.
getResultsForPresentation()
setMaxHits(int $a_max_hits)
__initSearchSettingsObject()
diffEntriesFromResult()
diff entries of this instance and another result object Used for search in results
preventOverwritingMaxhits(?bool $a_flag=null)
If you call this function and pass "true" the maxhits setting will not be overwritten in __initSearch...
ilUserSearchCache $search_cache
intersectEntries(ilSearchResult $result_obj)
Build intersection of entries (all entries that are present in both result sets)
mergeEntries(ilSearchResult $result_obj)
merge entries of this instance and another result object
addObserver(object $a_class, string $a_method)
The observer is used to call functions for filtering result.
ilSearchSettings $search_settings
save(int $a_type=ilUserSearchCache::DEFAULT_SEARCH)
bool $preventOverwritingMaxhits
__updateResultChilds(int $a_ref_id, array $a_childs)
Update child ids for a specific result.
filterResults(int $a_root_node)
Filter search area of result set.
filter(int $a_root_node, bool $check_and, ?ilDate $creation_filter_date_start=null, ?ilDate $creation_filter_date_end=null)
Filter search result.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Class for storing search result.
static _getInstance(int $a_usr_id)