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(FALSE);
00118 }
00119
00120
00121
00122 function __appendObject(&$object)
00123 {
00124
00125 global $tree;
00126
00127 $id = $object->getId();
00128
00129 $attrs = array('type' => $object->getType(),
00130 'obj_id' => $id);
00131
00132 $this->xmlStartTag('Object',$attrs);
00133 $this->xmlElement('Title',null,$object->getTitle());
00134 $this->xmlElement('Description',null,$object->getDescription());
00135 $this->xmlElement('Owner',null,$object->getOwner());
00136 $this->xmlElement('CreateDate',null,$object->getCreateDate());
00137 $this->xmlElement('LastUpdate',null,$object->getLastUpdateDate());
00138 $this->xmlElement('ImportId',null,$object->getImportId());
00139
00140 foreach(ilObject::_getAllReferences($object->getId()) as $ref_id)
00141 {
00142 $attr = array('ref_id' => $ref_id,
00143 'parent_id'=> $tree->getParentId(intval($ref_id)));
00144 $attr['accessInfo'] = $this->__getAccessInfo($object,$ref_id);
00145
00146 $this->xmlStartTag('References',$attr);
00147 $this->__appendOperations($ref_id,$object->getType());
00148 $this->xmlEndTag('References');
00149 }
00150 $this->xmlEndTag('Object');
00151 }
00152
00153 function __appendOperations($a_ref_id,$a_type)
00154 {
00155 global $ilAccess,$rbacreview;
00156
00157 if($this->enabledOperations())
00158 {
00159 $ops = $rbacreview->getOperationsOnTypeString($a_type);
00160 if (is_array($ops))
00161 {
00162 foreach($ops as $ops_id)
00163 {
00164 $operation = $rbacreview->getOperation($ops_id);
00165
00166 if($ilAccess->checkAccessOfUser($this->getUserId(),$operation['operation'],'view',$a_ref_id))
00167 {
00168 $this->xmlElement('Operation',null,$operation['operation']);
00169 }
00170 }
00171 }
00172 }
00173 return true;
00174 }
00175
00176
00177 function __buildHeader()
00178 {
00179 $this->xmlSetDtdDef("<!DOCTYPE Objects PUBLIC \"-//ILIAS//DTD ILIAS Repositoryobjects//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_object_3_7.dtd\">");
00180 $this->xmlSetGenCmt("Export of ILIAS objects");
00181 $this->xmlHeader();
00182
00183 $this->xmlStartTag("Objects");
00184
00185 return true;
00186 }
00187
00188 function __buildFooter()
00189 {
00190 $this->xmlEndTag('Objects');
00191 }
00192
00193 function __getAccessInfo(&$object,$ref_id)
00194 {
00195 global $ilAccess;
00196
00197 include_once 'Services/AccessControl/classes/class.ilAccessHandler.php';
00198
00199 $ilAccess->checkAccessOfUser($this->getUserId(),'read','view',$ref_id,$object->getType(),$object->getId());
00200
00201 if(!$info = $ilAccess->getInfo())
00202 {
00203 return 'granted';
00204 }
00205 else
00206 {
00207 return $info[0]['type'];
00208 }
00209 }
00210
00211
00212 }
00213
00214
00215 ?>