ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCourseXMLWriter Class Reference

XML writer class Class to simplify manual writing of xml documents. More...

+ Inheritance diagram for ilCourseXMLWriter:
+ Collaboration diagram for ilCourseXMLWriter:

Public Member Functions

 __construct (ilObjCourse $course_obj)
 
 setMode (int $a_mode)
 
 getMode ()
 
 start ()
 
 getXML ()
 
 modifyExportIdentifier ($a_tag, $a_param, $a_value)
 
 __buildHeader ()
 
 __buildTitleDescription ()
 
 __buildCourseStart ()
 
 __buildAdmin ()
 
 __buildTutor ()
 
 __buildMember ()
 
 __buildSubscriber ()
 
 __buildWaitingList ()
 
 __buildSetting ()
 
 __buildFooter ()
 
 setAttachUsers ($value)
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Data Fields

const int MODE_SOAP = 1
 
const int MODE_EXPORT = 2
 
const string EXPORT_VERSION = '8.0'
 

Protected Attributes

ilSetting $setting
 
ilAccessHandler $access
 

Private Member Functions

 __buildAdvancedMetaData ()
 

Private Attributes

int $mode = self::MODE_SOAP
 
string $xml = ''
 
ilObjCourse $course_obj
 
bool $attach_users = true
 

Detailed Description

XML writer class Class to simplify manual writing of xml documents.

It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 30 of file class.ilCourseXMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseXMLWriter::__construct ( ilObjCourse  $course_obj)

Definition at line 46 of file class.ilCourseXMLWriter.php.

47 {
48 global $DIC;
49
50 $this->setting = $DIC->settings();
51 $this->access = $DIC->access();
52
54 $this->course_obj = $course_obj;
55 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $course_obj, $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\access().

+ Here is the call graph for this function:

Member Function Documentation

◆ __buildAdmin()

ilCourseXMLWriter::__buildAdmin ( )

Definition at line 138 of file class.ilCourseXMLWriter.php.

138 : void
139 {
140 $admins = $this->course_obj->getMembersObject()->getAdmins();
141 $admins = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
142 'manage_members',
144 $this->course_obj->getRefId(),
145 $admins
146 );
147
148 foreach ($admins as $id) {
149 $attr['id'] = 'il_' . $this->setting->get('inst_id') . '_usr_' . $id;
150 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
151 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
152 $attr['contact'] = $this->course_obj->getMembersObject()->isContact($id) ? 'Yes' : 'No';
153
154 $this->xmlStartTag('Admin', $attr);
155 $this->xmlEndTag('Admin');
156 }
157 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS, $id, ilOrgUnitOperation\OP_MANAGE_MEMBERS, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildAdvancedMetaData()

ilCourseXMLWriter::__buildAdvancedMetaData ( )
private

Definition at line 133 of file class.ilCourseXMLWriter.php.

133 : void
134 {
135 ilAdvancedMDValues::_appendXMLByObjId($this, $this->course_obj->getId());
136 }
static _appendXMLByObjId(ilXmlWriter $a_xml_writer, int $a_obj_id)
Get xml of object values.

References ilAdvancedMDValues\_appendXMLByObjId().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildCourseStart()

ilCourseXMLWriter::__buildCourseStart ( )

Definition at line 125 of file class.ilCourseXMLWriter.php.

125 : void
126 {
127 $attrs["exportVersion"] = self::EXPORT_VERSION;
128 $attrs["id"] = "il_" . $this->setting->get('inst_id') . '_crs_' . $this->course_obj->getId();
129 $attrs['showMembers'] = ($this->course_obj->getShowMembers() ? 'Yes' : 'No');
130 $this->xmlStartTag("Course", $attrs);
131 }

References EXPORT_VERSION, and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildFooter()

ilCourseXMLWriter::__buildFooter ( )

Definition at line 369 of file class.ilCourseXMLWriter.php.

369 : void
370 {
371 $this->xmlEndTag('Course');
372 }

References ilXmlWriter\xmlEndTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildHeader()

ilCourseXMLWriter::__buildHeader ( )

Definition at line 110 of file class.ilCourseXMLWriter.php.

110 : void
111 {
112 $this->xmlSetGenCmt("Export of ILIAS course " . $this->course_obj->getId() . " of installation " . $this->setting->get('inst_id') . ".");
113 $this->xmlHeader();
114 }
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlHeader()
Writes xml header.

References ilXmlWriter\xmlHeader(), and ilXmlWriter\xmlSetGenCmt().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildMember()

ilCourseXMLWriter::__buildMember ( )

Definition at line 179 of file class.ilCourseXMLWriter.php.

179 : void
180 {
181 $members = $this->course_obj->getMembersObject()->getMembers();
182 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
183 'manage_members',
185 $this->course_obj->getRefId(),
186 $members
187 );
188 foreach ($members as $id) {
189 $attr['id'] = 'il_' . $this->setting->get('inst_id') . '_usr_' . $id;
190 $attr['blocked'] = ($this->course_obj->getMembersObject()->isBlocked($id)) ? 'Yes' : 'No';
191 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
192
193 $this->xmlStartTag('Member', $attr);
194 $this->xmlEndTag('Member');
195 }
196 }

