Code Duplication    Length = 11-12 lines in 5 locations

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

@@ 283-293 (lines=11) @@
280
 * @return array    An array with the current isocodes
281
 *
282
 * */
283
function api_get_platform_isocodes()
284
{
285
    $iso_code = array();
286
    $sql_result = Database::query("SELECT isocode FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." ORDER BY isocode ");
287
    if (Database::num_rows($sql_result)) {
288
        while ($row = Database::fetch_array($sql_result)) {;
289
            $iso_code[] = trim($row['isocode']);
290
        }
291
    }
292
    return $iso_code;
293
}
294
295
/**
296
 * Gets text direction according to the given language.

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

@@ 103-114 (lines=12) @@
100
     *
101
     * @return int
102
     */
103
    public static function url_id_exist($url)
104
    {
105
        if (empty($url)) {
106
            return false;
107
        }
108
        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
109
        $sql = "SELECT id FROM $table WHERE id = ".intval($url)."";
110
        $res = Database::query($sql);
111
        $num = Database::num_rows($res);
112
113
        return $num;
114
    }
115
116
    /**
117
     * This function get the quantity of URLs
@@ 410-420 (lines=11) @@
407
     * @param int $urlId
408
     * @return boolean true if success
409
     * */
410
    public static function relationUrlUsergroupExist($userGroupId, $urlId)
411
    {
412
        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
413
        $sql= "SELECT usergroup_id FROM $table
414
               WHERE access_url_id = ".intval($urlId)." AND
415
                     usergroup_id = ".intval($userGroupId);
416
        $result = Database::query($sql);
417
        $num = Database::num_rows($result);
418
419
        return $num;
420
    }
421
422
    /**
423
    * Checks the relationship between an URL and a Session (return the num_rows)
@@ 580-590 (lines=11) @@
577
     * @param int $urlId
578
     * @return boolean true if success
579
     * */
580
    public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581
    {
582
        $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
583
        $sql= "SELECT course_category_id FROM $table
584
               WHERE access_url_id = ".intval($urlId)." AND
585
                     course_category_id = ".intval($categoryCourseId);
586
        $result = Database::query($sql);
587
        $num = Database::num_rows($result);
588
589
        return $num;
590
    }
591
592
    /**
593
     * @param int $userGroupId

main/newscorm/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