Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 4037-4059 (lines=23) @@
4034
     * @param $courseId
4035
     * @return array
4036
     */
4037
    public static function getUserCourseCategoryForCourse($userId, $courseId)
4038
    {
4039
        $tblCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
4040
        $tblUserCategory = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
4041
        $courseId = intval($courseId);
4042
        $userId = intval($userId);
4043
4044
        $sql = "SELECT user_course_cat, title
4045
                FROM $tblCourseRelUser cru
4046
                LEFT JOIN $tblUserCategory ucc
4047
                ON cru.user_course_cat = ucc.id
4048
                WHERE
4049
                    cru.user_id = $userId AND c_id= $courseId ";
4050
4051
        $res = Database::query($sql);
4052
4053
        $data = array();
4054
        if (Database::num_rows($res) > 0) {
4055
            $data = Database::fetch_assoc($res);
4056
        }
4057
4058
        return $data;
4059
    }
4060
4061
    /**
4062
     * Get the course id based on the original id and field name in the extra fields.

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

@@ 4759-4780 (lines=22) @@
4756
     * @return bool    True if the user is a coach
4757
     *
4758
     */
4759
    public static function is_session_course_coach($user_id, $courseId, $session_id)
4760
    {
4761
        $tbl_session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
4762
        // Protect data
4763
        $user_id = intval($user_id);
4764
        $courseId = intval($courseId);
4765
        $session_id = intval($session_id);
4766
        $result = false;
4767
4768
        $sql = "SELECT session_id FROM $tbl_session_course_rel_user
4769
                WHERE
4770
                  session_id = $session_id AND
4771
                  c_id = $courseId AND
4772
                  user_id = $user_id AND
4773
                  status = 2 ";
4774
        $res = Database::query($sql);
4775
4776
        if (Database::num_rows($res) > 0) {
4777
            $result = true;
4778
        }
4779
        return $result;
4780
    }
4781
4782
    /**
4783
     * This function returns an icon path that represents the favicon of the website of which the url given.