aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/upgrades/2010071002.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-08-22 21:53:48 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-08-22 21:53:48 +0000
commitbe37104ac63cd25f2eac831ca03d6d2b19976e1c (patch)
tree5b168134f2b07933831daedd8cf2641ffb6c5c7d /engine/lib/upgrades/2010071002.php
parentd45a24be28b2eb2d0c2731708b589788a5b87215 (diff)
downloadelgg-be37104ac63cd25f2eac831ca03d6d2b19976e1c.tar.gz
elgg-be37104ac63cd25f2eac831ca03d6d2b19976e1c.tar.bz2
Merged r6684:6694 from 1.7 branch to trunk (pages plugin was manually merged due to standardization of code in trunk but not branch)
git-svn-id: http://code.elgg.org/elgg/trunk@6848 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/upgrades/2010071002.php')
-rw-r--r--engine/lib/upgrades/2010071002.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/engine/lib/upgrades/2010071002.php b/engine/lib/upgrades/2010071002.php
new file mode 100644
index 000000000..cdf08c830
--- /dev/null
+++ b/engine/lib/upgrades/2010071002.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Update the notifications based on all friends and access collections
+ */
+
+// loop through all users checking collections and notifications
+global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG;
+global $NOTIFICATION_HANDLERS;
+$users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity WHERE username != ''");
+while ($user = mysql_fetch_object($users)) {
+ $DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
+
+ $user = get_entity($user->guid);
+ foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
+ $notify = "notify$method";
+ $metaname = "collections_notifications_preferences_$method";
+ $collections_preferences = $user->$metaname;
+ if (!$collections_preferences) {
+ continue;
+ }
+ if (!is_array($collections_preferences)) {
+ $collections_preferences = array($collections_preferences);
+ }
+ foreach ($collections_preferences as $collection_id) {
+ // check the all friends notifications
+ if ($collection_id == -1) {
+ $options = array(
+ 'relationship' => 'friend',
+ 'relationship_guid' => $user->guid,
+ 'limit' => 0
+ );
+ $friends = elgg_get_entities_from_relationship($options);
+ foreach ($friends as $friend) {
+ if (!check_entity_relationship($user->guid, $notify, $friend->guid)) {
+ add_entity_relationship($user->guid, $notify, $friend->guid);
+ }
+ }
+ } else {
+ $members = get_members_of_access_collection($collection_id, TRUE);
+ foreach ($members as $member) {
+ if (!check_entity_relationship($user->guid, $notify, $members)) {
+ add_entity_relationship($user->guid, $notify, $member);
+ }
+ }
+ }
+ }
+ }
+}