Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update access checks #25

Open
wants to merge 9 commits into
base: release_8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions classes/UDFCheck/class.UDFCheckGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class UDFCheckGUI {
*/
public function __construct(UserSettingsGUI|UDFCheckGUI $parent_gui) {
global $DIC;
//is Admin?
if(in_array(2, $DIC->rbac()->review()->assignedGlobalRoles($DIC->user()->getId())) === false) {
echo "no Permission";
//check Access
if(!ilUserDefaultsPlugin::grantAccess()) {
echo "no UDFCheck Permission";
exit;
};

Expand Down Expand Up @@ -165,4 +165,4 @@ protected function getObject(): ?UDFCheck
{
return UDFCheck::getCheckById((int) filter_input(INPUT_GET, UDFCheckGUI::IDENTIFIER_CATEGORY), (int) filter_input(INPUT_GET, UDFCheckGUI::IDENTIFIER));
}
}
}
8 changes: 4 additions & 4 deletions classes/UserSearch/class.usrdefUserGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class usrdefUserGUI
public function __construct()
{
global $DIC;
//is Admin?
if(in_array(2, $DIC->rbac()->review()->assignedGlobalRoles($DIC->user()->getId())) === false) {
echo "no Permission";
//Check Access
if(!ilUserDefaultsPlugin::grantAccess()) {
echo "no Search Permission";
exit;
};

Expand Down Expand Up @@ -142,4 +142,4 @@ protected function selectUser(): void
$this->tpl->setOnScreenMessage('success', $this->pl->txt('userdef_users_assigned', "", [count($usr_ids)]), true);
$this->ctrl->redirect($this, self::CMD_INDEX);
}
}
}
8 changes: 4 additions & 4 deletions classes/UserSetting/class.UserSettingsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class UserSettingsGUI
public function __construct()
{
global $DIC;
//is Admin?
if(in_array(2, $DIC->rbac()->review()->assignedGlobalRoles($DIC->user()->getId())) === false) {
echo "no Permission";
//is access granted
if(!ilUserDefaultsPlugin::grantAccess()) {
echo "no Settings Permission";
exit;
};

Expand Down Expand Up @@ -445,4 +445,4 @@ protected function deleteMultiple(): void
}
$this->ctrl->redirect($this, self::CMD_INDEX);
}
}
}
6 changes: 3 additions & 3 deletions classes/class.ilUserDefaultsConfigGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class ilUserDefaultsConfigGUI extends ilPluginConfigGUI {
*/
public function __construct() {
global $DIC;
//is Admin?
if(in_array(2, $DIC->rbac()->review()->assignedGlobalRoles($DIC->user()->getId())) === false) {
echo "no Permission";
//Access granted?
if(!ilUserDefaultsPlugin::grantAccess()) {
echo "no Plugin Permission";
exit;
};

Expand Down
8 changes: 7 additions & 1 deletion classes/class.ilUserDefaultsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ public function getImagePath(string $imageName): string {
return $this->getDirectory()."/templates/images/".$imageName;
}


public static function grantAccess():bool {
global $DIC;
// check if user is allowed to configure UserDefauts
// since major parts of the plugin assign roles to users the capability to assign roles in useradministration is checked
// write would check if user can edit settings
return ($DIC->rbac()->system()->checkAccess("edit_roleassignment",USER_FOLDER_ID));
}
/**
* @inheritDoc
*/
Expand Down
6 changes: 3 additions & 3 deletions classes/class.ilUserDefaultsRestApiGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function __construct()
{
global $DIC;
$this->ctrl = $DIC->ctrl();
//is Admin?
if(in_array(2, $DIC->rbac()->review()->assignedGlobalRoles($DIC->user()->getId())) === false) {
// fix DH: Has permission
if (!ilUserDefaultsPlugin::grantAccess()) {
echo "no Permission";
exit;
};
Expand Down Expand Up @@ -115,4 +115,4 @@ public function executeCommand(): void
echo json_encode($this->userDefaultsApi->studyProgrammes->findAll());
exit;
}
}
}