edit.php 23.1 KB
Newer Older
Martyn Smith's avatar
Martyn Smith committed
1
2
3
4
5
<?php
/**
 *
 * @package    mahara
 * @subpackage core
6
 * @author     Catalyst IT Ltd
7
8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
Martyn Smith's avatar
Martyn Smith committed
9
10
11
12
 *
 */

define('INTERNAL', 1);
13
define('MENUITEM', 'groups/groupsiown');
14
require(dirname(dirname(__FILE__)) . '/init.php');
Martyn Smith's avatar
Martyn Smith committed
15
require_once('pieforms/pieform.php');
16
require_once('group.php');
17
require_once(get_config('libroot') . 'antispam.php');
18
require_once('embeddedimage.php');
Martyn Smith's avatar
Martyn Smith committed
19

20
21
22
if ($id = param_integer('id', null)) {
    define('TITLE', get_string('editgroup', 'group'));
    define('GROUP', $id);
Martyn Smith's avatar
Martyn Smith committed
23

24
    if (!group_user_access($id)) {
25
26
27
        $SESSION->add_error_msg(get_string('canteditdontown', 'group'));
        redirect('/group/mygroups.php');
    }
28
29
30
31
32
33
34
35

    $group_data = group_get_groups_for_editing(array($id));

    if (count($group_data) != 1) {
        throw new GroupNotFoundException(get_string('groupnotfound', 'group', $id));
    }

    $group_data = $group_data[0];
36
37
38
39

    // Fix dates to unix timestamps instead of formatted timestamps.
    $group_data->editwindowstart = isset($group_data->editwindowstart) ? strtotime($group_data->editwindowstart) : null;
    $group_data->editwindowend = isset($group_data->editwindowend) ? strtotime($group_data->editwindowend) : null;
40
41
42
43
44
45
46
47
48
49
50
51
52
}
else {
    define('TITLE', get_string('creategroup', 'group'));

    if (!group_can_create_groups()) {
        throw new AccessDeniedException(get_string('accessdenied', 'error'));
    }

    $group_data = (object) array(
        'id'             => null,
        'name'           => null,
        'description'    => null,
        'grouptype'      => 'standard',
53
54
        'open'           => 1,
        'controlled'     => 0,
55
56
57
        'category'       => 0,
        'public'         => 0,
        'usersautoadded' => 0,
58
        'viewnotify'     => GROUP_ROLES_ALL,
59
        'submittableto'  => 0,
60
        'allowarchives'  => 0,
61
        'editroles'      => 'all',
62
        'hidden'         => 0,
63
        'hidemembers'    => 0,
64
        'hidemembersfrommembers' => 0,
65
        'groupparticipationreports' => 0,
66
67
        'invitefriends'  => 0,
        'suggestfriends' => 0,
68
        'urlid'          => null,
69
        'editwindowstart' => null,
70
        'editwindowend'  => null,
71
72
        'sendnow'        => 0,
        'feedbacknotify' => GROUP_ROLES_ALL,
73
    );
Martyn Smith's avatar
Martyn Smith committed
74
}
75

