示例#1
0
文件: logs.php 项目: ratbird/hope
    /**
     * Sets the filters for the log view.
     * Filters are stored in the session.
     */
    public function filter_action()
    {
        $filter     = array_filter(Request::optionArray('filter'));
        $conditions = array();

        if (!empty($filter['status'])) {
            $conditions[] = ($filter['status'] === 'passed')
                          ? "exception = 'N;'"
                          : "exception != 'N;'";
        }

        if (!empty($filter['schedule_id'])) {
            $conditions[] = "schedule_id = " . DBManager::get()->quote($filter['schedule_id']);
        }

        if (!empty($filter['task_id'])) {
            $temp = CronjobSchedule::findByTask_id($filter['task_id']);
            $temp = SimpleORMapCollection::createFromArray($temp);
            $schedule_ids = $temp->pluck('schedule_id') ?: null;
            $conditions[] = "schedule_id IN (" . DBManager::get()->quote($schedule_ids). ")";
        }

        $_SESSION['cronlog-filter'] = array(
            'where'  => implode(" AND " , $conditions) ?: '1',
            'values' => $filter,
        );
        $this->redirect('admin/cronjobs/logs');
    }
示例#2
0
 /**
  * Cancels all schedules of the provided task.
  *
  * @param String $task_id Id of the task which schedules shall be canceled
  */
 public function cancelByTask($task_id)
 {
     $schedules = CronjobSchedule::findByTask_id($task_id);
     foreach ($schedules as $schedule) {
         $schedule->delete();
     }
 }