Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         groups
6
 * @author          WebsiteBaker Project
7
 * @copyright       Ryan Djurovich
8
 * @copyright       WebsiteBaker Org. e.V.
9
 * @link            http://websitebaker.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.3
12
 * @requirements    PHP 5.3.6 and higher
13
 * @version         $Id: save.php 2 2017-07-02 15:14:29Z Manuela $
14
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/admin/groups/save.php $
15
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
16
 *
17
 */
18

    
19
// Print admin header
20
    if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
21
    if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
22
// suppress to print the header, so no new FTAN will be set
23
    $admin = new admin('Access', 'groups_modify', false);
24
    $requestMethod = '_'.($GLOBALS['_SERVER']['REQUEST_METHOD']);
25
    $aRequestVars  = (@(${$requestMethod}) ? : null);
26

    
27
    $bAdvanced       = intval(@$aRequestVars['advanced'] ?: 0);
28
    $bAdvancedSave   = intval(@$aRequestVars['advanced_extended'] ?: 0);
29
    $bResetSystem    = intval(@$aRequestVars['reset_system'] ?: 0);
30
    $bResetModules   = intval(@$aRequestVars['reset_modules'] ?: 0);
31
    $bResetTemplates = intval(@$aRequestVars['reset_templates'] ?: 0);
32
    $js_back = ADMIN_URL.'/groups/index.php';
33
    $action = 'save';
34
    $action = (isset($aRequestVars['cancel']) ? 'cancel' : $action );
35
    switch ($action):
36
        case 'cancel':
37
            header('HTTP/1.1 301 Moved Permanently');
38
            header('Location: '.$js_back);
39
            exit;
40
        default:
41

    
42
        break;
43
    endswitch;
44

    
45
if (!$admin->checkFTAN())
46
{
47
    $admin->print_header();
48
    $sInfo = strtoupper(basename(__DIR__).'_'.basename(__FILE__, ''.PAGE_EXTENSION).'::');
49
    $sDEBUG=(@DEBUG?$sInfo:'');
50
    $admin->print_error($sDEBUG.$MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
51
}
52

    
53
// Check if group group_id is a valid number and doesnt equal 1
54
$group_id = intval($admin->checkIDKEY('group_id', 0, $_SERVER['REQUEST_METHOD']));
55
if( ($group_id < 2 ) )
56
{
57
    // if($admin_header) { $admin->print_header(); }
58
    $admin->print_header();
59
    $sInfo = strtoupper(basename(__DIR__).'_'.basename(__FILE__, ''.PAGE_EXTENSION).'::');
60
    $sDEBUG=(@DEBUG?$sInfo:'');
61
    $admin->print_error($sDEBUG.$MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
62
}
63
// Gather details entered
64
$group_name = preg_replace('/[^a-z0-9_-]/i', "", $admin->get_post('group_name'));
65
$group_name = $admin->StripCodeFromText($group_name);
66
// Check values
67
if($group_name == "") {
68
    $admin->print_error($MESSAGE['GROUPS_GROUP_NAME_BLANK'], $js_back);
69
}
70

    
71
// After check print the header
72
$admin->print_header();
73

    
74
$system_permissions = array();
75
$query = 'SELECT `system_permissions` FROM `'.TABLE_PREFIX.'groups` '
76
       . 'WHERE `group_id` = '.$group_id;
77
if ($sSystemPermissions = $database->get_one($query)) {
78
//    $aRes = $oRes->fetchRow(MYSQLI_ASSOC);
79
    $system_permissions = (explode(',', $sSystemPermissions));
80
}
81

    
82
// Get system permissions
83
require(ADMIN_PATH.'/groups/get_permissions.php');
84

    
85
// Update the database
86
$sql  = 'UPDATE `'.TABLE_PREFIX.'groups` SET '
87
      .'`name` = \''.$group_name.'\', '
88
      .'`system_permissions` = \''.$database->escapeString($system_permissions).'\', '
89
      .'`module_permissions` = \''.$database->escapeString($module_permissions).'\', '
90
      .'`template_permissions` = \''.$database->escapeString($template_permissions).'\' '
91
      .'WHERE `group_id` = '.intval($group_id);
92
$database->query($sql);
93
if($database->is_error()) {
94
    $admin->print_error($database->get_error(), $js_back);
95
} else {
96
    $group_id = $admin->getIDKEY($group_id);
97
    $modifyUrl = ADMIN_URL.'/groups/groups.php?modify=&group_id='.$group_id.'&advanced='.!$bAdvanced;
98
    $admin->print_success($MESSAGE['GROUPS_SAVED'], $modifyUrl);
99
}
100

    
101
// Print admin footer
102
$admin->print_footer();
(5-5/5)