]> git.mxchange.org Git - friendica.git/blob - src/Model/Photo.php
Introduce new DI container
[friendica.git] / src / Model / Photo.php
1 <?php
2
3 /**
4  * @file src/Model/Photo.php
5  * @brief This file contains the Photo class for database interface
6  */
7 namespace Friendica\Model;
8
9 use Friendica\BaseObject;
10 use Friendica\Core\Cache;
11 use Friendica\Core\Config;
12 use Friendica\Core\L10n;
13 use Friendica\Core\Logger;
14 use Friendica\Core\StorageManager;
15 use Friendica\Core\System;
16 use Friendica\Database\DBA;
17 use Friendica\Database\DBStructure;
18 use Friendica\DI;
19 use Friendica\Model\Storage\IStorage;
20 use Friendica\Object\Image;
21 use Friendica\Util\DateTimeFormat;
22 use Friendica\Util\Images;
23 use Friendica\Util\Network;
24 use Friendica\Util\Security;
25 use Friendica\Util\Strings;
26
27 require_once "include/dba.php";
28
29 /**
30  * Class to handle photo dabatase table
31  */
32 class Photo extends BaseObject
33 {
34         /**
35          * @brief Select rows from the photo table and returns them as array
36          *
37          * @param array $fields     Array of selected fields, empty for all
38          * @param array $conditions Array of fields for conditions
39          * @param array $params     Array of several parameters
40          *
41          * @return boolean|array
42          *
43          * @throws \Exception
44          * @see   \Friendica\Database\DBA::selectToArray
45          */
46         public static function selectToArray(array $fields = [], array $conditions = [], array $params = [])
47         {
48                 if (empty($fields)) {
49                         $fields = self::getFields();
50                 }
51
52                 return DBA::selectToArray('photo', $fields, $conditions, $params);
53         }
54
55         /**
56          * @brief Retrieve a single record from the photo table
57          *
58          * @param array $fields     Array of selected fields, empty for all
59          * @param array $conditions Array of fields for conditions
60          * @param array $params     Array of several parameters
61          *
62          * @return bool|array
63          *
64          * @throws \Exception
65          * @see   \Friendica\Database\DBA::select
66          */
67         public static function selectFirst(array $fields = [], array $conditions = [], array $params = [])
68         {
69                 if (empty($fields)) {
70                         $fields = self::getFields();
71                 }
72
73                 return DBA::selectFirst("photo", $fields, $conditions, $params);
74         }
75
76         /**
77          * @brief Get photos for user id
78          *
79          * @param integer $uid        User id
80          * @param string  $resourceid Rescource ID of the photo
81          * @param array   $conditions Array of fields for conditions
82          * @param array   $params     Array of several parameters
83          *
84          * @return bool|array
85          *
86          * @throws \Exception
87          * @see   \Friendica\Database\DBA::select
88          */
89         public static function getPhotosForUser($uid, $resourceid, array $conditions = [], array $params = [])
90         {
91                 $conditions["resource-id"] = $resourceid;
92                 $conditions["uid"] = $uid;
93
94                 return self::selectToArray([], $conditions, $params);
95         }
96
97         /**
98          * @brief Get a photo for user id
99          *
100          * @param integer $uid        User id
101          * @param string  $resourceid Rescource ID of the photo
102          * @param integer $scale      Scale of the photo. Defaults to 0
103          * @param array   $conditions Array of fields for conditions
104          * @param array   $params     Array of several parameters
105          *
106          * @return bool|array
107          *
108          * @throws \Exception
109          * @see   \Friendica\Database\DBA::select
110          */
111         public static function getPhotoForUser($uid, $resourceid, $scale = 0, array $conditions = [], array $params = [])
112         {
113                 $conditions["resource-id"] = $resourceid;
114                 $conditions["uid"] = $uid;
115                 $conditions["scale"] = $scale;
116
117                 return self::selectFirst([], $conditions, $params);
118         }
119
120         /**
121          * @brief Get a single photo given resource id and scale
122          *
123          * This method checks for permissions. Returns associative array
124          * on success, "no sign" image info, if user has no permission,
125          * false if photo does not exists
126          *
127          * @param string  $resourceid Rescource ID of the photo
128          * @param integer $scale      Scale of the photo. Defaults to 0
129          *
130          * @return boolean|array
131          * @throws \Exception
132          */
133         public static function getPhoto($resourceid, $scale = 0)
134         {
135                 $r = self::selectFirst(["uid"], ["resource-id" => $resourceid]);
136                 if (!DBA::isResult($r)) {
137                         return false;
138                 }
139
140                 $uid = $r["uid"];
141
142                 $sql_acl = Security::getPermissionsSQLByUserId($uid);
143
144                 $conditions = ["`resource-id` = ? AND `scale` <= ? " . $sql_acl, $resourceid, $scale];
145                 $params = ["order" => ["scale" => true]];
146                 $photo = self::selectFirst([], $conditions, $params);
147
148                 return $photo;
149         }
150
151         /**
152          * @brief Check if photo with given conditions exists
153          *
154          * @param array $conditions Array of extra conditions
155          *
156          * @return boolean
157          * @throws \Exception
158          */
159         public static function exists(array $conditions)
160         {
161                 return DBA::exists("photo", $conditions);
162         }
163
164
165         /**
166          * @brief Get Image object for given row id. null if row id does not exist
167          *
168          * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
169          *
170          * @return \Friendica\Object\Image
171          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
172          * @throws \ImagickException
173          */
174         public static function getImageForPhoto(array $photo)
175         {
176                 $data = "";
177
178                 if ($photo["backend-class"] == "") {
179                         // legacy data storage in "data" column
180                         $i = self::selectFirst(["data"], ["id" => $photo["id"]]);
181                         if ($i === false) {
182                                 return null;
183                         }
184                         $data = $i["data"];
185                 } else {
186                         $backendClass = $photo["backend-class"];
187                         $backendRef = $photo["backend-ref"];
188                         $data = $backendClass::get($backendRef);
189                 }
190
191                 if ($data === "") {
192                         return null;
193                 }
194
195                 return new Image($data, $photo["type"]);
196         }
197
198         /**
199          * @brief Return a list of fields that are associated with the photo table
200          *
201          * @return array field list
202          * @throws \Exception
203          */
204         private static function getFields()
205         {
206                 $allfields = DBStructure::definition(DI::app()->getBasePath(), false);
207                 $fields = array_keys($allfields["photo"]["fields"]);
208                 array_splice($fields, array_search("data", $fields), 1);
209                 return $fields;
210         }
211
212         /**
213          * @brief Construct a photo array for a system resource image
214          *
215          * @param string $filename Image file name relative to code root
216          * @param string $mimetype Image mime type. Defaults to "image/jpeg"
217          *
218          * @return array
219          * @throws \Exception
220          */
221         public static function createPhotoForSystemResource($filename, $mimetype = "image/jpeg")
222         {
223                 $fields = self::getFields();
224                 $values = array_fill(0, count($fields), "");
225
226                 $photo = array_combine($fields, $values);
227                 $photo["backend-class"] = Storage\SystemResource::class;
228                 $photo["backend-ref"] = $filename;
229                 $photo["type"] = $mimetype;
230                 $photo["cacheable"] = false;
231
232                 return $photo;
233         }
234
235
236         /**
237          * @brief store photo metadata in db and binary in default backend
238          *
239          * @param Image   $Image     Image object with data
240          * @param integer $uid       User ID
241          * @param integer $cid       Contact ID
242          * @param integer $rid       Resource ID
243          * @param string  $filename  Filename
244          * @param string  $album     Album name
245          * @param integer $scale     Scale
246          * @param integer $profile   Is a profile image? optional, default = 0
247          * @param string  $allow_cid Permissions, allowed contacts. optional, default = ""
248          * @param string  $allow_gid Permissions, allowed groups. optional, default = ""
249          * @param string  $deny_cid  Permissions, denied contacts.optional, default = ""
250          * @param string  $deny_gid  Permissions, denied greoup.optional, default = ""
251          * @param string  $desc      Photo caption. optional, default = ""
252          *
253          * @return boolean True on success
254          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
255          */
256         public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = "", $allow_gid = "", $deny_cid = "", $deny_gid = "", $desc = "")
257         {
258                 $photo = self::selectFirst(["guid"], ["`resource-id` = ? AND `guid` != ?", $rid, ""]);
259                 if (DBA::isResult($photo)) {
260                         $guid = $photo["guid"];
261                 } else {
262                         $guid = System::createGUID();
263                 }
264
265                 $existing_photo = self::selectFirst(["id", "created", "backend-class", "backend-ref"], ["resource-id" => $rid, "uid" => $uid, "contact-id" => $cid, "scale" => $scale]);
266                 $created = DateTimeFormat::utcNow();
267                 if (DBA::isResult($existing_photo)) {
268                         $created = $existing_photo["created"];
269                 }
270
271                 // Get defined storage backend.
272                 // if no storage backend, we use old "data" column in photo table.
273                 // if is an existing photo, reuse same backend
274                 $data = "";
275                 $backend_ref = "";
276
277                 /** @var IStorage $backend_class */
278                 if (DBA::isResult($existing_photo)) {
279                         $backend_ref = (string)$existing_photo["backend-ref"];
280                         $backend_class = (string)$existing_photo["backend-class"];
281                 } else {
282                         $backend_class = StorageManager::getBackend();
283                 }
284
285                 if ($backend_class === "") {
286                         $data = $Image->asString();
287                 } else {
288                         $backend_ref = $backend_class::put($Image->asString(), $backend_ref);
289                 }
290
291
292                 $fields = [
293                         "uid" => $uid,
294                         "contact-id" => $cid,
295                         "guid" => $guid,
296                         "resource-id" => $rid,
297                         "created" => $created,
298                         "edited" => DateTimeFormat::utcNow(),
299                         "filename" => basename($filename),
300                         "type" => $Image->getType(),
301                         "album" => $album,
302                         "height" => $Image->getHeight(),
303                         "width" => $Image->getWidth(),
304                         "datasize" => strlen($Image->asString()),
305                         "data" => $data,
306                         "scale" => $scale,
307                         "profile" => $profile,
308                         "allow_cid" => $allow_cid,
309                         "allow_gid" => $allow_gid,
310                         "deny_cid" => $deny_cid,
311                         "deny_gid" => $deny_gid,
312                         "desc" => $desc,
313                         "backend-class" => $backend_class,
314                         "backend-ref" => $backend_ref
315                 ];
316
317                 if (DBA::isResult($existing_photo)) {
318                         $r = DBA::update("photo", $fields, ["id" => $existing_photo["id"]]);
319                 } else {
320                         $r = DBA::insert("photo", $fields);
321                 }
322
323                 return $r;
324         }
325
326
327         /**
328          * @brief Delete info from table and data from storage
329          *
330          * @param array $conditions Field condition(s)
331          * @param array $options    Options array, Optional
332          *
333          * @return boolean
334          *
335          * @throws \Exception
336          * @see   \Friendica\Database\DBA::delete
337          */
338         public static function delete(array $conditions, array $options = [])
339         {
340                 // get photo to delete data info
341                 $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
342
343                 foreach($photos as $photo) {
344                         /** @var IStorage $backend_class */
345                         $backend_class = (string)$photo["backend-class"];
346                         if ($backend_class !== "") {
347                                 $backend_class::delete($photo["backend-ref"]);
348                         }
349                 }
350
351                 return DBA::delete("photo", $conditions, $options);
352         }
353
354         /**
355          * @brief Update a photo
356          *
357          * @param array         $fields     Contains the fields that are updated
358          * @param array         $conditions Condition array with the key values
359          * @param Image         $img        Image to update. Optional, default null.
360          * @param array|boolean $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
361          *
362          * @return boolean  Was the update successfull?
363          *
364          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
365          * @see   \Friendica\Database\DBA::update
366          */
367         public static function update($fields, $conditions, Image $img = null, array $old_fields = [])
368         {
369                 if (!is_null($img)) {
370                         // get photo to update
371                         $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
372
373                         foreach($photos as $photo) {
374                                 /** @var IStorage $backend_class */
375                                 $backend_class = (string)$photo["backend-class"];
376                                 if ($backend_class !== "") {
377                                         $fields["backend-ref"] = $backend_class::put($img->asString(), $photo["backend-ref"]);
378                                 } else {
379                                         $fields["data"] = $img->asString();
380                                 }
381                         }
382                         $fields['updated'] = DateTimeFormat::utcNow();
383                 }
384
385                 $fields['edited'] = DateTimeFormat::utcNow();
386
387                 return DBA::update("photo", $fields, $conditions, $old_fields);
388         }
389
390         /**
391          * @param string  $image_url     Remote URL
392          * @param integer $uid           user id
393          * @param integer $cid           contact id
394          * @param boolean $quit_on_error optional, default false
395          * @return array
396          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
397          * @throws \ImagickException
398          */
399         public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
400         {
401                 $thumb = "";
402                 $micro = "";
403
404                 $photo = DBA::selectFirst(
405                         "photo", ["resource-id"], ["uid" => $uid, "contact-id" => $cid, "scale" => 4, "album" => "Contact Photos"]
406                 );
407                 if (!empty($photo['resource-id'])) {
408                         $resource_id = $photo["resource-id"];
409                 } else {
410                         $resource_id = self::newResource();
411                 }
412
413                 $photo_failure = false;
414
415                 $filename = basename($image_url);
416                 if (!empty($image_url)) {
417                         $ret = Network::curl($image_url, true);
418                         $img_str = $ret->getBody();
419                         $type = $ret->getContentType();
420                 } else {
421                         $img_str = '';
422                 }
423
424                 if ($quit_on_error && ($img_str == "")) {
425                         return false;
426                 }
427
428                 if (empty($type)) {
429                         $type = Images::guessType($image_url, true);
430                 }
431
432                 $Image = new Image($img_str, $type);
433                 if ($Image->isValid()) {
434                         $Image->scaleToSquare(300);
435
436                         $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 4);
437
438                         if ($r === false) {
439                                 $photo_failure = true;
440                         }
441
442                         $Image->scaleDown(80);
443
444                         $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 5);
445
446                         if ($r === false) {
447                                 $photo_failure = true;
448                         }
449
450                         $Image->scaleDown(48);
451
452                         $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 6);
453
454                         if ($r === false) {
455                                 $photo_failure = true;
456                         }
457
458                         $suffix = "?ts=" . time();
459
460                         $image_url = System::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix;
461                         $thumb = System::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix;
462                         $micro = System::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
463
464                         // Remove the cached photo
465                         $a = \get_app();
466                         $basepath = $a->getBasePath();
467
468                         if (is_dir($basepath . "/photo")) {
469                                 $filename = $basepath . "/photo/" . $resource_id . "-4." . $Image->getExt();
470                                 if (file_exists($filename)) {
471                                         unlink($filename);
472                                 }
473                                 $filename = $basepath . "/photo/" . $resource_id . "-5." . $Image->getExt();
474                                 if (file_exists($filename)) {
475                                         unlink($filename);
476                                 }
477                                 $filename = $basepath . "/photo/" . $resource_id . "-6." . $Image->getExt();
478                                 if (file_exists($filename)) {
479                                         unlink($filename);
480                                 }
481                         }
482                 } else {
483                         $photo_failure = true;
484                 }
485
486                 if ($photo_failure && $quit_on_error) {
487                         return false;
488                 }
489
490                 if ($photo_failure) {
491                         $image_url = System::baseUrl() . "/images/person-300.jpg";
492                         $thumb = System::baseUrl() . "/images/person-80.jpg";
493                         $micro = System::baseUrl() . "/images/person-48.jpg";
494                 }
495
496                 return [$image_url, $thumb, $micro];
497         }
498
499         /**
500          * @param array $exifCoord coordinate
501          * @param string $hemi      hemi
502          * @return float
503          */
504         public static function getGps($exifCoord, $hemi)
505         {
506                 $degrees = count($exifCoord) > 0 ? self::gps2Num($exifCoord[0]) : 0;
507                 $minutes = count($exifCoord) > 1 ? self::gps2Num($exifCoord[1]) : 0;
508                 $seconds = count($exifCoord) > 2 ? self::gps2Num($exifCoord[2]) : 0;
509
510                 $flip = ($hemi == "W" || $hemi == "S") ? -1 : 1;
511
512                 return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
513         }
514
515         /**
516          * @param string $coordPart coordPart
517          * @return float
518          */
519         private static function gps2Num($coordPart)
520         {
521                 $parts = explode("/", $coordPart);
522
523                 if (count($parts) <= 0) {
524                         return 0;
525                 }
526
527                 if (count($parts) == 1) {
528                         return $parts[0];
529                 }
530
531                 return floatval($parts[0]) / floatval($parts[1]);
532         }
533
534         /**
535          * @brief Fetch the photo albums that are available for a viewer
536          *
537          * The query in this function is cost intensive, so it is cached.
538          *
539          * @param int  $uid    User id of the photos
540          * @param bool $update Update the cache
541          *
542          * @return array Returns array of the photo albums
543          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
544          */
545         public static function getAlbums($uid, $update = false)
546         {
547                 $sql_extra = Security::getPermissionsSQLByUserId($uid);
548
549                 $key = "photo_albums:".$uid.":".local_user().":".remote_user();
550                 $albums = Cache::get($key);
551                 if (is_null($albums) || $update) {
552                         if (!Config::get("system", "no_count", false)) {
553                                 /// @todo This query needs to be renewed. It is really slow
554                                 // At this time we just store the data in the cache
555                                 $albums = q("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
556                                         FROM `photo`
557                                         WHERE `uid` = %d  AND `album` != '%s' AND `album` != '%s' $sql_extra
558                                         GROUP BY `album` ORDER BY `created` DESC",
559                                         intval($uid),
560                                         DBA::escape("Contact Photos"),
561                                         DBA::escape(L10n::t("Contact Photos"))
562                                 );
563                         } else {
564                                 // This query doesn't do the count and is much faster
565                                 $albums = q("SELECT DISTINCT(`album`), '' AS `total`
566                                         FROM `photo` USE INDEX (`uid_album_scale_created`)
567                                         WHERE `uid` = %d  AND `album` != '%s' AND `album` != '%s' $sql_extra",
568                                         intval($uid),
569                                         DBA::escape("Contact Photos"),
570                                         DBA::escape(L10n::t("Contact Photos"))
571                                 );
572                         }
573                         Cache::set($key, $albums, Cache::DAY);
574                 }
575                 return $albums;
576         }
577
578         /**
579          * @param int $uid User id of the photos
580          * @return void
581          * @throws \Exception
582          */
583         public static function clearAlbumCache($uid)
584         {
585                 $key = "photo_albums:".$uid.":".local_user().":".remote_user();
586                 Cache::set($key, null, Cache::DAY);
587         }
588
589         /**
590          * Generate a unique photo ID.
591          *
592          * @return string
593          * @throws \Exception
594          */
595         public static function newResource()
596         {
597                 return System::createGUID(32, false);
598         }
599
600         /**
601          * Changes photo permissions that had been embedded in a post
602          *
603          * @todo This function currently does have some flaws:
604          * - Sharing a post with a forum will create a photo that only the forum can see.
605          * - Sharing a photo again that been shared non public before doesn't alter the permissions.
606          *
607          * @return string
608          * @throws \Exception
609          */
610         public static function setPermissionFromBody($body, $uid, $original_contact_id, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny)
611         {
612                 // Simplify image codes
613                 $img_body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
614                 $img_body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $img_body);
615
616                 // Search for images
617                 if (!preg_match_all("/\[img\](.*?)\[\/img\]/", $img_body, $match)) {
618                         return false;
619                 }
620                 $images = $match[1];
621                 if (empty($images)) {
622                         return false;
623                 }
624
625                 foreach ($images as $image) {
626                         if (!stristr($image, System::baseUrl() . '/photo/')) {
627                                 continue;
628                         }
629                         $image_uri = substr($image,strrpos($image,'/') + 1);
630                         $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
631                         if (!strlen($image_uri)) {
632                                 continue;
633                         }
634
635                         // Ensure to only modify photos that you own
636                         $srch = '<' . intval($original_contact_id) . '>';
637
638                         $condition = [
639                                 'allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
640                                 'resource-id' => $image_uri, 'uid' => $uid
641                         ];
642                         if (!Photo::exists($condition)) {
643                                 continue;
644                         }
645
646                         /// @todo Check if $str_contact_allow does contain a public forum. Then set the permissions to public.
647
648                         $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
649                                         'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
650                         $condition = ['resource-id' => $image_uri, 'uid' => $uid];
651                         Logger::info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);
652                         Photo::update($fields, $condition);
653                 }
654
655                 return true;
656         }
657
658         /**
659          * Strips known picture extensions from picture links
660          *
661          * @param string $name Picture link
662          * @return string stripped picture link
663          * @throws \Exception
664          */
665         public static function stripExtension($name)
666         {
667                 $name = str_replace([".jpg", ".png", ".gif"], ["", "", ""], $name);
668                 foreach (Images::supportedTypes() as $m => $e) {
669                         $name = str_replace("." . $e, "", $name);
670                 }
671                 return $name;
672         }
673
674         /**
675          * Returns the GUID from picture links
676          *
677          * @param string $name Picture link
678          * @return string GUID
679          * @throws \Exception
680          */
681         public static function getGUID($name)
682         {
683                 $a = \get_app();
684                 $base = $a->getBaseURL();
685
686                 $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
687
688                 $guid = self::stripExtension($guid);
689                 if (substr($guid, -2, 1) != "-") {
690                         return '';
691                 }
692
693                 $scale = intval(substr($guid, -1, 1));
694                 if (!is_numeric($scale)) {
695                         return '';
696                 }
697
698                 $guid = substr($guid, 0, -2);
699                 return $guid;
700         }
701
702         /**
703          * Tests if the picture link points to a locally stored picture
704          *
705          * @param string $name Picture link
706          * @return boolean
707          * @throws \Exception
708          */
709         public static function isLocal($name)
710         {
711                 $guid = self::getGUID($name);
712
713                 if (empty($guid)) {
714                         return false;
715                 }
716
717                 return DBA::exists('photo', ['resource-id' => $guid]);
718         }
719
720         /**
721          * Tests if the link points to a locally stored picture page
722          *
723          * @param string $name Page link
724          * @return boolean
725          * @throws \Exception
726          */
727         public static function isLocalPage($name)
728         {
729                 $a = \get_app();
730                 $base = $a->getBaseURL();
731
732                 $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
733                 $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
734                 if (empty($guid)) {
735                         return false;
736                 }
737
738                 return DBA::exists('photo', ['resource-id' => $guid]);
739         }
740 }