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

XML writer class. More...

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

Public Member Functions

 __construct ($course_obj)
 constructor More...
 
 setMode ($a_mode)
 
 getMode ()
 
 start ()
 
 getXML ()
 
 modifyExportIdentifier ($a_tag, $a_param, $a_value)
 
 __buildHeader ()
 
 __buildCourseStart ()
 
 __buildMetaData ()
 
 __buildAdmin ()
 
 __buildTutor ()
 
 __buildMember ()
 
 __buildSubscriber ()
 
 __buildWaitingList ()
 
 __buildSetting ()
 
 __buildFooter ()
 
 setAttachUsers ($value)
 write access to attach user property, if set to false no users will be attached. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header @access public. More...
 
 xmlStartTag ($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=true, $escape=true)
 Writes data. More...
 
 xmlElement ($tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=true)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr @access public More...
 

Data Fields

const MODE_SOAP = 1
 
const MODE_EXPORT = 2
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Private Member Functions

 __buildAdvancedMetaData ()
 Build advanced meta data. More...
 

Private Attributes

 $mode = self::MODE_SOAP
 
 $ilias
 
 $xml
 
 $course_obj
 
 $attach_users = true
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilCourseXMLWriter::__construct (   $course_obj)

constructor

Parameters
ilObject$course_obj

@access public

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

62 {
63 global $ilias;
64
65 parent::__construct();
66
67 $this->EXPORT_VERSION = "2";
68
69 $this->ilias = $ilias;
70 $this->course_obj = $course_obj;
71 }
redirection script todo: (a better solution should control the processing via a xml file)

References $course_obj, and $ilias.

Member Function Documentation

◆ __buildAdmin()

ilCourseXMLWriter::__buildAdmin ( )

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

174 {
175 $admins = $this->course_obj->getMembersObject()->getAdmins();
176 $admins = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
177 'manage_members',
179 $this->course_obj->getRefId(),
180 $admins
181 );
182
183 foreach ($admins as $id) {
184 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
185 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
186 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
187
188 $this->xmlStartTag('Admin', $attr);
189 $this->xmlEndTag('Admin');
190 }
191 return true;
192 }
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

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

Build advanced meta data.

@access private

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

168 {
169 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
170 ilAdvancedMDValues::_appendXMLByObjId($this, $this->course_obj->getId());
171 }
static _appendXMLByObjId(ilXmlWriter $a_xml_writer, $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 142 of file class.ilCourseXMLWriter.php.

143 {
144 $attrs["exportVersion"] = $this->EXPORT_VERSION;
145 $attrs["id"] = "il_" . $this->ilias->getSetting('inst_id') . '_crs_' . $this->course_obj->getId();
146 $attrs['showMembers'] = ($this->course_obj->getShowMembers() ? 'Yes' : 'No');
147 $this->xmlStartTag("Course", $attrs);
148 }

References 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 365 of file class.ilCourseXMLWriter.php.

366 {
367 $this->xmlEndTag('Course');
368 }

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 132 of file class.ilCourseXMLWriter.php.

133 {
134 $this->xmlSetDtdDef("<!DOCTYPE Course PUBLIC \"-//ILIAS//DTD Course//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_crs_5_0.dtd\">");
135 $this->xmlSetGenCmt("Export of ILIAS course " . $this->course_obj->getId() . " of installation " . $this->ilias->getSetting('inst_id') . ".");
136 $this->xmlHeader();
137
138
139 return true;
140 }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), 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 213 of file class.ilCourseXMLWriter.php.

214 {
215 $members = $this->course_obj->getMembersObject()->getMembers();
216 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
217 'manage_members',
219 $this->course_obj->getRefId(),
220 $members
221 );
222 foreach ($members as $id) {
223 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
224 $attr['blocked'] = ($this->course_obj->getMembersObject()->isBlocked($id)) ? 'Yes' : 'No';
225 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
226
227 $this->xmlStartTag('Member', $attr);
228 $this->xmlEndTag('Member');
229 }
230 return true;
231 }

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:

◆ __buildMetaData()

ilCourseXMLWriter::__buildMetaData ( )

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

151 {
152 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
153
154 $md2xml = new ilMD2XML($this->course_obj->getId(), $this->course_obj->getId(), 'crs');
155 $md2xml->startExport();
156 $this->appendXML($md2xml->getXML());
157
158 return true;
159 }
appendXML($a_str)
append xml string to document

References ilXmlWriter\appendXML().

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 284 of file class.ilCourseXMLWriter.php.

