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