60 $this->
logger = $DIC->logger()->src();
62 $this->db =
$DIC->database();
63 $this->tree =
$DIC->repositoryTree();
64 $this->
user = $DIC->user();
65 $this->lom_services =
$DIC->learningObjectMetadata();
68 $this->user_id = $a_user_id;
70 $this->user_id = $this->
user->getId();
81 $this->permission = $a_permission;
91 $this->user_id = $a_user_id;
110 $this->max_hits = $a_max_hits;
141 string $a_child_type =
''
144 if (!isset($this->entries[$a_obj_id])) {
145 $this->entries[$a_obj_id][
'obj_id'] = $a_obj_id;
146 $this->entries[$a_obj_id][
'type'] = $a_type;
147 $this->entries[$a_obj_id][
'found'] = $found;
148 $this->entries[$a_obj_id][
'child'] = [];
150 if ($a_child_id and $a_child_id != $a_obj_id) {
151 $this->entries[$a_obj_id][
'child'][$a_child_type .
'__' . $a_child_id] = [
152 'id' => $a_child_id,
'type' => $a_child_type
157 if ($a_child_id and $a_child_id != $a_obj_id) {
158 $this->entries[$a_obj_id][
'child'][$a_child_type .
'__' . $a_child_id] = [
159 'id' => $a_child_id,
'type' => $a_child_type
163 foreach ($found as $position) {
165 $this->entries[$a_obj_id][
'found'][
$counter] = $position;
174 return count($this->getEntries());
183 foreach ($result_obj->
getEntries() as $obj_id => $entry) {
184 $this->addEntry($entry[
'obj_id'], $entry[
'type'], $entry[
'found']);
185 $this->__updateEntryChilds($entry[
'obj_id'], $entry[
'child']);
195 $new_entries = $this->getEntries();
196 $this->entries = array();
199 foreach ($this->search_cache->getCheckedItems() as
$ref_id => $obj_id) {
200 if (isset($new_entries[$obj_id])) {
202 $new_entries[$obj_id][
'obj_id'],
203 $new_entries[$obj_id][
'type'],
204 $new_entries[$obj_id][
'found']
206 $this->__updateEntryChilds(
207 $new_entries[$obj_id][
'obj_id'],
208 $new_entries[$obj_id][
'child']
219 $new_entries = $this->getEntries();
221 foreach ($result_obj->
getEntries() as $entry) {
222 $obj_id = $entry[
'obj_id'];
223 if (isset($new_entries[$obj_id])) {
225 $new_entries[$obj_id][
'obj_id'],
226 $new_entries[$obj_id][
'type'],
227 $new_entries[$obj_id][
'found']
230 $this->__updateEntryChilds(
231 $new_entries[$obj_id][
'obj_id'],
232 $new_entries[$obj_id][
'child']
238 public function addResult(
int $a_ref_id,
int $a_obj_id,
string $a_type): void
240 $this->results[$a_ref_id][
'ref_id'] = $a_ref_id;
241 $this->results[$a_ref_id][
'obj_id'] = $a_obj_id;
242 $this->results[$a_ref_id][
'type'] = $a_type;
256 foreach ($this->getResults() as
$id => $tmp) {
265 foreach ($this->getResults() as
$ref_id => $res_data) {
266 $tmp_res[$res_data[
'obj_id']][] =
$ref_id;
279 foreach ($this->results as $result) {
280 if (in_array($result[
'obj_id'], $obj_ids)) {
283 $obj_ids[] = $result[
'obj_id'];
284 $objects[] = $result;
292 foreach ($this->getResults() as $result) {
293 if (!is_array($result)) {
297 $res[(
int) $result[
'ref_id']] = (
int) $result[
'obj_id'];
308 foreach ($this->getResults() as $row) {
309 $res[$row[
'obj_id']] = $row[
'child'] ?? [];
323 ?
ilDate $creation_filter_date_start =
null,
324 ?
ilDate $creation_filter_date_end =
null,
325 array $copyright_identifiers = []
328 if ($copyright_identifiers !== []) {
329 $entries_with_copyright = $this->findEntriesWithCopyright(...$copyright_identifiers);
335 foreach ($this->getEntries() as $entry) {
337 if ($check_and and in_array(0, $entry[
'found'])) {
342 if ($type ==
'rolt' or $type ==
'usr' or $type ==
'role') {
343 if ($this->callListeners($entry[
'obj_id'], $entry)) {
344 $this->addResult($entry[
'obj_id'], $entry[
'obj_id'], $type);
345 if (is_array($entry[
'child'])) {
349 if (++
$counter > $this->getMaxHits()) {
350 $this->limit_reached =
true;
361 if (!is_null($creation_filter_date_start) || !is_null($creation_filter_date_end)) {
368 $creation_date =
new ilDate(
369 date(
'Y-m-d', strtotime($creation_date_string)),
373 if ($creation_filter_date_start && is_null($creation_filter_date_end)) {
374 if (!
ilDate::_after($creation_date, $creation_filter_date_start)) {
377 } elseif ($creation_filter_date_end && is_null($creation_filter_date_start)) {
381 } elseif (!
ilDate::_within($creation_date, $creation_filter_date_start, $creation_filter_date_end)) {
387 $filtered_children = $entry[
'child'];
388 if ($copyright_identifiers !== []) {
389 foreach ($filtered_children as $key => $child) {
391 $entry[
'obj_id'] .
'__' . $child[
'id'] .
'__' . $child[
'type'],
392 $entries_with_copyright
396 unset($filtered_children[$key]);
399 empty($filtered_children) &&
401 $entry[
'obj_id'] .
'__' . $entry[
'obj_id'] .
'__' . $entry[
'type'],
402 $entries_with_copyright
413 if ($this->search_cache->isFailed(
$ref_id)) {
417 if ($this->search_cache->isChecked(
$ref_id) and !$this->isOffsetReached($offset_counter)) {
422 if (!$this->callListeners(
$ref_id, $entry)) {
432 $this->getRequiredPermission(),
440 #if($this->callListeners($ref_id,$entry))
442 $this->addResult(
$ref_id, $entry[
'obj_id'], $type);
443 $this->search_cache->appendToChecked(
$ref_id, $entry[
'obj_id']);
444 $this->__updateResultChilds(
$ref_id, $filtered_children);
450 if (
$counter >= $this->getMaxHits()) {
451 $this->limit_reached =
true;
452 $this->search_cache->setResults($this->results);
459 $this->search_cache->appendToFailed(
$ref_id);
462 $this->search_cache->setResults($this->results);
473 foreach ($this->entries as $entry) {
474 $filters[] = $this->lom_services->search()->getFilter(
479 foreach ($entry[
'child'] as $child) {
480 $filters[] = $this->lom_services->search()->getFilter(
488 $clause = $this->lom_services->copyrightHelper()->getCopyrightSearchClause(...$copyright_identifiers);
489 $results = $this->lom_services->search()->execute($clause,
null,
null, ...$filters);
493 $ids[] = $result->objID() .
'__' . $result->subID() .
'__' . $result->type();
503 $tmp_results = $this->getResults();
504 $this->results = array();
505 foreach ($tmp_results as $result) {
506 if (isset($result[
'ref_id']) && $this->tree->isGrandChild($a_root_node, $result[
'ref_id']) && $this->tree->isInTree($result[
'ref_id'])) {
507 $this->addResult($result[
'ref_id'], $result[
'obj_id'], $result[
'type']);
508 $this->__updateResultChilds($result[
'ref_id'], $result[
'child'] ?? []);
515 $this->search_cache->save();
520 $this->results = $this->search_cache->getResults();
530 if ($this->entries[$a_obj_id] and is_array($a_childs)) {
531 foreach ($a_childs as $child_info) {
533 $this->entries[$a_obj_id][
'child'][$child_info[
'type'] .
'__' . $child_info[
'id']] = $child_info;
546 if ($this->results[$a_ref_id] and is_array($a_childs)) {
547 foreach ($a_childs as $child_info) {
548 $this->results[$a_ref_id][
'child'][$child_info[
'type'] .
'__' . $child_info[
'id']] = $child_info;
558 if (!$this->preventOverwritingMaxhits()) {
559 $this->setMaxHits($this->search_settings->getMaxHits());
566 $this->offset = $this->getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
578 if (
null === $a_flag) {
579 return $this->preventOverwritingMaxhits;
582 $this->preventOverwritingMaxhits = $a_flag;
595 public function addObserver(
object $a_class,
string $a_method): bool
597 $this->observers[] = array(
'class' => $a_class,
598 'method' => $a_method);
605 foreach ($this->observers as $observer) {
606 $class = &$observer[
'class'];
607 $method = $observer[
'method'];
609 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)
addEntry(int $a_obj_id, string $a_type, array $found, int $a_child_id=0, string $a_child_type='')
add search result entry Entries are stored with 'obj_id'.
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)
getResultsForPresentation()
LOMServices $lom_services
findEntriesWithCopyright(string ... $copyright_identifiers)
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 children 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, array $copyright_identifiers=[])
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)
if(!file_exists('../ilias.ini.php'))