diff --git a/application/classes/Config.php b/application/classes/Config.php index 0527e6b5..39318a9e 100644 --- a/application/classes/Config.php +++ b/application/classes/Config.php @@ -65,7 +65,7 @@ class Config extends Kohana_Config { } public static function date($date) { - return is_null($date) ? NULL : date(Company::instance()->date_format(),$date); + return is_null($date) ? ' ' : date(Company::instance()->date_format(),$date); } /** diff --git a/application/classes/Controller/Login.php b/application/classes/Controller/Login.php index b9eb8042..6f037340 100644 --- a/application/classes/Controller/Login.php +++ b/application/classes/Controller/Login.php @@ -40,7 +40,7 @@ class Controller_Login extends lnApp_Controller_Login { // If the username is correct, create a method token if (! empty($_POST['username']) AND ($ao=ORM::factory('Account',array('username'=>$_POST['username']))) AND $ao->loaded()) { $mmto = ORM::factory('Module_Method_Token') - ->method(array('account','user_resetpassword')) + ->method(array('account','user:resetpassword')) ->account($ao) ->uses(2) ->expire(time()+$token_expire*60); diff --git a/application/classes/Controller/TemplateDefault/Affiliate.php b/application/classes/Controller/TemplateDefault/Affiliate.php deleted file mode 100644 index d95e4ad8..00000000 --- a/application/classes/Controller/TemplateDefault/Affiliate.php +++ /dev/null @@ -1,23 +0,0 @@ -'Retire this class extension', - 'type'=>'info', - 'body'=>__METHOD__, - )); - - return parent::after(); - } -} -?> diff --git a/application/classes/Controller/User/Account.php b/application/classes/Controller/User/Account.php index 60b737eb..eec23589 100644 --- a/application/classes/Controller/User/Account.php +++ b/application/classes/Controller/User/Account.php @@ -56,48 +56,73 @@ class Controller_User_Account extends Controller_Account { } 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'] = ' '; + 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($_POST); - - // Run validation and save - if ($this->ao->changed()) - if ($this->ao->check()) { - SystemMessage::factory() - ->title('Record updated') - ->type('success') - ->body(_('Your account record has been updated.')); - - $this->ao->save(); - - // Log the password reset - $this->ao->log('Password reset'); - - HTTP::redirect('login'); - - } else { - // @todo Need to check that this still works with the new bootstrap theming - $output = ''; - - foreach ($this->ao->validation()->errors('forms/login') as $field => $error) - $output .= sprintf('
  • %s %s
  • ',$field,$error); - - if ($output) - $output = sprintf('',$output); + // Store our new values + $this->ao->values($this->request->post()); + if (! $validation->check()) SystemMessage::factory() ->title(_('Record NOT updated')) ->type('error') - ->body(_('Your updates didnt pass validation.').'
    '.$output); - } + ->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'); + } + } + + if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure()) + Script::factory() + ->type('src') + ->data('media/js/jquery/jquery.validate-1.11.1.min.js'); + else + Script::factory() + ->type('src') + ->data('http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js'); + + Script::factory() + ->type('stdin') + ->data(' +$("#reset").validate({ + wrapper: "div", + errorElement: "span", + + rules: { + password_confirm: { + equalTo: "input[name=password]", + }, + }, + highlight: function(element) { + $(element).parents(".control-group").removeClass("success").addClass("error"); + }, + success: function(element) { + $(element).parents(".control-group").removeClass("error").addClass("success"); + }, + errorPlacement: function(error, element) { + error.appendTo(element.parents(".controls")); + } +}); + '); - // @todo To add JS password validation (minimum length and both values equal) Block::factory() ->title(sprintf('Password Reset: %s',$this->ao->accnum())) ->title_icon('icon-cog') + ->id('reset') ->type('form-horizontal') ->body(View::factory('account/user/resetpassword')->set('o',$this->ao)); } diff --git a/application/classes/Model/Affiliate.php b/application/classes/Model/Affiliate.php deleted file mode 100644 index eaf6c0a2..00000000 --- a/application/classes/Model/Affiliate.php +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/application/classes/Model/Auth/UserDefault.php b/application/classes/Model/Auth/UserDefault.php index fdbb11e1..7414250e 100644 --- a/application/classes/Model/Auth/UserDefault.php +++ b/application/classes/Model/Auth/UserDefault.php @@ -17,34 +17,15 @@ class Model_Auth_UserDefault extends Model_Auth_User { array('min_length', array(':value', 4)), array('max_length', array(':value', 32)), ), - 'password' => array( - array('not_empty'), - array('min_length', array(':value', 5)), - array('max_length', array(':value', 32)), - ), 'email' => array( array('not_empty'), array('min_length', array(':value', 4)), array('max_length', array(':value', 127)), array('email'), ), - // @todo To test - 'password_confirm' => array( - array('matches_ifset', array(':validation', 'password', 'password_confirm')), - ), ); } - // Validation callbacks - // @todo _callbacks no longer used - protected $_callbacks = array( - 'username' => array('username_available'), - 'email' => array('email_available'), - ); - - // Columns to ignore - protected $_ignored_columns = array('password_confirm'); - /** * Complete our login * diff --git a/application/classes/Response.php b/application/classes/Response.php deleted file mode 100644 index 731d23b6..00000000 --- a/application/classes/Response.php +++ /dev/null @@ -1,18 +0,0 @@ -_body .= (string) $content; - } -} -?> diff --git a/application/classes/Valid.php b/application/classes/Valid.php deleted file mode 100644 index 66b7392b..00000000 --- a/application/classes/Valid.php +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/modules/affiliate/classes/Model/Affiliate.php b/modules/affiliate/classes/Model/Affiliate.php deleted file mode 100644 index f5924c48..00000000 --- a/modules/affiliate/classes/Model/Affiliate.php +++ /dev/null @@ -1,18 +0,0 @@ -array('far_key'=>'affiliate_id','foreign_key'=>'id'), - ); -} -?> diff --git a/modules/service/classes/Model/Service.php b/modules/service/classes/Model/Service.php index 9b26fdf1..c2ae6822 100644 --- a/modules/service/classes/Model/Service.php +++ b/modules/service/classes/Model/Service.php @@ -90,7 +90,7 @@ class Model_Service extends ORM_OSB { $expire = (is_null($plugin=$this->plugin()) ? NULL : $plugin->expire()); // If $expire is NULL, we'll use the next invoice date - $expire = is_null($expire) ? $this->date_next_invoice-86400 : $expire; + $expire = is_null($expire) ? $this->paid_to() : $expire; return $format ? Config::date($expire) : $expire; } @@ -128,6 +128,15 @@ class Model_Service extends ORM_OSB { return $result; } + /** + * Show the date we are invoiced to + */ + public function invoiced_to($format=FALSE) { + $x = $this->invoice_item->order_by('date_stop','DESC')->limit(1)->find(); + + return $format ? $x->display('date_stop') : $x->date_stop; + } + /** * Display the service product name */ @@ -136,7 +145,22 @@ class Model_Service extends ORM_OSB { } /** - * Returns TRUE of this service has a planend change + * Returns the date that an item has been paid to + */ + public function paid_to($format=FALSE) { + $x = NULL; + + foreach ($this->invoice_item->order_by('date_stop','DESC')->order_by('date_orig','DESC')->find_all() as $iio) + if ($iio->invoice->due() == 0) { + $x = $iio; + break; + } + + return $format ? ($x ? $x->display('date_stop') : ' ') : ($x ? $x->date_stop : NULL); + } + + /** + * Returns TRUE of this service has a planned change */ public function pending_change() { return $this->service_change()->loaded() ? TRUE : FALSE; @@ -219,18 +243,13 @@ class Model_Service extends ORM_OSB { return $this->invoice_item->order_by('date_start,date_stop'); } - // @todo To implement - public function charges_new() { - return $this->charges(); - } - /** LIST FUNCTIONS **/ /** * Search for services matching a term */ public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) { - // We only show invoice numbers. + // We only show service numbers. if (! is_numeric($term)) return array(); diff --git a/modules/service/views/service/user/view.php b/modules/service/views/service/user/view.php index c3464ed6..6477ada4 100644 --- a/modules/service/views/service/user/view.php +++ b/modules/service/views/service/user/view.php @@ -21,6 +21,12 @@
    product_id,$o->product->title()); ?>
    +
    Invoiced To
    +
    invoiced_to(TRUE); ?>
    + +
    Paid To
    +
    paid_to(TRUE); ?>
    +
    Date Next Invoice
    display('date_next_invoice'); ?>
    diff --git a/modules/ssl/classes/Task/Ssl/Renew.php b/modules/ssl/classes/Task/Ssl/Renew.php index a4ea122a..cc90c4f1 100644 --- a/modules/ssl/classes/Task/Ssl/Renew.php +++ b/modules/ssl/classes/Task/Ssl/Renew.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Task_SSL_Renew extends Task { +class Task_SSL_Renew extends Minion_Task { /** * Renew a certificate */