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

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
@@ 429-439 (lines=11) @@
426
     * @param int $urlId
427
     * @return boolean true if success
428
     * */
429
    public static function relationUrlUsergroupExist($userGroupId, $urlId)
430
    {
431
        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
432
        $sql= "SELECT usergroup_id FROM $table
433
               WHERE access_url_id = ".intval($urlId)." AND
434
                     usergroup_id = ".intval($userGroupId);
435
        $result = Database::query($sql);
436
        $num = Database::num_rows($result);
437
438
        return $num;
439
    }
440
441
    /**
442
    * Checks the relationship between an URL and a Session (return the num_rows)
@@ 599-609 (lines=11) @@
596
     * @param int $urlId
597
     * @return boolean true if success
598
     * */
599
    public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
600
    {
601
        $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
602
        $sql= "SELECT course_category_id FROM $table
603
               WHERE access_url_id = ".intval($urlId)." AND
604
                     course_category_id = ".intval($categoryCourseId);
605
        $result = Database::query($sql);
606
        $num = Database::num_rows($result);
607
608
        return $num;
609
    }
610
611
    /**
612
     * @param int $userGroupId