ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilCourseXMLWriter.php
Go to the documentation of this file.
1<?php
2
3/*
4 +-----------------------------------------------------------------------------+
5 | ILIAS open source |
6 +-----------------------------------------------------------------------------+
7 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
8 | |
9 | This program is free software; you can redistribute it and/or |
10 | modify it under the terms of the GNU General Public License |
11 | as published by the Free Software Foundation; either version 2 |
12 | of the License, or (at your option) any later version. |
13 | |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software |
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22 +-----------------------------------------------------------------------------+
23*/
24
25include_once "./Services/Xml/classes/class.ilXmlWriter.php";
26
40{
41 const MODE_SOAP = 1;
42 const MODE_EXPORT = 2;
43
45
46
47 private $ilias;
48
49 private $xml;
50 private $course_obj;
51 private $attach_users = true;
52
53
62 {
63 global $ilias;
64
65 parent::ilXmlWriter();
66
67 $this->EXPORT_VERSION = "2";
68
69 $this->ilias =& $ilias;
70 $this->course_obj =& $course_obj;
71 }
72
73 public function setMode($a_mode)
74 {
75 $this->mode = $a_mode;
76 }
77
78 public function getMode()
79 {
80 return $this->mode;
81 }
82
83 function start()
84 {
85 if($this->getMode() == self::MODE_SOAP)
86 {
87
88 $this->__buildHeader();
89 $this->__buildCourseStart();
90 $this->__buildMetaData();
92 if ($this->attach_users)
93 {
94 $this->__buildAdmin();
95 $this->__buildTutor();
96 $this->__buildMember();
97 }
98 $this->__buildSubscriber();
99 $this->__buildWaitingList();
100
101 $this->__buildSetting();
102 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
103 ilContainerSortingSettings::_exportContainerSortingSettings($this,$this->course_obj->getId());
104 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
105 $this->__buildFooter();
106 }
107 elseif($this->getMode() == self::MODE_EXPORT)
108 {
109 $this->__buildCourseStart();
110 $this->__buildMetaData();
112 $this->__buildSetting();
113 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
114 ilContainerSortingSettings::_exportContainerSortingSettings($this,$this->course_obj->getId());
115 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
116 $this->__buildFooter();
117 }
118 }
119
120 function getXML()
121 {
122 #var_dump("<pre>", htmlentities($this->xmlDumpMem()),"<pre>");
123 return $this->xmlDumpMem(false);
124 }
125
126 // Called from nested class
127 function modifyExportIdentifier($a_tag, $a_param, $a_value)
128 {
129 if ($a_tag == "Identifier" && $a_param == "Entry")
130 {
131 $a_value = "il_".$this->ilias->getSetting('inst_id')."_crs_".$this->course_obj->getId();
132 }
133
134 return $a_value;
135 }
136
137 // PRIVATE
138 function __buildHeader()
139 {
140 $this->xmlSetDtdDef("<!DOCTYPE Course PUBLIC \"-//ILIAS//DTD Course//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_crs_5_0.dtd\">");
141 $this->xmlSetGenCmt("Export of ILIAS course ". $this->course_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
142 $this->xmlHeader();
143
144
145 return true;
146 }
147
149 {
150 $attrs["exportVersion"] = $this->EXPORT_VERSION;
151 $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_crs_'.$this->course_obj->getId();
152 $attrs['showMembers'] = ($this->course_obj->getShowMembers() ? 'Yes' : 'No');
153 $this->xmlStartTag("Course", $attrs);
154 }
155
157 {
158 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
159
160 $md2xml = new ilMD2XML($this->course_obj->getId(),$this->course_obj->getId(),'crs');
161 $md2xml->startExport();
162 $this->appendXML($md2xml->getXML());
163
164 return true;
165 }
166
173 private function __buildAdvancedMetaData()
174 {
175 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
176 ilAdvancedMDValues::_appendXMLByObjId($this,$this->course_obj->getId());
177 }
178
179 function __buildAdmin()
180 {
181 foreach($this->course_obj->getMembersObject()->getAdmins() as $id)
182 {
183 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
184 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
185 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
186
187 $this->xmlStartTag('Admin',$attr);
188 $this->xmlEndTag('Admin');
189 }
190 return true;
191 }
192
193 function __buildTutor()
194 {
195 foreach($this->course_obj->getMembersObject()->getTutors() as $id)
196 {
197 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
198 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
199 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
200
201 $this->xmlStartTag('Tutor',$attr);
202 $this->xmlEndTag('Tutor');
203 }
204 return true;
205 }
206 function __buildMember()
207 {
208 foreach($this->course_obj->getMembersObject()->getMembers() as $id)
209 {
210 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
211 $attr['blocked'] = ($this->course_obj->getMembersObject()->isBlocked($id)) ? 'Yes' : 'No';
212 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
213
214 $this->xmlStartTag('Member',$attr);
215 $this->xmlEndTag('Member');
216 }
217 return true;
218 }
219
221 {
222 foreach($this->course_obj->getMembersObject()->getSubscribers() as $id)
223 {
224 $data = $this->course_obj->getMembersObject()->getSubscriberData($id);
225
226 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
227 $attr['subscriptionTime'] = $data['time'];
228
229 $this->xmlStartTag('Subscriber',$attr);
230 $this->xmlEndTag('Subscriber');
231 }
232 return true;
233 }
234
236 {
237 include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
238
239 $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
240
241 foreach($waiting_list->getAllUsers() as $data)
242 {
243 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$data['usr_id'];
244 $attr['position'] = $data['position'];
245 $attr['subscriptionTime'] = $data['time'];
246
247 $this->xmlStartTag('WaitingList',$attr);
248 $this->xmlEndTag('WaitingList');
249 }
250 return true;
251 }
252
253
254 function __buildSetting()
255 {
256 $this->xmlStartTag('Settings');
257
258 // Availability
259 $this->xmlStartTag('Availability');
260 if($this->course_obj->getOfflineStatus())
261 {
262 $this->xmlElement('NotAvailable');
263 }
264 elseif($this->course_obj->getActivationUnlimitedStatus())
265 {
266 $this->xmlElement('Unlimited');
267 }
268 else
269 {
270 $this->xmlStartTag('TemporarilyAvailable');
271 $this->xmlElement('Start',null,$this->course_obj->getActivationStart());
272 $this->xmlElement('End',null,$this->course_obj->getActivationEnd());
273 $this->xmlEndTag('TemporarilyAvailable');
274 }
275 $this->xmlEndTag('Availability');
276
277 // Syllabus
278 $this->xmlElement('Syllabus',null,$this->course_obj->getSyllabus());
279 $this->xmlElement('ImportantInformation',null,$this->course_obj->getImportantInformation());
280
281
282 // Contact
283 $this->xmlStartTag('Contact');
284 $this->xmlElement('Name',null,$this->course_obj->getContactName());
285 $this->xmlElement('Responsibility',null,$this->course_obj->getContactResponsibility());
286 $this->xmlElement('Phone',null,$this->course_obj->getContactPhone());
287 $this->xmlElement('Email',null,$this->course_obj->getContactEmail());
288 $this->xmlElement('Consultation',null,$this->course_obj->getContactConsultation());
289 $this->xmlEndTag('Contact');
290
291 // Registration
292 $attr = array();
293
294 if($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_CONFIRMATION)
295 {
296 $attr['registrationType'] = 'Confirmation';
297 }
298 elseif($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_DIRECT)
299 {
300 $attr['registrationType'] = 'Direct';
301 }
302 else
303 {
304 $attr['registrationType'] = 'Password';
305 }
306
307 $attr['maxMembers'] = $this->course_obj->isSubscriptionMembershipLimited() ?
308 $this->course_obj->getSubscriptionMaxMembers() : 0;
309 $attr['notification'] = $this->course_obj->getSubscriptionNotify() ? 'Yes' : 'No';
310 $attr['waitingList'] = $this->course_obj->enabledWaitingList() ? 'Yes' : 'No';
311
312 $this->xmlStartTag('Registration',$attr);
313
314 if($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
315 {
316 $this->xmlElement('Disabled');
317 }
318 elseif($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_UNLIMITED)
319 {
320 $this->xmlElement('Unlimited');
321 }
322 else
323 {
324 $this->xmlStartTag('TemporarilyAvailable');
325 $this->xmlElement('Start',null,$this->course_obj->getSubscriptionStart());
326 $this->xmlElement('End',null,$this->course_obj->getSubscriptionEnd());
327 $this->xmlEndTag('TemporarilyAvailable');
328 }
329 if(strlen($pwd = $this->course_obj->getSubscriptionPassword()))
330 {
331 $this->xmlElement('Password',null,$pwd);
332 }
333 $this->xmlEndTag('Registration');
334
335 // Archives
336 $attr = array();
337 if($this->course_obj->getViewMode() != IL_CRS_VIEW_ARCHIVE)
338 {
339 $attr['Access'] = 'Disabled';
340 }
341 elseif($this->course_obj->getViewMode() == IL_CRS_VIEW_ARCHIVE)
342 {
343 $attr['Access'] = 'Read';
344 }
345 if($this->course_obj->getArchiveType() == IL_CRS_ARCHIVE_DOWNLOAD)
346 {
347 $attr['Access'] = 'Download';
348 }
349 $this->xmlStartTag('Archive',$attr);
350
351 $this->xmlElement('Start',null,$this->course_obj->getArchiveStart());
352 $this->xmlElement('End',null,$this->course_obj->getArchiveEnd());
353
354 $this->xmlEndTag('Archive');
355
356 $this->xmlStartTag('Period');
357 $this->xmlElement('Start',null,($this->course_obj->getCourseStart() && !$this->course_obj->getCourseStart()->isNull()) ? $this->course_obj->getCourseStart()->get(IL_CAL_UNIX) : null);
358 $this->xmlElement('End',null,($this->course_obj->getCourseEnd() && !$this->course_obj->getCourseEnd()->isNull()) ? $this->course_obj->getCourseEnd()->get(IL_CAL_UNIX) : null);
359 $this->xmlEndTag('Period');
360 $this->xmlElement('WaitingListAutoFill',null,(int)$this->course_obj->hasWaitingListAutoFill());
361 $this->xmlElement('CancellationEnd',null,($this->course_obj->getCancellationEnd() && !$this->course_obj->getCancellationEnd()->isNull()) ? $this->course_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
362 $this->xmlElement('MinMembers',null,(int)$this->course_obj->getSubscriptionMinMembers());
363
364 $this->xmlEndTag('Settings');
365
366 return true;
367 }
368
369 function __buildFooter()
370 {
371 $this->xmlEndTag('Course');
372 }
373
379 function setAttachUsers ($value) {
380 $this->attach_users = $value ? true : false;
381 }
382}
383
384
385?>
const IL_CRS_SUBSCRIPTION_CONFIRMATION
const IL_CRS_ARCHIVE_DOWNLOAD
const IL_CRS_VIEW_ARCHIVE
const IL_CRS_SUBSCRIPTION_UNLIMITED
const IL_CRS_SUBSCRIPTION_DEACTIVATED
const IL_CRS_SUBSCRIPTION_DIRECT
const IL_CAL_UNIX
static _appendXMLByObjId(ilXmlWriter $a_xml_writer, $a_obj_id)
Get xml of object values.
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
modifyExportIdentifier($a_tag, $a_param, $a_value)
__buildAdvancedMetaData()
Build advanced meta data.
ilCourseXMLWriter(&$course_obj)
constructor
setAttachUsers($value)
write access to attach user property, if set to false no users will be attached.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlDumpMem($format=TRUE)
Returns xml document from memory.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlHeader()
Writes xml header @access public.
appendXML($a_str)
append xml string to document
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
$data
redirection script todo: (a better solution should control the processing via a xml file)