Code Duplication    Length = 8-14 lines in 7 locations

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

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

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/gradebook/lib/be/category.class.php 1 location

@@ 1838-1848 (lines=11) @@
1835
     * @param int $catId Category parent ID
1836
     * @return array Array of Category objects
1837
     */
1838
    public function getCategories($catId)
1839
    {
1840
        $tblGradeCategories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
1841
        $sql = 'SELECT * FROM '.$tblGradeCategories.'
1842
                WHERE parent_id = '.intval($catId);
1843
1844
        $result = Database::query($sql);
1845
        $allcats = Category::create_category_objects_from_sql_result($result);
1846
1847
        return $allcats;
1848
    }
1849
1850
    /**
1851
     * Gets the type for the current object

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/inc/lib/api.lib.php 1 location

@@ 5937-5944 (lines=8) @@
5934
 * @param int The tool id
5935
 * @return array
5936
 */
5937
function api_get_tool_information_by_name($name) {
5938
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
5939
    $course_id = api_get_course_int_id();
5940
    $sql = "SELECT * FROM $t_tool
5941
            WHERE c_id = $course_id  AND name = '".Database::escape_string($name)."' ";
5942
    $rs  = Database::query($sql);
5943
    return Database::fetch_array($rs, 'ASSOC');
5944
}
5945
5946
/**
5947
 * Function used to protect a "global" admin script.