ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 

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 105 of file class.SurveySearch.php.

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

106  {
107  global $ilDB;
108 
109  $this->ilDB = $ilDB;
110 
111  $this->search_terms = explode(" +", $search_text);
112  $this->concatenation = $concatenation;
113  $this->search_field = $search_field;
114  $this->search_type = $search_type;
115  $this->search_results = array();
116  }
Create styles array
The data for the language used.
Database Wrapper.
Definition: class.ilDB.php:29

Member Function Documentation

◆ search()

SurveySearch::search ( )

Executes a search.

Executes a search

public

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

References $ilDB, $params, $result, $row, and array.

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

Field Documentation

◆ $concatenation

SurveySearch::$concatenation

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

Referenced by __construct().

◆ $ilDB

SurveySearch::$ilDB

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

Referenced by __construct(), and search().

◆ $search_field

SurveySearch::$search_field

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

Referenced by __construct().

◆ $search_results

SurveySearch::$search_results

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

◆ $search_terms

SurveySearch::$search_terms

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

◆ $search_type

SurveySearch::$search_type

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

Referenced by __construct().

◆ CONCAT_AND

const SurveySearch::CONCAT_AND = 0

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

◆ CONCAT_OR

const SurveySearch::CONCAT_OR = 1

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


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