• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Course/classes/class.ilCourseXMLWriter.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004     +-----------------------------------------------------------------------------+
00005     | ILIAS open source                                                           |
00006         +-----------------------------------------------------------------------------+
00007     | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00008     |                                                                             |
00009     | This program is free software; you can redistribute it and/or               |
00010     | modify it under the terms of the GNU General Public License                 |
00011     | as published by the Free Software Foundation; either version 2              |
00012     | of the License, or (at your option) any later version.                      |
00013     |                                                                             |
00014     | This program is distributed in the hope that it will be useful,             |
00015     | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016     | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017     | GNU General Public License for more details.                                |
00018     |                                                                             |
00019     | You should have received a copy of the GNU General Public License           |
00020     | along with this program; if not, write to the Free Software                 |
00021     | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022     +-----------------------------------------------------------------------------+
00023 */
00024 
00038 include_once "./classes/class.ilXmlWriter.php";
00039 
00040 class ilCourseXMLWriter extends ilXmlWriter
00041 {
00042         private  $ilias;
00043 
00044         private  $xml;
00045         private  $course_obj;
00046         private $attach_users = true;
00047         
00048 
00056         function ilCourseXMLWriter(&$course_obj)
00057         {
00058                 global $ilias;
00059 
00060                 parent::ilXmlWriter();
00061 
00062                 $this->EXPORT_VERSION = "2";
00063 
00064                 $this->ilias =& $ilias;
00065                 $this->course_obj =& $course_obj;
00066         }
00067 
00068         function start()
00069         {
00070                 $this->__buildHeader();
00071                 $this->__buildMetaData();
00072                 $this->__buildAdvancedMetaData();
00073                 if ($this->attach_users) 
00074                 {
00075                         $this->__buildAdmin();
00076                         $this->__buildTutor();
00077                         $this->__buildMember();
00078                 }
00079                 $this->__buildSubscriber();
00080                 $this->__buildWaitingList();
00081                 
00082                 $this->__buildSetting();
00083 
00084                 #$this->__buildObject($this->course_obj->getRefId());
00085                 
00086                 $this->__buildFooter();
00087         }
00088 
00089         function getXML()
00090         {
00091                 #var_dump("<pre>", htmlentities($this->xmlDumpMem()),"<pre>");
00092                 return $this->xmlDumpMem(false);
00093         }
00094 
00095         // Called from nested class
00096         function modifyExportIdentifier($a_tag, $a_param, $a_value)
00097         {
00098                 if ($a_tag == "Identifier" && $a_param == "Entry")
00099                 {
00100                         $a_value = "il_".$this->ilias->getSetting('inst_id')."_crs_".$this->course_obj->getId();
00101                 }
00102 
00103                 return $a_value;
00104         }
00105 
00106         // PRIVATE
00107         function __buildHeader()
00108         {
00109                 $this->xmlSetDtdDef("<!DOCTYPE Course PUBLIC \"-//ILIAS//DTD Course//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_course_3_8.dtd\">"); 
00110                 $this->xmlSetGenCmt("Export of ILIAS course ". $this->course_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
00111                 $this->xmlHeader();
00112 
00113                 $attrs["exportVersion"] = $this->EXPORT_VERSION;
00114                 $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_crs_'.$this->course_obj->getId();
00115                 $this->xmlStartTag("Course", $attrs);
00116 
00117                 return true;
00118         }
00119         function __buildMetaData()
00120         {
00121                 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
00122 
00123                 $md2xml = new ilMD2XML($this->course_obj->getId(),$this->course_obj->getId(),'crs');
00124                 $md2xml->startExport();
00125                 $this->appendXML($md2xml->getXML());
00126 
00127                 return true;
00128         }
00129         
00136         private function __buildAdvancedMetaData()
00137         {
00138                 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
00139                 ilAdvancedMDValues::_appendXMLByObjId($this,$this->course_obj->getId());
00140         }
00141         
00142         function __buildAdmin()
00143         {
00144                 $this->course_obj->initCourseMemberObject();
00145 
00146                 foreach($this->course_obj->members_obj->getAdmins() as $id)
00147                 {
00148                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00149                         $attr['notification'] = ($this->course_obj->members_obj->isNotificationEnabled($id)) ? 'Yes' : 'No';
00150                         $attr['passed'] = $this->course_obj->members_obj->hasPassed($id) ? 'Yes' : 'No';
00151 
00152                         $this->xmlStartTag('Admin',$attr);
00153                         $this->xmlEndTag('Admin');
00154                 }
00155                 return true;
00156         }
00157 
00158         function __buildTutor()
00159         {
00160                 $this->course_obj->initCourseMemberObject();
00161 
00162                 foreach($this->course_obj->members_obj->getTutors() as $id)
00163                 {
00164                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00165                         $attr['notification'] = ($this->course_obj->members_obj->isNotificationEnabled($id)) ? 'Yes' : 'No';
00166                         $attr['passed'] = $this->course_obj->members_obj->hasPassed($id) ? 'Yes' : 'No';
00167 
00168                         $this->xmlStartTag('Tutor',$attr);
00169                         $this->xmlEndTag('Tutor');
00170                 }
00171                 return true;
00172         }
00173         function __buildMember()
00174         {
00175                 $this->course_obj->initCourseMemberObject();
00176 
00177                 foreach($this->course_obj->members_obj->getMembers() as $id)
00178                 {
00179                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00180                         $attr['blocked'] = ($this->course_obj->members_obj->isBlocked($id)) ? 'Yes' : 'No';
00181                         $attr['passed'] = $this->course_obj->members_obj->hasPassed($id) ? 'Yes' : 'No';
00182 
00183                         $this->xmlStartTag('Member',$attr);
00184                         $this->xmlEndTag('Member');
00185                 }
00186                 return true;
00187         }
00188 
00189         function __buildSubscriber()
00190         {
00191                 $this->course_obj->initCourseMemberObject();
00192 
00193                 foreach($this->course_obj->members_obj->getSubscribers() as $id)
00194                 {
00195                         $data = $this->course_obj->members_obj->getSubscriberData($id);
00196 
00197                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00198                         $attr['subscriptionTime'] = $data['time'];
00199 
00200                         $this->xmlStartTag('Subscriber',$attr);
00201                         $this->xmlEndTag('Subscriber');
00202                 }
00203                 return true;
00204         }
00205 
00206         function __buildWaitingList()
00207         {
00208                 include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
00209 
00210                 $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
00211                 
00212                 foreach($waiting_list->getAllUsers() as $data)
00213                 {
00214                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$data['usr_id'];
00215                         $attr['position'] = $data['position'];
00216                         $attr['subscriptionTime'] = $data['time'];
00217                         
00218                         $this->xmlStartTag('WaitingList',$attr);
00219                         $this->xmlEndTag('WaitingList');
00220                 }
00221                 return true;
00222         }
00223 
00224 
00225         function __buildSetting()
00226         {
00227                 $this->xmlStartTag('Settings');
00228 
00229                 // Availability
00230                 $this->xmlStartTag('Availability');
00231                 if($this->course_obj->getOfflineStatus())
00232                 {
00233                         $this->xmlElement('NotAvailable');
00234                 }
00235                 elseif($this->course_obj->getActivationUnlimitedStatus())
00236                 {
00237                         $this->xmlElement('Unlimited');
00238                 }
00239                 else
00240                 {
00241                         $this->xmlStartTag('TemporarilyAvailable');
00242                         $this->xmlElement('Start',null,$this->course_obj->getActivationStart());
00243                         $this->xmlElement('End',null,$this->course_obj->getActivationEnd());
00244                         $this->xmlEndTag('TemporarilyAvailable');
00245                 }
00246                 $this->xmlEndTag('Availability');
00247 
00248                 // Syllabus
00249                 $this->xmlElement('Syllabus',null,$this->course_obj->getSyllabus());
00250                 $this->xmlElement('ImportantInformation',null,$this->course_obj->getImportantInformation());
00251                 
00252                 
00253                 // Contact
00254                 $this->xmlStartTag('Contact');
00255                 $this->xmlElement('Name',null,$this->course_obj->getContactName());
00256                 $this->xmlElement('Responsibility',null,$this->course_obj->getContactResponsibility());
00257                 $this->xmlElement('Phone',null,$this->course_obj->getContactPhone());
00258                 $this->xmlElement('Email',null,$this->course_obj->getContactEmail());
00259                 $this->xmlElement('Consultation',null,$this->course_obj->getContactConsultation());
00260                 $this->xmlEndTag('Contact');
00261 
00262                 // Registration
00263                 $attr = array();
00264 
00265                 if($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_CONFIRMATION)
00266                 {
00267                         $attr['registrationType'] = 'Confirmation';
00268                 }
00269                 elseif($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_DIRECT)
00270                 {
00271                         $attr['registrationType'] = 'Direct';
00272                 }
00273                 else
00274                 {
00275                         $attr['registrationType'] = 'Password';
00276                 }
00277 
00278                 $attr['maxMembers'] = $this->course_obj->getSubscriptionMaxMembers();
00279                 $attr['notification'] = $this->course_obj->getSubscriptionNotify() ? 'Yes' : 'No';
00280                 $attr['waitingList'] = $this->course_obj->enabledWaitingList() ? 'Yes' : 'No';
00281 
00282                 $this->xmlStartTag('Registration',$attr);
00283                 
00284                 if($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
00285                 {
00286                         $this->xmlElement('Disabled');
00287                 }
00288                 elseif($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_UNLIMITED)
00289                 {
00290                         $this->xmlElement('Unlimited');
00291                 }
00292                 else
00293                 {
00294                         $this->xmlStartTag('TemporarilyAvailable');
00295                         $this->xmlElement('Start',null,$this->course_obj->getSubscriptionStart());
00296                         $this->xmlElement('End',null,$this->course_obj->getSubscriptionEnd());
00297                         $this->xmlEndTag('TemporarilyAvailable');
00298                 }
00299                 if(strlen($pwd = $this->course_obj->getSubscriptionPassword()))
00300                 {
00301                         $this->xmlElement('Password',null,$pwd);
00302                 }
00303                 $this->xmlEndTag('Registration');
00304 
00305                 // Sort
00306                 $attr = array();
00307                 if($this->course_obj->getOrderType() == IL_CRS_SORT_MANUAL)
00308                 {
00309                         $attr['type'] = 'Manual';
00310                 }
00311                 elseif($this->course_obj->getOrderType() == IL_CRS_SORT_TITLE)
00312                 {
00313                         $attr['type'] = 'Title';
00314                 }
00315                 else
00316                 {
00317                         $attr['type'] = 'Activation';
00318                 }
00319                 $this->xmlElement('Sort',$attr);
00320 
00321                 // Archives
00322                 $attr = array();
00323                 if($this->course_obj->getViewMode() != IL_CRS_VIEW_ARCHIVE)
00324                 {
00325                         $attr['Access'] = 'Disabled';
00326                 }
00327                 elseif($this->course_obj->getViewMode() == IL_CRS_VIEW_ARCHIVE)
00328                 {
00329                         $attr['Access'] = 'Read';
00330                 }
00331                 if($this->course_obj->getArchiveType() == IL_CRS_ARCHIVE_DOWNLOAD)
00332                 {
00333                         $attr['Access'] = 'Download';
00334                 }
00335                 $this->xmlStartTag('Archive',$attr);
00336 
00337                 $this->xmlElement('Start',null,$this->course_obj->getArchiveStart());
00338                 $this->xmlElement('End',null,$this->course_obj->getArchiveEnd());
00339 
00340                 $this->xmlEndTag('Archive');
00341 
00342                 $this->xmlEndTag('Settings');
00343 
00344                 return true;
00345         }
00346 
00347         
00348         // recursive
00349         function __buildObject($a_parent_id)
00350         {
00351                 $this->course_obj->initCourseItemObject();
00352                 $this->course_obj->items_obj->setParentId($a_parent_id);
00353 
00354                 foreach($this->course_obj->items_obj->getAllItems() as $item)
00355                 {
00356                         
00357                         if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'],false))
00358                         {
00359                                 continue;
00360                         }
00361                 
00362                         $attr = array();
00363                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_'.$tmp_obj->getType().'_'.$item['child'];
00364                         $attr['type'] = $tmp_obj->getType();
00365                         $attr['Unlimited'] = $item['activation_unlimited'] ? 1 : 0;
00366                         $attr['Position'] = $item['position'];
00367 
00368                         $this->xmlStartTag('Object',$attr);
00369                         $this->xmlElement('Title',null,$item['title']);
00370                         $this->xmlElement('Description',null,$item['description']);
00371                         $this->xmlElement('Start',null,$item['activation_start']);
00372                         $this->xmlElement('End',null,$item['activation_end']);
00373 
00374                         if($item['type'] == 'file')
00375                         {
00376                                 $this->xmlElement('FileType',null,$tmp_obj->getFileType());
00377                         }
00378 
00379                         $this->__buildObject($item['child']);
00380                         
00381                         $this->xmlEndTag('Object');
00382 
00383                         unset($tmp_obj);
00384                 }
00385         }
00386 
00387         function __buildFooter()
00388         {
00389                 $this->xmlEndTag('Course');
00390         }
00391 
00397         function setAttachUsers ($value) {
00398                 $this->attach_users = $value ? true : false;
00399         }
00400 }
00401 
00402 
00403 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1