Code Duplication    Length = 40-40 lines in 2 locations

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

@@ 99-138 (lines=40) @@
96
     * @param bool $show_slide
97
     * @return null|string
98
     */
99
    public function return_announcements($show_slide = true)
100
    {
101
        // Display System announcements
102
        $hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected');
103
        $currentUserId = api_get_user_id();
104
        if ($hideAnnouncements == 'true' && empty($currentUserId)) {
105
            return null;
106
        }
107
        $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null;
108
        $announcement = intval($announcement);
109
110
        if (!api_is_anonymous() && $this->user_id) {
111
            $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
112
            if ($show_slide) {
113
                $announcements = SystemAnnouncementManager:: display_announcements_slider(
114
                    $visibility,
115
                    $announcement
116
                );
117
            } else {
118
                $announcements = SystemAnnouncementManager:: display_all_announcements(
119
                    $visibility,
120
                    $announcement
121
                );
122
            }
123
        } else {
124
            if ($show_slide) {
125
                $announcements = SystemAnnouncementManager:: display_announcements_slider(
126
                    SystemAnnouncementManager::VISIBLE_GUEST,
127
                    $announcement
128
                );
129
            } else {
130
                $announcements = SystemAnnouncementManager:: display_all_announcements(
131
                    SystemAnnouncementManager::VISIBLE_GUEST,
132
                    $announcement
133
                );
134
            }
135
        }
136
137
        return $announcements;
138
    }
139
140
    /**
141
     * Alias for the online_logout() function

src/Chamilo/CoreBundle/Framework/PageController.php 1 location

@@ 336-375 (lines=40) @@
333
     * @param bool True: show the announcements as a slider. False: show them as a vertical list
334
     * @return string HTML list of announcements
335
     */
336
    public function getAnnouncements($user_id = null, $show_slide = true)
337
    {
338
        // Display System announcements
339
        $hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected');
340
        if ($hideAnnouncements == 'true' && empty($user_id)) {
341
            return null;
342
        }
343
344
        $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null;
345
        $announcement = intval($announcement);
346
347
        if (!api_is_anonymous() && $user_id) {
348
            $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
349
            if ($show_slide) {
350
                $announcements = SystemAnnouncementManager:: display_announcements_slider(
351
                    $visibility,
352
                    $announcement
353
                );
354
            } else {
355
                $announcements = SystemAnnouncementManager:: display_all_announcements(
356
                    $visibility,
357
                    $announcement
358
                );
359
            }
360
        } else {
361
            if ($show_slide) {
362
                $announcements = SystemAnnouncementManager:: display_announcements_slider(
363
                    SystemAnnouncementManager::VISIBLE_GUEST,
364
                    $announcement
365
                );
366
            } else {
367
                $announcements = SystemAnnouncementManager:: display_all_announcements(
368
                    SystemAnnouncementManager::VISIBLE_GUEST,
369
                    $announcement
370
                );
371
            }
372
        }
373
374
        return $announcements;
375
    }
376
377
    /**
378
     * Return the homepage, including announcements