From d8d330a7c40975fce62e0fc6b5473ff6844f6384 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 4 Feb 2009 16:49:38 +0000 Subject: Access improvements on granular notifications git-svn-id: https://code.elgg.org/elgg/trunk@2649 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/access.php | 6 +++--- engine/lib/notification.php | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/access.php b/engine/lib/access.php index 02ca5906a..7770e0745 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -70,9 +70,9 @@ $query .= " LEFT JOIN {$CONFIG->dbprefix}access_collections ag ON ag.id = am.access_collection_id "; $query .= " WHERE am.user_guid = {$user_id} AND (ag.site_guid = {$site_id} OR ag.site_guid = 0)"; - $tmp_access_array = array(2); + $tmp_access_array = array(ACCESS_PUBLIC); if (isloggedin()) { - $tmp_access_array[] = 1; + $tmp_access_array[] = ACCESS_LOGGED_IN; // The following can only return sensible data if the user is logged in. @@ -94,7 +94,7 @@ global $is_admin; if (isset($is_admin) && $is_admin == true) { - $tmp_access_array[] = 0; + $tmp_access_array[] = ACCESS_PRIVATE; } $access_array[$user_id] = $tmp_access_array; diff --git a/engine/lib/notification.php b/engine/lib/notification.php index de3c64bef..2d43d5e53 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -386,20 +386,23 @@ if (is_array($interested_users)) foreach($interested_users as $user) { if ($user instanceof ElggUser) { - $tmp = (array)get_user_notification_settings($guid); - $methods = array(); - // TODO: get the specific method to contact each user with - for now just go with their prefs - foreach($tmp as $k => $v) - if ($v) { - - $methodstring = trigger_plugin_hook('notify:entity:message',$entity->getType(),array( - 'entity' => $object, - 'to_entity' => $user, - 'method' => $v - ),$string); - notify_user($user->guid,$object->container_guid,$descr,$methodstring,NULL,array($v)); - } + if (in_array($object->access_id,get_access_list($user->guid))) { + $tmp = (array)get_user_notification_settings($guid); + $methods = array(); + + // TODO: get the specific method to contact each user with - for now just go with their prefs + foreach($tmp as $k => $v) + if ($v) { + + $methodstring = trigger_plugin_hook('notify:entity:message',$entity->getType(),array( + 'entity' => $object, + 'to_entity' => $user, + 'method' => $v + ),$string); + notify_user($user->guid,$object->container_guid,$descr,$methodstring,NULL,array($v)); + } + } } } } -- cgit v1.2.3