]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / classes / Profile.php
index d658b6b0ba997a2bc63840c1d36ea04d73b7ad92..2ad302ccb8f80aab2a61ecffec8da5dc7f3ee352 100644 (file)
@@ -354,7 +354,10 @@ class Profile extends Memcached_DataObject
         $profiles = array();
 
         while ($subs->fetch()) {
-            $profiles[] = Profile::staticGet($subs->subscribed);
+            $profile = Profile::staticGet($subs->subscribed);
+            if ($profile) {
+                $profiles[] = $profile;
+            }
         }
 
         return new ArrayWrapper($profiles);
@@ -369,7 +372,10 @@ class Profile extends Memcached_DataObject
         $profiles = array();
 
         while ($subs->fetch()) {
-            $profiles[] = Profile::staticGet($subs->subscriber);
+            $profile = Profile::staticGet($subs->subscriber);
+            if ($profile) {
+                $profiles[] = $profile;
+            }
         }
 
         return new ArrayWrapper($profiles);
@@ -746,6 +752,10 @@ class Profile extends Memcached_DataObject
                 throw new Exception("Can't save role '$name' for profile '{$this->id}'");
             }
 
+            if ($name == 'owner') {
+                User::blow('user:site_owner');
+            }
+
             Event::handle('EndGrantRole', array($this, $name));
         }
 
@@ -774,6 +784,10 @@ class Profile extends Memcached_DataObject
                 throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; database error.'),$name, $this->id));
             }
 
+            if ($name == 'owner') {
+                User::blow('user:site_owner');
+            }
+
             Event::handle('EndRevokeRole', array($this, $name));
 
             return true;
@@ -859,6 +873,12 @@ class Profile extends Memcached_DataObject
             case Right::EMAILONFAVE:
                 $result = !$this->isSandboxed();
                 break;
+            case Right::WEBLOGIN:
+                $result = !$this->isSilenced();
+                break;
+            case Right::API:
+                $result = !$this->isSilenced();
+                break;
             case Right::BACKUPACCOUNT:
                 $result = common_config('profile', 'backup');
                 break;
@@ -918,6 +938,31 @@ class Profile extends Memcached_DataObject
         return $xs->getString();
     }
 
+    /**
+     * Extra profile info for atom entries
+     *
+     * Clients use some extra profile info in the atom stream.
+     * This gives it to them.
+     *
+     * @param User $cur Current user
+     *
+     * @return array representation of <statusnet:profile_info> element or null
+     */
+
+    function profileInfo($cur)
+    {
+        $profileInfoAttr = array('local_id' => $this->id);
+
+        if ($cur != null) {
+            // Whether the current user is a subscribed to this profile
+            $profileInfoAttr['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
+            // Whether the current user is has blocked this profile
+            $profileInfoAttr['blocking']  = $cur->hasBlocked($this) ? 'true' : 'false';
+        }
+
+        return array('statusnet:profile_info', $profileInfoAttr, null);
+    }
+
     /**
      * Returns an XML string fragment with profile information as an
      * Activity Streams <activity:actor> element.