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

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