aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-23 21:24:23 -0700
committerfriendica <info@friendica.com>2012-10-23 21:24:23 -0700
commit968b9ce1af797ad422e26eb35bd58fc4ebd8c4b3 (patch)
treed95c068957657b11ba08ea67052454b0cdf8b593 /mod
parent8e8482355baa55a5c9e3cb3553eecf5a733e2897 (diff)
downloadvolse-hubzilla-968b9ce1af797ad422e26eb35bd58fc4ebd8c4b3.tar.gz
volse-hubzilla-968b9ce1af797ad422e26eb35bd58fc4ebd8c4b3.tar.bz2
volse-hubzilla-968b9ce1af797ad422e26eb35bd58fc4ebd8c4b3.zip
more heavy lifting
Diffstat (limited to 'mod')
-rw-r--r--mod/photo.php57
-rw-r--r--mod/photos.php18
2 files changed, 36 insertions, 39 deletions
diff --git a/mod/photo.php b/mod/photo.php
index 94354af24..5033033ff 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -10,12 +10,8 @@ function photo_init(&$a) {
switch(argc()) {
case 4:
$person = argv(3);
- $customres = intval(argv(2));
- $type = argv(1);
- break;
- case 3:
- $person = argv(2);
- $type = argv(1);
+ $res = argv(2);
+ $type = argv(1);
break;
case 2:
$photo = argv(1);
@@ -35,26 +31,27 @@ function photo_init(&$a) {
* Profile photos
*/
- switch($type) {
-
- case 'profile':
- case 'custom':
- $resolution = 4;
- break;
- case 'micro':
- $resolution = 6;
- $default = 'images/person-48.jpg';
- break;
- case 'avatar':
- default:
- $resolution = 5;
- $default = 'images/person-80.jpg';
- break;
+ if($type === 'profile') {
+ switch($res) {
+
+ case 'm':
+ $resolution = 5;
+ $default = 'images/person-80.jpg';
+ break;
+ case 's':
+ $resolution = 6;
+ $default = 'images/person-48.jpg';
+ break;
+ case 'l':
+ default:
+ $resolution = 4;
+ break;
+ }
}
$uid = $person;
- $r = q("SELECT * FROM `photo` WHERE `scale` = %d AND `uid` = %d AND `profile` = 1 LIMIT 1",
+ $r = q("SELECT * FROM photo WHERE scale = %d AND uid = %d AND profile = 1 LIMIT 1",
intval($resolution),
intval($uid)
);
@@ -74,16 +71,16 @@ function photo_init(&$a) {
*/
$resolution = 0;
- foreach( Photo::supportedTypes() as $m=>$e){
- $photo = str_replace(".$e",'',$photo);
- }
+
+ if(strpos($photo,'.') !== false)
+ $photo = substr($photo,0,strpos($photo,'.'));
if(substr($photo,-2,1) == '-') {
$resolution = intval(substr($photo,-1,1));
$photo = substr($photo,0,-2);
}
- $r = q("SELECT `uid` FROM `photo` WHERE `resource_id` = '%s' AND `scale` = %d LIMIT 1",
+ $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND scale = %d LIMIT 1",
dbesc($photo),
intval($resolution)
);
@@ -93,7 +90,7 @@ function photo_init(&$a) {
// Now we'll see if we can access the photo
- $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `scale` = %d $sql_extra LIMIT 1",
+ $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND scale = %d $sql_extra LIMIT 1",
dbesc($photo),
intval($resolution)
);
@@ -149,10 +146,10 @@ function photo_init(&$a) {
}
}
- if(isset($customres) && $customres > 0 && $customres < 500) {
+ if(isset($res) && intval($res) && $res < 500) {
$ph = new Photo($data, $mimetype);
if($ph->is_valid()) {
- $ph->scaleImageSquare($customres);
+ $ph->scaleImageSquare($res);
$data = $ph->imageString();
$mimetype = $ph->getType();
}
@@ -167,7 +164,7 @@ function photo_init(&$a) {
header_remove('pragma');
}
- header("Content-type: ".$mimetype);
+ header("Content-type: " . $mimetype);
if($prvcachecontrol) {
diff --git a/mod/photos.php b/mod/photos.php
index 350b4bcd5..cca68da7b 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -14,28 +14,28 @@ function photos_init(&$a) {
}
$o = '';
- if($a->argc > 1) {
- $nick = $a->argv[1];
- $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
+ if(argc() > 1) {
+ $nick = argv(1);
+ $r = q("SELECT * FROM channel WHERE channel_address = '%s' LIMIT 1",
dbesc($nick)
);
- if(! count($r))
+ if(! ($r && count($r)))
return;
- $a->data['user'] = $r[0];
+ $a->data['channel'] = $r[0];
- $sql_extra = permissions_sql($a->data['user']['uid']);
+ $sql_extra = permissions_sql($a->data['channel']['channel_id']);
$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc",
- intval($a->data['user']['uid'])
+ intval($a->data['channel']['channel_id'])
);
if(count($albums)) {
$a->data['albums'] = $albums;
-
+// FIXME
$o .= '<div class="vcard">';
- $o .= '<div class="fn">' . $a->data['user']['username'] . '</div>';
+ $o .= '<div class="fn">' . $a->data['channel']['channel_name'] . '</div>';
$o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid']) . '" alt="' . $a->data['user']['username'] . '" /></div>';
$o .= '</div>';