ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPollDataSet Class Reference

Poll Dataset class. More...

+ Inheritance diagram for ilPollDataSet:
+ Collaboration diagram for ilPollDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 

Protected Attributes

 $current_blog
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 

Detailed Description

Poll Dataset class.

This class implements the following entities:

  • poll: object data
  • poll_answer: data from table il_poll_answer
Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 17 of file class.ilPollDataSet.php.

Member Function Documentation

◆ getDependencies()

ilPollDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 145 of file class.ilPollDataSet.php.

References array.

146  {
147  switch ($a_entity) {
148  case "poll":
149  return array(
150  "poll_answer" => array("ids" => $a_rec["Id"])
151  );
152  }
153  return false;
154  }
Create styles array
The data for the language used.

◆ getSupportedVersions()

ilPollDataSet::getSupportedVersions ( )

Get supported versions.

Definition at line 24 of file class.ilPollDataSet.php.

References array.

25  {
26  return array("4.3.0", "5.0.0");
27  }
Create styles array
The data for the language used.

◆ getTypes()

ilPollDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Definition at line 40 of file class.ilPollDataSet.php.

References array.

41  {
42  if ($a_entity == "poll") {
43  switch ($a_version) {
44  case "4.3.0":
45  return array(
46  "Id" => "integer",
47  "Title" => "text",
48  "Description" => "text",
49  "Question" => "text",
50  "Image" => "text",
51  "ViewResults" => "integer",
52  "Dir" => "directory"
53  );
54  break;
55  case "5.0.0":
56  return array(
57  "Id" => "integer",
58  "Title" => "text",
59  "Description" => "text",
60  "Question" => "text",
61  "Image" => "text",
62  "ViewResults" => "integer",
63  "Dir" => "directory",
64  "ShowResultsAs" => "integer",
65  "ShowComments" => "integer",
66  "MaxAnswers" => "integer",
67  "ResultSort" => "integer",
68  "NonAnon" => "integer",
69  "Period" => "integer",
70  "PeriodBegin" => "integer",
71  "PeriodEnd" => "integer"
72 
73  );
74  break;
75  }
76  }
77 
78  if ($a_entity == "poll_answer") {
79  switch ($a_version) {
80  case "4.3.0":
81  case "5.0.0":
82  return array(
83  "Id" => "integer",
84  "PollId" => "integer",
85  "Answer" => "text",
86  "Pos" => "integer",
87  );
88  break;
89  }
90  }
91  }
Create styles array
The data for the language used.

◆ getXmlNamespace()

ilPollDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Definition at line 32 of file class.ilPollDataSet.php.

33  {
34  return "http://www.ilias.de/xml/Modules/Poll/" . $a_entity;
35  }

◆ getXmlRecord()

ilPollDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record.

Parameters

Definition at line 162 of file class.ilPollDataSet.php.

References ilNote\commentsActivated(), and ilObjPoll\initStorage().

163  {
164  if ($a_entity == "poll") {
165  include_once("./Modules/Poll/classes/class.ilObjPoll.php");
166  $dir = ilObjPoll::initStorage($a_set["Id"]);
167  $a_set["Dir"] = $dir;
168 
169  include_once("./Services/Notes/classes/class.ilNote.php");
170  $a_set["ShowComments"] = ilNote::commentsActivated($a_set["Id"], 0, "poll");
171  }
172 
173  return $a_set;
174  }
static initStorage($a_id, $a_subdir=null)
Init file system storage.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
+ Here is the call graph for this function:

◆ importRecord()

ilPollDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters

Definition at line 182 of file class.ilPollDataSet.php.

References ilDataSet\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilObjPoll\initStorage(), and ilUtil\rCopy().

