Code Duplication    Length = 17-21 lines in 2 locations

main/inc/lib/AnnouncementManager.php 1 location

@@ 429-449 (lines=21) @@
426
     *
427
     * @return int
428
     */
429
    public static function get_last_announcement_order($courseInfo)
430
    {
431
        if (empty($courseInfo)) {
432
            return 0;
433
        }
434
        $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
435
436
        $course_id = $courseInfo['real_id'];
437
        $sql = "SELECT MAX(display_order)
438
                FROM $tbl_announcement
439
                WHERE c_id = $course_id ";
440
        $res_max = Database::query($sql);
441
442
        $order = 0;
443
        if (Database::num_rows($res_max)) {
444
            $row_max = Database::fetch_array($res_max);
445
            $order = intval($row_max[0]) + 1;
446
        }
447
448
        return $order;
449
    }
450
451
    /**
452
     * Store an announcement in the database (including its attached file if any)

main/work/work.lib.php 1 location

@@ 4128-4144 (lines=17) @@
4125
 * @param array $courseInfo
4126
 * @return int
4127
 */
4128
function agendaExistsForWork($workId, $courseInfo)
4129
{
4130
    $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
4131
    $courseId = $courseInfo['real_id'];
4132
    $workId = intval($workId);
4133
4134
    $sql = "SELECT add_to_calendar FROM $workTable
4135
            WHERE c_id = $courseId AND publication_id = ".$workId;
4136
    $res = Database::query($sql);
4137
    if (Database::num_rows($res)) {
4138
        $row = Database::fetch_array($res, 'ASSOC');
4139
        if (!empty($row['add_to_calendar'])) {
4140
            return $row['add_to_calendar'];
4141
        }
4142
    }
4143
    return 0;
4144
}
4145
4146
/**
4147
 * Update work description, qualification, weight, allow_text_assignment