]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/groupeditform.php
Merge branch '0.9.x' into facebook-upgrade
[quix0rs-gnu-social.git] / lib / groupeditform.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Form for editing a group
6  *
7  * PHP version 5
8  *
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.
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  Form
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@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/
29  */
30
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/form.php';
36
37 /**
38  * Form for editing a group
39  *
40  * @category Form
41  * @package  StatusNet
42  * @author   Evan Prodromou <evan@status.net>
43  * @author   Sarven Capadisli <csarven@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://status.net/
46  *
47  * @see      UnsubscribeForm
48  */
49
50 class GroupEditForm extends Form
51 {
52     /**
53      * group for user to join
54      */
55
56     var $group = null;
57
58     /**
59      * Constructor
60      *
61      * @param Action     $out   output channel
62      * @param User_group $group group to join
63      */
64
65     function __construct($out=null, $group=null)
66     {
67         parent::__construct($out);
68
69         $this->group = $group;
70     }
71
72     /**
73      * ID of the form
74      *
75      * @return string ID of the form
76      */
77
78     function id()
79     {
80         if ($this->group) {
81             return 'form_group_edit-' . $this->group->id;
82         } else {
83             return 'form_group_add';
84         }
85     }
86
87     /**
88      * class of the form
89      *
90      * @return string of the form class
91      */
92
93     function formClass()
94     {
95         return 'form_settings';
96     }
97
98     /**
99      * Action of the form
100      *
101      * @return string URL of the action
102      */
103
104     function action()
105     {
106         if ($this->group) {
107             return common_local_url('editgroup',
108                                     array('nickname' => $this->group->nickname));
109         } else {
110             return common_local_url('newgroup');
111         }
112     }
113
114     /**
115      * Name of the form
116      *
117      * @return void
118      */
119
120     function formLegend()
121     {
122         $this->out->element('legend', null, _('Create a new group'));
123     }
124
125     /**
126      * Data elements of the form
127      *
128      * @return void
129      */
130
131     function formData()
132     {
133         if ($this->group) {
134             $id = $this->group->id;
135             $nickname = $this->group->nickname;
136             $fullname = $this->group->fullname;
137             $homepage = $this->group->homepage;
138             $description = $this->group->description;
139             $location = $this->group->location;
140         } else {
141             $id = '';
142             $nickname = '';
143             $fullname = '';
144             $homepage = '';
145             $description = '';
146             $location = '';
147         }
148
149         $this->out->elementStart('ul', 'form_data');
150         $this->out->elementStart('li');
151         $this->out->hidden('groupid', $id);
152         $this->out->input('nickname', _('Nickname'),
153                           ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
154                           _('1-64 lowercase letters or numbers, no punctuation or spaces'));
155         $this->out->elementEnd('li');
156         $this->out->elementStart('li');
157         $this->out->input('fullname', _('Full name'),
158                           ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
159         $this->out->elementEnd('li');
160         $this->out->elementStart('li');
161         $this->out->input('homepage', _('Homepage'),
162                           ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
163                           _('URL of the homepage or blog of the group or topic.'));
164         $this->out->elementEnd('li');
165         $this->out->elementStart('li');
166         $desclimit = User_group::maxDescription();
167         if ($desclimit == 0) {
168             $descinstr = _('Describe the group or topic');
169         } else {
170             $descinstr = sprintf(_m('Describe the group or topic in %d character or less',
171                                     'Describe the group or topic in %d characters or less',
172                                     $desclimit),
173                                  $desclimit);
174         }
175         $this->out->textarea('description', _('Description'),
176                              ($this->out->arg('description')) ? $this->out->arg('description') : $description,
177                              $descinstr);
178         $this->out->elementEnd('li');
179         $this->out->elementStart('li');
180         $this->out->input('location', _('Location'),
181                           ($this->out->arg('location')) ? $this->out->arg('location') : $location,
182                           _('Location for the group, if any, like "City, State (or Region), Country".'));
183         $this->out->elementEnd('li');
184         if (common_config('group', 'maxaliases') > 0) {
185             $aliases = (empty($this->group)) ? array() : $this->group->getAliases();
186             $this->out->elementStart('li');
187             $this->out->input('aliases', _('Aliases'),
188                               ($this->out->arg('aliases')) ? $this->out->arg('aliases') :
189                               (!empty($aliases)) ? implode(' ', $aliases) : '',
190                               sprintf(_m('Extra nicknames for the group, separated with commas or spaces. Maximum %d alias allowed.',
191                                          'Extra nicknames for the group, separated with commas or spaces. Maximum %d aliases allowed.',
192                                          common_config('group', 'maxaliases')),
193                                       common_config('group', 'maxaliases')));;
194             $this->out->elementEnd('li');
195         }
196         $this->out->elementEnd('ul');
197     }
198
199     /**
200      * Action elements
201      *
202      * @return void
203      */
204
205     function formActions()
206     {
207         $this->out->submit('submit', _m('BUTTON','Save'));
208     }
209 }