Code Duplication    Length = 26-29 lines in 2 locations

main/auth/courses_controller.php 2 locations

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