]> git.mxchange.org Git - friendica.git/commitdiff
Reworked permission stuff
authorMichael <heluecht@pirati.ca>
Sat, 21 Mar 2020 18:30:40 +0000 (18:30 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 21 Mar 2020 18:30:40 +0000 (18:30 +0000)
mod/item.php
src/Model/Photo.php

index c18941471096561c901791da954bcb133c896de2..99251a4a47dfaf11b7bfa38be49b78b434c0bbf9 100644 (file)
@@ -244,10 +244,10 @@ function item_post(App $a) {
        $body = preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $body);
 
        if (!empty($orig_post)) {
-               $str_group_allow   = $orig_post['allow_gid'] ?? '';
-               $str_contact_allow = $orig_post['allow_cid'] ?? '';
-               $str_group_deny    = $orig_post['deny_gid']  ?? '';
-               $str_contact_deny  = $orig_post['deny_cid']  ?? '';
+               $str_group_allow   = $orig_post['allow_gid'];
+               $str_contact_allow = $orig_post['allow_cid'];
+               $str_group_deny    = $orig_post['deny_gid'];
+               $str_contact_deny  = $orig_post['deny_cid'];
                $location          = $orig_post['location'];
                $coord             = $orig_post['coord'];
                $verb              = $orig_post['verb'];
index fa3ffe81b368bda326a22f3f83b8bda18cfcb490..34fd37a9de52bf0cdcd6f21f41bbbb25ea56767a 100644 (file)
@@ -298,14 +298,6 @@ class Photo
                        $backend_ref = $storage->put($Image->asString(), $backend_ref);
                }
 
-               // Prevent "null" permissions
-               if (!empty($uid)) {
-                       $allow_cid = $allow_cid ?? '<' . $uid . '>';
-                       $allow_gid = $allow_gid ?? '';
-                       $deny_cid = $deny_cid ?? '';
-                       $deny_gid = $deny_gid ?? '';
-               }
-
                $fields = [
                        "uid" => $uid,
                        "contact-id" => $cid,
@@ -662,20 +654,13 @@ class Photo
                                continue;
                        }
 
-                       if (DI::pConfig()->get($uid, 'system', 'accessible-photos')) {
-                               $condition = ['resource-id' => $image_rid, 'uid' => $uid];
-                               Logger::info('Set accessibility', ['condition' => $condition]);
-                               Photo::update(['accessible' => true], $condition);
-                       }
-
                        // 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)) {
                                continue;
                        }
@@ -688,7 +673,8 @@ class Photo
                         */
 
                        $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
-                                       'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
+                                       '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]);