19declare(strict_types=1);
34 private \ilGlobalTemplateInterface
$tpl;
40 private \ilDBInterface
$db;
56 $this->
lng = $DIC[
'lng'];
58 $this->tpl =
$DIC[
'tpl'];
59 $this->
toolbar = $DIC[
'ilToolbar'];
60 $this->
tabs = $DIC[
'ilTabs'];
61 $this->
ctrl = $DIC[
'ilCtrl'];
62 $this->tree =
$DIC[
'tree'];
63 $this->
user = $DIC[
'ilUser'];
64 $this->db =
$DIC[
'ilDB'];
65 $this->rbac_review =
$DIC[
'rbacreview'];
66 $this->rbac_system =
$DIC[
'rbacsystem'];
67 $this->ui_factory =
$DIC[
'ui.factory'];
68 $this->ui_renderer =
$DIC[
'ui.renderer'];
74 $this->starting_point_repository =
LocalDIC::dic()[Repository::class];
76 $this->parent_ref_id = $a_parent_ref_id;
78 $this->
lng->loadLanguageModule(
"administration");
79 $this->
lng->loadLanguageModule(
"user");
80 $this->
lng->loadLanguageModule(
"dateplaner");
85 $cmd = $this->
ctrl->getCmd();
86 if ($cmd ==
'roleStartingPointform' || !$cmd) {
87 $cmd =
'initRoleStartingPointForm';
99 $this->ui_factory->link()->standard(
100 $this->lng->txt(
'create_starting_point'),
101 $this->ctrl->getLinkTarget($this,
"roleStartingPointform")
105 $tbl = new \ilUserRoleStartingPointTableGUI(
107 $this->starting_point_repository,
113 $this->tpl->setContent($tbl->getHTML());
119 $form = $this->getUserStartingPointForm();
121 $this->tpl->setContent($form->getHTML());
129 $this->tpl->setContent($form->getHTML());
134 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
135 $this->
error->raiseError(
136 $this->
lng->txt(
'msg_no_perm_read'),
140 $form = new \ilPropertyFormGUI();
141 $this->
ctrl->saveParameter($this, [
'spid']);
143 $starting_point_id = $this->user_request->getStartingPointId();
146 $req_role_id = $this->user_request->getRoleId();
155 $si->setValue((
string) $starting_point_type);
159 $form->addCommandButton(
'saveStartingPoint', $this->
lng->txt(
'save'));
160 $form->addCommandButton(
'startingPoints', $this->
lng->txt(
'cancel'));
162 $form->setTitle($this->
lng->txt(
'starting_point_settings'));
163 $form->setFormAction($this->
ctrl->getFormAction($this));
170 if ($starting_point_id ===
null) {
174 return $this->starting_point_repository->getStartingPointById(
181 if ($starting_point ===
null) {
190 if ($spoint_id ===
null) {
199 $roles = $this->starting_point_repository->getGlobalRolesWithoutStartingPoint();
203 $radg = new \ilRadioGroupInputGUI($this->
lng->txt(
'role'),
'role_type');
204 $radg->setValue(
'1');
206 $radg->setValue(
'0');
207 $op1 = new \ilRadioOption($this->
lng->txt(
'user_global_role'),
'0');
208 $radg->addOption($op1);
211 foreach ($roles as $role) {
212 $role_options[$role[
'id']] = $role[
'title'];
214 $si_roles = new \ilSelectInputGUI($this->
lng->txt(
'roles_without_starting_point'),
'role');
215 $si_roles->setOptions($role_options);
216 $op1->addSubItem($si_roles);
219 $op2 = new \ilRadioOption($this->
lng->txt(
'user_local_role'),
'1');
220 $radg->addOption($op2);
221 $role_search = new \ilRoleAutoCompleteInputGUI(
'',
'role_search', $this,
'addRoleAutoCompleteObject');
222 $role_search->setSize(40);
223 $op2->addSubItem($role_search);
229 $title = $this->
lng->txt(
'default');
230 if ($spoint_id !== $this->starting_point_repository->getDefaultStartingPointID()) {
231 $role = new \ilObjRole($req_role_id);
232 $title = $role->getTitle();
236 $inputs[0] = new \ilNonEditableValueGUI($this->
lng->txt(
'editing_this_role'),
'role_disabled');
239 $inputs[1] = new \ilHiddenInputGUI(
'role');
240 $inputs[1]->setValue((
string) $req_role_id);
242 $inputs[2] = new \ilHiddenInputGUI(
'start_point_id');
243 $inputs[2]->setValue((
string) $spoint_id);
250 $si = new \ilRadioGroupInputGUI($this->
lng->txt(
'adm_user_starting_point'),
'start_point');
251 $si->setRequired(
true);
252 $si->setInfo($this->
lng->txt(
'adm_user_starting_point_info'));
253 $valid = array_keys($this->starting_point_repository->getPossibleStartingPoints());
254 foreach ($this->starting_point_repository->getPossibleStartingPoints(
true) as $value => $caption) {
283 if (!in_array($value,
$valid)) {
284 $opt->setInfo($this->
lng->txt(
'adm_user_starting_point_invalid_info'));
292 $default_cal_view = new \ilRadioGroupInputGUI($this->
lng->txt(
'cal_def_view'),
'user_calendar_view');
293 $default_cal_view->setRequired(
true);
296 $default_cal_view->addOption($day);
298 $default_cal_view->addOption($week);
300 $default_cal_view->addOption($month);
304 $cal_periods = new \ilSelectInputGUI($this->
lng->txt(
'cal_list'),
'user_cal_period');
305 $cal_periods->setOptions([
311 $cal_periods->setRequired(
true);
313 if ($st_point !==
null) {
318 $list->addSubItem($cal_periods);
319 $default_cal_view->addOption($list);
321 return $default_cal_view;
326 $repobj_id = new \ilTextInputGUI($this->
lng->txt(
'adm_user_starting_point_ref_id'),
'start_object');
327 $repobj_id->setRequired(
true);
328 $repobj_id->setSize(5);
330 if ($st_point !==
null) {
332 $repobj_id->setValue($start_ref_id);
335 if (isset($start_ref_id)) {
356 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
357 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->FATAL);
360 $start_point_id = $this->user_request->getStartingPointId();
363 $form = $this->getRoleStartingPointForm();
365 if (!$form->checkInput()) {
366 $form->setValuesByPost();
367 $this->tpl->setContent($form->getHTML());
371 $starting_point = $this->starting_point_repository->getStartingPointById(
376 $role_id = $this->user_request->getRoleId();
378 if ($form->getInput(
'role_type') ===
'1'
379 && ($role_id ===
null || $role_id < 1)) {
380 $parser = new \ilQueryParser($form->getInput(
'role_search'));
383 $parser->setMinWordLength(1);
387 $object_search = new \ilLikeObjectSearch($parser);
388 $object_search->setFilter([
'role']);
389 $res = $object_search->performSearch();
391 $entries =
$res->getEntries();
393 if ($entries === []) {
394 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_corresponding_roles'),
true);
395 $form->setValuesByPost();
396 $this->tpl->setContent($form->getHTML());
400 if (count($entries) > 1) {
401 $this->showRoleSelection(
402 $form->getInput(
'role'),
403 $form->getInput(
'role_search'),
404 $form->getInput(
'start_point'),
405 $form->getInput(
'start_object')
410 if (count($entries) === 1) {
411 $role = current($entries);
412 $role_id = $role[
'obj_id'];
416 if ($role_id === 0) {
417 $role_id = $form->getInput(
'role');
420 if ($role_id !== 0) {
421 $starting_point->setRuleTypeRoleBased();
422 $rules = [
'role_id' => $role_id];
423 $starting_point->setRuleOptions(serialize($rules));
426 $starting_point->setStartingPointType((
int) $form->getInput(
'start_point'));
428 $obj_id = (
int) $form->getInput(
'start_object');
429 $cal_view = (
int) $form->getInput(
'user_calendar_view');
430 $cal_period = (
int) $form->getInput(
'user_cal_period');
435 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_ref_id_not_exist'),
true);
436 $form->setValuesByPost();
437 $this->tpl->setContent($form->getHTML());
440 $starting_point->setStartingObject($obj_id);
443 $starting_point->setCalendarView($cal_view);
444 $starting_point->setCalendarPeriod($cal_period);
447 if ($start_point_id !==
null) {
448 $this->starting_point_repository->update($starting_point);
450 $this->starting_point_repository->save($starting_point);
453 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
454 $this->
ctrl->redirect($this,
'startingPoints');
468 $object_search = new \ilLikeObjectSearch($parser);
469 $object_search->setFilter([
'role']);
470 $res = $object_search->performSearch();
472 $entries =
$res->getEntries();
474 $table = new \ilRoleSelectionTableGUI($this,
'saveStartingPoint');
475 $table->setLimit(9999);
476 $table->disable(
'sort');
477 $table->addHiddenInput(
'role_search', $role_search);
478 $table->addHiddenInput(
'start_point', $start_point);
479 $table->addHiddenInput(
'start_object', $start_object);
480 $table->addHiddenInput(
'role', $role);
481 $table->addHiddenInput(
'role_type',
'1');
482 $table->setTitle($this->
lng->txt(
'user_role_selection'));
483 $table->addMultiCommand(
'saveStartingPoint', $this->
lng->txt(
'select'));
484 $table->parse($entries);
486 $this->tpl->setContent($table->getHTML());
491 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
492 throw new \ilPermissionException($this->
lng->txt(
'msg_no_perm_read'));
495 $positions = $this->user_request->getPositions();
496 if (count($positions) > 0) {
497 $this->starting_point_repository->saveOrder($positions);
500 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
501 $this->
ctrl->redirect($this,
'startingPoints');
506 if (!$this->rbac_system->checkAccess(
'write', $this->parent_ref_id)) {
507 throw new \ilPermissionException($this->
lng->txt(
'msg_no_perm_read'));
510 $spoint_id = $this->user_request->getStartingPointId();
511 $req_role_id = $this->user_request->getRoleId();
513 if ($req_role_id && is_numeric($spoint_id)) {
514 $sp = $this->starting_point_repository->getStartingPointById(
517 $this->starting_point_repository->delete($sp->getId());
518 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
520 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_spoint_not_modified'),
true);
522 $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.