285 {
286 $this->xmlStartTag('Settings');
287
288 // Availability
289 $this->xmlStartTag('Availability');
290 if ($this->course_obj->getOfflineStatus()) {
291 $this->xmlElement('NotAvailable');
292 } elseif ($this->course_obj->getActivationUnlimitedStatus()) {
293 $this->xmlElement('Unlimited');
294 } else {
295 $this->xmlStartTag('TemporarilyAvailable');
296 $this->xmlElement('Start', null, $this->course_obj->getActivationStart());
297 $this->xmlElement('End', null, $this->course_obj->getActivationEnd());
298 $this->xmlEndTag('TemporarilyAvailable');
299 }
300 $this->xmlEndTag('Availability');
301
302 // Syllabus
303 $this->xmlElement('Syllabus', null, $this->course_obj->getSyllabus());
304 $this->xmlElement('ImportantInformation', null, $this->course_obj->getImportantInformation());
305
306
307 // Contact
308 $this->xmlStartTag('Contact');
309 $this->xmlElement('Name', null, $this->course_obj->getContactName());
310 $this->xmlElement('Responsibility', null, $this->course_obj->getContactResponsibility());
311 $this->xmlElement('Phone', null, $this->course_obj->getContactPhone());
312 $this->xmlElement('Email', null, $this->course_obj->getContactEmail());
313 $this->xmlElement('Consultation', null, $this->course_obj->getContactConsultation());
314 $this->xmlEndTag('Contact');
315
316 // Registration
317 $attr = array();
318
319 if ($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_CONFIRMATION) {
320 $attr['registrationType'] = 'Confirmation';
321 } elseif ($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_DIRECT) {
322 $attr['registrationType'] = 'Direct';
323 } else {
324 $attr['registrationType'] = 'Password';
325 }
326
327 $attr['maxMembers'] = $this->course_obj->isSubscriptionMembershipLimited() ?
328 $this->course_obj->getSubscriptionMaxMembers() : 0;
329 $attr['notification'] = $this->course_obj->getSubscriptionNotify() ? 'Yes' : 'No';
330 $attr['waitingList'] = $this->course_obj->enabledWaitingList() ? 'Yes' : 'No';
331
332 $this->xmlStartTag('Registration', $attr);
333
334 if ($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED) {
335 $this->xmlElement('Disabled');
336 } elseif ($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_UNLIMITED) {
337 $this->xmlElement('Unlimited');
338 } else {
339 $this->xmlStartTag('TemporarilyAvailable');
340 $this->xmlElement('Start', null, $this->course_obj->getSubscriptionStart());
341 $this->xmlElement('End', null, $this->course_obj->getSubscriptionEnd());
342 $this->xmlEndTag('TemporarilyAvailable');
343 }
344 if (strlen($pwd = $this->course_obj->getSubscriptionPassword())) {
345 $this->xmlElement('Password', null, $pwd);
346 }
347 $this->xmlEndTag('Registration');
348
349
350 $this->xmlStartTag('Period');
351 $this->xmlElement('Start', null, ($this->course_obj->getCourseStart() && !$this->course_obj->getCourseStart()->isNull()) ? $this->course_obj->getCourseStart()->get(IL_CAL_UNIX) : null);
352 $this->xmlElement('End', null, ($this->course_obj->getCourseEnd() && !$this->course_obj->getCourseEnd()->isNull()) ? $this->course_obj->getCourseEnd()->get(IL_CAL_UNIX) : null);
353 $this->xmlEndTag('Period');
354 $this->xmlElement('WaitingListAutoFill', null, (int) $this->course_obj->hasWaitingListAutoFill());
355 $this->xmlElement('CancellationEnd', null, ($this->course_obj->getCancellationEnd() && !$this->course_obj->getCancellationEnd()->isNull()) ? $this->course_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
356 $this->xmlElement('MinMembers', null, (int) $this->course_obj->getSubscriptionMinMembers());
357
358 $this->xmlElement('ViewMode', null, $this->course_obj->getViewMode());
359
360 $this->xmlEndTag('Settings');
361
362 return true;
363 }
const IL_CRS_SUBSCRIPTION_CONFIRMATION
const IL_CRS_SUBSCRIPTION_UNLIMITED
const IL_CRS_SUBSCRIPTION_DEACTIVATED
const IL_CRS_SUBSCRIPTION_DIRECT
const IL_CAL_UNIX
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

References IL_CAL_UNIX, IL_CRS_SUBSCRIPTION_CONFIRMATION, IL_CRS_SUBSCRIPTION_DEACTIVATED, IL_CRS_SUBSCRIPTION_DIRECT, IL_CRS_SUBSCRIPTION_UNLIMITED, 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 233 of file class.ilCourseXMLWriter.php.

234 {
235 $subs = $this->course_obj->getMembersObject()->getSubscribers();
236 $subs = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
237 'manage_members',
239 $this->course_obj->getRefId(),
240 $subs
241 );
242
243 foreach ($subs as $id) {
244 $data = $this->course_obj->getMembersObject()->getSubscriberData($id);
245
246 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
247 $attr['subscriptionTime'] = $data['time'];
248
249 $this->xmlStartTag('Subscriber', $attr);
250 $this->xmlEndTag('Subscriber');
251 }
252 return true;
253 }

