Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

Implementing permissions for workflows #151

Closed

Conversation

Buddhima
Copy link
Contributor

Pull Request for Issue #138 .

Summary of Changes

This implementation is to validate user's permission in workflow component. Similar to categories, workflow permission uses it's parent component's permission settings plus its own.
A new permission transition.run is used to indicate which users can perform a particular transition.

Testing Instructions

Setup Joomla CMS. Create user groups and change permissions. Create users for those groups, and check the visibility of different operations based on permissions

@Buddhima Buddhima changed the title Implementing permission for workflows Implementing permissions for workflows Oct 22, 2017
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps can add the transition execute action here, too. Then it could be inherit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's more clearer run.transition stays within transition

*/
protected function allowEdit($data = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, if the (int) is not executed on the isset

if ($ownerId == $user->id)
{
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

return !empty($record) && $record->created_by == $user->id;

{
$user = Factory::getUser();

return ($user->authorise('core.create', $this->extension));
Copy link
Contributor

Choose a reason for hiding this comment

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

No brackets needed


$user = Factory::getUser();
$userId = $user->id;
$isNew = ($this->item->id == 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

!empty($this->item->id)

Copy link
Contributor Author

@Buddhima Buddhima Oct 23, 2017

Choose a reason for hiding this comment

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

I think it should be empty($this->item->id) since we check for new item

@bembelimen bembelimen mentioned this pull request Dec 23, 2017
@bembelimen
Copy link
Contributor

In favor of: #157

@bembelimen bembelimen closed this Dec 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants