Code Duplication    Length = 22-23 lines in 2 locations

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

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

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

@@ 4774-4795 (lines=22) @@
4771
     * @return bool    True if the user is a coach
4772
     *
4773
     */
4774
    public static function is_session_course_coach($user_id, $courseId, $session_id)
4775
    {
4776
        $tbl_session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
4777
        // Protect data
4778
        $user_id = intval($user_id);
4779
        $courseId = intval($courseId);
4780
        $session_id = intval($session_id);
4781
        $result = false;
4782
4783
        $sql = "SELECT session_id FROM $tbl_session_course_rel_user
4784
                WHERE
4785
                  session_id = $session_id AND
4786
                  c_id = $courseId AND
4787
                  user_id = $user_id AND
4788
                  status = 2 ";
4789
        $res = Database::query($sql);
4790
4791
        if (Database::num_rows($res) > 0) {
4792
            $result = true;
4793
        }
4794
        return $result;
4795
    }
4796
4797
    /**
4798
     * This function returns an icon path that represents the favicon of the website of which the url given.