Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         groups
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.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 1907 2013-06-07 02:30:42Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/groups/index.php $
14
 * @lastmodified    $Date: 2013-06-07 04:30:42 +0200 (Fri, 07 Jun 2013) $
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
		$mLang = Translate::getinstance();
26
		$mLang->enableAddon('admin\groups');
27

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

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

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

    
44
		$group_id = ( isset($_POST['group_id']) ? intval($_POST['group_id']) :  '0' );
45

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

    
117
		if(!msgQueue::isEmpty())
118
		{
119
		}
120
		if( ($msg = msgQueue::getSuccess()) != '')
121
		{
122
			$output = $admin->format_message($msg, 'ok').$output;
123
		}
124
		if( ($msg = msgQueue::getError()) != '')
125
		{
126
			$output = $admin->format_message($msg, 'error').$output;
127
		}
128
		print $output;
129
		$admin->print_footer();
130
		$mLang->disableAddon();
131
	}
132
	// start dispatcher maintenance
133
	if(!defined('WB_PATH'))
134
	{
135
		$config_file = realpath('../../config.php');
136
		if(file_exists($config_file) && !defined('WB_URL'))
137
		{
138
			require($config_file);
139
		}
140
	}
141
	if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
142
	admin_groups_index();
143
	exit;
144
// end of file
(4-4/6)