ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
SurveySearch Class Reference

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

+ Collaboration diagram for SurveySearch:

Public Member Functions

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

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:
class.SurveySearch.php 43723 2013-07-29 11:19:02Z jluetzen

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

Member Function Documentation

SurveySearch::search ( )

Executes a search.

Executes a search

public

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

References $ilDB, $result, and $row.

{
global $ilDB;
$where = "";
$fields = array();
if (strcmp($this->search_type, "all") != 0)
{
$where = "svy_qtype.type_tag = " . $ilDB->quote($this->search_type, 'text');
}
foreach ($this->search_terms as $term)
{
switch ($this->search_field)
{
case "all":
$fields["$term"] = array();
array_push($fields["$term"], $ilDB->like("svy_question.title", 'text', "%" .$term . "%"));
array_push($fields["$term"], $ilDB->like("svy_question.description", 'text', "%" .$term . "%"));
array_push($fields["$term"], $ilDB->like("svy_question.author", 'text', "%" .$term . "%"));
array_push($fields["$term"], $ilDB->like("svy_question.questiontext", 'text', "%" .$term . "%"));
break;
default:
$fields["$term"] = array();
array_push($fields["$term"], $ilDB->like("svy_question." . $this->search_field, 'text', "%" .$term . "%"));
break;
}
}
$cumulated_fields = array();
foreach ($fields as $params)
{
array_push($cumulated_fields, "(" . join($params, " OR ") . ")");
}
$str_where = "";
if ($this->concatenation == self::CONCAT_AND)
{
$str_where = "(" . join($cumulated_fields, " AND ") . ")";
}
else
{
$str_where = "(" . join($cumulated_fields, " OR ") . ")";
}
if ($str_where)
{
$str_where = " AND $str_where";
}
if ($where)
{
$str_where .= " AND (" . $where . ")";
}
$result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, object_reference.ref_id FROM " .
"svy_question, svy_qtype, object_reference WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id ".
"AND svy_question.original_id IS NULL AND svy_question.obj_fi = object_reference.obj_id AND ".
"svy_question.obj_fi > 0$str_where");
$result_array = array();
global $rbacsystem;
if ($result->numRows() > 0)
{
while ($row = $ilDB->fetchAssoc($result))
{
if (($row["complete"] == 1) and ($rbacsystem->checkAccess('write', $row["ref_id"])))
{
array_push($result_array, $row);
}
}
}
$this->search_results =& $result_array;
}
SurveySearch::SurveySearch (   $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, and $search_type.

{
global $ilDB;
$this->ilDB =& $ilDB;
$this->search_terms = split(" +", $search_text);
$this->concatenation = $concatenation;
$this->search_field = $search_field;
$this->search_type = $search_type;
$this->search_results = array();
}

Field Documentation

SurveySearch::$concatenation

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

Referenced by SurveySearch().

SurveySearch::$ilDB

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

Referenced by search(), and SurveySearch().

SurveySearch::$search_field

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

Referenced by SurveySearch().

SurveySearch::$search_results

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

SurveySearch::$search_terms

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

SurveySearch::$search_type

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

Referenced by SurveySearch().

const SurveySearch::CONCAT_AND = 0

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

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: