Many misc fixes
This commit is contained in:
parent
f0f6479ca2
commit
d9c3394b0f
@ -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
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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'),
|
||||
|
@ -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;
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
<?php echo Form::open(); ?>
|
||||
<table class="login">
|
||||
<tr><td><b>Email Address</b></td></tr>
|
||||
<tr><td><?php echo Form::input('email',null,array('id'=>'login-uid','size'=>40));?></td></tr>
|
||||
<tr><td><b>Username</b></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>
|
||||
</table>
|
||||
<?php echo Form::close(); ?>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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'),
|
||||
|
@ -21,9 +21,13 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Charges for excess traffic usage
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -18,6 +18,6 @@ return array(
|
||||
'minpass_length' => 4,
|
||||
|
||||
// Location to openssl config
|
||||
'config' => 'appliation/config/openssl.cnf',
|
||||
'config' => 'application/config/openssl.cnf',
|
||||
);
|
||||
?>
|
||||
|
Reference in New Issue
Block a user