]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User.php
And another one has 'Action' as type-hint: onStartShowLocalNavBlock()
[quix0rs-gnu-social.git] / classes / User.php
index 7a4564c80dbb0dc5f1b21de9b30cddd4709def05..1ccbdbc2174c20128845b19247040ff9d9030ab6 100644 (file)
@@ -73,7 +73,7 @@ class User extends Managed_DataObject
                 'email' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for password recovery etc.'),
                 'incomingemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for post-by-email'),
                 'emailnotifysub' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of subscriptions'),
-                'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of favorites'),
+                'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'),
                 'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'),
                 'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'),
                 'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'),
@@ -113,7 +113,7 @@ class User extends Managed_DataObject
         );
     }
 
-    protected $_profile = null;
+    protected $_profile = array();
 
     /**
      * @return Profile
@@ -122,14 +122,14 @@ class User extends Managed_DataObject
      */
     public function getProfile()
     {
-        if (!($this->_profile instanceof Profile)) {
-            $this->_profile = Profile::getKV('id', $this->id);
-            if (!($this->_profile instanceof Profile)) {
+        if (!isset($this->_profile[$this->id])) {
+            $profile = Profile::getKV('id', $this->id);
+            if (!$profile instanceof Profile) {
                 throw new UserNoProfileException($this);
             }
+            $this->_profile[$this->id] = $profile;
         }
-
-        return $this->_profile;
+        return $this->_profile[$this->id];
     }
 
     public function getUri()
@@ -137,6 +137,11 @@ class User extends Managed_DataObject
         return $this->uri;
     }
 
+    public function getNickname()
+    {
+        return $this->getProfile()->getNickname();
+    }
+
     function isSubscribed(Profile $other)
     {
         return $this->getProfile()->isSubscribed($other);
@@ -284,7 +289,6 @@ class User extends Managed_DataObject
         // initially for sites using caching, since the initial encache
         // doesn't know about the defaults in the database.
         $user->emailnotifysub = 1;
-        $user->emailnotifyfav = 1;
         $user->emailnotifynudge = 1;
         $user->emailnotifymsg = 1;
         $user->emailnotifyattn = 1;
@@ -435,11 +439,6 @@ class User extends Managed_DataObject
         }
     }
 
-    function hasFave($notice)
-    {
-        return $this->getProfile()->hasFave($notice);
-    }
-
     function mutuallySubscribed(Profile $other)
     {
         return $this->getProfile()->mutuallySubscribed($other);
@@ -474,16 +473,6 @@ class User extends Managed_DataObject
         return $this->getProfile()->getNotices($offset, $limit, $since_id, $before_id);
     }
 
-    function favoriteNotices($own=false, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
-    {
-        return $this->getProfile()->favoriteNotices($own, $offset, $limit, $since_id, $max_id);
-    }
-
-    function blowFavesCache()
-    {
-        $this->getProfile()->blowFavesCache();
-    }
-
     function getSelfTags()
     {
         return Profile_tag::getTagsArray($this->id, $this->id, $this->id);
@@ -636,7 +625,7 @@ class User extends Managed_DataObject
             common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion.");
         }
 
-        $related = array('Fave',
+        $related = array(
                          'Confirm_address',
                          'Remember_me',
                          'Foreign_link',
@@ -976,18 +965,6 @@ class User extends Managed_DataObject
         return false;
     }
 
-    function conversationTree()
-    {
-        if (common_config('oldschool', 'enabled')) {
-            $osp = Old_school_prefs::getKV('user_id', $this->id);
-            if (!empty($osp)) {
-                return $osp->conversation_tree;
-            }
-        }
-
-        return false;
-    }
-
     function streamNicknames()
     {
         if (common_config('oldschool', 'enabled')) {
@@ -1012,7 +989,7 @@ class User extends Managed_DataObject
 
         $act = new Activity();
 
-        $act->actor = ActivityObject::fromProfile($profile);
+        $act->actor = $profile->asActivityObject();
         $act->verb = ActivityVerb::JOIN;
 
         $act->objects[] = $service;
@@ -1029,4 +1006,14 @@ class User extends Managed_DataObject
                                 $service->title);
         return $act;
     }
+
+    public function getPref($namespace, $topic, $default=null)
+    {
+        return $this->getProfile()->getPref($namespace, $topic, $default);
+    }
+
+    public function setPref($namespace, $topic, $data)
+    {
+        return $this->getProfile()->setPref($namespace, $topic, $data);
+    }
 }