19 declare(strict_types=1);
50 [
'rbac_id' => 37,
'obj_id' => 55,
'obj_type' =>
'type1'],
51 [
'rbac_id' => 123,
'obj_id' => 85,
'obj_type' =>
'type2'],
52 [
'rbac_id' => 98,
'obj_id' => 4,
'obj_type' =>
'type3']
60 foreach ($ressource_ids as $ressource_id) {
62 'rbac_id' => $ressource_id->obj_id,
63 'obj_id' => $ressource_id->sub_id,
64 'obj_type' => $ressource_id->type
68 return $array ===
$data;
91 protected array $paths = [];
92 protected bool $force_join_to_base_table =
false;
94 public function addPathAndGetColumn(
96 bool $force_join_to_base_table
98 if (!$this->force_join_to_base_table) {
99 $this->force_join_to_base_table = $force_join_to_base_table;
102 $this->paths[] = $path_string;
103 return $path_string .
'_column';
106 public function getSelectForQuery():
string 108 if (empty($this->paths)) {
109 throw new \ilMDRepositoryException(
'no paths!');
111 return 'selected paths' . ($this->force_join_to_base_table ?
' (join forced)' :
'') .
112 ':[' . implode(
'~', $this->paths) .
']';
115 public function getTableAliasForFilters():
string 117 if (empty($this->paths)) {
118 throw new \ilMDRepositoryException(
'no paths!');
128 $paths_parser_factory,
131 public string $exposed_last_query;
136 protected array $db_result
138 $this->ressource_factory = $ressource_factory;
139 $this->paths_parser_factory = $paths_parser_factory;
142 protected function queryDB(
string $query): \Generator
144 $this->exposed_last_query = $query;
145 yield
from $this->db_result;
148 protected function quoteIdentifier(
string $identifier):
string 150 return '~identifier:' . $identifier .
'~';
153 protected function quoteText(
string $text):
string 155 return '~text:' . $text .
'~';
158 protected function quoteInteger(
int $integer):
string 160 return '~int:' . $integer .
'~';
172 return new class ($negated,
$path, $mode, $value, $mode_negated) extends
NullClause {
174 protected bool $negated,
175 protected string $path,
176 protected Mode $mode,
177 protected string $value,
178 protected bool $mode_negated
182 public function isNegated():
bool 184 return $this->negated;
187 public function isJoin():
bool 201 protected string $path,
202 protected Mode $mode,
203 protected string $value,
204 protected bool $mode_negated
211 public function __construct(
protected string $path)
222 public function isModeNegated():
bool 224 return $this->mode_negated;
227 public function mode():
Mode 232 public function value():
string 251 return new class ($negated, $operator, $clauses) extends
NullClause {
253 protected bool $negated,
255 protected array $clauses
259 public function isNegated():
bool 261 return $this->negated;
264 public function isJoin():
bool 279 protected array $clauses
283 public function operator():
Operator 285 return $this->operator;
288 public function subClauses(): \Generator
290 yield
from $this->clauses;
302 return new class ($obj_id, $sub_id, $type) extends
NullFilter {
312 return $this->obj_id;
317 return $this->sub_id;
338 $result = $searcher->search($clause,
null,
null);
339 $this->assertNull($result->current());
353 $result = $searcher->search($clause,
null,
null);
370 $result = iterator_to_array($searcher->search($clause,
null,
null));
372 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
373 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
374 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
375 'ORDER BY rbac_id, obj_id, obj_type',
376 $searcher->exposed_last_query
391 $result = iterator_to_array($searcher->search($clause,
null,
null));
393 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
394 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
395 'HAVING COUNT(CASE WHEN path_column LIKE ~text:%value%~ THEN 1 END) > 0 ' .
396 'ORDER BY rbac_id, obj_id, obj_type',
397 $searcher->exposed_last_query
412 $result = iterator_to_array($searcher->search($clause,
null,
null));
414 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
415 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
416 'HAVING COUNT(CASE WHEN path_column LIKE ~text:value%~ THEN 1 END) > 0 ' .
417 'ORDER BY rbac_id, obj_id, obj_type',
418 $searcher->exposed_last_query
433 $result = iterator_to_array($searcher->search($clause,
null,
null));
435 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
436 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
437 'HAVING COUNT(CASE WHEN path_column LIKE ~text:%value~ THEN 1 END) > 0 ' .
438 'ORDER BY rbac_id, obj_id, obj_type',
439 $searcher->exposed_last_query
454 $result = iterator_to_array($searcher->search($clause,
null,
null));
456 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
457 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
458 'HAVING COUNT(CASE WHEN NOT path_column = ~text:value~ THEN 1 END) > 0 ' .
459 'ORDER BY rbac_id, obj_id, obj_type',
460 $searcher->exposed_last_query
475 $result = iterator_to_array($searcher->search($clause,
null,
null));
477 'selected paths (join forced):[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
478 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
479 'HAVING NOT COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
480 'ORDER BY rbac_id, obj_id, obj_type',
481 $searcher->exposed_last_query
498 $result = iterator_to_array($searcher->search($clause,
null,
null));
500 'selected paths (join forced):[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
501 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
502 'HAVING COUNT(CASE WHEN path_column = ~text:~ THEN 1 END) > 0 ' .
503 'ORDER BY rbac_id, obj_id, obj_type',
504 $searcher->exposed_last_query
527 $result = iterator_to_array($searcher->search($joined_clause,
null,
null));
529 'selected paths:[path1~path2] GROUP BY ~identifier:base_table~.rbac_id, ' .
530 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
531 'HAVING (COUNT(CASE WHEN path1_column = ~text:value1~ THEN 1 END) > 0 ' .
532 'OR COUNT(CASE WHEN path2_column LIKE ~text:value2%~ THEN 1 END) > 0) ' .
533 'ORDER BY rbac_id, obj_id, obj_type',
534 $searcher->exposed_last_query
555 $joined_clause = $this->
getJoinedClause(
false, Operator::AND, $clause1, $clause2);
557 $result = iterator_to_array($searcher->search($joined_clause,
null,
null));
559 'selected paths:[path1~path2] GROUP BY ~identifier:base_table~.rbac_id, ' .
560 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
561 'HAVING (COUNT(CASE WHEN path1_column LIKE ~text:%value1%~ THEN 1 END) > 0 ' .
562 'AND COUNT(CASE WHEN path2_column LIKE ~text:value2%~ THEN 1 END) > 0) ' .
563 'ORDER BY rbac_id, obj_id, obj_type',
564 $searcher->exposed_last_query
585 $joined_clause = $this->
getJoinedClause(
true, Operator::AND, $clause1, $clause2);
587 $result = iterator_to_array($searcher->search($joined_clause,
null,
null));
589 'selected paths:[path1~path2] GROUP BY ~identifier:base_table~.rbac_id, ' .
590 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
591 'HAVING NOT (COUNT(CASE WHEN path1_column LIKE ~text:%value1%~ THEN 1 END) > 0 ' .
592 'AND COUNT(CASE WHEN path2_column = ~text:value2~ THEN 1 END) > 0) ' .
593 'ORDER BY rbac_id, obj_id, obj_type',
594 $searcher->exposed_last_query
634 $result = iterator_to_array($searcher->search($joined_clause,
null,
null));
636 'selected paths:[path1~path2~path3] GROUP BY ~identifier:base_table~.rbac_id, ' .
637 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
638 'HAVING (COUNT(CASE WHEN path1_column LIKE ~text:%value1%~ THEN 1 END) > 0 ' .
639 'AND NOT (COUNT(CASE WHEN path2_column = ~text:value2~ THEN 1 END) > 0 OR ' .
640 'COUNT(CASE WHEN path3_column LIKE ~text:%value3~ THEN 1 END) > 0)) ' .
641 'ORDER BY rbac_id, obj_id, obj_type',
642 $searcher->exposed_last_query
657 $result = iterator_to_array($searcher->search($clause, 37,
null));
659 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
660 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
661 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
662 'ORDER BY rbac_id, obj_id, obj_type LIMIT ~int:37~',
663 $searcher->exposed_last_query
678 $result = iterator_to_array($searcher->search($clause,
null, 16));
680 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
681 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
682 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
683 'ORDER BY rbac_id, obj_id, obj_type LIMIT ~int:' . PHP_INT_MAX .
'~ OFFSET ~int:16~',
684 $searcher->exposed_last_query
699 $result = iterator_to_array($searcher->search($clause, 37, 16));
701 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
702 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
703 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
704 'ORDER BY rbac_id, obj_id, obj_type LIMIT ~int:37~ OFFSET ~int:16~',
705 $searcher->exposed_last_query
721 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
723 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
724 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
725 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
726 'ORDER BY rbac_id, obj_id, obj_type',
727 $searcher->exposed_last_query
743 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
745 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
746 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
747 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
748 'AND ((~identifier:base_table~.rbac_id = ~int:37~)) ' .
749 'ORDER BY rbac_id, obj_id, obj_type',
750 $searcher->exposed_last_query
766 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
768 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
769 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
770 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
771 'AND ((~identifier:base_table~.obj_id = ~int:15~)) ' .
772 'ORDER BY rbac_id, obj_id, obj_type',
773 $searcher->exposed_last_query
789 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
791 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
792 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
793 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
794 'AND ((~identifier:base_table~.obj_type = ~text:some type~)) ' .
795 'ORDER BY rbac_id, obj_id, obj_type',
796 $searcher->exposed_last_query
810 $filter = $this->
getFilter(37, 15,
'some type');
812 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
814 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
815 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
816 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
817 'AND ((~identifier:base_table~.rbac_id = ~int:37~ AND ' .
818 '~identifier:base_table~.obj_id = ~int:15~ AND ' .
819 '~identifier:base_table~.obj_type = ~text:some type~)) ' .
820 'ORDER BY rbac_id, obj_id, obj_type',
821 $searcher->exposed_last_query
839 $result = iterator_to_array($searcher->search(
848 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
849 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
850 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
851 'AND ((~identifier:base_table~.rbac_id = ~int:37~ AND ~identifier:base_table~.obj_id = ~int:15~) ' .
852 'OR (~identifier:base_table~.obj_id = ~int:15~ AND ~identifier:base_table~.obj_type = ~text:some type~) ' .
853 'OR (~identifier:base_table~.rbac_id = ~int:37~ AND ~identifier:base_table~.obj_type = ~text:some type~)) ' .
854 'ORDER BY rbac_id, obj_id, obj_type',
855 $searcher->exposed_last_query
871 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
873 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
874 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
875 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
876 'AND ((~identifier:base_table~.obj_id = ~identifier:base_table~.rbac_id)) ' .
877 'ORDER BY rbac_id, obj_id, obj_type',
878 $searcher->exposed_last_query
894 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
896 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
897 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
898 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
899 'AND ((~identifier:base_table~.rbac_id = ~identifier:base_table~.obj_id)) ' .
900 'ORDER BY rbac_id, obj_id, obj_type',
901 $searcher->exposed_last_query
917 $result = iterator_to_array($searcher->search($clause,
null,
null, $filter));
919 'selected paths:[path] GROUP BY ~identifier:base_table~.rbac_id, ' .
920 '~identifier:base_table~.obj_id, ~identifier:base_table~.obj_type ' .
921 'HAVING COUNT(CASE WHEN path_column = ~text:value~ THEN 1 END) > 0 ' .
922 'AND ((~identifier:base_table~.rbac_id = ~identifier:base_table~.obj_type)) ' .
923 'ORDER BY rbac_id, obj_id, obj_type',
924 $searcher->exposed_last_query
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.