Skip to content

Commit

Permalink
User: Harden Selection of StartingPoint-Form
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Dec 15, 2023
1 parent 44f3366 commit bd693ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Services/User/classes/class.StandardGUIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getTerm(): string
public function getStartingPointId(): string
{
$id = $this->str("spid");
if ($id == 0) {
if ($id === '0' || $id === '') {
$id = $this->str("start_point_id");
}
return $id;
Expand All @@ -90,7 +90,7 @@ public function getStartingPointId(): string
public function getRoleId(): string
{
$role_id = $this->str("rolid");
if ($role_id == 0) {
if ($role_id === '0' || $role_id === '') {
$role_id = $this->str("role_id");
}
return $role_id;
Expand Down
50 changes: 23 additions & 27 deletions Services/User/classes/class.ilUserStartingPointGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,32 @@ protected function getRoleStartingPointForm(): ilPropertyFormGUI
$spoint_id = $this->user_request->getStartingPointId();
$req_role_id = $this->user_request->getRoleId();

//edit no default
if ($spoint_id > 0 && $spoint_id != 'default') {
$st_point = new ilStartingPoint($spoint_id);
if ($spoint_id === 'default') {
$starting_point = ilUserUtil::getStartingPoint();
} elseif (is_numeric($spoint_id) && intval($spoint_id) > 0) {
$st_point = new ilStartingPoint((int) $spoint_id);

//starting point role based
if ($st_point->getRuleType() == ilStartingPoint::ROLE_BASED && $req_role_id) {
$rolid = $req_role_id;
if ($role = new ilObjRole($rolid)) {
$options[$rolid] = $role->getTitle();
$starting_point = $st_point->getStartingPoint();

// role title, non editable
$ne = new ilNonEditableValueGUI($this->lng->txt("editing_this_role"), 'role_disabled');
$ne->setValue($role->getTitle());
$form->addItem($ne);

$hi = new ilHiddenInputGUI("role");
$hi->setValue($rolid);
$form->addItem($hi);

$hidde_sp_id = new ilHiddenInputGUI("start_point_id");
$hidde_sp_id->setValue($spoint_id);
$form->addItem($hidde_sp_id);
}
if ($st_point->getRuleType() === ilStartingPoint::ROLE_BASED
&& is_numeric($req_role_id) && intval($req_role_id) > 0
&& ($role = new ilObjRole((int) $req_role_id))) {
$options[$req_role_id] = $role->getTitle();
$starting_point = $st_point->getStartingPoint();

// role title, non editable
$ne = new ilNonEditableValueGUI($this->lng->txt("editing_this_role"), 'role_disabled');
$ne->setValue($role->getTitle());
$form->addItem($ne);

$hi = new ilHiddenInputGUI("role");
$hi->setValue($req_role_id);
$form->addItem($hi);

$hidde_sp_id = new ilHiddenInputGUI("start_point_id");
$hidde_sp_id->setValue($spoint_id);
$form->addItem($hidde_sp_id);
}
}
//create
elseif (!$spoint_id || $spoint_id != 'default') {
} else {
//starting point role based
if (ilStartingPoint::ROLE_BASED) {
$roles = ilStartingPoint::getGlobalRolesWithoutStartingPoint();
Expand All @@ -204,8 +202,6 @@ protected function getRoleStartingPointForm(): ilPropertyFormGUI
$role_search->setSize(40);
$op2->addSubItem($role_search);
}
} else {
$starting_point = ilUserUtil::getStartingPoint();
}

// starting point
Expand Down

0 comments on commit bd693ec

Please sign in to comment.