ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjCourseReferenceGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/ContainerReference/classes/class.ilContainerReferenceGUI.php');
37{
41 private $logger = null;
42
43 protected $target_type = 'crs';
44 protected $reference_type = 'crsr';
45
51 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
52 {
53 global $DIC;
54
55 $this->logger = $DIC->logger()->crsr();
56
57 parent::__construct($a_data, $a_id, true, false);
58
59 $this->lng->loadLanguageModule('crs');
60 }
61
68 public function executeCommand()
69 {
70 global $DIC;
71
72 $user = $DIC->user();
73
74 $next_class = $this->ctrl->getNextClass($this);
75 switch ($next_class) {
76 case 'illearningprogressgui':
77 $this->prepareOutput();
78 $this->tabs_gui->activateTab('learning_progress');
79 $lp_gui = new \ilLearningProgressGUI(
81 $this->object->getRefId(),
82 $user->getId()
83 );
84 $this->ctrl->forwardCommand($lp_gui);
85 return;
86 }
87 parent::executeCommand();
88 }
89
95 public function getTabs()
96 {
97 global $DIC;
98
99 $help = $DIC->help();
100 $help->setScreenIdComponent($this->getReferenceType());
101
102 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
103 $this->tabs_gui->addTab(
104 'settings',
105 $this->lng->txt('settings'),
106 $this->ctrl->getLinkTarget($this, 'edit')
107 );
108 }
109
110 if (ilLearningProgressAccess::checkAccess($this->object->getRefId(), false)) {
111 $this->tabs_gui->addTab(
112 'learning_progress',
113 $this->lng->txt('learning_progress'),
114 $this->ctrl->getLinkTargetByClass(
115 [
116 ilObjCourseReferenceGUI::class,
117 ilLearningProgressGUI::class
118 ],
119 ''
120 )
121 );
122 }
123 if ($this->access->checkAccess('edit_permission', '', $this->object->getRefId())) {
124 $this->tabs_gui->addTab(
125 'perm_settings',
126 $this->lng->txt('perm_settings'),
127 $this->ctrl->getLinkTargetByClass(
128 [
129 ilObjCourseReferenceGUI::class,
130 ilPermissionGUI::class
131 ],
132 'perm'
133 )
134 );
135 }
136 }
137
138
142 public function initForm($a_mode = self::MODE_EDIT)
143 {
144 $form = parent::initForm($a_mode);
145
146 if ($a_mode == self::MODE_CREATE) {
147 return $form;
148 }
149
150 $path_info = \ilCourseReferencePathInfo::getInstanceByRefId($this->object->getRefId(), $this->object->getTargetRefId());
151
152
153 // nothing todo if no parent course is in path
154 if (!$path_info->hasParentCourse()) {
155 return $form;
156 }
157
158 $access = $path_info->checkManagmentAccess();
159
160 $auto_update = new \ilCheckboxInputGUI($this->lng->txt('crs_ref_member_update'), 'member_update');
161 $auto_update->setChecked($this->object->isMemberUpdateEnabled());
162 $auto_update->setInfo($this->lng->txt('crs_ref_member_update_info'));
163 $auto_update->setDisabled(!$access);
164 $form->addItem($auto_update);
165
166 return $form;
167 }
168
174 {
175 $ok = true;
176 $ok = parent::loadPropertiesFromSettingsForm($form);
177
178 $path_info = ilCourseReferencePathInfo::getInstanceByRefId($this->object->getRefId(), $this->object->getTargetRefId());
179
180 $auto_update = $form->getInput('member_update');
181 if ($auto_update && !$path_info->hasParentCourse()) {
182 $ok = false;
183 $form->getItemByPostVar('member_update')->setAlert($this->lng->txt('crs_ref_missing_parent_crs'));
184 }
185 if ($auto_update && !$path_info->checkManagmentAccess()) {
186 $ok = false;
187 $form->getItemByPostVar('member_update')->setAlert($this->lng->txt('crs_ref_missing_access'));
188 }
189
190 // check manage members
191 $this->object->enableMemberUpdate((bool) $form->getInput('member_update'));
192
193 return $ok;
194 }
195
196
203 public static function _goto($a_target)
204 {
205 global $DIC;
206
207 $access = $DIC->access();
208 $ctrl = $DIC->ctrl();
209 $logger = $DIC->logger()->crsr();
210
211 $target_ref_id = $a_target;
212 $write_access = $access->checkAccess('write', '', (int) $target_ref_id);
213
214
215 if ($write_access) {
216 $target_class = \ilObjCourseReferenceGUI::class;
217 } else {
218 $target_ref_id = \ilContainerReference::_lookupTargetRefId(\ilObject::_lookupObjId($target_ref_id));
219 $target_class = \ilObjCourseGUI::class;
220 }
221
222 $ctrl->initBaseClass(ilRepositoryGUI::class);
223 $ctrl->setParameterByClass($target_class, 'ref_id', $target_ref_id);
224 $ctrl->redirectByClass(
225 [
226 \ilRepositoryGUI::class,
227 $target_class
228 ],
229 'edit'
230 );
231 }
232}
An exception for terminatinating execution or to throw for unit testing.
static _lookupTargetRefId($a_obj_id)
Lookup target ref_id.
static getInstanceByRefId(int $ref_id, int $target_ref_id=0)
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
initForm($a_mode=self::MODE_EDIT)
Init title form.ilPropertyFormGUI
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)
Constructor.
prepareOutput($a_show_subobjects=true)
prepare output
static _lookupObjId($a_id)
This class represents a property form user interface.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46