Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add onGetGroupsByUser event trigger #1494

Closed
wants to merge 3 commits into from

3 participants

@mdobrinic

code style updated; JEventDispatcher used instead of JDispatcher

@elinw

http://developer.joomla.org/pulls/pulls/1494.html

You have a number of code style errors and a unit test failure.
I'm not sure what the UT failure is about but it is probably the messy intertwining of user and session.
We use tabs and not space except inside docblocks.

Wait are these two the same?

@elinw

If this one and the other one are the same will you close whichever one is not the one you want?

@eddieajau

I'm going to close this one mainly because I have no idea what the problem is you are trying to solve.

@eddieajau eddieajau closed this
@mdobrinic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 24, 2012
Commits on Aug 27, 2012
  1. Code style changed opening bracked to newline

    mdobrinic authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 2 deletions.
  1. +30 −2 libraries/joomla/access/access.php
View
32 libraries/joomla/access/access.php
@@ -60,7 +60,14 @@ class JAccess
*/
protected static $groupsByUser = array();
- /**
+ /**
+ * Semaphore to guard against nested calls of getUsersByGroup
+ * When set to true, JPluginHelper::importPlugin() is not called again
+ * @var boolean
+ */
+ protected static $loaded = false;
+
+ /**
* Method for clearing static caches.
*
* @return void
@@ -333,7 +340,28 @@ public static function getGroupsByUser($userId, $recursive = true)
$db->setQuery($query);
$result = $db->loadColumn();
- // Clean up any NULL or duplicate values, just in case
+ // Execute the query and load the rules from the result.
+ $db->setQuery($query);
+ $result = $db->loadColumn();
+
+ // Add trigger to allow for external group assignment
+ // nesting prevention:
+ if (!self::$loaded)
+ {
+ self::$loaded = true;
+ JPluginHelper::importPlugin('user');
+ }
+ $dispatcher = JEventDispatcher::getInstance();
+ $r = $dispatcher->trigger('onGetGroupsByUser', array($userId, $recursive));
+
+ if (! empty($r)) {
+ // Collect result from all fired plugins
+ foreach ($r as $plugin_r) {
+ $result = array_merge($result, $plugin_r);
+ }
+ }
+
+ // Clean up any NULL or duplicate values, just in case
JArrayHelper::toInteger($result);
if (empty($result))
Something went wrong with that request. Please try again.