summaryrefslogtreecommitdiff
path: root/actions/twitapilaconica.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-12-30 16:14:44 -0500
committerEvan Prodromou <evan@prodromou.name>2008-12-30 16:14:44 -0500
commit91a41242ef5309fdae0243251d0e0add75c51b99 (patch)
tree0531d0ad6f69e1fe42e1bf34f1e5ceda3c5b73ee /actions/twitapilaconica.php
parent481c6d2316f3a31c85235cb64fbd198a08a92211 (diff)
implement the api/laconica/config method
darcs-hash:20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz
Diffstat (limited to 'actions/twitapilaconica.php')
-rw-r--r--actions/twitapilaconica.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/actions/twitapilaconica.php b/actions/twitapilaconica.php
index 6d3490abd..9d9fcef6f 100644
--- a/actions/twitapilaconica.php
+++ b/actions/twitapilaconica.php
@@ -89,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
@@ -100,8 +102,44 @@ 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');
+ // XXX: check that all sections and settings are legal XML elements
+ foreach ($keys as $section => $settings) {
+ common_element_start($section);
+ foreach ($settings as $setting) {
+ common_element($setting, null, common_config($section, $setting));
+ }
+ common_element_end($section);
+ }
+ $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->client_error(_('API method not found!'), $code=404);
+ }
}
/**