From 9455292feec751d799d93b1c2b790ea47e9f6f52 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 12 Jul 2012 14:30:36 +0200 Subject: Add cron function for user controller Signed-off-by: Florian Pritz --- application/controllers/user.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'application/controllers') diff --git a/application/controllers/user.php b/application/controllers/user.php index 3b6570a91..add6e8bdc 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -216,4 +216,18 @@ class User extends CI_Controller { $this->load->view($this->var->view_dir.'hash_password', $this->data); $this->load->view($this->var->view_dir.'footer', $this->data); } + + function cron() + { + if (!$this->input->is_cli_request()) return; + + if ($this->config->item('invitations_max_age') == 0) return; + + $oldest_time = (time() - $this->config->item('invitations_max_age')); + + $this->db->query(" + DELETE FROM invitations + WHERE date < ? + ", array($oldest_time)); + } } -- cgit v1.2.3-24-g4f1b