3 * StatusNet, the distributed open-source microblogging tool
5 * Dump of configuration variables
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/lib/api.php';
37 * Gives a full dump of configuration variables for this instance
38 * of StatusNet, minus variables that may be security-sensitive (like
40 * URL: http://identi.ca/api/statusnet/config.(xml|json)
45 * @author Zach Copley <zach@status.net>
46 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47 * @link http://status.net/
50 class ApiStatusnetConfigAction extends TwitterApiAction
55 'site' => array('name', 'server', 'theme', 'path', 'fancy', 'language',
56 'email', 'broughtby', 'broughtbyurl', 'closed',
57 'inviteonly', 'private'),
58 'license' => array('url', 'title', 'image'),
59 'nickname' => array('featured'),
60 'throttle' => array('enabled', 'count', 'timespan'),
61 'xmpp' => array('enabled', 'server', 'user')
65 * Take arguments for running
67 * @param array $args $_REQUEST args
69 * @return boolean success flag
73 function prepare($args)
75 parent::prepare($args);
76 $this->format = $this->arg('format');
83 * @param array $args $_REQUEST data (unused)
88 function handle($args)
90 parent::handle($args);
92 switch ($this->format) {
94 $this->init_document('xml');
95 $this->elementStart('config');
97 // XXX: check that all sections and settings are legal XML elements
99 common_debug(var_export($this->keys, true));
101 foreach ($this->keys as $section => $settings) {
102 $this->elementStart($section);
103 foreach ($settings as $setting) {
104 $value = common_config($section, $setting);
105 if (is_array($value)) {
106 $value = implode(',', $value);
107 } else if ($value === false) {
109 } else if ($value === true) {
112 $this->element($setting, null, $value);
114 $this->elementEnd($section);
116 $this->elementEnd('config');
117 $this->end_document('xml');
121 foreach ($this->keys as $section => $settings) {
122 $result[$section] = array();
123 foreach ($settings as $setting) {
124 $result[$section][$setting]
125 = common_config($section, $setting);
128 $this->init_document('json');
129 $this->show_json_objects($result);
130 $this->end_document('json');
134 _('API method not found!'),