ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilUserStartingPointGUI Class Reference

Class ilUserStartingPointGUI. More...

+ Collaboration diagram for ilUserStartingPointGUI:

Public Member Functions

 __construct ($a_parent_ref_id)
 Constructor public. More...
 
executeCommand ()
 
 startingPoints ()
 table form to set up starting points depends of user roles More...
 
 initUserStartingPointForm (ilPropertyFormGUI $form=null)
 
 initRoleStartingPointForm (ilPropertyFormGUI $form=null)
 
 saveOrder ()
 
 confirmDeleteStartingPoint ()
 Confirm delete starting point. More...
 

Protected Member Functions

 getUserStartingPointForm ()
 
 getRoleStartingPointForm ()
 
 saveUserStartingPoint ()
 
 saveStartingPoint ()
 store starting point from the form More...
 
 deleteStartingPoint ()
 Set to 0 the starting point values. More...
 

Protected Attributes

 $log
 
 $lng
 
 $tpl
 
 $parent_ref_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilUserStartingPointGUI::__construct (   $a_parent_ref_id)

Constructor public.

Definition at line 24 of file class.ilUserStartingPointGUI.php.

References $DIC, $ilCtrl, $lng, $tpl, and ilLoggerFactory\getLogger().

25  {
26  global $DIC;
27 
28  $lng = $DIC['lng'];
29  $tpl = $DIC['tpl'];
30  $ilToolbar = $DIC['ilToolbar'];
31  $ilCtrl = $DIC['ilCtrl'];
32 
33  $this->log = ilLoggerFactory::getLogger("user");
34  $this->lng = $lng;
35  $this->tpl = $tpl;
36  $this->toolbar = $ilToolbar;
37  $this->ctrl = $ilCtrl;
38  $this->parent_ref_id = $a_parent_ref_id;
39  $this->lng->loadLanguageModule("administration");
40  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteStartingPoint()

ilUserStartingPointGUI::confirmDeleteStartingPoint ( )

Confirm delete starting point.

Definition at line 359 of file class.ilUserStartingPointGUI.php.

References $DIC, $ilCtrl, $lng, and $tpl.

360  {
361  global $DIC;
362 
363  $ilCtrl = $DIC['ilCtrl'];
364  $lng = $DIC['lng'];
365  $tpl = $DIC['tpl'];
366  $ilTabs = $DIC['ilTabs'];
367 
368  $ilTabs->clearTargets();
369  $ilTabs->setBackTarget($lng->txt('back_to_starting_points_list'), $ilCtrl->getLinkTarget($this, 'startingPoints'));
370 
371  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
372  $conf = new ilConfirmationGUI();
373  $conf->setFormAction($ilCtrl->getFormAction($this));
374  $conf->setHeaderText($lng->txt('confirm_delete_starting_point'));
375 
376  //if type role based
377  if ($_REQUEST['rolid'] && $_REQUEST['spid']) {
378  include_once "./Services/AccessControl/classes/class.ilObjRole.php";
379 
380  $rolid = (int) $_REQUEST['rolid'];
381  $spid = (int) $_REQUEST['spid'];
382 
383  $role = new ilObjRole($rolid);
384 
385  $conf->addItem('rolid', $rolid, $role->getTitle());
386  $conf->addItem('spid', $spid, "");
387  }
388 
389  $conf->setConfirm($lng->txt('delete'), 'deleteStartingPoint');
390  $conf->setCancel($lng->txt('cancel'), 'startingPoints');
391 
392  $tpl->setContent($conf->getHTML());
393  }
Class ilObjRole.
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
Confirmation screen class.

◆ deleteStartingPoint()

ilUserStartingPointGUI::deleteStartingPoint ( )
protected

Set to 0 the starting point values.

Definition at line 398 of file class.ilUserStartingPointGUI.php.

References $DIC, $ilCtrl, $ilErr, $lng, and ilUtil\sendFailure().

399  {
400  global $DIC;
401 
402  $ilCtrl = $DIC['ilCtrl'];
403  $rbacsystem = $DIC['rbacsystem'];
404  $ilErr = $DIC['ilErr'];
405 
406  if (!$rbacsystem->checkAccess("write", $this->parent_ref_id)) {
407  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
408  }
409 
410  require_once "./Services/AccessControl/classes/class.ilObjRole.php";
411 
412  if ($rolid = $_REQUEST['rolid'] && $spid = $_REQUEST['spid']) {
413  include_once("./Services/AccessControl/classes/class.ilStartingPoint.php");
414  $sp = new ilStartingPoint($spid);
415  $sp->delete();
416  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
417  } else {
418  ilUtil::sendFailure($this->lng->txt("msg_spoint_not_modified"), true);
419  }
420  $ilCtrl->redirect($this, "startingPoints");
421  }
global $DIC
Definition: saml.php:7
Class ilStartingPoint.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ executeCommand()

& ilUserStartingPointGUI::executeCommand ( )

Definition at line 41 of file class.ilUserStartingPointGUI.php.

References $DIC, and $ilCtrl.

42  {
43  global $DIC;
44 
45  $ilCtrl = $DIC['ilCtrl'];
46 
47  $cmd = $ilCtrl->getCmd();
48  if ($cmd == "roleStartingPointform" || !$cmd) {
49  $cmd = "initRoleStartingPointForm";
50  }
51 
52  $this->$cmd();
53 
54  return true;
55  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18

◆ getRoleStartingPointForm()

ilUserStartingPointGUI::getRoleStartingPointForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 125 of file class.ilUserStartingPointGUI.php.

References $DIC, $form, $ilCtrl, $ilErr, $lng, PHPMailer\PHPMailer\$options, $si, $valid, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilStartingPoint\getGlobalRolesWithoutStartingPoint(), ilUserUtil\getPossibleStartingPoints(), ilUserUtil\getStartingObject(), ilUserUtil\getStartingPoint(), ilStartingPoint\ROLE_BASED, ilRadioOption\setInfo(), ilSelectInputGUI\setOptions(), ilRadioOption\setValue(), and ilUserUtil\START_REPOSITORY_OBJ.

Referenced by initRoleStartingPointForm(), and saveStartingPoint().

126  {
127  global $DIC;
128 
129  $ilCtrl = $DIC['ilCtrl'];
130  $rbacsystem = $DIC['rbacsystem'];
131  $ilErr = $DIC['ilErr'];
132 
133  if (!$rbacsystem->checkAccess("write", $this->parent_ref_id)) {
134  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
135  }
136 
137  require_once "Services/Form/classes/class.ilPropertyFormGUI.php";
138  require_once "./Services/AccessControl/classes/class.ilObjRole.php";
139  require_once "./Services/AccessControl/classes/class.ilStartingPoint.php";
140  include_once "Services/User/classes/class.ilUserUtil.php";
141 
142  $form = new ilPropertyFormGUI();
143  $ilCtrl->saveParameter($this, array("spid"));
144 
145  $spoint_id = $_REQUEST['spid'];
146 
147  //edit no default
148  if ($spoint_id > 0 && $spoint_id != 'default') {
149  $st_point = new ilStartingPoint($spoint_id);
150 
151  //starting point role based
152  if ($st_point->getRuleType() == ilStartingPoint::ROLE_BASED && $_REQUEST['rolid']) {
153  $rolid = (int) $_REQUEST['rolid'];
154  if ($role = new ilObjRole($rolid)) {
155  $options[$rolid] = $role->getTitle();
156  $starting_point = $st_point->getStartingPoint();
157  $si_roles = new ilSelectInputGUI($this->lng->txt("editing_this_role"), 'role_disabled');
158  $si_roles->setOptions($options);
159  $si_roles->setDisabled(true);
160  $form->addItem($si_roles);
161 
162  $hi = new ilHiddenInputGUI("role");
163  $hi->setValue($rolid);
164  $form->addItem($hi);
165 
166  $hidde_sp_id = new ilHiddenInputGUI("start_point_id");
167  $hidde_sp_id->setValue($spoint_id);
168  $form->addItem($hidde_sp_id);
169  }
170  }
171  }
172  //create
173  elseif (!$spoint_id || $spoint_id != 'default') {
174  //starting point role based
177 
178  foreach ($roles as $role) {
179  $options[$role['id']] = $role['title'];
180  }
181  $si_roles = new ilSelectInputGUI($this->lng->txt("roles_without_starting_point"), 'role');
182  $si_roles->setOptions($options);
183  $form->addItem($si_roles);
184  }
185  } else {
186  $starting_point = ilUserUtil::getStartingPoint();
187  }
188 
189  // starting point
190 
191  $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "start_point");
192  $si->setRequired(true);
193  $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
195  foreach (ilUserUtil::getPossibleStartingPoints(true) as $value => $caption) {
196  $opt = new ilRadioOption($caption, $value);
197  $si->addOption($opt);
198 
199  if (!in_array($value, $valid)) {
200  $opt->setInfo($this->lng->txt("adm_user_starting_point_invalid_info"));
201  }
202  }
203  $si->setValue($starting_point);
204  $form->addItem($si);
205 
206  // starting point: repository object
207  $repobj = new ilRadioOption($this->lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
208  $repobj_id = new ilTextInputGUI($this->lng->txt("adm_user_starting_point_ref_id"), "start_object");
209  $repobj_id->setRequired(true);
210  $repobj_id->setSize(5);
211  //$i has the starting_point value, so we are here only when edit one role or setting the default role.
212  if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) {
213  if ($st_point) {
214  $start_ref_id = $st_point->getStartingObject();
215  } else {
216  $start_ref_id = ilUserUtil::getStartingObject();
217  }
218 
219  $repobj_id->setValue($start_ref_id);
220  if ($start_ref_id) {
221  $start_obj_id = ilObject::_lookupObjId($start_ref_id);
222  if ($start_obj_id) {
223  $repobj_id->setInfo($this->lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) .
224  ": " . ilObject::_lookupTitle($start_obj_id));
225  }
226  }
227  }
228  $repobj->addSubItem($repobj_id);
229  $si->addOption($repobj);
230 
231  // save and cancel commands
232  $form->addCommandButton("saveStartingPoint", $this->lng->txt("save"));
233  $form->addCommandButton("startingPoints", $this->lng->txt("cancel"));
234 
235  $form->setTitle($this->lng->txt("starting_point_settings"));
236  $form->setFormAction($ilCtrl->getFormAction($this));
237 
238  return $form;
239  }
Class ilObjRole.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
Class ilStartingPoint.
$valid
static _lookupTitle($a_id)
lookup object title
static getGlobalRolesWithoutStartingPoint()
Get id and title of the roles without starting points.
static getStartingPoint()
Get current starting point setting.
setInfo($a_info)
Set Info.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
static getPossibleStartingPoints($a_force_all=false)
Get all valid starting points.
This class represents a hidden form property in a property form.
This class represents a property in a property form.
setValue($a_value)
Set Value.
if(isset($_POST['submit'])) $form
static _lookupObjId($a_id)
static getStartingObject()
Get ref id of starting object.
This class represents a text property in a property form.
setOptions($a_options)
Set Options.
static _lookupType($a_id, $a_reference=false)
lookup object type
const START_REPOSITORY_OBJ
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserStartingPointForm()

