]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Merge branch 'master' into 0.9.x
[quix0rs-gnu-social.git] / classes / Profile.php
index 064ba551c4bf6de46047989e3b7a3cad8dba1a70..8dbdcbd97385395f78bdaac90c41a21226f8b998 100644 (file)
@@ -125,6 +125,14 @@ class Profile extends Memcached_DataObject
         return $avatar;
     }
 
+    /**
+     * Delete attached avatars for this user from the database and filesystem.
+     * This should be used instead of a batch delete() to ensure that files
+     * get removed correctly.
+     *
+     * @param boolean $original true to delete only the original-size file
+     * @return <type>
+     */
     function delete_avatars($original=true)
     {
         $avatar = new Avatar();
@@ -161,7 +169,7 @@ class Profile extends Memcached_DataObject
     {
         if ($this->fullname) {
             // TRANS: Full name of a profile or group followed by nickname in parens
-            return sprintf(_('%1$s (%2$s)'), $this->fullname, $this->nickname);
+            return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->fullname, $this->nickname);
         } else {
             return $this->nickname;
         }
@@ -494,6 +502,29 @@ class Profile extends Memcached_DataObject
         return $cnt;
     }
 
+    /**
+     * Is this profile subscribed to another profile?
+     *
+     * @param Profile $other
+     * @return boolean
+     */
+    function isSubscribed($other)
+    {
+        return Subscription::exists($this, $other);
+    }
+
+    /**
+     * Are these two profiles subscribed to each other?
+     *
+     * @param Profile $other
+     * @return boolean
+     */
+    function mutuallySubscribed($other)
+    {
+        return $this->isSubscribed($other) &&
+          $other->isSubscribed($this);
+    }
+
     function hasFave($notice)
     {
         $cache = common_memcache();
@@ -641,9 +672,11 @@ class Profile extends Memcached_DataObject
         $this->_deleteMessages();
         $this->_deleteTags();
         $this->_deleteBlocks();
+        $this->delete_avatars();
 
-        $related = array('Avatar',
-                         'Reply',
+        // Warning: delete() will run on the batch objects,
+        // not on individual objects.
+        $related = array('Reply',
                          'Group_member',
                          );
         Event::handle('ProfileDeleteRelated', array($this, &$related));