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

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 154 of file class.ilPollDataSet.php.

References array.

155  {
156  switch ($a_entity)
157  {
158  case "poll":
159  return array (
160  "poll_answer" => array("ids" => $a_rec["Id"])
161  );
162  }
163  return false;
164  }
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  {
44  switch ($a_version)
45  {
46  case "4.3.0":
47  return array(
48  "Id" => "integer",
49  "Title" => "text",
50  "Description" => "text",
51  "Question" => "text",
52  "Image" => "text",
53  "ViewResults" => "integer",
54  "Dir" => "directory"
55  );
56  break;
57  case "5.0.0":
58  return array(
59  "Id" => "integer",
60  "Title" => "text",
61  "Description" => "text",
62  "Question" => "text",
63  "Image" => "text",
64  "ViewResults" => "integer",
65  "Dir" => "directory",
66  "ShowResultsAs" => "integer",
67  "ShowComments" => "integer",
68  "MaxAnswers" => "integer",
69  "ResultSort" => "integer",
70  "NonAnon" => "integer",
71  "Period" => "integer",
72  "PeriodBegin" => "integer",
73  "PeriodEnd" => "integer"
74 
75  );
76  break;
77  }
78  }
79 
80  if ($a_entity == "poll_answer")
81  {
82  switch ($a_version)
83  {
84  case "4.3.0":
85  case "5.0.0":
86  return array(
87  "Id" => "integer",
88  "PollId" => "integer",
89  "Answer" => "text",
90  "Pos" => "integer",
91  );
92  break;
93  }
94  }
95  }
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 172 of file class.ilPollDataSet.php.

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

173  {
174  if ($a_entity == "poll")
175  {
176  include_once("./Modules/Poll/classes/class.ilObjPoll.php");
177  $dir = ilObjPoll::initStorage($a_set["Id"]);
178  $a_set["Dir"] = $dir;
179 
180  include_once("./Services/Notes/classes/class.ilNote.php");
181  $a_set["ShowComments"] = ilNote::commentsActivated($a_set["Id"], 0, "poll");
182  }
183 
184  return $a_set;
185  }
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 193 of file class.ilPollDataSet.php.

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

194  {
195  switch ($a_entity)
196  {
197  case "poll":
198  include_once("./Modules/Poll/classes/class.ilObjPoll.php");
199 
200  // container copy
201  if($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"]))
202  {
203  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
204  }
205  else
206  {
207  $newObj = new ilObjPoll();
208  $newObj->create();
209  }
210 
211  $newObj->setTitle($a_rec["Title"]);
212  $newObj->setDescription($a_rec["Description"]);
213  if((int)$a_rec["MaxAnswers"])
214  {
215  $newObj->setMaxNumberOfAnswers($a_rec["MaxAnswers"]);
216  }
217  $newObj->setSortResultByVotes((bool)$a_rec["ResultSort"]);
218  $newObj->setNonAnonymous((bool)$a_rec["NonAnon"]);
219  if((int)$a_rec["ShowResultsAs"])
220  {
221  $newObj->setShowResultsAs($a_rec["ShowResultsAs"]);
222  }
223  $newObj->setShowComments($a_rec["ShowComments"]);
224  $newObj->setQuestion($a_rec["Question"]);
225  $newObj->setImage($a_rec["Image"]);
226  $newObj->setViewResults($a_rec["ViewResults"]);
227  $newObj->setVotingPeriod($a_rec["Period"]);
228  $newObj->setVotingPeriodBegin($a_rec["PeriodBegin"]);
229  $newObj->setVotingPeriodEnd($a_rec["PeriodEnd"]);
230  $newObj->update();
231 
232  // handle image(s)
233  if($a_rec["Image"])
234  {
235  $dir = str_replace("..", "", $a_rec["Dir"]);
236  if ($dir != "" && $this->getImportDirectory() != "")
237  {
238  $source_dir = $this->getImportDirectory()."/".$dir;
239  $target_dir = ilObjPoll::initStorage($newObj->getId());
240  ilUtil::rCopy($source_dir, $target_dir);
241  }
242  }
243 
244  $a_mapping->addMapping("Modules/Poll", "poll", $a_rec["Id"], $newObj->getId());
245  break;
246 
247  case "poll_answer":
248  $poll_id = (int) $a_mapping->getMapping("Modules/Poll", "poll", $a_rec["PollId"]);
249  if($poll_id)
250  {
251  $poll = new ilObjPoll($poll_id, false);
252  $poll->saveAnswer($a_rec["Answer"], $a_rec["pos"]);
253  }
254  break;
255  }
256  }
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 103 of file class.ilPollDataSet.php.

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

104  {
105  global $ilDB;
106 
107  if (!is_array($a_ids))
108  {
109  $a_ids = array($a_ids);
110  }
111 
112  if ($a_entity == "poll")
113  {
114  switch ($a_version)
115  {
116  case "4.3.0":
117  $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description,".
118  "pl.question,pl.image,pl.view_results".
119  " FROM il_poll pl".
120  " JOIN object_data od ON (od.obj_id = pl.id)".
121  " WHERE ".$ilDB->in("pl.id", $a_ids, false, "integer").
122  " AND od.type = ".$ilDB->quote("poll", "text"));
123  break;
124  case "5.0.0":
125  $this->getDirectDataFromQuery("SELECT pl.id,od.title,od.description".
126  ",pl.question,pl.image,pl.view_results,pl.show_results_as".
127  ",pl.max_answers,pl.result_sort,pl.non_anon,pl.period,pl.period_begin,pl.period_end".
128  " FROM il_poll pl".
129  " JOIN object_data od ON (od.obj_id = pl.id)".
130  " WHERE " . $ilDB->in("pl.id", $a_ids, false, "integer").
131  " AND od.type = " . $ilDB->quote("poll", "text"));
132  break;
133 
134  }
135  }
136 
137  if ($a_entity == "poll_answer")
138  {
139  switch ($a_version)
140  {
141  case "4.3.0":
142  case "5.0.0":
143  $this->getDirectDataFromQuery("SELECT id,poll_id,answer,pos".
144  " FROM il_poll_answer WHERE ".
145  $ilDB->in("poll_id", $a_ids, false, "integer"));
146  break;
147  }
148  }
149  }
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: