]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapilaconica.php
Revert "Added configuration option to only allow OpenID logins."
[quix0rs-gnu-social.git] / actions / twitapilaconica.php
index 4ecbf94e17c0c81389615f86c1a95f8d5ef5e351..442fdbcef2e60955374b6ad8e714bc654e490441 100644 (file)
@@ -70,14 +70,16 @@ class TwitapilaconicaAction extends TwitterapiAction
         switch ($apidata['content-type']) {
          case 'xml':
             $this->init_document('xml');
-            common_element('version', null, LACONICA_VERSION);
+            $this->element('version', null, LACONICA_VERSION);
             $this->end_document('xml');
+            break;
          case 'json':
             $this->init_document('json');
             print '"'.LACONICA_VERSION.'"';
             $this->end_document('json');
+            break;
          default:
-            $this->client_error(_('API method not found!'), $code=404);
+            $this->clientError(_('API method not found!'), $code=404);
         }
     }
 
@@ -87,6 +89,8 @@ class TwitapilaconicaAction extends TwitterapiAction
      * Gives a full dump of configuration variables for this instance
      * of Laconica, minus variables that may be security-sensitive (like
      * passwords).
+     * URL: http://identi.ca/api/laconica/config.(xml|json)
+     * Formats: xml, json
      *
      * @param array $args    Web arguments
      * @param array $apidata Twitter API data
@@ -98,8 +102,54 @@ class TwitapilaconicaAction extends TwitterapiAction
 
     function config($args, $apidata)
     {
+        static $keys = array('site' => array('name', 'server', 'theme', 'path', 'fancy', 'language',
+                                             'email', 'broughtby', 'broughtbyurl', 'closed',
+                                             'inviteonly', 'private'),
+                             'license' => array('url', 'title', 'image'),
+                             'nickname' => array('featured'),
+                             'throttle' => array('enabled', 'count', 'timespan'),
+                             'xmpp' => array('enabled', 'server', 'user'));
+
         parent::handle($args);
-        common_server_error(_('API method under construction.'), 501);
+
+        switch ($apidata['content-type']) {
+         case 'xml':
+            $this->init_document('xml');
+            $this->elementStart('config');
+            // XXX: check that all sections and settings are legal XML elements
+            foreach ($keys as $section => $settings) {
+                $this->elementStart($section);
+                foreach ($settings as $setting) {
+                    $value = common_config($section, $setting);
+                    if (is_array($value)) {
+                        $value = implode(',', $value);
+                    } else if ($value === false) {
+                        $value = 'false';
+                    } else if ($value === true) {
+                        $value = 'true';
+                    }
+                    $this->element($setting, null, $value);
+                }
+                $this->elementEnd($section);
+            }
+            $this->elementEnd('config');
+            $this->end_document('xml');
+            break;
+         case 'json':
+            $result = array();
+            foreach ($keys as $section => $settings) {
+                $result[$section] = array();
+                foreach ($settings as $setting) {
+                    $result[$section][$setting] = common_config($section, $setting);
+                }
+            }
+            $this->init_document('json');
+            $this->show_json_objects($result);
+            $this->end_document('json');
+            break;
+         default:
+            $this->clientError(_('API method not found!'), $code=404);
+        }
     }
 
     /**
@@ -119,6 +169,7 @@ class TwitapilaconicaAction extends TwitterapiAction
     function wadl($args, $apidata)
     {
         parent::handle($args);
-        common_server_error(_('API method under construction.'), 501);
+        $this->serverError(_('API method under construction.'), 501);
     }
+
 }