References $GLOBALS, $id, ilOrgUnitOperation\OP_MANAGE_MEMBERS, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildSetting()

ilCourseXMLWriter::__buildSetting ( )

Definition at line 243 of file class.ilCourseXMLWriter.php.

243 : void
244 {
245 $this->xmlStartTag('Settings');
246
247 // Availability
248 $this->xmlStartTag('Availability');
249 if ($this->course_obj->getOfflineStatus()) {
250 $this->xmlElement('NotAvailable');
251 } elseif ($this->course_obj->getActivationUnlimitedStatus()) {
252 $this->xmlElement('Unlimited');
253 } else {
254 $this->xmlStartTag('TemporarilyAvailable');
255 $this->xmlElement('Start', null, $this->course_obj->getActivationStart());
256 $this->xmlElement('End', null, $this->course_obj->getActivationEnd());
257 $this->xmlEndTag('TemporarilyAvailable');
258 }
259 $this->xmlEndTag('Availability');
260
261 // Syllabus
262 $this->xmlElement('Syllabus', null, $this->course_obj->getSyllabus());
263 $this->xmlElement('ImportantInformation', null, $this->course_obj->getImportantInformation());
264 $this->xmlElement('TargetGroup', null, $this->course_obj->getTargetGroup());
265
266 // Contact
267 $this->xmlStartTag('Contact');
268 $this->xmlElement('Name', null, $this->course_obj->getContactName());
269 $this->xmlElement('Responsibility', null, $this->course_obj->getContactResponsibility());
270 $this->xmlElement('Phone', null, $this->course_obj->getContactPhone());
271 $this->xmlElement('Email', null, $this->course_obj->getContactEmail());
272 $this->xmlElement('Consultation', null, $this->course_obj->getContactConsultation());
273 $this->xmlEndTag('Contact');
274
275 // Registration
276 $attr = array();
277
278 if ($this->course_obj->getSubscriptionType() == ilCourseConstants::IL_CRS_SUBSCRIPTION_CONFIRMATION) {
279 $attr['registrationType'] = 'Confirmation';
280 } elseif ($this->course_obj->getSubscriptionType() == ilCourseConstants::IL_CRS_SUBSCRIPTION_DIRECT) {
281 $attr['registrationType'] = 'Direct';
282 } else {
283 $attr['registrationType'] = 'Password';
284 }
285
286 $attr['maxMembers'] = $this->course_obj->isSubscriptionMembershipLimited() ?
287 $this->course_obj->getSubscriptionMaxMembers() : 0;
288 $attr['notification'] = $this->course_obj->getSubscriptionNotify() ? 'Yes' : 'No';
289 $attr['waitingList'] = $this->course_obj->enabledWaitingList() ? 'Yes' : 'No';
290
291 $this->xmlStartTag('Registration', $attr);
292
293 if ($this->course_obj->getSubscriptionLimitationType() == ilCourseConstants::IL_CRS_SUBSCRIPTION_DEACTIVATED) {
294 $this->xmlElement('Disabled');
295 } elseif ($this->course_obj->getSubscriptionLimitationType() == ilCourseConstants::IL_CRS_SUBSCRIPTION_UNLIMITED) {
296 $this->xmlElement('Unlimited');
297 } else {
298 $this->xmlStartTag('TemporarilyAvailable');
299 $this->xmlElement('Start', null, $this->course_obj->getSubscriptionStart());
300 $this->xmlElement('End', null, $this->course_obj->getSubscriptionEnd());
301 $this->xmlEndTag('TemporarilyAvailable');
302 }
303 if (strlen($pwd = $this->course_obj->getSubscriptionPassword())) {
304 $this->xmlElement('Password', null, $pwd);
305 }
306 $this->xmlEndTag('Registration');
307
308 $this->xmlStartTag('Period', ['withTime' => $this->course_obj->getCourseStartTimeIndication() ? 1 : 0]);
309 $this->xmlElement(
310 'Start',
311 null,
312 $this->course_obj->getCourseStart()
313 ? $this->course_obj->getCourseStart()->get(IL_CAL_UNIX)
314 : null
315 );
316 $this->xmlElement(
317 'End',
318 null,
319 $this->course_obj->getCourseEnd()
320 ? $this->course_obj->getCourseEnd()->get(IL_CAL_UNIX)
321 : null
322 );
323 $this->xmlEndTag('Period');
324 $this->xmlElement('WaitingListAutoFill', null, (int) $this->course_obj->hasWaitingListAutoFill());
325 $this->xmlElement(
326 'CancellationEnd',
327 null,
328 ($this->course_obj->getCancellationEnd() && !$this->course_obj->getCancellationEnd()->isNull()) ? $this->course_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null
329 );
330 $this->xmlElement('MinMembers', null, $this->course_obj->getSubscriptionMinMembers());
331
332 $this->xmlElement('ViewMode', null, $this->course_obj->getViewMode());
333 if ($this->course_obj->getViewMode() == ilCourseConstants::IL_CRS_VIEW_TIMING) {
334 $this->xmlElement('TimingMode', null, $this->course_obj->getTimingMode());
335 }
336
337 $this->xmlElement('TutorialSupportBlock', [
338 'active' => $this->course_obj->getTutorialSupportBlockSettingValue()
339 ]);
340
341 $this->xmlElement(
342 'SessionLimit',
343 [
344 'active' => $this->course_obj->isSessionLimitEnabled() ? 1 : 0,
345 'previous' => $this->course_obj->getNumberOfPreviousSessions(),
346 'next' => $this->course_obj->getNumberOfNextSessions()
347 ]
348 );
349
350 $this->xmlElement(
351 'WelcomeMail',
352 [
353 'status' => $this->course_obj->getAutoNotification() ? 1 : 0
354 ]
355 );
356
357 $this->xmlElement('StatusDetermination', null, (int) $this->course_obj->getStatusDetermination());
358 $this->xmlElement('MailToMembersType', null, (int) $this->course_obj->getMailToMembersType());
359 $this->xmlElement('CourseMap', [
360 'enabled' => (int) $this->course_obj->getEnableCourseMap(),
361 'latitude' => $this->course_obj->getLatitude(),
362 'longitude' => $this->course_obj->getLongitude(),
363 'location_zoom' => $this->course_obj->getLocationZoom()
364 ]);
365
366 $this->xmlEndTag('Settings');
367 }
const IL_CAL_UNIX
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

