Skip to content

Conversation

@okaufman
Copy link
Owner

A User with the role "UserTakeOver-User" would be enabled to use the TakeOver Plugin

@okaufman okaufman self-assigned this Jan 24, 2020
Copy link
Collaborator

@Amstutz Amstutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @okaufman

Thx for factoring out some of the new method logic. Did we not say we'd like make the roles having access selectable by the plugin configs screen? If not, at least, get the roles with permission from a new table in the DB to be prepared for this change. Further, see the inline comments.

Thx a lot.

if (!in_array(2, self::dic()->rbacreview()->assignedGlobalRoles(self::dic()->user()->getId()))) {

if (!usrtoHelper::getInstance()->checkPluginAccess())
// if (!in_array(2, self::dic()->rbacreview()->assignedGlobalRoles(self::dic()->user()->getId())))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What ist this, why is it outcommented, -> probably remove.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
}

public function checkPluginAccess($usr_id=null){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add return value to method signature, probably:
public function checkPluginAccess($usr_id=null): string

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not listen to uncle bob ;-). Null as default probably wrong. Here especially. Always pass $usr_id to prevent side effects.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


}

protected function getRoleAllowed()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add return value method signature probably protected function getRoleAllowed() : int

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


public function checkPluginAccess($usr_id=null){
if (!isset($usr_id)) {
$usr_id = self::dic()->user()->getId();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here is the side effect, now this method depends on the state of self::dic()->user(), pass this from the outside always and get rid if this if here.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
// roles named UserTakeOver-User are allowed to use the plugin
if(self::dic()->rbacreview()->roleExists(self::USRTO_ROLE_NAME)){
$roles= self::dic()->rbacreview()->getRolesByFilter(2,0, self::USRTO_ROLE_NAME);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not make that selectable by the plugins config screen?

if(self::dic()->rbacreview()->roleExists(self::USRTO_ROLE_NAME)){
$roles= self::dic()->rbacreview()->getRolesByFilter(2,0, self::USRTO_ROLE_NAME);
}
return $roles[0]["obj_id"];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is admin not also allowed, where ist that set?

@Amstutz Amstutz added the enhancement New feature or request label Jan 24, 2020
remove comments
change function checkPluginAccess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants