]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Tidying up getUser calls to profiles and some events
[quix0rs-gnu-social.git] / classes / Profile.php
index 6f502c9c188ced49fa8738a21dd200179e829a93..fe8e11641989603e1067b5b8fe44380fff9e3d7d 100644 (file)
@@ -84,15 +84,28 @@ class Profile extends Managed_DataObject
 
     protected $_user = -1;  // Uninitialized value distinct from null
 
-    function getUser()
+    public function getUser()
     {
-        if (is_int($this->_user) && $this->_user == -1) {
+        if ($this->_user === -1) {
             $this->_user = User::getKV('id', $this->id);
         }
+        if (!is_a($this->_user, 'User')) {
+            throw new NoSuchUserException(array('id'=>$this->id));
+        }
 
         return $this->_user;
     }
 
+    public function isLocal()
+    {
+        try {
+            $this->getUser();
+        } catch (NoSuchUserException $e) {
+            return false;
+        }
+        return true;
+    }
+
     protected $_avatars;
 
     function getAvatar($width, $height=null)