Code Duplication    Length = 24-30 lines in 2 locations

main/inc/lib/AnnouncementManager.php 1 location

@@ 93-122 (lines=30) @@
90
     * @param int $session_id
91
     * @return array html with the content and count of announcements or false otherwise
92
     */
93
    public static function get_all_annoucement_by_course($course_info, $session_id = 0)
94
    {
95
        $session_id = intval($session_id);
96
        $course_id = $course_info['real_id'];
97
98
        $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
99
        $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
100
101
        $sql = "SELECT DISTINCT 
102
                    announcement.id, 
103
                    announcement.title, 
104
                    announcement.content
105
				FROM $tbl_announcement announcement 
106
				INNER JOIN $tbl_item_property i
107
				ON (announcement.id = i.ref AND announcement.c_id = i.c_id)
108
				WHERE
109
                    i.tool='announcement' AND
110
                    announcement.session_id  = '$session_id' AND
111
                    announcement.c_id = $course_id AND
112
                    i.c_id = $course_id
113
				ORDER BY display_order DESC";
114
        $rs = Database::query($sql);
115
        $num_rows = Database::num_rows($rs);
116
        if ($num_rows > 0) {
117
            $list = array();
118
            while ($row = Database::fetch_array($rs)) {
119
                $list[] = $row;
120
            }
121
122
            return $list;
123
        }
124
125
        return false;

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

@@ 2777-2800 (lines=24) @@
2774
     *
2775
     * @return array
2776
     */
2777
    public function getAllSkillPerTag($fieldId, $tagId)
2778
    {
2779
        $skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
2780
        $tagRelExtraTable = Database::get_main_table(TABLE_MAIN_EXTRA_FIELD_REL_TAG);
2781
        $fieldId = intval($fieldId);
2782
        $tagId = intval($tagId);
2783
2784
        $sql = "SELECT s.id
2785
                FROM $skillTable s INNER JOIN $tagRelExtraTable t
2786
                ON t.item_id = s.id
2787
                WHERE tag_id = $tagId AND t.field_id = $fieldId;
2788
        ";
2789
2790
        $result = Database::query($sql);
2791
        $result = Database::store_result($result, 'ASSOC');
2792
2793
        $skillList = [];
2794
        foreach ($result as $index => $value) {
2795
            $skillList[$value['id']] = $value['id'];
2796
        }
2797
2798
        return $skillList;
2799
    }
2800
}
2801