19declare(strict_types=1);
34 private \ilGlobalTemplateInterface
$tpl;
40 private \ilDBInterface
$db;
57 $this->
lng = $DIC[
'lng'];
59 $this->tpl =
$DIC[
'tpl'];
60 $this->
toolbar = $DIC[
'ilToolbar'];
61 $this->
tabs = $DIC[
'ilTabs'];
62 $this->
ctrl = $DIC[
'ilCtrl'];
63 $this->tree =
$DIC[
'tree'];
64 $this->
user = $DIC[
'ilUser'];
65 $this->db =
$DIC[
'ilDB'];
66 $this->
error = $DIC[
'ilErr'];
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'];
76 $this->starting_point_repository =
LocalDIC::dic()[Repository::class];
78 $this->parent_ref_id = $a_parent_ref_id;
80 $this->
lng->loadLanguageModule(
"administration");
81 $this->
lng->loadLanguageModule(
"user");
82 $this->
lng->loadLanguageModule(
"dateplaner");
87 $cmd = $this->
ctrl->getCmd();
88 if ($cmd ==
'roleStartingPointform' || !$cmd) {
89 $cmd =
'initRoleStartingPointForm';
101 $this->ui_factory->link()->standard(
102 $this->lng->txt(
'create_starting_point'),
103 $this->ctrl->getLinkTarget($this,
"roleStartingPointform")
107 $tbl = new \ilUserRoleStartingPointTableGUI(
109 $this->starting_point_repository,
115 $this->tpl->setContent($tbl->getHTML());
121 $form = $this->getUserStartingPointForm();
123 $this->tpl->setContent($form->getHTML());
131 $this->tpl->setContent($form->getHTML());
136 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
137 $this->
error->raiseError(
138 $this->
lng->txt(
'msg_no_perm_read'),
142 $form = new \ilPropertyFormGUI();
143 $this->
ctrl->saveParameter($this, [
'spid']);
145 $starting_point_id = $this->user_request->getStartingPointId();
148 $req_role_id = $this->user_request->getRoleId();
157 $si->setValue((
string) $starting_point_type);
161 $form->addCommandButton(
'saveStartingPoint', $this->
lng->txt(
'save'));
162 $form->addCommandButton(
'startingPoints', $this->
lng->txt(
'cancel'));
164 $form->setTitle($this->
lng->txt(
'starting_point_settings'));
165 $form->setFormAction($this->
ctrl->getFormAction($this));
172 if ($starting_point_id ===
null) {
176 return $this->starting_point_repository->getStartingPointById(
183 if ($starting_point ===
null) {
192 if ($spoint_id ===
null) {
201 $roles = $this->starting_point_repository->getGlobalRolesWithoutStartingPoint();
205 $radg = new \ilRadioGroupInputGUI($this->
lng->txt(
'role'),
'role_type');
206 $radg->setValue(
'1');
208 $radg->setValue(
'0');
209 $op1 = new \ilRadioOption($this->
lng->txt(
'user_global_role'),
'0');
210 $radg->addOption($op1);
213 foreach ($roles as $role) {
214 $role_options[$role[
'id']] = $role[
'title'];
216 $si_roles = new \ilSelectInputGUI($this->
lng->txt(
'roles_without_starting_point'),
'role');
217 $si_roles->setOptions($role_options);
218 $op1->addSubItem($si_roles);
221 $op2 = new \ilRadioOption($this->
lng->txt(
'user_local_role'),
'1');
222 $radg->addOption($op2);
223 $role_search = new \ilRoleAutoCompleteInputGUI(
'',
'role_search', $this,
'addRoleAutoCompleteObject');
224 $role_search->setSize(40);
225 $op2->addSubItem($role_search);
231 $title = $this->
lng->txt(
'default');
232 if ($spoint_id !== $this->starting_point_repository->getDefaultStartingPointID()) {
233 $role = new \ilObjRole($req_role_id);
234 $title = $role->getTitle();
238 $inputs[0] = new \ilNonEditableValueGUI($this->
lng->txt(
'editing_this_role'),
'role_disabled');
241 $inputs[1] = new \ilHiddenInputGUI(
'role');
242 $inputs[1]->setValue((
string) $req_role_id);
244 $inputs[2] = new \ilHiddenInputGUI(
'start_point_id');
245 $inputs[2]->setValue((
string) $spoint_id);
252 $si = new \ilRadioGroupInputGUI($this->
lng->txt(
'adm_user_starting_point'),
'start_point');
253 $si->setRequired(
true);
254 $si->setInfo($this->
lng->txt(
'adm_user_starting_point_info'));
255 $valid = array_keys($this->starting_point_repository->getPossibleStartingPoints());
256 foreach ($this->starting_point_repository->getPossibleStartingPoints(
true) as $value => $caption) {
285 if (!in_array($value,
$valid)) {
286 $opt->setInfo($this->
lng->txt(
'adm_user_starting_point_invalid_info'));
294 $default_cal_view = new \ilRadioGroupInputGUI($this->
lng->txt(
'cal_def_view'),
'user_calendar_view');
295 $default_cal_view->setRequired(
true);
298 $default_cal_view->addOption($day);
300 $default_cal_view->addOption($week);
302 $default_cal_view->addOption($month);
306 $cal_periods = new \ilSelectInputGUI($this->
lng->txt(
'cal_list'),
'user_cal_period');
307 $cal_periods->setOptions([
313 $cal_periods->setRequired(
true);
315 if ($st_point !==
null) {
320 $list->addSubItem($cal_periods);
321 $default_cal_view->addOption($list);
323 return $default_cal_view;
328 $repobj_id = new \ilTextInputGUI($this->
lng->txt(
'adm_user_starting_point_ref_id'),
'start_object');
329 $repobj_id->setRequired(
true);
330 $repobj_id->setSize(5);
332 if ($st_point !==
null) {
334 $repobj_id->setValue($start_ref_id);
337 if (isset($start_ref_id)) {
358 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
359 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->FATAL);
362 $start_point_id = $this->user_request->getStartingPointId();
365 $form = $this->getRoleStartingPointForm();
367 if (!$form->checkInput()) {
368 $form->setValuesByPost();
369 $this->tpl->setContent($form->getHTML());
373 $starting_point = $this->starting_point_repository->getStartingPointById(
378 $role_id = $this->user_request->getRoleId();
380 if ($form->getInput(
'role_type') ===
'1'
381 && ($role_id ===
null || $role_id < 1)) {
382 $parser = new \ilQueryParser($form->getInput(
'role_search'));
385 $parser->setMinWordLength(1);
389 $object_search = new \ilLikeObjectSearch($parser);
390 $object_search->setFilter([
'role']);
391 $res = $object_search->performSearch();
393 $entries =
$res->getEntries();
395 if ($entries === []) {
396 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_corresponding_roles'),
true);
397 $form->setValuesByPost();
398 $this->tpl->setContent($form->getHTML());
402 if (count($entries) > 1) {
403 $this->showRoleSelection(
404 $form->getInput(
'role'),
405 $form->getInput(
'role_search'),
406 $form->getInput(
'start_point'),
407 $form->getInput(
'start_object')
412 if (count($entries) === 1) {
413 $role = current($entries);
414 $role_id = $role[
'obj_id'];
418 if ($role_id === 0) {
419 $role_id = $form->getInput(
'role');
422 if ($role_id !== 0) {
423 $starting_point->setRuleTypeRoleBased();
424 $rules = [
'role_id' => $role_id];
425 $starting_point->setRuleOptions(serialize($rules));
428 $starting_point->setStartingPointType((
int) $form->getInput(
'start_point'));
430 $obj_id = (
int) $form->getInput(
'start_object');
431 $cal_view = (
int) $form->getInput(
'user_calendar_view');
432 $cal_period = (
int) $form->getInput(
'user_cal_period');
437 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_ref_id_not_exist'),
true);
438 $form->setValuesByPost();
439 $this->tpl->setContent($form->getHTML());
442 $starting_point->setStartingObject($obj_id);
445 $starting_point->setCalendarView($cal_view);
446 $starting_point->setCalendarPeriod($cal_period);
449 if ($start_point_id !==
null) {
450 $this->starting_point_repository->update($starting_point);
452 $this->starting_point_repository->save($starting_point);
455 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
456 $this->
ctrl->redirect($this,
'startingPoints');
470 $object_search = new \ilLikeObjectSearch($parser);
471 $object_search->setFilter([
'role']);
472 $res = $object_search->performSearch();
474 $entries =
$res->getEntries();
476 $table = new \ilRoleSelectionTableGUI($this,
'saveStartingPoint');
477 $table->setLimit(9999);
478 $table->disable(
'sort');
479 $table->addHiddenInput(
'role_search', $role_search);
480 $table->addHiddenInput(
'start_point', $start_point);
481 $table->addHiddenInput(
'start_object', $start_object);
482 $table->addHiddenInput(
'role', $role);
483 $table->addHiddenInput(
'role_type',
'1');
484 $table->setTitle($this->
lng->txt(
'user_role_selection'));
485 $table->addMultiCommand(
'saveStartingPoint', $this->
lng->txt(
'select'));
486 $table->parse($entries);
488 $this->tpl->setContent($table->getHTML());
493 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
494 throw new \ilPermissionException($this->
lng->txt(
'msg_no_perm_read'));
497 $positions = $this->user_request->getPositions();
498 if (count($positions) > 0) {
499 $this->starting_point_repository->saveOrder($positions);
502 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
503 $this->
ctrl->redirect($this,
'startingPoints');
508 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
509 throw new \ilPermissionException($this->
lng->txt(
'msg_no_perm_read'));
512 $spoint_id = $this->user_request->getStartingPointId();
513 $req_role_id = $this->user_request->getRoleId();
515 if ($req_role_id && is_numeric($spoint_id)) {
516 $sp = $this->starting_point_repository->getStartingPointById(
519 $this->starting_point_repository->delete($sp->getId());
520 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
522 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_spoint_not_modified'),
true);
524 $this->
ctrl->redirect($this,
'startingPoints');
Builds a Color from either hex- or rgb values.
const START_REPOSITORY_OBJ
initUserStartingPointForm(?\ilPropertyFormGUI $form=null)
getCreateFormSpecificInputs()
getStartingPointSelectionOption(int $value, string $caption, ?StartingPoint $st_point, array $valid)
saveStartingPoint()
store starting point from the form
showRoleSelection(string $role, string $role_search, string $start_point, string $start_object)
getRepositoryObjectInput(?StartingPoint $st_point)
ilRbacReview $rbac_review
getRoleStartingPointForm()
startingPoints()
table form to set up starting points depends of user roles
addRoleAutoCompleteObject()
getStartingPointSelectionInput(?StartingPoint $st_point)
ilRbacSystem $rbac_system
Repository $starting_point_repository
UserGUIRequest $user_request
initRoleStartingPointForm(?\ilPropertyFormGUI $form=null)
getCalenderSubInputs(?StartingPoint $st_point)
getFormTypeSpecificStartingPointFormParts(?int $spoint_id, ?int $req_role_id)
getCurrentStartingPointOrNullForStartingPointForm(?int $starting_point_id)
getCurrentTypeForStartingPointForm(?StartingPoint $starting_point)
getEditFormSpecificInputs(int $spoint_id, int $req_role_id)
ilGlobalTemplateInterface $tpl
getCalendarView()
Gets calendar view.
__construct()
Constructor setup ILIAS global object @access public.
static getLogger(string $a_component_id)
Get component logger.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
setMinWordLength(int $a_length)
This class represents an option in a radio group.
This class represents a text property in a property form.
An entity that renders components to a string output.