General tidying up
This commit is contained in:
@@ -10,40 +10,35 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Account extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
class Controller_User_Account extends Controller_TemplateDefault_User {
|
||||
protected $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'resetpassword'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_resetpassword() {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$ao->id));
|
||||
|
||||
// @todo Fix this next logic, since matches_ifset is not being called when the value is on the form, but empty
|
||||
if (empty($_POST['password_confirm']))
|
||||
$_POST['password_confirm'] = ' ';
|
||||
|
||||
// Store our new values
|
||||
$ao->values($_POST);
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($ao->changed())
|
||||
if ($ao->check()) {
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record updated'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Your account record has been updated.')
|
||||
));
|
||||
|
||||
$ao->save();
|
||||
$this->ao->save();
|
||||
Request::current()->redirect('login');
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
foreach ($ao->validation()->errors('forms/login') as $field => $error)
|
||||
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
||||
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||
|
||||
if ($output)
|
||||
@@ -59,7 +54,7 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
||||
Block::add(array(
|
||||
'title'=>_('Password Reset'),
|
||||
'body'=>View::factory('account/password_reset')
|
||||
->set('record',$ao),
|
||||
->set('record',$this->ao),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -67,28 +62,23 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
||||
* Show a product
|
||||
*/
|
||||
public function action_edit() {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$ao->id));
|
||||
|
||||
// Store our new values
|
||||
$ao->values($_POST);
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($ao->changed())
|
||||
if ($ao->check()) {
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record updated'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Your account record has been updated.')
|
||||
));
|
||||
|
||||
$ao->save();
|
||||
$this->ao->save();
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
foreach ($ao->validation()->errors('forms/login') as $field => $error)
|
||||
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
||||
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||
|
||||
if ($output)
|
||||
@@ -102,9 +92,9 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$ao->accnum(),$ao->name(TRUE)),
|
||||
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory('account/edit')
|
||||
->set('record',$ao),
|
||||
->set('record',$this->ao),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user