ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 
12 {
13  protected ?int $reference_obj_id = null;
14  protected int $reference_ref_id;
15  protected bool $deleted = false;
16 
22  public function __construct()
23  {
25  }
26 
30  public function getIconImageType(): string
31  {
32  return 'grpr';
33  }
34 
38  public function getTypeIcon(): string
39  {
40  $reference_obj_id = ilObject::_lookupObjId($this->getCommandId());
41  return ilObject::_getIcon(
42  $reference_obj_id,
43  'small'
44  );
45  }
46 
47 
53  public function getCommandId(): int
54  {
56  }
57 
61  public function insertTimingsCommand(): void
62  {
63  return;
64  }
65 
66 
67 
71  public function init(): void
72  {
73  $this->copy_enabled = true;
74  $this->static_link_enabled = false;
75  $this->delete_enabled = true;
76  $this->cut_enabled = true;
77  $this->subscribe_enabled = true;
78  $this->link_enabled = false;
79  $this->info_screen_enabled = true;
80  $this->type = 'grpr';
81  $this->gui_class_name = "ilobjgroupgui";
82 
83  $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
84  if ($this->substitutions->isActive()) {
85  $this->substitutions_enabled = true;
86  }
87  }
88 
89 
90 
94  public function initItem(
95  int $ref_id,
96  int $obj_id,
97  string $type,
98  string $title = "",
99  string $description = ""
100  ): void {
101  global $DIC;
102 
103  $ilAccess = $DIC['ilAccess'];
104  $tree = $DIC['tree'];
105 
106  $this->reference_ref_id = $ref_id;
107  $this->reference_obj_id = $obj_id;
108 
109 
110  $target_obj_id = ilContainerReference::_lookupTargetId($obj_id);
111 
112  $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
113  $target_ref_id = current($target_ref_ids);
114  $target_title = ilContainerReference::_lookupTitle($obj_id);
115  $target_description = ilObject::_lookupDescription($target_obj_id);
116 
117  $this->deleted = !$target_ref_id || $tree->isDeleted($target_ref_id);
118 
119  parent::initItem((int) $target_ref_id, $target_obj_id, $type, $target_title, $target_description);
120 
121  // general commands array
122  $this->commands = ilObjGroupReferenceAccess::_getCommands($this->reference_ref_id);
123 
124  if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) {
125  $this->info_screen_enabled = false;
126  } else {
127  $this->info_screen_enabled = true;
128  }
129  }
130 
131  public function getProperties(): array
132  {
133  global $DIC;
134 
135  $lng = $DIC['lng'];
136  $ilUser = $DIC['ilUser'];
137  $tree = $DIC['tree'];
138 
139  $props = parent::getProperties();
140 
141  // offline
142  if ($this->deleted) {
143  $props[] = array("alert" => true, "property" => $lng->txt("status"),
144  "value" => $lng->txt("reference_deleted"));
145  }
146 
147  return $props ? $props : array();
148  }
149 
155  public function checkCommandAccess(
156  string $permission,
157  string $cmd,
158  int $ref_id,
159  string $type,
160  ?int $obj_id = null
161  ): bool {
162  // Check edit reference against reference edit permission
163  switch ($cmd) {
164  case 'editReference':
165  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
166  }
167 
168  switch ($permission) {
169  case 'copy':
170  case 'delete':
171  // check against target ref_id
172  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
173 
174  default:
175  // check against reference
176  return parent::checkCommandAccess($permission, $cmd, $ref_id, $type, $obj_id);
177  }
178  }
179 
185  public function getCommandLink(string $cmd): string
186  {
187  global $DIC;
188 
189  $ilCtrl = $DIC['ilCtrl'];
190 
191  switch ($cmd) {
192  case 'editReference':
193  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
194  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
195  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? 0);
196  return $cmd_link;
197 
198  default:
199  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
200  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
201  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"] ?? 0);
202  return $cmd_link;
203  }
204  }
205 }
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)
static _getCommands()
get commands
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
global $DIC
Definition: shib_login.php:25
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
static _lookupDescription(int $obj_id)
$_GET['cmd']
Definition: lti.php:26
insertTimingsCommand()
no activation for links
__construct(Container $dic, ilPlugin $plugin)
static _lookupTargetId(int $a_obj_id)
static _getInstanceByObjectType(string $a_type)