ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjGroupReferenceListGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./Modules/Group/classes/class.ilObjGroupListGUI.php";
6 
14 {
15  protected ?int $reference_obj_id = null;
16  protected int $reference_ref_id;
17  protected bool $deleted = false;
18 
24  public function __construct()
25  {
27  }
28 
32  public function getIconImageType(): string
33  {
34  return 'grpr';
35  }
36 
40  public function getTypeIcon(): string
41  {
42  $reference_obj_id = ilObject::_lookupObjId($this->getCommandId());
43  return ilObject::_getIcon(
44  $reference_obj_id,
45  'small'
46  );
47  }
48 
49 
55  public function getCommandId(): int
56  {
58  }
59 
63  public function insertTimingsCommand(): void
64  {
65  return;
66  }
67 
68 
69 
73  public function init(): void
74  {
75  $this->copy_enabled = true;
76  $this->static_link_enabled = false;
77  $this->delete_enabled = true;
78  $this->cut_enabled = true;
79  $this->subscribe_enabled = true;
80  $this->link_enabled = false;
81  $this->info_screen_enabled = true;
82  $this->type = 'grpr';
83  $this->gui_class_name = "ilobjgroupgui";
84 
85  $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
86  if ($this->substitutions->isActive()) {
87  $this->substitutions_enabled = true;
88  }
89  }
90 
91 
92 
96  public function initItem(
97  int $ref_id,
98  int $obj_id,
99  string $type,
100  string $title = "",
101  string $description = ""
102  ): void {
103  global $DIC;
104 
105  $ilAccess = $DIC['ilAccess'];
106  $tree = $DIC['tree'];
107 
108  $this->reference_ref_id = $ref_id;
109  $this->reference_obj_id = $obj_id;
110 
111 
112  include_once('./Services/ContainerReference/classes/class.ilContainerReference.php');
113  $target_obj_id = ilContainerReference::_lookupTargetId($obj_id);
114 
115  $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
116  $target_ref_id = current($target_ref_ids);
117  $target_title = ilContainerReference::_lookupTitle($obj_id);
118  $target_description = ilObject::_lookupDescription($target_obj_id);
119 
120  $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
121 
122  parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
123 
124  // general commands array
125  include_once('./Modules/GroupReference/classes/class.ilObjGroupReferenceAccess.php');
126  $this->commands = ilObjGroupReferenceAccess::_getCommands($this->reference_ref_id);
127 
128  if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) {
129  $this->info_screen_enabled = false;
130  } else {
131  $this->info_screen_enabled = true;
132  }
133  }
134 
135  public function getProperties(): array
136  {
137  global $DIC;
138 
139  $lng = $DIC['lng'];
140  $ilUser = $DIC['ilUser'];
141  $tree = $DIC['tree'];
142 
143  $props = parent::getProperties();
144 
145  // offline
146  if ($this->deleted) {
147  $props[] = array("alert" => true, "property" => $lng->txt("status"),
148  "value" => $lng->txt("reference_deleted"));
149  }
150 
151  return $props ? $props : array();
152  }
153 
159  public function checkCommandAccess(
160  string $permission,
161  string $cmd,
162  int $ref_id,
163  string $type,
164  ?int $obj_id = null
165  ): bool {
166  // Check edit reference against reference edit permission
167  switch ($cmd) {
168  case 'editReference':
169  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
170  }
171 
172  switch ($permission) {
173  case 'copy':
174  case 'delete':
175  // check against target ref_id
176  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
177 
178  default:
179  // check against reference
180  return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
181  }
182  }
183 
189  public function getCommandLink(string $cmd): string
190  {
191  global $DIC;
192 
193  $ilCtrl = $DIC['ilCtrl'];
194 
195  switch ($cmd) {
196  case 'editReference':
197  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
198  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
199  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? 0);
200  return $cmd_link;
201 
202  default:
203  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
204  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
205  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? 0);
206  return $cmd_link;
207  }
208  }
209 }
$_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.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
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.
getCommandLink(string $cmd)
get command link
Class ilObjGroupListGUI.
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
static _getCommands()
get commands
__construct(VocabulariesInterface $vocabularies)
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
static _lookupDescription(int $obj_id)
insertTimingsCommand()
no activation for links
static _lookupTargetId(int $a_obj_id)
static _getInstanceByObjectType(string $a_type)