/** * Loads jobs available to be marked for Flex, or the marker's current job if present. * * @return $jobs JSON encoded array of jobs if marker hasn't already got a job * @return $script ID of script if marker has a job already * @return $lastPage of script if marker has a job already */ function joblist() { $this->load->database(); $this->load->model('script'); $this->load->model('mark'); $query = $this->mark->getScriptsBeingMarkedBy($this->_getUser()); if ($query->num_rows() > 0) { $scripts = $query->result_array(); $script = $scripts[0]['ID']; $lastPage = count(unserialize($scripts[0]['pageKeys'])); $this->load->view('flex/json_result', array('result' => '{"result":"' . I_FlexJobs::MARKER_HAS_JOB . '","script":' . $script . ',"lastPage":' . $lastPage . '}')); return; } $script = new Script(); // load 10 oldest jobs still active $results = $script->getScriptsForMarking(10); if ($results->num_rows() !== 0) { foreach ($results->result_array() as $script) { $explodeAroundPipe = explode('|', $script['pageKeys']); $script['pages'] = count($explodeAroundPipe); unset($script['pageKeys']); $jobs[] = $script; } } else { $jobs = 'jobs=false'; } $this->load->library('json'); $jobs = $this->json->encode($jobs); $this->load->view('marker/job_list', array('jobs' => $jobs)); }