]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
method to get the site owner
authorEvan Prodromou <evan@status.net>
Fri, 29 Jan 2010 20:15:23 +0000 (15:15 -0500)
committerEvan Prodromou <evan@status.net>
Fri, 29 Jan 2010 20:15:23 +0000 (15:15 -0500)
classes/User.php

index 6ea975202d2c732427a930a54451e647263605f3..b70049617841fe10fe32e3d8c581e45852084e80 100644 (file)
@@ -925,4 +925,30 @@ class User extends Memcached_DataObject
             return $share;
         }
     }
+
+    static function siteOwner()
+    {
+        $owner = self::cacheGet('user:site_owner');
+
+        if ($owner === false) { // cache miss
+
+            $pr = new Profile_role();
+
+            $pr->role = Profile_role::OWNER;
+
+            $pr->orderBy('created');
+
+            $pr->limit(0, 1);
+
+            if ($pr->fetch($true)) {
+                $owner = User::staticGet('id', $pr->profile_id);
+            } else {
+                $owner = null;
+            }
+
+            self::cacheSet('user:site_owner', $owner);
+        }
+
+        return $owner;
+    }
 }