51 string $search_text =
"",
52 int $concatenation = self::CONCAT_AND,
53 string $search_field =
"all",
54 string $search_type =
"all" 58 $this->rbacsystem = $DIC->rbac()->system();
59 $ilDB = $DIC->database();
63 $this->search_terms = explode(
" +", $search_text);
67 $this->search_results = array();
77 if (strcmp($this->search_type,
"all") !== 0) {
78 $where =
"svy_qtype.type_tag = " . $ilDB->
quote($this->search_type,
'text');
80 foreach ($this->search_terms as $term) {
81 $fields[(string) $term] = array();
82 switch ($this->search_field) {
84 $fields[(string) $term][] = $ilDB->
like(
"svy_question.title",
'text',
"%" . $term .
"%");
85 $fields[(string) $term][] = $ilDB->
like(
"svy_question.description",
'text',
"%" . $term .
"%");
86 $fields[(string) $term][] = $ilDB->
like(
"svy_question.author",
'text',
"%" . $term .
"%");
87 $fields[(string) $term][] = $ilDB->
like(
"svy_question.questiontext",
'text',
"%" . $term .
"%");
90 $fields[(string) $term][] = $ilDB->
like(
"svy_question." . $this->search_field,
'text',
"%" . $term .
"%");
94 $cumulated_fields = array();
96 $cumulated_fields[] =
"(" . implode(
" OR ", $params) .
")";
99 if ($this->concatenation === self::CONCAT_AND) {
100 $str_where =
"(" . implode(
" AND ", $cumulated_fields) .
")";
102 $str_where =
"(" . implode(
" OR ", $cumulated_fields) .
")";
105 $str_where =
" AND $str_where";
108 $str_where .=
" AND (" . $where .
")";
110 $result = $ilDB->
query(
"SELECT svy_question.*, svy_qtype.type_tag, object_reference.ref_id FROM " .
111 "svy_question, svy_qtype, object_reference WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
112 "AND svy_question.original_id IS NULL AND svy_question.obj_fi = object_reference.obj_id AND " .
113 "svy_question.obj_fi > 0$str_where");
114 $result_array = array();
116 if ($result->numRows() > 0) {
118 if (((
int) $row[
"complete"]) === 1 && $rbacsystem->
checkAccess(
'write', $row[
"ref_id"])) {
119 $result_array[] = $row;
123 $this->search_results = $result_array;
fetchAssoc(ilDBStatement $statement)
like(string $column, string $type, string $value="?", bool $case_insensitive=true)
Generate a like subquery.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
quote($value, string $type)
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
__construct(string $search_text="", int $concatenation=self::CONCAT_AND, string $search_field="all", string $search_type="all")
query(string $query)
Run a (read-only) Query on the database.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...