I needed to clear some caches based on on the thread operations on the main 'inbox'.

Here is a patch that adds a new hook so other modules can see when operations are performed.

Comments

berdir’s picture

Status: Needs review » Needs work
+++ privatemsg.api.php	14 Jan 2011 01:56:17 -0000
@@ -634,5 +634,19 @@
+ * @param $operation
+ *   The operation that was executed.
+ *   @see hook_privatemsg_thread_operations()
+ * @param $threads
+ *   An array of thread ids. The array is filtered to include only
+ *   checked threads.
+ */
+function hook_privatemsg_operation_executed($operation, $threads, $account = NULL) {

- Why is $account optional here? I think we should define it as a required argument, makes implementing the hook easier.

- @see is usually at the end of a docblock.

- Maybe something like "An array which contains the thread ids on which the operation has been executed." instead of your current sentence?

+++ privatemsg.module	14 Jan 2011 01:56:18 -0000
@@ -2132,6 +2138,13 @@
+
+  // Allow modules to respond to the operation.
+  foreach (module_implements('privatemsg_operation_executed') as $module) {
+    $function = $module . '_privatemsg_operation_executed';
+    $function($operation, $threads, $account);
+  }
+

No need to use module_implements directly?

This should be exactly the same:

module_invoke_all('privatemsg_operation_executed', $operation, $threads, $account);

Edit: Doing it manually is only required when you are passing arguments by reference but aren't using an _alter() hook.

Powered by Dreditor.

te-brian’s picture

$account is optional in privatemsg_operation_execute(), from which this hook is invoked. So it can't require account unless we know there will be one.

The other changes make sense.

berdir’s picture

Ah, makes sense.

Looking at where the privatemsg_operation_execute() is called, this is a possible bug when viewing messages of an other user. Looks like we might need a separate issue that makes $account required for both.

te-brian’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB

Implemented some of the discussed changes.

berdir’s picture

Version: » 7.x-1.x-dev

Thanks commited.

This will need to be added to 7.x too. Patch will likely apply there too, testbot can check that.

berdir’s picture

#4: privatemsg-operation-execute.patch queued for re-testing.

berdir’s picture

Status: Needs review » Fixed

Commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.