ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjStudyProgrammeReferenceListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected bool $conditions_ok;
24 protected ?int $ref_obj_id = null;
25 protected ?int $ref_ref_id = null;
26 protected bool $deleted = false;
29
30 public function __construct()
31 {
32 global $DIC;
33 $this->request_wrapper = $DIC->http()->wrapper()->query();
34 $this->refinery = $DIC->refinery();
35
37 }
38
39 public function getIconImageType(): string
40 {
41 return 'prgr';
42 }
43
47 public function getTypeIcon(): string
48 {
50 return ilObject::_getIcon(
51 $ref_obj_id,
52 'small'
53 );
54 }
55
56 public function getCommandId(): int
57 {
58 return $this->ref_ref_id;
59 }
60
64 public function insertTimingsCommand(): void
65 {
66 }
67
68 public function init(): void
69 {
70 $this->static_link_enabled = false;
71 $this->delete_enabled = true;
72 $this->cut_enabled = false;
73 $this->info_screen_enabled = true;
74 $this->copy_enabled = true;
75 $this->subscribe_enabled = false;
76 $this->link_enabled = false;
77
78 $this->type = "prgr";
79 $this->gui_class_name = "ilobjstudyprogrammegui";
80
81 $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
82 if ($this->substitutions->isActive()) {
83 $this->substitutions_enabled = true;
84 }
85 }
86
91 public function initItem(
92 int $ref_id,
93 int $obj_id,
94 string $type,
95 string $title = "",
96 string $description = ""
97 ): void {
98 $this->ref_ref_id = $ref_id;
99 $this->ref_obj_id = $obj_id;
100
102
103 $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
104 $target_ref_id = current($target_ref_ids);
106 $target_description = ilObject::_lookupDescription($target_obj_id);
107
108 $this->deleted = $this->tree->isDeleted($target_ref_id);
109
110 $this->conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($target_ref_id, $target_obj_id);
111
112 parent::initItem($target_ref_id, $target_obj_id, 'prg', $target_title, $target_description);
113 $this->setTitle($target_title);
114 $this->commands = ilObjStudyProgrammeReferenceAccess::_getCommands($this->ref_ref_id);
115
116 if ($this->access->checkAccess('write', '', $this->ref_ref_id) || $this->deleted) {
117 $this->info_screen_enabled = false;
118 } else {
119 $this->info_screen_enabled = true;
120 }
121 $this->cut_enabled = $this->getParentType() !== 'prg';
122 }
123
124 public function getProperties(): array
125 {
126 $props = parent::getProperties();
127
128 // offline
129 if ($this->deleted) {
130 $props[] = array("alert" => true, "property" => $this->lng->txt("status"),
131 "value" => $this->lng->txt("reference_deleted"));
132 }
133
134 return $props ?: array();
135 }
136
137 public function checkCommandAccess(
138 string $permission,
139 string $cmd,
140 int $ref_id,
141 string $type,
142 ?int $obj_id = null
143 ): bool {
144 // Check edit reference against reference edit permission
145 switch ($cmd) {
146 case 'editReference':
147 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
148 }
149
150 return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), 'prgr', null);
151 }
152
160 public function getCommandLink($a_cmd): string
161 {
162 $ref_id = $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int());
163 switch ($a_cmd) {
164 case 'editReference':
165 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
166 $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
167 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
168 return $cmd_link;
169
170 default:
171 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
172 $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
173 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
174 return $cmd_link;
175 }
176 }
177
178 public function getListItemHTML(
179 int $a_ref_id,
180 int $a_obj_id,
181 string $a_title,
182 string $a_description,
183 bool $a_use_asynch = false,
184 bool $a_get_asynch_commands = false,
185 string $a_asynch_url = "",
186 int $a_context = self::CONTEXT_REPOSITORY
187 ): string {
188 $target_obj_id = ilContainerReference::_lookupTargetId($a_obj_id);
189 if ($this->getCheckboxStatus() && $this->hasAssignments($target_obj_id)) {
190 $this->setAdditionalInformation($this->lng->txt("prg_can_not_manage_in_repo"));
191 $this->enableCheckbox(false);
192 } else {
193 $this->setAdditionalInformation(null);
194 }
195
196 $this->reference_ref_id = $a_ref_id;
197
199 $a_ref_id,
200 $a_obj_id,
201 $a_title,
202 $a_description,
203 $a_use_asynch,
204 $a_get_asynch_commands,
205 $a_asynch_url
206 );
207 }
208
209 private function hasAssignments(int $obj_id): bool
210 {
211 $assignment_repo = ilStudyProgrammeDIC::dic()['repo.assignment'];
212 $target_obj_id = ilContainerReference::_lookupTargetId($obj_id);
213 return $assignment_repo->countAllForNodeIsContained($target_obj_id) > 0;
214 }
215
216 private function getParentType(): string
217 {
218 $parent_data = $this->tree->getParentNodeData($this->getCommandId());
219 return $parent_data["type"];
220 }
221
222}
Builds data types.
Definition: Factory.php:36
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)
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
initialize new item Group reference inits the group item
getListItemHTML(int $a_ref_id, int $a_obj_id, string $a_title, string $a_description, bool $a_use_asynch=false, bool $a_get_asynch_commands=false, string $a_asynch_url="", int $a_context=self::CONTEXT_REPOSITORY)
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
static _getCommands()
get commands
getListItemHTML(int $ref_id, int $obj_id, string $title, string $description)
Get all item information (title, commands, description) in HTML.
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)
Interface RequestWrapper.
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26