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

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

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

@@ 217-230 (lines=14) @@
214
 * @return array    An array with the current isocodes
215
 *
216
 * */
217
function api_get_platform_isocodes()
218
{
219
    $iso_code = array();
220
    $sql = "SELECT isocode 
221
            FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." 
222
            ORDER BY isocode ";
223
    $sql_result = Database::query($sql);
224
    if (Database::num_rows($sql_result)) {
225
        while ($row = Database::fetch_array($sql_result)) {
226
            $iso_code[] = trim($row['isocode']);
227
        }
228
    }
229
    return $iso_code;
230
}
231
232
/**
233
 * Gets text direction according to the given language.

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

@@ 5916-5923 (lines=8) @@
5913
 * @param int The tool id
5914
 * @return array
5915
 */
5916
function api_get_tool_information_by_name($name) {
5917
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
5918
    $course_id = api_get_course_int_id();
5919
    $sql = "SELECT * FROM $t_tool
5920
            WHERE c_id = $course_id  AND name = '".Database::escape_string($name)."' ";
5921
    $rs  = Database::query($sql);
5922
    return Database::fetch_array($rs, 'ASSOC');
5923
}
5924
5925
/**
5926
 * Function used to protect a "global" admin script.