]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.8.x' into 0.9.x
authorEvan Prodromou <evan@status.net>
Tue, 29 Sep 2009 22:03:10 +0000 (18:03 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 29 Sep 2009 22:03:10 +0000 (18:03 -0400)
Conflicts:
actions/twitapistatuses.php

actions/editgroup.php
lib/clienterroraction.php
lib/error.php
lib/servererroraction.php
lib/twitterapi.php

index 0c2dc8bdf89ef027141d09d38ae1de434696bfc7..5dd039f8a30c3dc55d4d64f9994890e5e1bfe8c2 100644 (file)
@@ -250,7 +250,6 @@ class EditgroupAction extends GroupDesignAction
         $this->group->homepage    = $homepage;
         $this->group->description = $description;
         $this->group->location    = $location;
-        $this->group->created     = common_sql_now();
 
         $result = $this->group->update($orig);
 
index 7d007a75675775ee35fa67dc89ea79acb2774426..1b98a1064570d6472bfc2c553925be5d15efb3a8 100644 (file)
@@ -46,28 +46,28 @@ require_once INSTALLDIR.'/lib/error.php';
  */
 class ClientErrorAction extends ErrorAction
 {
+    static $status = array(400 => 'Bad Request',
+                           401 => 'Unauthorized',
+                           402 => 'Payment Required',
+                           403 => 'Forbidden',
+                           404 => 'Not Found',
+                           405 => 'Method Not Allowed',
+                           406 => 'Not Acceptable',
+                           407 => 'Proxy Authentication Required',
+                           408 => 'Request Timeout',
+                           409 => 'Conflict',
+                           410 => 'Gone',
+                           411 => 'Length Required',
+                           412 => 'Precondition Failed',
+                           413 => 'Request Entity Too Large',
+                           414 => 'Request-URI Too Long',
+                           415 => 'Unsupported Media Type',
+                           416 => 'Requested Range Not Satisfiable',
+                           417 => 'Expectation Failed');
+
     function __construct($message='Error', $code=400)
     {
         parent::__construct($message, $code);
-
-        $this->status  = array(400 => 'Bad Request',
-                               401 => 'Unauthorized',
-                               402 => 'Payment Required',
-                               403 => 'Forbidden',
-                               404 => 'Not Found',
-                               405 => 'Method Not Allowed',
-                               406 => 'Not Acceptable',
-                               407 => 'Proxy Authentication Required',
-                               408 => 'Request Timeout',
-                               409 => 'Conflict',
-                               410 => 'Gone',
-                               411 => 'Length Required',
-                               412 => 'Precondition Failed',
-                               413 => 'Request Entity Too Large',
-                               414 => 'Request-URI Too Long',
-                               415 => 'Unsupported Media Type',
-                               416 => 'Requested Range Not Satisfiable',
-                               417 => 'Expectation Failed');
         $this->default = 400;
     }
 
@@ -91,9 +91,4 @@ class ClientErrorAction extends ErrorAction
 
         $this->showPage();
     }
-
-    function title()
-    {
-        return $this->status[$this->code];
-    }
 }
