Code Duplication    Length = 29-29 lines in 3 locations

src/projects/fdelete.php 1 location

@@ 37-65 (lines=29) @@
34
35
init_page();
36
37
if (get_user_level() == USER_LEVEL_ADMIN)
38
{
39
    $id    = ustr2int(try_request('id'));
40
    $field = field_find($id);
41
42
    if ($field)
43
    {
44
        if ($field['is_locked'])
45
        {
46
            field_delete($id);
47
            header('Location: sview.php?tab=2&id=' . $field['state_id']);
48
        }
49
        else
50
        {
51
            debug_write_log(DEBUG_NOTICE, 'Field is not removable.');
52
            header('Location: fview.php?id=' . $id);
53
        }
54
    }
55
    else
56
    {
57
        debug_write_log(DEBUG_NOTICE, 'Field cannot be found.');
58
        header('Location: index.php');
59
    }
60
}
61
else
62
{
63
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
64
    header('Location: index.php');
65
}
66
67
?>
68

src/projects/sdelete.php 1 location

@@ 37-65 (lines=29) @@
34
35
init_page();
36
37
if (get_user_level() == USER_LEVEL_ADMIN)
38
{
39
    $id    = ustr2int(try_request('id'));
40
    $state = state_find($id);
41
42
    if ($state)
43
    {
44
        if (is_state_removable($id) && $state['is_locked'])
45
        {
46
            state_delete($id);
47
            header('Location: tview.php?tab=2&id=' . $state['template_id']);
48
        }
49
        else
50
        {
51
            debug_write_log(DEBUG_NOTICE, 'State is not removable.');
52
            header('Location: sview.php?id=' . $id);
53
        }
54
    }
55
    else
56
    {
57
        debug_write_log(DEBUG_NOTICE, 'State cannot be found.');
58
        header('Location: index.php');
59
    }
60
}
61
else
62
{
63
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
64
    header('Location: index.php');
65
}
66
67
?>
68

src/projects/tdelete.php 1 location

@@ 37-65 (lines=29) @@
34
35
init_page();
36
37
if (get_user_level() == USER_LEVEL_ADMIN)
38
{
39
    $id       = ustr2int(try_request('id'));
40
    $template = template_find($id);
41
42
    if ($template)
43
    {
44
        if (is_template_removable($id) && $template['is_locked'])
45
        {
46
            template_delete($id);
47
            header('Location: view.php?tab=3&id=' . $template['project_id']);
48
        }
49
        else
50
        {
51
            debug_write_log(DEBUG_NOTICE, 'Template is not removable.');
52
            header('Location: tview.php?id=' . $id);
53
        }
54
    }
55
    else
56
    {
57
        debug_write_log(DEBUG_NOTICE, 'Template cannot be found.');
58
        header('Location: index.php');
59
    }
60
}
61
else
62
{
63
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
64
    header('Location: index.php');
65
}
66
67
?>
68