3 * StatusNet, the distributed open-source microblogging tool
5 * Facebook integration administration panel
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 2010 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')) {
35 * Administer global Facebook integration settings
39 * @author Zach Copley <zach@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
43 class FacebookadminpanelAction extends AdminPanelAction
46 * Returns the page title
48 * @return string page title
52 return _m('Facebook');
56 * Instructions for using this form.
58 * @return string instructions
60 function getInstructions()
62 return _m('Facebook integration settings');
66 * Show the Facebook admin panel form
72 $form = new FacebookAdminPanelForm($this);
78 * Save settings from the form
82 function saveSettings()
84 static $settings = array(
85 'facebook' => array('appid', 'secret'),
90 foreach ($settings as $section => $parts) {
91 foreach ($parts as $setting) {
92 $values[$section][$setting]
93 = $this->trimmed($setting);
97 // This throws an exception on validation errors
98 $this->validate($values);
100 // assert(all values are valid);
102 $config = new Config();
104 $config->query('BEGIN');
106 foreach ($settings as $section => $parts) {
107 foreach ($parts as $setting) {
108 Config::save($section, $setting, $values[$section][$setting]);
112 $config->query('COMMIT');
117 function validate(&$values)
119 // appId, key and secret (can't be too long)
121 if (mb_strlen($values['facebook']['appid']) > 255) {
123 _m("Invalid Facebook ID. Max length is 255 characters.")
127 if (mb_strlen($values['facebook']['secret']) > 255) {
129 _m("Invalid Facebook secret. Max length is 255 characters.")
135 class FacebookAdminPanelForm extends AdminForm
140 * @return int ID of the form
144 return 'facebookadminpanel';
150 * @return string class of the form
154 return 'form_settings';
160 * @return string URL of the action
164 return common_local_url('facebookadminpanel');
168 * Data elements of the form
174 $this->out->elementStart(
176 array('id' => 'settings_facebook-application')
178 $this->out->element('legend', null, _m('Facebook application settings'));
179 $this->out->elementStart('ul', 'form_data');
184 _m('Application ID'),
185 _m('ID of your Facebook application'),
194 _m('Application secret'),
199 $this->out->elementEnd('ul');
200 $this->out->elementEnd('fieldset');
208 function formActions()
210 $this->out->submit('submit', _m('Save'), 'submit', null, _m('Save Facebook settings'));