Code Duplication    Length = 8-9 lines in 5 locations

main/inc/lib/course.lib.php 1 location

@@ 2723-2730 (lines=8) @@
2720
     * @return bool True if attribute was successfully updated,
2721
     * false if course was not found or attribute name is invalid
2722
     */
2723
    public static function update_attribute($id, $name, $value)
2724
    {
2725
        $id = (int)$id;
2726
        $table = Database::get_main_table(TABLE_MAIN_COURSE);
2727
        $sql = "UPDATE $table SET $name = '" . Database::escape_string($value) . "'
2728
                WHERE id = '$id';";
2729
        return Database::query($sql);
2730
    }
2731
2732
    /**
2733
     * Update course attributes. Will only update attributes with a non-empty value.

main/inc/lib/course_request.lib.php 2 locations

@@ 361-368 (lines=8) @@
358
     * @param int/string $id            The id (an integer number) of the corresponding database record.
359
     * @return bool                     Returns TRUE on success or FALSE on failure.
360
     */
361
    public static function delete_course_request($id)
362
    {
363
        $id = (int)$id;
364
        $sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
365
                WHERE id = ".$id;
366
        $result = Database::query($sql);
367
        return $result !== false;
368
    }
369
370
    /**
371
     * @param null $status
@@ 701-708 (lines=8) @@
698
     * @param int/string $id            The database primary id of the given request.
699
     * @return bool                     Returns TRUE if additional information has been asked or FALSE otherwise.
700
     */
701
    public static function additional_info_asked($id)
702
    {
703
        $id = (int)$id;
704
        $sql = "SELECT id FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
705
                WHERE (id = ".$id." AND info > 0)";
706
        $result = Database::num_rows(Database::query($sql));
707
        return !empty($result);
708
    }
709
}
710

main/inc/lib/sub_language.class.php 2 locations

@@ 357-365 (lines=9) @@
354
     * @param Integer The language id
355
     * @return void()
356
     */
357
    public static function make_unavailable_language($language_id)
358
    {
359
        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
360
        $sql = "UPDATE $tbl_admin_languages SET available='0'
361
                WHERE id = " . intval($language_id) . "";
362
        $result = Database::query($sql);
363
364
        return $result !== false; //only return false on sql error
365
    }
366
367
    /**
368
     * Make available the language
@@ 372-380 (lines=9) @@
369
     * @param Integer The language id
370
     * @return void
371
     */
372
    public static function make_available_language($language_id)
373
    {
374
        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
375
        $sql = "UPDATE $tbl_admin_languages SET available='1'
376
                WHERE id = " . intval($language_id) . "";
377
        $result = Database::query($sql);
378
379
        return $result !== false; //only return false on sql error
380
    }
381
382
    /**
383
     * Set platform language