ILIAS  Release_3_10_x_branch Revision 61812
 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=CONCAT_AND, $search_field="all", $search_type="all")
 SurveySearch constructor.
 search ()
 Executes a search.

Data Fields

 $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 15696 2008-01-08 18:38:04Z hschottm

Definition at line 36 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 $result, and CONCAT_AND.

{
$where = "";
$fields = array();
if (strcmp($this->search_type, "all") != 0)
{
$where = sprintf("survey_questiontype.type_tag = %s",
$this->ilDB->quote($this->search_type)
);
}
foreach ($this->search_terms as $term)
{
switch ($this->search_field)
{
case "all":
$fields["$term"] = array();
array_push($fields["$term"], sprintf("survey_question.title LIKE %s",
$this->ilDB->quote("%$term%")
));
array_push($fields["$term"], sprintf("survey_question.description LIKE %s",
$this->ilDB->quote("%$term%")
));
array_push($fields["$term"], sprintf("survey_question.author LIKE %s",
$this->ilDB->quote("%$term%")
));
array_push($fields["$term"], sprintf("survey_question.questiontext LIKE %s",
$this->ilDB->quote("%$term%")
));
break;
default:
$fields["$term"] = array();
array_push($fields["$term"], sprintf("survey_question.$this->search_field LIKE %s",
$this->ilDB->quote("%$term%")
));
break;
}
}
$cumulated_fields = array();
foreach ($fields as $params)
{
array_push($cumulated_fields, "(" . join($params, " OR ") . ")");
}
$str_where = "";
if ($this->concatenation == 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 . ")";
}
$query = "SELECT survey_question.*, survey_questiontype.type_tag, object_reference.ref_id FROM survey_question, survey_questiontype, object_reference WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND ISNULL(survey_question.original_id) AND survey_question.obj_fi = object_reference.obj_id AND survey_question.obj_fi > 0$str_where";
$result = $this->ilDB->query($query);
$result_array = array();
global $rbacsystem;
if ($result->numRows() > 0)
{
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
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 = 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 104 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 54 of file class.SurveySearch.php.

Referenced by SurveySearch().

SurveySearch::$ilDB

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

Referenced by SurveySearch().

SurveySearch::$search_field

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

Referenced by SurveySearch().

SurveySearch::$search_results

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

SurveySearch::$search_terms

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

SurveySearch::$search_type

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

Referenced by SurveySearch().


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