Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Reset_Controller extends App_Controller {
- public function index() {
- echo "<p>Are you sure you want to reset the configuration?</p>";
- echo "<p>This will delete all companies, all users, all items and restore the admin user's default password to 'admin/admin'</p>";
- echo html::anchor('reset/reset', 'Yes I am sure! Just reset the program!');
- }
- public function reset () {
- ORM::factory('company')->delete_all();
- ORM::factory('user')->delete_all();
- ORM::factory('item')->delete_all();
- $this->company = ORM::factory('company');
- $this->company->name = 'admin';
- $this->company->save();
- $this->user = ORM::factory('user');
- $this->user->username = "admin";
- $this->user->email = "admin@localhost";
- $this->user->password = "admin";
- $this->user->company_id = $this->company->id;
- $this->user->add(ORM::factory('role', array('name' => 'admin')));
- $this->user->add(ORM::factory('role', array('name' => 'login')));
- $this->user->save();
- echo html::anchor('/', 'Return Home');
- }
- public function __construct() {
- parent::__construct();
- $this->template->content = 'Reset Configuration';
- $this->template->title = 'Reset Configuration';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement