3 * StatusNet, the distributed open-source microblogging tool
5 * Form for editing a group
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 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/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/form.php';
38 * Form for editing a group
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/
47 * @see UnsubscribeForm
49 class GroupEditForm extends Form
52 * group for user to join
59 * @param Action $out output channel
60 * @param User_group $group group to join
62 function __construct($out=null, $group=null)
64 parent::__construct($out);
66 $this->group = $group;
72 * @return string ID of the form
77 return 'form_group_edit-' . $this->group->id;
79 return 'form_group_add';
86 * @return string of the form class
90 return 'form_settings';
96 * @return string URL of the action
101 return common_local_url('editgroup',
102 array('nickname' => $this->group->nickname));
104 return common_local_url('newgroup');
113 function formLegend()
115 // TRANS: Form legend for group edit form.
116 $this->out->element('legend', null, _('Create a new group'));
120 * Data elements of the form
127 $id = $this->group->id;
128 $nickname = $this->group->nickname;
129 $fullname = $this->group->fullname;
130 $homepage = $this->group->homepage;
131 $description = $this->group->description;
132 $location = $this->group->location;
142 $this->out->elementStart('ul', 'form_data');
143 if (Event::handle('StartGroupEditFormData', array($this))) {
144 $this->out->elementStart('li');
145 $this->out->hidden('groupid', $id);
146 // TRANS: Field label on group edit form.
147 $this->out->input('nickname', _('Nickname'),
148 ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
149 // TRANS: Field title on group edit form.
150 _('1-64 lowercase letters or numbers, no punctuation or spaces.'));
151 $this->out->elementEnd('li');
152 $this->out->elementStart('li');
153 // TRANS: Field label on group edit form.
154 $this->out->input('fullname', _('Full name'),
155 ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
156 $this->out->elementEnd('li');
157 $this->out->elementStart('li');
158 // TRANS: Field label on group edit form; points to "more info" for a group.
159 $this->out->input('homepage', _('Homepage'),
160 ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
161 // TRANS: Field title on group edit form.
162 _('URL of the homepage or blog of the group or topic.'));
163 $this->out->elementEnd('li');
164 $this->out->elementStart('li');
165 $desclimit = User_group::maxDescription();
166 if ($desclimit == 0) {
167 // TRANS: Text area title for group description when there is no text limit.
168 $descinstr = _('Describe the group or topic.');
170 // TRANS: Text area title for group description.
171 // TRANS: %d is the number of characters available for the description.
172 $descinstr = sprintf(_m('Describe the group or topic in %d character or less.',
173 'Describe the group or topic in %d characters or less.',
177 // TRANS: Text area label on group edit form; contains description of group.
178 $this->out->textarea('description', _('Description'),
179 ($this->out->arg('description')) ? $this->out->arg('description') : $description,
181 $this->out->elementEnd('li');
182 $this->out->elementStart('li');
183 // TRANS: Field label on group edit form.
184 $this->out->input('location', _('Location'),
185 ($this->out->arg('location')) ? $this->out->arg('location') : $location,
186 // TRANS: Field title on group edit form.
187 _('Location for the group, if any, like "City, State (or Region), Country".'));
188 $this->out->elementEnd('li');
189 if (common_config('group', 'maxaliases') > 0) {
190 $aliases = (empty($this->group)) ? array() : $this->group->getAliases();
191 $this->out->elementStart('li');
192 // TRANS: Field label on group edit form.
193 $this->out->input('aliases', _('Aliases'),
194 ($this->out->arg('aliases')) ? $this->out->arg('aliases') :
195 (!empty($aliases)) ? implode(' ', $aliases) : '',
196 // TRANS: Input field title for group aliases.
197 // TRANS: %d is the maximum number of group aliases available.
198 sprintf(_m('Extra nicknames for the group, separated with commas or spaces. Maximum %d alias allowed.',
199 'Extra nicknames for the group, separated with commas or spaces. Maximum %d aliases allowed.',
200 common_config('group', 'maxaliases')),
201 common_config('group', 'maxaliases')));;
202 $this->out->elementEnd('li');
204 $this->out->elementStart('li');
205 $this->out->dropdown('join_policy',
206 // TRANS: Dropdown fieldd label on group edit form.
207 _('Membership policy'),
208 array(User_group::JOIN_POLICY_OPEN => _('Open to all'),
209 User_group::JOIN_POLICY_MODERATE => _('Admin must approve all members')),
210 // TRANS: Dropdown field title on group edit form.
211 _('Whether admin approval is required to join this group.'),
213 (empty($this->group->join_policy)) ? User_group::JOIN_POLICY_OPEN : $this->group->join_policy);
214 $this->out->elementEnd('li');
215 Event::handle('EndGroupEditFormData', array($this));
217 $this->out->elementEnd('ul');
225 function formActions()
227 // TRANS: Text for save button on group edit form.
228 $this->out->submit('submit', _m('BUTTON','Save'));