index 0c521db08124a29d77259ae3dfb25df5dadb0f49..6a9b76be11b97391f41ac13292ed76f38bdeba2a 100644 (file)
@@ -44,9 +44,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  */
 class ErrorAction extends Action
 {
+    static $status = array();
+
     var $code    = null;
     var $message = null;
-    var $status  = null;
     var $default = null;
 
     function __construct($message, $code, $output='php://output', $indent=true)
@@ -88,9 +89,10 @@ class ErrorAction extends Action
      *
      * @return page title
      */
+
     function title()
     {
-        return $this->message;
+        return self::$status[$this->code];
     }
 
     function isReadOnly($args)
index c6400605ea9bdc1936829b8e2d92e19c3350159c..0993a63bca506149dcecddf892b6d264d4b1cd8e 100644 (file)
@@ -55,17 +55,17 @@ require_once INSTALLDIR.'/lib/error.php';
 
 class ServerErrorAction extends ErrorAction
 {
+    static $status = array(500 => 'Internal Server Error',
+                           501 => 'Not Implemented',
+                           502 => 'Bad Gateway',
+                           503 => 'Service Unavailable',
+                           504 => 'Gateway Timeout',
+                           505 => 'HTTP Version Not Supported');
+
     function __construct($message='Error', $code=500)
     {
         parent::__construct($message, $code);
 
-        $this->status  = array(500 => 'Internal Server Error',
-                               501 => 'Not Implemented',
-                               502 => 'Bad Gateway',
-                               503 => 'Service Unavailable',
-                               504 => 'Gateway Timeout',
-                               505 => 'HTTP Version Not Supported');
-
         $this->default = 500;
 
         // Server errors must be logged.
@@ -93,9 +93,4 @@ class ServerErrorAction extends ErrorAction
 
         $this->showPage();
     }
-
-    function title()
-    {
-        return $this->status[$this->code];
-    }
 }
index d199e4dee27d657e05bcadf20c3b07200706068c..4a5de6ab3af99573badeac5441c88055db71580a 100644 (file)
@@ -502,7 +502,7 @@ class TwitterapiAction extends Action
             $enclosure = $entry['enclosures'][0];
             $this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
         }
-        
+
         if(array_key_exists('tags', $entry)){
             foreach($entry['tags'] as $tag){
                 $this->element('category', null,$tag);
@@ -936,35 +936,16 @@ class TwitterapiAction extends Action
 
     function clientError($msg, $code = 400, $content_type = 'json')
     {
-
-        static $status = array(400 => 'Bad Request',
-                               401 => 'Unauthorized',
-                               402 => 'Payment Required',
-                               403 => 'Forbidden',
-                               404 => 'Not Found',
-                               405 => 'Method Not Allowed',
-                               406 => 'Not Acceptable',
-                               407 => 'Proxy Authentication Required',
-                               408 => 'Request Timeout',
-                               409 => 'Conflict',
-                               410 => 'Gone',
-                               411 => 'Length Required',
-                               412 => 'Precondition Failed',
-                               413 => 'Request Entity Too Large',
-                               414 => 'Request-URI Too Long',
-                               415 => 'Unsupported Media Type',
-                               416 => 'Requested Range Not Satisfiable',
-                               417 => 'Expectation Failed');
-
         $action = $this->trimmed('action');
 
         common_debug("User error '$code' on '$action': $msg", __FILE__);
 
-        if (!array_key_exists($code, $status)) {
+        if (!array_key_exists($code, ClientErrorAction::$status)) {
             $code = 400;
         }
 
-        $status_string = $status[$code];
+        $status_string = ClientErrorAction::$status[$code];
+
         header('HTTP/1.1 '.$code.' '.$status_string);
 
         if ($content_type == 'xml') {
@@ -983,6 +964,35 @@ class TwitterapiAction extends Action
 
     }
 
+    function serverError($msg, $code = 500, $content_type = 'json')
+    {
+        $action = $this->trimmed('action');
+
+        common_debug("Server error '$code' on '$action': $msg", __FILE__);
+
+        if (!array_key_exists($code, ServerErrorAction::$status)) {
+            $code = 400;
+        }
+
+        $status_string = ServerErrorAction::$status[$code];
+
+        header('HTTP/1.1 '.$code.' '.$status_string);
+
+        if ($content_type == 'xml') {
+            $this->init_document('xml');
+            $this->elementStart('hash');
+            $this->element('error', null, $msg);
+            $this->element('request', null, $_SERVER['REQUEST_URI']);
+            $this->elementEnd('hash');
+            $this->end_document('xml');
+        } else {
+            $this->init_document('json');
+            $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
+            print(json_encode($error_array));
+            $this->end_document('json');
+        }
+    }
+
     function init_twitter_rss()
     {
         $this->startXML();