References IL_CAL_UNIX, ilCourseConstants\IL_CRS_SUBSCRIPTION_CONFIRMATION, ilCourseConstants\IL_CRS_SUBSCRIPTION_DEACTIVATED, ilCourseConstants\IL_CRS_SUBSCRIPTION_DIRECT, ilCourseConstants\IL_CRS_SUBSCRIPTION_UNLIMITED, ilCourseConstants\IL_CRS_VIEW_TIMING, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildSubscriber()

ilCourseXMLWriter::__buildSubscriber ( )

Definition at line 198 of file class.ilCourseXMLWriter.php.

198 : void
199 {
200 $subs = $this->course_obj->getMembersObject()->getSubscribers();
201 $subs = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
202 'manage_members',
204 $this->course_obj->getRefId(),
205 $subs
206 );
207
208 foreach ($subs as $id) {
209 $data = $this->course_obj->getMembersObject()->getSubscriberData($id);
210
211 $attr['id'] = 'il_' . $this->setting->get('inst_id') . '_usr_' . $id;
212 $attr['subscriptionTime'] = $data['time'];
213
214 $this->xmlStartTag('Subscriber', $attr);
215 $this->xmlEndTag('Subscriber');
216 }
217 }

References $data, $id, ILIAS\Repository\access(), ilOrgUnitOperation\OP_MANAGE_MEMBERS, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildTitleDescription()

