Project

General

Profile

1 4 ryan
<?php
2 1398 FrankH
/**
3
 *
4
 * @category        admin
5
 * @package         groups
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14 1457 Luisehahne
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 1398 FrankH
 *
17
 */
18 4 ryan
19
// Print admin header
20
require('../../config.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
23 1457 Luisehahne
// suppress to print the header, so no new FTAN will be set
24
$admin = new admin('Access', 'groups_add', false);
25 1425 Luisehahne
// Create a javascript back link
26
$js_back = ADMIN_URL.'/groups/index.php';
27
28 1398 FrankH
if (!$admin->checkFTAN())
29
{
30 1457 Luisehahne
	$admin->print_header();
31 1425 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back);
32 1398 FrankH
}
33 1457 Luisehahne
// After check print the header
34
$admin->print_header();
35 4 ryan
36
// Gather details entered
37 1426 Luisehahne
$group_name = mysql_real_escape_string(strip_tags(trim($admin->get_post('group_name'))));
38 4 ryan
39
// Check values
40
if($group_name == "") {
41
	$admin->print_error($MESSAGE['GROUPS']['GROUP_NAME_BLANK'], $js_back);
42
}
43 25 stefan
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE name = '$group_name'");
44
if($results->numRows()>0) {
45
	$admin->print_error($MESSAGE['GROUPS']['GROUP_NAME_EXISTS'], $js_back);
46
}
47 4 ryan
48
// Get system and module permissions
49
require(ADMIN_PATH.'/groups/get_permissions.php');
50
51
// Update the database
52
$query = "INSERT INTO ".TABLE_PREFIX."groups (name,system_permissions,module_permissions,template_permissions) VALUES ('$group_name','$system_permissions','$module_permissions','$template_permissions')";
53
54
$database->query($query);
55
if($database->is_error()) {
56
	$admin->print_error($database->get_error());
57
} else {
58
	$admin->print_success($MESSAGE['GROUPS']['ADDED'], ADMIN_URL.'/groups/index.php');
59
}
60
61
// Print admin footer
62
$admin->print_footer();