]> git.mxchange.org Git - friendica.git/commitdiff
Remove resourceid parameter from Photo::exists()
authorfabrixxm <fabrix.xm@gmail.com>
Wed, 12 Dec 2018 07:12:34 +0000 (08:12 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 21 Jan 2019 14:12:29 +0000 (09:12 -0500)
include/api.php
mod/item.php
src/Model/Photo.php

index 5a2248e6e7088060275bfc42b59168cd43d703e7..9c184411034eb7c2a7abd1414956105c091ff1a8 100644 (file)
@@ -3995,7 +3995,7 @@ function api_fr_photoalbum_update($type)
                throw new BadRequestException("no new albumname specified");
        }
        // check if album is existing
-       if (!Photo::exists(null, ['uid' => api_user(), 'album' => $album])) {
+       if (!Photo::exists(['uid' => api_user(), 'album' => $album])) {
                throw new BadRequestException("album not available");
        }
        // now let's update all photos to the albumname
@@ -4100,7 +4100,7 @@ function api_fr_photo_create_update($type)
                $mode = "update";
 
                // check if photo is existing in databasei
-               if (!Photo::exists($photo_id, ['uid' => api_user(), 'album' => $album])) {
+               if (!Photo::exists(['resource-id' => $photo_id, 'uid' => api_user(), 'album' => $album])) {
                        throw new BadRequestException("photo not available");
                }
        }
@@ -4211,7 +4211,7 @@ function api_fr_photo_delete($type)
                throw new BadRequestException("no photo_id specified");
        }
        // check if photo is existing in database
-       $r = Photo::exists($photo_id, ['uid' => api_user()]);
+       $r = Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()]);
        if (!$r) {
                throw new BadRequestException("photo not available");
        }
index cc9de0dd60bb114fc7d44f567d8260bfb8b8fb58..62b088a04fe6f9716cba30f9f4178282332d8626 100644 (file)
@@ -459,9 +459,9 @@ function item_post(App $a) {
 
                                $condition = [
                                        'allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
-                                       'uid' => $profile_uid
+                                       'resource-id' => $image_uri, 'uid' => $profile_uid
                                ];
-                               if (!Photo::exists($image_uri, $condition)) {
+                               if (!Photo::exists($condition)) {
                                        continue;
                                }
 
index 1b308794566fdfcf1c02c51d4d599df297d3de83..7eb7bb26accfb5983250ef5cfd5a6a8a77c8a962 100644 (file)
@@ -147,20 +147,12 @@ class Photo extends BaseObject
        /**
         * @brief Check if photo with given resource id exists
         *
-        * @param string  $resourceid  Resource ID of the photo
         * @param array   $conditions  Array of extra conditions. Optional
         *
         * @return boolean
         */
-       public static function exists($resourceid, array $conditions = [])
+       public static function exists(array $conditions = [])
        {
-               if (!is_null($resourceid)) {
-                       $conditions["resource-id"] = $resourceid;
-               }
-               if (count($conditions) == 0) {
-                       // no conditions defined. return false
-                       return false;
-               }
                return DBA::count("photo", $conditions) > 0;
        }