Code Duplication    Length = 21-22 lines in 2 locations

main/gradebook/lib/be/category.class.php 2 locations

@@ 1226-1246 (lines=21) @@
1223
        if (!api_is_allowed_to_edit()) {
1224
            $sql .= ' AND visible = 1';
1225
            //proceed with checks on optional parameters course & session
1226
            if (!empty($course_code)) {
1227
                // TODO: considering it highly improbable that a user would get here
1228
                // if he doesn't have the rights to view this course and this
1229
                // session, we don't check his registration to these, but this
1230
                // could be an improvement
1231
                if (!empty($session_id)) {
1232
                    $sql .= " AND course_code = '".$course_code."' AND session_id = ".$session_id;
1233
                } else {
1234
                    $sql .= " AND course_code = '".$course_code."' AND session_id is null OR session_id=0";
1235
                }
1236
            } else {
1237
                //no optional parameter, proceed as usual
1238
                $sql .= ' AND course_code in
1239
                     (
1240
                        SELECT c.code
1241
                        FROM '.$main_course_user_table.' cu INNER JOIN '.$courseTable.' c
1242
                        ON (cu.c_id = c.id)
1243
                        WHERE cu.user_id = '.intval($stud_id).'
1244
                        AND cu.status = '.STUDENT.'
1245
                    )';
1246
            }
1247
        } elseif (api_is_allowed_to_edit() && !api_is_platform_admin()) {
1248
            //proceed with checks on optional parameters course & session
1249
            if (!empty($course_code)) {
@@ 1249-1270 (lines=22) @@
1246
            }
1247
        } elseif (api_is_allowed_to_edit() && !api_is_platform_admin()) {
1248
            //proceed with checks on optional parameters course & session
1249
            if (!empty($course_code)) {
1250
                // TODO: considering it highly improbable that a user would get here
1251
                // if he doesn't have the rights to view this course and this
1252
                // session, we don't check his registration to these, but this
1253
                // could be an improvement
1254
                $sql .= " AND course_code  = '".$course_code."'";
1255
                if (!empty($session_id)) {
1256
                    $sql .= " AND session_id = ".$session_id;
1257
                } else {
1258
                    $sql .= "AND session_id IS NULL OR session_id=0";
1259
                }
1260
            } else {
1261
                $sql .= ' AND course_code IN
1262
                     (
1263
                        SELECT c.code
1264
                        FROM '.$main_course_user_table.' cu INNER JOIN '.$courseTable.' c
1265
                        ON (cu.c_id = c.id)
1266
                        WHERE
1267
                            cu.user_id = '.api_get_user_id().' AND
1268
                            cu.status = '.COURSEMANAGER.'
1269
                    )';
1270
            }
1271
        } elseif (api_is_platform_admin()) {
1272
            if (isset($session_id) && $session_id != 0) {
1273
                $sql .= ' AND session_id='.$session_id;