Project

General

Profile

1
<?php
2

    
3
// $Id: add.php 1386 2011-01-16 09:56:53Z Luisehahne $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
// Print admin header
27
require('../../config.php');
28
require_once(WB_PATH.'/framework/class.admin.php');
29
$admin = new admin('Access', 'groups_add');
30

    
31
// Create new database object
32
// $database = new database();
33

    
34
// Gather details entered
35
$group_name = $admin->get_post('group_name');
36

    
37
// Create a javascript back link
38
$js_back = "javascript: history.go(-1);";
39

    
40
// Check values
41
if($group_name == "") {
42
	$admin->print_error($MESSAGE['GROUPS']['GROUP_NAME_BLANK'], $js_back);
43
}
44
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE name = '$group_name'");  
45
if($results->numRows()>0) {
46
	$admin->print_error($MESSAGE['GROUPS']['GROUP_NAME_EXISTS'], $js_back);  
47
}
48

    
49
// Get system and module permissions
50
require(ADMIN_PATH.'/groups/get_permissions.php');
51

    
52
// Update the database
53
$query = "INSERT INTO ".TABLE_PREFIX."groups (name,system_permissions,module_permissions,template_permissions) VALUES ('$group_name','$system_permissions','$module_permissions','$template_permissions')";
54

    
55
$database->query($query);
56
if($database->is_error()) {
57
	$admin->print_error($database->get_error());
58
} else {
59
	$admin->print_success($MESSAGE['GROUPS']['ADDED'], ADMIN_URL.'/groups/index.php');
60
}
61

    
62
// Print admin footer
63
$admin->print_footer();
64

    
65
?>
(1-1/5)