Code Duplication    Length = 17-21 lines in 2 locations

main/inc/lib/AnnouncementManager.php 1 location

@@ 453-473 (lines=21) @@
450
     *
451
     * @return int
452
     */
453
    public static function get_last_announcement_order($courseInfo)
454
    {
455
        if (empty($courseInfo)) {
456
            return 0;
457
        }
458
        $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
459
460
        $course_id = $courseInfo['real_id'];
461
        $sql = "SELECT MAX(display_order)
462
                FROM $tbl_announcement
463
                WHERE c_id = $course_id ";
464
        $res_max = Database::query($sql);
465
466
        $order = 0;
467
        if (Database::num_rows($res_max)) {
468
            $row_max = Database::fetch_array($res_max);
469
            $order = intval($row_max[0]) + 1;
470
        }
471
472
        return $order;
473
    }
474
475
    /**
476
     * Store an announcement in the database (including its attached file if any)

main/work/work.lib.php 1 location

@@ 4187-4203 (lines=17) @@
4184
 * @param array $courseInfo
4185
 * @return int
4186
 */
4187
function agendaExistsForWork($workId, $courseInfo)
4188
{
4189
    $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
4190
    $courseId = $courseInfo['real_id'];
4191
    $workId = intval($workId);
4192
4193
    $sql = "SELECT add_to_calendar FROM $workTable
4194
            WHERE c_id = $courseId AND publication_id = ".$workId;
4195
    $res = Database::query($sql);
4196
    if (Database::num_rows($res)) {
4197
        $row = Database::fetch_array($res, 'ASSOC');
4198
        if (!empty($row['add_to_calendar'])) {
4199
            return $row['add_to_calendar'];
4200
        }
4201
    }
4202
    return 0;
4203
}
4204
4205
/**
4206
 * Update work description, qualification, weight, allow_text_assignment