/**
  * Fetches our export data as a multi-dimensional array.
  *
  * @param bool $manual          Whether this is a manual run.
  * @param int  $targetstarttime The timestamp representing the theoretical time when this task was meant to be run
  * @param int  $lastruntime     The last time the export was run (required for incremental scheduled export)
  *
  * @return array The export data
  */
 protected function get_export_data($manual = true, $targetstarttime = 0, $lastruntime = 0)
 {
     global $CFG;
     $file = get_plugin_directory('dhexport', 'version1elis') . '/version1elis.class.php';
     require_once $file;
     // Set the export to be incremental.
     set_config('nonincremental', 0, 'dhexport_version1elis');
     // Set the incremental time delta.
     set_config('incrementaldelta', '1d', 'dhexport_version1elis');
     // Plugin for file IO.
     $fileplugin = new rlip_fileplugin_export();
     $fileplugin->open(RLIP_FILE_WRITE);
     // Our specific export.
     $exportplugin = new rlip_exportplugin_version1elis($fileplugin, $manual);
     $exportplugin->init($targetstarttime, $lastruntime);
     $exportplugin->export_records(0);
     $exportplugin->close();
     $fileplugin->close();
     return $fileplugin->get_data();
 }
 /**
  * Validate that the export resets state appropriately
  */
 public function test_export_resetsstate()
 {
     global $CFG;
     $file = get_plugin_directory('dhexport', 'version1elis') . '/version1elis.class.php';
     require_once $file;
     // Data setup.
     $this->load_csv_data();
     // Set the export to be incremental.
     set_config('nonincremental', 0, 'dhexport_version1elis');
     // Plugin for file IO.
     $fileplugin = new rlip_fileplugin_export();
     $fileplugin->open(RLIP_FILE_WRITE);
     // Our specific export.
     $exportplugin = new rlip_exportplugin_version1elis($fileplugin, true);
     $exportplugin->init(0, 0);
     // Validate setup.
     $this->assertTrue($exportplugin->recordset->valid());
     $exportplugin->close();
     // Validate result.
     $this->assertNull($exportplugin->recordset);
     $fileplugin->close();
 }
 /**
  * Run the export for whatever data is currently in the database
  *
  * @param int $targetstarttime The timestamp representing the theoretical time when this task was meant to be run
  * @param int $writedelay The num of seconds delay each write call (passed to rlipexport_version1elis_fileplugin_memoryexport)
  * @param int $lastruntime The last time the export was run (required for incremental scheduled export)
  * @param int $maxruntime The max time in seconds to complete export default: 0 => unlimited
  * @param object $state Previous ran state data to continue from
  * @uses  $CFG
  * @return object State object on error (time limit exceeded) null on success.
  */
 public function run_export($targetstarttime = 0, $writedelay = 0, $lastruntime = 0, $maxruntime = 0, $state = null)
 {
     global $CFG;
     $file = get_plugin_directory('dhexport', 'version1elis') . '/version1elis.class.php';
     require_once $file;
     // Set the log file location to the dataroot.
     $filepath = $CFG->dataroot;
     // Plugin for file IO.
     $fileplugin = new rlipexport_version1elis_fileplugin_memoryexport($writedelay);
     $fileplugin->open(RLIP_FILE_WRITE);
     // Cleanup log files first.
     self::cleanup_log_files();
     // Our specific export.
     $exportplugin = new rlip_exportplugin_version1elis($fileplugin);
     return $exportplugin->run($targetstarttime, $lastruntime, $maxruntime, $state);
 }