Just curious if Rules support is in the works anywhere.

Possible Conditions:
* Is Masquerading?

Possible Events:
* Began Masquerade-ing
* Stopped Masquerade-ing

Possible Actions:
* Start Masquerade-ing
* Stop Masquerade-ing
* Stop All Masquerade-ing

Comments

This would be an extremely valuable feature to add!

Status:Active» Closed (duplicate)

This request would depend on:
#1458418: Add masquerade events API

And therefore, this request had already been moved to (somehow I forgot about this post):
#1458334: Add Rules support

I don't think we need an events API to support Rules. Rules is popular enough to get bumped ahead of a generic API integration if someone submitted a patch for it.

Then, for example, the implementation of capturing when a user is about to masquerade would be:

<?php
if (module_exists('rules')) {
 
// rules_invoke_event(<event_id>, <current_user>, <new_user>)
 
rules_invoke_event('masquerade_X', $user, $account);
}
?>

I thought initially about going down this road, but it feels too tightly coupled.

Plus, in further thought, we could let other modules stop the masquerade based on custom requirements.

<?php
$roll_with_it
= TRUE;
if (
module_exists('rules')) {
 
// rules_invoke_event(<event_id>, <current_user>, <new_user>, <permit_masquerade>)
 
rules_invoke_event('masquerade_X', $user, $account, $roll_with_it);
}
if (!
$roll_with_it) {
 
// Do something to let the user know the masquerade wasn't permitted.
}
?>

Status:Closed (duplicate)» Active

let's continue in this issue, marked as dumplicated #1458334: Add Rules support

suppose we just need to implement support in masquerade.rules.inc

Where should development of this feature continue? It seems like both the Masquerade and Masquerade Extras projects are assuming the other will implement the feature. This seems has been closed in the Masquerade Extras project and marked as a duplicate of this issue.

@citricguy
That's not quite the case.
The Masquerade module needs to fire the basic hooks necessary for rules to work. Otherwise, the rest of this is not possible.
(For example: module_invoke("masquerade_start")). This thread already suggests the basics for what would be required. #1547058: Add hooks when user starts or stops masquerading

My original suggestion was wrong because rules integration would be coupled to masquerade with hooks specific to rules.
All masquerade_extras would supply is the hooks/events that would be useful to rules.

Whether or not Masquerade's maintainers want that integration in this suite or elsewhere is up to them.