76
77
78
79
80
81
$form = array(
    'name'       => 'editgroup',
    'plugintype' => 'core',
    'pluginname' => 'groups',
    'elements'   => array(
        'name' => array(
Martyn Smith's avatar
Martyn Smith committed
82
            'type'         => 'text',
83
            'title'        => get_string('groupname', 'group'),
Penny Leach's avatar
Penny Leach committed
84
            'rules'        => array( 'required' => true, 'maxlength' => 128 ),
85
86
87
            'defaultvalue' => $group_data->name,
        ),
        'description' => array(
Martyn Smith's avatar
Martyn Smith committed
88
            'type'         => 'wysiwyg',
89
            'title'        => get_string('groupdescription', 'group'),
90
            'rules'        => array('maxlength' => 65536),
Martyn Smith's avatar
Martyn Smith committed
91
            'rows'         => 10,
92
            'cols'         => 55,
93
94
            'defaultvalue' => $group_data->description,
        ),
95
96
97
98
99
100
101
102
103
        'urlid' => array(
            'type'         => 'text',
            'title'        => get_string('groupurl', 'group'),
            'prehtml'      => '<span class="description">' . get_config('wwwroot') . get_config('cleanurlgroupdefault') . '/</span> ',
            'description'  => get_string('groupurldescription', 'group') . ' ' . get_string('cleanurlallowedcharacters'),
            'rules'        => array('maxlength' => 30, 'regex' => get_config('cleanurlvalidate')),
            'defaultvalue' => $group_data->urlid,
            'ignore'       => !$id || !get_config('cleanurls'),
        ),
104
105
106
107
        'settings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
            'collapsed'    => false,
108
            'class'        => 'sectioned last',
109
110
111
112
113
            'legend'       => get_string('settings'),
            'elements'     => array(),
        ),
        'submit' => array(
            'type'         => 'submitcancel',
114
            'class'        => 'btn-primary',
115
116
            'value'        => array(get_string('savegroup', 'group'), get_string('cancel')),
            'goto'         => get_config('wwwroot') . 'group/mygroups.php',
117
118
119
        ),
    ),
);
120

121
122
$elements = array();

123
124
$elements['membership'] = array(
    'type'         => 'html',
125
    'value'        => '<h4>' . get_string('Membership', 'group') . '</h4>',
126
127
);

128
129
130
131
$cancreatecontrolled = $USER->get('admin') || $USER->get('staff')
    || $USER->is_institutional_admin() || $USER->is_institutional_staff();

$elements['open'] = array(
132
    'type'         => 'switchbox',
133
134
    'title'        => get_string('Open', 'group'),
    'description'  => get_string('opendescription', 'group'),
135
136
    'defaultvalue' => $group_data->open,
    'disabled'     => !$cancreatecontrolled && $group_data->controlled,
137
);
138
if ($cancreatecontrolled || $group_data->controlled) {
139
    $elements['controlled'] = array(
140
        'type'         => 'switchbox',
141
142
        'title'        => get_string('Controlled', 'group'),
        'description'  => get_string('controlleddescription', 'group'),
143
        'defaultvalue' => $group_data->controlled,
144
145
        'disabled'     => !$cancreatecontrolled,
    );
146
}
147
148
149
else {
    $form['elements']['controlled'] = array(
        'type'         => 'hidden',
150
        'value'        => $group_data->controlled,
151
152
153
    );
}
$elements['request'] = array(
154
    'type'         => 'switchbox',
155
156
    'title'        => get_string('request', 'group'),
    'description'  => get_string('requestdescription', 'group'),
157
158
    'defaultvalue' => !$group_data->open && $group_data->request,
    'disabled'     => $group_data->open,
159
160
161
162
);

// The grouptype determines the allowed roles
$grouptypeoptions = group_get_grouptype_options($group_data->grouptype);
163

164
165
// Hide the grouptype option if it was passed in as a parameter, if the user
// isn't allowed to change it, or if there's only one option.
166
167
168
if (!$id) {
    $grouptypeparam = param_alphanumext('grouptype', 0);
    if (isset($grouptypeoptions[$grouptypeparam])) {
169
170
        $group_data->grouptype = $grouptypeparam;
        $forcegrouptype = true;
171
172
    }
}
173
174
175
176
177
178
179
180
181
182
183
184
else if (!isset($grouptypeoptions[$group_data->grouptype])) {
    // The user can't create groups of this type.  Probably a non-staff user
    // who's been promoted to admin of a controlled group.
    $forcegrouptype = true;
}

if (!empty($forcegrouptype) || count($grouptypeoptions) < 2) {
    $form['elements']['grouptype'] = array(
        'type'         => 'hidden',
        'value'        => $group_data->grouptype,
    );
}
185
186
187
188
189
190
191
192
193
else {
    $elements['grouptype'] = array(
        'type'         => 'select',
        'title'        => get_string('Roles', 'group'),
        'options'      => $grouptypeoptions,
        'defaultvalue' => $group_data->grouptype,
        'help'         => true
    );
}
194

