Code Duplication    Length = 13-16 lines in 4 locations

main/inc/lib/sub_language.class.php 1 location

@@ 416-428 (lines=13) @@
413
     * Get platform language ID
414
     * @return     int     The platform language ID
415
     */
416
    public static function get_platform_language_id()
417
    {
418
        $name = api_get_setting('platformLanguage');
419
        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
420
        $sql = "SELECT id FROM " . $tbl_admin_languages . " WHERE english_name ='$name'";
421
        $res = Database::query($sql);
422
        if (Database::num_rows($res) < 1) {
423
            return false;
424
        }
425
        $row = Database::fetch_array($res);
426
427
        return $row['id'];
428
    }
429
430
    /**
431
     * Get parent language path (or null if no parent)

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

@@ 5585-5599 (lines=15) @@
5582
 * @author Julio Montoya <[email protected]>
5583
 * @return int access_url_id of the current Chamilo Installation
5584
 */
5585
function api_get_current_access_url_id() {
5586
    $access_url_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
5587
    $path = Database::escape_string(api_get_path(WEB_PATH));
5588
    $sql = "SELECT id FROM $access_url_table WHERE url = '".$path."'";
5589
    $result = Database::query($sql);
5590
    if (Database::num_rows($result) > 0) {
5591
        $access_url_id = Database::result($result, 0, 0);
5592
        return $access_url_id;
5593
    }
5594
    //if the url in WEB_PATH was not found, it can only mean that there is
5595
    // either a configuration problem or the first URL has not been defined yet
5596
    // (by default it is http://localhost/). Thus the more sensible thing we can
5597
    // do is return 1 (the main URL) as the user cannot hack this value anyway
5598
    return 1;
5599
}
5600
5601
/**
5602
 * Gets the registered urls from a given user id

main/gradebook/lib/be/category.class.php 1 location

@@ 763-777 (lines=15) @@
760
    /**
761
     * Shows all information of an category
762
     */
763
    public function shows_all_information_an_category($selectcat = '')
764
    {
765
        if ($selectcat == '') {
766
            return null;
767
        } else {
768
            $tbl_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
769
            $sql = 'SELECT name,description,user_id,course_code,parent_id,weight,visible,certif_min_score,session_id, generate_certificates, is_requirement
770
                    FROM '.$tbl_category.' c
771
                    WHERE c.id='.intval($selectcat);
772
            $result = Database::query($sql);
773
            $row = Database::fetch_array($result, 'ASSOC');
774
775
            return $row;
776
        }
777
    }
778
779
    /**
780
     * Check if a category name (with the same parent category) already exists

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

@@ 49-64 (lines=16) @@
46
     * @param   int $userId The user for which we need the unread messages count
47
     * @return  int The number of unread messages in the database for the given user
48
     */
49
    private static function getCountNewMessagesFromDB($userId)
50
    {
51
        if (empty($userId)) {
52
            return 0;
53
        }
54
        $table = Database::get_main_table(TABLE_MESSAGE);
55
        $sql = "SELECT COUNT(id) as count 
56
                        FROM $table
57
                        WHERE
58
                            user_receiver_id=" . api_get_user_id() . " AND
59
                            msg_status = " . MESSAGE_STATUS_UNREAD;
60
        $result = Database::query($sql);
61
        $row = Database::fetch_assoc($result);
62
63
        return $row['count'];
64
    }
65
66
    /**
67
     * Get the list of user_ids of users who are online.