ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjStudyProgrammeReferenceListGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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  {
49  $ref_obj_id = ilObject::_lookupObjId($this->getCommandId());
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 
101  $target_obj_id = ilContainerReference::_lookupTargetId($obj_id);
102 
103  $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
104  $target_ref_id = current($target_ref_ids);
105  $target_title = ilContainerReference::_lookupTitle($obj_id);
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  }
122 
123  public function getProperties(): array
124  {
125  $props = parent::getProperties();
126 
127  // offline
128  if ($this->deleted) {
129  $props[] = array("alert" => true, "property" => $this->lng->txt("status"),
130  "value" => $this->lng->txt("reference_deleted"));
131  }
132 
133  return $props ?: array();
134  }
135 
136  public function checkCommandAccess(
137  string $permission,
138  string $cmd,
139  int $ref_id,
140  string $type,
141  ?int $obj_id = null
142  ): bool {
143  // Check edit reference against reference edit permission
144  switch ($cmd) {
145  case 'editReference':
146  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), $type, $obj_id);
147  }
148 
149  return parent::checkCommandAccess($permission, $cmd, $this->getCommandId(), 'prgr', null);
150  }
151 
159  public function getCommandLink($a_cmd): string
160  {
161  $ref_id = $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int());
162  switch ($a_cmd) {
163  case 'editReference':
164  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
165  $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
166  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
167  return $cmd_link;
168 
169  default:
170  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
171  $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
172  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
173  return $cmd_link;
174  }
175  }
176 
177  public function getListItemHTML(
178  int $a_ref_id,
179  int $a_obj_id,
180  string $a_title,
181  string $a_description,
182  bool $a_use_asynch = false,
183  bool $a_get_asynch_commands = false,
184  string $a_asynch_url = "",
185  int $a_context = self::CONTEXT_REPOSITORY
186  ): string {
187  $target_obj_id = ilContainerReference::_lookupTargetId($a_obj_id);
188  $target_ref_id = current(ilObject::_getAllReferences($target_obj_id));
189  $prg = new ilObjStudyProgramme($target_ref_id);
190  $assignments = $prg->getAssignments();
191  if ($this->getCheckboxStatus() && count($assignments) > 0) {
192  $this->setAdditionalInformation($this->lng->txt("prg_can_not_manage_in_repo"));
193  $this->enableCheckbox(false);
194  } else {
195  $this->setAdditionalInformation(null);
196  }
198  $a_ref_id,
199  $a_obj_id,
200  $a_title,
201  $a_description,
202  $a_use_asynch,
203  $a_get_asynch_commands,
204  $a_asynch_url
205  );
206  }
207 }
static _lookupTitle(int $obj_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
setAdditionalInformation(?string $val)
initItem(int $ref_id, int $obj_id, string $type, string $title="", string $description="")
initialize new item Group reference inits the group item
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getCommands()
get commands
getListItemHTML(int $ref_id, int $obj_id, string $title, string $description, bool $use_async=false, bool $get_async_commands=false, string $async_url="")
Get all item information (title, commands, description) in HTML.
static _lookupDescription(int $obj_id)
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
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
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)
__construct(Container $dic, ilPlugin $plugin)
enableCheckbox(bool $status)
static _lookupTargetId(int $a_obj_id)
static _getInstanceByObjectType(string $a_type)