]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Correct content now ... :-(
[quix0rs-gnu-social.git] / classes / Notice.php
index e155ccfcc0a86f8e84b5f9f4abe92cfe53e2b664..83d5d5fd577e73cb953ccf31c45915e1c900b8f2 100644 (file)
@@ -2666,6 +2666,11 @@ class Notice extends Managed_DataObject
                 ($this->is_local != Notice::GATEWAY));
     }
 
+    public function isPrivateScope () {
+        return ($this->scope != Notice::SITE_SCOPE &&
+                $this->scope != Notice::PUBLIC_SCOPE);
+    }
+
     /**
      * Check that the given profile is allowed to read, respond to, or otherwise
      * act on this notice.
@@ -2936,4 +2941,37 @@ class Notice extends Managed_DataObject
             $notice->_setReplies($ids);
         }
     }
+
+    /**
+     * Checks whether the current profile is allowed (in scope) to see this notice.
+     *
+     * @return $inScope Whether the current profile is allowed to see this notice
+     */
+    function isCurrentProfileInScope () {
+        // Check scope, default is allowed
+        $inScope = TRUE;
+
+        //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] this->tag=' . $this->tag . ',this->id=' . $this->id . ',this->scope=' . $this->scope);
+
+        // Is it private scope?
+        if ($this->isPrivateScope()) {
+            // 2) Get current profile
+            $profile = Profile::current();
+
+            // Is the profile not set?
+            if (!$profile instanceof Profile) {
+                // Public viewer shall not see a tag from a private dent (privacy leak)
+                //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] Not logged in (public view).');
+                $inScope = FALSE;
+            } elseif (!$this->inScope($profile)) {
+                // Current profile is not in scope (not allowed to see) of notice
+                //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] profile->id=' . $profile->id . ' is not allowed to see this notice.');
+                $inScope = FALSE;
+            }
+        }
+
+        // Return result
+        //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] this->tag=' . $this->tag . ',this->weight=' . $this->weight . ',inScope=' . intval($inScope) . ' - EXIT!');
+        return $inScope;
+    }
 }