| 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 = Translate::getinstance();
|
| 24 |
|
|
$mLang->enableAddon('admin\groups');
|
| 25 |
1386
|
Luisehahne
|
|
| 26 |
1710
|
Luisehahne
|
$mod_path = dirname(str_replace('\\', '/', __FILE__));
|
| 27 |
|
|
$mod_name = basename($mod_path);
|
| 28 |
|
|
$output = '';
|
| 29 |
1386
|
Luisehahne
|
|
| 30 |
1710
|
Luisehahne
|
if( isset($_POST['action_cancel']))
|
| 31 |
|
|
{
|
| 32 |
|
|
unset($_POST);
|
| 33 |
|
|
}
|
| 34 |
1386
|
Luisehahne
|
|
| 35 |
1710
|
Luisehahne
|
$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 |
1386
|
Luisehahne
|
|
| 42 |
1710
|
Luisehahne
|
$group_id = ( isset($_POST['group_id']) ? intval($_POST['group_id']) : '0' );
|
| 43 |
1386
|
Luisehahne
|
|
| 44 |
1710
|
Luisehahne
|
switch($submit_action) :
|
| 45 |
|
|
case 'delete': // delete the group
|
| 46 |
1784
|
Luisehahne
|
$admin = new admin('Access', 'groups_delete', false);
|
| 47 |
1710
|
Luisehahne
|
// $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 |
1386
|
Luisehahne
|
|
| 115 |
1710
|
Luisehahne
|
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 |
1386
|
Luisehahne
|
}
|
| 129 |
1710
|
Luisehahne
|
// start dispatcher maintenance
|
| 130 |
|
|
if(!defined('WB_PATH'))
|
| 131 |
|
|
{
|
| 132 |
1883
|
Luisehahne
|
$config_file = realpath('../../config.php');
|
| 133 |
|
|
if(file_exists($config_file) && !defined('WB_URL'))
|
| 134 |
|
|
{
|
| 135 |
|
|
require($config_file);
|
| 136 |
|
|
}
|
| 137 |
1386
|
Luisehahne
|
}
|
| 138 |
1883
|
Luisehahne
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
| 139 |
1710
|
Luisehahne
|
admin_groups_index();
|
| 140 |
|
|
exit;
|
| 141 |
|
|
// end of file
|