ILIAS  release_8 Revision v8.24
class.ilObjCourseReferenceListGUI.php
Go to the documentation of this file.
1<?php
2
19include_once "./Modules/Course/classes/class.ilObjCourseListGUI.php";
20
30{
31 protected ?int $reference_obj_id = null;
32 protected int $reference_ref_id;
33 protected bool $deleted = false;
34
41 public function __construct()
42 {
44 }
45
46 public function getIconImageType(): string
47 {
48 return 'crsr';
49 }
50
54 public function getTypeIcon(): string
55 {
57 return ilObject::_getIcon(
58 $reference_obj_id,
59 'small'
60 );
61 }
62
63
71 public function getCommandId(): int
72 {
74 }
75
79 public function insertTimingsCommand(): void
80 {
81 return;
82 }
83
87 public function init(): void
88 {
89 $this->copy_enabled = true;
90 $this->static_link_enabled = false;
91 $this->delete_enabled = true;
92 $this->cut_enabled = true;
93 $this->subscribe_enabled = true;
94 $this->link_enabled = false;
95 $this->info_screen_enabled = true;
96 $this->type = "crs";
97 $this->gui_class_name = "ilobjcoursegui";
98
99 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
100 if ($this->substitutions->isActive()) {
101 $this->substitutions_enabled = true;
102 }
103 }
104
105
106
110 public function initItem(
111 int $ref_id,
112 int $obj_id,
113 string $type,
114 string $title = "",
115 string $description = ""
116 ): void {
117 global $ilBench,$ilAccess,$tree;
118
119 $this->reference_ref_id = $ref_id;
120 $this->reference_obj_id = $obj_id;
121
122
123 include_once('./Services/ContainerReference/classes/class.ilContainerReference.php');
125
126 $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
127 $target_ref_id = current($target_ref_ids);
129 $target_description = ilObject::_lookupDescription($target_obj_id);
130
131 $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
132
133 $ilBench->start("ilObjCourseListGUI", "1000_checkAllConditions");
134 $this->conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget((int) $target_ref_id, (int) $target_obj_id);
135 $ilBench->stop("ilObjCourseListGUI", "1000_checkAllConditions");
136
137
138 parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
139
140 // general commands array
141 include_once('./Modules/CourseReference/classes/class.ilObjCourseReferenceAccess.php');
142 $this->commands = ilObjCourseReferenceAccess::_getCommands($this->reference_ref_id);
143
144 if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) {
145 $this->info_screen_enabled = false;
146 } else {
147 $this->info_screen_enabled = true;
148 }
149 }
150
151 public function getProperties(): array
152 {
153 global $lng,$ilUser,$tree;
154
155 $props = parent::getProperties();
156
157 // offline
158 if ($this->deleted) {
159 $props[] = array("alert" => true, "property" => $lng->txt("status"),
160 "value" => $lng->txt("reference_deleted"));
161 }
162
163 return $props ? $props : array();
164 }
165
171 public function checkCommandAccess(
172 string $permission,
173 string $cmd,
174 int $ref_id,
175 string $type,
176 ?int $obj_id = null
177 ): bool {
178 // Check edit reference against reference edit permission
179 switch ($cmd) {
180 case 'editReference':
181 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
182 }
183
184 switch ($permission) {
185 case 'copy':
186 case 'delete':
187 // check against target ref_id
188 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
189
190 default:
191 // check against reference
192 return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
193 }
194 }
195
202 public function getCommandLink(string $cmd): string
203 {
204 global $ilCtrl;
205
206 switch ($cmd) {
207 case 'editReference':
208 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
209 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
210 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? null);
211 return $cmd_link;
212
213 default:
214 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
215 $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
216 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? null);
217 return $cmd_link;
218 }
219 }
220}
static _getInstanceByObjectType(string $a_type)
static _checkAllConditionsOfTarget(int $a_target_ref_id, int $a_target_id, string $a_target_type="", int $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
static _lookupTitle(int $obj_id)
static _lookupTargetId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getIconImageType()
Returns the icon image type.
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
getTypeIcon()
Get object type specific type icon.
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
initialize new item (is called by getItemHTML())
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.
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$_GET['client_id']
Definition: saml1-acs.php:21
$lng