forked from geraldbullard/gnscms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editGroup.php
40 lines (40 loc) · 1.43 KB
/
editGroup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
function editGroup() {
global $lang;
$page_lang = scandir('inc/lang/' . $_SESSION['language']);
foreach ($page_lang as $file) {
if ($file != '.' && $file != '..') {
$parts = explode(".", $file);
$page = $parts[0];
if ($page == 'group') {
$page_file = $file;
}
}
}
include_once('inc/lang/' . $_SESSION['language'] . '/' . $page_file);
if ($_SESSION['access']->users > 1) {
$results = array();
$results['formAction'] = "editGroup";
if ( isset( $_POST['saveChanges'] ) ) {
// User has posted the group edit form: save the group changes
if ( !$group = Group::getById( (int)$_GET['editId'] ) ) {
header( "Location: index.php?action=listUser&error=groupNotFound" );
return;
}
$group = new Group;
$group->storeFormValues( $_POST );
$group->update();
header( "Location: index.php?action=listUser&success=groupChangesSaved" );
} elseif ( isset( $_POST['cancel'] ) ) {
// User has cancelled their edits: return to the group list
header( "Location: index.php?action=listUser" );
} else {
// User has not submitted the group edit form: display the group edit form
$results['group'] = Group::getById( (int)$_GET['groupId'] );
require( "inc/layout/editGroup.php" );
}
} else {
require( "inc/layout/noAccess.php" );
}
}
?>