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

@@ 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

@@ 1883-1893 (lines=11) @@
1880
     * @param int $catId Category parent ID
1881
     * @return array Array of Category objects
1882
     */
1883
    public function getCategories($catId)
1884
    {
1885
        $tblGradeCategories = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
1886
        $sql = 'SELECT * FROM '.$tblGradeCategories.'
1887
                WHERE parent_id = '.intval($catId);
1888
1889
        $result = Database::query($sql);
1890
        $categories = self::create_category_objects_from_sql_result($result);
1891
1892
        return $categories;
1893
    }
1894
1895
    /**
1896
     * Gets the type for the current object

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

@@ 6026-6033 (lines=8) @@
6023
 * @param int The tool id
6024
 * @return array
6025
 */
6026
function api_get_tool_information_by_name($name)
6027
{
6028
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
6029
    $course_id = api_get_course_int_id();
6030
    $sql = "SELECT * FROM $t_tool
6031
            WHERE c_id = $course_id  AND name = '".Database::escape_string($name)."' ";
6032
    $rs  = Database::query($sql);
6033
    return Database::fetch_array($rs, 'ASSOC');
6034
}
6035
6036
/**