195
$elements['invitefriends'] = array(
196
    'type'         => 'switchbox',
197
    'title'        => get_string('friendinvitations', 'group'),
198
    'description'  => get_string('invitefriendsdescription1', 'group'),
199
200
201
202
    'defaultvalue' => $group_data->invitefriends,
);

$elements['suggestfriends'] = array(
203
    'type'         => 'switchbox',
204
    'title'        => get_string('Recommendations', 'group'),
205
    'description'  => get_string('suggestfriendsdescription1', 'group'),
206
    'defaultvalue' => $group_data->suggestfriends && ($group_data->open || $group_data->request),
207
    'disabled'     => !$group_data->open && !$group_data->request,
208
209
);

210
211
$elements['pages'] = array(
    'type'         => 'html',
212
    'value'        => '<h4>' . get_string('content') . '</h4>',
213
214
215
216
217
);

$elements['editroles'] = array(
    'type'         => 'select',
    'options'      => group_get_editroles_options(),
218
219
    'title'        => get_string('editroles1', 'group'),
    'description'  => get_string('editrolesdescription1', 'group'),
220
221
222
223
    'defaultvalue' => $group_data->editroles,
    'help'         => true,
);

224
225
if ($cancreatecontrolled) {
    $elements['submittableto'] = array(
226
        'type'         => 'switchbox',
227
228
        'title'        => get_string('allowsubmissions', 'group'),
        'description'  => get_string('allowssubmissionsdescription1', 'group'),
229
230
        'defaultvalue' => $group_data->submittableto,
    );
231
    $elements['allowarchives'] = array(
232
        'type'         => 'switchbox',
233
234
235
236
237
238
        'title'        => get_string('allowsarchives', 'group'),
        'description'  => get_string('allowsarchivesdescription', 'group'),
        'defaultvalue' => $group_data->allowarchives,
        'disabled'     => !$group_data->submittableto,
        'help'         => true,
    );
239
240
241
242
243
244
}
else {
    $form['elements']['submittableto'] = array(
        'type'         => 'hidden',
        'value'        => $group_data->submittableto,
    );
245
246
247
248
    $form['elements']['allowarchives'] = array(
        'type'         => 'hidden',
        'value'        => $group_data->allowarchives,
    );
249
250
}

251
$publicallowed = get_config('createpublicgroups') == 'all' || (get_config('createpublicgroups') == 'admins' && $USER->get('admin'));
252
$publicallowed = $publicallowed && !is_probationary_user();
253

254
255
256
257
if (!$id && !param_exists('pieform_editgroup')) {
    // If a 'public=0' parameter is passed on the first page load, hide the
    // public checkbox.  The only purpose of this is to allow custom create
    // group buttons/links which lead to a slightly simplified form.
258
259
260
    $publicparam = param_integer('public', null);
}

261
262
263
264
265
$ignorepublic = !$publicallowed || (isset($publicparam) && $publicparam === 0);

if ($cancreatecontrolled || !$ignorepublic) {
    $elements['visibility'] = array(
        'type'         => 'html',
266
        'value'        => '<h4>' .get_string('Visibility') . '</h4>',
267
268
269
    );
}

270
$elements['public'] = array(
271
    'type'         => 'switchbox',
272
    'title'        => get_string('publiclyviewablegroup', 'group'),
273
    'description'  => get_string('publiclyviewablegroupdescription1', 'group'),
274
275
    'defaultvalue' => $group_data->public,
    'help'         => true,
276
277
278
279
280
    'ignore'       => $ignorepublic,
);