ilUserStartingPointGUI::getUserStartingPointForm ( )
protected

Definition at line 98 of file class.ilUserStartingPointGUI.php.

References $DIC, $form, $ilCtrl, ilUserUtil\hasPersonalStartingPoint(), and ilFormPropertyGUI\setInfo().

Referenced by initUserStartingPointForm(), and saveUserStartingPoint().

99  {
100  global $DIC;
101 
102  $ilCtrl = $DIC['ilCtrl'];
103 
104  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
105  require_once "Services/User/classes/class.ilUserUtil.php";
106 
107  $form = new ilPropertyFormGUI();
108 
109  // starting point: personal
110  $startp = new ilCheckboxInputGUI($this->lng->txt("user_chooses_starting_page"), "usr_start_pers");
111  $startp->setInfo($this->lng->txt("adm_user_starting_point_personal_info"));
112  $startp->setChecked(ilUserUtil::hasPersonalStartingPoint());
113 
114  $form->addItem($startp);
115 
116  $form->addCommandButton("saveUserStartingPoint", $this->lng->txt("save"));
117  $form->setFormAction($ilCtrl->getFormAction($this));
118 
119  return $form;
120  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a checkbox property in a property form.
static hasPersonalStartingPoint()
Can starting point be personalized?
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initRoleStartingPointForm()

ilUserStartingPointGUI::initRoleStartingPointForm ( ilPropertyFormGUI  $form = null)

Definition at line 90 of file class.ilUserStartingPointGUI.php.

References $form, and getRoleStartingPointForm().

91  {
92  if (!($form instanceof ilPropertyFormGUI)) {
93  $form = $this->getRoleStartingPointForm();
94  }
95  $this->tpl->setContent($form->getHTML());
96  }
This class represents a property form user interface.
+ Here is the call graph for this function:

◆ initUserStartingPointForm()

ilUserStartingPointGUI::initUserStartingPointForm ( ilPropertyFormGUI  $form = null)

Definition at line 82 of file class.ilUserStartingPointGUI.php.

References $form, and getUserStartingPointForm().

83  {
84  if (!($form instanceof ilPropertyFormGUI)) {
85  $form = $this->getUserStartingPointForm();
86  }
87  $this->tpl->setContent($form->getHTML());
88  }
This class represents a property form user interface.
+ Here is the call graph for this function:

◆ saveOrder()

ilUserStartingPointGUI::saveOrder ( )

Definition at line 333 of file class.ilUserStartingPointGUI.php.

References $_POST, $DIC, $ilCtrl, $ilErr, and $lng.

334  {
335  global $DIC;
336 
337  $ilCtrl = $DIC['ilCtrl'];
338  $rbacsystem = $DIC['rbacsystem'];
339  $ilErr = $DIC['ilErr'];
340 
341  if (!$rbacsystem->checkAccess("write", $this->parent_ref_id)) {
342  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
343  }
344 
345  if ($_POST['position']) {
346  require_once "./Services/AccessControl/classes/class.ilStartingPoint.php";
347 
348  $sp = new ilStartingPoint();
349  $sp->saveOrder($_POST['position']);
350  }
351 
352  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
353  $ilCtrl->redirect($this, "startingPoints");
354  }
global $DIC
Definition: saml.php:7
Class ilStartingPoint.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
$_POST["username"]

◆ saveStartingPoint()

ilUserStartingPointGUI::saveStartingPoint ( )
protected

store starting point from the form

Definition at line 269 of file class.ilUserStartingPointGUI.php.

References $_POST, $DIC, $form, $ilCtrl, $ilErr, $tpl, $tree, ilObject\_lookupObjId(), getRoleStartingPointForm(), ilStartingPoint\ROLE_BASED, ilUtil\sendFailure(), ilUserUtil\setStartingPoint(), and ilUserUtil\START_REPOSITORY_OBJ.

270  {
271  global $DIC;
272 
273  $ilCtrl = $DIC['ilCtrl'];
274  $tree = $DIC['tree'];
275  $rbacsystem = $DIC['rbacsystem'];
276  $ilErr = $DIC['ilErr'];
277  $tpl = $DIC['tpl'];
278 
279  if (!$rbacsystem->checkAccess("write", $this->parent_ref_id)) {
280  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->FATAL);
281  }
282 
283  if ((int) $_POST['start_point_id'] > 0) {
284  $start_point_id = (int) $_POST['start_point_id'];
285  }
286 
287  //add from form
288  $form = $this->getRoleStartingPointForm();
289  if ($form->checkInput()) {
290  //if role
291  if ($form->getInput('role')) {
292 
293  //create starting point
294  if ($start_point_id) {
295  $starting_point = new ilStartingPoint($start_point_id);
296  } else { //edit
297  $starting_point = new ilStartingPoint();
298  }
299  $starting_point->setRuleType(ilStartingPoint::ROLE_BASED);
300  $starting_point->setStartingPoint($form->getInput("start_point"));
301  $rules = array("role_id" => $form->getInput('role'));
302  $starting_point->setRuleOptions(serialize($rules));
303 
304  $obj_id = $form->getInput('start_object');
305  if ($obj_id && ($starting_point->getStartingPoint() == ilUserUtil::START_REPOSITORY_OBJ)) {
306  if (ilObject::_lookupObjId($obj_id) && !$tree->isDeleted($obj_id)) {
307  $starting_point->setStartingObject($obj_id);
308  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
309  } else {
310  ilUtil::sendFailure($this->lng->txt("obj_ref_id_not_exist"), true);
311  }
312  } else {
313  $starting_point->setStartingObject(0);
314  }
315 
316  if ($start_point_id) {
317  $starting_point->update();
318  } else {
319  $starting_point->save();
320  }
321  } else { //default
322  ilUserUtil::setStartingPoint($form->getInput('start_point'), $form->getInput('start_object'));
323  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
324  }
325 
326  $ilCtrl->redirect($this, "startingPoints");
327  }
328  $tpl->setContent($form->getHTML());
329 
330  //$ilCtrl->redirect($this, "startingPoints");
331  }
global $DIC
Definition: saml.php:7
Class ilStartingPoint.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
static _lookupObjId($a_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const START_REPOSITORY_OBJ
static setStartingPoint($a_value, $a_ref_id=null)
Set starting point setting.
$_POST["username"]
+ Here is the call graph for this function:

◆ saveUserStartingPoint()

ilUserStartingPointGUI::saveUserStartingPoint ( )
protected

Definition at line 241 of file class.ilUserStartingPointGUI.php.

References $DIC, $form, $ilCtrl, $ilErr, getUserStartingPointForm(), ilUtil\sendFailure(), and ilUserUtil\togglePersonalStartingPoint().

242  {
243  global $DIC;
244 
245  $ilCtrl = $DIC['ilCtrl'];
246  $rbacsystem = $DIC['rbacsystem'];
247  $ilErr = $DIC['ilErr'];
248 
249  if (!$rbacsystem->checkAccess("write", $this->parent_ref_id)) {
250  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->FATAL);
251  }
252 
253  include_once "Services/User/classes/class.ilUserUtil.php";
254 
255  $form = $this->getUserStartingPointForm();
256 
257  if ($form->checkInput()) {
258  ilUserUtil::togglePersonalStartingPoint($form->getInput('usr_start_pers'));
259  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
260  $ilCtrl->redirect($this, "startingPoints");
261  }
262  ilUtil::sendFailure($this->lng->txt("msg_error"), true);
263  $ilCtrl->redirect($this, "startingPoints");
264  }
global $DIC
Definition: saml.php:7
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static togglePersonalStartingPoint($a_value)
Toggle personal starting point setting.
+ Here is the call graph for this function:

