X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=a22fcf457f09cfc994b2460d9d92ac749764738b;hb=be49a3a2b53e6ed1d08a443f1d8646c84c24c930;hp=f47a200e65fabc75ddbcd3f2489fdc8bcfd1eccb;hpb=999cdc7db90678c37eeb1f5874d993faa8ab748f;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index f47a200e65..a22fcf457f 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -41,7 +41,7 @@ use Friendica\Util\Proxy; use Friendica\Util\Strings; /** - * Class to handle photo dabatase table + * Class to handle photo database table */ class Photo { @@ -148,13 +148,14 @@ class Photo * on success, "no sign" image info, if user has no permission, * false if photo does not exists * - * @param string $resourceid Rescource ID of the photo - * @param integer $scale Scale of the photo. Defaults to 0 + * @param string $resourceid Rescource ID of the photo + * @param integer $scale Scale of the photo. Defaults to 0 + * @param integer $visitor_uid UID of the visitor * * @return boolean|array * @throws \Exception */ - public static function getPhoto(string $resourceid, int $scale = 0) + public static function getPhoto(string $resourceid, int $scale = 0, int $visitor_uid = 0) { $r = self::selectFirst(['uid'], ['resource-id' => $resourceid]); if (!DBA::isResult($r)) { @@ -165,7 +166,11 @@ class Photo $accessible = $uid ? (bool)DI::pConfig()->get($uid, 'system', 'accessible-photos', false) : false; - $sql_acl = Security::getPermissionsSQLByUserId($uid, $accessible); + if (!empty($visitor_uid) && ($uid == $visitor_uid)) { + $sql_acl = ''; + } else { + $sql_acl = Security::getPermissionsSQLByUserId($uid, $accessible); + } $conditions = ["`resource-id` = ? AND `scale` <= ? " . $sql_acl, $resourceid, $scale]; $params = ['order' => ['scale' => true]]; @@ -226,7 +231,7 @@ class Photo DBA::p( "SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`, min(`scale`) AS `hiq`, max(`scale`) AS `loq`, ANY_VALUE(`desc`) AS `desc`, ANY_VALUE(`created`) AS `created` - FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?) $sqlExtra + FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?) $sqlExtra GROUP BY `resource-id` $sqlExtra2", $values )); @@ -411,7 +416,7 @@ class Photo * @param string $allow_cid Permissions, allowed contacts. optional, default = "" * @param string $allow_gid Permissions, allowed groups. optional, default = "" * @param string $deny_cid Permissions, denied contacts.optional, default = "" - * @param string $deny_gid Permissions, denied greoup.optional, default = "" + * @param string $deny_gid Permissions, denied group.optional, default = "" * @param string $desc Photo caption. optional, default = "" * * @return boolean True on success @@ -913,7 +918,7 @@ class Photo */ public static function getResourceData(string $name): array { - $base = DI::baseUrl()->get(); + $base = DI::baseUrl(); $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name)); @@ -977,7 +982,7 @@ class Photo */ public static function isLocalPage(string $name): bool { - $base = DI::baseUrl()->get(); + $base = DI::baseUrl(); $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name)); $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);