Code Duplication    Length = 26-27 lines in 2 locations

main/auth/courses_controller.php 2 locations

@@ 688-714 (lines=27) @@
685
     * Show the Session Catalogue with filtered session by course tags
686
     * @param array $limit Limit info
687
     */
688
    public function sessionsListByCoursesTag(array $limit)
689
    {
690
        $searchTag = isset($_POST['search_tag']) ? $_POST['search_tag'] : null;
691
        $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
692
        $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
693
        $courseUrl = CourseCategory::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
694
695
        $sessions = $this->model->browseSessionsByTags($searchTag, $limit);
696
        $sessionsBlocks = $this->getFormattedSessionsBlock($sessions);
697
698
        $tpl = new Template();
699
700
        $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
701
        $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
702
        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
703
        $tpl->assign('course_url', $courseUrl);
704
        $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
705
        $tpl->assign('hidden_links', $hiddenLinks);
706
        $tpl->assign('search_token', Security::get_token());
707
        $tpl->assign('search_date', Security::remove_XSS($searchDate));
708
        $tpl->assign('search_tag', Security::remove_XSS($searchTag));
709
        $tpl->assign('sessions', $sessionsBlocks);
710
711
        $contentTemplate = $tpl->get_template('auth/session_catalog.tpl');
712
713
        $tpl->display($contentTemplate);
714
    }
715
716
    /**
717
     * Show the Session Catalogue with filtered session by a query term
@@ 720-745 (lines=26) @@
717
     * Show the Session Catalogue with filtered session by a query term
718
     * @param array $limit
719
     */
720
    public function sessionListBySearch(array $limit)
721
    {
722
        $q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null;
723
        $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
724
        $courseUrl = CourseCategory::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
725
        $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
726
727
        $sessions = $this->model->browseSessionsBySearch($q, $limit);
728
        $sessionsBlocks = $this->getFormattedSessionsBlock($sessions);
729
730
        $tpl = new Template();
731
        $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
732
        $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
733
        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
734
        $tpl->assign('course_url', $courseUrl);
735
        $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
736
        $tpl->assign('hidden_links', $hiddenLinks);
737
        $tpl->assign('search_token', Security::get_token());
738
        $tpl->assign('search_date', Security::remove_XSS($searchDate));
739
        $tpl->assign('search_tag', Security::remove_XSS($q));
740
        $tpl->assign('sessions', $sessionsBlocks);
741
742
        $contentTemplate = $tpl->get_template('auth/session_catalog.tpl');
743
744
        $tpl->display($contentTemplate);
745
    }
746
747
    /**
748
     * Get the formatted data for sessions block to be displayed on Session Catalog page