if ($cancreatecontrolled) {
    $elements['hidden'] = array(
281
        'type'         => 'switchbox',
282
        'title'        => get_string('hiddengroup', 'group'),
283
        'description'  => get_string('hiddengroupdescription1', 'group'),
284
285
        'defaultvalue' => $group_data->hidden,
    );
286
    $elements['hidemembers'] = array(
287
        'type'         => 'switchbox',
288
289
        'title'        => get_string('hidemembers', 'group'),
        'description'  => get_string('hidemembersdescription', 'group'),
290
291
        'defaultvalue' => $group_data->hidemembers || $group_data->hidemembersfrommembers,
        'disabled'     => $group_data->hidemembersfrommembers,
292
    );
293
    $elements['hidemembersfrommembers'] = array(
294
        'type'         => 'switchbox',
295
        'title'        => get_string('hidemembersfrommembers', 'group'),
296
        'description'  => get_string('hidemembersfrommembersdescription1', 'group'),
297
298
        'defaultvalue' => $group_data->hidemembersfrommembers,
    );
299
300
301
302
303
304
}
else {
    $form['elements']['hidden'] = array(
        'type'         => 'hidden',
        'value'        => $group_data->hidden,
    );
305
306
    $form['elements']['hidemembers'] = array(
        'type'         => 'hidden',
307
        'value'        => $group_data->hidemembers || $group_data->hidemembersfrommembers,
308
    );
309
310
311
312
    $form['elements']['hidemembersfrommembers'] = array(
        'type'         => 'hidden',
        'value'        => $group_data->hidemembersfrommembers,
    );
313
314
}

315
$elements['groupparticipationreports'] = array(
316
    'type'         => 'switchbox',
317
    'title'        => get_string('groupparticipationreports', 'group'),
318
    'description'  => get_string('groupparticipationreportsdesc1', 'group'),
319
320
321
    'defaultvalue' => $group_data->groupparticipationreports,
);

322
323
$elements['editability'] = array(
    'type'         => 'html',
324
    'value'        => '<h4>' . get_string('editability', 'group') . '</h4>',
325
326
327
328
329
330
);

$currentdate = getdate();

$elements['editwindowstart'] = array (
    'type'         => 'date',
Naomi Guyer's avatar
Naomi Guyer committed
331
    'class'        => 'five-across hide-label',
332
333
    'title'        => get_string('windowstart', 'group'),
    'defaultvalue' => $group_data->editwindowstart,
334
    'description'  => get_string('windowstartdesc', 'group'),
335
336
337
338
339
340
341
    'minyear'      => $currentdate['year'],
    'maxyear'      => $currentdate['year'] + 20,
    'time'         => true
);

$elements['editwindowend'] = array (
    'type'         => 'date',
Naomi Guyer's avatar
Naomi Guyer committed
342
    'class'        => 'five-across hide-label',
343
344
    'title'        => get_string('windowend', 'group'),
    'defaultvalue' => $group_data->editwindowend,
345
    'description'  => get_string('windowenddesc', 'group'),
346
347
348
349
350
    'minyear'      => $currentdate['year'],
    'maxyear'      => $currentdate['year'] + 20,
    'time'         => true
);

351
352
$elements['general'] = array(
    'type'         => 'html',
353
    'value'        => '<h4>' . get_string('general') . '</h4>',
354
355
);

356
357
358
if (get_config('allowgroupcategories')
    && $groupcategories = get_records_menu('group_category','','','displayorder', 'id,title')
) {
359
    $elements['category'] = array(
360
361
                'type'         => 'select',
                'title'        => get_string('groupcategory', 'group'),
362
                'options'      => array('0'=>get_string('nocategoryselected', 'group')) + $groupcategories,
363
                'defaultvalue' => $group_data->category);
364
365
366
367

    // If it's a new group & the category was passed as a parameter, hide it in the form.
    $groupcategoryparam = param_integer('category', 0);
    if (!$id && isset($groupcategories[$groupcategoryparam])) {
368
        $form['elements']['category'] = array(
369
370
371
372
373
374
            'type'  => 'hidden',
            'value' => $groupcategoryparam,
        );
    }
}

