summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-07-12 14:30:36 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-07-12 14:30:36 +0200
commit9455292feec751d799d93b1c2b790ea47e9f6f52 (patch)
tree5211ac47801a8c47b474f706f9c6b26fec1a3d89
parent1eb6508517a670667c8d69b1fe3d6a6beaab7451 (diff)
Add cron function for user controller
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xapplication/config/example/config.php1
-rw-r--r--application/controllers/user.php14
2 files changed, 15 insertions, 0 deletions
diff --git a/application/config/example/config.php b/application/config/example/config.php
index bd9ec40aa..000af65fc 100755
--- a/application/config/example/config.php
+++ b/application/config/example/config.php
@@ -375,6 +375,7 @@ $config['upload_max_text_size'] = 2*1024*1024;
// 0 disables deletion
$config['upload_max_age'] = 60*60*24*5; // 5 days
+$config['invitations_max_age'] = 60*60*24*5; // 5 days
// won't be deleted
$config['small_upload_size'] = 1024*10; // 10KB
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));
+ }
}