aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/upgrades/2010060401.php57
-rw-r--r--mod/groups/views/default/widgets/a_users_groups/view.php77
-rw-r--r--version.php2
3 files changed, 97 insertions, 39 deletions
diff --git a/engine/lib/upgrades/2010060401.php b/engine/lib/upgrades/2010060401.php
new file mode 100644
index 000000000..2106bdbc0
--- /dev/null
+++ b/engine/lib/upgrades/2010060401.php
@@ -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");
+}
diff --git a/mod/groups/views/default/widgets/a_users_groups/view.php b/mod/groups/views/default/widgets/a_users_groups/view.php
index f020e07c4..687ba7251 100644
--- a/mod/groups/views/default/widgets/a_users_groups/view.php
+++ b/mod/groups/views/default/widgets/a_users_groups/view.php
@@ -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>";
+}
diff --git a/version.php b/version.php
index b8d0efc3f..11a678d5b 100644
--- a/version.php
+++ b/version.php
@@ -12,7 +12,7 @@
// YYYYMMDD = Elgg Date
// XX = Interim incrementer
-$version = 2010060101;
+$version = 2010060401;
// Human-friendly version name
$release = '1.8-svn';