/** * Reverts an import. */ public function actionRevert() { // If entry revisions are supported if (craft()->getEdition() == Craft::Pro) { // Get history id $history = craft()->request->getParam('id'); // Set criteria $criteria = new \CDbCriteria(); $criteria->condition = 'historyId = :history_id'; $criteria->params = array(':history_id' => $history); // Get entries in history $entries = Import_EntriesRecord::model()->findAll($criteria); // Create the revert task $task = craft()->tasks->createTask('Import_Revert', Craft::t('Reverting import'), array('entries' => $entries)); // Notify user craft()->userSession->setNotice(Craft::t('Revert import process started.')); } // Redirect to history $this->redirect('import/history'); }
/** * Save entry version. * * @param int $history * @param int $entry */ public function version($history, $entry) { // Get previous version $version = end(craft()->entryRevisions->getVersionsByEntryId($entry, false, 2)); // Save $log = new Import_EntriesRecord(); $log->historyId = $history; $log->entryId = $entry; $log->versionId = $version ? $version->versionId : null; $log->save(false); }