ILIAS  trunk Revision v12.0_alpha-1338-g8f7e531aa3c
class.ilObjGroupReferenceListGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected ?int $reference_obj_id = null;
28 protected int $reference_ref_id;
29 protected bool $deleted = false;
30
36 public function __construct()
37 {
39 }
40
44 public function getIconImageType(): string
45 {
46 return 'grpr';
47 }
48
49
55 public function getCommandId(): int
56 {
58 }
59
63 public function insertTimingsCommand(): void
64 {
65 return;
66 }
67
68
69
73 public function init(): void
74 {
75 $this->copy_enabled = true;
76 $this->static_link_enabled = false;
77 $this->delete_enabled = true;
78 $this->cut_enabled = true;
79 $this->subscribe_enabled = true;
80 $this->link_enabled = false;
81 $this->info_screen_enabled = true;
82 $this->type = 'grpr';
83 $this->gui_class_name = "ilobjgroupgui";
84
85 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
86 if ($this->substitutions->isActive()) {
87 $this->substitutions_enabled = true;
88 }
89 }
90
91
92
96 public function initItem(
97 int $ref_id,
98 int $obj_id,
99 string $type,
100 string $title = "",
101 string $description = ""
102 ): void {
103 global $DIC;
104
105 $ilAccess = $DIC['ilAccess'];
106 $tree = $DIC['tree'];
107
108 $this->reference_ref_id = $ref_id;
109 $this->reference_obj_id = $obj_id;
110
111
113
114 $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
115 $target_ref_id = current($target_ref_ids);
117 $target_description = ilObject::_lookupDescription($target_obj_id);
118
119 $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
120
121 parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
122
123 // general commands array
124 $this->commands = ilObjGroupReferenceAccess::_getCommands($this->reference_ref_id);
125
126 if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) {
127 $this->info_screen_enabled = false;
128 } else {
129 $this->info_screen_enabled = true;
130 }
131 }
132
133 public function getProperties(): array
134 {
135 global $DIC;
136
137 $lng = $DIC['lng'];
138 $ilUser = $DIC['ilUser'];
139 $tree = $DIC['tree'];
140
141 $props = parent::getProperties();
142
143 // offline
144 if ($this->deleted) {
145 $props[] = array("alert" => true, "property" => $lng->txt("status"),
146 "value" => $lng->txt("reference_deleted"));
147 }
148
149 return $props ? $props : array();
150 }
151
157 public function checkCommandAccess(
158 string $permission,
159 string $cmd,
160 int $ref_id,
161 string $type,
162 ?int $obj_id = null
163 ): bool {
164 // Check edit reference against reference edit permission
165 switch ($cmd) {
166 case 'editReference':
167 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
168 }
169
170 switch ($permission) {
171 case 'copy':
172 case 'delete':
173 // check against target ref_id
174 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
175
176 default:
177 // check against reference
178 return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
179 }
180 }
181
187 public function getCommandLink(string $cmd): string
188 {
189 global $DIC;
190
191 $ilCtrl = $DIC['ilCtrl'];
192
193 switch ($cmd) {
194 case 'editReference':
195 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
196 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
197 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? 0);
198 return $cmd_link;
199
200 default:
201 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
202 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
203 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? 0);
204 return $cmd_link;
205 }
206 }
207}
static _getInstanceByObjectType(string $a_type)
static _lookupTitle(int $obj_id)
static _lookupTargetId(int $a_obj_id)
Class ilObjGroupListGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
initialize new item (is called by getItemHTML())
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
getCommandLink(string $cmd)
get command link
static _getCommands()
get commands
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupDescription(int $obj_id)
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
$_GET['cmd']
Definition: lti.php:26
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:26
global $DIC
Definition: shib_login.php:26