/**
  * Deletes an import from the history.
  */
 public function actionDelete()
 {
     // Get history id
     $history = craft()->request->getParam('id');
     // Get history
     $model = Import_HistoryRecord::model()->findById($history);
     // Notify user
     craft()->userSession->setNotice(Craft::t('The import history of {file} has been deleted.', array('file' => $model->file)));
     // Set criteria
     $criteria = new \CDbCriteria();
     $criteria->condition = 'historyId = :history_id';
     $criteria->params = array(':history_id' => $history);
     // Delete attached logs
     Import_LogRecord::model()->deleteAll($criteria);
     // Delete history
     $model->delete();
     // Redirect to history
     $this->redirect('import/history');
 }
 /**
  * Add to log.
  *
  * @param int   $history
  * @param int   $line
  * @param array $errors
  *
  * @return array
  */
 public function log($history, $line, array $errors)
 {
     if (Import_HistoryRecord::model()->findById($history)) {
         $log = new Import_LogRecord();
         $log->historyId = $history;
         $log->line = $line + 2;
         $log->errors = $errors;
         $log->save(false);
     }
     return $errors;
 }
 /**
  * @codeCoverageIgnore
  *
  * @param \CDbCriteria $criteria
  *
  * @return Import_LogRecord[]
  */
 protected function findAllLogs(\CDbCriteria $criteria)
 {
     return Import_LogRecord::model()->findAll($criteria);
 }