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

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

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

@@ 5708-5722 (lines=15) @@
5705
 * @author Julio Montoya <[email protected]>
5706
 * @return int access_url_id of the current Chamilo Installation
5707
 */
5708
function api_get_current_access_url_id() {
5709
    $access_url_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
5710
    $path = Database::escape_string(api_get_path(WEB_PATH));
5711
    $sql = "SELECT id FROM $access_url_table WHERE url = '".$path."'";
5712
    $result = Database::query($sql);
5713
    if (Database::num_rows($result) > 0) {
5714
        $access_url_id = Database::result($result, 0, 0);
5715
        return $access_url_id;
5716
    }
5717
    //if the url in WEB_PATH was not found, it can only mean that there is
5718
    // either a configuration problem or the first URL has not been defined yet
5719
    // (by default it is http://localhost/). Thus the more sensible thing we can
5720
    // do is return 1 (the main URL) as the user cannot hack this value anyway
5721
    return 1;
5722
}
5723
5724
/**
5725
 * Gets the registered urls from a given user id