]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GNUsocialProfileExtensions/actions/profilefields.php
ae01269a103750435c87a356c375f50635fe0b0f
[quix0rs-gnu-social.git] / plugins / GNUsocialProfileExtensions / actions / profilefields.php
1 <?php
2 /**
3  * GNU Social
4  * Copyright (C) 2010, Free Software Foundation, Inc.
5  *
6  * PHP version 5
7  *
8  * LICENCE:
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Widget
23  * @package   GNU Social
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
27  */
28
29 if (!defined('STATUSNET')) {
30     exit(1);
31 }
32
33 require_once INSTALLDIR . '/lib/adminpanelaction.php';
34
35 class ProfilefieldsAdminPanelAction extends AdminPanelAction
36 {
37
38     function title()
39     {
40         return _('Profile fields');
41     }
42
43     function getInstructions()
44     {
45         return _('GNU Social custom profile fields');
46     }
47
48     function showForm()
49     {
50         $form = new ProfilefieldsAdminForm($this);
51         $form->show();
52         return;
53     }
54
55     function saveSettings()
56     {
57         $title = $this->trimmed('title');
58         $description = $this->trimmed('description');
59         $type = $this->trimmed('type');
60         $systemname = $this->trimmed('systemname');
61
62         $field = GNUsocialProfileExtensionField::newField($title, $description, $type, $systemname);
63
64         return;
65     }
66
67 }
68
69 class ProfilefieldsAdminForm extends AdminForm
70 {
71
72     function id()
73     {
74         return 'form_profilefields_admin_panel';
75     }
76
77     function formClass()
78     {
79         return 'form_settings';
80     }
81
82     function action()
83     {
84         return '/admin/profilefields';
85     }
86
87     function formData()
88     {
89         //Listing all fields
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) {
95             $this->li();
96             $this->out->element('div', array(), $field->title . ' (' .
97                                 $field->type . '): ' . $field->description);
98             $this->unli();
99         }
100         $this->out->elementEnd('ul');
101         $this->out->elementEnd('fieldset');
102
103         //New fields
104         $this->out->elementStart('fieldset');
105         $this->out->element('legend', null, _('New Profile Field'));
106         $this->out->elementStart('ul', 'form_data');
107
108         $this->li();
109         $this->input('title', _('Title'),
110                      _('The title of the field'));
111         $this->unli();
112         $this->li();
113         $this->input('systemname', _('Internal name'), 
114                     _('The name used internally for this field.  Also the key used in OStatus user info. (optional)'));
115         $this->unli();
116         $this->li();
117         $this->input('description', _('Description'),
118                      _('An optional more detailed description of the field'));
119         $this->unli();
120         $this->li();
121         $this->out->dropdown('type', _('Type'), array('text' => _("Text"),
122                                                       'str' => _("String")), 
123                              _('The type of the datafield'));
124         $this->unli();
125         $this->out->elementEnd('ul');
126         $this->out->elementEnd('fieldset');
127     }
128
129     /**
130      * Action elements
131      *
132      * @return void
133      */
134
135     function formActions()
136     {
137         $this->out->submit('submit', _('Save'), 'submit', null, _('Save new field'));
138     }
139 }