Added cron-manager-entry

This commit is contained in:
int2001
2025-09-03 13:20:36 +00:00
parent df68d5d7c7
commit 5ae66fbb5c
3 changed files with 48 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 253;
$config['migration_version'] = 254;
/*
|--------------------------------------------------------------------------

View File

@@ -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

View File

@@ -0,0 +1,43 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_dcl_cron extends CI_Migration {
public function up() {
if ($this->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());
}
}
}