Revision 1710
Added by Dietmar about 12 years ago
index.php | ||
---|---|---|
4 | 4 |
* @category admin |
5 | 5 |
* @package groups |
6 | 6 |
* @author Ryan Djurovich, WebsiteBaker Project |
7 |
* @copyright 2009-2011, Website Baker Org. e.V.
|
|
7 |
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
|
8 | 8 |
* @link http://www.websitebaker2.org/ |
9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
10 | 10 |
* @platform WebsiteBaker 2.8.x |
... | ... | |
12 | 12 |
* @version $Id$ |
13 | 13 |
* @filesource $HeadURL$ |
14 | 14 |
* @lastmodified $Date$ |
15 |
* @description action dispatcher of this module. |
|
15 | 16 |
* |
16 |
*/ |
|
17 |
*/ |
|
18 |
/* ************************************************************************** */ |
|
17 | 19 |
|
18 |
// Print admin header
|
|
19 |
require('../../config.php');
|
|
20 |
require_once(WB_PATH.'/framework/class.admin.php');
|
|
21 |
$admin = new admin('Access', 'groups');
|
|
22 |
$ftan = $admin->getFTAN();
|
|
20 |
function admin_groups_index()
|
|
21 |
{
|
|
22 |
$database = WbDatabase::getInstance();
|
|
23 |
$mLang = ModLanguage::getInstance();
|
|
24 |
$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
|
|
23 | 25 |
|
24 |
// Setup template object, parse vars to it, then parse it |
|
25 |
// Create new template object |
|
26 |
$template = new Template(dirname($admin->correct_theme_source('groups.htt'))); |
|
27 |
// $template->debug = true; |
|
28 |
$template->set_file('page', 'groups.htt'); |
|
29 |
$template->set_block('page', 'main_block', 'main'); |
|
30 |
$template->set_block('main_block', 'manage_users_block', 'users'); |
|
31 |
// insert urls |
|
32 |
$template->set_var(array( |
|
33 |
'ADMIN_URL' => ADMIN_URL, |
|
34 |
'WB_URL' => WB_URL, |
|
35 |
'THEME_URL' => THEME_URL, |
|
36 |
'FTAN' => $ftan |
|
37 |
) |
|
38 |
); |
|
26 |
$mod_path = dirname(str_replace('\\', '/', __FILE__)); |
|
27 |
$mod_name = basename($mod_path); |
|
28 |
$output = ''; |
|
39 | 29 |
|
40 |
// Get existing value from database |
|
41 |
// $database = new database(); |
|
42 |
$query = "SELECT group_id,name FROM ".TABLE_PREFIX."groups WHERE group_id != '1'"; |
|
43 |
$results = $database->query($query); |
|
44 |
if($database->is_error()) { |
|
45 |
$admin->print_error($database->get_error(), 'index.php'); |
|
46 |
} |
|
30 |
if( isset($_POST['action_cancel'])) |
|
31 |
{ |
|
32 |
unset($_POST); |
|
33 |
} |
|
47 | 34 |
|
48 |
// Insert values into the modify/remove menu |
|
49 |
$template->set_block('main_block', 'list_block', 'list'); |
|
50 |
if($results->numRows() > 0) { |
|
51 |
// Insert first value to say please select |
|
52 |
$template->set_var('VALUE', ''); |
|
53 |
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...'); |
|
54 |
$template->parse('list', 'list_block', true); |
|
55 |
// Loop through groups |
|
56 |
while($group = $results->fetchRow()) { |
|
57 |
$template->set_var('VALUE',$admin->getIDKEY($group['group_id'])); |
|
58 |
$template->set_var('NAME', $group['name']); |
|
59 |
$template->parse('list', 'list_block', true); |
|
60 |
} |
|
61 |
} else { |
|
62 |
// Insert single value to say no groups were found |
|
63 |
$template->set_var('NAME', $TEXT['NONE_FOUND']); |
|
64 |
$template->parse('list', 'list_block', true); |
|
65 |
} |
|
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 ); |
|
66 | 41 |
|
67 |
// Insert permissions values |
|
68 |
if($admin->get_permission('groups_add') != true) { |
|
69 |
$template->set_var('DISPLAY_ADD', 'hide'); |
|
70 |
} |
|
71 |
if($admin->get_permission('groups_modify') != true) { |
|
72 |
$template->set_var('DISPLAY_MODIFY', 'hide'); |
|
73 |
} |
|
74 |
if($admin->get_permission('groups_delete') != true) { |
|
75 |
$template->set_var('DISPLAY_DELETE', 'hide'); |
|
76 |
} |
|
42 |
$group_id = ( isset($_POST['group_id']) ? intval($_POST['group_id']) : '0' ); |
|
77 | 43 |
|
78 |
// Insert language headings |
|
79 |
$template->set_var(array( |
|
80 |
'HEADING_MODIFY_DELETE_GROUP' => $HEADING['MODIFY_DELETE_GROUP'], |
|
81 |
'HEADING_ADD_GROUP' => $HEADING['ADD_GROUP'] |
|
82 |
) |
|
83 |
); |
|
84 |
// Insert language text and messages |
|
85 |
$template->set_var(array( |
|
86 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
87 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
88 |
'TEXT_MANAGE_USERS' => ( $admin->get_permission('users') == true ) ? $TEXT['MANAGE_USERS']: "", |
|
89 |
'CONFIRM_DELETE' => $MESSAGE['GROUPS']['CONFIRM_DELETE'] |
|
90 |
) |
|
91 |
); |
|
92 |
if ( $admin->get_permission('users') == true ) $template->parse("users", "manage_users_block", true); |
|
93 |
// Parse template object |
|
94 |
$template->parse('main', 'main_block', false); |
|
95 |
$template->pparse('output', 'page'); |
|
44 |
switch($submit_action) : |
|
45 |
case 'delete': // delete the group |
|
46 |
$admin = new admin('Access', 'groups_delete'); |
|
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 |
|
96 | 114 |
|
97 |
// Setup template object, parse vars to it, then parse it |
|
98 |
// Create new template object |
|
99 |
$template = new Template(dirname($admin->correct_theme_source('groups_form.htt'))); |
|
100 |
// $template->debug = true; |
|
101 |
$template->set_file('page', 'groups_form.htt'); |
|
102 |
$template->set_block('page', 'main_block', 'main'); |
|
103 |
$template->set_var('DISPLAY_EXTRA', 'display:none;'); |
|
104 |
$template->set_var('ACTION_URL', ADMIN_URL.'/groups/add.php'); |
|
105 |
$template->set_var('SUBMIT_TITLE', $TEXT['ADD']); |
|
106 |
$template->set_var('ADVANCED_LINK', 'index.php'); |
|
107 |
|
|
108 |
// Tell the browser whether or not to show advanced options |
|
109 |
if ( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) { |
|
110 |
$template->set_var('DISPLAY_ADVANCED', ''); |
|
111 |
$template->set_var('DISPLAY_BASIC', 'display:none;'); |
|
112 |
$template->set_var('ADVANCED', 'yes'); |
|
113 |
$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']); |
|
114 |
} else { |
|
115 |
$template->set_var('DISPLAY_ADVANCED', 'display:none;'); |
|
116 |
$template->set_var('DISPLAY_BASIC', ''); |
|
117 |
$template->set_var('ADVANCED', 'no'); |
|
118 |
$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>'); |
|
119 |
} |
|
120 |
|
|
121 |
// Insert permissions values |
|
122 |
if($admin->get_permission('groups_add') != true) { |
|
123 |
$template->set_var('DISPLAY_ADD', 'hide'); |
|
124 |
} |
|
125 |
|
|
126 |
// Insert values into module list |
|
127 |
$template->set_block('main_block', 'module_list_block', 'module_list'); |
|
128 |
$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "module" AND `function` = "page" ORDER BY `name`'); |
|
129 |
if($result->numRows() > 0) { |
|
130 |
while($addon = $result->fetchRow()) { |
|
131 |
$template->set_var('VALUE', $addon['directory']); |
|
132 |
$template->set_var('NAME', $addon['name']); |
|
133 |
$template->parse('module_list', 'module_list_block', true); |
|
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(); |
|
134 | 128 |
} |
135 |
} |
|
136 |
|
|
137 |
// Insert values into template list |
|
138 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
139 |
$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" ORDER BY `name`'); |
|
140 |
if($result->numRows() > 0) { |
|
141 |
while($addon = $result->fetchRow()) { |
|
142 |
$template->set_var('VALUE', $addon['directory']); |
|
143 |
$template->set_var('NAME', $addon['name']); |
|
144 |
$template->parse('template_list', 'template_list_block', true); |
|
129 |
// start dispatcher maintenance |
|
130 |
if(!defined('WB_PATH')) |
|
131 |
{ |
|
132 |
require('../../config.php'); |
|
133 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
145 | 134 |
} |
146 |
} |
|
147 |
|
|
148 |
// Insert language text and messages |
|
149 |
$template->set_var(array( |
|
150 |
'TEXT_RESET' => $TEXT['RESET'], |
|
151 |
'TEXT_ACTIVE' => $TEXT['ACTIVE'], |
|
152 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
153 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
154 |
'TEXT_USERNAME' => $TEXT['USERNAME'], |
|
155 |
'TEXT_PASSWORD' => $TEXT['PASSWORD'], |
|
156 |
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], |
|
157 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
158 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
159 |
'TEXT_GROUP' => $TEXT['GROUP'], |
|
160 |
'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'], |
|
161 |
'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'], |
|
162 |
'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'], |
|
163 |
'TEXT_NAME' => $TEXT['NAME'], |
|
164 |
'SECTION_PAGES' => $MENU['PAGES'], |
|
165 |
'SECTION_MEDIA' => $MENU['MEDIA'], |
|
166 |
'SECTION_MODULES' => $MENU['MODULES'], |
|
167 |
'SECTION_TEMPLATES' => $MENU['TEMPLATES'], |
|
168 |
'SECTION_SETTINGS' => $MENU['SETTINGS'], |
|
169 |
'SECTION_LANGUAGES' => $MENU['LANGUAGES'], |
|
170 |
'SECTION_USERS' => $MENU['USERS'], |
|
171 |
'SECTION_GROUPS' => $MENU['GROUPS'], |
|
172 |
'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'], |
|
173 |
'TEXT_VIEW' => $TEXT['VIEW'], |
|
174 |
'TEXT_ADD' => $TEXT['ADD'], |
|
175 |
'TEXT_LEVEL' => $TEXT['LEVEL'], |
|
176 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
177 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
178 |
'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'], |
|
179 |
'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'], |
|
180 |
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'], |
|
181 |
'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], |
|
182 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
183 |
'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], |
|
184 |
'TEXT_BASIC' => $TEXT['BASIC'], |
|
185 |
'TEXT_ADVANCED' => $TEXT['ADVANCED'], |
|
186 |
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'], |
|
187 |
'CHECKED' => ' checked="checked"', |
|
188 |
'ADMIN_URL' => ADMIN_URL, |
|
189 |
'WB_URL' => WB_URL, |
|
190 |
'THEME_URL' => THEME_URL, |
|
191 |
'FTAN' => $ftan |
|
192 |
) |
|
193 |
); |
|
194 |
|
|
195 |
// Parse template for add group form |
|
196 |
$template->parse('main', 'main_block', false); |
|
197 |
$template->pparse('output', 'page'); |
|
198 |
|
|
199 |
// Print the admin footer |
|
200 |
$admin->print_footer(); |
|
135 |
admin_groups_index(); |
|
136 |
exit; |
|
137 |
// end of file |
Also available in: Unified diff
! update folder admin/groups, admin/users, admin/skel/htt