Is it possible to have integration with the Rules module? What I have in mind is to give permissions to specific users with a rule after an event occurs.

Example use cases

Event: A student creates a node.
Action: The student's supervisor is granted access to the node.

Event: A user creates a node.
Action: Other users which are friends with the creator (flag friend module) are granted access to the node.

Event: Employee creates a request for his/her manager.
Action: Only the manager assigned as the superior of the employee shall have access to the request.

Event: An editor grants a reviewer access to unpublished content.
Action: An e-mail is sent to the reviewer telling him that he now has access.

Event: There is a feature that allows a user to request to be added to the ACL for a node.
Action: An administrator approves the request. This triggers a rule that the user is granted access, and an email is sent to the user informing him that he is granted access.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gisle’s picture

Thank you for suggesting integration with the Rules module.

My first priority now is to get Flexi Access ready for a stable full release, and I will not work on feature request before that goal is reached. However, I am open for suggestions, and will look again at all suggestions when the stable full release is done.

It will also be useful to know more about what sort of use cases you see for integration with Rules. For example what sort of events do you think will be used to trigger permission changes?

Sinan Erdem’s picture

Thanks for the reply.

One certain use case is:

Event: A user creates a content.
Action: Other users which are friends with the creator (flag friend module) gain access to content.

gisle’s picture

Status: Active » Postponed

Thanks for the helpful example/use case.
Postponed until a stable release is done.

gisle’s picture

Status: Postponed » Active

A stable release of Flexi Access is now available.

Adding this feature will probably not be done by the maintainer (I am already too busy with other projects). However, I shall review any patches that adds this feature, and include them in the next release if they pass review.

Elin Yordanov’s picture

This feature would be very useful.

radj’s picture

Another user case:

Context: User A created Content Node N but page is visible only to user A by default. User B can make Request Node R to view N.
Event: When User A approves Request R for Node N
Action: Add User B to list of users that can view Node N

This feature would be really helpful!

jojomojo’s picture

Hi Radj,

Have you found another way of accomplishing your use case, maybe just with the normal ACL module and rules?
If I've found a way to do this, I'll post it here.

Thanks in advance

jojomojo’s picture

Just to come back to the issue, I solved this case via Organic Groups. Nodes or other entity permissions can be managed quite nicely with it.

gisle’s picture

Issue summary: View changes

Added use cases to summary

gisle’s picture

Issue summary: View changes
apaferal’s picture

There is new news about this feature. It would be very interesting the integration with rules.

gisle’s picture

Issue summary: View changes

Added another use case.

abarpetia’s picture

Hello,
Is this use case is implemented?

Event: An editor grants a reviewer access to view content.
Action: An e-mail is sent to the reviewer telling him that he now has access.

Regards,
Abarpetia

gisle’s picture

abarpetia wrote:

Is this use case is implemented?

No. None of the use cases listed can be implemented with Flexi Access until it has integration with the rules module.

abarpetia’s picture

Hello Gisle,
I tried to achieve this use case with rules module but i haven't found any token which will give me email id of person who got access.

gisle’s picture

@abartetia, this use case is not supported by this module.

The features necessary to implement the use cases are requested. This issue is a feature request, not a manual page.

gisle’s picture

Issue summary: View changes
abarpetia’s picture

Hey guys, I am currently working on this patch. I am trying to implement following use case and have already achieved till triggering rule event after flexi access save (attached patch).

To send out emails to all users who got access to node, I need to provide list of users to rule's send email action set but I am not sure how I can achieve this. So, would appreciate some help here.

Event: An editor grants a reviewer access to view content.
Action: An e-mail is sent to the reviewer telling him that he now has access.

abarpetia’s picture

Assigned: Unassigned » abarpetia
Status: Active » Needs review
FileSize
5.09 KB

Here is the new patch which is creating grant and revoke rule action. By using this actions, user can able to assign or revoke view/delete/update permissions.

Targeted case study:
Event: A student creates a node.
Action: The student's supervisor is granted access to the node.

Event: A user creates a node.
Action: Other users which are friends with the creator (flag friend module) are granted access to the node.

Event: Employee creates a request for his/her manager.
Action: Only the manager assigned as the superior of the employee shall have access to the request.

