]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Merged r6349:6351 from 1.7 to trunk.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Jun 2010 15:41:31 +0000 (15:41 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Jun 2010 15:41:31 +0000 (15:41 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6357 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/upgrades/2010060401.php [new file with mode: 0644]
mod/groups/views/default/widgets/a_users_groups/view.php
version.php

diff --git a/engine/lib/upgrades/2010060401.php b/engine/lib/upgrades/2010060401.php
new file mode 100644 (file)
index 0000000..2106bdb
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Get each user's notify* relationships and confirm that they have a friend
+ * or member relationship depending on type. This fixes the notify relationships
+ * that were not updated to due to #1837
+ */
+
+$count = 0;
+
+$user_guids = mysql_query("SELECT guid FROM {$CONFIG->dbprefix}users_entity");
+while ($user = mysql_fetch_object($user_guids)) {
+
+       $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships WHERE guid_one=$user->guid AND relationship LIKE 'notify%'";
+       $relationships = mysql_query($query);
+       if (mysql_num_rows($relationships) == 0) {
+               // no notify relationships for this user
+               continue;
+       }
+
+       while ($obj = mysql_fetch_object($relationships)) {
+               $query = "SELECT type FROM {$CONFIG->dbprefix}entities WHERE guid=$obj->guid_two";
+               $results = mysql_query($query);
+               if (mysql_num_rows($results) == 0) {
+                       // entity doesn't exist - shouldn't be possible
+                       continue;
+               }
+
+               $entity = mysql_fetch_object($results);
+
+               switch ($entity->type) {
+                       case 'user':
+                               $relationship_type = 'friend';
+                               break;
+                       case 'group':
+                               $relationship_type = 'member';
+                               break;
+               }
+
+               if (isset($relationship_type)) {
+                               $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships
+                                                       WHERE guid_one=$user->guid AND relationship='$relationship_type'
+                                                       AND guid_two=$obj->guid_two";
+                               $results = mysql_query($query);
+                               if (mysql_num_rows($results) == 0) {
+                                       $query = "DELETE FROM {$CONFIG->dbprefix}entity_relationships WHERE id=$obj->id";
+                                       mysql_query($query);
+                                       $count++;
+                               }
+               }
+       }
+
+}
+
+if (is_callable('error_log')) {
+       error_log("Deleted $count notify relationships in upgrade");
+}
index f020e07c4f8191d7458662ed0333b92c7b2efa30..687ba7251fd8b9da7586d7a0e9df40c3300c2dd6 100644 (file)
@@ -1,50 +1,51 @@
 <?php
 
-       /**
        *  Group profile widget - this displays a users groups on their profile
        **/
+/** 
+ *  Group profile widget - this displays a users groups on their profile
+ **/
 
-       //the number of groups to display
-       $number = (int) $vars['entity']->num_display;
-       if (!$number)
-               $number = 4;
+//the number of groups to display
+$number = (int) $vars['entity']->num_display;
+if (!$number) {
+       $number = 4;
+}
 
-       //the page owner
-       $owner = $vars['entity']->owner_guid;
+//the page owner
+$owner = $vars['entity']->owner_guid;
 
-       //$groups = get_users_membership($owner);
-       //$groups = list_entities_from_relationship('member',$owner,false,'group','',0,$number,false,false,false);
+//$groups = get_users_membership($owner);
+//$groups = list_entities_from_relationship('member',$owner,false,'group','',0,$number,false,false,false);
+$groups = get_entities_from_relationship('member', $owner, false, "group", "", 0, "", $number, 0, false, 0);
 
-       $options = array(
-               'relationship' => 'member',
-               'relationship_guid' => $owner,
-               'type' => 'group',
-               'limit' => $number,
-       );
 
-       $groups = elgg_get_entities_from_relationship($options);
+if ($groups) {
 
+       echo "<div class=\"groupmembershipwidget\">";
 
-       if($groups){
-
-               echo "<div class=\"groupmembershipwidget\">";
-
-               foreach($groups as $group){
-                       $icon = elgg_view(
+       foreach ($groups as $group) {
+               $icon = elgg_view(
                                "groups/icon", array(
-                                                                       'entity' => $group,
-                                                                       'size' => 'small',
-                                                               )
-                               );
-
-                       echo "<div class=\"contentWrapper\">" . $icon . " <div class='search_listing_info'><p><span>" . $group->name . "</span><br />";
-                       echo $group->briefdescription . "</p></div><div class=\"clearfloat\"></div></div>";
+                               'entity' => $group,
+                               'size' => 'small',
+                               )
+               );
+
+               $group_link = $group->getURL();
+
+               echo <<<___END
+
+<div class="contentWrapper">
+       $icon
+       <div class="search_listing_info">
+               <p>
+                       <span><a href="$group_link">$group->name</a></span><br />
+                       $group->briefdescription
+               </p>
+       </div>
+       <div class="clearfloat"></div>
+</div>
+___END;
 
-               }
-               echo "</div>";
        }
-
-
-// echo $groups;
-
-?>
\ No newline at end of file
+       echo "</div>";
+}
index b8d0efc3fe3af0991cee77e48b0308f0708f3b13..11a678d5bc8a98a6172fdfa816ad92c14afa0d11 100644 (file)
@@ -12,7 +12,7 @@
 
 // YYYYMMDD = Elgg Date
 // XX = Interim incrementer
-$version = 2010060101;
+$version = 2010060401;
 
 // Human-friendly version name
 $release = '1.8-svn';