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

webservice/soap/classes/class.ilObjectXMLWriter.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 ilObjectXMLWriter extends ilXmlWriter
00041 {
00042         var $ilias;
00043 
00044         var $xml;
00045         var $enable_operations = false;
00046         var $objects = array();
00047         var $user_id = 0;
00048 
00056         function ilObjectXMLWriter()
00057         {
00058                 global $ilias,$ilUser;
00059 
00060                 parent::ilXmlWriter();
00061 
00062                 $this->ilias =& $ilias;
00063                 $this->user_id = $ilUser->getId();
00064         }
00065 
00066         function setUserId($a_id)
00067         {
00068                 $this->user_id = $a_id;
00069         }
00070         function getUserId()
00071         {
00072                 return $this->user_id;
00073         }
00074 
00075         function enableOperations($a_status)
00076         {
00077                 $this->enable_operations = $a_status;
00078                 
00079                 return true;
00080         }
00081 
00082         function enabledOperations()
00083         {
00084                 return $this->enable_operations;
00085         }
00086 
00087         function setObjects($objects)
00088         {
00089                 $this->objects = $objects;
00090         }
00091 
00092         function __getObjects()
00093         {
00094                 return $this->objects ? $this->objects : array();
00095         }
00096 
00097         function start()
00098         {
00099                 if(!count($objects = $this->__getObjects()))
00100                 {
00101                         return false;
00102                 }
00103 
00104                 $this->__buildHeader();
00105 
00106                 foreach($this->__getObjects() as $object)
00107                 {
00108                         $this->__appendObject($object);
00109                 }
00110                 $this->__buildFooter();
00111 
00112                 return true;
00113         }
00114 
00115         function getXML()
00116         {
00117                 return $this->xmlDumpMem();
00118         }
00119 
00120 
00121         // PRIVATE
00122         function __appendObject(&$object)
00123         {
00124                 $attrs = array('type' => $object->getType(),
00125                                            'obj_id' => $object->getId());
00126 
00127                 $this->xmlStartTag('Object',$attrs);
00128                 $this->xmlElement('Title',null,$object->getTitle());
00129                 $this->xmlElement('Description',null,$object->getDescription());
00130                 $this->xmlElement('Owner',null,$object->getOwner());
00131                 $this->xmlElement('CreateDate',null,$object->getCreateDate());
00132                 $this->xmlElement('LastUpdate',null,$object->getLastUpdateDate());
00133                 $this->xmlElement('ImportId',null,$object->getImportId());
00134                 
00135                 foreach(ilObject::_getAllReferences($object->getId()) as $ref_id)
00136                 {
00137                         $attr = array('ref_id' => $ref_id);
00138                         $attr['accessInfo'] = $this->__getAccessInfo($object,$ref_id);
00139 
00140                         $this->xmlStartTag('References',$attr);
00141                         $this->__appendOperations($ref_id,$object->getType());
00142                         $this->xmlEndTag('References');
00143                 }
00144                 $this->xmlEndTag('Object');
00145         }
00146 
00147         function __appendOperations($a_ref_id,$a_type)
00148         {
00149                 global $ilAccess,$rbacreview;
00150 
00151                 if($this->enabledOperations())
00152                 {
00153                         foreach($rbacreview->getOperationsOnTypeString($a_type) as $ops_id)
00154                         {
00155                                 $operation = $rbacreview->getOperation($ops_id);
00156 
00157                                 if($ilAccess->checkAccessOfUser($this->getUserId(),$operation['operation'],'view',$a_ref_id))
00158                                 {
00159                                         $this->xmlElement('Operation',null,$operation['operation']);
00160                                 }
00161                         }
00162                 }
00163                 return true;
00164         }
00165         
00166 
00167         function __buildHeader()
00168         {
00169                 $this->xmlSetDtdDef("<!DOCTYPE Objects SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_object_0_1.dtd\">");
00170                 $this->xmlSetGenCmt("Export of ILIAS objects");
00171                 $this->xmlHeader();
00172 
00173                 $this->xmlStartTag("Objects");
00174 
00175                 return true;
00176         }
00177 
00178         function __buildFooter()
00179         {
00180                 $this->xmlEndTag('Objects');
00181         }
00182 
00183         function __getAccessInfo(&$object,$ref_id)
00184         {
00185                 global $ilAccess;
00186 
00187                 include_once 'Services/AccessControl/classes/class.ilAccessHandler.php';
00188 
00189                 $ilAccess->checkAccessOfUser($this->getUserId(),'read','view',$ref_id,$object->getType(),$object->getId());
00190 
00191                 if(!$info = $ilAccess->getInfo())
00192                 {
00193                         return 'granted';
00194                 }
00195                 else
00196                 {
00197                         return $info[0]['type'];
00198                 }
00199         }
00200 
00201 }
00202 
00203 
00204 ?>

Generated on Fri Dec 13 2013 11:58:04 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1