From 5e077e541ae5c627a9626454f1c36b2a1470d3c4 Mon Sep 17 00:00:00 2001
From: Michael Vogel <icarus@dabo.de>
Date: Wed, 6 Feb 2013 08:01:46 +0100
Subject: [PATCH] The community page is speeded up. Photos will be compressed
 before the output.

---
 mod/community.php |  7 ++++---
 mod/photo.php     | 12 ++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/mod/community.php b/mod/community.php
index a7f5c9bf82..e267447e41 100644
--- a/mod/community.php
+++ b/mod/community.php
@@ -64,7 +64,8 @@ function community_content(&$a, $update = 0) {
 
 	}
 
-	$r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, 
+	//$r = q("SELECT distinct(`item`.`uri`)
+	$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, 
 		`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
 		`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
 		`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
@@ -75,13 +76,13 @@ function community_content(&$a, $update = 0) {
 		AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
 		AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = '' 
 		AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
-		AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+		AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
 		ORDER BY `received` DESC LIMIT %d, %d ",
 		intval($a->pager['start']),
 		intval($a->pager['itemspage'])
 
 	);
-//		AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri`
+//		group by `item`.`uri`
 
 	if(! count($r)) {
 		info( t('No results.') . EOL);
diff --git a/mod/photo.php b/mod/photo.php
index 93db82a641..c92ab387b0 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -106,7 +106,7 @@ function photo_init(&$a) {
 			intval($resolution)
 		);
 		if(count($r)) {
-			
+
 			$sql_extra = permissions_sql($r[0]['uid']);
 
 			// Now we'll see if we can access the photo
@@ -169,13 +169,13 @@ function photo_init(&$a) {
 		}
 	}
 
-	if(isset($customres) && $customres > 0 && $customres < 500) {
-		$ph = new Photo($data, $mimetype);
-		if($ph->is_valid()) {
+	$ph = new Photo($data, $mimetype);
+	if($ph->is_valid()) {
+		if(isset($customres) && $customres > 0 && $customres < 500) {
 			$ph->scaleImageSquare($customres);
-			$data = $ph->imageString();
-			$mimetype = $ph->getType();
 		}
+		$data = $ph->imageString();
+		$mimetype = $ph->getType();
 	}
 
 	if(function_exists('header_remove')) {