ILIAS  release_8 Revision v8.24
ilCalendarDataSet Class Reference

Calendar data set class. More...

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

Public Member Functions

 getSupportedVersions ()
 @inheritDoc More...
 
 readData (string $a_entity, string $a_version, array $a_ids)
 @inheritDoc More...
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 @inheritDoc More...
 
- 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...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 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 ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> 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...
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 @inheritDoc More...
 
 getTypes (string $a_entity, string $a_version)
 @inheritDoc More...
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 @inheritDoc More...
 
- 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)
 
 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 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
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

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 12 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

@inheritDoc

Reimplemented from ilDataSet.

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

181 : array {
182 switch ($a_entity) {
183 case "calendar":
184 $assignmnts = ilCalendarCategoryAssignments::_getAssignedAppointments(array($a_rec["CatId"] ?? []));
185 $entries = array();
186 foreach ($assignmnts as $cal_id) {
187 $entries[$cal_id] = $cal_id;
188 }
189 return array(
190 "cal_entry" => array("ids" => $entries),
191 "cal_assignment" => array("ids" => $a_rec["CatId"] ?? null)
192 );
193 case "cal_entry":
194 return array(
195 "recurrence_rule" => array("ids" => $a_rec["Id"] ?? null)
196 );
197 }
198
199 return [];
200 }
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.

References ilCalendarCategoryAssignments\_getAssignedAppointments().

+ Here is the call graph for this function:

◆ getSupportedVersions()

ilCalendarDataSet::getSupportedVersions ( )

@inheritDoc

Reimplemented from ilDataSet.

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

17 : array
18 {
19 return array("4.3.0");
20 }

◆ getTypes()

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

@inheritDoc

Reimplemented from ilDataSet.

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

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

◆ getXmlNamespace()

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

@inheritDoc

Reimplemented from ilDataSet.

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

25 : string
26 {
27 return "http://www.ilias.de/xml/Services/Calendar/" . $a_entity;
28 }

◆ importRecord()

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

@inheritDoc

Reimplemented from ilDataSet.

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

211 : void {
212 switch ($a_entity) {
213 case "calendar":
214 // please note: we currently only support private user calendars to
215 // be imported
216 if (($a_rec["Type"] ?? 0) == 1) {
217 $usr_id = (int) $a_mapping->getMapping("Services/User", "usr", $a_rec["ObjId"]);
218 if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
219 $category = new ilCalendarCategory(0);
220 $category->setTitle((string) $a_rec["Title"]);
221 $category->setColor((string) $a_rec["Color"]);
222 $category->setType((int) ilCalendarCategory::TYPE_USR);
223 $category->setObjId((int) $usr_id);
224 $category->add();
225 $a_mapping->addMapping(
226 "Services/Calendar",
227 "calendar",
228 $a_rec["CatId"],
229 (string) $category->getCategoryID()
230 );
231 }
232 }
233 break;
234
235 case "cal_entry":
236 // please note: we currently only support private user calendars to
237 // be imported
238 if ((int) ($a_rec["ContextId"] ?? 0) == 0) {
239 $entry = new ilCalendarEntry(0);
240 $entry->setTitle((string) $a_rec["Title"]);
241 $entry->setSubtitle((string) $a_rec["Subtitle"]);
242 $entry->setDescription((string) $a_rec["Description"]);
243 $entry->setLocation((string) $a_rec["Location"]);
244 $entry->setFullday((bool) $a_rec["Fullday"]);
245 if ($a_rec["Starta"] != "") {
246 $entry->setStart(new ilDateTime($a_rec["Starta"], IL_CAL_DATETIME, 'UTC'));
247 }
248 if (($a_rec["Enda"] ?? '') != "") {
249 $entry->setEnd(new ilDateTime($a_rec["Enda"], IL_CAL_DATETIME, 'UTC'));
250 }
251 $entry->setFurtherInformations((string) ($a_rec["Informations"] ?? ''));
252 $entry->setAutoGenerated((bool) ($a_rec["AutoGenerated"] ?? false));
253 $entry->setContextId((int) ($a_rec["ContextId"] ?? 0));
254 $entry->setMilestone((bool) ($a_rec["Milestone"] ?? false));
255 $entry->setCompletion((int) ($a_rec["Completion"] ?? 0));
256 $entry->setTranslationType((int) ($a_rec["TranslationType"] ?? 0));
257 $entry->enableNotification((bool) ($a_rec["Notification"] ?? false));
258 $entry->save();
259 $a_mapping->addMapping(
260 "Services/Calendar",
261 "cal_entry",
262 $a_rec["Id"],
263 (string) $entry->getEntryId()
264 );
265 }
266 break;
267
268 case "cal_assignment":
269 $cat_id = (int) $a_mapping->getMapping("Services/Calendar", "calendar", $a_rec["CatId"]);
270 $entry_id = (int) $a_mapping->getMapping("Services/Calendar", "cal_entry", $a_rec["EntryId"]);
271 if ($cat_id > 0 && $entry_id > 0) {
272 $ass = new ilCalendarCategoryAssignments($entry_id);
273 $ass->addAssignment($cat_id);
274 }
275 break;
276
277 case "recurrence_rule":
278 $entry_id = $a_mapping->getMapping("Services/Calendar", "cal_entry", $a_rec["EntryId"]);
279 if ($entry_id > 0) {
280 $rec = new ilCalendarRecurrence();
281 $rec->setEntryId((int) $entry_id);
282 $rec->setRecurrence((int) $a_rec["CalRecurrence"]);
283 $rec->setFrequenceType((string) $a_rec["FreqType"]);
284 if ($a_rec["FreqUntilDate"] != "") {
285 $rec->setFrequenceUntilDate(new ilDateTime((string) $a_rec["FreqUntilDate"], IL_CAL_DATETIME));
286 }
287 $rec->setFrequenceUntilCount((int) $a_rec["FreqUntilCount"]);
288 $rec->setInterval((int) ($a_rec["Interval"] ?? 0));
289 $rec->setBYDAY((string) ($a_rec["Byday"] ?? ''));
290 $rec->setBYWEEKNO((string) ($a_rec["Byweekno"] ?? ''));
291 $rec->setBYMONTH((string) ($a_rec["Bymonth"] ?? ''));
292 $rec->setBYMONTHDAY((string) ($a_rec["Bymonthday"] ?? ''));
293 $rec->setBYYEARDAY((string) ($a_rec["Byyearday"] ?? ''));
294 $rec->setBYSETPOS((string) ($a_rec["Bysetpos"] ?? ''));
295 $rec->setWeekstart((string) ($a_rec["Weekstart"] ?? ''));
296 $rec->save();
297 $a_mapping->addMapping(
298 "Services/Calendar",
299 "recurrence_rule",
300 $a_rec["RuleId"],
301 (string) $rec->getRecurrenceId()
302 );
303 }
304 break;
305 }
306 }
const IL_CAL_DATETIME
Stores calendar categories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription Date and time handling
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)

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

