public function undoimportAction()
 {
     $fi_import = $this->findById();
     // change the status of the import
     $fi_import->status = FeedImporter_Import::STATUS_IN_PROGRESS_UNDO_IMPORT;
     $fi_import->save();
     // // dispatch the background process to undo the import
     $user = current_user();
     $args = array();
     $args['import_id'] = $fi_import->id;
     ProcessDispatcher::startProcess('FeedImporter_UndoImportProcess', $user, $args);
     // $this->flashSuccess("Successfully started to undo the import. Reload this page for status updates.");
     $this->redirect->gotoUrl('feeds/show/' . $fi_import->feed_id);
     //$this->redirect->gotoUrl('feeds/imports/show/' . $fi_import->id );
 }
 public function run($params = null)
 {
     _log("Running cron");
     $params = unserialize($params);
     $feed_id = $params[0];
     _log("Cron task: {$feed_id}");
     $feed = get_db()->getTable('FeedImporter_Feed')->find($feed_id);
     //make a new FI_Import
     $newImport = new FeedImporter_Import();
     $newImport->feed_id = $feed->id;
     $newImport->collection_id = $feed->collection_id;
     $newImport->status = STATUS_IN_PROGRESS_IMPORT;
     $newImport->created = date('Y-m-d G:i:s');
     $newImport->save();
     // dispatch the background process to import the items
     $user = current_user();
     $args = array();
     $args['import_id'] = $newImport->id;
     ProcessDispatcher::startProcess('FeedImporter_ImportProcess', $user, $args);
 }
 public function importAction()
 {
     if (!$this->_hasValidPHPCliPath()) {
         $this->redirect->goto('error');
     }
     $feed = $this->findById();
     //make a new FI_Import
     $newImport = new FeedImporter_Import();
     $newImport->feed_id = $feed->id;
     $newImport->collection_id = $feed->collection_id;
     $newImport->status = STATUS_IN_PROGRESS_IMPORT;
     $newImport->created = date('Y-m-d G:i:s');
     $newImport->save();
     // dispatch the background process to import the items
     $user = current_user();
     $args = array();
     $args['import_id'] = $newImport->id;
     ProcessDispatcher::startProcess('FeedImporter_ImportProcess', $user, $args);
     $this->view->assign(array('import' => $newImport, 'feed' => $feed));
     $this->redirect->gotoUrl('feeds/imports/show/' . $newImport->id);
 }