From 4220ade8ac742c8e97a2cbb2101ca142ce4c031b Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 1 Aug 2012 22:43:33 +1000 Subject: [PATCH] Changed use of active to status --- application/classes/auth/osb.php | 2 +- .../classes/controller/admin/welcome.php | 2 +- application/classes/controller/tree.php | 2 +- application/classes/editor.php | 2 +- application/classes/http/exception/404.php | 2 +- application/classes/kohana.php | 2 +- .../classes/lnapp/controller/login.php | 10 ++-- application/classes/lnapp/pwgen.php | 2 +- application/classes/model/account.php | 18 ++++---- application/classes/ormosb.php | 16 +++++-- application/classes/valid.php | 2 +- modules/adsl/classes/model/adsl/supplier.php | 15 ++---- .../service/traffic/adsl/exetelhspa.php | 2 +- .../classes/service/traffic/adsl/exetelpe.php | 2 +- .../service/traffic/adsl/iinetadsl.php | 2 +- .../classes/controller/admin/charge.php | 46 +++++++++---------- modules/checkout/classes/model/checkout.php | 2 +- .../classes/model/product/plugin/domain.php | 6 +-- .../email/classes/model/email/template.php | 2 +- .../email/views/email/admin/templateadd.php | 2 +- .../email/views/email/admin/templateedit.php | 2 +- .../views/email/admin/templatelist/body.php | 2 +- modules/invoice/classes/model/invoice.php | 6 +-- modules/invoice/views/invoice/user/view.php | 2 +- .../payment/views/payment/admin/add_view.php | 2 +- .../classes/controller/admin/product.php | 10 ++-- .../product/classes/controller/product.php | 2 +- modules/product/classes/model/product.php | 39 ++++++++-------- .../classes/model/product/category.php | 4 -- .../product/views/product/admin/update.php | 2 +- .../classes/controller/admin/service.php | 14 +++--- .../classes/controller/affiliate/service.php | 8 ++-- .../classes/controller/task/service.php | 2 +- .../classes/controller/user/service.php | 2 +- modules/service/classes/model/service.php | 18 ++------ .../service/views/service/admin/update.php | 2 +- modules/service/views/service/user/view.php | 2 +- modules/ssl/classes/controller/user/ssl.php | 2 +- .../ssl/classes/model/service/plugin/ssl.php | 2 +- modules/task/classes/model/task.php | 6 +-- 40 files changed, 123 insertions(+), 145 deletions(-) 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 .= '
'; diff --git a/modules/email/classes/model/email/template.php b/modules/email/classes/model/email/template.php index 10aff29e..d11dee05 100644 --- a/modules/email/classes/model/email/template.php +++ b/modules/email/classes/model/email/template.php @@ -23,7 +23,7 @@ class Model_Email_Template extends ORMOSB { ); protected $_display_filters = array( - 'active'=>array( + 'status'=>array( array('StaticList_YesNo::display',array(':value')), ), ); diff --git a/modules/email/views/email/admin/templateadd.php b/modules/email/views/email/admin/templateadd.php index 30e6ebc8..2bf0fc33 100644 --- a/modules/email/views/email/admin/templateadd.php +++ b/modules/email/views/email/admin/templateadd.php @@ -5,7 +5,7 @@ Active: - + Notes: diff --git a/modules/email/views/email/admin/templateedit.php b/modules/email/views/email/admin/templateedit.php index 3bc5aeca..16faada0 100644 --- a/modules/email/views/email/admin/templateedit.php +++ b/modules/email/views/email/admin/templateedit.php @@ -5,7 +5,7 @@ Active: - active); ?> + status); ?> Notes: diff --git a/modules/email/views/email/admin/templatelist/body.php b/modules/email/views/email/admin/templatelist/body.php index 087fd3a5..745ab6fe 100644 --- a/modules/email/views/email/admin/templatelist/body.php +++ b/modules/email/views/email/admin/templatelist/body.php @@ -1,4 +1,4 @@ name; ?> - display('active'); ?> + display('status'); ?> diff --git a/modules/invoice/classes/model/invoice.php b/modules/invoice/classes/model/invoice.php index 0d35fa6f..5180f1ea 100644 --- a/modules/invoice/classes/model/invoice.php +++ b/modules/invoice/classes/model/invoice.php @@ -510,15 +510,11 @@ class Model_Invoice extends ORMOSB { return $return; } - private function _list_active() { - return ORM::factory('invoice')->where('status','=',1); - } - private function _list_due() { static $result = array(); if (! $result) - foreach ($this->_list_active()->find_all() as $io) + foreach ($this->list_active() as $io) if ($io->due()) array_push($result,$io); diff --git a/modules/invoice/views/invoice/user/view.php b/modules/invoice/views/invoice/user/view.php index 1692f0b0..7acccf64 100644 --- a/modules/invoice/views/invoice/user/view.php +++ b/modules/invoice/views/invoice/user/view.php @@ -204,7 +204,7 @@ - + Total Outstanding This Account: account->invoices_due_total(NULL,TRUE); ?> diff --git a/modules/payment/views/payment/admin/add_view.php b/modules/payment/views/payment/admin/add_view.php index a050a048..1f530be3 100644 --- a/modules/payment/views/payment/admin/add_view.php +++ b/modules/payment/views/payment/admin/add_view.php @@ -12,7 +12,7 @@ Method - checkout_plugin_id,'id','name',array('active'=>'=:1'),TRUE,array('class'=>'form_button'));?> + checkout_plugin_id,'id','name',array('status'=>'=:1'),TRUE,array('class'=>'form_button'));?> Amount diff --git a/modules/product/classes/controller/admin/product.php b/modules/product/classes/controller/admin/product.php index 118acd9c..6c940ec1 100644 --- a/modules/product/classes/controller/admin/product.php +++ b/modules/product/classes/controller/admin/product.php @@ -41,7 +41,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { if ($this->request->param('id')) $prods = ORM::factory('product')->list_category($this->request->param('id'),FALSE); else - $prods = ORM::factory('product')->order_by('active DESC,prod_plugin_file')->find_all(); + $prods = ORM::factory('product')->order_by('status DESC,prod_plugin_file')->find_all(); Block::add(array( 'title'=>_('Customer Products'), @@ -51,14 +51,14 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { array( 'id'=>array('label'=>'ID','url'=>'product/view/'), 'name()'=>array('label'=>'Details'), - 'active'=>array('label'=>'Active'), + 'status'=>array('label'=>'Active'), 'prod_plugin_file'=>array('label'=>'Plugin Name'), 'prod_plugin_data'=>array('label'=>'Plugin Data'), 'price_type'=>array('label'=>'Price Type'), 'price_base'=>array('label'=>'Price Base'), 'taxable'=>array('label'=>'Taxable'), - 'services_count()'=>array('label'=>'Services'), - 'invoices_count()'=>array('label'=>'Invoices'), + 'count_services()'=>array('label'=>'Services'), + 'count_invoices()'=>array('label'=>'Invoices'), ), array( 'page'=>TRUE, @@ -130,7 +130,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { 'account->accnum()'=>array(), 'account->name()'=>array('label'=>'Account'), 'name()'=>array('label'=>'Details'), - 'active'=>array('label'=>'Active'), + 'status'=>array('label'=>'Active'), 'price(TRUE,TRUE)'=>array('label'=>'Price','align'=>'right'), ), array( diff --git a/modules/product/classes/controller/product.php b/modules/product/classes/controller/product.php index 48c2cfb6..91f3c18c 100644 --- a/modules/product/classes/controller/product.php +++ b/modules/product/classes/controller/product.php @@ -15,7 +15,7 @@ class Controller_Product extends Controller_TemplateDefault { $output = '
'; $output .= '