Code Duplication    Length = 15-20 lines in 4 locations

main/survey/survey.lib.php 2 locations

@@ 1499-1516 (lines=18) @@
1496
     * @author Patrick Cool <[email protected]>, Ghent University
1497
     * @version January 2007
1498
     */
1499
    public static function delete_all_survey_questions_options($survey_id, $shared = false)
1500
    {
1501
        // Table definitions
1502
        $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1503
        $course_id = api_get_course_int_id();
1504
        $course_condition = " c_id = $course_id AND ";
1505
        if ($shared) {
1506
            $course_condition = "";
1507
            $table_survey_question_option = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1508
        }
1509
1510
        $sql = "DELETE FROM $table_survey_question_option
1511
                WHERE $course_condition survey_id='".intval($survey_id)."'";
1512
1513
        // Deleting the options of the survey questions
1514
        Database::query($sql);
1515
1516
        return true;
1517
    }
1518
1519
    /**
@@ 1532-1551 (lines=20) @@
1529
     * @author Julio Montoya
1530
     * @version March 2007
1531
     */
1532
    public static function delete_survey_question_option($survey_id, $question_id, $shared = false)
1533
    {
1534
        $course_id = api_get_course_int_id();
1535
        $course_condition = " c_id = $course_id AND ";
1536
1537
        // Table definitions
1538
        $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1539
        if ($shared) {
1540
            $course_condition = "";
1541
            $table_survey_question_option = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1542
        }
1543
1544
        // Deleting the options of the survey questions
1545
        $sql = "DELETE from $table_survey_question_option
1546
		        WHERE
1547
		            $course_condition survey_id='".intval($survey_id)."' AND
1548
		            question_id='".intval($question_id)."'";
1549
        Database::query($sql);
1550
        return true;
1551
    }
1552
1553
    /**
1554
     * SURVEY ANSWERS FUNCTIONS

main/forum/forumfunction.inc.php 1 location

@@ 2073-2088 (lines=16) @@
2070
 * @author Patrick Cool <[email protected]>, Ghent University
2071
 * @version february 2006, dokeos 1.8
2072
 */
2073
function get_post_information($post_id)
2074
{
2075
    $table_posts = Database::get_course_table(TABLE_FORUM_POST);
2076
    $table_users = Database::get_main_table(TABLE_MAIN_USER);
2077
    $course_id = api_get_course_int_id();
2078
2079
    $sql = "SELECT posts.*, email FROM ".$table_posts." posts, ".$table_users." users
2080
            WHERE
2081
                c_id = $course_id AND
2082
                posts.poster_id=users.user_id AND
2083
                posts.post_id = ".intval($post_id);
2084
    $result = Database::query($sql);
2085
    $row = Database::fetch_array($result, 'ASSOC');
2086
2087
    return $row;
2088
}
2089
2090
/**
2091
 * This function retrieves all the information of a thread

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

@@ 2664-2678 (lines=15) @@
2661
     * @param int $courseId
2662
     * @return bool Returns TRUE if the session and the course are related, FALSE otherwise.
2663
     * */
2664
    public static function relation_session_course_exist($session_id, $courseId)
2665
    {
2666
        $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
2667
        $return_value = false;
2668
        $sql = "SELECT c_id FROM $tbl_session_course
2669
                WHERE
2670
                  session_id = ".intval($session_id)." AND
2671
                  c_id = " . intval($courseId);
2672
        $result = Database::query($sql);
2673
        $num = Database::num_rows($result);
2674
        if ($num > 0) {
2675
            $return_value = true;
2676
        }
2677
        return $return_value;
2678
    }
2679
2680
    /**
2681
     * Get the session information by name