Code Duplication    Length = 8-14 lines in 7 locations

main/inc/lib/urlmanager.lib.php 3 locations

@@ 429-439 (lines=11) @@
426
     * @param int $urlId
427
     * @return boolean true if success
428
     * */
429
    public static function relationUrlUsergroupExist($userGroupId, $urlId)
430
    {
431
        $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
432
        $sql = "SELECT usergroup_id FROM $table
433
               WHERE 
434
                    access_url_id = ".intval($urlId)." AND
435
                    usergroup_id = ".intval($userGroupId);
436
        $result = Database::query($sql);
437
        $num = Database::num_rows($result);
438
439
        return $num;
440
    }
441
442
    /**
@@ 121-132 (lines=12) @@
118
     *
119
     * @return int
120
     */
121
    public static function url_id_exist($url)
122
    {
123
        if (empty($url)) {
124
            return false;
125
        }
126
        $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
127
        $sql = "SELECT id FROM $table WHERE id = ".intval($url)."";
128
        $res = Database::query($sql);
129
        $num = Database::num_rows($res);
130
131
        return $num;
132
    }
133
134
    /**
135
     * This function get the quantity of URLs
@@ 602-612 (lines=11) @@
599
     * @param int $urlId
600
     * @return boolean true if success
601
     * */
602
    public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
603
    {
604
        $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
605
        $sql = "SELECT course_category_id FROM $table
606
                WHERE 
607
                    access_url_id = ".intval($urlId)." AND
608
                    course_category_id = ".intval($categoryCourseId);
609
        $result = Database::query($sql);
610
        $num = Database::num_rows($result);
611
612
        return $num;
613
    }
614
615
    /**

main/lp/storageapi.php 1 location

@@ 283-293 (lines=11) @@
280
    return json_encode($results);
281
}
282
283
function storage_get_all_users() {
284
    $sql = "select user_id, username, firstname, lastname
285
        from ".Database::get_main_table(TABLE_MAIN_USER)."
286
        order by user_id asc";
287
    $res = Database::query($sql);
288
    $results = array();
289
    while ($row = Database::fetch_assoc($res)) {
290
        $results[] = $row;
291
    }
292
    return json_encode($results);
293
}
294

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

@@ 146-159 (lines=14) @@
143
 * @return array    An array with the current isocodes
144
 *
145
 * */
146
function api_get_platform_isocodes()
147
{
148
    $iso_code = array();
149
    $sql = "SELECT isocode 
150
            FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." 
151
            ORDER BY isocode ";
152
    $sql_result = Database::query($sql);
153
    if (Database::num_rows($sql_result)) {
154
        while ($row = Database::fetch_array($sql_result)) {
155
            $iso_code[] = trim($row['isocode']);
156
        }
157
    }
158
    return $iso_code;
159
}
160
161
/**
162
 * Gets text direction according to the given language.

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

@@ 1902-1912 (lines=11) @@
1899
     * @param int $catId Category parent ID
1900
     * @return array Array of Category objects
1901
     */
1902
    public function getCategories($catId)
1903
    {
1904
        $tblGradeCategories = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
1905
        $sql = 'SELECT * FROM '.$tblGradeCategories.'
1906
                WHERE parent_id = '.intval($catId);
1907
1908
        $result = Database::query($sql);
1909
        $categories = self::create_category_objects_from_sql_result($result);
1910
1911
        return $categories;
1912
    }
1913
1914
    /**
1915
     * Gets the type for the current object

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

@@ 5985-5992 (lines=8) @@
5982
 * @param int The tool id
5983
 * @return array
5984
 */
5985
function api_get_tool_information_by_name($name)
5986
{
5987
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
5988
    $course_id = api_get_course_int_id();
5989
    $sql = "SELECT * FROM $t_tool
5990
            WHERE c_id = $course_id  AND name = '".Database::escape_string($name)."' ";
5991
    $rs  = Database::query($sql);
5992
    return Database::fetch_array($rs, 'ASSOC');
5993
}
5994
5995
/**