ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCategoryReferenceListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
28 protected ?int $reference_obj_id = null;
29 protected int $reference_ref_id;
30 protected bool $deleted = false;
32
33 public function __construct()
34 {
36 global $DIC;
37
38 $this->access = $DIC->access();
39 $this->tree = $DIC->repositoryTree();
40 $this->lng = $DIC->language();
41 $this->user = $DIC->user();
42 $this->ctrl = $DIC->ctrl();
44 $this->cont_ref_request = $DIC
45 ->containerReference()
46 ->internal()
47 ->gui()
48 ->standardRequest();
49 }
50
51 public function getIconImageType(): string
52 {
53 return 'catr';
54 }
55
56 public function getTypeIcon(): string
57 {
59 return ilObject::_getIcon(
60 $reference_obj_id,
61 'small'
62 );
63 }
64
65
66 public function getCommandId(): int
67 {
69 }
70
71 public function insertTimingsCommand(): void
72 {
73 }
74
75 public function init(): void
76 {
77 $this->copy_enabled = true;
78 $this->static_link_enabled = false;
79 $this->delete_enabled = true;
80 $this->cut_enabled = true;
81 $this->subscribe_enabled = true;
82 $this->link_enabled = false;
83 $this->info_screen_enabled = true;
84 $this->type = 'catr';
85 $this->gui_class_name = "ilobjcategorygui";
86
87 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
88 if ($this->substitutions->isActive()) {
89 $this->substitutions_enabled = true;
90 }
91 }
92
93 public function initItem(
94 int $ref_id,
95 int $obj_id,
96 string $type,
97 string $title = "",
98 string $description = ""
99 ): void {
100 $ilAccess = $this->access;
102
103 $this->reference_ref_id = $ref_id;
104 $this->reference_obj_id = $obj_id;
105
107
108 $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
109 $target_ref_id = current($target_ref_ids);
111 $target_description = ilObject::_lookupDescription($target_obj_id);
112
113 $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
114
115 parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
116
117 // general commands array
118 $this->commands = ilObjCategoryReferenceAccess::_getCommands($this->reference_ref_id);
119
120 if ($this->deleted || $ilAccess->checkAccess('write', '', $this->reference_ref_id)) {
121 $this->info_screen_enabled = false;
122 } else {
123 $this->info_screen_enabled = true;
124 }
125 }
126
127
128 public function getProperties(): array
129 {
131 $tree = $this->tree;
132
133 $props = parent::getProperties();
134
135 // offline
136 if ($tree->isDeleted($this->ref_id)) {
137 $props[] = [
138 "alert" => true, "property" => $lng->txt("status"),
139 "value" => $lng->txt("reference_deleted")
140 ];
141 }
142
143 return $props;
144 }
145
146 public function checkCommandAccess(
147 string $permission,
148 string $cmd,
149 int $ref_id,
150 string $type,
151 ?int $obj_id = null
152 ): bool {
153 // Check edit reference against reference edit permission
154 switch ($cmd) {
155 case 'editReference':
156 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
157 }
158
159 switch ($permission) {
160 case 'copy':
161 case 'delete':
162 // check against target ref_id
163 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
164
165 default:
166 // check against reference
167 return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
168 }
169 }
170
171 public function getCommandLink(string $cmd): string
172 {
173 $ilCtrl = $this->ctrl;
174
175 switch ($cmd) {
176 case 'editReference':
177 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
178 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
179 $ilCtrl->setParameterByClass(
180 "ilrepositorygui",
181 "ref_id",
182 $this->cont_ref_request->getRefId()
183 );
184 return $cmd_link;
185
186 default:
187 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
188 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
189 $ilCtrl->setParameterByClass(
190 "ilrepositorygui",
191 "ref_id",
192 $this->cont_ref_request->getRefId()
193 );
194 return $cmd_link;
195 }
196 }
197}
static _getInstanceByObjectType(string $a_type)
static _lookupTitle(int $obj_id)
static _lookupTargetId(int $a_obj_id)
Class ilObjCategoryListGUI.
getTypeIcon()
Get object type specific type icon.
insertTimingsCommand()
ks, 23 OCT 2023: This function is badly named and it already was before the changes made today.
getCommandId()
get command id Normally the ref id.
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 url.
static _getCommands()
get commands
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupDescription(int $obj_id)
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26