+ Here is the call graph for this function:

◆ readData()

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

@inheritDoc

Reimplemented from ilDataSet.

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

112 : void
113 {
114 global $DIC;
115
116 $ilDB = $DIC['ilDB'];
117
118 if (!is_array($a_ids)) {
119 $a_ids = array($a_ids);
120 }
121
122 // calendar
123 if ($a_entity == "calendar") {
124 switch ($a_version) {
125 case "4.3.0":
126 $this->getDirectDataFromQuery("SELECT cat_id, obj_id, title, color, type " .
127 " FROM cal_categories " .
128 " WHERE " .
129 $this->db->in("cat_id", $a_ids, false, "integer"));
130 break;
131 }
132 }
133
134 // cal assignments
135 if ($a_entity == "cal_assignment") {
136 switch ($a_version) {
137 case "4.3.0":
138 $this->getDirectDataFromQuery("SELECT cat_id, cal_id entry_id " .
139 " FROM cal_cat_assignments " .
140 " WHERE " .
141 $this->db->in("cat_id", $a_ids, false, "integer"));
142 break;
143 }
144 }
145
146 // cal entries
147 if ($a_entity == "cal_entry") {
148 switch ($a_version) {
149 case "4.3.0":
150 $this->getDirectDataFromQuery("SELECT cal_id id, title, subtitle, description, location, fullday, " .
151 " starta, enda, informations, auto_generated, context_id, translation_type, is_milestone, completion, notification " .
152 " FROM cal_entries " .
153 " WHERE " .
154 $this->db->in("cal_id", $a_ids, false, "integer"));
155 break;
156 }
157 }
158
159 // recurrence_rule
160 if ($a_entity == "recurrence_rule") {
161 switch ($a_version) {
162 case "4.3.0":
163 $this->getDirectDataFromQuery("SELECT rule_id, cal_id entry_id, cal_recurrence, freq_type, freq_until_date, freq_until_count, " .
164 " intervall, byday, byweekno, bymonth, bymonthday, byyearday, bysetpos, weekstart " .
165 " FROM cal_recurrence_rules " .
166 " WHERE " .
167 $this->db->in("cal_id", $a_ids, false, "integer"));
168 break;
169 }
170 }
171 }
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 ...
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

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