We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

groupeditform.php 6.52 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1 2
<?php
/**
3
 * StatusNet, the distributed open-source microblogging tool
Evan Prodromou's avatar
Evan Prodromou committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * Form for editing a group
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Form
23
 * @package   StatusNet
24 25
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
26
 * @copyright 2009 StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
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/
Evan Prodromou's avatar
Evan Prodromou committed
29 30
 */

31
if (!defined('STATUSNET') && !defined('LACONICA')) {
Evan Prodromou's avatar
Evan Prodromou committed
32 33 34 35 36 37 38 39 40
    exit(1);
}

require_once INSTALLDIR.'/lib/form.php';

/**
 * Form for editing a group
 *
 * @category Form
41
 * @package  StatusNet
42 43
 * @author   Evan Prodromou <evan@status.net>
 * @author   Sarven Capadisli <csarven@status.net>
Evan Prodromou's avatar
Evan Prodromou committed
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/
Evan Prodromou's avatar
Evan Prodromou committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
 *
 * @see      UnsubscribeForm
 */
class GroupEditForm extends Form
{
    /**
     * group for user to join
     */
    var $group = null;

    /**
     * Constructor
     *
     * @param Action     $out   output channel
     * @param User_group $group group to join
     */
    function __construct($out=null, $group=null)
    {
        parent::__construct($out);

        $this->group = $group;
    }

    /**
     * ID of the form
     *
     * @return string ID of the form
     */
    function id()
    {
        if ($this->group) {
sarven's avatar
sarven committed
77
            return 'form_group_edit-' . $this->group->id;
Evan Prodromou's avatar
Evan Prodromou committed
78
        } else {
sarven's avatar
sarven committed
79
            return 'form_group_add';
Evan Prodromou's avatar
Evan Prodromou committed
80 81 82 83 84 85 86 87 88 89
        }
    }

    /**
     * class of the form
     *
     * @return string of the form class
     */
    function formClass()
    {
sarven's avatar
sarven committed
90
        return 'form_settings';
Evan Prodromou's avatar
Evan Prodromou committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        if ($this->group) {
            return common_local_url('editgroup',
                                    array('nickname' => $this->group->nickname));
        } else {
            return common_local_url('newgroup');
        }
    }

sarven's avatar
sarven committed
108 109 110 111 112 113 114 115 116 117
    /**
     * Name of the form
     *
     * @return void
     */
    function formLegend()
    {
        $this->out->element('legend', null, _('Create a new group'));
    }

Evan Prodromou's avatar
Evan Prodromou committed
118 119 120 121 122 123 124
    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
        if ($this->group) {
            $id = $this->group->id;
            $nickname = $this->group->nickname;
            $fullname = $this->group->fullname;
            $homepage = $this->group->homepage;
            $description = $this->group->description;
            $location = $this->group->location;
        } else {
            $id = '';
            $nickname = '';
            $fullname = '';
            $homepage = '';
            $description = '';
            $location = '';
        }

Evan Prodromou's avatar
Evan Prodromou committed
141 142
        $this->out->elementStart('ul', 'form_data');
        $this->out->elementStart('li');
143
        $this->out->hidden('groupid', $id);
Evan Prodromou's avatar
Evan Prodromou committed
144
        $this->out->input('nickname', _('Nickname'),
Evan Prodromou's avatar
Evan Prodromou committed
145
                          ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
146
                          _('1-64 lowercase letters or numbers, no punctuation or spaces.'));
Evan Prodromou's avatar
Evan Prodromou committed
147 148 149
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
        $this->out->input('fullname', _('Full name'),
Evan Prodromou's avatar
Evan Prodromou committed
150
                          ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
Evan Prodromou's avatar
Evan Prodromou committed
151 152 153
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
        $this->out->input('homepage', _('Homepage'),
Evan Prodromou's avatar
Evan Prodromou committed
154
                          ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
155
                          _('URL of the homepage or blog of the group or topic.'));
Evan Prodromou's avatar
Evan Prodromou committed
156 157
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
158 159 160 161
        $desclimit = User_group::maxDescription();
        if ($desclimit == 0) {
            $descinstr = _('Describe the group or topic');
        } else {
162 163
            $descinstr = sprintf(_m('Describe the group or topic in %d character or less.',
                                    'Describe the group or topic in %d characters or less.',
164 165
                                    $desclimit),
                                 $desclimit);
166
        }
167
        $this->out->textarea('description', _('Description'),
Evan Prodromou's avatar
Evan Prodromou committed
168
                             ($this->out->arg('description')) ? $this->out->arg('description') : $description,
169
                             $descinstr);
Evan Prodromou's avatar
Evan Prodromou committed
170 171 172
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
        $this->out->input('location', _('Location'),
Evan Prodromou's avatar
Evan Prodromou committed
173
                          ($this->out->arg('location')) ? $this->out->arg('location') : $location,
174
                          _('Location for the group, if any, like "City, State (or Region), Country".'));
Evan Prodromou's avatar
Evan Prodromou committed
175
        $this->out->elementEnd('li');
176 177 178 179 180 181
        if (common_config('group', 'maxaliases') > 0) {
            $aliases = (empty($this->group)) ? array() : $this->group->getAliases();
            $this->out->elementStart('li');
            $this->out->input('aliases', _('Aliases'),
                              ($this->out->arg('aliases')) ? $this->out->arg('aliases') :
                              (!empty($aliases)) ? implode(' ', $aliases) : '',
182 183 184
                              sprintf(_m('Extra nicknames for the group, separated with commas or spaces. Maximum %d alias allowed.',
                                         'Extra nicknames for the group, separated with commas or spaces. Maximum %d aliases allowed.',
                                         common_config('group', 'maxaliases')),
185 186 187
                                      common_config('group', 'maxaliases')));;
            $this->out->elementEnd('li');
        }
Evan Prodromou's avatar
Evan Prodromou committed
188 189 190 191 192 193 194 195 196 197
        $this->out->elementEnd('ul');
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
Siebrand Mazeland's avatar
Siebrand Mazeland committed
198
        $this->out->submit('submit', _m('BUTTON','Save'));
Evan Prodromou's avatar
Evan Prodromou committed
199 200
    }
}