I am still working on that email user list(#18).

april26’s picture

It would be great to have rules integration. I would like to automatically give the author access to edit the node at least for a short time. Current it looks like I have to identify and add the author as soon as the node is created. Even with the preview, most times they see a minor correction the second they publish!

gisle’s picture

@april26,
a patch is available.

It would help a lot if you could review the patch in #18 and tell us whether it works for you.

abarpetia’s picture

New patch which support all use cases include the one mentioned in #13. Let me know if there are any issues with this patch.

Target use cases:
Event: A student creates a node.
Action: The student's supervisor is granted access to the node.

Event: A user creates a node.
Action: Other users which are friends with the creator (flag friend module) are granted access to the node.

Event: Employee creates a request for his/her manager.
Action: Only the manager assigned as the superior of the employee shall have access to the request.

Event: An editor grants a reviewer access to view/update/delete content.
Action: An e-mail is sent to the reviewer telling him that he now has access to view/update/delete.

Event: An editor grants a reviewer access to unpublished content.
Action: An e-mail is sent to the reviewer telling him that he now has access.

Patch description:
Event: After updating per node Flexi Access permissions
This event will trigger when user click on "commit updates" button on Node -> FlexiAccess tab.

Actions: "Grant permissions to user" And "Revoke permissions of user"
This actions will allow grant OR revoke view/update/delete permissions.

To access list of users who got view/update/delete access, you'll need to create a loop which will iterate through flexiaccess_view_user_list / flexiaccess_update_user_list / flexiaccess_delete_user_list data selector list.

markpape’s picture

Hi abarpetia,

I get this error when adding users:

Notice: Undefined variable: update_list in flexiaccess_page_submit() (line 118 of /usr/www/users/client/sites/all/modules/flexiaccess/flexiaccess.nodes.inc).
Notice: Undefined variable: delete_list in flexiaccess_page_submit() (line 118 of /usr/www/users/client/sites/all/modules/flexiaccess/flexiaccess.nodes.inc).

I added a Rule to execute what you have in #18 and after changing users for a node got this error:

Notice: Undefined variable: update_list in flexiaccess_page_submit() (line 118 of /usr/www/users/client/sites/all/modules/flexiaccess/flexiaccess.nodes.inc).
•Notice: Undefined variable: delete_list in flexiaccess_page_submit() (line 118 of /usr/www/users/client/sites/all/modules/flexiaccess/flexiaccess.nodes.inc).
•RulesEvaluationException: Argument <em class="placeholder">flexiaccess_update_user_list</em> is missing. in RulesPlugin->setUpState() (line 717 of /usr/www/users/client/sites/all/modules/rules/includes/rules.core.inc).
The website encountered an unexpected error. Please try again later. 

Where is the correct place to report this?

--- UPDATE ---

The above problem was created (by me :( oops!) after moving from flexiaccess 7.x-1.1 to flexiaccess 7.x-1.x-dev without clearing all ACL records in bulk operations: http://www.santheafrica.org/admin/config/people/flexiaccess/bulkop, i reset and deleted.

So far solved my own problem.

markpape’s picture

Hi abarpetia,

I am currently able to fulfill the following use case in Rules:

Event: After updating per node Flexi Access permissions
Actions: Email all users notifying them they have been granted access.

How do i ensure only new users in the ACL list are emailed?

Also, How do i implement your initial use case below:

"Event: There is a feature that allows a user to request to be added to the ACL for a node.
Action: An administrator approves the request. This triggers a rule that the user is granted access, and an email is sent to the user informing him that he is granted access."

abarpetia’s picture

Hello Markpape,

How do i ensure only new users in the ACL list are emailed?

It sends out notification to all users in the ACL list. For ex, if test1 is already in list and test2 is new user then It'll send notifications to both test1 and test2.

"Event: There is a feature that allows a user to request to be added to the ACL for a node.
Action: An administrator approves the request. This triggers a rule that the user is granted access, and an email is sent to the user informing him that he is granted access.

This patch has "Grant permissions to user" action which you can use to grant access and email to users. Not sure about approval phase though, may be some kind of request form or field.

abarpetia’s picture

While testing #22 patch got error message "Call to undefined function rules_invoke_event()" because Rules module was not enable. Re-rolled new patch which checks whether rules_invoke_event function is exist or not.

We can also add strict dependency on .info page but I'll prefer to leave this decision on Module maintainer.

@Markpape, If this patch worked for you then please feel free to change RTBC status.

gisle’s picture

abarpetia wrote:

We can also add strict dependency on .info page but I'll prefer to leave this decision on Module maintainer.

It is better to check whether the rules_invoke_event function is exists.

Introducing a hard dependency in .info means that users who use this module without requiring integration with Rules would be forced to install the Rules module. We don't want that.

Jan-E’s picture

New patch for release 7.x-1.2

Jan-E’s picture

Moved more lines into the check on function_exists('rules_invoke_event')

Jan-E’s picture

And removed the change to .info

gisle’s picture

@Jan-E, thanks for re-rolling the patch for release 7.x-1.2.

To have this committed, we need to have this patch tested by someone who actually uses Rules along with Flexi access.

gisle’s picture

Status: Needs review » Closed (won't fix)

Nobody has stepped forwards to review this for nearly five years, and there don't seem to be much interest. For Drupal 9 and later, the contributed Rules project, seems to lack traction.

I am sorry, but I've decided to not move forwards with this feature request.