Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3998-4020 (lines=23) @@
3995
     * @param $courseId
3996
     * @return array
3997
     */
3998
    public static function getUserCourseCategoryForCourse($userId, $courseId)
3999
    {
4000
        $tblCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
4001
        $tblUserCategory = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
4002
        $courseId = intval($courseId);
4003
        $userId = intval($userId);
4004
4005
        $sql = "SELECT user_course_cat, title
4006
                FROM $tblCourseRelUser cru
4007
                LEFT JOIN $tblUserCategory ucc
4008
                ON cru.user_course_cat = ucc.id
4009
                WHERE
4010
                    cru.user_id = $userId AND c_id= $courseId ";
4011
4012
        $res = Database::query($sql);
4013
4014
        $data = array();
4015
        if (Database::num_rows($res) > 0) {
4016
            $data = Database::fetch_assoc($res);
4017
        }
4018
4019
        return $data;
4020
    }
4021
4022
    /**
4023
     * Get the course id based on the original id and field name in the extra fields.

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

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