Skip to content

Commit

Permalink
Introduce a reset_email function in Hooks #35
Browse files Browse the repository at this point in the history
This reset_email function truncates the email_batch table. This is purely for testing purposes and should be removed before go live
  • Loading branch information
MathieuNls committed Feb 3, 2016
1 parent 68198c1 commit b6c23fe
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions application/controllers/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,24 @@ public function email($key, $time = 0){
if ($key === "bPiAi9XNEa3p9FF1lQnZfuUY") {

$this->load->library("auto_email");
$this->auto_email->cronCheck(60*60*$time);
}
}

public function reset_email($key){

//FIXME: The token has to be env value
if ($key === "bPiAi9XNEa3p9FF1lQnZfuUY") {

$emailBatch = new MY_MODEL("email_batch");
$emailBatch->truncate();
$emailBatch->insert(array("time"=>time(), "amount"=>0));


$date = new DateTime("@".time());

echo "<h1> Reset success. New last batch at " . $date->format('Y-m-d H:i:s') . "</h1>";

if($time == 0){
$this->auto_email->cronCheck(time());
}else{
$this->auto_email->cronCheck(time()+60*60*$time);
}
}
}
}

0 comments on commit b6c23fe

Please sign in to comment.