19 declare(strict_types=1);
58 $this->
lng = $DIC[
'lng'];
60 $this->tpl = $DIC[
'tpl'];
61 $this->
toolbar = $DIC[
'ilToolbar'];
62 $this->
tabs = $DIC[
'ilTabs'];
63 $this->
ctrl = $DIC[
'ilCtrl'];
64 $this->tree = $DIC[
'tree'];
65 $this->
user = $DIC[
'ilUser'];
66 $this->db = $DIC[
'ilDB'];
67 $this->rbac_review = $DIC[
'rbacreview'];
68 $this->rbac_system = $DIC[
'rbacsystem'];
69 $this->ui_factory = $DIC[
'ui.factory'];
70 $this->ui_renderer = $DIC[
'ui.renderer'];
86 $this->parent_ref_id = $a_parent_ref_id;
88 $this->
lng->loadLanguageModule(
"administration");
89 $this->
lng->loadLanguageModule(
"user");
90 $this->
lng->loadLanguageModule(
"dateplaner");
95 $cmd = $this->
ctrl->getCmd();
96 if ($cmd ==
'roleStartingPointform' || !$cmd) {
97 $cmd =
'initRoleStartingPointForm';
109 $this->ui_factory->link()->standard(
110 $this->
lng->txt(
'create_starting_point'),
111 $this->
ctrl->getLinkTarget($this,
"roleStartingPointform")
117 $this->starting_point_repository,
123 $this->tpl->setContent($tbl->getHTML());
131 $this->tpl->setContent($form->getHTML());
139 $this->tpl->setContent($form->getHTML());
148 $startp->setInfo($this->
lng->txt(
'adm_user_starting_point_personal_info'));
149 $startp->setChecked($this->starting_point_repository->isPersonalStartingPointEnabled());
151 $form->addItem($startp);
153 $form->addCommandButton(
'saveUserStartingPoint', $this->
lng->txt(
'save'));
154 $form->setFormAction($this->
ctrl->getFormAction($this));
164 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
165 $this->error->raiseError(
166 $this->
lng->txt(
'msg_no_perm_read'),
171 $this->
ctrl->saveParameter($this, [
'spid']);
173 $starting_point_id = $this->user_request->getStartingPointId();
176 $req_role_id = $this->user_request->getRoleId();
185 $si->setValue((
string) $starting_point_type);
189 $form->addCommandButton(
'saveStartingPoint', $this->
lng->txt(
'save'));
190 $form->addCommandButton(
'startingPoints', $this->
lng->txt(
'cancel'));
192 $form->setTitle($this->
lng->txt(
'starting_point_settings'));
193 $form->setFormAction($this->
ctrl->getFormAction($this));
200 if ($starting_point_id === null) {
204 return $this->starting_point_repository->getStartingPointById(
211 if ($starting_point === null) {
220 if ($spoint_id === null) {
229 $roles = $this->starting_point_repository->getGlobalRolesWithoutStartingPoint();
236 $radg->setValue(
'0');
238 $radg->addOption($op1);
241 foreach ($roles as $role) {
242 $role_options[$role[
'id']] = $role[
'title'];
246 $op1->addSubItem($si_roles);
250 $radg->addOption($op2);
252 $role_search->setSize(40);
253 $op2->addSubItem($role_search);
259 $title = $this->
lng->txt(
'default');
260 if ($spoint_id !== $this->starting_point_repository->getDefaultStartingPointID()) {
262 $title = $role->getTitle();
270 $inputs[1]->setValue((
string) $req_role_id);
273 $inputs[2]->setValue((
string) $spoint_id);
282 $si->setInfo($this->
lng->txt(
'adm_user_starting_point_info'));
283 $valid = array_keys($this->starting_point_repository->getPossibleStartingPoints());
284 foreach ($this->starting_point_repository->getPossibleStartingPoints(
true) as $value => $caption) {
313 if (!in_array($value, $valid)) {
314 $opt->setInfo($this->
lng->txt(
'adm_user_starting_point_invalid_info'));
326 $default_cal_view->addOption($day);
328 $default_cal_view->addOption($week);
330 $default_cal_view->addOption($month);
341 $cal_periods->setRequired(
true);
343 if ($st_point !== null) {
348 $list->addSubItem($cal_periods);
349 $default_cal_view->addOption($list);
351 return $default_cal_view;
356 $repobj_id =
new ilTextInputGUI($this->
lng->txt(
'adm_user_starting_point_ref_id'),
'start_object');
357 $repobj_id->setRequired(
true);
358 $repobj_id->setSize(5);
360 if ($st_point !== null) {
362 $repobj_id->setValue($start_ref_id);
365 if (isset($start_ref_id)) {
383 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
384 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->FATAL);
389 if ($form->checkInput()) {
390 $this->starting_point_repository->togglePersonalStartingPointActivation((
bool) $form->getInput(
'usr_start_pers'));
391 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
392 $this->
ctrl->redirect($this,
'startingPoints');
394 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_error'),
true);
395 $this->
ctrl->redirect($this,
'startingPoints');
403 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
404 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->FATAL);
407 $start_point_id = $this->user_request->getStartingPointId();
412 if (!$form->checkInput()) {
413 $form->setValuesByPost();
414 $this->tpl->setContent($form->getHTML());
418 $starting_point = $this->starting_point_repository->getStartingPointById(
423 $role_id = $this->user_request->getRoleId();
425 if ($form->getInput(
'role_type') ===
'1' 426 && ($role_id === null || $role_id < 1)) {
435 $object_search->setFilter([
'role']);
436 $res = $object_search->performSearch();
438 $entries =
$res->getEntries();
440 if ($entries === []) {
441 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_corresponding_roles'),
true);
442 $form->setValuesByPost();
443 $this->tpl->setContent($form->getHTML());
447 if (count($entries) > 1) {
449 $form->getInput(
'role'),
450 $form->getInput(
'role_search'),
451 $form->getInput(
'start_point'),
452 $form->getInput(
'start_object')
457 if (count($entries) === 1) {
458 $role = current($entries);
459 $role_id = $role[
'obj_id'];
463 if ($role_id === 0) {
464 $role_id = $form->getInput(
'role');
467 if ($role_id !== 0) {
468 $starting_point->setRuleTypeRoleBased();
469 $rules = [
'role_id' => $role_id];
470 $starting_point->setRuleOptions(serialize($rules));
473 $starting_point->setStartingPointType((
int) $form->getInput(
'start_point'));
475 $obj_id = (
int) $form->getInput(
'start_object');
476 $cal_view = (
int) $form->getInput(
'user_calendar_view');
477 $cal_period = (
int) $form->getInput(
'user_cal_period');
482 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_ref_id_not_exist'),
true);
483 $form->setValuesByPost();
484 $this->tpl->setContent($form->getHTML());
487 $starting_point->setStartingObject($obj_id);
490 $starting_point->setCalendarView($cal_view);
491 $starting_point->setCalendarPeriod($cal_period);
494 if ($start_point_id !== null) {
495 $this->starting_point_repository->update($starting_point);
497 $this->starting_point_repository->save($starting_point);
500 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
501 $this->
ctrl->redirect($this,
'startingPoints');
511 $parser->setMinWordLength(1);
516 $object_search->setFilter([
'role']);
517 $res = $object_search->performSearch();
519 $entries =
$res->getEntries();
522 $table->setLimit(9999);
523 $table->disable(
'sort');
524 $table->addHiddenInput(
'role_search', $role_search);
525 $table->addHiddenInput(
'start_point', $start_point);
526 $table->addHiddenInput(
'start_object', $start_object);
527 $table->addHiddenInput(
'role', $role);
528 $table->addHiddenInput(
'role_type',
'1');
529 $table->setTitle($this->
lng->txt(
'user_role_selection'));
530 $table->addMultiCommand(
'saveStartingPoint', $this->
lng->txt(
'select'));
531 $table->parse($entries);
533 $this->tpl->setContent($table->getHTML());
538 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
542 $positions = $this->user_request->getPositions();
543 if (count($positions) > 0) {
544 $this->starting_point_repository->saveOrder($positions);
547 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
548 $this->
ctrl->redirect($this,
'startingPoints');
553 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
557 $spoint_id = $this->user_request->getStartingPointId();
558 $req_role_id = $this->user_request->getRoleId();
560 if ($req_role_id && is_numeric($spoint_id)) {
561 $sp = $this->starting_point_repository->getStartingPointById(
564 $this->starting_point_repository->delete($sp->getId());
565 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
567 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_spoint_not_modified'),
true);
569 $this->
ctrl->redirect($this,
'startingPoints');
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
getCalenderSubInputs(?ilUserStartingPoint $st_point)
getRepositoryObjectInput(?ilUserStartingPoint $st_point)
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveStartingPoint()
store starting point from the form
getEditFormSpecificInputs(int $spoint_id, int $req_role_id)
TableGUI class for LTI consumer listing.
getCreateFormSpecificInputs()
getUserStartingPointForm()
ilUserStartingPointRepository $starting_point_repository
ilGlobalTemplateInterface $tpl
showRoleSelection(string $role, string $role_search, string $start_point, string $start_object)
getCurrentStartingPointOrNullForStartingPointForm(?int $starting_point_id)
initRoleStartingPointForm(ilPropertyFormGUI $form=null)
static _lookupObjId(int $ref_id)
setMinWordLength(int $a_length)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
startingPoints()
table form to set up starting points depends of user roles
static _lookupTitle(int $obj_id)
initUserStartingPointForm(ilPropertyFormGUI $form=null)
const START_REPOSITORY_OBJ
ilRbacSystem $rbac_system
Class ilUserStartingPointGUI.
UserGUIRequest $user_request
getRoleStartingPointForm()
addRoleAutoCompleteObject()
getStartingPointSelectionOption(int $value, string $caption, ?ilUserStartingPoint $st_point, array $valid)
ilRbacReview $rbac_review
getCalendarView()
Gets calendar view.
static _lookupType(int $id, bool $reference=false)
getStartingPointSelectionInput(?ilUserStartingPoint $st_point)
getCurrentTypeForStartingPointForm(?ilUserStartingPoint $starting_point)
getFormTypeSpecificStartingPointFormParts(?int $spoint_id, ?int $req_role_id)