◆ startingPoints()

ilUserStartingPointGUI::startingPoints ( )

table form to set up starting points depends of user roles

Definition at line 60 of file class.ilUserStartingPointGUI.php.

References $tbl, ilStartingPoint\getGlobalRolesWithoutStartingPoint(), and ilUtil\sendInfo().

61  {
62  include_once "Services/User/classes/class.ilUserRoleStartingPointTableGUI.php";
63 
64  require_once "./Services/AccessControl/classes/class.ilStartingPoint.php";
66 
67  if (!empty($roles_without_point)) {
68  $this->toolbar->addButton(
69  $this->lng->txt('create_starting_point'),
70  $this->ctrl->getLinkTarget($this, "roleStartingPointform")
71  );
72  } else {
73  ilUtil::sendInfo($this->lng->txt("all_roles_has_starting_point"));
74  }
75 
76 
78 
79  $this->tpl->setContent($tbl->getHTML());
80  }
$tbl
Definition: example_048.php:81
TableGUI class for LTI consumer listing.
static getGlobalRolesWithoutStartingPoint()
Get id and title of the roles without starting points.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilUserStartingPointGUI::$lng
protected

◆ $log

ilUserStartingPointGUI::$log
protected

Definition at line 15 of file class.ilUserStartingPointGUI.php.

◆ $parent_ref_id

ilUserStartingPointGUI::$parent_ref_id
protected

Definition at line 18 of file class.ilUserStartingPointGUI.php.

◆ $tpl

ilUserStartingPointGUI::$tpl
protected

The documentation for this class was generated from the following file: