Code Duplication    Length = 41-41 lines in 3 locations

src/groups/modify.php 1 location

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

src/projects/gmodify.php 1 location

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

src/projects/modify.php 1 location

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