git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

groupeditform.php 5.81 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')) {
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 77 78 79 80
 *
 * @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) {
81
            return 'form_group_edit-' . $this->group->id;
Evan Prodromou's avatar
Evan Prodromou committed
82
        } else {
83
            return 'form_group_add';
Evan Prodromou's avatar
Evan Prodromou committed
84 85 86 87 88 89 90 91 92 93 94
        }
    }

    /**
     * class of the form
     *
     * @return string of the form class
     */

    function formClass()
    {
95
        return 'form_settings';
Evan Prodromou's avatar
Evan Prodromou committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
    }

    /**
     * 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');
        }
    }

114 115 116 117 118 119 120 121 122 123 124
    /**
     * Name of the form
     *
     * @return void
     */

    function formLegend()
    {
        $this->out->element('legend', null, _('Create a new group'));
    }

Evan Prodromou's avatar
Evan Prodromou committed
125 126 127 128 129 130 131 132
    /**
     * Data elements of the form
     *
     * @return void
     */

    function formData()
    {
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
        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
149 150
        $this->out->elementStart('ul', 'form_data');
        $this->out->elementStart('li');
151
        $this->out->hidden('groupid', $id);
Evan Prodromou's avatar
Evan Prodromou committed
152
        $this->out->input('nickname', _('Nickname'),
153
                     ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
Evan Prodromou's avatar
Evan Prodromou committed
154 155 156 157
                     _('1-64 lowercase letters or numbers, no punctuation or spaces'));
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
        $this->out->input('fullname', _('Full name'),
158
                     ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
Evan Prodromou's avatar
Evan Prodromou committed
159 160 161
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
        $this->out->input('homepage', _('Homepage'),
162
                     ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
Evan Prodromou's avatar
Evan Prodromou committed
163 164 165
                     _('URL of the homepage or blog of the group or topic'));
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
166
        $this->out->textarea('description', _('Description'),
167
                        ($this->out->arg('description')) ? $this->out->arg('description') : $description,
Evan Prodromou's avatar
Evan Prodromou committed
168 169 170 171
                        _('Describe the group or topic in 140 chars'));
        $this->out->elementEnd('li');
        $this->out->elementStart('li');
        $this->out->input('location', _('Location'),
172
                     ($this->out->arg('location')) ? $this->out->arg('location') : $location,
Evan Prodromou's avatar
Evan Prodromou committed
173 174
                     _('Location for the group, if any, like "City, State (or Region), Country"'));
        $this->out->elementEnd('li');
175 176 177 178 179 180 181 182 183 184
        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) : '',
                              sprintf(_('Extra nicknames for the group, comma- or space- separated, max %d'),
                                      common_config('group', 'maxaliases')));;
            $this->out->elementEnd('li');
        }
Evan Prodromou's avatar
Evan Prodromou committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198
        $this->out->elementEnd('ul');
    }

    /**
     * Action elements
     *
     * @return void
     */

    function formActions()
    {
        $this->out->submit('submit', _('Save'));
    }
}