1 |
1710
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @category admin
|
4 |
|
|
* @package groups
|
5 |
|
|
* @author Independend-Software-Team
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
1907
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker.org/
|
9 |
1710
|
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 |
1710
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
* @description all basic actions of this module, called by dispatcher only.
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
// Must include code to stop this file being access directly
|
19 |
|
|
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
20 |
|
|
|
21 |
|
|
/* *****************************************************************************
|
22 |
|
|
* Delete an existing group and remove existing group in user
|
23 |
|
|
* @access public
|
24 |
|
|
* @param object $admin: admin-object
|
25 |
|
|
* @param int $group_id: ID from group to delete
|
26 |
|
|
* @return bool: true or false
|
27 |
|
|
*/
|
28 |
|
|
function delete_group($admin, $group_id = 0)
|
29 |
|
|
{
|
30 |
1883
|
Luisehahne
|
// global $MESSAGE;
|
31 |
1710
|
Luisehahne
|
$database = WbDatabase::getInstance();
|
32 |
1883
|
Luisehahne
|
$mLang = Translate::getInstance();
|
33 |
1710
|
Luisehahne
|
// first check form-tan
|
34 |
|
|
if($admin->checkFTAN())
|
35 |
|
|
{
|
36 |
|
|
if($group_id > 1) // prevent admin [ID 1] from being deleted
|
37 |
|
|
{
|
38 |
|
|
$sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'groups` WHERE `group_id` = '.$group_id;
|
39 |
|
|
$groupname = ($database->get_one($sql));
|
40 |
|
|
// $sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups` ';
|
41 |
|
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'groups` ';
|
42 |
|
|
$sql .= 'WHERE `group_id` = '.$group_id;
|
43 |
|
|
if($database->query($sql) != false)
|
44 |
|
|
{
|
45 |
|
|
// remove group from users groups_id
|
46 |
1883
|
Luisehahne
|
msgQueue :: add($mLang->MESSAGE_GROUPS_DELETED,true);
|
47 |
1710
|
Luisehahne
|
$sql = 'SELECT `user_id`, `groups_id`, `home_folder` FROM `'.TABLE_PREFIX.'users` WHERE user_id != 1';
|
48 |
|
|
if(($res_users = $database->query($sql)) && ($res_users->numRows() > 0) )
|
49 |
|
|
{
|
50 |
|
|
while($rec_users = $res_users->fetchRow(MYSQL_ASSOC))
|
51 |
|
|
{
|
52 |
|
|
$user_id = $rec_users['user_id'];
|
53 |
|
|
$groups_id = explode(',',$rec_users['groups_id']);
|
54 |
|
|
|
55 |
|
|
if( is_numeric($x = array_search($group_id, $groups_id)) )
|
56 |
|
|
{
|
57 |
|
|
unset($groups_id[$x]);
|
58 |
|
|
$groups_id = (sizeof($groups_id) == 0) ? FRONTEND_SIGNUP : implode(',',$groups_id);
|
59 |
|
|
$groups_id = ( ($groups_id == 1) && (trim($rec_users['home_folder']) != '') ) ? FRONTEND_SIGNUP : $groups_id;
|
60 |
|
|
$sql = 'UPDATE `'.TABLE_PREFIX.'users` SET ';
|
61 |
|
|
$sql .= '`groups_id` = \''.$groups_id.'\' ';
|
62 |
|
|
$sql .= 'WHERE `user_id` = '.$user_id;
|
63 |
|
|
if( $database->query($sql) )
|
64 |
|
|
{
|
65 |
|
|
$sql_info = mysql_info($database->db_handle);
|
66 |
|
|
if(preg_match('/matched: *([1-9][0-9]*)/i', $sql_info) != 1)
|
67 |
|
|
{
|
68 |
1883
|
Luisehahne
|
msgQueue :: add($mLang->MESSAGE_RECORD_MODIFIED_FAILED );
|
69 |
1710
|
Luisehahne
|
}
|
70 |
|
|
} else {
|
71 |
|
|
|
72 |
|
|
msgQueue :: add($database->get_error());
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
// $admin->print_success($msg);
|
78 |
|
|
} else {
|
79 |
1883
|
Luisehahne
|
msgQueue :: add($mLang->MESSAGE_RECORD_MODIFIED_FAILED );
|
80 |
1710
|
Luisehahne
|
}
|
81 |
|
|
}
|
82 |
|
|
} else {
|
83 |
1883
|
Luisehahne
|
msgQueue :: add($mLang->MESSAGE_GENERIC_SECURITY_OFFENSE );
|
84 |
1710
|
Luisehahne
|
}
|
85 |
1784
|
Luisehahne
|
$admin->print_header();
|
86 |
|
|
return ;
|
87 |
|
|
}
|