Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         groups
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: index.php 1784 2012-10-11 21:59:45Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/groups/index.php $
14
 * @lastmodified    $Date: 2012-10-11 23:59:45 +0200 (Thu, 11 Oct 2012) $
15
 * @description     action dispatcher of this module.
16
 *
17
 */
18
/* ************************************************************************** */
19

    
20
	function admin_groups_index()
21
	{
22
		$database = WbDatabase::getInstance();
23
		$mLang = ModLanguage::getInstance();
24
		$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
25

    
26
		$mod_path = dirname(str_replace('\\', '/', __FILE__));
27
		$mod_name = basename($mod_path);
28
		$output = '';
29

    
30
		if( isset($_POST['action_cancel']))
31
		{
32
			unset($_POST);
33
		}
34

    
35
		$submit_action = 'show'; // default action
36
		$submit_action = ( isset($_POST['action_cancel']) ? 'cancel' : $submit_action );
37
		$submit_action = ( isset($_POST['action_delete']) ? 'delete' : $submit_action );
38
		// $submit_action = ( isset($_POST['action_add'])    ? 'modify' : $submit_action );
39
		$submit_action = ( isset($_POST['action_modify']) ? 'modify' : $submit_action );
40
		$submit_action = ( isset($_POST['action_save'])   ? 'save'   : $submit_action );
41

    
42
		$group_id = ( isset($_POST['group_id']) ? intval($_POST['group_id']) :  '0' );
43

    
44
		switch($submit_action) :
45
			case 'delete': // delete the group
46
				$admin = new admin('Access', 'groups_delete', false);
47
				// $group_id = $admin->checkIDKEY($_POST['group_id']);
48
				msgQueue::clear();
49
				include($mod_path.'/delete.inc.php');
50
				delete_group($admin, $group_id);
51
				if( ($msg = msgQueue::getSuccess()) != '')
52
				{
53
					include($mod_path.'/groups_list.inc.php');
54
					$output = show_grouplist($admin);
55
				}
56
				if( ($msg = msgQueue::getError()) != '')
57
				{
58
					include($mod_path.'/groups_list.inc.php');
59
					$output = show_grouplist($admin);
60
				}
61
				break;
62
			case 'save': // insert/update group
63
				if( $group_id == 0 )
64
				{
65
					$admin = new admin('Access', 'groups_add',false);
66
				}else {
67
					$admin = new admin('Access', 'groups_modify',false);
68
				}
69
				msgQueue::clear();
70
				include($mod_path.'/save.inc.php');
71
				$group_id = save_group($admin, $group_id);
72
				if(!msgQueue::isEmpty())
73
				{
74
				}
75
				if( ($msg = msgQueue::getSuccess()) != '')
76
				{
77
					include($mod_path.'/groups_list.inc.php');
78
					$output = show_grouplist($admin);
79
				}
80
				if( ($msg = msgQueue::getError()) != '')
81
				{
82
					// $group_id = $admin->checkIDKEY($_POST['group_id']);
83
					include($mod_path.'/groups_mask.inc.php');
84
					$output = show_groupmask($admin, $group_id);
85
				}
86
				break;
87
			case 'modify': // insert/update group
88
				$admin = new admin('Access', 'groups');
89
				msgQueue::clear();
90
				if( ($group_id != 1 ) && ($admin->get_permission('groups')) )
91
				{
92
					// $group_id = $admin->checkIDKEY($_POST['group_id']);
93
					include($mod_path.'/groups_mask.inc.php');
94
					$output = show_groupmask($admin, $group_id);
95
				} else {
96
					include($mod_path.'/groups_list.inc.php');
97
					$output  = show_grouplist($admin, $group_id);
98
				}
99
				break;
100
			default: // show grouplist with empty modify mask
101
				$admin = new admin('Access', 'groups');
102
				$group_id = isset($_POST['group_id']) ? (int)$_POST['group_id'] : 0;
103
				msgQueue::clear();
104
				if($group_id > 1) // prevent 'admin' [ID 1] from modify
105
				{
106
					// $group_id = $admin->checkIDKEY($_POST['group_id']);
107
					include($mod_path.'/groups_mask.inc.php');
108
					$output .= show_groupmask($admin, $group_id);
109
				}else { // if invalid GroupID is called, fall back to 'show-mode'
110
					include($mod_path.'/groups_list.inc.php');
111
					$output  = show_grouplist($admin);
112
				}
113
		endswitch; // end of switch
114

    
115
		if(!msgQueue::isEmpty())
116
		{
117
		}
118
		if( ($msg = msgQueue::getSuccess()) != '')
119
		{
120
			$output = $admin->format_message($msg, 'ok').$output;
121
		}
122
		if( ($msg = msgQueue::getError()) != '')
123
		{
124
			$output = $admin->format_message($msg, 'error').$output;
125
		}
126
		print $output;
127
		$admin->print_footer();
128
	}
129
	// start dispatcher maintenance
130
	if(!defined('WB_PATH'))
131
	{
132
		require('../../config.php');
133
		require_once(WB_PATH.'/framework/class.admin.php');
134
	}
135
	admin_groups_index();
136
	exit;
137
// end of file
(4-4/6)