Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') OR die('No direct access allowed.');
- class Register_Controller extends Authenticate_Controller {
- public $template = 'shared/template';
- public $auto_render = TRUE;
- public function __construct()
- {
- parent::__construct();
- $this->template->title = 'Register';
- if (!$this->authentic->logged_in('admin'))
- {
- url::redirect('dashboard');
- }
- }
- public function index()
- {
- $this->template->title .= template::append_title('Register User');
- $this->template->content = new View('account/register/index');
- if($this->input->post())
- {
- $this->perform_register();
- }
- }
- private function perform_register()
- {
- $user = ORM::factory('user');
- $photo = $this->handle_photo();
- $user->username = $this->input->post('username');
- $user->password = $this->input->post('password');
- $user->email = $this->input->post('email');
- $user->title = $this->input->post('title');
- $user->first_name = $this->input->post('first_name');
- $user->last_name = $this->input->post('last_name');
- $user->twitter = $this->input->post('twitter');
- $user->phone = $this->input->post('phone');
- $user->email = $this->input->post('email');
- if ($user->add(ORM::factory('role', 'login')) AND $user->add(ORM::factory('user_photo' , $photo)) AND $user->save())
- {
- url::redirect('account/dashboard');
- }
- }
- private function handle_photo()
- {
- $files = Validation::factory($_FILES)->add_rules('picture', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[1M]');
- if ($files->validate())
- {
- $filename = upload::save('picture');
- Image::factory($filename)
- ->resize(144, 196, Image::WIDTH)
- ->save(DOCROOT.'images/team/'.basename($filename));
- // Save Into Database
- $image = ORM::factory('user_photo');
- $image->primary = 1;
- $image->name = basename($filename);
- $image->save();
- unlink($filename);
- return $image;
- }
- }
- }
Add Comment
Please, Sign In to add comment