ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilCalendarDataSet Class Reference

Calendar data set class. More...

+ Inheritance diagram for ilCalendarDataSet:
+ Collaboration diagram for ilCalendarDataSet:

Public Member Functions

 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $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 (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
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
 
int $dircnt = 0
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Detailed Description

Calendar data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 26 of file class.ilCalendarDataSet.php.

Member Function Documentation

◆ getDependencies()

ilCalendarDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Definition at line 184 of file class.ilCalendarDataSet.php.

References ilCalendarCategoryAssignments\_getAssignedAppointments(), and null.

189  : array {
190  switch ($a_entity) {
191  case "calendar":
192  $assignmnts = ilCalendarCategoryAssignments::_getAssignedAppointments(array($a_rec["CatId"] ?? []));
193  $entries = array();
194  foreach ($assignmnts as $cal_id) {
195  $entries[$cal_id] = $cal_id;
196  }
197  return array(
198  "cal_entry" => array("ids" => $entries),
199  "cal_assignment" => array("ids" => $a_rec["CatId"] ?? null)
200  );
201  case "cal_entry":
202  return array(
203  "recurrence_rule" => array("ids" => $a_rec["Id"] ?? null)
204  );
205  }
206 
207  return [];
208  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
+ Here is the call graph for this function:

◆ getSupportedVersions()

ilCalendarDataSet::getSupportedVersions ( )

Definition at line 31 of file class.ilCalendarDataSet.php.

31  : array
32  {
33  return array("4.3.0");
34  }

◆ getTypes()

ilCalendarDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Definition at line 47 of file class.ilCalendarDataSet.php.

47  : array
48  {
49  // calendar
50  if ($a_entity == "calendar") {
51  switch ($a_version) {
52  case "4.3.0":
53  return array(
54  "CatId" => "integer",
55  "ObjId" => "text",
56  "Title" => "text",
57  "Color" => "text",
58  "Type" => "integer"
59  );
60  }
61  }
62 
63  // calendar entry
64  if ($a_entity == "cal_entry") {
65  switch ($a_version) {
66  case "4.3.0":
67  return array(
68  "Id" => "integer",
69  "Title" => "text",
70  "Subtitle" => "text",
71  "Description" => "text",
72  "Location" => "text",
73  "Fullday" => "integer",
74  "Starta" => "text",
75  "Enda" => "text",
76  "Informations" => "text",
77  "AutoGenerated" => "integer",
78  "ContextId" => "integer",
79  "TranslationType" => "integer",
80  "Notification" => "integer"
81  );
82  }
83  }
84 
85  // calendar/entry assignment
86  if ($a_entity == "cal_assignment") {
87  switch ($a_version) {
88  case "4.3.0":
89  return array(
90  "CatId" => "integer",
91  "EntryId" => "integer"
92  );
93  }
94  }
95 
96  // recurrence rule
97  if ($a_entity == "recurrence_rule") {
98  switch ($a_version) {
99  case "4.3.0":
100  return array(
101  "RuleId" => "integer",
102  "EntryId" => "integer",
103  "CalRecurrence" => "integer",
104  "FreqType" => "text",
105  "FreqUntilDate" => "text",
106  "FreqUntilCount" => "integer",
107  "Intervall" => "integer",
108  "Byday" => "text",
109  "Byweekno" => "text",
110  "Bymonth" => "text",
111  "Bymonthday" => "text",
112  "Byyearday" => "text",
113  "Bysetpos" => "text",
114  "Weekstart" => "text"
115  );
116  }
117  }
118  return [];
119  }

◆ getXmlNamespace()

ilCalendarDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

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

39  : string
40  {
41  return "http://www.ilias.de/xml/Services/Calendar/" . $a_entity;
42  }

◆ importRecord()

ilCalendarDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Definition at line 213 of file class.ilCalendarDataSet.php.

References ilObject\_lookupType(), ilImportMapping\addMapping(), ilImportMapping\getMapping(), IL_CAL_DATETIME, ILIAS\Repository\int(), and ilCalendarCategory\TYPE_USR.

219  : void {
220  switch ($a_entity) {
221  case "calendar":
222  // please note: we currently only support private user calendars to
223  // be imported
224  if (($a_rec["Type"] ?? 0) == 1) {
225  $usr_id = (int) $a_mapping->getMapping("components/ILIAS/User", "usr", $a_rec["ObjId"]);
226  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
227  $category = new ilCalendarCategory(0);
228  $category->setTitle((string) $a_rec["Title"]);
229  $category->setColor((string) $a_rec["Color"]);
230  $category->setType((int) ilCalendarCategory::TYPE_USR);
231  $category->setObjId((int) $usr_id);
232  $category->add();
233  $a_mapping->addMapping(
234  "components/ILIAS/Calendar",
235  "calendar",
236  $a_rec["CatId"],
237  (string) $category->getCategoryID()
238  );
239  }
240  }
241  break;
242 
243  case "cal_entry":
244  // please note: we currently only support private user calendars to
245  // be imported
246  if ((int) ($a_rec["ContextId"] ?? 0) == 0) {
247  $entry = new ilCalendarEntry(0);
248  $entry->setTitle((string) $a_rec["Title"]);
249  $entry->setSubtitle((string) $a_rec["Subtitle"]);
250  $entry->setDescription((string) $a_rec["Description"]);
251  $entry->setLocation((string) $a_rec["Location"]);
252  $entry->setFullday((bool) $a_rec["Fullday"]);
253  if ($a_rec["Starta"] != "") {
254  $entry->setStart(new ilDateTime($a_rec["Starta"], IL_CAL_DATETIME, 'UTC'));
255  }
256  if (($a_rec["Enda"] ?? '') != "") {
257  $entry->setEnd(new ilDateTime($a_rec["Enda"], IL_CAL_DATETIME, 'UTC'));
258  }
259  $entry->setFurtherInformations((string) ($a_rec["Informations"] ?? ''));
260  $entry->setAutoGenerated((bool) ($a_rec["AutoGenerated"] ?? false));
261  $entry->setContextId((int) ($a_rec["ContextId"] ?? 0));
262  $entry->setTranslationType((int) ($a_rec["TranslationType"] ?? 0));
263  $entry->enableNotification((bool) ($a_rec["Notification"] ?? false));
264  $entry->save();
265  $a_mapping->addMapping(
266  "components/ILIAS/Calendar",
267  "cal_entry",
268  $a_rec["Id"],
269  (string) $entry->getEntryId()
270  );
271  }
272  break;
273 
274  case "cal_assignment":
275  $cat_id = (int) $a_mapping->getMapping("components/ILIAS/Calendar", "calendar", $a_rec["CatId"]);
276  $entry_id = (int) $a_mapping->getMapping("components/ILIAS/Calendar", "cal_entry", $a_rec["EntryId"]);
277  if ($cat_id > 0 && $entry_id > 0) {
278  $ass = new ilCalendarCategoryAssignments($entry_id);
279  $ass->addAssignment($cat_id);
280  }
281  break;
282 
283  case "recurrence_rule":
284  $entry_id = $a_mapping->getMapping("components/ILIAS/Calendar", "cal_entry", $a_rec["EntryId"]);
285  if ($entry_id > 0) {
286  $rec = new ilCalendarRecurrence();
287  $rec->setEntryId((int) $entry_id);
288  $rec->setRecurrence((int) $a_rec["CalRecurrence"]);
289  $rec->setFrequenceType((string) $a_rec["FreqType"]);
290  if ($a_rec["FreqUntilDate"] != "") {
291  $rec->setFrequenceUntilDate(new ilDateTime((string) $a_rec["FreqUntilDate"], IL_CAL_DATETIME));
292  }
293  $rec->setFrequenceUntilCount((int) $a_rec["FreqUntilCount"]);
294  $rec->setInterval((int) ($a_rec["Interval"] ?? 0));
295  $rec->setBYDAY((string) ($a_rec["Byday"] ?? ''));
296  $rec->setBYWEEKNO((string) ($a_rec["Byweekno"] ?? ''));
297  $rec->setBYMONTH((string) ($a_rec["Bymonth"] ?? ''));
298  $rec->setBYMONTHDAY((string) ($a_rec["Bymonthday"] ?? ''));
299  $rec->setBYYEARDAY((string) ($a_rec["Byyearday"] ?? ''));
300  $rec->setBYSETPOS((string) ($a_rec["Bysetpos"] ?? ''));
301  $rec->setWeekstart((string) ($a_rec["Weekstart"] ?? ''));
302  $rec->save();
303  $a_mapping->addMapping(
304  "components/ILIAS/Calendar",
305  "recurrence_rule",
306  $a_rec["RuleId"],
307  (string) $rec->getRecurrenceId()
308  );
309  }
310  break;
311  }
312  }
const IL_CAL_DATETIME
Stores calendar categories.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ readData()

ilCalendarDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Definition at line 124 of file class.ilCalendarDataSet.php.

References ilDataSet\getDirectDataFromQuery().

124  : void
125  {
126  if (!is_array($a_ids)) {
127  $a_ids = array($a_ids);
128  }
129 
130  // calendar
131  if ($a_entity == "calendar") {
132  switch ($a_version) {
133  case "4.3.0":
134  $this->getDirectDataFromQuery("SELECT cat_id, obj_id, title, color, type " .
135  " FROM cal_categories " .
136  " WHERE " .
137  $this->db->in("cat_id", $a_ids, false, "integer"));
138  break;
139  }
140  }
141 
142  // cal assignments
143  if ($a_entity == "cal_assignment") {
144  switch ($a_version) {
145  case "4.3.0":
146  $this->getDirectDataFromQuery("SELECT cat_id, cal_id entry_id " .
147  " FROM cal_cat_assignments " .
148  " WHERE " .
149  $this->db->in("cat_id", $a_ids, false, "integer"));
150  break;
151  }
152  }
153 
154  // cal entries
155  if ($a_entity == "cal_entry") {
156  switch ($a_version) {
157  case "4.3.0":
158  $this->getDirectDataFromQuery("SELECT cal_id id, title, subtitle, description, location, fullday, " .
159  " starta, enda, informations, auto_generated, context_id, translation_type, notification " .
160  " FROM cal_entries " .
161  " WHERE " .
162  $this->db->in("cal_id", $a_ids, false, "integer"));
163  break;
164  }
165  }
166 
167  // recurrence_rule
168  if ($a_entity == "recurrence_rule") {
169  switch ($a_version) {
170  case "4.3.0":
171  $this->getDirectDataFromQuery("SELECT rule_id, cal_id entry_id, cal_recurrence, freq_type, freq_until_date, freq_until_count, " .
172  " intervall, byday, byweekno, bymonth, bymonthday, byyearday, bysetpos, weekstart " .
173  " FROM cal_recurrence_rules " .
174  " WHERE " .
175  $this->db->in("cal_id", $a_ids, false, "integer"));
176  break;
177  }
178  }
179  }
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
+ Here is the call graph for this function:

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