ilCourseXMLWriter::__buildTitleDescription ( )

Definition at line 116 of file class.ilCourseXMLWriter.php.

116 : void
117 {
118 $this->xmlElement('Title', null, $this->course_obj->getTitle());
119
120 if ($desc = $this->course_obj->getDescription()) {
121 $this->xmlElement('Description', null, $desc);
122 }
123 }

References ilXmlWriter\xmlElement().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildTutor()

ilCourseXMLWriter::__buildTutor ( )

Definition at line 159 of file class.ilCourseXMLWriter.php.

159 : void
160 {
161 $tutors = $this->course_obj->getMembersObject()->getTutors();
162 $tutors = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
163 'manage_members',
165 $this->course_obj->getRefId(),
166 $tutors
167 );
168 foreach ($tutors as $id) {
169 $attr['id'] = 'il_' . $this->setting->get('inst_id') . '_usr_' . $id;
170 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
171 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
172 $attr['contact'] = $this->course_obj->getMembersObject()->isContact($id) ? 'Yes' : 'No';
173
174 $this->xmlStartTag('Tutor', $attr);
175 $this->xmlEndTag('Tutor');
176 }
177 }

References $id, ILIAS\Repository\access(), ilOrgUnitOperation\OP_MANAGE_MEMBERS, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildWaitingList()

ilCourseXMLWriter::__buildWaitingList ( )

Definition at line 219 of file class.ilCourseXMLWriter.php.

219 : void
220 {
221 $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
222 $wait = $waiting_list->getAllUsers();
223 foreach ($wait as $data) {
224 $is_accessible = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
225 'manage_members',
227 $this->course_obj->getRefId(),
228 [$data['usr_id']]
229 );
230 if (count($is_accessible) === 0) {
231 continue;
232 }
233
234 $attr['id'] = 'il_' . $this->setting->get('inst_id') . '_usr_' . $data['usr_id'];
235 $attr['position'] = $data['position'];
236 $attr['subscriptionTime'] = $data['time'];
237
238 $this->xmlStartTag('WaitingList', $attr);
239 $this->xmlEndTag('WaitingList');
240 }
241 }

References $data, $GLOBALS, ilOrgUnitOperation\OP_MANAGE_MEMBERS, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMode()

ilCourseXMLWriter::getMode ( )

Definition at line 62 of file class.ilCourseXMLWriter.php.

62 : int
63 {
64 return $this->mode;
65 }

References $mode.

Referenced by start().

+ Here is the caller graph for this function:

◆ getXML()

