4 * Copyright (C) 2010, Free Software Foundation, Inc.
9 * 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 Max Shinn <trombonechamp@gmail.com>
25 * @copyright 2010 Free Software Foundation, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
29 if (!defined('STATUSNET')) {
33 require_once INSTALLDIR . '/lib/adminpanelaction.php';
35 class ProfilefieldsAdminPanelAction extends AdminPanelAction
40 return _('Profile fields');
43 function getInstructions()
45 return _('GNU Social custom profile fields');
50 $form = new ProfilefieldsAdminForm($this);
55 function saveSettings()
57 $title = $this->trimmed('title');
58 $description = $this->trimmed('description');
59 $type = $this->trimmed('type');
60 $systemname = $this->trimmed('systemname');
62 $field = GNUsocialProfileExtensionField::newField($title, $description, $type, $systemname);
69 class ProfilefieldsAdminForm extends AdminForm
74 return 'form_profilefields_admin_panel';
79 return 'form_settings';
84 return '/admin/profilefields';
90 $this->out->elementStart('fieldset');
91 $this->out->element('legend', null, _('Existing Custom Profile Fields'));
92 $this->out->elementStart('ul', 'form_data');
93 $fields = GNUsocialProfileExtensionField::allFields();
94 foreach ($fields as $field) {
96 $this->out->element('div', array(), $field->title . ' (' .
97 $field->type . '): ' . $field->description);
100 $this->out->elementEnd('ul');
101 $this->out->elementEnd('fieldset');
104 $this->out->elementStart('fieldset');
105 $this->out->element('legend', null, _('New Profile Field'));
106 $this->out->elementStart('ul', 'form_data');
109 $this->input('title', _('Title'),
110 _('The title of the field'));
113 $this->input('systemname', _('Internal name'),
114 _('The name used internally for this field. Also the key used in OStatus user info. (optional)'));
117 $this->input('description', _('Description'),
118 _('An optional more detailed description of the field'));
121 $this->out->dropdown('type', _('Type'), array('text' => _("Text"),
122 'str' => _("String")),
123 _('The type of the datafield'));
125 $this->out->elementEnd('ul');
126 $this->out->elementEnd('fieldset');
135 function formActions()
137 $this->out->submit('submit', _('Save'), 'submit', null, _('Save new field'));