From 239610b7ca432c90f9082e6359b29cefa8eed9f2 Mon Sep 17 00:00:00 2001 From: Greg Froese Date: Wed, 20 May 2009 19:22:07 +0000 Subject: added highest rated view for group albums --- highestrated.php | 65 ++++++++++++++++++++++++++++++++++++++++++ languages/en.php | 1 + start.php | 6 +++- views/default/object/album.php | 6 +++- 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 highestrated.php diff --git a/highestrated.php b/highestrated.php new file mode 100644 index 000000000..e9f0296e2 --- /dev/null +++ b/highestrated.php @@ -0,0 +1,65 @@ +username); + } + }*/ + +// if (is_null(page_owner_entity()->name) || page_owner_entity()->name == '') { +// $groupname = get_input('username'); +// } else { +// $groupname = page_owner_entity()->name; +// }; +// + //there has to be a better way to do this + if(!$groupname) { + $page = get_input("page"); + list($pagename, $groupname) = split("/", $page); + } + + list($group_holder, $album_id) = split(":", $groupname); +// echo "
page: $page\ngroup: $groupname\nalbum: $album_id"; die;
+	
+	$user = get_user_by_username($friendname);
+	global $CONFIG;
+	$prefix = $CONFIG->dbprefix;
+	$max = 24;
+
+	$sql = "SELECT ent.guid, count(1) as mycount, avg(ms2.string) as average
+			FROM " . $prefix . "entities ent
+			INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id
+			AND sub.subtype = 'image' AND  ent.container_guid = $album_id
+			INNER JOIN " . $prefix . "annotations ann1 ON ann1.entity_guid = ent.guid
+			INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id
+			AND ms.string = 'generic_rate'
+			INNER JOIN " . $prefix . "metastrings ms2 ON ms2.id = ann1.value_id
+			INNER JOIN " . $prefix . "users_entity u ON ann1.owner_guid = u.guid			
+			GROUP BY ent.guid HAVING mycount > 1
+			ORDER BY average DESC
+			LIMIT $max";
+	
+	$result = get_data($sql);
+
+	$entities = array();
+	foreach($result as $entity) {
+		$entities[] = get_entity($entity->guid);
+	}
+	
+	$album = get_entity($album_id);
+	$title = $album["title"] . ": " . elgg_echo("tidypics:highestrated");
+	$area2 = elgg_view_title($title);
+	$area2 .= elgg_view_entity_list($entities, $max, 0, $max);
+	$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+	page_draw($title, $body);
+
+?>
\ No newline at end of file
diff --git a/languages/en.php b/languages/en.php
index dbf98eb5d..094b5aa4c 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -32,6 +32,7 @@
 			'tidypics:yourmostrecent' => 'Your most recent images',
 			'tidypics:friendmostviewed' => "%s's most viewed images",
 			'tidypics:friendmostrecent' => "%s's most recent images",
+			'tidypics:highestrated' => "Highest Rated Images",
 	
 		//settings
 			'tidypics:image_lib' => "Image Library",
diff --git a/start.php b/start.php
index 6c22df63b..1881b1d31 100644
--- a/start.php
+++ b/start.php
@@ -257,6 +257,11 @@
 					if (isset($page[1])) set_input('guid',$page[1]);
 					include($CONFIG->pluginspath . "tidypics/recentlyviewed.php");
 				break;
+				
+				case "highestrated":
+					if (isset($page[1])) set_input('guid',$page[1]);
+					include($CONFIG->pluginspath . "tidypics/highestrated.php");
+				break;
 			}
 		}
 		else
@@ -343,6 +348,5 @@
 	register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php");
 	register_action("tidypics/download", true, $CONFIG->pluginspath . "tidypics/actions/download.php");
 	register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php");
-	register_action("tidypics/rate", true, $CONFIG->pluginspath . "tidypics/actions/rate.php");
 
 ?>
\ No newline at end of file
diff --git a/views/default/object/album.php b/views/default/object/album.php
index bee379666..acceaac91 100644
--- a/views/default/object/album.php
+++ b/views/default/object/album.php
@@ -57,7 +57,11 @@
 		}
 		
 	} else {							
-		// individual album view	
+		// individual album view
+		$page = get_input("page");
+		list($album_placeholder, $album_id, $album_title) = split("/", $page);
+		add_submenu_item(	elgg_echo("tidypics:highestrated"),
+							$CONFIG->wwwroot . "pg/photos/highestrated/group:" . $album_id);
 ?>
 
-- cgit v1.2.3