Code Duplication    Length = 20-28 lines in 3 locations

main/forum/forumfunction.inc.php 1 location

@@ 3323-3344 (lines=22) @@
3320
 * @author Isaac Flores <[email protected]>, U.N.A.S University
3321
 * @version December 2008, dokeos  1.8.6
3322
 */
3323
function current_qualify_of_thread($threadId, $sessionId, $userId)
3324
{
3325
    $table_threads_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
3326
3327
    $course_id = api_get_course_int_id();
3328
    $currentUserId = api_get_user_id();
3329
    $sessionId = intval($sessionId);
3330
    $threadId = intval($threadId);
3331
3332
    $sql = "SELECT qualify FROM $table_threads_qualify
3333
            WHERE
3334
                c_id = $course_id AND
3335
                thread_id = $threadId AND
3336
                session_id = $sessionId AND
3337
                qualify_user_id = $currentUserId AND
3338
                user_id = $userId
3339
            ";
3340
    $res = Database::query($sql);
3341
    $row = Database::fetch_array($res, 'ASSOC');
3342
3343
    return $row['qualify'];
3344
}
3345
3346
/**
3347
 * This function stores a reply in the forum_post table.

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

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