183  {
184  switch ($a_entity) {
185  case "poll":
186  include_once("./Modules/Poll/classes/class.ilObjPoll.php");
187 
188  // container copy
189  if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
190  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
191  } else {
192  $newObj = new ilObjPoll();
193  $newObj->create();
194  }
195 
196  $newObj->setTitle($a_rec["Title"]);
197  $newObj->setDescription($a_rec["Description"]);
198  if ((int) $a_rec["MaxAnswers"]) {
199  $newObj->setMaxNumberOfAnswers($a_rec["MaxAnswers"]);
200  }
201  $newObj->setSortResultByVotes((bool) $a_rec["ResultSort"]);
202  $newObj->setNonAnonymous((bool) $a_rec["NonAnon"]);
203  if ((int) $a_rec["ShowResultsAs"]) {
204  $newObj->setShowResultsAs($a_rec["ShowResultsAs"]);
205  }
206  $newObj->setShowComments($a_rec["ShowComments"]);
207  $newObj->setQuestion($a_rec["Question"]);
208  $newObj->setImage($a_rec["Image"]);
209  $newObj->setViewResults($a_rec["ViewResults"]);
210  $newObj->setVotingPeriod($a_rec["Period"]);
211  $newObj->setVotingPeriodBegin($a_rec["PeriodBegin"]);
212  $newObj->setVotingPeriodEnd($a_rec["PeriodEnd"]);
213  $newObj->update();
214 
215  // handle image(s)
216  if ($a_rec["Image"]) {
217  $dir = str_replace("..", "", $a_rec["Dir"]);
218  if ($dir != "" && $this->getImportDirectory() != "") {
219  $source_dir = $this->getImportDirectory() . "/" . $dir;
220  $target_dir = ilObjPoll::initStorage($newObj->getId());
221  ilUtil::rCopy($source_dir, $target_dir);
222  }
223  }
224 
225  $a_mapping->addMapping("Modules/Poll", "poll", $a_rec["Id"], $newObj->getId());
226  break;
227 
228  case "poll_answer":
229  $poll_id = (int) $a_mapping->getMapping("Modules/Poll", "poll", $a_rec["PollId"]);
230  if ($poll_id) {
231  $poll = new ilObjPoll($poll_id, false);
232  $poll->saveAnswer($a_rec["Answer"], $a_rec["pos"]);
233  }
234  break;
235  }
236  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getImportDirectory()
Get import directory.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static initStorage($a_id, $a_subdir=null)
Init file system storage.
Class ilObjPoll.
+ Here is the call graph for this function:

◆ readData()

ilPollDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

Definition at line 99 of file class.ilPollDataSet.php.

References ilDataSet\$db, $ilDB, array, and ilDataSet\getDirectDataFromQuery().

100  {
101  $ilDB = $this->db;
102 
103  if (!is_array($a_ids)) {
104  $a_ids = array($a_ids);
105  }
106 
107  if ($a_entity == "poll") {
108  switch ($a_version) {
109  case "4.3.0":
110  $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description," .
111  "pl.question,pl.image,pl.view_results" .
112  " FROM il_poll pl" .
113  " JOIN object_data od ON (od.obj_id = pl.id)" .
114  " WHERE " . $ilDB->in("pl.id", $a_ids, false, "integer") .
115  " AND od.type = " . $ilDB->quote("poll", "text"));
116  break;
117  case "5.0.0":
118  $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description" .
119  ",pl.question,pl.image,pl.view_results,pl.show_results_as" .
120  ",pl.max_answers,pl.result_sort,pl.non_anon,pl.period,pl.period_begin,pl.period_end" .
121  " FROM il_poll pl" .
122  " JOIN object_data od ON (od.obj_id = pl.id)" .
123  " WHERE " . $ilDB->in("pl.id", $a_ids, false, "integer") .
124  " AND od.type = " . $ilDB->quote("poll", "text"));
125  break;
126 
127  }
128  }
129 
130  if ($a_entity == "poll_answer") {
131  switch ($a_version) {
132  case "4.3.0":
133  case "5.0.0":
134  $this->getDirectDataFromQuery("SELECT id,poll_id,answer,pos" .
135  " FROM il_poll_answer WHERE " .
136  $ilDB->in("poll_id", $a_ids, false, "integer"));
137  break;
138  }
139  }
140  }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $current_blog

ilPollDataSet::$current_blog
protected

Definition at line 19 of file class.ilPollDataSet.php.


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