diff --git a/class/upload_token.class.php b/class/upload_token.class.php index 57bffba..8bb2c2e 100644 --- a/class/upload_token.class.php +++ b/class/upload_token.class.php @@ -25,10 +25,15 @@ class BerichtUploadToken /** * Erstellt einen neuen Token für einen Bericht. + * Räumt dabei abgelaufene Tokens gleich mit auf (kein Cronjob nötig). * @return string|false Hex-Token bei Erfolg */ public function create($fk_bericht, $fk_user, $lifetime = null, $max_uploads = null) { + // Opportunistisches Cleanup: entferne abgelaufene Tokens bei jedem Insert + $this->db->query("DELETE FROM ".$this->db->prefix()."bericht_upload_token" + ." WHERE expires_at < '".$this->db->idate(dol_now())."'", 1); + $this->token = bin2hex(random_bytes(32)); $this->fk_bericht = (int) $fk_bericht; $this->fk_user_creat = (int) $fk_user; diff --git a/core/modules/modBericht.class.php b/core/modules/modBericht.class.php index 8f88cfc..76f398a 100644 --- a/core/modules/modBericht.class.php +++ b/core/modules/modBericht.class.php @@ -89,23 +89,9 @@ class modBericht extends DolibarrModules $this->dictionaries = array(); $this->boxes = array(); - // Cleanup expired Mobile-Upload-Tokens (täglich um 03:30) - $this->cronjobs = array( - 0 => array( - 'label' => 'Bericht: Expired Upload-Tokens bereinigen', - 'jobtype' => 'method', - 'class' => '/bericht/class/upload_token.class.php', - 'objectname' => 'BerichtUploadToken', - 'method' => 'cleanupExpired', - 'parameters' => '', - 'comment' => 'Löscht abgelaufene Mobile-Upload-Tokens aus llx_bericht_upload_token', - 'frequency' => 1, - 'unitfrequency' => 86400, - 'status' => 1, - 'test' => 'isModEnabled("bericht")', - 'priority' => 50, - ), - ); + // Kein Cronjob — Cleanup expired Upload-Tokens passiert on-demand + // beim Anlegen eines neuen Tokens (siehe BerichtUploadToken::create()). + $this->cronjobs = array(); // Rechte — wie Stundenzettel: [4]=perms, [5]=subperms (leer) $this->rights = array();