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 |
|
|
/* *****************************************************************************
|
19 |
|
|
* Delete an existing group and remove existing group in user
|
20 |
|
|
* @access public
|
21 |
|
|
* @param object $admin: admin-object
|
22 |
|
|
* @param int $group_id: ID from group to delete
|
23 |
|
|
* @return bool: true or false
|
24 |
|
|
*/
|
25 |
2013
|
darkviper
|
function delete_group($admin, $iGroupId = 0)
|
26 |
1710
|
Luisehahne
|
{
|
27 |
2013
|
darkviper
|
$oDb = WbDatabase::getInstance();
|
28 |
|
|
$oLang = Translate::getInstance();
|
29 |
1710
|
Luisehahne
|
// first check form-tan
|
30 |
2013
|
darkviper
|
if (!$admin->checkFTAN() || $iGroupId <= 1) {
|
31 |
|
|
msgQueue::add($oLang->MESSAGE_GENERIC_SECURITY_OFFENSE );
|
32 |
|
|
} else {
|
33 |
|
|
// if FTAN is successful checked and not Administrator group is seleced
|
34 |
|
|
$sql = 'SELECT GROUP_CONCAT(`username` ORDER BY `username` SEPARATOR \', \') '
|
35 |
|
|
. 'FROM `'.$oDb->TablePrefix.'users` '
|
36 |
|
|
. 'WHERE `groups_id`=\''.(string)$iGroupId.'\'';
|
37 |
|
|
if (($sUsers = $oDb->getOne($sql))) {
|
38 |
|
|
// sorry, this group has users which having this group as the only one group
|
39 |
|
|
msgQueue::add($oLang->MESSAGE_UNABLE_DELETE_GROUP . '<br />' . $sUsers);
|
40 |
|
|
} else {
|
41 |
|
|
$sql = 'UPDATE `'.$oDb->TablePrefix.'users` '
|
42 |
|
|
. 'SET `groups_id`=TRIM(BOTH \',\' FROM REPLACE(CONCAT(\',\',`groups_id`,\',\'),\','.$iGroupId.',\',\',\')) '
|
43 |
|
|
. 'WHERE FIND_IN_SET('.$iGroupId.', `groups_id`) AND `user_id`!=1';
|
44 |
|
|
// remove Group from Users
|
45 |
|
|
$oDb->doQuery($sql);
|
46 |
|
|
$sql = 'SELECT COUNT(*) '
|
47 |
|
|
. 'FROM `'.$oDb->TablePrefix.'users` '
|
48 |
|
|
. 'WHERE FIND_IN_SET('.$iGroupId.', `groups_id`) AND `user_id`!=1';
|
49 |
|
|
if ($oDb->getOne($sql)) {
|
50 |
|
|
// the group already has assigned users.
|
51 |
|
|
msgQueue::add($oLang->MESSAGE_RECORD_MODIFIED_FAILED );
|
52 |
1710
|
Luisehahne
|
} else {
|
53 |
2013
|
darkviper
|
$sql = 'DELETE FROM `'.$oDb->TablePrefix.'groups` '
|
54 |
|
|
. 'WHERE `group_id`='.$iGroupId;
|
55 |
|
|
// delete the group itself
|
56 |
|
|
$oDb->doQuery($sql);
|
57 |
|
|
msgQueue::add($oLang->MESSAGE_GROUPS_DELETED,true);
|
58 |
1710
|
Luisehahne
|
}
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
1784
|
Luisehahne
|
$admin->print_header();
|
62 |
|
|
return ;
|
63 |
|
|
}
|