ilCourseXMLWriter::getXML ( )

Definition at line 95 of file class.ilCourseXMLWriter.php.

95 : string
96 {
97 return $this->xmlDumpMem(true);
98 }
xmlDumpMem(bool $format=true)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ modifyExportIdentifier()

ilCourseXMLWriter::modifyExportIdentifier (   $a_tag,
  $a_param,
  $a_value 
)

Definition at line 100 of file class.ilCourseXMLWriter.php.

101 {
102 if ($a_tag == "Identifier" && $a_param == "Entry") {
103 $a_value = "il_" . $this->setting->get('inst_id') . "_crs_" . $this->course_obj->getId();
104 }
105
106 return $a_value;
107 }

◆ setAttachUsers()

ilCourseXMLWriter::setAttachUsers (   $value)

Definition at line 374 of file class.ilCourseXMLWriter.php.

374 : void
375 {
376 $this->attach_users = (bool) $value;
377 }

◆ setMode()

ilCourseXMLWriter::setMode ( int  $a_mode)

Definition at line 57 of file class.ilCourseXMLWriter.php.

57 : void
58 {
59 $this->mode = $a_mode;
60 }

◆ start()

ilCourseXMLWriter::start ( )

Definition at line 67 of file class.ilCourseXMLWriter.php.

67 : void
68 {
69 if ($this->getMode() == self::MODE_SOAP) {
70 $this->__buildHeader();
71 $this->__buildCourseStart();
74 if ($this->attach_users) {
75 $this->__buildAdmin();
76 $this->__buildTutor();
77 $this->__buildMember();
78 }
79 $this->__buildSubscriber();
80 $this->__buildWaitingList();
81
82 $this->__buildSetting();
83 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->course_obj->getId());
84 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
85 $this->__buildFooter();
86 } elseif ($this->getMode() == self::MODE_EXPORT) {
87 $this->__buildCourseStart();
88 $this->__buildSetting();
89 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->course_obj->getId());
90 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
91 $this->__buildFooter();
92 }
93 }
static _exportContainerSortingSettings(ilXmlWriter $xml, int $obj_id)
sorting XML-export for all container objects
static _exportContainerSettings(ilXmlWriter $a_xml, int $a_obj_id)

References __buildAdmin(), __buildAdvancedMetaData(), __buildCourseStart(), __buildFooter(), __buildHeader(), __buildMember(), __buildSetting(), __buildSubscriber(), __buildTitleDescription(), __buildTutor(), __buildWaitingList(), ilContainer\_exportContainerSettings(), ilContainerSortingSettings\_exportContainerSortingSettings(), and getMode().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilCourseXMLWriter::$access
protected

Definition at line 44 of file class.ilCourseXMLWriter.php.

◆ $attach_users

bool ilCourseXMLWriter::$attach_users = true
private

Definition at line 41 of file class.ilCourseXMLWriter.php.

◆ $course_obj

ilObjCourse ilCourseXMLWriter::$course_obj
private

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

Referenced by __construct().

◆ $mode

int ilCourseXMLWriter::$mode = self::MODE_SOAP
private

Definition at line 37 of file class.ilCourseXMLWriter.php.

Referenced by getMode().

◆ $setting

ilSetting ilCourseXMLWriter::$setting
protected

Definition at line 43 of file class.ilCourseXMLWriter.php.

◆ $xml

string ilCourseXMLWriter::$xml = ''
private

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

◆ EXPORT_VERSION

const string ilCourseXMLWriter::EXPORT_VERSION = '8.0'

Definition at line 35 of file class.ilCourseXMLWriter.php.

Referenced by __buildCourseStart().

◆ MODE_EXPORT

const int ilCourseXMLWriter::MODE_EXPORT = 2

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

Referenced by ilCourseExporter\getXmlRepresentation().

◆ MODE_SOAP

const int ilCourseXMLWriter::MODE_SOAP = 1

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


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