Code Duplication    Length = 26-27 lines in 3 locations

src/accounts/delete.php 1 location

@@ 37-62 (lines=26) @@
34
35
init_page();
36
37
if (get_user_level() == USER_LEVEL_ADMIN)
38
{
39
    $id = ustr2int(try_request('id'));
40
    $account = account_find($id);
41
42
    if (!$account)
43
    {
44
        debug_write_log(DEBUG_NOTICE, 'Account cannot be found.');
45
    }
46
    elseif ($account['is_ldapuser'])
47
    {
48
        debug_write_log(DEBUG_NOTICE, 'Active Directory account cannot be viewed.');
49
    }
50
    elseif (is_account_removable($id))
51
    {
52
        account_delete($id);
53
    }
54
    else
55
    {
56
        debug_write_log(DEBUG_NOTICE, 'Account is not removable.');
57
    }
58
}
59
else
60
{
61
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
62
}
63
64
header('Location: index.php');
65

src/groups/delete.php 1 location

@@ 37-62 (lines=26) @@
34
35
init_page();
36
37
if (get_user_level() == USER_LEVEL_ADMIN)
38
{
39
    $id = ustr2int(try_request('id'));
40
    $group = group_find($id);
41
42
    if (!$group)
43
    {
44
        debug_write_log(DEBUG_NOTICE, 'Group cannot be found.');
45
    }
46
    elseif (!$group['is_global'])
47
    {
48
        debug_write_log(DEBUG_NOTICE, 'Group must be global.');
49
    }
50
    elseif (is_group_removable($id))
51
    {
52
        group_delete($id);
53
    }
54
    else
55
    {
56
        debug_write_log(DEBUG_NOTICE, 'Group is not removable.');
57
    }
58
}
59
else
60
{
61
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
62
}
63
64
header('Location: index.php');
65

src/projects/gdelete.php 1 location

@@ 39-65 (lines=27) @@
36
37
$project_id = 0;
38
39
if (get_user_level() == USER_LEVEL_ADMIN)
40
{
41
    $id = ustr2int(try_request('id'));
42
    $group = group_find($id);
43
44
    if (!$group)
45
    {
46
        debug_write_log(DEBUG_NOTICE, 'Group cannot be found.');
47
    }
48
    elseif ($group['is_global'])
49
    {
50
        debug_write_log(DEBUG_NOTICE, 'Group must be local.');
51
    }
52
    elseif (is_group_removable($id))
53
    {
54
        $project_id = $group['project_id'];
55
        group_delete($id);
56
    }
57
    else
58
    {
59
        debug_write_log(DEBUG_NOTICE, 'Group is not removable.');
60
    }
61
}
62
else
63
{
64
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
65
}
66
67
header('Location: view.php?tab=2&id=' . $project_id);
68