Many misc fixes

This commit is contained in:
Deon George 2012-02-22 19:15:46 +11:00
parent f0f6479ca2
commit d9c3394b0f
14 changed files with 47 additions and 18 deletions

View File

@ -222,7 +222,7 @@ class Auth_OSB extends Auth_ORM {
// Load the user // Load the user
$user = ORM::factory('account'); $user = ORM::factory('account');
$user->where($user->unique_key($username), '=', $username)->find(); $user->where('username','=',$username)->find();
} }
// If the passwords match, perform a login // If the passwords match, perform a login

View File

@ -88,7 +88,7 @@ abstract class lnApp_Config extends Kohana_Config {
} }
public static function login_uri() { 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'));
} }
/** /**

View File

@ -130,8 +130,8 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
// If the user posted their details to reset their password // If the user posted their details to reset their password
if ($_POST) { if ($_POST) {
// If the email address is correct, create a method token // If the username is correct, create a method token
if (! empty($_POST['email']) AND ($ao=ORM::factory('account',array('email'=>$_POST['email']))) AND $ao->loaded()) { if (! empty($_POST['username']) AND ($ao=ORM::factory('account',array('username'=>$_POST['username']))) AND $ao->loaded()) {
$mmto = ORM::factory('module_method_token') $mmto = ORM::factory('module_method_token')
->method(array('account','user_resetpassword')) ->method(array('account','user_resetpassword'))
->account($ao) ->account($ao)
@ -164,7 +164,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
} }
// Show our token screen even if the email was invalid. // Show our token screen even if the email was invalid.
if (isset($_POST['email'])) if (isset($_POST['username']))
Block::add(array( Block::add(array(
'title'=>_('Reset your password'), 'title'=>_('Reset your password'),
'body'=>View::factory('login_reset_sent'), 'body'=>View::factory('login_reset_sent'),

View File

@ -82,6 +82,7 @@ class Model_Module_Method_Token extends ORMOSB {
return $this; 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() { public function generate() {
if (! $this->account_id OR ! $this->method_id OR ! ($this->date_expire OR $this->uses)) if (! $this->account_id OR ! $this->method_id OR ! ($this->date_expire OR $this->uses))
return NULL; return NULL;

View File

@ -5,8 +5,8 @@
<?php echo Form::open(); ?> <?php echo Form::open(); ?>
<table class="login"> <table class="login">
<tr><td><b>Email Address</b></td></tr> <tr><td><b>Username</b></td></tr>
<tr><td><?php echo Form::input('email',null,array('id'=>'login-uid','size'=>40));?></td></tr> <tr><td><?php echo Form::input('username',null,array('id'=>'login-uid','size'=>40));?></td></tr>
<tr><td colspan="2" style="text-align: center;"><?php echo Form::submit('submit',_('Reset'),array('class'=>'form_button'));?></td></tr> <tr><td colspan="2" style="text-align: center;"><?php echo Form::submit('submit',_('Reset'),array('class'=>'form_button'));?></td></tr>
</table> </table>
<?php echo Form::close(); ?> <?php echo Form::close(); ?>

View File

@ -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)) if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so); 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; return $services;
} }

View File

@ -70,11 +70,17 @@ class Service_Traffic_ADSL {
* Traffic data from supplier * Traffic data from supplier
*/ */
public function update_traffic() { public function update_traffic() {
if (CLI::options('verbose'))
echo ' - Last: '.date('Y-m-d',strtotime($this->last_update().'+1 day'))."\n";
$alreadyrun = FALSE; $alreadyrun = FALSE;
for ($querydate=date('Y-m-d',strtotime($this->last_update().'+1 day')); for ($querydate=date('Y-m-d',strtotime($this->last_update().'+1 day'));
$querydate<=$this->today; $querydate<=$this->today;
$querydate=date('Y-m-d',strtotime($querydate.'+1 day'))) { $querydate=date('Y-m-d',strtotime($querydate.'+1 day'))) {
if (CLI::options('verbose'))
echo " - Date: $querydate\n";
$goodfetch = false; $goodfetch = false;
// @todo log this fetch in a "log" // @todo log this fetch in a "log"
@ -82,6 +88,9 @@ class Service_Traffic_ADSL {
// Data returned should be in MB's // Data returned should be in MB's
$data = $this->getdata($querydate); $data = $this->getdata($querydate);
if (CLI::options('verbose'))
print_r($data);
if (! $this->fetchresult) { if (! $this->fetchresult) {
echo 'Bad fetch'.get_class($this); echo 'Bad fetch'.get_class($this);
break; break;

View File

@ -39,6 +39,9 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
$update = array(); $update = array();
foreach ($this->so->services() as $so) { 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) { if ($so->plugin()->service_stats_collect AND $so->plugin()->service_stats_lastupdate < $date) {
// Start Session // Start Session
$request = Request::factory($this->so->stats_url) $request = Request::factory($this->so->stats_url)

View File

@ -370,7 +370,7 @@ class Model_Invoice extends ORMOSB {
} }
public function min_due($date) { 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) { public function save(Validation $validation = NULL) {

View File

@ -534,6 +534,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'recur_schedule'=>array('label'=>'Billing'), 'recur_schedule'=>array('label'=>'Billing'),
'date_next_invoice'=>array('label'=>'Next Invoice'), 'date_next_invoice'=>array('label'=>'Next Invoice'),
'price'=>array('label'=>'Price','class'=>'right'), 'price'=>array('label'=>'Price','class'=>'right'),
'charges_new()'=>array('label'=>'Charges','class'=>'right'),
'active'=>array('label'=>'Active'), 'active'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'), 'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'), 'account->name()'=>array('label'=>'Customer'),

View File

@ -21,8 +21,12 @@ class Controller_Task_Service extends Controller_Task {
* List all services by their default checkout method * List all services by their default checkout method
*/ */
public function action_gettraffic() { 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(); $traffic = Service_Traffic_ADSL::instance($aso->name)->update_traffic();
}
} }
/** /**

View File

@ -123,6 +123,11 @@ class Model_Service extends ORMOSB {
return $this->invoice_item->order_by('date_start,date_stop')->find_all(); return $this->invoice_item->order_by('date_start,date_stop')->find_all();
} }
// @todo To implement
public function charges_new() {
return 0;
}
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
private function _list_active() { private function _list_active() {

View File

@ -80,10 +80,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
public function _details($type) { public function _details($type) {
switch ($type) { switch ($type) {
case 'invoice_detail_items': case 'invoice_detail_items':
return array( return array();
_('Service Address')=>$this->service_address ? $this->display('service_address') : '>NotSet<',
_('Contract Until')=>$this->contract_date_end(),
);
break; break;
default: default:
return parent::$_details($type); return parent::$_details($type);
@ -125,17 +122,19 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
public function renew() { public function renew() {
$d = SSL::details($this->cert); $d = SSL::details($this->cert);
$ssl_conf = Kohana::config('ssl'); $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 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; 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'], 'config'=>$ssl_conf['config'],
'x509_extensions'=>$this->ssl->extensions, 'x509_extensions'=>$this->service->product->plugin()->extensions,
),time()); ),time());
if (openssl_x509_export($res,$cert)) { if ($res AND openssl_x509_export($res,$cert)) {
$this->cert = $cert; $this->cert = $cert;
$this->save(); $this->save();

View File

@ -18,6 +18,6 @@ return array(
'minpass_length' => 4, 'minpass_length' => 4,
// Location to openssl config // Location to openssl config
'config' => 'appliation/config/openssl.cnf', 'config' => 'application/config/openssl.cnf',
); );
?> ?>