diff --git a/application/config/migration.php b/application/config/migration.php index 3cf48e933..6fd06b52e 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 253; +$config['migration_version'] = 254; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Dcl.php b/application/controllers/Dcl.php index a3462e8de..6076d2264 100644 --- a/application/controllers/Dcl.php +++ b/application/controllers/Dcl.php @@ -76,6 +76,10 @@ class Dcl extends CI_Controller { $this->load->view('interface_assets/footer'); } + public function dcl_sync() { + $this->dcl_upload(); + } + public function dcl_upload() { // Called as User: Upload for User (if manual sync isn't disabled // Called from cron / without Session: iterate through stations, check for DCL-Key and upload diff --git a/application/migrations/254_dcl_cron.php b/application/migrations/254_dcl_cron.php new file mode 100644 index 000000000..8fc0f053a --- /dev/null +++ b/application/migrations/254_dcl_cron.php @@ -0,0 +1,43 @@ +chk4cron('sync_dcl') == 0) { + $data = array( + array( + 'id' => 'sync_dcl', + 'enabled' => '0', + 'status' => 'disabled', + 'description' => 'Sync with DARC-DCL', + 'function' => 'index.php/dcl/dcl_sync', + 'expression' => '45 4 * * *', + 'last_run' => null, + 'next_run' => null + )); + $this->db->insert_batch('cron', $data); + } + + } + + public function down() { + if ($this->chk4cron('sync_dcl') > 0) { + $this->db->query("delete from cron where id='sync_dcl'"); + } + // No way back to tle-table + } + + function chk4cron($cronkey) { + $query = $this->db->query("select count(id) as cid from cron where id=?",$cronkey); + $row = $query->row(); + return $row->cid ?? 0; + } + + function dbtry($what) { + try { + $this->db->query($what); + } catch (Exception $e) { + log_message("error", "Something gone wrong while altering FKs: ".$e." // Executing: ".$this->db->last_query()); + } + } +}