Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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 ?>