ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCourseReferenceGUI.php
Go to the documentation of this file.
1<?php
2
27{
28 private ?ilLogger $logger = null;
29
30 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
31 {
32 global $DIC;
33
34 $this->target_type = 'crs';
35 $this->reference_type = 'crsr';
36 $this->logger = $DIC->logger()->crsr();
37
38 parent::__construct($a_data, $a_id, true, false);
39
40 $this->lng->loadLanguageModule('crs');
41 }
42
47 public function executeCommand(): void
48 {
49 global $DIC;
50
51 $user = $DIC->user();
52
53 $next_class = $this->ctrl->getNextClass($this);
54 switch ($next_class) {
55 case 'illearningprogressgui':
56 $this->prepareOutput();
57 $this->tabs_gui->activateTab('learning_progress');
58 $lp_gui = new \ilLearningProgressGUI(
60 $this->object->getRefId(),
61 $user->getId()
62 );
63 $this->ctrl->forwardCommand($lp_gui);
64 return;
65 }
66 parent::executeCommand();
67 }
68
73 protected function getTabs(): void
74 {
75 global $DIC;
76
77 $help = $DIC->help();
78 $help->setScreenIdComponent($this->getReferenceType());
79
80 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
81 $this->tabs_gui->addTab(
82 'settings',
83 $this->lng->txt('settings'),
84 $this->ctrl->getLinkTarget($this, 'edit')
85 );
86 }
87
88 if (ilLearningProgressAccess::checkAccess($this->object->getRefId(), false)) {
89 $this->tabs_gui->addTab(
90 'learning_progress',
91 $this->lng->txt('learning_progress'),
92 $this->ctrl->getLinkTargetByClass(
93 [
94 ilObjCourseReferenceGUI::class,
95 ilLearningProgressGUI::class
96 ],
97 ''
98 )
99 );
100 }
101 if ($this->access->checkAccess('edit_permission', '', $this->object->getRefId())) {
102 $this->tabs_gui->addTab(
103 'perm_settings',
104 $this->lng->txt('perm_settings'),
105 $this->ctrl->getLinkTargetByClass(
106 [
107 ilObjCourseReferenceGUI::class,
108 ilPermissionGUI::class
109 ],
110 'perm'
111 )
112 );
113 }
114 }
115
119 public function initForm($a_mode = self::MODE_EDIT): ilPropertyFormGUI
120 {
121 $form = parent::initForm($a_mode);
122
123 if ($a_mode == self::MODE_CREATE) {
124 return $form;
125 }
126
128 $this->object->getRefId(),
129 $this->object->getTargetRefId()
130 );
131
132 // nothing todo if no parent course is in path
133 if (!$path_info->hasParentCourse()) {
134 return $form;
135 }
136
137 $access = $path_info->checkManagmentAccess();
138
139 $auto_update = new \ilCheckboxInputGUI($this->lng->txt('crs_ref_member_update'), 'member_update');
140 $auto_update->setChecked($this->object->isMemberUpdateEnabled());
141 $auto_update->setInfo($this->lng->txt('crs_ref_member_update_info'));
142 $auto_update->setDisabled(!$access);
143 $form->addItem($auto_update);
144
145 return $form;
146 }
147
153 {
154 $ok = true;
155 $ok = parent::loadPropertiesFromSettingsForm($form);
156
158 $this->object->getRefId(),
159 $this->object->getTargetRefId()
160 );
161
162 $auto_update = $form->getInput('member_update');
163 if ($auto_update && !$path_info->hasParentCourse()) {
164 $ok = false;
165 $form->getItemByPostVar('member_update')->setAlert($this->lng->txt('crs_ref_missing_parent_crs'));
166 }
167 if ($auto_update && !$path_info->checkManagmentAccess()) {
168 $ok = false;
169 $form->getItemByPostVar('member_update')->setAlert($this->lng->txt('crs_ref_missing_access'));
170 }
171
172 // check manage members
173 $this->object->enableMemberUpdate((bool) $form->getInput('member_update'));
174
175 return $ok;
176 }
177
183 public static function _goto($a_target)
184 {
185 global $DIC;
186
187 $access = $DIC->access();
188 $ctrl = $DIC->ctrl();
189 $logger = $DIC->logger()->crsr();
190
191 $target_ref_id = $a_target;
192 $write_access = $access->checkAccess('write', '', (int) $target_ref_id);
193
194 if ($write_access) {
195 $target_class = \ilObjCourseReferenceGUI::class;
196 } else {
197 $target_ref_id = \ilContainerReference::_lookupTargetRefId(\ilObject::_lookupObjId($target_ref_id));
198 $target_class = \ilObjCourseGUI::class;
199 }
200
201 $ctrl->setTargetScript('ilias.php');
202 $ctrl->setParameterByClass($target_class, 'ref_id', $target_ref_id);
204 [
205 \ilRepositoryGUI::class,
206 $target_class
207 ],
208 'edit'
209 );
210 }
211}
static _lookupTargetRefId(int $a_obj_id)
static getInstanceByRefId(int $ref_id, int $target_ref_id=0)
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setTargetScript(string $a_target_script)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
executeCommand()
Execute command @access public.
getTabs()
Add tabs @access public.
static _goto($a_target)
Support for goto php.
loadPropertiesFromSettingsForm(ilPropertyFormGUI $form)
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
ilAccessHandler $access
prepareOutput(bool $show_sub_objects=true)
static _lookupObjId(int $ref_id)
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26