References $data, $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:

◆ __buildTutor()

ilCourseXMLWriter::__buildTutor ( )

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

195 {
196 $tutors = $this->course_obj->getMembersObject()->getTutors();
197 $tutors = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
198 'manage_members',
200 $this->course_obj->getRefId(),
201 $tutors
202 );
203 foreach ($tutors as $id) {
204 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
205 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
206 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
207
208 $this->xmlStartTag('Tutor', $attr);
209 $this->xmlEndTag('Tutor');
210 }
211 return true;
212 }

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:

◆ __buildWaitingList()

ilCourseXMLWriter::__buildWaitingList ( )

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

256 {
257 include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
258 $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
259
260 $wait = $waiting_list->getAllUsers();
261
262 foreach ($wait as $data) {
263 $is_accessible = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
264 'manage_members',
266 $this->course_obj->getRefId(),
267 [$data['usr_id']]
268 );
269 if (!count($is_accessible)) {
270 continue;
271 }
272
273 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $data['usr_id'];
274 $attr['position'] = $data['position'];
275 $attr['subscriptionTime'] = $data['time'];
276
277 $this->xmlStartTag('WaitingList', $attr);
278 $this->xmlEndTag('WaitingList');
279 }
280 return true;
281 }

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 78 of file class.ilCourseXMLWriter.php.

References $mode.

Referenced by start().

+ Here is the caller graph for this function:

◆ getXML()

ilCourseXMLWriter::getXML ( )

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

116 {
117 #var_dump("<pre>", htmlentities($this->xmlDumpMem()),"<pre>");
118 return $this->xmlDumpMem(true);
119 }
xmlDumpMem($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 122 of file class.ilCourseXMLWriter.php.

123 {
124 if ($a_tag == "Identifier" && $a_param == "Entry") {
125 $a_value = "il_" . $this->ilias->getSetting('inst_id') . "_crs_" . $this->course_obj->getId();
126 }
127
128 return $a_value;
129 }

◆ setAttachUsers()

ilCourseXMLWriter::setAttachUsers (   $value)

write access to attach user property, if set to false no users will be attached.

Parameters
unknown_type$value

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

376 {
377 $this->attach_users = $value ? true : false;
378 }

◆ setMode()

ilCourseXMLWriter::setMode (   $a_mode)

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

74 {
75 $this->mode = $a_mode;
76 }

◆ start()

ilCourseXMLWriter::start ( )

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

84 {
85 if ($this->getMode() == self::MODE_SOAP) {
86 $this->__buildHeader();
87 $this->__buildCourseStart();
88 $this->__buildMetaData();
90 if ($this->attach_users) {
91 $this->__buildAdmin();
92 $this->__buildTutor();
93 $this->__buildMember();
94 }
95 $this->__buildSubscriber();
96 $this->__buildWaitingList();
97
98 $this->__buildSetting();
99 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
100 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->course_obj->getId());
101 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
102 $this->__buildFooter();
103 } elseif ($this->getMode() == self::MODE_EXPORT) {
104 $this->__buildCourseStart();
105 $this->__buildMetaData();
107 $this->__buildSetting();
108 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
109 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->course_obj->getId());
110 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
111 $this->__buildFooter();
112 }
113 }
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
__buildAdvancedMetaData()
Build advanced meta data.

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

+ Here is the call graph for this function:

Field Documentation

◆ $attach_users

ilCourseXMLWriter::$attach_users = true
private

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

◆ $course_obj

ilCourseXMLWriter::$course_obj
private

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

Referenced by __construct().

◆ $ilias

ilCourseXMLWriter::$ilias
private

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

Referenced by __construct().

◆ $mode

ilCourseXMLWriter::$mode = self::MODE_SOAP
private

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

Referenced by getMode().

◆ $xml

ilCourseXMLWriter::$xml
private

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

◆ MODE_EXPORT

const ilCourseXMLWriter::MODE_EXPORT = 2

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

Referenced by ilCourseExporter\getXmlRepresentation().

◆ MODE_SOAP

const ilCourseXMLWriter::MODE_SOAP = 1

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


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