604c07fe53ddc1e82d7d2f18a72f5abb76bc47ce
[living-lab-site.git] / application / controllers / admin_cli.php
1 <?php
2
3 /**
4  * Class Admin_cli controls site administration features
5  *
6  * @category    Controller
7  * @author              Călin-Andrei Burloiu
8  */
9 class Admin_cli extends CI_Controller {
10         
11         public function __construct()
12         {
13                 parent::__construct();
14                 
15                 if (!$this->input->is_cli_request())
16                 {
17                         die("This controller is allowed only from CLI!");
18                 }
19         }
20         
21         public function index()
22         {               
23         }
24         
25         /**
26          * Removes users that didn't activated their account within
27          * $days_to_expire days inclusively.
28          * 
29          * @param int $days_to_expire 
30          */
31         public function cleanup_unactivated_users($days_to_expire = 2)
32         {
33                 $days_to_expire = intval($days_to_expire);
34                 
35                 $this->load->model('users_model');
36                 
37                 if ($this->users_model->cleanup_unactivated_users($days_to_expire))
38                         echo "Users unactivated within $days_to_expire days were successfully deleted from the database.".PHP_EOL;
39                 else
40                         echo "No users were deleted.".PHP_EOL;
41         }
42 }
43
44 /* End of file admin_cli.php */
45 /* Location: ./application/controllers/admin_cli.php */