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

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

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

@@ 5902-5909 (lines=8) @@
5899
 * @param int The tool id
5900
 * @return array
5901
 */
5902
function api_get_tool_information_by_name($name) {
5903
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
5904
    $course_id = api_get_course_int_id();
5905
    $sql = "SELECT * FROM $t_tool
5906
            WHERE c_id = $course_id  AND name = '".Database::escape_string($name)."' ";
5907
    $rs  = Database::query($sql);
5908
    return Database::fetch_array($rs, 'ASSOC');
5909
}
5910
5911
/**
5912
 * Function used to protect a "global" admin script.

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