This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
lnapp/classes/lnApp/Controller/User/Account.php

74 lines
2.0 KiB
PHP
Raw Normal View History

2014-10-02 05:33:07 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User Account Update functions
*
* @package lnApp
* @category Controllers/User
* @author Deon George
* @copyright (c) 2009-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class lnApp_Controller_User_Account extends Controller_Account {
2014-10-10 05:35:02 +00:00
protected $auth_required = TRUE;
2014-10-02 05:33:07 +00:00
protected $secure_actions = array(
'edit'=>TRUE,
'resetpassword'=>TRUE,
2014-10-02 05:33:07 +00:00
);
/**
* Enable User to Edit their Account Details
*/
public function action_edit() {
2016-08-03 05:56:14 +00:00
if ($this->request->post() AND $this->ao->values($this->request->post())->changed() AND (! $this->save($this->ao)))
2014-10-02 05:33:07 +00:00
$this->ao->reload();
Block::factory()
->title(sprintf('Account: %s',$this->ao->refnum()))
2014-10-02 05:33:07 +00:00
->title_icon('fa-wrench')
->type('form-horizontal')
->body(View::factory('account/user/edit')->set('o',$this->ao));
}
public function action_resetpassword() {
if ($this->request->post()) {
$validation = Validation::factory($this->request->post())
->rule('password','not_empty')
->rule('password','min_length',array(':value',6))
->rule('password_confirm','matches',array(':validation',':field','password'));
// Store our new values
$this->ao->values($this->request->post());
if (! $validation->check())
SystemMessage::factory()
->title(_('Record NOT updated'))
->type('error')
->body(_('Your password didnt pass validation.'));
// Run validation and save
elseif ($this->ao->changed())
if ($this->ao->save()) {
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your account record has been updated.'));
// Log the password reset
$this->ao->log('Password reset');
HTTP::redirect('login');
2014-10-02 05:33:07 +00:00
}
}
Block::factory()
->title(sprintf('Password Reset: %s',$this->ao->refnum()))
2014-10-02 05:33:07 +00:00
->title_icon('fa-cog')
->id('reset')
->type('form-horizontal')
->body(View::factory('account/user/resetpassword')->set('o',$this->ao));
}
}
?>