ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 getCommandId(): int
57 {
59 }
60
61 public function insertTimingsCommand(): void
62 {
63 }
64
65 public function init(): void
66 {
67 $this->copy_enabled = true;
68 $this->static_link_enabled = false;
69 $this->delete_enabled = true;
70 $this->cut_enabled = true;
71 $this->subscribe_enabled = true;
72 $this->link_enabled = false;
73 $this->info_screen_enabled = true;
74 $this->type = 'catr';
75 $this->gui_class_name = "ilobjcategorygui";
76
77 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
78 if ($this->substitutions->isActive()) {
79 $this->substitutions_enabled = true;
80 }
81 }
82
83 public function initItem(
84 int $ref_id,
85 int $obj_id,
86 string $type,
87 string $title = "",
88 string $description = ""
89 ): void {
90 $ilAccess = $this->access;
92
93 $this->reference_ref_id = $ref_id;
94 $this->reference_obj_id = $obj_id;
95
97
98 $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
99 $target_ref_id = current($target_ref_ids);
101 $target_description = ilObject::_lookupDescription($target_obj_id);
102
103 $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
104
105 parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
106
107 // general commands array
108 $this->commands = ilObjCategoryReferenceAccess::_getCommands($this->reference_ref_id);
109
110 if ($this->deleted || $ilAccess->checkAccess('write', '', $this->reference_ref_id)) {
111 $this->info_screen_enabled = false;
112 } else {
113 $this->info_screen_enabled = true;
114 }
115 }
116
117
118 public function getProperties(): array
119 {
121 $tree = $this->tree;
122
123 $props = parent::getProperties();
124
125 // offline
126 if ($tree->isDeleted($this->ref_id)) {
127 $props[] = [
128 "alert" => true, "property" => $lng->txt("status"),
129 "value" => $lng->txt("reference_deleted")
130 ];
131 }
132
133 return $props;
134 }
135
136 public function checkCommandAccess(
137 string $permission,
138 string $cmd,
139 int $ref_id,
140 string $type,
141 ?int $obj_id = null
142 ): bool {
143 // Check edit reference against reference edit permission
144 switch ($cmd) {
145 case 'editReference':
146 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
147 }
148
149 switch ($permission) {
150 case 'copy':
151 case 'delete':
152 // check against target ref_id
153 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
154
155 default:
156 // check against reference
157 return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
158 }
159 }
160
161 public function getCommandLink(string $cmd): string
162 {
163 $ilCtrl = $this->ctrl;
164
165 switch ($cmd) {
166 case 'editReference':
167 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
168 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
169 $ilCtrl->setParameterByClass(
170 "ilrepositorygui",
171 "ref_id",
172 $this->cont_ref_request->getRefId()
173 );
174 return $cmd_link;
175
176 default:
177 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
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 }
187}
static _getInstanceByObjectType(string $a_type)
static _lookupTitle(int $obj_id)
static _lookupTargetId(int $a_obj_id)
Class ilObjCategoryListGUI.
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 _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.
$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