ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSoapRoleObjectXMLWriter.php
Go to the documentation of this file.
1<?php
2
30{
31 public string $xml = '';
32 private array $roles = [];
33 private string $role_type = '';
34
35 public function __construct()
36 {
37 global $DIC;
38
39 $ilUser = $DIC->user();
40
42 }
43
44 public function setObjects(array $roles): void
45 {
46 $this->roles = $roles;
47 }
48
49 public function setType(string $type): void
50 {
51 $this->role_type = $type;
52 }
53
54 public function start(): bool
55 {
56 global $DIC;
57
58 $rbacreview = $DIC['rbacreview'];
59 if ($this->roles === []) {
60 return false;
61 }
62
63 $this->buildHeader();
64
65 foreach ($this->roles as $role) {
66 // if role type is not empty and does not match, then continue;
67 if (!empty($this->role_type) && strcasecmp($this->role_type, $role["role_type"]) !== 0) {
68 continue;
69 }
70 if ($rbacreview->isRoleDeleted($role["obj_id"])) {
71 continue;
72 }
73
74 $attrs = [
75 'role_type' => ucwords($role["role_type"]),
76 'id' => "il_" . IL_INST_ID . "_role_" . $role["obj_id"]
77 ];
78
79 $this->xmlStartTag("Role", $attrs);
80 $this->xmlElement('Title', null, $role["title"]);
81 $this->xmlElement('Description', null, $role["description"]);
82 $this->xmlElement('Translation', null, ilObjRole::_getTranslation($role["title"]));
83
84 if ($ref_id = ilUtil::__extractRefId($role["title"])) {
86
87 if (is_object($ownerObj)) {
88 $attrs = [
89 "obj_id" => implode(
90 '_',
91 [
92 "il",
94 $ownerObj->getType(),
95 $ownerObj->getId()
96 ]
97 ),
98 "ref_id" => $ownerObj->getRefId(),
99 "type" => $ownerObj->getType()
100 ];
101 $this->xmlStartTag('AssignedObject', $attrs);
102 $this->xmlElement('Title', null, $ownerObj->getTitle());
103 $this->xmlElement('Description', null, $ownerObj->getDescription());
105 $this->xmlEndTag('AssignedObject');
106 }
107 }
108 $this->xmlEndTag("Role");
109 }
110 $this->buildFooter();
111 return true;
112 }
113
114 public function getXML(): string
115 {
116 return $this->xmlDumpMem(false);
117 }
118
119 private function buildHeader(): void
120 {
121 $this->xmlSetDtdDef("<!DOCTYPE Roles PUBLIC \"-//ILIAS//DTD ILIAS Roles//EN\" \"" . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_role_object_3_10.dtd\">");
122 $this->xmlSetGenCmt("Roles information of ilias system");
123 $this->xmlHeader();
124 $this->xmlStartTag('Roles');
125 }
126
127 private function buildFooter(): void
128 {
129 $this->xmlEndTag('Roles');
130 }
131}
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26