Code Duplication    Length = 24-25 lines in 2 locations

main/webservices/cm_webservice_announcements.php 1 location

@@ 148-171 (lines=24) @@
145
                        GROUP BY ip.ref
146
                        ORDER BY display_order DESC
147
                        LIMIT 0,$maximum";
148
            } else {
149
150
                if (api_get_course_setting('allow_user_edit_announcement')) {
151
                    $cond_user_id = " AND (
152
                        ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL
153
                    ) ";
154
                } else {
155
                    $cond_user_id = " AND ip.to_group_id='0' ";
156
                }
157
158
                // the user is not identiefied => show only the general announcements
159
                $sql = "SELECT
160
                        announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
161
                        FROM $tbl_announcement announcement, $tbl_item_property ip
162
                        WHERE announcement.id = ip.ref
163
                        AND ip.tool='announcement'
164
                        AND ip.visibility='1'
165
                        AND ip.to_group_id='0'
166
                        $announcement_id
167
                        $condition_session
168
                        GROUP BY ip.ref
169
                        ORDER BY display_order DESC
170
                        LIMIT 0,$maximum";
171
            }
172
        }
173
174
        $result = Database::query($sql);

main/inc/lib/AnnouncementManager.php 1 location

@@ 1802-1826 (lines=25) @@
1799
                                GROUP BY ip.ref
1800
                                ORDER BY display_order DESC
1801
                                LIMIT 0, $maximum";
1802
                    } else {
1803
1804
                        if (api_get_course_setting('allow_user_edit_announcement')) {
1805
                            $cond_user_id = " AND (
1806
                                ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL
1807
                            ) ";
1808
                        } else {
1809
                            $cond_user_id = " AND ip.to_group_id='0' ";
1810
                        }
1811
1812
                        // the user is not identiefied => show only the general announcements
1813
                        $sql = "SELECT 
1814
                                    announcement.*, 
1815
                                    ip.visibility, 
1816
                                    ip.to_group_id, 
1817
                                    ip.insert_user_id
1818
                                FROM $tbl_announcement announcement 
1819
                                INNER JOIN $tbl_item_property ip
1820
                                ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
1821
                                WHERE
1822
                                    announcement.c_id = $course_id AND
1823
                                    ip.c_id = $course_id AND 
1824
                                    ip.tool='announcement' AND 
1825
                                    ip.visibility='1' AND 
1826
                                    ip.to_group_id='0'
1827
                                    $condition_session
1828
                                GROUP BY ip.ref
1829
                                ORDER BY display_order DESC