Code Duplication    Length = 41-41 lines in 3 locations

src/groups/create.php 1 location

@@ 48-88 (lines=41) @@
45
46
// new group has been submitted
47
48
if (try_request('submitted') == 'createform')
49
{
50
    debug_write_log(DEBUG_NOTICE, 'Data are submitted.');
51
52
    $group_name  = ustrcut($_REQUEST['group_name'],  MAX_GROUP_NAME);
53
    $description = ustrcut($_REQUEST['description'], MAX_GROUP_DESCRIPTION);
54
55
    $error = group_validate($group_name);
56
57
    if ($error == NO_ERROR)
58
    {
59
        $error = group_create(0, $group_name, $description);
60
    }
61
62
    switch ($error)
63
    {
64
        case NO_ERROR:
65
            header('HTTP/1.0 200 OK');
66
            break;
67
68
        case ERROR_INCOMPLETE_FORM:
69
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
70
            break;
71
72
        case ERROR_ALREADY_EXISTS:
73
            send_http_error(get_html_resource(RES_ALERT_GROUP_ALREADY_EXISTS_ID));
74
            break;
75
76
        default:
77
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
78
    }
79
80
    exit;
81
}
82
else
83
{
84
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
85
86
    $group_name  = NULL;
87
    $description = NULL;
88
}
89
90
// local JS functions
91

src/projects/create.php 1 location

@@ 48-88 (lines=41) @@
45
46
// new project has been submitted
47
48
if (try_request('submitted') == 'createform')
49
{
50
    debug_write_log(DEBUG_NOTICE, 'Data are submitted.');
51
52
    $project_name = ustrcut($_REQUEST['project_name'], MAX_PROJECT_NAME);
53
    $description  = ustrcut($_REQUEST['description'],  MAX_PROJECT_DESCRIPTION);
54
55
    $error = project_validate($project_name, $description);
56
57
    if ($error == NO_ERROR)
58
    {
59
        $error = project_create($project_name, $description);
60
    }
61
62
    switch ($error)
63
    {
64
        case NO_ERROR:
65
            header('HTTP/1.0 200 OK');
66
            break;
67
68
        case ERROR_INCOMPLETE_FORM:
69
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
70
            break;
71
72
        case ERROR_ALREADY_EXISTS:
73
            send_http_error(get_html_resource(RES_ALERT_PROJECT_ALREADY_EXISTS_ID));
74
            break;
75
76
        default:
77
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
78
    }
79
80
    exit;
81
}
82
else
83
{
84
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
85
86
    $project_name = NULL;
87
    $description  = NULL;
88
}
89
90
// local JS functions
91

src/projects/gcreate.php 1 location

@@ 61-101 (lines=41) @@
58
59
// new group has been submitted
60
61
if (try_request('submitted') == 'createform')
62
{
63
    debug_write_log(DEBUG_NOTICE, 'Data are submitted.');
64
65
    $group_name  = ustrcut($_REQUEST['group_name'],  MAX_GROUP_NAME);
66
    $description = ustrcut($_REQUEST['description'], MAX_GROUP_DESCRIPTION);
67
68
    $error = group_validate($group_name);
69
70
    if ($error == NO_ERROR)
71
    {
72
        $error = group_create($id, $group_name, $description);
73
    }
74
75
    switch ($error)
76
    {
77
        case NO_ERROR:
78
            header('HTTP/1.0 200 OK');
79
            break;
80
81
        case ERROR_INCOMPLETE_FORM:
82
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
83
            break;
84
85
        case ERROR_ALREADY_EXISTS:
86
            send_http_error(get_html_resource(RES_ALERT_GROUP_ALREADY_EXISTS_ID));
87
            break;
88
89
        default:
90
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
91
    }
92
93
    exit;
94
}
95
else
96
{
97
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
98
99
    $group_name  = NULL;
100
    $description = NULL;
101
}
102
103
// local JS functions
104