Code Duplication    Length = 11-14 lines in 4 locations

main/forum/forumfunction.inc.php 1 location

@@ 2369-2380 (lines=12) @@
2366
 * @author Patrick Cool <[email protected]>, Ghent University
2367
 * @version february 2006, dokeos 1.8
2368
 */
2369
function count_number_of_forums_in_category($cat_id)
2370
{
2371
    $table_forums = Database :: get_course_table(TABLE_FORUM);
2372
    $course_id = api_get_course_int_id();
2373
    $sql = "SELECT count(*) AS number_of_forums
2374
            FROM ".$table_forums."
2375
            WHERE c_id = $course_id AND forum_category='".Database::escape_string($cat_id)."'";
2376
    $result = Database::query($sql);
2377
    $row = Database::fetch_array($result);
2378
2379
    return $row['number_of_forums'];
2380
}
2381
2382
/**
2383
 * This function update a thread

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

@@ 1644-1657 (lines=14) @@
1641
     *
1642
     * @return string the comment
1643
     */
1644
    public static function get_comments($exe_id, $question_id)
1645
    {
1646
        $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
1647
        $sql = "SELECT teacher_comment 
1648
                FROM $table_track_attempt
1649
                WHERE
1650
                    exe_id='".Database::escape_string($exe_id)."' AND
1651
                    question_id = '".Database::escape_string($question_id)."'
1652
                ORDER by question_id";
1653
        $sqlres = Database::query($sql);
1654
        $comm = Database::result($sqlres, 0, 'teacher_comment');
1655
1656
        return $comm;
1657
    }
1658
1659
    /**
1660
     * @param int $exe_id

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

@@ 253-264 (lines=12) @@
250
     * @param int user receiver id
251
     * @return int
252
     */
253
    public static function get_message_number_invitation_by_user_id($user_receiver_id)
254
    {
255
        $tbl_message = Database::get_main_table(TABLE_MESSAGE);
256
        $sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.'
257
                WHERE
258
                    user_receiver_id='.intval($user_receiver_id).' AND
259
                    msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
260
        $res = Database::query($sql);
261
        $row = Database::fetch_array($res, 'ASSOC');
262
263
        return $row['count_message_in_box'];
264
    }
265
266
    /**
267
     * Get invitation list received by user

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

@@ 5551-5561 (lines=11) @@
5548
     * Returns the course name from a given code
5549
     * @param string $code
5550
     */
5551
    public static function getCourseNameFromCode($code)
5552
    {
5553
        $tbl_main_categories = Database:: get_main_table(TABLE_MAIN_COURSE);
5554
        $sql = 'SELECT title
5555
                FROM ' . $tbl_main_categories . '
5556
                WHERE code = "' . Database::escape_string($code) . '"';
5557
        $result = Database::query($sql);
5558
        if ($col = Database::fetch_array($result)) {
5559
            return $col['title'];
5560
        }
5561
    }
5562
5563
    /**
5564
     * Generates a course code from a course title