diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-09 01:12:05 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-09 01:27:26 -0700 |
commit | 1ee7d24766a3055d4199251f6ce990714b9c3641 (patch) | |
tree | a198bb05283f35dc47b6617140ccd1a4531f9f75 | |
parent | 00ee91837faf4807fb17dde3272ca8248a9dcd94 (diff) |
Add support for the in filter to get_user_list and get_group_list. Convert the notifications to use user::get_user_list instead of accessing the table directly.
-rw-r--r-- | modules/notification/helpers/notification.php | 21 | ||||
-rw-r--r-- | modules/user/helpers/group.php | 8 | ||||
-rw-r--r-- | modules/user/helpers/user.php | 8 |
3 files changed, 27 insertions, 10 deletions
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index 88d92b16..150616ab 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -67,15 +67,20 @@ class notification { } static function get_subscribers($item) { - // @todo don't access the user table directly // @todo only return distinct email addresses - $users = ORM::factory("user") - ->join("subscriptions", "users.id", "subscriptions.user_id") - ->join("items", "subscriptions.item_id", "items.id") - ->where("email IS NOT", null) - ->where("items.left_ptr <=", $item->left_ptr) - ->where("items.right_ptr >", $item->right_ptr) - ->find_all(); + $subscriber_ids = array(); + foreach (ORM::factory("subscription") + ->select("user_id") + ->join("items", "subscriptions.item_id", "items.id") + ->where("items.left_ptr <=", $item->left_ptr) + ->where("items.right_ptr >", $item->right_ptr) + ->find_all() + ->as_array() as $subscriber) { + $subscriber_ids[] = $subscriber->user_id; + } + + $users = user::get_user_list(array("in" => array("id", $subscriber_ids), + "where" => array("email IS NOT" => null))); $subscribers = array(); foreach ($users as $user) { diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php index 2590c7d1..fbc5157d 100644 --- a/modules/user/helpers/group.php +++ b/modules/user/helpers/group.php @@ -82,7 +82,13 @@ class group_Core { $group = ORM::factory("group"); foreach($filter as $method => $args) { - $group->$method($args); + switch ($method) { + case "in": + $group->in($args[0], $args[1]); + break; + default: + $group->$method($args); + } } return $group->find_all(); } diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index 6a155768..c6a7735b 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -334,7 +334,13 @@ class user_Core { $user = ORM::factory("user"); foreach($filter as $method => $args) { - $user->$method($args); + switch ($method) { + case "in": + $user->in($args[0], $args[1]); + break; + default: + $user->$method($args); + } } return $user->find_all(); } |