Code Duplication    Length = 11-14 lines in 4 locations

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

@@ 283-294 (lines=12) @@
280
     * @param int user receiver id
281
     * @return int
282
     */
283
    public static function get_message_number_invitation_by_user_id($user_receiver_id)
284
    {
285
        $tbl_message = Database::get_main_table(TABLE_MESSAGE);
286
        $sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.'
287
                WHERE
288
                    user_receiver_id='.intval($user_receiver_id).' AND
289
                    msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
290
        $res = Database::query($sql);
291
        $row = Database::fetch_array($res, 'ASSOC');
292
293
        return $row['count_message_in_box'];
294
    }
295
296
    /**
297
     * Get number of messages sent to other users

main/forum/forumfunction.inc.php 1 location

@@ 2398-2409 (lines=12) @@
2395
 * @author Patrick Cool <[email protected]>, Ghent University
2396
 * @version february 2006, dokeos 1.8
2397
 */
2398
function count_number_of_forums_in_category($cat_id)
2399
{
2400
    $table_forums = Database::get_course_table(TABLE_FORUM);
2401
    $course_id = api_get_course_int_id();
2402
    $sql = "SELECT count(*) AS number_of_forums
2403
            FROM ".$table_forums."
2404
            WHERE c_id = $course_id AND forum_category='".Database::escape_string($cat_id)."'";
2405
    $result = Database::query($sql);
2406
    $row = Database::fetch_array($result);
2407
2408
    return $row['number_of_forums'];
2409
}
2410
2411
/**
2412
 * This function update a thread

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

@@ 5696-5706 (lines=11) @@
5693
     * Returns the course name from a given code
5694
     * @param string $code
5695
     */
5696
    public static function getCourseNameFromCode($code)
5697
    {
5698
        $tbl_main_categories = Database::get_main_table(TABLE_MAIN_COURSE);
5699
        $sql = 'SELECT title
5700
                FROM ' . $tbl_main_categories.'
5701
                WHERE code = "' . Database::escape_string($code).'"';
5702
        $result = Database::query($sql);
5703
        if ($col = Database::fetch_array($result)) {
5704
            return $col['title'];
5705
        }
5706
    }
5707
5708
    /**
5709
     * Generates a course code from a course title

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

@@ 1652-1665 (lines=14) @@
1649
     *
1650
     * @return string the comment
1651
     */
1652
    public static function get_comments($exe_id, $question_id)
1653
    {
1654
        $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
1655
        $sql = "SELECT teacher_comment 
1656
                FROM $table_track_attempt
1657
                WHERE
1658
                    exe_id='".Database::escape_string($exe_id)."' AND
1659
                    question_id = '".Database::escape_string($question_id)."'
1660
                ORDER by question_id";
1661
        $sqlres = Database::query($sql);
1662
        $comm = Database::result($sqlres, 0, 'teacher_comment');
1663
1664
        return $comm;
1665
    }
1666
1667
    /**
1668
     * @param int $exe_id