Code Duplication    Length = 47-47 lines in 2 locations

module/Jobs/src/Jobs/Controller/ApprovalController.php 1 location

@@ 80-126 (lines=47) @@
77
    /**
78
     * @return ViewModel
79
     */
80
    public function listOpenJobsAction()
81
    {
82
        /* @var $request \Zend\Http\Request */
83
        $request     = $this->getRequest();
84
        $params      = $request->getQuery();
85
        $jsonFormat  = 'json' == $params->get('format');
86
        $isRecruiter = $this->acl()->isRole(User::ROLE_RECRUITER);
87
88
        if (!$jsonFormat && !$request->isXmlHttpRequest()) {
89
            $session       = new Session('Jobs\Index');
90
            $sessionKey    = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams';
91
            $sessionParams = $session[$sessionKey];
92
93
            if ($sessionParams) {
94
                foreach ($sessionParams as $key => $value) {
95
                    $params->set($key, $params->get($key, $value));
96
                }
97
            } elseif ($isRecruiter) {
98
                $params->set('by', 'me');
99
            }
100
            /* @var $filterForm \Jobs\Form\ListFilter */
101
            $session[$sessionKey] = $params->toArray();
102
103
            $this->searchForm->bind($params);
104
105
        }
106
107
        if (!isset($params['sort'])) {
108
            $params['sort'] = '-date';
109
        }
110
111
        $paginator = $this->paginatorservice('Jobs/Admin', $params);
112
113
        $return = array(
114
            'by'   => $params->get('by', 'all'),
115
            'jobs' => $paginator,
116
            'showPendingJobs' => true,
117
        );
118
        if (isset($this->searchForm)) {
119
            $return['filterForm'] = $this->searchForm;
120
        }
121
122
        $model = new ViewModel();
123
        $model->setVariables($return);
124
        $model->setTemplate('jobs/index/index');
125
        return $model;
126
    }
127
}
128

module/Jobs/src/Jobs/Controller/IndexController.php 1 location

@@ 91-137 (lines=47) @@
88
     *
89
     * @return ViewModel
90
     */
91
    protected function listJobs()
92
    {
93
        /* @var $request \Zend\Http\Request */
94
        $request     = $this->getRequest();
95
        $params      = $request->getQuery();
96
        $jsonFormat  = 'json' == $params->get('format');
97
        $isRecruiter = $this->acl()->isRole(User::ROLE_RECRUITER);
98
99
        if (!$jsonFormat && !$request->isXmlHttpRequest()) {
100
            $session       = new Session('Jobs\Index');
101
            $sessionKey    = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams';
102
            $sessionParams = $session[$sessionKey];
103
104
            if ($sessionParams) {
105
                foreach ($sessionParams as $key => $value) {
106
                    $params->set($key, $params->get($key, $value));
107
                }
108
            } elseif ($isRecruiter) {
109
                $params->set('by', 'me');
110
            }
111
112
            $session[$sessionKey] = $params->toArray();
113
114
            $this->searchForm->bind($params);
115
116
        }
117
118
        if (!isset($params['sort'])) {
119
            $params['sort'] = '-date';
120
        }
121
122
        $paginator = $this->paginatorservice('Jobs/Job', $params);
123
124
        $return = array(
125
            'by'   => $params->get('by', 'all'),
126
            'jobs' => $paginator,
127
            'showPendingJobs' => false,
128
        );
129
        if (isset($this->searchForm)) {
130
            $return['filterForm'] = $this->searchForm;
131
        }
132
133
        $model = new ViewModel();
134
        $model->setVariables($return);
135
        $model->setTemplate('jobs/index/index');
136
        return $model;
137
    }
138
139
    /**
140
     * Handles the dashboard widget for the jobs module.