]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Merge branch '1.0.x' into testing
[quix0rs-gnu-social.git] / classes / Profile.php
index ac008877c4bcae1d18ac3656e00913a0e054b3bf..b9c50905a79e6dd06a3b35d01f6f7e660204d7ff 100644 (file)
@@ -68,9 +68,17 @@ class Profile extends Memcached_DataObject
         if (is_null($height)) {
             $height = $width;
         }
-        return Avatar::pkeyGet(array('profile_id' => $this->id,
-                                     'width' => $width,
-                                     'height' => $height));
+
+        $avatar = null;
+
+        if (Event::handle('StartProfileGetAvatar', array($this, $width, &$avatar))) {
+            $avatar = Avatar::pkeyGet(array('profile_id' => $this->id,
+                                            'width' => $width,
+                                            'height' => $height));
+            Event::handle('EndProfileGetAvatar', array($this, $width, &$avatar));
+        }
+
+        return $avatar;
     }
 
     function getOriginalAvatar()
@@ -1304,4 +1312,53 @@ class Profile extends Memcached_DataObject
 
         return true;
     }
+
+    static function current()
+    {
+        $user = common_current_user();
+        if (empty($user)) {
+            $profile = null;
+        } else {
+            $profile = $user->getProfile();
+        }
+        return $profile;
+    }
+
+    function getLists()
+    {
+        $ids = array();
+
+        $keypart = sprintf('profile:lists:%d', $this->id);
+
+        $idstr = self::cacheGet($keypart);
+
+        if ($idstr !== false) {
+            $ids = explode(',', $idstr);
+        } else {
+            $list = new Profile_list();
+            $list->selectAdd();
+            $list->selectAdd('id');
+            $list->tagger = $this->id;
+            
+            if ($list->find()) {
+                while ($list->fetch()) {
+                    $ids[] = $list->id;
+                }
+            }
+
+            self::cacheSet($keypart, implode(',', $ids));
+        }
+
+        $lists = array();
+
+        foreach ($ids as $id) {
+            $list = Profile_list::staticGet('id', $id);
+            if (!empty($list) && 
+                ($showPrivate || !$list->private)) {
+                $lists[] = $list;
+            }
+        }
+
+        return new ArrayWrapper($lists);
+    }
 }