ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjCourseReferenceListGUI.php
Go to the documentation of this file.
1 <?php
2 
19 include_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  {
56  $reference_obj_id = ilObject::_lookupObjId($this->getCommandId());
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 = 'crsr';
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 $DIC;
118 
119  $ilAccess = $DIC->access();
120  $tree = $DIC->repositoryTree();
121 
122  $this->reference_ref_id = $ref_id;
123  $this->reference_obj_id = $obj_id;
124 
125 
126  $target_obj_id = ilContainerReference::_lookupTargetId($obj_id);
127 
128  $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
129  $target_ref_id = current($target_ref_ids);
130  $target_title = ilContainerReference::_lookupTitle($obj_id);
131  $target_description = ilObject::_lookupDescription($target_obj_id);
132 
133  $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
134 
135  parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
136 
137  // general commands array
138  $this->commands = ilObjCourseReferenceAccess::_getCommands($this->reference_ref_id);
139 
140  if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) {
141  $this->info_screen_enabled = false;
142  } else {
143  $this->info_screen_enabled = true;
144  }
145  }
146 
147  public function getProperties(): array
148  {
149  global $lng,$ilUser,$tree;
150 
151  $props = parent::getProperties();
152 
153  // offline
154  if ($this->deleted) {
155  $props[] = array("alert" => true, "property" => $lng->txt("status"),
156  "value" => $lng->txt("reference_deleted"));
157  }
158 
159  return $props ? $props : array();
160  }
161 
167  public function checkCommandAccess(
168  string $permission,
169  string $cmd,
170  int $ref_id,
171  string $type,
172  ?int $obj_id = null
173  ): bool {
174  // Check edit reference against reference edit permission
175  switch ($cmd) {
176  case 'editReference':
177  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
178  }
179 
180  switch ($permission) {
181  case 'copy':
182  case 'delete':
183  // check against target ref_id
184  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
185 
186  default:
187  // check against reference
188  return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
189  }
190  }
191 
198  public function getCommandLink(string $cmd): string
199  {
200  global $ilCtrl;
201 
202  switch ($cmd) {
203  case 'editReference':
204  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
205  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
206  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? null);
207  return $cmd_link;
208 
209  default:
210  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
211  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
212  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? null);
213  return $cmd_link;
214  }
215  }
216 }
$_GET["client_id"]
Definition: webdav.php:30
static _lookupTitle(int $obj_id)
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
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
static _getCommands()
get commands
__construct(VocabulariesInterface $vocabularies)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupDescription(int $obj_id)
getCommandLink(string $cmd)
get command link
static _lookupTargetId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
static _getInstanceByObjectType(string $a_type)