Code Duplication    Length = 49-49 lines in 2 locations

src/records/modify.php 1 location

@@ 84-132 (lines=49) @@
81
        $error = record_modify($id, $subject, $record['creator_id'], $record['responsible_id']);
82
    }
83
84
    switch ($error)
85
    {
86
        case NO_ERROR:
87
            header('HTTP/1.0 200 OK');
88
            break;
89
90
        case ERROR_INCOMPLETE_FORM:
91
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
92
            break;
93
94
        case ERROR_INVALID_INTEGER_VALUE:
95
            send_http_error(get_html_resource(RES_ALERT_INVALID_INTEGER_VALUE_ID));
96
            break;
97
98
        case ERROR_INVALID_FLOAT_VALUE:
99
            send_http_error(get_html_resource(RES_ALERT_INVALID_DECIMAL_VALUE_ID));
100
            break;
101
102
        case ERROR_INVALID_DATE_VALUE:
103
            send_http_error(get_html_resource(RES_ALERT_INVALID_DATE_VALUE_ID));
104
            break;
105
106
        case ERROR_INVALID_TIME_VALUE:
107
            send_http_error(get_html_resource(RES_ALERT_INVALID_TIME_VALUE_ID));
108
            break;
109
110
        case ERROR_INTEGER_VALUE_OUT_OF_RANGE:
111
        case ERROR_FLOAT_VALUE_OUT_OF_RANGE:
112
        case ERROR_DATE_VALUE_OUT_OF_RANGE:
113
        case ERROR_TIME_VALUE_OUT_OF_RANGE:
114
            send_http_error(ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), $_SESSION['FIELD_NAME'], $_SESSION['MIN_FIELD_INTEGER'], $_SESSION['MAX_FIELD_INTEGER']));
115
            unset($_SESSION['FIELD_NAME']);
116
            unset($_SESSION['MIN_FIELD_INTEGER']);
117
            unset($_SESSION['MAX_FIELD_INTEGER']);
118
            break;
119
120
        case ERROR_RECORD_NOT_FOUND:
121
            send_http_error(get_html_resource(RES_ALERT_RECORD_NOT_FOUND_ID));
122
            break;
123
124
        case ERROR_VALUE_FAILS_REGEX_CHECK:
125
            send_http_error(ustrprocess(get_html_resource(RES_ALERT_VALUE_FAILS_REGEX_CHECK_ID), $_SESSION['FIELD_NAME'], $_SESSION['FIELD_VALUE']));
126
            unset($_SESSION['FIELD_NAME']);
127
            unset($_SESSION['FIELD_VALUE']);
128
            break;
129
130
        default:
131
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
132
    }
133
134
    exit;
135
}

src/records/state.php 1 location

@@ 171-219 (lines=49) @@
168
                              is_record_closed($record));
169
    }
170
171
    switch ($error)
172
    {
173
        case NO_ERROR:
174
            header('HTTP/1.0 200 OK');
175
            break;
176
177
        case ERROR_INCOMPLETE_FORM:
178
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
179
            break;
180
181
        case ERROR_INVALID_INTEGER_VALUE:
182
            send_http_error(get_html_resource(RES_ALERT_INVALID_INTEGER_VALUE_ID));
183
            break;
184
185
        case ERROR_INVALID_FLOAT_VALUE:
186
            send_http_error(get_html_resource(RES_ALERT_INVALID_DECIMAL_VALUE_ID));
187
            break;
188
189
        case ERROR_INVALID_DATE_VALUE:
190
            send_http_error(get_html_resource(RES_ALERT_INVALID_DATE_VALUE_ID));
191
            break;
192
193
        case ERROR_INVALID_TIME_VALUE:
194
            send_http_error(get_html_resource(RES_ALERT_INVALID_TIME_VALUE_ID));
195
            break;
196
197
        case ERROR_INTEGER_VALUE_OUT_OF_RANGE:
198
        case ERROR_FLOAT_VALUE_OUT_OF_RANGE:
199
        case ERROR_DATE_VALUE_OUT_OF_RANGE:
200
        case ERROR_TIME_VALUE_OUT_OF_RANGE:
201
            send_http_error(ustrprocess(get_js_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), $_SESSION['FIELD_NAME'], $_SESSION['MIN_FIELD_INTEGER'], $_SESSION['MAX_FIELD_INTEGER']));
202
            unset($_SESSION['FIELD_NAME']);
203
            unset($_SESSION['MIN_FIELD_INTEGER']);
204
            unset($_SESSION['MAX_FIELD_INTEGER']);
205
            break;
206
207
        case ERROR_RECORD_NOT_FOUND:
208
            send_http_error(get_html_resource(RES_ALERT_RECORD_NOT_FOUND_ID));
209
            break;
210
211
        case ERROR_VALUE_FAILS_REGEX_CHECK:
212
            send_http_error(ustrprocess(get_js_resource(RES_ALERT_VALUE_FAILS_REGEX_CHECK_ID), $_SESSION['FIELD_NAME'], $_SESSION['FIELD_VALUE']));
213
            unset($_SESSION['FIELD_NAME']);
214
            unset($_SESSION['FIELD_VALUE']);
215
            break;
216
217
        default:
218
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
219
    }
220
221
    exit;
222
}