Code Duplication    Length = 26-27 lines in 2 locations

main/auth/courses_controller.php 2 locations

@@ 664-690 (lines=27) @@
661
     * Show the Session Catalogue with filtered session by course tags
662
     * @param array $limit Limit info
663
     */
664
    public function sessionsListByCoursesTag(array $limit)
665
    {
666
        $searchTag = isset($_POST['search_tag']) ? $_POST['search_tag'] : null;
667
        $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
668
        $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
669
        $courseUrl = CourseCategory::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
670
671
        $sessions = $this->model->browseSessionsByTags($searchTag, $limit);
672
        $sessionsBlocks = $this->getFormatedSessionsBlock($sessions);
673
674
        $tpl = new Template();
675
676
        $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
677
        $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
678
        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
679
        $tpl->assign('course_url', $courseUrl);
680
        $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
681
        $tpl->assign('hidden_links', $hiddenLinks);
682
        $tpl->assign('search_token', Security::get_token());
683
        $tpl->assign('search_date', Security::remove_XSS($searchDate));
684
        $tpl->assign('search_tag', Security::remove_XSS($searchTag));
685
        $tpl->assign('sessions', $sessionsBlocks);
686
687
        $contentTemplate = $tpl->get_template('auth/session_catalog.tpl');
688
689
        $tpl->display($contentTemplate);
690
    }
691
692
    /**
693
     * Show the Session Catalogue with filtered session by a query term
@@ 696-721 (lines=26) @@
693
     * Show the Session Catalogue with filtered session by a query term
694
     * @param array $limit
695
     */
696
    public function sessionListBySearch(array $limit)
697
    {
698
        $q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null;
699
        $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
700
        $courseUrl = CourseCategory::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
701
        $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
702
703
        $sessions = $this->model->browseSessionsBySearch($q, $limit);
704
        $sessionsBlocks = $this->getFormatedSessionsBlock($sessions);
705
706
        $tpl = new Template();
707
        $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
708
        $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
709
        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
710
        $tpl->assign('course_url', $courseUrl);
711
        $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
712
        $tpl->assign('hidden_links', $hiddenLinks);
713
        $tpl->assign('search_token', Security::get_token());
714
        $tpl->assign('search_date', Security::remove_XSS($searchDate));
715
        $tpl->assign('search_tag', Security::remove_XSS($q));
716
        $tpl->assign('sessions', $sessionsBlocks);
717
718
        $contentTemplate = $tpl->get_template('auth/session_catalog.tpl');
719
720
        $tpl->display($contentTemplate);
721
    }
722
723
    /**
724
     * Get the formated data for sessions block to be displayed on Session Catalog page