Code Duplication    Length = 8-17 lines in 10 locations

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

@@ 275-286 (lines=12) @@
272
 * @return array    An array with the current isocodes
273
 *
274
 * */
275
function api_get_platform_isocodes()
276
{
277
    $iso_code = array();
278
    $sql = "SELECT isocode 
279
            FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." 
280
            ORDER BY isocode ";
281
    $sql_result = Database::query($sql);
282
    if (Database::num_rows($sql_result)) {
283
        while ($row = Database::fetch_array($sql_result)) {
284
            $iso_code[] = trim($row['isocode']);
285
        }
286
    }
287
    return $iso_code;
288
}
289

main/inc/lib/urlmanager.lib.php 4 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
@@ 831-840 (lines=10) @@
828
     *
829
     * @return boolean true if success
830
     * */
831
    public static function delete_url_rel_usergroup($userGroupId, $urlId)
832
    {
833
        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
834
        $sql= "DELETE FROM $table
835
               WHERE usergroup_id = '".intval($userGroupId)."' AND
836
                     access_url_id = ".intval($urlId);
837
        $result = Database::query($sql);
838
839
        return $result;
840
    }
841
842
    /**
843
     * Deletes an url and $userGroup relationship

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/lp/learnpathItem.class.php 1 location

@@ 1872-1883 (lines=12) @@
1869
     * Get the extra terms (tags) that identify this item
1870
     * @return mixed
1871
     */
1872
    public function get_terms()
1873
    {
1874
        $lp_item = Database::get_course_table(TABLE_LP_ITEM);
1875
        $course_id = api_get_course_int_id();
1876
        $sql = "SELECT * FROM $lp_item
1877
                WHERE
1878
                    c_id = $course_id AND
1879
                    id='" . intval($this->db_id) . "'";
1880
        $res = Database::query($sql);
1881
        $row = Database::fetch_array($res);
1882
        return $row['terms'];
1883
    }
1884
1885
    /**
1886
     * Returns the item's title

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

@@ 2116-2124 (lines=9) @@
2113
     * Get the document id of the directory certificate
2114
     * @return int The document id of the directory certificate
2115
     */
2116
    public static function get_document_id_of_directory_certificate()
2117
    {
2118
        $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
2119
        $course_id = api_get_course_int_id();
2120
        $sql = "SELECT id FROM $tbl_document 
2121
                WHERE c_id = $course_id AND path='/certificates' ";
2122
        $rs = Database::query($sql);
2123
        $row = Database::fetch_array($rs);
2124
        return $row['id'];
2125
    }
2126
2127
    /**

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

@@ 469-485 (lines=17) @@
466
    * @param int announcement id
467
    * @return array array of group id
468
    **/
469
    public static function get_announcement_groups($announcement_id)
470
    {
471
        $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
472
        $tbl_group = Database :: get_main_table(TABLE_USERGROUP);
473
        //first delete all group associations for this announcement
474
475
        $sql = "SELECT
476
                    g.id as group_id,
477
                    g.name as group_name
478
                FROM $tbl_group g , $tbl_announcement_group ag
479
                WHERE
480
                    announcement_id =".intval($announcement_id)." AND
481
                    ag.group_id = g.id";
482
        $res = Database::query($sql);
483
        $groups = Database::fetch_array($res);
484
485
        return $groups;
486
    }
487
488
	/**

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

@@ 5959-5966 (lines=8) @@
5956
 * @param int The tool id
5957
 * @return array
5958
 */
5959
function api_get_tool_information_by_name($name) {
5960
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
5961
    $course_id = api_get_course_int_id();
5962
    $sql = "SELECT * FROM $t_tool
5963
            WHERE c_id = $course_id  AND name = '".Database::escape_string($name)."' ";
5964
    $rs  = Database::query($sql);
5965
    return Database::fetch_array($rs, 'ASSOC');
5966
}
5967
5968
/**
5969
 * Function used to protect a "global" admin script.