375
$elements['usersautoadded'] = array(
376
            'type'         => 'switchbox',
377
            'title'        => get_string('usersautoadded', 'group'),
378
            'description'  => get_string('usersautoaddeddescription1', 'group'),
379
            'defaultvalue' => $group_data->usersautoadded,
380
            'help'         => true,
381
            'ignore'       => !$USER->get('admin'));
382
$notifyroles = array(get_string('none', 'admin')) + group_get_editroles_options(true);
383
$elements['viewnotify'] = array(
384
    'type' => 'select',
385
    'title' => get_string('viewnotify', 'group'),
386
387
    'options' => $notifyroles,
    'description' => get_string('viewnotifydescription2', 'group'),
388
389
    'defaultvalue' => $group_data->viewnotify
);
390
391
392
393
$elements['feedbacknotify'] = array(
    'type' => 'select',
    'title' => get_string('feedbacknotify', 'group'),
    'options' => $notifyroles,
394
    'description' => get_string('feedbacknotifydescription1', 'group'),
395
396
    'defaultvalue' => $group_data->feedbacknotify
);
397
398
if ($cancreatecontrolled) {
    $elements['sendnow'] = array(
399
        'type'         => 'switchbox',
400
        'title'        => get_string('allowsendnow', 'group'),
401
        'description'  => get_string('allowsendnowdescription1', 'group'),
402
403
404
405
406
407
408
409
410
        'defaultvalue' => $group_data->sendnow
    );
}
else {
    $form['elements']['sendnow'] = array(
        'type'         => 'hidden',
        'value'        => $group_data->sendnow,
    );
}
411
412
$form['elements']['settings']['elements'] = $elements;
$editgroup = pieform($form);
Martyn Smith's avatar
Martyn Smith committed
413

414
function editgroup_validate(Pieform $form, $values) {
415
416
417
    global $group_data;
    if ($group_data->name != $values['name']) {
        // This check has not always been case-insensitive; don't use get_record in case we get >1 row back.
418
419
420
421
        if ($ids = get_records_sql_array('SELECT id FROM {group} WHERE LOWER(TRIM(name)) = ?', array(strtolower(trim($values['name']))))) {
            if (count($ids) > 1 || $ids[0]->id != $group_data->id) {
                $form->set_error('name', get_string('groupalreadyexists', 'group'));
            }
422
        }
Martyn Smith's avatar
Martyn Smith committed
423
    }
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442

    if (isset($values['urlid']) && get_config('cleanurls')) {
        $urlidlength = strlen($values['urlid']);
        if ($group_data->urlid != $values['urlid']) {
            if ($urlidlength && record_exists('group', 'urlid', $values['urlid'])) {
                $form->set_error('urlid', get_string('groupurltaken', 'group'));
            }
            else if (!$urlidlength) {
                // Once you've set a group url, there's no going back
                $form->set_error('urlid', get_string('rule.minlength.minlength', 'pieforms', 3));
            }
        }
        // If the urlid is empty, we'll generate it when creating a group, but if it's 1 or 2 characters
        // long, it's an error.
        if ($urlidlength > 0 && $urlidlength < 3) {
            $form->set_error('urlid', get_string('rule.minlength.minlength', 'pieforms', 3));
        }
    }

443
444
445
446
447
448
449
450
    if (!empty($values['open'])) {
        if (!empty($values['controlled'])) {
            $form->set_error('open', get_string('membershipopencontrolled', 'group'));
        }
        if (!empty($values['request'])) {
            $form->set_error('request', get_string('membershipopenrequest', 'group'));
        }
    }
451
452
453
    if (!empty($values['invitefriends']) && !empty($values['suggestfriends'])) {
        $form->set_error('invitefriends', get_string('suggestinvitefriends', 'group'));
    }
454
455
456
    if (!empty($values['suggestfriends']) && empty($values['open']) && empty($values['request'])) {
        $form->set_error('suggestfriends', get_string('suggestfriendsrequesterror', 'group'));
    }
457
458
459
    if (!empty($values['editwindowstart']) && !empty($values['editwindowend']) && ($values['editwindowstart'] >= $values['editwindowend'])) {
        $form->set_error('editwindowend', get_string('editwindowendbeforestart', 'group'));
    }
Martyn Smith's avatar
Martyn Smith committed
460
461
}

