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://www.gnu.org/software/social/
31 if (!defined('GNUSOCIAL')) { exit(1); }
34 * Gives a full dump of configuration variables for this instance
35 * of GNU social, minus variables that may be security-sensitive (like
37 * URL: https://example.com/api/gnusocial/config.(xml|json)
42 * @author Evan Prodromou <evan@status.net>
43 * @author Zach Copley <zach@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://www.gnu.org/software/social/
47 class ApiGNUsocialConfigAction extends ApiAction
50 'site' => array('name', 'server', 'theme', 'path', 'logo', 'fancy', 'language',
51 'email', 'broughtby', 'broughtbyurl', 'timezone', 'closed',
52 'inviteonly', 'private', 'textlimit', 'ssl', 'sslserver'),
53 'license' => array('type', 'owner', 'url', 'title', 'image'),
54 'nickname' => array('featured'),
55 'profile' => array('biolimit'),
56 'group' => array('desclimit'),
57 'notice' => array('contentlimit'),
58 'throttle' => array('enabled', 'count', 'timespan'),
59 'xmpp' => array('enabled', 'server', 'port', 'user'),
60 'integration' => array('source'),
61 'attachments' => array('uploads', 'file_quota'),
62 'url' => array('maxurllength', 'maxnoticelength'),
65 protected function handle()
69 switch ($this->format) {
71 $this->initDocument('xml');
72 $this->elementStart('config');
74 // XXX: check that all sections and settings are legal XML elements
76 foreach ($this->keys as $section => $settings) {
77 $this->elementStart($section);
78 foreach ($settings as $setting) {
79 $value = $this->setting($section, $setting);
80 if (is_array($value)) {
81 $value = implode(',', $value);
82 } else if ($value === false || $value == '0') {
84 } else if ($value === true || $value == '1') {
88 // return theme logo if there's no site specific one
90 if ($section == 'site' && $setting == 'logo') {
91 $value = Theme::path('logo.png');
95 $this->element($setting, null, $value);
97 $this->elementEnd($section);
99 $this->elementEnd('config');
100 $this->endDocument('xml');
104 foreach ($this->keys as $section => $settings) {
105 $result[$section] = array();
106 foreach ($settings as $setting) {
107 $result[$section][$setting]
108 = $this->setting($section, $setting);
111 $this->initDocument('json');
112 $this->showJsonObjects($result);
113 $this->endDocument('json');
116 // TRANS: Client error displayed when coming across a non-supported API method.
117 $this->clientError(_('API method not found.'), 404);
121 function setting($section, $key) {
122 $result = common_config($section, $key);
123 if ($key == 'file_quota') {
124 // hack: adjust for the live upload limit
125 if (common_config($section, 'uploads')) {
126 $max = ImageFile::maxFileSizeInt();
130 return min($result, $max);
136 * Return true if read only.
140 * @param array $args other arguments
142 * @return boolean is read only action?
144 function isReadOnly($args)