/** * Displays a form for editing an entry * * @return void */ public function displayTask() { // Filters $filters = array('sort' => trim(Request::getState($this->_option . '.jobs.sort', 'filter_order', 'id')), 'sort_Dir' => trim(Request::getState($this->_option . '.jobs.sortdir', 'filter_order_Dir', 'ASC'))); // Get records $rows = Job::all()->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows(); // Output the HTML $this->view->set('rows', $rows)->set('filters', $filters)->display(); }
/** * Display a list of latest whiteboard entries * * @return void */ public function displayTask() { if (!User::authorise('core.manage', $this->_option)) { $ip = Request::ip(); $ips = explode(',', $this->config->get('whitelist', '')); $ips = array_map('trim', $ips); if (!in_array($ip, $ips)) { $ips = gethostbynamel($_SERVER['SERVER_NAME']); if (!in_array($ip, $ips)) { $ips = gethostbynamel('localhost'); if (!in_array($ip, $ips)) { header("HTTP/1.1 404 Not Found"); exit; } } } } Request::setVar('no_html', 1); Request::setVar('tmpl', 'component'); $now = Date::toSql(); $results = Job::all()->whereEquals('state', 1)->where('next_run', '<=', Date::toLocal('Y-m-d H:i:s'))->whereEquals('publish_up', '0000-00-00 00:00:00', 1)->orWhere('publish_up', '<=', $now, 1)->resetDepth()->whereEquals('publish_down', '0000-00-00 00:00:00', 1)->orWhere('publish_down', '>', $now, 1)->rows(); $output = new stdClass(); $output->jobs = array(); if ($results) { foreach ($results as $job) { if ($job->get('active') || !$job->isAvailable()) { continue; } // Show related content $job->mark('start_run'); $results = Event::trigger('cron.' . $job->get('event'), array($job)); if ($results && is_array($results)) { // Set it as active in case there were multiple plugins called on // the event. This is to ensure ALL processes finished. $job->set('active', 1); $job->save(); foreach ($results as $result) { if ($result) { $job->set('active', 0); } } } $job->mark('end_run'); $job->set('last_run', Date::toLocal('Y-m-d H:i:s')); //Date::toSql()); $job->set('next_run', $job->nextRun()); $job->save(); $output->jobs[] = $job->toArray(); } } $this->view->set('no_html', Request::getInt('no_html', 0))->set('output', $output)->display(); }
/** * Displays a form for editing an entry * * @return void */ public function displayTask() { // Filters $this->view->filters = array('sort' => trim(Request::getState($this->_option . '.jobs.sort', 'filter_order', 'id')), 'sort_Dir' => trim(Request::getState($this->_option . '.jobs.sortdir', 'filter_order_Dir', 'ASC'))); /*if ($this->view->filters['search']) { $record->whereLike('fullname', $this->view->filters['search']); }*/ $record = Job::all(); $this->view->rows = $record->ordered('filter_order', 'filter_order_Dir')->paginated(); // Output the HTML $this->view->display(); }
/** * Run any scheduled cron tasks * * @return void */ public function displayTask() { // If the current user doesn't have access to manage the component, // try to see if their IP address is in the whtielist. // Otherwise, we stop any further code execution. if (!User::authorise('core.manage', $this->_option)) { $ip = Request::ip(); $ips = explode(',', $this->config->get('whitelist', '')); $ips = array_map('trim', $ips); if (!in_array($ip, $ips)) { $ips = gethostbynamel($_SERVER['SERVER_NAME']); if (!in_array($ip, $ips)) { $ips = gethostbynamel('localhost'); if (!in_array($ip, $ips)) { header("HTTP/1.1 404 Not Found"); exit; } } } } // Forcefully do NOT render the template // (extra processing that's not needed) Request::setVar('no_html', 1); Request::setVar('tmpl', 'component'); $now = Date::toSql(); // Get the list of jobs that should be run $results = Job::all()->whereEquals('state', 1)->where('next_run', '<=', Date::toLocal('Y-m-d H:i:s'))->whereEquals('publish_up', '0000-00-00 00:00:00', 1)->orWhere('publish_up', '<=', $now, 1)->resetDepth()->whereEquals('publish_down', '0000-00-00 00:00:00', 1)->orWhere('publish_down', '>', $now, 1)->rows(); $output = new stdClass(); $output->jobs = array(); if ($results) { foreach ($results as $job) { if ($job->get('active') || !$job->isAvailable()) { continue; } // Show related content $job->mark('start_run'); $results = Event::trigger('cron.' . $job->get('event'), array($job)); if ($results && is_array($results)) { // Set it as active in case there were multiple plugins called on // the event. This is to ensure ALL processes finished. $job->set('active', 1); $job->save(); foreach ($results as $result) { if ($result) { $job->set('active', 0); } } } $job->mark('end_run'); $job->set('last_run', Date::toLocal('Y-m-d H:i:s')); //Date::toSql()); $job->set('next_run', $job->nextRun()); $job->save(); $output->jobs[] = $job->toArray(); } } // Output any data from the jobs that ran // Largely used for debugging/monitoring purposes $this->view->set('no_html', Request::getInt('no_html', 0))->set('output', $output)->display(); }