Sequenzia/app/controllers/JobTaskController.php
2013-10-26 18:06:58 -05:00

47 lines
1.3 KiB
PHP
Executable File

<?php
class JobTaskController extends ApplicationController
{
public function index()
{
$this->job_tasks = JobTask::order("id DESC")->paginate($this->page_number(), 25);
}
public function show()
{
$this->job_task = JobTask::find($this->params()->id);
if ($this->job_task->task_type == "upload_post" && $this->job_task->status == "finished") {
$this->redirectTo(['controller' => "post", 'action' => "show", 'id' => $this->job_task->status_message]);
}
}
public function destroy()
{
$this->job_task = JobTask::find($this->params()->id);
if ($this->request()->isPost()) {
$this->job_task->destroy();
$this->redirectTo(['action' => "index"]);
}
}
public function restart()
{
$this->job_task = JobTask::find($this->params()->id);
if ($this->request()->isPost()) {
$this->job_task->updateAttributes(['status' => "pending", 'status_message' => ""]);
$this->redirectTo(['action' => "show", 'id' => $this->job_task->id]);
}
}
protected function filters()
{
return [
'before' => [
'admin_only' => ['only' => ['destroy', 'restart']]
]
];
}
}