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 Evan Prodromou <evan@status.net>
25 * @author Zach Copley <zach@status.net>
26 * @copyright 2009 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
36 * Gives a full dump of configuration variables for this instance
37 * of StatusNet, minus variables that may be security-sensitive (like
39 * URL: http://identi.ca/api/statusnet/config.(xml|json)
44 * @author Evan Prodromou <evan@status.net>
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/
49 class ApiStatusnetConfigAction extends ApiAction
52 'site' => array('name', 'server', 'theme', 'path', 'logo', 'fancy', 'language',
53 'email', 'broughtby', 'broughtbyurl', 'timezone', 'closed',
54 'inviteonly', 'private', 'textlimit', 'ssl', 'sslserver'),
55 'license' => array('type', 'owner', 'url', 'title', 'image'),
56 'nickname' => array('featured'),
57 'profile' => array('biolimit'),
58 'group' => array('desclimit'),
59 'notice' => array('contentlimit'),
60 'throttle' => array('enabled', 'count', 'timespan'),
61 'xmpp' => array('enabled', 'server', 'port', 'user'),
62 'integration' => array('source'),
63 'attachments' => array('uploads', 'file_quota'),
64 'url' => array('maxlength', 'maxnoticelength'),
68 * Take arguments for running
70 * @param array $args $_REQUEST args
72 * @return boolean success flag
74 function prepare($args)
76 parent::prepare($args);
83 * @param array $args $_REQUEST data (unused)
87 function handle($args)
89 parent::handle($args);
91 switch ($this->format) {
93 $this->initDocument('xml');
94 $this->elementStart('config');
96 // XXX: check that all sections and settings are legal XML elements
98 foreach ($this->keys as $section => $settings) {
99 $this->elementStart($section);
100 foreach ($settings as $setting) {
101 $value = $this->setting($section, $setting);
102 if (is_array($value)) {
103 $value = implode(',', $value);
104 } else if ($value === false || $value == '0') {
106 } else if ($value === true || $value == '1') {
110 // return theme logo if there's no site specific one
112 if ($section == 'site' && $setting == 'logo') {
113 $value = Theme::path('logo.png');
117 $this->element($setting, null, $value);
119 $this->elementEnd($section);
121 $this->elementEnd('config');
122 $this->endDocument('xml');
126 foreach ($this->keys as $section => $settings) {
127 $result[$section] = array();
128 foreach ($settings as $setting) {
129 $result[$section][$setting]
130 = $this->setting($section, $setting);
133 $this->initDocument('json');
134 $this->showJsonObjects($result);
135 $this->endDocument('json');
139 // TRANS: Client error displayed when coming across a non-supported API method.
140 _('API method not found.'),
148 function setting($section, $key) {
149 $result = common_config($section, $key);
150 if ($key == 'file_quota') {
151 // hack: adjust for the live upload limit
152 if (common_config($section, 'uploads')) {
153 $max = ImageFile::maxFileSizeInt();
157 return min($result, $max);
163 * Return true if read only.
167 * @param array $args other arguments
169 * @return boolean is read only action?
171 function isReadOnly($args)