19 declare(strict_types=1);
60 $this->
lng = $DIC[
'lng'];
62 $this->tpl = $DIC[
'tpl'];
63 $this->
toolbar = $DIC[
'ilToolbar'];
64 $this->
tabs = $DIC[
'ilTabs'];
65 $this->
ctrl = $DIC[
'ilCtrl'];
66 $this->tree = $DIC[
'tree'];
67 $this->
user = $DIC[
'ilUser'];
68 $this->db = $DIC[
'ilDB'];
69 $this->rbac_review = $DIC[
'rbacreview'];
70 $this->rbac_system = $DIC[
'rbacsystem'];
71 $this->ui_factory = $DIC[
'ui.factory'];
72 $this->ui_renderer = $DIC[
'ui.renderer'];
88 $this->parent_ref_id = $a_parent_ref_id;
90 $this->
lng->loadLanguageModule(
"administration");
91 $this->
lng->loadLanguageModule(
"user");
92 $this->
lng->loadLanguageModule(
"dateplaner");
97 $cmd = $this->
ctrl->getCmd();
98 if ($cmd ==
'roleStartingPointform' || !$cmd) {
99 $cmd =
'initRoleStartingPointForm';
111 $this->ui_factory->link()->standard(
112 $this->
lng->txt(
'create_starting_point'),
113 $this->
ctrl->getLinkTarget($this,
"roleStartingPointform")
119 $this->starting_point_repository,
125 $this->tpl->setContent($tbl->getHTML());
133 $this->tpl->setContent($form->getHTML());
141 $this->tpl->setContent($form->getHTML());
150 $startp->setInfo($this->
lng->txt(
'adm_user_starting_point_personal_info'));
151 $startp->setChecked($this->starting_point_repository->isPersonalStartingPointEnabled());
153 $form->addItem($startp);
155 $form->addCommandButton(
'saveUserStartingPoint', $this->
lng->txt(
'save'));
156 $form->setFormAction($this->
ctrl->getFormAction($this));
166 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
167 $this->error->raiseError(
168 $this->
lng->txt(
'msg_no_perm_read'),
173 $this->
ctrl->saveParameter($this, [
'spid']);
175 $starting_point_id = $this->user_request->getStartingPointId();
178 $req_role_id = $this->user_request->getRoleId();
187 $si->setValue((
string) $starting_point_type);
191 $form->addCommandButton(
'saveStartingPoint', $this->
lng->txt(
'save'));
192 $form->addCommandButton(
'startingPoints', $this->
lng->txt(
'cancel'));
194 $form->setTitle($this->
lng->txt(
'starting_point_settings'));
195 $form->setFormAction($this->
ctrl->getFormAction($this));
202 if ($starting_point_id ===
null) {
206 return $this->starting_point_repository->getStartingPointById(
213 if ($starting_point ===
null) {
222 if ($spoint_id ===
null) {
231 $roles = $this->starting_point_repository->getGlobalRolesWithoutStartingPoint();
238 $radg->setValue(
'0');
240 $radg->addOption($op1);
243 foreach ($roles as $role) {
244 $role_options[$role[
'id']] = $role[
'title'];
248 $op1->addSubItem($si_roles);
252 $radg->addOption($op2);
254 $role_search->setSize(40);
255 $op2->addSubItem($role_search);
261 $title = $this->
lng->txt(
'default');
262 if ($spoint_id !== $this->starting_point_repository->getDefaultStartingPointID()) {
264 $title = $role->getTitle();
272 $inputs[1]->setValue((
string) $req_role_id);
275 $inputs[2]->setValue((
string) $spoint_id);
284 $si->setInfo($this->
lng->txt(
'adm_user_starting_point_info'));
285 $valid = array_keys($this->starting_point_repository->getPossibleStartingPoints());
286 foreach ($this->starting_point_repository->getPossibleStartingPoints(
true) as $value => $caption) {
315 if (!in_array($value, $valid)) {
316 $opt->setInfo($this->
lng->txt(
'adm_user_starting_point_invalid_info'));
328 $default_cal_view->addOption($day);
330 $default_cal_view->addOption($week);
332 $default_cal_view->addOption($month);
343 $cal_periods->setRequired(
true);
345 if ($st_point !==
null) {
350 $list->addSubItem($cal_periods);
351 $default_cal_view->addOption($list);
353 return $default_cal_view;
358 $repobj_id =
new ilTextInputGUI($this->
lng->txt(
'adm_user_starting_point_ref_id'),
'start_object');
359 $repobj_id->setRequired(
true);
360 $repobj_id->setSize(5);
362 if ($st_point !==
null) {
364 $repobj_id->setValue($start_ref_id);
367 if (isset($start_ref_id)) {
385 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
386 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->FATAL);
391 if ($form->checkInput()) {
392 $this->starting_point_repository->togglePersonalStartingPointActivation((
bool) $form->getInput(
'usr_start_pers'));
393 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
394 $this->
ctrl->redirect($this,
'startingPoints');
396 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_error'),
true);
397 $this->
ctrl->redirect($this,
'startingPoints');
405 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
406 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->FATAL);
409 $start_point_id = $this->user_request->getStartingPointId();
414 if (!$form->checkInput()) {
415 $form->setValuesByPost();
416 $this->tpl->setContent($form->getHTML());
420 $starting_point = $this->starting_point_repository->getStartingPointById(
425 $role_id = $this->user_request->getRoleId();
427 if ($form->getInput(
'role_type') ===
'1' 428 && ($role_id ===
null || $role_id < 1)) {
437 $object_search->setFilter([
'role']);
438 $res = $object_search->performSearch();
440 $entries =
$res->getEntries();
442 if ($entries === []) {
443 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_corresponding_roles'),
true);
444 $form->setValuesByPost();
445 $this->tpl->setContent($form->getHTML());
449 if (count($entries) > 1) {
451 $form->getInput(
'role'),
452 $form->getInput(
'role_search'),
453 $form->getInput(
'start_point'),
454 $form->getInput(
'start_object')
459 if (count($entries) === 1) {
460 $role = current($entries);
461 $role_id = $role[
'obj_id'];
465 if ($role_id === 0) {
466 $role_id = $form->getInput(
'role');
469 if ($role_id !== 0) {
470 $starting_point->setRuleTypeRoleBased();
471 $rules = [
'role_id' => $role_id];
472 $starting_point->setRuleOptions(serialize($rules));
475 $starting_point->setStartingPointType((
int) $form->getInput(
'start_point'));
477 $obj_id = (
int) $form->getInput(
'start_object');
478 $cal_view = (
int) $form->getInput(
'user_calendar_view');
479 $cal_period = (
int) $form->getInput(
'user_cal_period');
484 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_ref_id_not_exist'),
true);
485 $form->setValuesByPost();
486 $this->tpl->setContent($form->getHTML());
489 $starting_point->setStartingObject($obj_id);
492 $starting_point->setCalendarView($cal_view);
493 $starting_point->setCalendarPeriod($cal_period);
496 if ($start_point_id !==
null) {
497 $this->starting_point_repository->update($starting_point);
499 $this->starting_point_repository->save($starting_point);
502 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
503 $this->
ctrl->redirect($this,
'startingPoints');
513 $parser->setMinWordLength(1);
518 $object_search->setFilter([
'role']);
519 $res = $object_search->performSearch();
521 $entries =
$res->getEntries();
524 $table->setLimit(9999);
525 $table->disable(
'sort');
526 $table->addHiddenInput(
'role_search', $role_search);
527 $table->addHiddenInput(
'start_point', $start_point);
528 $table->addHiddenInput(
'start_object', $start_object);
529 $table->addHiddenInput(
'role', $role);
530 $table->addHiddenInput(
'role_type',
'1');
531 $table->setTitle($this->
lng->txt(
'user_role_selection'));
532 $table->addMultiCommand(
'saveStartingPoint', $this->
lng->txt(
'select'));
533 $table->parse($entries);
535 $this->tpl->setContent($table->getHTML());
540 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
544 $positions = $this->user_request->getPositions();
545 if (count($positions) > 0) {
546 $this->starting_point_repository->saveOrder($positions);
549 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
550 $this->
ctrl->redirect($this,
'startingPoints');
555 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
559 $spoint_id = $this->user_request->getStartingPointId();
560 $req_role_id = $this->user_request->getRoleId();
562 if ($req_role_id && is_numeric($spoint_id)) {
563 $sp = $this->starting_point_repository->getStartingPointById(
566 $this->starting_point_repository->delete($sp->getId());
567 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
569 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_spoint_not_modified'),
true);
571 $this->
ctrl->redirect($this,
'startingPoints');
This class represents an option in a radio group.
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)
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setMinWordLength(int $a_length)
startingPoints()
table form to set up starting points depends of user roles
static _lookupTitle(int $obj_id)
const START_REPOSITORY_OBJ
ilRbacSystem $rbac_system
Class ilUserStartingPointGUI.
UserGUIRequest $user_request
initUserStartingPointForm(?ilPropertyFormGUI $form=null)
getRoleStartingPointForm()
__construct(Container $dic, ilPlugin $plugin)
addRoleAutoCompleteObject()
getStartingPointSelectionOption(int $value, string $caption, ?ilUserStartingPoint $st_point, array $valid)
ilRbacReview $rbac_review
initRoleStartingPointForm(?ilPropertyFormGUI $form=null)
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)