aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Photo.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-10-12 12:13:44 +0200
committerMario Vavti <mario@mariovavti.com>2016-10-12 12:13:44 +0200
commitcf547be1d6900d12719a9372cbc1a5d433d31863 (patch)
tree03a525cf40905adafc21b0c4146e467bad288437 /Zotlabs/Module/Photo.php
parent29617737ca2c03c800ebbe4701dc21cf9f25ce22 (diff)
parent16da1a4e810889448eecbd13d68183a820bcebe2 (diff)
downloadvolse-hubzilla-cf547be1d6900d12719a9372cbc1a5d433d31863.tar.gz
volse-hubzilla-cf547be1d6900d12719a9372cbc1a5d433d31863.tar.bz2
volse-hubzilla-cf547be1d6900d12719a9372cbc1a5d433d31863.zip
Merge branch '1.14RC'
Diffstat (limited to 'Zotlabs/Module/Photo.php')
-rw-r--r--Zotlabs/Module/Photo.php57
1 files changed, 40 insertions, 17 deletions
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 66aaec49f..4332fd6e9 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -59,20 +59,33 @@ class Photo extends \Zotlabs\Web\Controller {
}
$uid = $person;
-
- $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1",
- intval($resolution),
- intval($uid),
- intval(PHOTO_PROFILE)
- );
- if($r) {
- $data = dbunescbin($r[0]['content']);
- $mimetype = $r[0]['mimetype'];
+
+ $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ];
+ call_hooks('get_profile_photo',$d);
+
+ $resolution = $d['imgscale'];
+ $uid = $d['channel_id'];
+ $default = $d['default'];
+ $data = $d['data'];
+ $mimetype = $d['mimetype'];
+
+ if(! $data) {
+ $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1",
+ intval($resolution),
+ intval($uid),
+ intval(PHOTO_PROFILE)
+ );
+ if($r) {
+ $data = dbunescbin($r[0]['content']);
+ $mimetype = $r[0]['mimetype'];
+ }
+ if(intval($r[0]['os_storage']))
+ $data = file_get_contents($data);
}
- if(intval($r[0]['os_storage']))
- $data = file_get_contents($data);
- if(! isset($data)) {
+ if(! $data) {
$data = file_get_contents($default);
+ }
+ if(! $mimetype) {
$mimetype = 'image/png';
}
}
@@ -88,6 +101,7 @@ class Photo extends \Zotlabs\Web\Controller {
Project link: https://github.com/Retina-Images/Retina-Images
License link: http://creativecommons.org/licenses/by/3.0/
*/
+
$cookie_value = false;
if (isset($_COOKIE['devicePixelRatio'])) {
$cookie_value = intval($_COOKIE['devicePixelRatio']);
@@ -114,15 +128,15 @@ class Photo extends \Zotlabs\Web\Controller {
}
// If using resolution 1, make sure it exists before proceeding:
- if ($resolution == 1)
- {
+ if($resolution == 1) {
$r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),
intval($resolution)
- );
- if (!($r))
+ );
+ if(! $r) {
$resolution = 2;
- }
+ }
+ }
$r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),
@@ -133,7 +147,16 @@ class Photo extends \Zotlabs\Web\Controller {
$allowed = (($r[0]['uid']) ? perm_is_allowed($r[0]['uid'],$observer_xchan,'view_storage') : true);
$sql_extra = permissions_sql($r[0]['uid']);
+
+ if(! $sql_extra)
+ $sql_extra = ' and true ';
+
+ // Only check permissions on normal photos. Those photos we don't check includes
+ // profile photos, xchan photos (which are also profile photos), 'thing' photos,
+ // and cover photos
+ $sql_extra = " and (( photo_usage = 0 $sql_extra ) or photo_usage != 0 )";
+
$channel = channelx_by_n($r[0]['uid']);
// Now we'll see if we can access the photo