Code Duplication    Length = 20-28 lines in 3 locations

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

@@ 809-836 (lines=28) @@
806
     * @param integer $thematic_advance_id
807
     * @return	int		Affected rows
808
     */
809
    public function thematic_advance_destroy($thematic_advance_id)
810
    {
811
        $_course = api_get_course_info();
812
        $course_id = api_get_course_int_id();
813
814
        // definition database table
815
        $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
816
817
        // protect data
818
        $thematic_advance_id = intval($thematic_advance_id);
819
        $user_id = api_get_user_id();
820
821
        $sql = "DELETE FROM $tbl_thematic_advance
822
                WHERE c_id = $course_id AND id = $thematic_advance_id ";
823
        $result = Database::query($sql);
824
        $affected_rows = Database::affected_rows($result);
825
        if ($affected_rows) {
826
            api_item_property_update(
827
                $_course,
828
                'thematic_advance',
829
                $thematic_advance_id,
830
                'ThematicAdvanceDeleted',
831
                $user_id
832
            );
833
        }
834
835
        return $affected_rows;
836
    }
837
838
    /**
839
     * get thematic plan data

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

@@ 1337-1356 (lines=20) @@
1334
     * @param integer $item_id
1335
     * @return array
1336
     */
1337
    public static function displayRating($type, $blog_id, $item_id)
1338
    {
1339
        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1340
        $course_id = api_get_course_int_id();
1341
        $blog_id = intval($blog_id);
1342
        $item_id = intval($item_id);
1343
        $type = Database::escape_string($type);
1344
1345
        // Calculate rating
1346
        $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1347
                WHERE
1348
                    c_id = $course_id AND
1349
                    blog_id = $blog_id AND
1350
                    item_id = $item_id AND
1351
                    rating_type = '$type'";
1352
        $result = Database::query($sql);
1353
        $result = Database::fetch_array($result);
1354
1355
        return round($result['rating'], 2);
1356
    }
1357
1358
    /**
1359
     * Displays the form to create a new post

main/forum/forumfunction.inc.php 1 location

@@ 3276-3297 (lines=22) @@
3273
 * @author Isaac Flores <[email protected]>, U.N.A.S University
3274
 * @version December 2008, dokeos  1.8.6
3275
 */
3276
function current_qualify_of_thread($threadId, $sessionId, $userId)
3277
{
3278
    $table_threads_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
3279
3280
    $course_id = api_get_course_int_id();
3281
    $currentUserId = api_get_user_id();
3282
    $sessionId = intval($sessionId);
3283
    $threadId = intval($threadId);
3284
3285
    $sql = "SELECT qualify FROM $table_threads_qualify
3286
            WHERE
3287
                c_id = $course_id AND
3288
                thread_id = $threadId AND
3289
                session_id = $sessionId AND
3290
                qualify_user_id = $currentUserId AND
3291
                user_id = $userId
3292
            ";
3293
    $res = Database::query($sql);
3294
    $row = Database::fetch_array($res, 'ASSOC');
3295
3296
    return $row['qualify'];
3297
}
3298
3299
/**
3300
 * This function stores a reply in the forum_post table.