ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSurveyPhrases Class Reference

Survey phrases class. More...

+ Collaboration diagram for ilSurveyPhrases:

Public Member Functions

 __construct ()
 ilSurveyPhrases constructor
 deletePhrases ($phrase_array)
 Delete phrases from the database.

Static Public Member Functions

static & _getAvailablePhrases ($useronly=0)
 Gets the available phrases from the database.
static & _getCategoriesForPhrase ($phrase_id)
 Gets the available categories for a given phrase.

Detailed Description

Survey phrases class.

The ilSurveyPhrases class manages survey phrases (collections of survey categories) for ordinal survey question types.

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.ilSurveyPhrases.php.

Constructor & Destructor Documentation

ilSurveyPhrases::__construct ( )

ilSurveyPhrases constructor

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

{
}

Member Function Documentation

static& ilSurveyPhrases::_getAvailablePhrases (   $useronly = 0)
static

Gets the available phrases from the database.

Parameters
boolean$useronlyReturns only the user defined phrases if set to true. The default is false.
Returns
array All available phrases as key/value pairs

Definition at line 49 of file class.ilSurveyPhrases.php.

References $ilDB, $lng, $result, and $row.

Referenced by ilSurveyPhrasesGUI\deletePhrasesForm(), ilSurveyPhrasesGUI\phrases(), SurveySingleChoiceQuestionGUI\wizardanswers(), and SurveyMatrixQuestionGUI\wizardcolumns().

{
global $ilUser;
global $ilDB;
global $lng;
$phrases = array();
$result = $ilDB->queryF("SELECT * FROM svy_phrase WHERE defaultvalue = %s OR owner_fi = %s ORDER BY title",
array('text', 'integer'),
array('1', $ilUser->getId())
);
while ($row = $ilDB->fetchObject($result))
{
if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
{
if (!$useronly)
{
$phrases[$row->phrase_id] = array(
"title" => $lng->txt($row->title),
"owner" => $row->owner_fi
);
}
}
else
{
if ($ilUser->getId() == $row->owner_fi)
{
$phrases[$row->phrase_id] = array(
"title" => $row->title,
"owner" => $row->owner_fi
);
}
}
}
return $phrases;
}

+ Here is the caller graph for this function:

static& ilSurveyPhrases::_getCategoriesForPhrase (   $phrase_id)
static

Gets the available categories for a given phrase.

Parameters
integer$phrase_idThe database id of the given phrase
Returns
array All available categories

Definition at line 92 of file class.ilSurveyPhrases.php.

References $ilDB, $lng, $result, and $row.

Referenced by ilSurveyPhrasesGUI\deletePhrasesForm(), ilSurveyPhrasesGUI\phrases(), SurveySingleChoiceQuestionGUI\wizardanswers(), and SurveyMatrixQuestionGUI\wizardcolumns().

{
global $ilDB;
global $lng;
$categories = array();
$result = $ilDB->queryF("SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s ORDER BY svy_phrase_cat.sequence",
array('integer'),
array($phrase_id)
);
while ($row = $ilDB->fetchObject($result))
{
if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
{
$categories[$row->category_id] = $lng->txt($row->title);
}
else
{
$categories[$row->category_id] = $row->title;
}
}
return $categories;
}

+ Here is the caller graph for this function:

ilSurveyPhrases::deletePhrases (   $phrase_array)

Delete phrases from the database.

Parameters
array$phrase_arrayAn array containing phrase id's to delete

Definition at line 121 of file class.ilSurveyPhrases.php.

References $ilDB.

{
global $ilDB;
if ((is_array($phrase_array)) && (count($phrase_array)))
{
$affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase WHERE " . $ilDB->in('phrase_id', $phrase_array, false, 'integer'));
$affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase_cat WHERE " . $ilDB->in('phrase_fi', $phrase_array, false, 'integer'));
}
}

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