Code Duplication    Length = 24-30 lines in 2 locations

main/inc/lib/AnnouncementManager.php 1 location

@@ 117-146 (lines=30) @@
114
     * @param int $session_id
115
     * @return array html with the content and count of announcements or false otherwise
116
     */
117
    public static function get_all_annoucement_by_course($course_info, $session_id = 0)
118
    {
119
        $session_id = intval($session_id);
120
        $course_id = $course_info['real_id'];
121
122
        $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
123
        $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
124
125
        $sql = "SELECT DISTINCT 
126
                    announcement.id, 
127
                    announcement.title, 
128
                    announcement.content
129
				FROM $tbl_announcement announcement 
130
				INNER JOIN $tbl_item_property i
131
				ON (announcement.id = i.ref AND announcement.c_id = i.c_id)
132
				WHERE
133
                    i.tool='announcement' AND
134
                    announcement.session_id  = '$session_id' AND
135
                    announcement.c_id = $course_id AND
136
                    i.c_id = $course_id
137
				ORDER BY display_order DESC";
138
        $rs = Database::query($sql);
139
        $num_rows = Database::num_rows($rs);
140
        if ($num_rows > 0) {
141
            $list = array();
142
            while ($row = Database::fetch_array($rs)) {
143
                $list[] = $row;
144
            }
145
146
            return $list;
147
        }
148
149
        return false;

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

@@ 2847-2870 (lines=24) @@
2844
     *
2845
     * @return array
2846
     */
2847
    public function getAllSkillPerTag($fieldId, $tagId)
2848
    {
2849
        $skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
2850
        $tagRelExtraTable = Database::get_main_table(TABLE_MAIN_EXTRA_FIELD_REL_TAG);
2851
        $fieldId = intval($fieldId);
2852
        $tagId = intval($tagId);
2853
2854
        $sql = "SELECT s.id
2855
                FROM $skillTable s INNER JOIN $tagRelExtraTable t
2856
                ON t.item_id = s.id
2857
                WHERE tag_id = $tagId AND t.field_id = $fieldId;
2858
        ";
2859
2860
        $result = Database::query($sql);
2861
        $result = Database::store_result($result, 'ASSOC');
2862
2863
        $skillList = [];
2864
        foreach ($result as $index => $value) {
2865
            $skillList[$value['id']] = $value['id'];
2866
        }
2867
2868
        return $skillList;
2869
    }
2870
}
2871