]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Photo.php
File and category aren't using "term" anymore
[friendica.git] / src / Model / Photo.php
index 2ac95e952dd8165a42f228694b5cb80bcad7bf25..9d8b5611f7f8b5f2543b0cc74e92521be7a6a0ba 100644 (file)
@@ -298,7 +298,6 @@ class Photo
                        $backend_ref = $storage->put($Image->asString(), $backend_ref);
                }
 
-
                $fields = [
                        "uid" => $uid,
                        "contact-id" => $cid,
@@ -433,9 +432,7 @@ class Photo
                        return false;
                }
 
-               if (empty($type)) {
-                       $type = Images::guessType($image_url, true);
-               }
+               $type = Images::getMimeTypeByData($img_str, $image_url, $type);
 
                $Image = new Image($img_str, $type);
                if ($Image->isValid()) {
@@ -658,12 +655,17 @@ class Photo
                        // Ensure to only modify photos that you own
                        $srch = '<' . intval($original_contact_id) . '>';
 
-                       $condition = ["(`allow_cid` = ? OR `allow_cid` IS NULL) AND
-                               (`allow_gid` = ? OR `allow_gid` IS NULL) AND
-                               (`deny_cid` = ? OR `deny_cid` IS NULL) AND
-                               (`deny_gid` = ? OR `deny_gid` IS NULL) AND
-                               `resource-id` = ? AND `uid` =?", $srch, '', '', '', $image_rid, $uid];
+                       $condition = [
+                               'allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
+                               'resource-id' => $image_rid, 'uid' => $uid
+                       ];
                        if (!Photo::exists($condition)) {
+                               $photo = self::selectFirst(['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'uid'], ['resource-id' => $image_rid]);
+                               if (!DBA::isResult($photo)) {
+                                       Logger::info('Image not found', ['resource-id' => $image_rid]);
+                               } else {
+                                       Logger::info('Mismatching permissions', ['condition' => $condition, 'photo' => $photo]);
+                               }
                                continue;
                        }
 
@@ -675,11 +677,8 @@ class Photo
                         */
 
                        $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
-                                       'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
-
-                       if (DI::pConfig()->get($uid, 'system', 'accessible-photos')) {
-                               $fields['accessible'] = true;
-                       }
+                                       'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
+                                       'accessible' => DI::pConfig()->get($uid, 'system', 'accessible-photos', false)];
 
                        $condition = ['resource-id' => $image_rid, 'uid' => $uid];
                        Logger::info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);