Code Duplication    Length = 15-16 lines in 3 locations

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

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

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

@@ 797-811 (lines=15) @@
794
    /**
795
     * Shows all information of an category
796
     */
797
    public function shows_all_information_an_category($selectcat = '')
798
    {
799
        if ($selectcat == '') {
800
            return null;
801
        } else {
802
            $tbl_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
803
            $sql = 'SELECT 
804
                        name,
805
                        description,
806
                        user_id,
807
                        c_id,
808
                        parent_id,
809
                        weight,
810
                        visible,
811
                        certif_min_score,
812
                        session_id, 
813
                        generate_certificates, 
814
                        is_requirement

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

@@ 5681-5695 (lines=15) @@
5678
 * @author Julio Montoya <[email protected]>
5679
 * @return int access_url_id of the current Chamilo Installation
5680
 */
5681
function api_get_current_access_url_id() {
5682
    $access_url_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
5683
    $path = Database::escape_string(api_get_path(WEB_PATH));
5684
    $sql = "SELECT id FROM $access_url_table WHERE url = '".$path."'";
5685
    $result = Database::query($sql);
5686
    if (Database::num_rows($result) > 0) {
5687
        $access_url_id = Database::result($result, 0, 0);
5688
        return $access_url_id;
5689
    }
5690
    //if the url in WEB_PATH was not found, it can only mean that there is
5691
    // either a configuration problem or the first URL has not been defined yet
5692
    // (by default it is http://localhost/). Thus the more sensible thing we can
5693
    // do is return 1 (the main URL) as the user cannot hack this value anyway
5694
    return 1;
5695
}
5696
5697
/**
5698
 * Gets the registered urls from a given user id