]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apistatusesupdate.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / actions / apistatusesupdate.php
index 898a4bd723cef157ad3e768096ac5c1134db62ce..7ddf7703bb70364acc8ffaf204e1c3d0698fd563 100644 (file)
@@ -61,6 +61,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction
     var $source                = null;
     var $status                = null;
     var $in_reply_to_status_id = null;
+    var $lat                   = null;
+    var $lon                   = null;
+
     static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
 
     /**
@@ -79,8 +82,10 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         $this->user   = $this->auth_user;
         $this->status = $this->trimmed('status');
         $this->source = $this->trimmed('source');
+        $this->lat    = $this->trimmed('lat');
+        $this->lon    = $this->trimmed('long');
 
-        if (empty($this->source) || in_array($source, $this->reserved_sources)) {
+        if (empty($this->source) || in_array($source, self::$reserved_sources)) {
             $this->source = 'api';
         }
 
@@ -112,6 +117,20 @@ class ApiStatusesUpdateAction extends ApiAuthAction
             return;
         }
 
+        // Workaround for PHP returning empty $_POST and $_FILES when POST
+        // length > post_max_size in php.ini
+
+        if (empty($_FILES)
+            && empty($_POST)
+            && ($_SERVER['CONTENT_LENGTH'] > 0)
+        ) {
+             $msg = _('The server was unable to handle that much POST ' .
+                    'data (%s bytes) due to its current configuration.');
+
+            $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
+            return;
+        }
+
         if (empty($this->status)) {
             $this->clientError(
                 'Client must provide a \'status\' parameter with a value.',
@@ -122,14 +141,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         }
 
         if (empty($this->user)) {
-            $this->clientError(_('No such user!'), 404, $this->format);
-            return;
-        }
-
-        // Workaround for PHP returning empty $_FILES when POST length > PHP settings
-
-        if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) {
-            $this->clientError(_('Unable to handle that much POST data!'));
+            $this->clientError(_('No such user.'), 404, $this->format);
             return;
         }
 
@@ -191,6 +203,12 @@ class ApiStatusesUpdateAction extends ApiAuthAction
                 }
             }
 
+            $location = null;
+
+            if (!empty($this->lat) && !empty($this->lon)) {
+                $location = Location::fromLatLon($this->lat, $this->lon);
+            }
+
             $upload = null;
 
             try {
@@ -218,7 +236,13 @@ class ApiStatusesUpdateAction extends ApiAuthAction
                 html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
                 $this->source,
                 1,
-                $reply_to
+                $reply_to,
+                null,
+                null,
+                empty($location) ? null : $location->lat,
+                empty($location) ? null : $location->lon,
+                empty($location) ? null : $location->location_id,
+                empty($location) ? null : $location->location_ns
             );
 
             if (isset($upload)) {