462
function editgroup_cancel_submit() {
463
    redirect('/group/mygroups.php');
Martyn Smith's avatar
Martyn Smith committed
464
465
}

466
function editgroup_submit(Pieform $form, $values) {
467
    global $USER, $SESSION, $group_data, $publicallowed;
Martyn Smith's avatar
Martyn Smith committed
468

469
    $values['public'] = (isset($values['public'])) ? $values['public'] : 0;
470
    $values['usersautoadded'] = (isset($values['usersautoadded'])) ? $values['usersautoadded'] : 0;
471

472
    $newvalues = array(
473
474
        'name'           => $group_data->name == $values['name'] ? $values['name'] : trim($values['name']),
        'description'    => $values['description'],
475
        'grouptype'      => $values['grouptype'],
476
        'category'       => empty($values['category']) ? null : intval($values['category']),
477
478
479
        'open'           => intval($values['open']),
        'controlled'     => intval($values['controlled']),
        'request'        => intval($values['request']),
480
        'usersautoadded' => intval($values['usersautoadded']),
481
        'public'         => ($publicallowed ? intval($values['public']) : 0),
482
        'viewnotify'     => intval($values['viewnotify']),
483
        'submittableto'  => intval($values['submittableto']),
484
        'allowarchives'  => intval(!empty($values['allowarchives']) ? $values['allowarchives'] : 0),
485
        'editroles'      => $values['editroles'],
486
        'hidden'         => intval($values['hidden']),
487
        'hidemembers'    => intval(!empty($values['hidemembersfrommembers']) || !empty($values['hidemembers'])),
488
        'hidemembersfrommembers' => intval($values['hidemembersfrommembers']),
489
        'groupparticipationreports' => intval($values['groupparticipationreports']),
490
491
        'invitefriends'  => intval($values['invitefriends']),
        'suggestfriends' => intval($values['suggestfriends']),
492
        'editwindowstart' => db_format_timestamp($values['editwindowstart']),
493
        'editwindowend'  => db_format_timestamp($values['editwindowend']),
494
495
        'sendnow'        => intval($values['sendnow']),
        'feedbacknotify'     => intval($values['feedbacknotify']),
Martyn Smith's avatar
Martyn Smith committed
496
497
    );

498
499
500
501
502
    if (
            get_config('cleanurls')
            && isset($values['urlid'])
            && '' !== (string) $values['urlid']
    ) {
503
504
505
        $newvalues['urlid'] = $values['urlid'];
    }

506
507
    db_begin();

508
    if (!$group_data->id) {
509
510
511
512
        $newvalues['members'] = array($USER->get('id') => 'admin');
        $group_data->id = group_create($newvalues);
        $USER->reset_grouproles();
    }
513
514
515
516
517
    // Now update the description with any embedded image info
    $newvalues['description'] = EmbeddedImage::prepare_embedded_images($newvalues['description'], 'group', $group_data->id, $group_data->id);
    $newvalues['id'] = $group_data->id;
    unset($newvalues['members']);
    group_update((object)$newvalues);
518

519
    $SESSION->add_ok_msg(get_string('groupsaved', 'group'));
Martyn Smith's avatar
Martyn Smith committed
520
521
522

    db_commit();

523
    // Reload $group_data->urlid or else the redirect will fail
524
    if (get_config('cleanurls') && (!isset($values['urlid']) || $group_data->urlid != $values['urlid'])) {
525
526
527
528
        $group_data->urlid = get_field('group', 'urlid', 'id', $group_data->id);
    }

    redirect(group_homepage_url($group_data));
Martyn Smith's avatar
Martyn Smith committed
529
530
}

