Project

General

Profile

1 1386 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         groups
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1907 Luisehahne
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9 1386 Luisehahne
 * @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$
13 1907 Luisehahne
 * @filesource      $HeadURL$
14 1386 Luisehahne
 * @lastmodified    $Date$
15 1710 Luisehahne
 * @description     action dispatcher of this module.
16 1386 Luisehahne
 *
17 1710 Luisehahne
 */
18
/* ************************************************************************** */
19 1386 Luisehahne
20 1710 Luisehahne
	function admin_groups_index()
21
	{
22
		$database = WbDatabase::getInstance();
23 1883 Luisehahne
//		$mLang = ModLanguage::getInstance();
24
//		$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
25
		$mLang = Translate::getinstance();
26
		$mLang->enableAddon('admin\groups');
27 1386 Luisehahne
28 1710 Luisehahne
		$mod_path = dirname(str_replace('\\', '/', __FILE__));
29
		$mod_name = basename($mod_path);
30
		$output = '';
31 1386 Luisehahne
32 1710 Luisehahne
		if( isset($_POST['action_cancel']))
33
		{
34
			unset($_POST);
35
		}
36 1386 Luisehahne
37 1710 Luisehahne
		$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 1386 Luisehahne
44 1710 Luisehahne
		$group_id = ( isset($_POST['group_id']) ? intval($_POST['group_id']) :  '0' );
45 1386 Luisehahne
46 1710 Luisehahne
		switch($submit_action) :
47
			case 'delete': // delete the group
48 1784 Luisehahne
				$admin = new admin('Access', 'groups_delete', false);
49 1710 Luisehahne
				// $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 1386 Luisehahne
117 1710 Luisehahne
		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 1883 Luisehahne
		$mLang->disableAddon();
131 1386 Luisehahne
	}
132 1710 Luisehahne
	// start dispatcher maintenance
133
	if(!defined('WB_PATH'))
134
	{
135 1883 Luisehahne
		$config_file = realpath('../../config.php');
136
		if(file_exists($config_file) && !defined('WB_URL'))
137
		{
138
			require($config_file);
139
		}
140 1386 Luisehahne
	}
141 1883 Luisehahne
	if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
142 1710 Luisehahne
	admin_groups_index();
143
	exit;
144
// end of file