Code Duplication    Length = 11-14 lines in 2 locations

main/inc/lib/AnnouncementManager.php 1 location

@@ 1290-1303 (lines=14) @@
1287
     * @param integer $id attachment file Id
1288
     * @return bool
1289
     */
1290
    public static function delete_announcement_attachment_file($id)
1291
    {
1292
        $table = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1293
        $id = intval($id);
1294
        $course_id = api_get_course_int_id();
1295
        if (empty($course_id) || empty($id)) {
1296
            return false;
1297
        }
1298
        $sql = "DELETE FROM $table
1299
                WHERE c_id = $course_id AND id = $id";
1300
        Database::query($sql);
1301
1302
        return true;
1303
    }
1304
1305
    /**
1306
     * @param array $courseInfo

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

@@ 3409-3419 (lines=11) @@
3406
     * @return  boolean True if is admin, false otherwise
3407
     * @see main_api.lib.php::api_is_platform_admin() for a context-based check
3408
     */
3409
    public static function is_admin($user_id)
3410
    {
3411
        if (empty($user_id) || $user_id != strval(intval($user_id))) {
3412
            return false;
3413
        }
3414
        $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
3415
        $sql = "SELECT * FROM $admin_table WHERE user_id = $user_id";
3416
        $res = Database::query($sql);
3417
3418
        return Database::num_rows($res) === 1;
3419
    }
3420
3421
    /**
3422
     * Get the total count of users