105 lines
2.6 KiB
PHP
105 lines
2.6 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This class provides User Account Update functions
|
|
*
|
|
* @package OSB
|
|
* @category Controllers/User
|
|
* @author Deon George
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
* @license http://dev.osbill.net/license.html
|
|
*/
|
|
class Controller_User_Account extends Controller_Account {
|
|
protected $secure_actions = array(
|
|
'edit'=>TRUE,
|
|
'resetpassword'=>TRUE,
|
|
);
|
|
|
|
/**
|
|
* Enable User to Edit their Account Details
|
|
*/
|
|
public function action_edit() {
|
|
// Store our new values
|
|
$this->ao->values($_POST);
|
|
|
|
// Run validation and save
|
|
if ($this->ao->changed())
|
|
if ($this->ao->check()) {
|
|
SystemMessage::add(array(
|
|
'title'=>_('Record updated'),
|
|
'type'=>'info',
|
|
'body'=>_('Your account record has been updated.')
|
|
));
|
|
|
|
$this->ao->save();
|
|
|
|
} else {
|
|
$output = '';
|
|
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
|
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
|
|
|
if ($output)
|
|
$output = sprintf('<ul>%s</ul>',$output);
|
|
|
|
SystemMessage::add(array(
|
|
'title'=>_('Record NOT updated'),
|
|
'type'=>'error',
|
|
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
|
|
));
|
|
}
|
|
|
|
Block::add(array(
|
|
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
|
'body'=>View::factory($this->viewpath())
|
|
->set('record',$this->ao),
|
|
));
|
|
}
|
|
|
|
public function action_resetpassword() {
|
|
// @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
|
|
$this->ao->values($_POST);
|
|
|
|
// Run validation and save
|
|
if ($this->ao->changed())
|
|
if ($this->ao->check()) {
|
|
SystemMessage::add(array(
|
|
'title'=>_('Record updated'),
|
|
'type'=>'info',
|
|
'body'=>_('Your account record has been updated.')
|
|
));
|
|
|
|
$this->ao->save();
|
|
|
|
// Log the password reset
|
|
$this->ao->log('Password reset');
|
|
|
|
HTTP::redirect('login');
|
|
|
|
} else {
|
|
$output = '';
|
|
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
|
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
|
|
|
if ($output)
|
|
$output = sprintf('<ul>%s</ul>',$output);
|
|
|
|
SystemMessage::add(array(
|
|
'title'=>_('Record NOT updated'),
|
|
'type'=>'error',
|
|
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
|
|
));
|
|
}
|
|
|
|
Block::add(array(
|
|
'title'=>_('Password Reset'),
|
|
'body'=>View::factory($this->viewpath())
|
|
->set('record',$this->ao),
|
|
));
|
|
}
|
|
}
|
|
?>
|