From d9c3394b0f95b566f161e58344697ec36a356546 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 22 Feb 2012 19:15:46 +1100 Subject: [PATCH] Many misc fixes --- application/classes/auth/osb.php | 2 +- application/classes/lnapp/config.php | 2 +- application/classes/lnapp/controller/login.php | 6 +++--- application/classes/model/module/method/token.php | 1 + application/views/login_reset.php | 4 ++-- modules/adsl/classes/model/adsl/supplier.php | 7 +++++++ modules/adsl/classes/service/traffic/adsl.php | 9 +++++++++ .../classes/service/traffic/adsl/exetelhspa.php | 3 +++ modules/invoice/classes/model/invoice.php | 2 +- .../service/classes/controller/admin/service.php | 1 + .../service/classes/controller/task/service.php | 6 +++++- modules/service/classes/model/service.php | 5 +++++ modules/ssl/classes/model/service/plugin/ssl.php | 15 +++++++-------- modules/ssl/config/ssl.php | 2 +- 14 files changed, 47 insertions(+), 18 deletions(-) diff --git a/application/classes/auth/osb.php b/application/classes/auth/osb.php index 349dd784..78436096 100644 --- a/application/classes/auth/osb.php +++ b/application/classes/auth/osb.php @@ -222,7 +222,7 @@ class Auth_OSB extends Auth_ORM { // Load the user $user = ORM::factory('account'); - $user->where($user->unique_key($username), '=', $username)->find(); + $user->where('username','=',$username)->find(); } // If the passwords match, perform a login diff --git a/application/classes/lnapp/config.php b/application/classes/lnapp/config.php index 4edc13cb..c3e46550 100644 --- a/application/classes/lnapp/config.php +++ b/application/classes/lnapp/config.php @@ -88,7 +88,7 @@ abstract class lnApp_Config extends Kohana_Config { } public static function login_uri() { - return ($ao = Auth::instance()->get_user()) ? HTML::anchor('user/account/edit',$ao->name()) : HTML::anchor('login',_('Login')); + return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor('user/account/edit',$ao->name()) : HTML::anchor('login',_('Login')); } /** diff --git a/application/classes/lnapp/controller/login.php b/application/classes/lnapp/controller/login.php index dc95d958..edf22de2 100644 --- a/application/classes/lnapp/controller/login.php +++ b/application/classes/lnapp/controller/login.php @@ -130,8 +130,8 @@ class lnApp_Controller_Login extends Controller_TemplateDefault { // If the user posted their details to reset their password if ($_POST) { - // If the email address is correct, create a method token - if (! empty($_POST['email']) AND ($ao=ORM::factory('account',array('email'=>$_POST['email']))) AND $ao->loaded()) { + // 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')) ->account($ao) @@ -164,7 +164,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault { } // Show our token screen even if the email was invalid. - if (isset($_POST['email'])) + if (isset($_POST['username'])) Block::add(array( 'title'=>_('Reset your password'), 'body'=>View::factory('login_reset_sent'), diff --git a/application/classes/model/module/method/token.php b/application/classes/model/module/method/token.php index bb3dee73..a5f747b9 100644 --- a/application/classes/model/module/method/token.php +++ b/application/classes/model/module/method/token.php @@ -82,6 +82,7 @@ class Model_Module_Method_Token extends ORMOSB { return $this; } + // @todo Login Reset: When called within a timelimit (so existing token already exists), is returning true but password reset emails have blanks where the tokens are public function generate() { if (! $this->account_id OR ! $this->method_id OR ! ($this->date_expire OR $this->uses)) return NULL; diff --git a/application/views/login_reset.php b/application/views/login_reset.php index 465963f7..38a14819 100644 --- a/application/views/login_reset.php +++ b/application/views/login_reset.php @@ -5,8 +5,8 @@ - - + +
Email Address
'login-uid','size'=>40));?>
Username
'login-uid','size'=>40));?>
'form_button'));?>
diff --git a/modules/adsl/classes/model/adsl/supplier.php b/modules/adsl/classes/model/adsl/supplier.php index aa00cdca..a9782fad 100644 --- a/modules/adsl/classes/model/adsl/supplier.php +++ b/modules/adsl/classes/model/adsl/supplier.php @@ -60,6 +60,13 @@ class Model_ADSL_Supplier extends ORMOSB { if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans)) array_push($services,$so); + // @todo poor cludge, we should find them without using list_bylistgroup() + if (! $services) + foreach (ORM::factory('service')->list_bylistgroup('HSPA') as $so) + if (! $active OR $so->active) + if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans)) + array_push($services,$so); + return $services; } diff --git a/modules/adsl/classes/service/traffic/adsl.php b/modules/adsl/classes/service/traffic/adsl.php index c4c4bdf8..e810cf0e 100644 --- a/modules/adsl/classes/service/traffic/adsl.php +++ b/modules/adsl/classes/service/traffic/adsl.php @@ -70,11 +70,17 @@ class Service_Traffic_ADSL { * Traffic data from supplier */ public function update_traffic() { + if (CLI::options('verbose')) + echo ' - Last: '.date('Y-m-d',strtotime($this->last_update().'+1 day'))."\n"; + $alreadyrun = FALSE; for ($querydate=date('Y-m-d',strtotime($this->last_update().'+1 day')); $querydate<=$this->today; $querydate=date('Y-m-d',strtotime($querydate.'+1 day'))) { + if (CLI::options('verbose')) + echo " - Date: $querydate\n"; + $goodfetch = false; // @todo log this fetch in a "log" @@ -82,6 +88,9 @@ class Service_Traffic_ADSL { // Data returned should be in MB's $data = $this->getdata($querydate); + if (CLI::options('verbose')) + print_r($data); + if (! $this->fetchresult) { echo 'Bad fetch'.get_class($this); break; diff --git a/modules/adsl/classes/service/traffic/adsl/exetelhspa.php b/modules/adsl/classes/service/traffic/adsl/exetelhspa.php index 51ceb452..ca196fe7 100644 --- a/modules/adsl/classes/service/traffic/adsl/exetelhspa.php +++ b/modules/adsl/classes/service/traffic/adsl/exetelhspa.php @@ -39,6 +39,9 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { $update = array(); foreach ($this->so->services() as $so) { + if (CLI::options('verbose')) + echo " = Service: ".$so->name()."\n"; + if ($so->plugin()->service_stats_collect AND $so->plugin()->service_stats_lastupdate < $date) { // Start Session $request = Request::factory($this->so->stats_url) diff --git a/modules/invoice/classes/model/invoice.php b/modules/invoice/classes/model/invoice.php index 26dc2ad0..9d23bfab 100644 --- a/modules/invoice/classes/model/invoice.php +++ b/modules/invoice/classes/model/invoice.php @@ -370,7 +370,7 @@ class Model_Invoice extends ORMOSB { } public function min_due($date) { - return ($date < time()) ? time()+ORM::factory('invoice')->config('DUE_DAYS_MIN')*86400 : $date; + return strtotime(date('Y-M-d',($date < time()) ? time()+ORM::factory('invoice')->config('DUE_DAYS_MIN')*86400 : $date)); } public function save(Validation $validation = NULL) { diff --git a/modules/service/classes/controller/admin/service.php b/modules/service/classes/controller/admin/service.php index 5b38faff..b31a7140 100644 --- a/modules/service/classes/controller/admin/service.php +++ b/modules/service/classes/controller/admin/service.php @@ -534,6 +534,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { 'recur_schedule'=>array('label'=>'Billing'), 'date_next_invoice'=>array('label'=>'Next Invoice'), 'price'=>array('label'=>'Price','class'=>'right'), + 'charges_new()'=>array('label'=>'Charges','class'=>'right'), 'active'=>array('label'=>'Active'), 'account->accnum()'=>array('label'=>'Cust ID'), 'account->name()'=>array('label'=>'Customer'), diff --git a/modules/service/classes/controller/task/service.php b/modules/service/classes/controller/task/service.php index dc327850..dcab14f9 100644 --- a/modules/service/classes/controller/task/service.php +++ b/modules/service/classes/controller/task/service.php @@ -21,8 +21,12 @@ class Controller_Task_Service extends Controller_Task { * List all services by their default checkout method */ public function action_gettraffic() { - foreach ($this->_traffic_suppliers(TRUE) as $aso) + foreach ($this->_traffic_suppliers(TRUE) as $aso) { + if (CLI::options('verbose')) + echo $aso->name."\n"; + $traffic = Service_Traffic_ADSL::instance($aso->name)->update_traffic(); + } } /** diff --git a/modules/service/classes/model/service.php b/modules/service/classes/model/service.php index 3514d3e7..d73c0785 100644 --- a/modules/service/classes/model/service.php +++ b/modules/service/classes/model/service.php @@ -123,6 +123,11 @@ class Model_Service extends ORMOSB { return $this->invoice_item->order_by('date_start,date_stop')->find_all(); } + // @todo To implement + public function charges_new() { + return 0; + } + /** LIST FUNCTIONS **/ private function _list_active() { diff --git a/modules/ssl/classes/model/service/plugin/ssl.php b/modules/ssl/classes/model/service/plugin/ssl.php index 637f5957..53faadf8 100644 --- a/modules/ssl/classes/model/service/plugin/ssl.php +++ b/modules/ssl/classes/model/service/plugin/ssl.php @@ -80,10 +80,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { public function _details($type) { switch ($type) { case 'invoice_detail_items': - return array( - _('Service Address')=>$this->service_address ? $this->display('service_address') : '>NotSet<', - _('Contract Until')=>$this->contract_date_end(), - ); + return array(); break; default: return parent::$_details($type); @@ -125,17 +122,19 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { public function renew() { $d = SSL::details($this->cert); $ssl_conf = Kohana::config('ssl'); + // @todo change this so an admin can force this. + $force = TRUE; // If our certificate is not old enough skip - if ($d['validTo_time_t'] > time()+$ssl_conf['min_renew_days']*86400) + if ($d['validTo_time_t'] > time()+$ssl_conf['min_renew_days']*86400 AND ! $force) return FALSE; - $res = openssl_csr_sign($this->csr,$this->ssl_ca->sign_cert,$this->ssl_ca->sign_pk,$this->ssl->days,array( + $res = openssl_csr_sign($this->csr,$this->ssl_ca->sign_cert,$this->ssl_ca->sign_pk,$this->service->product->plugin()->days,array( 'config'=>$ssl_conf['config'], - 'x509_extensions'=>$this->ssl->extensions, + 'x509_extensions'=>$this->service->product->plugin()->extensions, ),time()); - if (openssl_x509_export($res,$cert)) { + if ($res AND openssl_x509_export($res,$cert)) { $this->cert = $cert; $this->save(); diff --git a/modules/ssl/config/ssl.php b/modules/ssl/config/ssl.php index 7df8df05..4083b4a1 100644 --- a/modules/ssl/config/ssl.php +++ b/modules/ssl/config/ssl.php @@ -18,6 +18,6 @@ return array( 'minpass_length' => 4, // Location to openssl config - 'config' => 'appliation/config/openssl.cnf', + 'config' => 'application/config/openssl.cnf', ); ?>