Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.45 KB | None | 0 0
  1. <?php
  2.  
  3. class Reset_Controller extends App_Controller {
  4.  
  5.    
  6.         public function index() {
  7.             echo "<p>Are you sure you want to reset the configuration?</p>";
  8.             echo "<p>This will delete all companies, all users, all items and restore the admin user's default password to 'admin/admin'</p>";
  9.  
  10.             echo html::anchor('reset/reset', 'Yes I am sure! Just reset the program!');
  11.         }
  12.  
  13.         public function reset () {
  14.             ORM::factory('company')->delete_all();
  15.             ORM::factory('user')->delete_all();
  16.             ORM::factory('item')->delete_all();
  17.  
  18.             $this->company = ORM::factory('company');
  19.             $this->company->name = 'admin';
  20.             $this->company->save();
  21.  
  22.             $this->user = ORM::factory('user');
  23.             $this->user->username = "admin";
  24.             $this->user->email = "admin@localhost";
  25.             $this->user->password = "admin";
  26.             $this->user->company_id = $this->company->id;
  27.             $this->user->add(ORM::factory('role', array('name' => 'admin')));
  28.             $this->user->add(ORM::factory('role', array('name' => 'login')));
  29.             $this->user->save();
  30.  
  31.             echo html::anchor('/', 'Return Home');
  32.         }
  33.  
  34.         public function  __construct() {
  35.             parent::__construct();
  36.             $this->template->content = 'Reset Configuration';
  37.             $this->template->title = 'Reset Configuration';
  38.         }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement