| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      
 
     | 
  
  
    | 
      3
     | 
    
      // $Id: groups.php 16 2005-09-04 15:17:05Z stefan $
 
     | 
  
  
    | 
      4
     | 
    
      
 
     | 
  
  
    | 
      5
     | 
    
      /*
 
     | 
  
  
    | 
      6
     | 
    
      
 
     | 
  
  
    | 
      7
     | 
    
       Website Baker Project <http://www.websitebaker.org/>
 
     | 
  
  
    | 
      8
     | 
    
       Copyright (C) 2004-2005, 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
     | 
    
      // Include config file and admin class file
 
     | 
  
  
    | 
      27
     | 
    
      require('../../config.php');
     | 
  
  
    | 
      28
     | 
    
      require_once(WB_PATH.'/framework/class.admin.php');
 
     | 
  
  
    | 
      29
     | 
    
      
 
     | 
  
  
    | 
      30
     | 
    
      // Create new database object
 
     | 
  
  
    | 
      31
     | 
    
      $database = new database();
 
     | 
  
  
    | 
      32
     | 
    
      
 
     | 
  
  
    | 
      33
     | 
    
      if(!isset($_POST['action']) OR $_POST['action'] != "modify" AND $_POST['action'] != "delete") {
     | 
  
  
    | 
      34
     | 
    
      	header("Location: index.php");
     | 
  
  
    | 
      35
     | 
    
      }
 
     | 
  
  
    | 
      36
     | 
    
      
 
     | 
  
  
    | 
      37
     | 
    
      // Check if group group_id is a valid number and doesnt equal 1
 
     | 
  
  
    | 
      38
     | 
    
      if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
     | 
  
  
    | 
      39
     | 
    
      	header("Location: index.php");
     | 
  
  
    | 
      40
     | 
    
      }
 
     | 
  
  
    | 
      41
     | 
    
      
 
     | 
  
  
    | 
      42
     | 
    
      if($_POST['action'] == 'modify') {
     | 
  
  
    | 
      43
     | 
    
      	// Create new admin object
 
     | 
  
  
    | 
      44
     | 
    
      	$admin = new admin('Access', 'groups_modify', false);
     | 
  
  
    | 
      45
     | 
    
      	// Print header
 
     | 
  
  
    | 
      46
     | 
    
      	$admin->print_header();
 
     | 
  
  
    | 
      47
     | 
    
      	// Get existing values
 
     | 
  
  
    | 
      48
     | 
    
      	$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'");
     | 
  
  
    | 
      49
     | 
    
      	$group = $results->fetchRow();
 
     | 
  
  
    | 
      50
     | 
    
      	// Setup template object
 
     | 
  
  
    | 
      51
     | 
    
      	$template = new Template(ADMIN_PATH.'/groups');
 
     | 
  
  
    | 
      52
     | 
    
      	$template->set_file('page', 'group_form.html');
     | 
  
  
    | 
      53
     | 
    
      	$template->set_block('page', 'main_block', 'main');
     | 
  
  
    | 
      54
     | 
    
      	$template->set_var(	array(
 
     | 
  
  
    | 
      55
     | 
    
      										'ACTION_URL' => ADMIN_URL.'/groups/save.php',
 
     | 
  
  
    | 
      56
     | 
    
      										'SUBMIT_TITLE' => $TEXT['SAVE'],
 
     | 
  
  
    | 
      57
     | 
    
      										'GROUP_ID' => $group['group_id'],
 
     | 
  
  
    | 
      58
     | 
    
      										'GROUP_NAME' => $group['name'],
 
     | 
  
  
    | 
      59
     | 
    
      										'ADVANCED_ACTION' => 'groups.php'
 
     | 
  
  
    | 
      60
     | 
    
      										)
 
     | 
  
  
    | 
      61
     | 
    
      							);
 
     | 
  
  
    | 
      62
     | 
    
      	// Tell the browser whether or not to show advanced options
 
     | 
  
  
    | 
      63
     | 
    
      	if(isset($_POST['advanced']) AND $_POST['advanced'] == $TEXT['SHOW_ADVANCED'].' >>') {
     | 
  
  
    | 
      64
     | 
    
      		$template->set_var('DISPLAY_ADVANCED', '');
     | 
  
  
    | 
      65
     | 
    
      		$template->set_var('DISPLAY_BASIC', 'none');
     | 
  
  
    | 
      66
     | 
    
      		$template->set_var('ADVANCED', 'yes');
     | 
  
  
    | 
      67
     | 
    
      		$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']);
     | 
  
  
    | 
      68
     | 
    
      	} else {
     | 
  
  
    | 
      69
     | 
    
      		$template->set_var('DISPLAY_ADVANCED', 'none');
     | 
  
  
    | 
      70
     | 
    
      		$template->set_var('DISPLAY_BASIC', '');
     | 
  
  
    | 
      71
     | 
    
      		$template->set_var('ADVANCED', 'no');
     | 
  
  
    | 
      72
     | 
    
      		$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>');
     | 
  
  
    | 
      73
     | 
    
      	}
 
     | 
  
  
    | 
      74
     | 
    
      	
 
     | 
  
  
    | 
      75
     | 
    
      	// Explode system permissions
 
     | 
  
  
    | 
      76
     | 
    
      	$system_permissions = explode(',', $group['system_permissions']);
     | 
  
  
    | 
      77
     | 
    
      	// Check system permissions boxes
 
     | 
  
  
    | 
      78
     | 
    
      	foreach($system_permissions AS $name) {
     | 
  
  
    | 
      79
     | 
    
      			$template->set_var($name.'_checked', 'checked');
 
     | 
  
  
    | 
      80
     | 
    
      	}
 
     | 
  
  
    | 
      81
     | 
    
      	// Explode module permissions
 
     | 
  
  
    | 
      82
     | 
    
      	$module_permissions = explode(',', $group['module_permissions']);
     | 
  
  
    | 
      83
     | 
    
      	// Explode template permissions
 
     | 
  
  
    | 
      84
     | 
    
      	$template_permissions = explode(',', $group['template_permissions']);
     | 
  
  
    | 
      85
     | 
    
      	
 
     | 
  
  
    | 
      86
     | 
    
      	// Insert values into module list
 
     | 
  
  
    | 
      87
     | 
    
      	$template->set_block('main_block', 'module_list_block', 'module_list');
     | 
  
  
    | 
      88
     | 
    
      	if ($handle = opendir(WB_PATH.'/modules/')) {
     | 
  
  
    | 
      89
     | 
    
      		while (false !== ($file = readdir($handle))) {
     | 
  
  
    | 
      90
     | 
    
      			if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
     | 
  
  
    | 
      91
     | 
    
      				// Include the modules info file
 
     | 
  
  
    | 
      92
     | 
    
      				require(WB_PATH.'/modules/'.$file.'/info.php');
 
     | 
  
  
    | 
      93
     | 
    
      				$template->set_var('VALUE', $file);
     | 
  
  
    | 
      94
     | 
    
      				$template->set_var('NAME', $module_name);
     | 
  
  
    | 
      95
     | 
    
      				if(!is_numeric(array_search($file, $module_permissions))) {
     | 
  
  
    | 
      96
     | 
    
      					$template->set_var('CHECKED', 'checked');
     | 
  
  
    | 
      97
     | 
    
      				} else {
     | 
  
  
    | 
      98
     | 
    
      					$template->set_var('CHECKED', '');
     | 
  
  
    | 
      99
     | 
    
      				}
 
     | 
  
  
    | 
      100
     | 
    
      				$template->parse('module_list', 'module_list_block', true);
     | 
  
  
    | 
      101
     | 
    
      			}
 
     | 
  
  
    | 
      102
     | 
    
      		}
 
     | 
  
  
    | 
      103
     | 
    
      	}
 
     | 
  
  
    | 
      104
     | 
    
      	
 
     | 
  
  
    | 
      105
     | 
    
      	// Insert values into template list
 
     | 
  
  
    | 
      106
     | 
    
      	$template->set_block('main_block', 'template_list_block', 'template_list');
     | 
  
  
    | 
      107
     | 
    
      	if ($handle = opendir(WB_PATH.'/templates/')) {
     | 
  
  
    | 
      108
     | 
    
      		while (false !== ($file = readdir($handle))) {
     | 
  
  
    | 
      109
     | 
    
      			if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) {
     | 
  
  
    | 
      110
     | 
    
      				// Include the modules info file
 
     | 
  
  
    | 
      111
     | 
    
      				require(WB_PATH.'/templates/'.$file.'/info.php');
 
     | 
  
  
    | 
      112
     | 
    
      				$template->set_var('VALUE', $file);
     | 
  
  
    | 
      113
     | 
    
      				$template->set_var('NAME', $template_name);
     | 
  
  
    | 
      114
     | 
    
      				if(!is_numeric(array_search($file, $template_permissions))) {
     | 
  
  
    | 
      115
     | 
    
      					$template->set_var('CHECKED', 'checked');
     | 
  
  
    | 
      116
     | 
    
      				} else {
     | 
  
  
    | 
      117
     | 
    
      					$template->set_var('CHECKED', '');
     | 
  
  
    | 
      118
     | 
    
      				}
 
     | 
  
  
    | 
      119
     | 
    
      				$template->parse('template_list', 'template_list_block', true);
     | 
  
  
    | 
      120
     | 
    
      			}
 
     | 
  
  
    | 
      121
     | 
    
      		}
 
     | 
  
  
    | 
      122
     | 
    
      	}
 
     | 
  
  
    | 
      123
     | 
    
      	
 
     | 
  
  
    | 
      124
     | 
    
      	// Insert language text and messages
 
     | 
  
  
    | 
      125
     | 
    
      	$template->set_var(array(
 
     | 
  
  
    | 
      126
     | 
    
      									'TEXT_RESET' => $TEXT['RESET'],
 
     | 
  
  
    | 
      127
     | 
    
      									'TEXT_ACTIVE' => $TEXT['ACTIVE'],
 
     | 
  
  
    | 
      128
     | 
    
      									'TEXT_DISABLED' => $TEXT['DISABLED'],
 
     | 
  
  
    | 
      129
     | 
    
      									'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
 
     | 
  
  
    | 
      130
     | 
    
      									'TEXT_USERNAME' => $TEXT['USERNAME'],
 
     | 
  
  
    | 
      131
     | 
    
      									'TEXT_PASSWORD' => $TEXT['PASSWORD'],
 
     | 
  
  
    | 
      132
     | 
    
      									'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
 
     | 
  
  
    | 
      133
     | 
    
      									'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
 
     | 
  
  
    | 
      134
     | 
    
      									'TEXT_EMAIL' => $TEXT['EMAIL'],
 
     | 
  
  
    | 
      135
     | 
    
      									'TEXT_GROUP' => $TEXT['GROUP'],
 
     | 
  
  
    | 
      136
     | 
    
      									'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
 
     | 
  
  
    | 
      137
     | 
    
      									'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
 
     | 
  
  
    | 
      138
     | 
    
      									'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
 
     | 
  
  
    | 
      139
     | 
    
      									'TEXT_NAME' => $TEXT['NAME'],
 
     | 
  
  
    | 
      140
     | 
    
      									'SECTION_PAGES' => $MENU['PAGES'],
 
     | 
  
  
    | 
      141
     | 
    
      									'SECTION_MEDIA' => $MENU['MEDIA'],
 
     | 
  
  
    | 
      142
     | 
    
      									'SECTION_MODULES' => $MENU['MODULES'],
 
     | 
  
  
    | 
      143
     | 
    
      									'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
 
     | 
  
  
    | 
      144
     | 
    
      									'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
 
     | 
  
  
    | 
      145
     | 
    
      									'SECTION_SETTINGS' => $MENU['SETTINGS'],
 
     | 
  
  
    | 
      146
     | 
    
      									'SECTION_USERS' => $MENU['USERS'],
 
     | 
  
  
    | 
      147
     | 
    
      									'SECTION_GROUPS' => $MENU['GROUPS'],
 
     | 
  
  
    | 
      148
     | 
    
      									'TEXT_VIEW' => $TEXT['VIEW'],
 
     | 
  
  
    | 
      149
     | 
    
      									'TEXT_ADD' => $TEXT['ADD'],
 
     | 
  
  
    | 
      150
     | 
    
      									'TEXT_LEVEL' => $TEXT['LEVEL'],
 
     | 
  
  
    | 
      151
     | 
    
      									'TEXT_MODIFY' => $TEXT['MODIFY'],
 
     | 
  
  
    | 
      152
     | 
    
      									'TEXT_DELETE' => $TEXT['DELETE'],
 
     | 
  
  
    | 
      153
     | 
    
      									'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
 
     | 
  
  
    | 
      154
     | 
    
      									'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
 
     | 
  
  
    | 
      155
     | 
    
      									'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
 
     | 
  
  
    | 
      156
     | 
    
      									'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
 
     | 
  
  
    | 
      157
     | 
    
      									'TEXT_RENAME' => $TEXT['RENAME'],
 
     | 
  
  
    | 
      158
     | 
    
      									'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
 
     | 
  
  
    | 
      159
     | 
    
      									'TEXT_BASIC' => $TEXT['BASIC'],
 
     | 
  
  
    | 
      160
     | 
    
      									'TEXT_ADVANCED' => $TEXT['ADVANCED'],
 
     | 
  
  
    | 
      161
     | 
    
      									'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD']
 
     | 
  
  
    | 
      162
     | 
    
      									)
 
     | 
  
  
    | 
      163
     | 
    
      							);
 
     | 
  
  
    | 
      164
     | 
    
      	
 
     | 
  
  
    | 
      165
     | 
    
      	// Parse template object
 
     | 
  
  
    | 
      166
     | 
    
      	$template->parse('main', 'main_block', false);
     | 
  
  
    | 
      167
     | 
    
      	$template->pparse('output', 'page');
     | 
  
  
    | 
      168
     | 
    
      } elseif($_POST['action'] == 'delete') {
     | 
  
  
    | 
      169
     | 
    
      	// Create new admin object
 
     | 
  
  
    | 
      170
     | 
    
      	$admin = new admin('Access', 'groups_delete', false);
     | 
  
  
    | 
      171
     | 
    
      	// Print header
 
     | 
  
  
    | 
      172
     | 
    
      	$admin->print_header();
 
     | 
  
  
    | 
      173
     | 
    
      	// Delete the group
 
     | 
  
  
    | 
      174
     | 
    
      	$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1");
     | 
  
  
    | 
      175
     | 
    
      	if($database->is_error()) {
     | 
  
  
    | 
      176
     | 
    
      		$admin->print_error($database->get_error());
 
     | 
  
  
    | 
      177
     | 
    
      	} else {
     | 
  
  
    | 
      178
     | 
    
      		// Delete users in the group
 
     | 
  
  
    | 
      179
     | 
    
      		$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'");
     | 
  
  
    | 
      180
     | 
    
      		if($database->is_error()) {
     | 
  
  
    | 
      181
     | 
    
      			$admin->print_error($database->get_error());
 
     | 
  
  
    | 
      182
     | 
    
      		} else {
     | 
  
  
    | 
      183
     | 
    
      			$admin->print_success($MESSAGE['GROUPS']['DELETED']);
 
     | 
  
  
    | 
      184
     | 
    
      		}
 
     | 
  
  
    | 
      185
     | 
    
      	}
 
     | 
  
  
    | 
      186
     | 
    
      }
 
     | 
  
  
    | 
      187
     | 
    
      
 
     | 
  
  
    | 
      188
     | 
    
      // Print admin footer
 
     | 
  
  
    | 
      189
     | 
    
      $admin->print_footer();
 
     | 
  
  
    | 
      190
     | 
    
      
 
     | 
  
  
    | 
      191
     | 
    
      ?>
 
     |