1 |
1710
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @category admin
|
4 |
|
|
* @package groups
|
5 |
|
|
* @author WebsiteBaker Project, Independend-Software-Team
|
6 |
|
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
7 |
|
|
* @link http://www.websitebaker2.org/
|
8 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
9 |
|
|
* @platform WebsiteBaker 2.8.x
|
10 |
|
|
* @requirements PHP 5.2.2 and higher
|
11 |
|
|
* @version $Id$
|
12 |
|
|
* @filesource $HeadURL$
|
13 |
|
|
* @lastmodified $Date$
|
14 |
|
|
* @description all basic actions of this module, called by dispatcher only.
|
15 |
|
|
*/
|
16 |
|
|
|
17 |
|
|
// Must include code to stop this file being access directly
|
18 |
|
|
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
19 |
|
|
|
20 |
|
|
/* *****************************************************************************
|
21 |
|
|
* Show groupslist with delete-/ modify-button
|
22 |
|
|
* @access public
|
23 |
|
|
* @param object $admin: admin-object
|
24 |
|
|
* @return string: parsed HTML-content
|
25 |
|
|
*/
|
26 |
|
|
function show_grouplist($admin)
|
27 |
|
|
{
|
28 |
1782
|
Luisehahne
|
global $TEXT, $MESSAGE, $MENU, $HEADING;
|
29 |
1710
|
Luisehahne
|
$database = WbDatabase::getInstance();
|
30 |
|
|
$mLang = ModLanguage::getInstance();
|
31 |
|
|
// Create new template object for the modify/remove section
|
32 |
|
|
$tpl = new Template(dirname($admin->correct_theme_source('groups_list.htt')),'keep');
|
33 |
|
|
$tpl->set_file('page', 'groups_list.htt');
|
34 |
|
|
$tpl->set_block('page', 'main_block', 'main');
|
35 |
|
|
|
36 |
|
|
$tpl->set_var('ACTION_URL', $_SERVER['SCRIPT_NAME']);
|
37 |
|
|
$tpl->set_var('FTAN', $admin->getFTAN());
|
38 |
|
|
|
39 |
|
|
// -- if permission then activate link 'manage users'
|
40 |
|
|
$tpl->set_block('main_block', 'show_cmd_manage_users_block', 'show_cmd_manage_users');
|
41 |
|
|
if($admin->get_permission('users') == true)
|
42 |
|
|
{
|
43 |
|
|
$tpl->set_var('TEXT_MANAGE_USERS', $mLang->TEXT_MANAGE_USERS);
|
44 |
|
|
$tpl->set_var('LINK_MANAGE_USERS', ADMIN_URL.'/users/index'.PAGE_EXTENSION);
|
45 |
|
|
$tpl->parse('show_cmd_manage_users', 'show_cmd_manage_users_block', true);
|
46 |
|
|
}else { // switch off cmd_manage_groups_block
|
47 |
|
|
$tpl->parse('show_cmd_manage_users', '');
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
$tpl->set_block('main_block', 'show_cmd_group_list_block', 'show_cmd_group_list');
|
51 |
|
|
if( $admin->get_permission('groups_view') == true )
|
52 |
|
|
{
|
53 |
|
|
$tpl->set_var('CONTENT_HEADER', $mLang->HEADING_VIEW_GROUPS);
|
54 |
|
|
if( ($admin->get_permission('groups_modify') == true) )
|
55 |
|
|
{
|
56 |
|
|
$tpl->set_var('CONTENT_HEADER', $mLang->HEADING_MODIFY_DELETE_GROUP);
|
57 |
|
|
}
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
$tpl->set_var('FORM_NAME_GROUPLIST', 'frm_group_list');
|
61 |
|
|
|
62 |
|
|
// -- build grouplist from database
|
63 |
|
|
$tpl->set_block('show_cmd_group_list_block', 'grouplist_block', 'grouplist');
|
64 |
|
|
// Insert first value to say please select
|
65 |
|
|
// $tpl->set_var('GROUP_ID', $admin->getIDKEY(0));
|
66 |
|
|
$tpl->set_var('GROUP_ID', 0);
|
67 |
|
|
$tpl->set_var('GROUP_NAME', '');
|
68 |
|
|
$tpl->set_var('GROUP_DISPLAY_NAME', $mLang->TEXT_PLEASE_SELECT.'...');
|
69 |
|
|
$tpl->set_var('CSS_GROUP_DELETED', '');
|
70 |
|
|
|
71 |
|
|
$tpl->parse('grouplist', 'grouplist_block', true);
|
72 |
|
|
$sql = 'SELECT `group_id`, `name` ';
|
73 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'groups` ';
|
74 |
|
|
$sql .= 'WHERE `group_id` > 1 ORDER BY `name` ';
|
75 |
|
|
if( ($res_groups = $database->query($sql)) != false )
|
76 |
|
|
{
|
77 |
|
|
while($rec_group = $res_groups->fetchRow(MYSQL_ASSOC))
|
78 |
|
|
{
|
79 |
1790
|
Luisehahne
|
if( in_array($rec_group['group_id'], explode( ',', $admin->get_session('GROUPS_ID') ) ) ) { continue; }
|
80 |
1710
|
Luisehahne
|
// $tpl->set_var('GROUP_ID', $admin->getIDKEY($rec_group['group_id']));
|
81 |
|
|
$tpl->set_var('GROUP_ID', $rec_group['group_id']);
|
82 |
|
|
$tpl->set_var('GROUP_NAME', $rec_group['name']);
|
83 |
|
|
$tpl->set_var('GROUP_DISPLAY_NAME', $rec_group['name']);
|
84 |
|
|
$tpl->parse('grouplist', 'grouplist_block', true);
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
$sPermission = 'none';
|
89 |
|
|
$sPermission = $admin->get_permission('groups_view') ? 'permView' : $sPermission;
|
90 |
|
|
$sPermission = $admin->get_permission('groups_add') ? 'permAdd' : $sPermission;
|
91 |
|
|
$sPermission = $admin->get_permission('groups_modify') ? 'permModify' : $sPermission;
|
92 |
|
|
|
93 |
|
|
// if( ($admin->get_permission('groups_modify') == false) && ($admin->get_permission('groups_delete') == false) )
|
94 |
|
|
if( ($admin->get_permission('groups') == false) )
|
95 |
|
|
{
|
96 |
|
|
$tpl->parse('show_cmd_group_list', '');
|
97 |
|
|
} else {
|
98 |
|
|
$tpl->parse('show_cmd_group_list', 'show_cmd_group_list_block', true);
|
99 |
|
|
// -- if permission then activate button 'modify groups'
|
100 |
|
|
$tpl->set_block('show_cmd_group_list', 'show_cmd_modify_group_block', 'show_cmd_modify_group');
|
101 |
|
|
if( $admin->get_permission('groups') == true )
|
102 |
|
|
{
|
103 |
|
|
$tpl->parse('show_cmd_modify_group', 'show_cmd_modify_group_block', true);
|
104 |
|
|
}else {
|
105 |
|
|
$tpl->parse('show_cmd_modify_group', '');
|
106 |
|
|
}
|
107 |
|
|
// -- if permission then activate button 'delete groups'
|
108 |
|
|
$tpl->set_block('show_cmd_group_list', 'show_cmd_delete_group_block', 'show_cmd_delete_group');
|
109 |
|
|
if($admin->get_permission('groups_delete') == true)
|
110 |
|
|
{
|
111 |
|
|
$tpl->parse('show_cmd_delete_group', 'show_cmd_delete_group_block', true);
|
112 |
|
|
}else {
|
113 |
|
|
$tpl->parse('show_cmd_delete_group', '');
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
$tpl->set_block('main_block', 'show_cmd_add_input_block', 'show_cmd_add_input');
|
119 |
|
|
if($admin->get_permission('groups_add') )
|
120 |
|
|
{
|
121 |
|
|
$tpl->set_var('DISPLAY_ADD', '');
|
122 |
|
|
$tpl->set_var('GROUP_ACTION_URL', $_SERVER['SCRIPT_NAME']);
|
123 |
|
|
$tpl->set_var('GROUPS_HEADER', $mLang->HEADING_ADD_GROUP );
|
124 |
|
|
$tpl->set_var('SUBMIT_TITLE', $mLang->TEXT_ADD);
|
125 |
|
|
$tpl->set_var('ACTION_HANDLE', 'action_modify');
|
126 |
|
|
$tpl->set_var('ACTION_HIDDEN', 'action_add');
|
127 |
|
|
$tpl->set_var('FORM_NAME_GROUPMASK', 'frm_addnew_group');
|
128 |
|
|
$tpl->parse('show_cmd_add_input', 'show_cmd_add_input_block', false);
|
129 |
|
|
} else {
|
130 |
|
|
$tpl->parse('show_cmd_add_input', '');
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
// insert urls
|
134 |
|
|
$tpl->set_var(array(
|
135 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
136 |
|
|
'WB_URL' => WB_URL,
|
137 |
|
|
'THEME_URL' => THEME_URL
|
138 |
|
|
)
|
139 |
|
|
);
|
140 |
|
|
// Insert language text and messages
|
141 |
|
|
$tpl->set_var(array(
|
142 |
|
|
'TEXT_MODIFY' => ($admin->get_permission('groups_modify') == true) ? $mLang->TEXT_MODIFY : $mLang->TEXT_VIEW,
|
143 |
|
|
'TEXT_DELETE' => $mLang->TEXT_DELETE,
|
144 |
1782
|
Luisehahne
|
'CONFIRM_DELETE' => $MESSAGE['GROUPS_CONFIRM_DELETE']
|
145 |
1710
|
Luisehahne
|
));
|
146 |
|
|
|
147 |
|
|
// Parse template object
|
148 |
|
|
$tpl->parse('main', 'main_block', false);
|
149 |
|
|
$output = $tpl->finish($tpl->parse('output', 'page'));
|
150 |
|
|
unset($tpl);
|
151 |
|
|
return $output;
|
152 |
|
|
}
|