531
$js = '
Naomi Guyer's avatar
Naomi Guyer committed
532
533
jQuery(function($) {
    $("#editgroup_controlled").click(function() {
534
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
535
536
537
538
539
            $("#editgroup_request").removeAttr("disabled");
            $("#editgroup_open").removeAttr("checked");
            if (!$("#editgroup_request").attr("checked")) {
                $("#editgroup_suggestfriends").removeAttr("checked");
                $("#editgroup_suggestfriends").attr("disabled", true);
540
            }
541
542
        }
    });
Naomi Guyer's avatar
Naomi Guyer committed
543
    $("#editgroup_open").click(function() {
544
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
545
546
547
548
            $("#editgroup_controlled").removeAttr("checked");
            $("#editgroup_request").removeAttr("checked");
            $("#editgroup_request").attr("disabled", true);
            $("#editgroup_suggestfriends").removeAttr("disabled");
549
550
        }
        else {
Naomi Guyer's avatar
Naomi Guyer committed
551
552
553
554
            $("#editgroup_request").removeAttr("disabled");
            if (!$("#editgroup_request").attr("checked")) {
                $("#editgroup_suggestfriends").removeAttr("checked");
                $("#editgroup_suggestfriends").attr("disabled", true);
555
556
557
            }
        }
    });
Naomi Guyer's avatar
Naomi Guyer committed
558
    $("#editgroup_request").click(function() {
559
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
560
            $("#editgroup_suggestfriends").removeAttr("disabled");
561
562
        }
        else {
Naomi Guyer's avatar
Naomi Guyer committed
563
564
565
            if (!$("#editgroup_open").attr("checked")) {
                $("#editgroup_suggestfriends").removeAttr("checked");
                $("#editgroup_suggestfriends").attr("disabled", true);
566
            }
567
568
        }
    });
Naomi Guyer's avatar
Naomi Guyer committed
569
    $("#editgroup_invitefriends").click(function() {
570
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
571
572
            if ($("#editgroup_request").attr("checked") || $("#editgroup_open").attr("checked")) {
                $("#editgroup_suggestfriends").removeAttr("disabled");
573
            }
Naomi Guyer's avatar
Naomi Guyer committed
574
            $("#editgroup_suggestfriends").removeAttr("checked");
575
576
        }
    });
Naomi Guyer's avatar
Naomi Guyer committed
577
    $("#editgroup_suggestfriends").click(function() {
578
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
579
            $("#editgroup_invitefriends").removeAttr("checked");
580
581
        }
    });
Naomi Guyer's avatar
Naomi Guyer committed
582
    $("#editgroup_hidemembersfrommembers").click(function() {
583
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
584
585
            $("#editgroup_hidemembers").attr("checked", true);
            $("#editgroup_hidemembers").attr("disabled", true);
586
587
        }
        else {
Naomi Guyer's avatar
Naomi Guyer committed
588
            $("#editgroup_hidemembers").removeAttr("disabled");
589
590
        }
    });
Naomi Guyer's avatar
Naomi Guyer committed
591
    $("#editgroup_submittableto").click(function() {
592
        if (this.checked) {
Naomi Guyer's avatar
Naomi Guyer committed
593
            $("#editgroup_allowarchives").attr("disabled", false);
594
595
        }
        else {
Naomi Guyer's avatar
Naomi Guyer committed
596
597
            $("#editgroup_allowarchives").removeAttr("checked");
            $("#editgroup_allowarchives").attr("disabled", true);
598
599
        }
    });
600
601
602
});
';

603
$smarty = smarty();
604
605
$smarty->assign('form', $editgroup);
$smarty->assign('PAGEHEADING', TITLE);
606
$smarty->assign('INLINEJAVASCRIPT', $js);
607
$smarty->display('form.tpl');