ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SurveySearch Class Reference

Class for search actions in ILIAS survey tool. More...

+ Collaboration diagram for SurveySearch:

Public Member Functions

 __construct ($search_text="", $concatenation=self::CONCAT_AND, $search_field="all", $search_type="all")
 SurveySearch constructor. More...
 
 search ()
 Executes a search. More...
 

Data Fields

const CONCAT_AND = 0
 
const CONCAT_OR = 1
 
 $search_terms
 
 $concatenation
 
 $search_field
 
 $search_type
 
 $search_results
 
 $ilDB
 

Protected Attributes

 $rbacsystem
 

Detailed Description

Class for search actions in ILIAS survey tool.

The SurveySearch class defines and encapsulates basic methods and attributes to search the ILIAS survey tool for questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 34 of file class.SurveySearch.php.

Constructor & Destructor Documentation

◆ __construct()

SurveySearch::__construct (   $search_text = "",
  $concatenation = self::CONCAT_AND,
  $search_field = "all",
  $search_type = "all" 
)

SurveySearch constructor.

The constructor takes possible arguments an creates an instance of the SurveySearch object.

Parameters
string$titleA title string to describe the question
string$descriptionA description string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator public

Definition at line 110 of file class.SurveySearch.php.

References $concatenation, $DIC, $ilDB, $search_field, and $search_type.

111  {
112  global $DIC;
113 
114  $this->rbacsystem = $DIC->rbac()->system();
115  $ilDB = $DIC->database();
116 
117  $this->ilDB = $ilDB;
118 
119  $this->search_terms = explode(" +", $search_text);
120  $this->concatenation = $concatenation;
121  $this->search_field = $search_field;
122  $this->search_type = $search_type;
123  $this->search_results = array();
124  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ search()

SurveySearch::search ( )

Executes a search.

Executes a search

public

Definition at line 133 of file class.SurveySearch.php.

References $ilDB, PHPMailer\PHPMailer\$params, $rbacsystem, $result, and $row.

134  {
135  $ilDB = $this->ilDB;
136 
137  $where = "";
138  $fields = array();
139  if (strcmp($this->search_type, "all") != 0) {
140  $where = "svy_qtype.type_tag = " . $ilDB->quote($this->search_type, 'text');
141  }
142  foreach ($this->search_terms as $term) {
143  switch ($this->search_field) {
144  case "all":
145  $fields["$term"] = array();
146  array_push($fields["$term"], $ilDB->like("svy_question.title", 'text', "%" . $term . "%"));
147  array_push($fields["$term"], $ilDB->like("svy_question.description", 'text', "%" . $term . "%"));
148  array_push($fields["$term"], $ilDB->like("svy_question.author", 'text', "%" . $term . "%"));
149  array_push($fields["$term"], $ilDB->like("svy_question.questiontext", 'text', "%" . $term . "%"));
150  break;
151  default:
152  $fields["$term"] = array();
153  array_push($fields["$term"], $ilDB->like("svy_question." . $this->search_field, 'text', "%" . $term . "%"));
154  break;
155  }
156  }
157  $cumulated_fields = array();
158  foreach ($fields as $params) {
159  array_push($cumulated_fields, "(" . join(" OR ", $params) . ")");
160  }
161  $str_where = "";
162  if ($this->concatenation == self::CONCAT_AND) {
163  $str_where = "(" . join(" AND ", $cumulated_fields) . ")";
164  } else {
165  $str_where = "(" . join(" OR ", $cumulated_fields) . ")";
166  }
167  if ($str_where) {
168  $str_where = " AND $str_where";
169  }
170  if ($where) {
171  $str_where .= " AND (" . $where . ")";
172  }
173  $result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, object_reference.ref_id FROM " .
174  "svy_question, svy_qtype, object_reference WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
175  "AND svy_question.original_id IS NULL AND svy_question.obj_fi = object_reference.obj_id AND " .
176  "svy_question.obj_fi > 0$str_where");
177  $result_array = array();
179  if ($result->numRows() > 0) {
180  while ($row = $ilDB->fetchAssoc($result)) {
181  if (($row["complete"] == 1) and ($rbacsystem->checkAccess('write', $row["ref_id"]))) {
182  array_push($result_array, $row);
183  }
184  }
185  }
186  $this->search_results = &$result_array;
187  }
$result
$row

Field Documentation

◆ $concatenation

SurveySearch::$concatenation

Definition at line 60 of file class.SurveySearch.php.

Referenced by __construct().

◆ $ilDB

SurveySearch::$ilDB

Definition at line 96 of file class.SurveySearch.php.

Referenced by __construct(), and search().

◆ $rbacsystem

SurveySearch::$rbacsystem
protected

Definition at line 39 of file class.SurveySearch.php.

Referenced by search().

◆ $search_field

SurveySearch::$search_field

Definition at line 69 of file class.SurveySearch.php.

Referenced by __construct().

◆ $search_results

SurveySearch::$search_results

Definition at line 87 of file class.SurveySearch.php.

◆ $search_terms

SurveySearch::$search_terms

Definition at line 51 of file class.SurveySearch.php.

◆ $search_type

SurveySearch::$search_type

Definition at line 78 of file class.SurveySearch.php.

Referenced by __construct().

◆ CONCAT_AND

const SurveySearch::CONCAT_AND = 0

Definition at line 41 of file class.SurveySearch.php.

◆ CONCAT_OR

const SurveySearch::CONCAT_OR = 1

Definition at line 42 of file class.SurveySearch.php.


The documentation for this class was generated from the following file: