ILIAS  release_8 Revision v8.24
class.ilSoapRoleObjectXMLWriter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
16{
17 public string $xml = '';
18 private array $roles = [];
19 private string $role_type = '';
20
21 public function __construct()
22 {
23 global $DIC;
24
25 $ilUser = $DIC->user();
26
28 }
29
30 public function setObjects(array $roles) : void
31 {
32 $this->roles = $roles;
33 }
34
35 public function setType(string $type) : void
36 {
37 $this->role_type = $type;
38 }
39
40 public function start() : bool
41 {
42 global $DIC;
43
44 $rbacreview = $DIC['rbacreview'];
45 if ($this->roles === []) {
46 return false;
47 }
48
49 $this->buildHeader();
50
51 include_once './Services/AccessControl/classes/class.ilObjRole.php';
52 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
53
54 foreach ($this->roles as $role) {
55 // if role type is not empty and does not match, then continue;
56 if (!empty($this->role_type) && strcasecmp($this->role_type, $role["role_type"]) !== 0) {
57 continue;
58 }
59 if ($rbacreview->isRoleDeleted($role["obj_id"])) {
60 continue;
61 }
62
63 $attrs = [
64 'role_type' => ucwords($role["role_type"]),
65 'id' => "il_" . IL_INST_ID . "_role_" . $role["obj_id"]
66 ];
67
68 $this->xmlStartTag("Role", $attrs);
69 $this->xmlElement('Title', null, $role["title"]);
70 $this->xmlElement('Description', null, $role["description"]);
71 $this->xmlElement('Translation', null, ilObjRole::_getTranslation($role["title"]));
72
73 if ($ref_id = ilUtil::__extractRefId($role["title"])) {
75
76 if (is_object($ownerObj)) {
77 $attrs = [
78 "obj_id" => implode(
79 '_',
80 [
81 "il",
83 $ownerObj->getType(),
84 $ownerObj->getId()
85 ]
86 ),
87 "ref_id" => $ownerObj->getRefId(),
88 "type" => $ownerObj->getType()
89 ];
90 $this->xmlStartTag('AssignedObject', $attrs);
91 $this->xmlElement('Title', null, $ownerObj->getTitle());
92 $this->xmlElement('Description', null, $ownerObj->getDescription());
94 $this->xmlEndTag('AssignedObject');
95 }
96 }
97 $this->xmlEndTag("Role");
98 }
99 $this->buildFooter();
100 return true;
101 }
102
103 public function getXML() : string
104 {
105 return $this->xmlDumpMem(false);
106 }
107
108 private function buildHeader() : void
109 {
110 $this->xmlSetDtdDef("<!DOCTYPE Roles PUBLIC \"-//ILIAS//DTD ILIAS Roles//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_role_object_3_10.dtd\">");
111 $this->xmlSetGenCmt("Roles information of ilias system");
112 $this->xmlHeader();
113 $this->xmlStartTag('Roles');
114 }
115
116 private function buildFooter() : void
117 {
118 $this->xmlEndTag('Roles');
119 }
120}
static _getTranslation(string $a_role_title)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static appendPathToObject(ilXmlWriter $writer, int $refid)
XML writer class Class to simplify manual writing of xml documents.
static __extractRefId(string $role_title)
extract ref id from role title, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
xmlDumpMem(bool $format=true)
Returns xml document from memory.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type