diff --git a/application/classes/auth/osb.php b/application/classes/auth/osb.php index c8f5ca8d..e9ee4677 100644 --- a/application/classes/auth/osb.php +++ b/application/classes/auth/osb.php @@ -226,7 +226,7 @@ class Auth_OSB extends Auth_ORM { } // If the passwords match, perform a login - if ($user->active AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password) + if ($user->status AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password) { if ($remember === TRUE) { diff --git a/application/classes/controller/admin/welcome.php b/application/classes/controller/admin/welcome.php index 1cbe89be..ecfebc7b 100644 --- a/application/classes/controller/admin/welcome.php +++ b/application/classes/controller/admin/welcome.php @@ -79,7 +79,7 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin { 'order'=>1, )); - // Show un-applied payments + // Show un-applied payments Block_Sub::add(array( 'title'=>'Unapplied Payments', 'body'=>Table::display( diff --git a/application/classes/controller/tree.php b/application/classes/controller/tree.php index 81a4ec47..c568978b 100644 --- a/application/classes/controller/tree.php +++ b/application/classes/controller/tree.php @@ -73,7 +73,7 @@ class Controller_Tree extends lnApp_Controller_Tree { $subdata[$sub][$name]['name'] = preg_replace('/^(.*: )/','',$mmo->notes); $subdata[$sub][$name]['id'] = sprintf('%s_%s',$mmo->module_id,$id); $subdata[$sub][$name]['href'] = (empty($details['page']) ? $url : $details['page']); - + } else { // We dont want to show these items again, if we can through on a submenu if (! $idx) diff --git a/application/classes/editor.php b/application/classes/editor.php index 20432e33..f60b2ff8 100644 --- a/application/classes/editor.php +++ b/application/classes/editor.php @@ -41,7 +41,7 @@ tinyMCE.init({ theme_advanced_buttons3_add_before : "tablecontrols,separator", theme_advanced_buttons3_add : "iespell,media,advhr", theme_advanced_toolbar_location : "bottom", - theme_advanced_toolbar_align : "center", + theme_advanced_toolbar_align : "center", plugin_insertdate_dateFormat : "%Y-%m-%d", plugin_insertdate_timeFormat : "%H:%M:%S", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", diff --git a/application/classes/http/exception/404.php b/application/classes/http/exception/404.php index c810aeaf..acf76bef 100644 --- a/application/classes/http/exception/404.php +++ b/application/classes/http/exception/404.php @@ -20,7 +20,7 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 { public static function handler(Exception $e) { SystemMessage::add(array( - 'title'=>_('Page not found'), + 'title'=>_('Page not found'), 'type'=>'error', 'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()), )); diff --git a/application/classes/kohana.php b/application/classes/kohana.php index 7a977028..9942d61e 100644 --- a/application/classes/kohana.php +++ b/application/classes/kohana.php @@ -18,7 +18,7 @@ class Kohana extends Kohana_Core { * unless each site has exactly the same modules enabled. * This is because Kohana::$file is cached with the enabled modules * and is not OSB multi-site aware. - * + * * @todo It might be nice to cache the Kohana::$file site-aware for improved performance */ public static function shutdown_handler() { diff --git a/application/classes/lnapp/controller/login.php b/application/classes/lnapp/controller/login.php index edf22de2..886cd590 100644 --- a/application/classes/lnapp/controller/login.php +++ b/application/classes/lnapp/controller/login.php @@ -33,13 +33,13 @@ class lnApp_Controller_Login extends Controller_TemplateDefault { if ($redir = Session::instance()->get('afterlogin')) { Session::instance()->delete('afterlogin'); Request::current()->redirect($redir); - + } else Request::current()->redirect('user/welcome/index'); } else { SystemMessage::add(array( - 'title'=>_('Invalid username or password'), + 'title'=>_('Invalid username or password'), 'type'=>'error', 'body'=>_('The username or password was invalid.') )); @@ -81,7 +81,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault { // Generic validation reason default: SystemMessage::add(array( - 'title'=>_('Validation failed'), + 'title'=>_('Validation failed'), 'type'=>'error', 'body'=>sprintf(_('The defaults on your submission were not valid for field %s (%s).'),$f,$r) )); @@ -100,7 +100,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault { } SystemMessage::add(array( - 'title'=>_('Already have an account?'), + 'title'=>_('Already have an account?'), 'type'=>'info', 'body'=>_('If you already have an account, please login..') )); @@ -184,7 +184,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault { public function action_noaccess() { SystemMessage::add(array( - 'title'=>_('No access to requested resource'), + 'title'=>_('No access to requested resource'), 'type'=>'error', 'body'=>_('You do not have access to the requested resource, please contact your administrator.') )); diff --git a/application/classes/lnapp/pwgen.php b/application/classes/lnapp/pwgen.php index 31e8bb0b..db4d9331 100644 --- a/application/classes/lnapp/pwgen.php +++ b/application/classes/lnapp/pwgen.php @@ -16,7 +16,7 @@ abstract class lnApp_PWgen { throw new Kohana_Exception('No configuration for host or port (:host/:port)',array(':host'=>Kohana::Config('pwgen.host'),':port'=>Kohana::Config('pwgen.port'))); $ps = socket_create(AF_INET,SOCK_STREAM,0); - if (! socket_connect($ps,Kohana::Config('pwgen.host'),Kohana::Config('pwgen.port'))) + if (! socket_connect($ps,Kohana::Config('pwgen.host'),Kohana::Config('pwgen.port'))) throw new Kohana_Exception('Unable to connect to password server'); // echo "Reading response:\n\n"; diff --git a/application/classes/model/account.php b/application/classes/model/account.php index b56cd3f1..c78169fc 100644 --- a/application/classes/model/account.php +++ b/application/classes/model/account.php @@ -24,15 +24,15 @@ class Model_Account extends Model_Auth_UserDefault { ); protected $_display_filters = array( - 'active'=>array( - array('StaticList_YesNo::display',array(':value')), - ), 'date_orig'=>array( array('Config::date',array(':value')), ), 'date_last'=>array( array('Config::date',array(':value')), ), + 'status'=>array( + array('StaticList_YesNo::display',array(':value')), + ), ); /** @@ -67,7 +67,7 @@ class Model_Account extends Model_Auth_UserDefault { } public function country($name) { - return StaticList_Module::form($name,'country',$this->country_id,'id','name',array('active'=>'=:1'),FALSE,array('class'=>'form_button')); + return StaticList_Module::form($name,'country',$this->country_id,'id','name',array('status'=>'=:1'),FALSE,array('class'=>'form_button')); } /** @@ -133,12 +133,12 @@ class Model_Account extends Model_Auth_UserDefault { return $alo->saved(); } - private function _active() { - return $this->where('active','=',TRUE); + private function _where_active() { + return $this->where('status','=',TRUE); } public function list_active() { - return $this->_active()->order_by('company,last_name,first_name')->find_all(); + return $this->_where_active()->order_by('company,last_name,first_name')->find_all(); } public function list_affiliates() { @@ -152,7 +152,7 @@ class Model_Account extends Model_Auth_UserDefault { } public function count_services($active=TRUE,$afid=NULL) { - return count($this->list_services($active,$afid)); + return $this->list_services($active,$afid)->count(); } /** @@ -200,7 +200,7 @@ class Model_Account extends Model_Auth_UserDefault { } public function list_services($active=TRUE,$afid=NULL) { - $svs = $this->service->where('active','=',$active); + $svs = $this->service->where_active(); if ($afid) $svs->where('affiliate_id','=',$afid); diff --git a/application/classes/ormosb.php b/application/classes/ormosb.php index d21add1b..dbb46e99 100644 --- a/application/classes/ormosb.php +++ b/application/classes/ormosb.php @@ -209,12 +209,22 @@ abstract class ORMOSB extends ORM { return empty($mc[$key]) ? '' : $mc[$key]; } - protected function _active() { - return $this->where('active','=',TRUE); + protected function _where_active() { + return $this->where('status','=',TRUE); + } + + public function where_active() { + return $this->_where_active(); } public function list_active() { - return $this->_active()->find_all(); + return $this->_where_active()->find_all(); + } + + public function list_count($active=TRUE) { + $a=($active ? $this->_where_active() : $this); + + return $a->find_all()->count(); } } ?> diff --git a/application/classes/valid.php b/application/classes/valid.php index fa0d3ecb..d76a083c 100644 --- a/application/classes/valid.php +++ b/application/classes/valid.php @@ -20,7 +20,7 @@ class Valid extends Kohana_Valid { * @return boolean */ public static function matches_ifset($array, $field, $match) - { + { return isset($array[$match]) ? ($array[$field] === $array[$match]) : TRUE; } } diff --git a/modules/adsl/classes/model/adsl/supplier.php b/modules/adsl/classes/model/adsl/supplier.php index a9782fad..397155ab 100644 --- a/modules/adsl/classes/model/adsl/supplier.php +++ b/modules/adsl/classes/model/adsl/supplier.php @@ -25,7 +25,7 @@ class Model_ADSL_Supplier extends ORMOSB { $a = $this->adsl_supplier_plan; if ($active) - $a->where('status','=',TRUE); + $a->where_active(); return $a; } @@ -56,27 +56,18 @@ class Model_ADSL_Supplier extends ORMOSB { // Start with all our ADSL Plans foreach (ORM::factory('service')->list_bylistgroup('ADSL') as $so) - if (! $active OR $so->active) + if (! $active OR $so->status) 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 (! $active OR $so->status) 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; } - - /** LIST FUNCTIONS **/ - - /** - * Return a list of active suppliers - */ - public function list_active() { - return $this->where('status','=',1)->find_all(); - } } ?> diff --git a/modules/adsl/classes/service/traffic/adsl/exetelhspa.php b/modules/adsl/classes/service/traffic/adsl/exetelhspa.php index ca196fe7..7d74c4ce 100644 --- a/modules/adsl/classes/service/traffic/adsl/exetelhspa.php +++ b/modules/adsl/classes/service/traffic/adsl/exetelhspa.php @@ -160,7 +160,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { } } } - + // If we got here and have data, we had a good fetch, update the stats date $so->plugin()->service_stats_lastupdate = $lastday; $so->plugin()->save(); diff --git a/modules/adsl/classes/service/traffic/adsl/exetelpe.php b/modules/adsl/classes/service/traffic/adsl/exetelpe.php index e57ec7e9..2fec6dc8 100644 --- a/modules/adsl/classes/service/traffic/adsl/exetelpe.php +++ b/modules/adsl/classes/service/traffic/adsl/exetelpe.php @@ -153,7 +153,7 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL { } } } - + // If we got here and have data, we had a good fetch, update the stats date $so->plugin()->service_stats_lastupdate = $lastday; $so->plugin()->save(); diff --git a/modules/adsl/classes/service/traffic/adsl/iinetadsl.php b/modules/adsl/classes/service/traffic/adsl/iinetadsl.php index 3fd4bb36..d60d271a 100644 --- a/modules/adsl/classes/service/traffic/adsl/iinetadsl.php +++ b/modules/adsl/classes/service/traffic/adsl/iinetadsl.php @@ -89,7 +89,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL { foreach ($day_hour->get('usage') as $usage) { $fields = $usage->attributes(); - + // If we find a field we dont understand, we'll return. if (empty($fields['type']) OR empty($this->fields[$fields['type']])) return array(); diff --git a/modules/charge/classes/controller/admin/charge.php b/modules/charge/classes/controller/admin/charge.php index 81c93c45..0719ab65 100644 --- a/modules/charge/classes/controller/admin/charge.php +++ b/modules/charge/classes/controller/admin/charge.php @@ -94,32 +94,32 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin { source: "'.URL::site('admin/account/autocomplete').'", minLength: 2, change: function(event,ui) { - // Send the request and update sub category dropdown - $.ajax({ - type: "GET", - data: "aid="+$(this).val(), - dataType: "json", - cache: false, - url: "'.URL::site('admin/service/autolist').'", - timeout: 2000, - error: function() { - alert("Failed to submit"); - }, + // Send the request and update sub category dropdown + $.ajax({ + type: "GET", + data: "aid="+$(this).val(), + dataType: "json", + cache: false, + url: "'.URL::site('admin/service/autolist').'", + timeout: 2000, + error: function() { + alert("Failed to submit"); + }, success: function(data) { - // Clear all options from sub category select - $("select[name=service_id] option").remove(); + // Clear all options from sub category select + $("select[name=service_id] option").remove(); // Prepopulate a blank - var row = ""; - $(row).appendTo("select[name=service_id]"); - - // Fill sub category select - $.each(data, function(i, j){ - var row = ""; - $(row).appendTo("select[name=service_id]"); - }); - } - }); + var row = ""; + $(row).appendTo("select[name=service_id]"); + + // Fill sub category select + $.each(data, function(i, j){ + var row = ""; + $(row).appendTo("select[name=service_id]"); + }); + } + }); } }); });' diff --git a/modules/checkout/classes/model/checkout.php b/modules/checkout/classes/model/checkout.php index b7a15f0f..b98d9e41 100644 --- a/modules/checkout/classes/model/checkout.php +++ b/modules/checkout/classes/model/checkout.php @@ -34,7 +34,7 @@ class Model_Checkout extends ORMOSB { $this->and_where('allow_new','=',TRUE); - foreach ($this->where('active','=',TRUE)->find_all() as $item) { + foreach ($this->list_active() as $item) { // Check that the cart total meets the minimum requirement if ($item->total_minimum AND $cart->total() < $item->total_minimum) continue; diff --git a/modules/domain/classes/model/product/plugin/domain.php b/modules/domain/classes/model/product/plugin/domain.php index 7374d84e..c6af99ce 100644 --- a/modules/domain/classes/model/product/plugin/domain.php +++ b/modules/domain/classes/model/product/plugin/domain.php @@ -27,12 +27,12 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin { // @todo Change this to a view. $output = sprintf('
%s |
',_('Domains are available with the following suffixes')); $output .= Table::display( - $t->where('status','=','1')->find_all(), + $t->list_active(), 25, - array( + array( 'display("name")'=>array('label'=>'TLD Suffix'), ), - array( + array( )); $output .= ' |
'.$pco->description().'
'; diff --git a/modules/product/classes/model/product.php b/modules/product/classes/model/product.php index 4e9a6e59..19959f4f 100644 --- a/modules/product/classes/model/product.php +++ b/modules/product/classes/model/product.php @@ -26,9 +26,6 @@ class Model_Product extends ORMOSB { ); protected $_display_filters = array( - 'active'=>array( - array('StaticList_YesNo::display',array(':value')), - ), 'price_base'=>array( array('Tax::add',array(':value')), array('Currency::display',array(':value')), @@ -36,6 +33,9 @@ class Model_Product extends ORMOSB { 'price_type'=>array( array('StaticList_PriceType::display',array(':value')), ), + 'status'=>array( + array('StaticList_YesNo::display',array(':value')), + ), 'taxable'=>array( array('StaticList_YesNo::display',array(':value')), ), @@ -173,6 +173,20 @@ class Model_Product extends ORMOSB { return array('price_base','price_setup'); } + /** + * List the number of services using this product + */ + public function count_services() { + return $this->service->list_count(TRUE); + } + + /** + * List the number of invoices using this product + */ + public function count_invoices() { + return $this->invoice->list_count(TRUE); + } + /** * Return the price for the particle group and price option for the period */ @@ -182,20 +196,6 @@ class Model_Product extends ORMOSB { return isset($x[$grp][$option]) ? $x[$grp][$option] : NULL; } - /** - * List the number of services using this product - */ - public function services_count() { - return $this->service->where('active','=',1)->find_all()->count(); - } - - /** - * List the number of invoices using this product - */ - public function invoices_count() { - return $this->invoice->where('status','=',1)->find_all()->count(); - } - /** * Return the products for a given category * @todo This shouldnt be here. @@ -203,10 +203,7 @@ class Model_Product extends ORMOSB { public function list_category($cat,$active=TRUE) { $results = array(); - if ($active) - $cats = $this->where('active','=',TRUE); - else - $cats = $this; + $cats = $active ? $this->_where_active() : $this; foreach ($cats->find_all() as $po) { if ($c = unserialize($po->avail_category) AND in_array($cat,$c)) diff --git a/modules/product/classes/model/product/category.php b/modules/product/classes/model/product/category.php index 27ba2f5c..72b2c77b 100644 --- a/modules/product/classes/model/product/category.php +++ b/modules/product/classes/model/product/category.php @@ -30,10 +30,6 @@ class Model_Product_Category extends ORMOSB { return ($a=$this->product_category_translate->where('language_id','=',$ao->language_id)->find()->description) ? $a : _('No Description'); } - public function list_active() { - return $this->where('status','=',1); - } - public function list_bylistgroup($cat) { $result = array(); diff --git a/modules/product/views/product/admin/update.php b/modules/product/views/product/admin/update.php index 02dcae60..be0900d9 100644 --- a/modules/product/views/product/admin/update.php +++ b/modules/product/views/product/admin/update.php @@ -7,7 +7,7 @@Service Active | -active); ?> | +status); ?> |
Queue | diff --git a/modules/service/views/service/user/view.php b/modules/service/views/service/user/view.php index 07fd1d80..69497d05 100644 --- a/modules/service/views/service/user/view.php +++ b/modules/service/views/service/user/view.php @@ -10,7 +10,7 @@||
Service Active | -display('active'); ?> | +display('status'); ?> |
Billing Period | diff --git a/modules/ssl/classes/controller/user/ssl.php b/modules/ssl/classes/controller/user/ssl.php index 5e0baa18..4748af9d 100644 --- a/modules/ssl/classes/controller/user/ssl.php +++ b/modules/ssl/classes/controller/user/ssl.php @@ -25,7 +25,7 @@ class Controller_User_SSL extends Controller_TemplateDefault_User { $passwd = $_POST['passwd']; if (strlen($passwd) < Kohana::config('ssl.minpass_length')) { SystemMessage::add(array( - 'title'=>_('Validation failed'), + 'title'=>_('Validation failed'), 'type'=>'error', 'body'=>_('Your requested password is too short.'), )); diff --git a/modules/ssl/classes/model/service/plugin/ssl.php b/modules/ssl/classes/model/service/plugin/ssl.php index d29e67f1..ddfb31e8 100644 --- a/modules/ssl/classes/model/service/plugin/ssl.php +++ b/modules/ssl/classes/model/service/plugin/ssl.php @@ -121,7 +121,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { } public function download_button() { - if (! $this->service->active OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time()) + if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time()) return ''; // @todo Do some password validation diff --git a/modules/task/classes/model/task.php b/modules/task/classes/model/task.php index f542bbcd..bc6ccdd9 100644 --- a/modules/task/classes/model/task.php +++ b/modules/task/classes/model/task.php @@ -81,14 +81,10 @@ class Model_Task extends ORMOSB { /** LIST FUNCTIONS **/ - private function _list_active() { - return $this->where('status','=',1)->find_all(); - } - public function list_active() { $return = array(); - foreach ($this->_list_active() as $to) { + foreach ($this->_where_active()->find_all() as $to) { $ct = sprintf('%s %s %s %s %s',$to->int_min,$to->int_hour,$to->int_month_day,$to->int_month,$to->int_week_day); $c = new Cron($ct,$to->command);