]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/api.php
Merge commit 'origin/testing' into 0.9.x
[quix0rs-gnu-social.git] / lib / api.php
index 0c66501116313226159841ae8cd1d956eeff2b7f..794b14050709dddb7d9503a3cad05b829a783cce 100644 (file)
@@ -53,6 +53,9 @@ if (!defined('STATUSNET')) {
 
 class ApiAction extends Action
 {
+    const READ_ONLY  = 1;
+    const READ_WRITE = 2;
+
     var $format    = null;
     var $user      = null;
     var $auth_user = null;
@@ -62,6 +65,8 @@ class ApiAction extends Action
     var $since_id  = null;
     var $since     = null;
 
+    var $access    = self::READ_ONLY;  // read (default) or read-write
+
     /**
      * Initialization.
      *
@@ -140,12 +145,14 @@ class ApiAction extends Action
 
         // Note: some profiles don't have an associated user
 
+        $defaultDesign = Design::siteDesign();
+
         if (!empty($user)) {
             $design = $user->getDesign();
         }
 
         if (empty($design)) {
-            $design = Design::siteDesign();
+            $design = $defaultDesign;
         }
 
         $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
@@ -166,7 +173,7 @@ class ApiAction extends Action
 
         $timezone = 'UTC';
 
-        if ($user->timezone) {
+        if (!empty($user) && $user->timezone) {
             $timezone = $user->timezone;
         }
 
@@ -220,14 +227,15 @@ class ApiAction extends Action
     {
         $base = $this->twitterSimpleStatusArray($notice, $include_user);
 
-        if (empty($notice->repeat_of)) {
-            return $base;
-        } else {
+        if (!empty($notice->repeat_of)) {
             $original = Notice::staticGet('id', $notice->repeat_of);
-            $original_array = $this->twitterSimpleStatusArray($original, $include_user);
-            $original_array['retweeted_status'] = $base;
-            return $original_array;
+            if (!empty($original)) {
+                $original_array = $this->twitterSimpleStatusArray($original, $include_user);
+                $base['retweeted_status'] = $original_array;
+            }
         }
+
+        return $base;
     }
 
     function twitterSimpleStatusArray($notice, $include_user=true)
@@ -786,7 +794,7 @@ class ApiAction extends Action
 
         $from = $message->getFrom();
 
-        $entry['title'] = sprintf('Message from %s to %s',
+        $entry['title'] = sprintf('Message from %1$s to %2$s',
             $from->nickname, $message->getTo()->nickname);
 
         $entry['content'] = common_xml_safe_str($message->rendered);