diff --git a/.htaccess b/.htaccess index 53b8ccbb..6e25c67a 100644 --- a/.htaccess +++ b/.htaccess @@ -2,7 +2,7 @@ RewriteEngine On # Installation directory -RewriteBase / +RewriteBase /osb/ # Protect hidden files from being viewed @@ -11,7 +11,7 @@ RewriteBase / # Protect application and system files from being viewed -RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L] +RewriteRule ^(?:application|modules|includes/kohana)\b.* index.php/$0 [L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f diff --git a/application/bootstrap.php b/application/bootstrap.php index d5949260..aff6e0db 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -22,7 +22,7 @@ else * @link http://kohanaframework.org/guide/using.configuration * @link http://www.php.net/manual/timezones */ -date_default_timezone_set('America/Chicago'); +date_default_timezone_set('Australia/Melbourne'); /** * Set the default locale. @@ -90,9 +90,9 @@ if (isset($_SERVER['KOHANA_ENV'])) * - boolean expose set the X-Powered-By header FALSE */ Kohana::init(array( - 'base_url' => '/osb', - 'index_file' => '', + 'base_url' => '/osb/', 'caching' => TRUE, + 'index_file' => '', )); /** @@ -114,14 +114,14 @@ Kohana::modules(array( 'cron' => SMDPATH.'cron', // Kohana Cron Module // 'codebench' => SMDPATH.'codebench', // Benchmarking tool 'database' => SMDPATH.'database', // Database access - // 'image' => SMDPATH.'image', // Image manipulation - // 'minion' => MODPATH.'minion', // CLI Tasks - 'orm' => SMDPATH.'orm', // Object Relationship Mapping - // 'unittest' => SMDPATH.'unittest', // Unit testing - 'userguide' => SMDPATH.'userguide', // User guide and API documentation - 'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework 'gchart' => MODPATH.'gchart', // Google Chart Module + // 'image' => SMDPATH.'image', // Image manipulation + 'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework + 'minion' => SMDPATH.'minion', // CLI Tasks + 'orm' => SMDPATH.'orm', // Object Relationship Mapping 'pagination' => SMDPATH.'pagination', // Kohana Pagination module for Kohana 3 PHP Framework + // 'unittest' => SMDPATH.'unittest', // Unit testing + // 'userguide' => SMDPATH.'userguide', // User guide and API documentation 'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework )); @@ -135,7 +135,7 @@ Kohana::modules(array_merge(Kohana::modules(),Config::modules())); */ Route::set('sections', '/(/(/(/)))', array( - 'directory' => '('.implode('|',Kohana::config('config.method_directory')).')' + 'directory' => '('.implode('|',Kohana::$config->load('config')->method_directory).')' )) ->defaults(array( 'action' => 'index', @@ -152,7 +152,7 @@ Route::set('default/media', 'media(/)', array('file' => '.+')) * Set the routes. Each route must have a minimum of a name, a URI and a set of * defaults for the URI. */ -Route::set('default', '((/(/)))', array('id' => '[a-zA-Z0-9_.-]+')) +Route::set('default', '((/(/)))', array('id'=>'[a-zA-Z0-9_.-]+')) ->defaults(array( 'controller' => 'welcome', 'action' => 'index', diff --git a/application/classes/auth/orm.php b/application/classes/Auth/ORM.php similarity index 100% rename from application/classes/auth/orm.php rename to application/classes/Auth/ORM.php diff --git a/application/classes/auth/osb.php b/application/classes/Auth/OSB.php similarity index 91% rename from application/classes/auth/osb.php rename to application/classes/Auth/OSB.php index a4d28a46..c957a19f 100644 --- a/application/classes/auth/osb.php +++ b/application/classes/Auth/OSB.php @@ -30,12 +30,12 @@ class Auth_OSB extends Auth_ORM { // If we are not a valid user object, then we are not logged in if (is_object($user) AND $user instanceof Model_Account AND $user->loaded()) { - if (Config::sitemode() == Kohana::DEVELOPMENT && Kohana::config('config.site_debug')) + if (Config::sitemode() == Kohana::DEVELOPMENT && Kohana::$config->load('config')->site_debug) SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Kohana::debug(array('user'=>$user->username,'r'=>$role)))); if (! empty($role)) { // Get the module details - $mo = ORM::factory('module',array('name'=>Request::current()->controller())); + $mo = ORM::factory('Module',array('name'=>Request::current()->controller())); if (! $mo->loaded() OR ! $mo->status) { SystemMessage::add(array( 'title'=>'Module is not defined or active in the Database', @@ -50,7 +50,7 @@ class Auth_OSB extends Auth_ORM { $method_name = Request::current()->action(); // Get the method number - $mmo = ORM::factory('module_method',array('module_id'=>$mo->id,'name'=>$method_name)); + $mmo = ORM::factory('Module_Method',array('module_id'=>$mo->id,'name'=>$method_name)); if (! $mmo->loaded()) { SystemMessage::add(array( 'title'=>'Method is not defined or active in the Database', @@ -60,7 +60,7 @@ class Auth_OSB extends Auth_ORM { } else { // If the role has the authorisation to run the method - $gmo = ORM::factory('group_method') + $gmo = ORM::factory('Group_Method') ->where('method_id','=',$mmo->id); $roles = ''; @@ -152,14 +152,14 @@ class Auth_OSB extends Auth_ORM { if (! is_null($user)) return $user; - $mmto = ORM::factory('module_method_token',array('token'=>$token)); + $mmto = ORM::factory('Module_Method_Token',array('token'=>$token)); $user = FALSE; // Ignore the token if it doesnt exist. if ($mmto->loaded()) { // Check that the token is for this URI - $mo = ORM::factory('module',array('name'=>Request::current()->controller())); - $mmo = ORM::factory('module_method',array( + $mo = ORM::factory('Module',array('name'=>Request::current()->controller())); + $mmo = ORM::factory('Module_Method',array( 'module_id'=>$mo->id, 'name'=>Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action() )); @@ -197,7 +197,7 @@ class Auth_OSB extends Auth_ORM { Session::instance()->set('token',$token); - $user = ORM::factory('account',$mmto->account_id); + $user = ORM::factory('Account',$mmto->account_id); $user->log(sprintf('Token %s used for method %s [%s]',$mmto->token,$mmto->module_method->name(),Request::current()->param('id'))); } } @@ -221,17 +221,23 @@ class Auth_OSB extends Auth_ORM { $username = $user; // Load the user - $user = ORM::factory('account'); + $user = ORM::factory('Account'); $user->where('username','=',$username)->find(); } + if (is_string($password)) + { + // Create a hashed password + $password = $this->hash($password); + } + // If the passwords match, perform a login - if ($user->status 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) { // Create a new autologin token - $token = ORM::factory('user_token'); + $token = ORM::factory('User_Token'); // Set token data $token->user_id = $user->id; @@ -250,7 +256,7 @@ class Auth_OSB extends Auth_ORM { // Do we need to update databases with our new sesion ID // @todo figure out where this is best to go - $session_change_trigger = array('cart'=>'session_id'); + $session_change_trigger = array('Cart'=>'session_id'); if (count($session_change_trigger) AND (session_id() != $oldsess)) { foreach ($session_change_trigger as $t => $c) { diff --git a/application/classes/block.php b/application/classes/Block.php similarity index 100% rename from application/classes/block.php rename to application/classes/Block.php diff --git a/application/classes/block/sub.php b/application/classes/Block/Sub.php similarity index 100% rename from application/classes/block/sub.php rename to application/classes/Block/Sub.php diff --git a/application/classes/breadcrumb.php b/application/classes/BreadCrumb.php similarity index 59% rename from application/classes/breadcrumb.php rename to application/classes/BreadCrumb.php index 61fc6976..2b44bf85 100644 --- a/application/classes/breadcrumb.php +++ b/application/classes/BreadCrumb.php @@ -1,4 +1,4 @@ diff --git a/application/classes/Cache.php b/application/classes/Cache.php new file mode 100644 index 00000000..f8ef4abe --- /dev/null +++ b/application/classes/Cache.php @@ -0,0 +1,16 @@ + diff --git a/application/classes/company.php b/application/classes/Company.php similarity index 96% rename from application/classes/company.php rename to application/classes/Company.php index 8a7a5fae..6ed97633 100644 --- a/application/classes/company.php +++ b/application/classes/Company.php @@ -60,12 +60,12 @@ class Company { public static function bsb() { // @todo Details should be obtained from DB - return Kohana::config('config.bsb'); + return Kohana::$config->load('config')->bsb; } public static function account() { // @todo Details should be obtained from DB - return Kohana::config('config.accnum'); + return Kohana::$config->load('config')->accnum; } public static function taxid() { diff --git a/application/classes/config.php b/application/classes/Config.php similarity index 61% rename from application/classes/config.php rename to application/classes/Config.php index 7521eda4..c88a79bc 100644 --- a/application/classes/config.php +++ b/application/classes/Config.php @@ -15,12 +15,55 @@ class Config extends lnApp_Config { public $so; public static $no_site_id_tables = array('setup','country','currency','language','tax'); + /** + * @compat Restore KH 3.1 functionality + * @var Kohana_Config Singleton static instance + */ + protected static $_instance; + + public function __construct() { + parent::__construct(); + + // We need to know our site here, so that we can subsequently load our enabled modules. + if (Kohana::$is_cli) { + if (! $site = Minion_CLI::options('site')) + // @todo Need to figure out how to make this CLI error nicer. + throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI')); + else + $_SERVER['SERVER_NAME'] = $site; + } + } + + /** + * Get the singleton instance of Config. + * + * $config = Config::instance(); + * + * @return Config + * @compat Restore KH 3.1 functionality + */ + public static function instance() { + if (Config::$_instance === NULL) + // Create a new instance + Config::$_instance = new Config; + + return Config::$_instance; + } + /** Overloaded methods **/ public static function date($date) { return date(Config::instance()->loadsite()->so->date_format,($date ? $date : time())); } + /** + * Show a date using a site configured format + * @note We need this function here, since we call static:: methods, which need to resolve to the child class. + */ + public static function datetime($date) { + return sprintf('%s %s',static::date($date),static::time($date)); + } + public static function siteid($format=FALSE) { return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id; } @@ -45,7 +88,7 @@ class Config extends lnApp_Config { if ($this->so AND $this->so->loaded()) return $this; - $this->so = ORM::factory('setup',array('url'=>URL::base('http'))); + $this->so = ORM::factory('Setup',array('url'=>URL::base('http'))); if (! $this->so->loaded()) throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http'))); @@ -65,7 +108,7 @@ class Config extends lnApp_Config { static $return = array(); if (! count($return)) - foreach (ORM::factory('module')->list_active() as $mo) + foreach (ORM::factory('Module')->list_external() as $mo) $return[$mo->name] = MODPATH.$mo->name; return $return; diff --git a/application/classes/controller/account.php b/application/classes/Controller/Account.php similarity index 100% rename from application/classes/controller/account.php rename to application/classes/Controller/Account.php diff --git a/application/classes/controller/admin/account.php b/application/classes/Controller/Admin/Account.php similarity index 91% rename from application/classes/controller/admin/account.php rename to application/classes/Controller/Admin/Account.php index 18f51fb4..22b461c2 100644 --- a/application/classes/controller/admin/account.php +++ b/application/classes/Controller/Admin/Account.php @@ -21,7 +21,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin { $return = array(); if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) - $return += ORM::factory('account')->list_autocomplete($_REQUEST['term']); + $return += ORM::factory('Account')->list_autocomplete($_REQUEST['term']); $this->auto_render = FALSE; $this->response->headers('Content-Type','application/json'); @@ -35,7 +35,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Account Login Log'), 'body'=>Table::display( - ORM::factory('account_log')->order_by('id','DESC')->find_all(), + ORM::factory('Account_Log')->order_by('id','DESC')->find_all(), 25, array( 'id'=>array('label'=>'ID'), @@ -57,7 +57,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Customer List'), 'body'=>Table::display( - ORM::factory('account')->list_active(), + ORM::factory('Account')->list_active(), 25, array( 'id'=>array('label'=>'ID','url'=>'user/account/view/'), diff --git a/application/classes/controller/admin/module.php b/application/classes/Controller/Admin/Module.php similarity index 93% rename from application/classes/controller/admin/module.php rename to application/classes/Controller/Admin/Module.php index b5af85d3..803a8b54 100644 --- a/application/classes/controller/admin/module.php +++ b/application/classes/Controller/Admin/Module.php @@ -26,11 +26,11 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin { $methods = array(); // List of classes where all our methods are, including this one. - $classes = Kohana::config('config.method_directory'); + $classes = Kohana::$config->load('config')->method_directory; array_unshift($classes,''); foreach ($classes as $c) { - $cn = sprintf($ch,$c ? $c.'_'.$class : $class); + $cn = sprintf($ch,$c ? ucfirst($c).'_'.ucfirst($class) : $class); if (class_exists($cn)) { $r = new ReflectionClass($cn); @@ -48,7 +48,7 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin { * List our installed modules */ public function action_list() { - $mo = ORM::factory('module'); + $mo = ORM::factory('Module'); Block::add(array( 'title'=>_('Defined Modules'), @@ -74,7 +74,7 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin { */ public function action_edit() { $mid = $this->request->param('id'); - $mo = ORM::factory('module',$mid); + $mo = ORM::factory('Module',$mid); if (! $mo->loaded()) { SystemMessage::add(array( diff --git a/application/classes/controller/admin/module/method.php b/application/classes/Controller/Admin/Module/Method.php similarity index 88% rename from application/classes/controller/admin/module/method.php rename to application/classes/Controller/Admin/Module/Method.php index 045bc775..def470d8 100644 --- a/application/classes/controller/admin/module/method.php +++ b/application/classes/Controller/Admin/Module/Method.php @@ -14,9 +14,12 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { /** * Add a method to the database */ - public function action_add($mid,$method) { - $mo = ORM::factory('module',$mid); - $mmo = ORM::factory('module_method'); + public function action_add() { + $id = $this->request->param('id'); + $method = $this->request->param('sid'); + + $mo = ORM::factory('Module',$id); + $mmo = ORM::factory('Module_Method'); if (! $mo->loaded() OR ! in_array($method,$this->_methods($mo->name))) throw new Kohana_Exception('Method (:method) does not exist in :class',array(':method'=>$method,':class'=>$mo->name)); @@ -37,7 +40,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { 'body'=>sprintf(_('Method %s defined to database'),$mmo->name), )); - Request::current()->redirect(sprintf('admin/module/edit/%s',$mo->id)); + HTTP::redirect(sprintf('admin/module/edit/%s',$mo->id)); } else { SystemMessage::add(array( @@ -65,7 +68,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { */ public function action_edit() { $mid = $this->request->param('id'); - $mmo = ORM::factory('module_method',$mid); + $mmo = ORM::factory('Module_Method',$mid); if (! $mmo->loaded()) { SystemMessage::add(array( @@ -80,13 +83,13 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { $output = ''; // The groups that can run this method. - $groups = ORM::factory('group'); + $groups = ORM::factory('Group'); if ($_POST) { foreach ($groups->find_all() as $go) { // If the group was defined and no longer if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) { - $gm = ORM::factory('group_method',array('method_id'=>$mmo->id,'group_id'=>$go->id)); + $gm = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id)); if (! $gm->delete()) SystemMessage::add(array( @@ -97,7 +100,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { // If the group was not defined and now is } elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) { - $gm = ORM::factory('group_method') + $gm = ORM::factory('Group_Method') ->values(array( 'method_id'=>$mmo->id, 'group_id'=>$go->id, diff --git a/application/classes/controller/admin/setup.php b/application/classes/Controller/Admin/Setup.php similarity index 97% rename from application/classes/controller/admin/setup.php rename to application/classes/Controller/Admin/Setup.php index 1b2ed385..5a94c528 100644 --- a/application/classes/controller/admin/setup.php +++ b/application/classes/Controller/Admin/Setup.php @@ -51,7 +51,7 @@ class Controller_Admin_Setup extends Controller_TemplateDefault_Admin { $output .= View::factory($this->viewpath().'/module/head'); foreach ($o->module_config as $mid => $detail) { - $mo = ORM::factory('module',$mid); + $mo = ORM::factory('Module',$mid); $output .= View::factory($this->viewpath().'/module/body') ->set('mo',$mo); diff --git a/application/classes/controller/admin/welcome.php b/application/classes/Controller/Admin/Welcome.php similarity index 95% rename from application/classes/controller/admin/welcome.php rename to application/classes/Controller/Admin/Welcome.php index ecfebc7b..094f279a 100644 --- a/application/classes/controller/admin/welcome.php +++ b/application/classes/Controller/Admin/Welcome.php @@ -16,11 +16,11 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin { ); public function action_index() { - $ao = ORM::factory('account',Auth::instance()->get_user()->id); + $ao = ORM::factory('Account',Auth::instance()->get_user()->id); $t = time(); // Show outstanding invoices - $o = ORM::factory('invoice'); + $o = ORM::factory('Invoice'); Block_Sub::add(array( 'title'=>'Invoices Overdue - No Auto Billing', @@ -83,7 +83,7 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin { Block_Sub::add(array( 'title'=>'Unapplied Payments', 'body'=>Table::display( - ORM::factory('payment')->list_unapplied(), + ORM::factory('Payment')->list_unapplied(), 25, array( 'date_payment'=>array('label'=>'Pay Date'), diff --git a/application/classes/controller/affiliate/account.php b/application/classes/Controller/Affiliate/Account.php similarity index 94% rename from application/classes/controller/affiliate/account.php rename to application/classes/Controller/Affiliate/Account.php index 5224eee1..cb4df5ab 100644 --- a/application/classes/controller/affiliate/account.php +++ b/application/classes/Controller/Affiliate/Account.php @@ -22,7 +22,7 @@ class Controller_Affiliate_Account extends Controller_TemplateDefault_Affiliate Block::add(array( 'title'=>_('Customer List'), 'body'=>Table::display( - $this->filter(ORM::factory('account')->list_active(),$this->ao->affiliate->id,'sortkey(TRUE)'), + $this->filter(ORM::factory('Account')->list_active(),$this->ao->affiliate->id,'sortkey(TRUE)'), 25, array( 'id'=>array('label'=>'ID','url'=>'user/account/view/'), diff --git a/application/classes/controller/debug.php b/application/classes/Controller/Debug.php similarity index 94% rename from application/classes/controller/debug.php rename to application/classes/Controller/Debug.php index 1bc76ee7..e30690a5 100644 --- a/application/classes/controller/debug.php +++ b/application/classes/Controller/Debug.php @@ -3,7 +3,7 @@ class Controller_Debug extends Controller_TemplateDefault { public function before() { if (! in_array(Config::sitemode(),array(Kohana::DEVELOPMENT,Kohana::TESTING))) - $this->request->redirect(); + HTTP::redirect(); parent::before(); } diff --git a/application/classes/controller/default.php b/application/classes/Controller/Default.php similarity index 100% rename from application/classes/controller/default.php rename to application/classes/Controller/Default.php diff --git a/application/classes/controller/login.php b/application/classes/Controller/Login.php similarity index 95% rename from application/classes/controller/login.php rename to application/classes/Controller/Login.php index c55a72f4..a365f4a2 100644 --- a/application/classes/controller/login.php +++ b/application/classes/Controller/Login.php @@ -20,7 +20,7 @@ class Controller_Login extends lnApp_Controller_Login { } // Instantiate a new user - $account = ORM::factory('account'); + $account = ORM::factory('Account'); // If there is a post and $_POST is not empty if ($_POST) { @@ -42,7 +42,7 @@ class Controller_Login extends lnApp_Controller_Login { } } - $ido = ORM::factory('module') + $ido = ORM::factory('Module') ->where('name','=','account') ->find(); @@ -84,8 +84,8 @@ class Controller_Login extends lnApp_Controller_Login { // If the user posted their details to reset their password if ($_POST) { // 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') + 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) ->uses(2) diff --git a/application/classes/controller/logout.php b/application/classes/Controller/Logout.php similarity index 100% rename from application/classes/controller/logout.php rename to application/classes/Controller/Logout.php diff --git a/application/classes/controller/media.php b/application/classes/Controller/Media.php similarity index 100% rename from application/classes/controller/media.php rename to application/classes/Controller/Media.php diff --git a/application/classes/controller/module.php b/application/classes/Controller/Module.php similarity index 100% rename from application/classes/controller/module.php rename to application/classes/Controller/Module.php diff --git a/application/classes/controller/task.php b/application/classes/Controller/Task.php similarity index 100% rename from application/classes/controller/task.php rename to application/classes/Controller/Task.php diff --git a/application/classes/controller/templatedefault.php b/application/classes/Controller/TemplateDefault.php similarity index 100% rename from application/classes/controller/templatedefault.php rename to application/classes/Controller/TemplateDefault.php diff --git a/application/classes/controller/templatedefault/admin.php b/application/classes/Controller/TemplateDefault/Admin.php similarity index 100% rename from application/classes/controller/templatedefault/admin.php rename to application/classes/Controller/TemplateDefault/Admin.php diff --git a/application/classes/controller/templatedefault/affiliate.php b/application/classes/Controller/TemplateDefault/Affiliate.php similarity index 100% rename from application/classes/controller/templatedefault/affiliate.php rename to application/classes/Controller/TemplateDefault/Affiliate.php diff --git a/application/classes/controller/templatedefault/user.php b/application/classes/Controller/TemplateDefault/User.php similarity index 92% rename from application/classes/controller/templatedefault/user.php rename to application/classes/Controller/TemplateDefault/User.php index bce5af1f..ad274530 100644 --- a/application/classes/controller/templatedefault/user.php +++ b/application/classes/Controller/TemplateDefault/User.php @@ -35,8 +35,8 @@ class Controller_TemplateDefault_User extends Controller_TemplateDefault { $dc = 'welcome/index'; $m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller()); - Breadcrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE); - Breadcrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE); + BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE); + BreadCrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE); parent::after(); } diff --git a/application/classes/controller/tree.php b/application/classes/Controller/Tree.php similarity index 99% rename from application/classes/controller/tree.php rename to application/classes/Controller/Tree.php index c568978b..a4cae5d8 100644 --- a/application/classes/controller/tree.php +++ b/application/classes/Controller/Tree.php @@ -46,7 +46,7 @@ class Controller_Tree extends lnApp_Controller_Tree { if (preg_match('/_/',$id)) list($id,$idx) = explode('_',$id,2); - $mo = ORM::factory('module',$id); + $mo = ORM::factory('Module',$id); $methods = array(); if ($mo->loaded()) { diff --git a/application/classes/controller/user/account.php b/application/classes/Controller/User/Account.php similarity index 98% rename from application/classes/controller/user/account.php rename to application/classes/Controller/User/Account.php index b10538f5..7c43e560 100644 --- a/application/classes/controller/user/account.php +++ b/application/classes/Controller/User/Account.php @@ -38,7 +38,7 @@ class Controller_User_Account extends Controller_TemplateDefault_User { // Log the password reset $this->ao->log('Password reset'); - Request::current()->redirect('login'); + HTTP::redirect('login'); } else { $output = ''; diff --git a/application/classes/controller/user/welcome.php b/application/classes/Controller/User/Welcome.php similarity index 90% rename from application/classes/controller/user/welcome.php rename to application/classes/Controller/User/Welcome.php index 959f46f0..34e87f27 100644 --- a/application/classes/controller/user/welcome.php +++ b/application/classes/Controller/User/Welcome.php @@ -16,7 +16,7 @@ class Controller_User_Welcome extends Controller_TemplateDefault_User { ); public function action_index() { - $ao = ORM::factory('account',Auth::instance()->get_user()->id); + $ao = ORM::factory('Account',Auth::instance()->get_user()->id); Block::add(array( 'title'=>sprintf('%s: %s %s',$ao->accnum(),$ao->first_name,$ao->last_name), diff --git a/application/classes/controller/welcome.php b/application/classes/Controller/Welcome.php similarity index 81% rename from application/classes/controller/welcome.php rename to application/classes/Controller/Welcome.php index 6e1ffcb0..e47a2f07 100644 --- a/application/classes/controller/welcome.php +++ b/application/classes/Controller/Welcome.php @@ -14,11 +14,11 @@ class Controller_Welcome extends Controller_TemplateDefault { protected $auth_required = FALSE; public function action_index() { - if (! Kohana::config('config.appname')) - Request::current()->redirect('guide/app'); + if (! Kohana::$config->load('config')->appname) + HTTP::redirect('guide/app'); // @todo This should be in the DB or something. - Request::current()->redirect('product/categorys'); + HTTP::redirect('product/categorys'); } public function action_breadcrumb() { diff --git a/application/classes/Cookie.php b/application/classes/Cookie.php new file mode 100644 index 00000000..2364f9dc --- /dev/null +++ b/application/classes/Cookie.php @@ -0,0 +1,16 @@ + diff --git a/application/classes/country.php b/application/classes/Country.php similarity index 92% rename from application/classes/country.php rename to application/classes/Country.php index 0ecf449b..c22b14fb 100644 --- a/application/classes/country.php +++ b/application/classes/Country.php @@ -12,7 +12,7 @@ */ class Country { public static function icon($cid) { - $co = ORM::factory('country',$cid); + $co = ORM::factory('Country',$cid); return HTML::image(sprintf('media/img/country/%s.png',strtolower($co->two_code)),array('alt'=>$co->currency()->symbol)); } diff --git a/application/classes/currency.php b/application/classes/Currency.php similarity index 100% rename from application/classes/currency.php rename to application/classes/Currency.php diff --git a/application/classes/db.php b/application/classes/DB.php similarity index 100% rename from application/classes/db.php rename to application/classes/DB.php diff --git a/application/classes/database/mysql.php b/application/classes/Database/Mysql.php similarity index 100% rename from application/classes/database/mysql.php rename to application/classes/Database/Mysql.php diff --git a/application/classes/editor.php b/application/classes/Editor.php similarity index 100% rename from application/classes/editor.php rename to application/classes/Editor.php diff --git a/application/classes/form.php b/application/classes/Form.php similarity index 100% rename from application/classes/form.php rename to application/classes/Form.php diff --git a/application/classes/html.php b/application/classes/HTML.php similarity index 100% rename from application/classes/html.php rename to application/classes/HTML.php diff --git a/application/classes/htmlrender.php b/application/classes/HTMLRender.php similarity index 100% rename from application/classes/htmlrender.php rename to application/classes/HTMLRender.php diff --git a/application/classes/http/exception/404.php b/application/classes/HTTP/Exception/404.php similarity index 78% rename from application/classes/http/exception/404.php rename to application/classes/HTTP/Exception/404.php index acf76bef..138a58dc 100644 --- a/application/classes/http/exception/404.php +++ b/application/classes/HTTP/Exception/404.php @@ -11,10 +11,10 @@ * @license http://dev.leenooks.net/license.html */ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 { - public function __construct($message, array $variables = NULL, $code = 0) + public function __construct($message = NULL, array $variables = NULL, Exception $previous = NULL) { set_exception_handler(array(get_class($this),'handler')); - parent::__construct($message, $variables, (int) $code); + parent::__construct($message, $variables, $previous); } public static function handler(Exception $e) @@ -25,7 +25,7 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 { 'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()), )); - Request::factory()->redirect('welcome'); + HTTP::redirect('welcome'); } } ?> diff --git a/application/classes/headimages.php b/application/classes/HeadImages.php similarity index 100% rename from application/classes/headimages.php rename to application/classes/HeadImages.php diff --git a/application/classes/kohana.php b/application/classes/Kohana.php similarity index 63% rename from application/classes/kohana.php rename to application/classes/Kohana.php index 811cd74d..ec5c80b8 100644 --- a/application/classes/kohana.php +++ b/application/classes/Kohana.php @@ -10,7 +10,23 @@ * @copyright (c) 2010 Deon George * @license http://dev.leenooks.net/license.html */ -class Kohana extends Kohana_Core { +abstract class Kohana extends Kohana_Core { + /** + * @compat Restore KH 3.1 functionality + * @var boolean True if Kohana is running from the command line + */ + public static $is_cli = FALSE; + + /** + * @compat Restore KH 3.1 functionality + */ + public static function init(array $settings = NULL) { + parent::init($settings); + + // Determine if we are running in a command line environment + Kohana::$is_cli = (PHP_SAPI === 'cli'); + } + /** * Override Kohana's shutdown_handler() * @@ -22,7 +38,7 @@ class Kohana extends Kohana_Core { public static function shutdown_handler() { // If caching isnt enabled, we can skip this anyway if (! Kohana::$caching) - return parent::shutdown_handler();; + return parent::shutdown_handler(); Kohana::$caching = FALSE; $result = parent::shutdown_handler(); diff --git a/application/classes/meta.php b/application/classes/Meta.php similarity index 100% rename from application/classes/meta.php rename to application/classes/Meta.php diff --git a/application/classes/Minion/Task.php b/application/classes/Minion/Task.php new file mode 100644 index 00000000..789a02a1 --- /dev/null +++ b/application/classes/Minion/Task.php @@ -0,0 +1,18 @@ +NULL, + ); +} +?> diff --git a/application/classes/model/account.php b/application/classes/Model/Account.php similarity index 98% rename from application/classes/model/account.php rename to application/classes/Model/Account.php index ae40d6ea..e9caf175 100644 --- a/application/classes/model/account.php +++ b/application/classes/Model/Account.php @@ -79,7 +79,7 @@ class Model_Account extends Model_Auth_UserDefault { public function isAdmin() { // @todo Define admins in the config file or DB - $admins = array(ORM::factory('group',array('name'=>'Root'))); + $admins = array(ORM::factory('Group',array('name'=>'Root'))); return $this->has('group',$admins); } @@ -124,7 +124,7 @@ class Model_Account extends Model_Auth_UserDefault { public function log($message) { // Log the logout - $alo = ORM::factory('account_log'); + $alo = ORM::factory('Account_Log'); $alo->account_id = $this->id; $alo->ip = Request::$client_ip; $alo->details = $message; diff --git a/application/classes/model/account/log.php b/application/classes/Model/Account/Log.php similarity index 100% rename from application/classes/model/account/log.php rename to application/classes/Model/Account/Log.php diff --git a/modules/task/classes/controller/task.php b/application/classes/Model/Affiliate.php similarity index 53% rename from modules/task/classes/controller/task.php rename to application/classes/Model/Affiliate.php index 7a842f64..bca497f3 100644 --- a/modules/task/classes/controller/task.php +++ b/application/classes/Model/Affiliate.php @@ -1,15 +1,15 @@ diff --git a/application/classes/model/auth/roledefault.php b/application/classes/Model/Auth/RoleDefault.php similarity index 100% rename from application/classes/model/auth/roledefault.php rename to application/classes/Model/Auth/RoleDefault.php diff --git a/application/classes/model/auth/userdefault.php b/application/classes/Model/Auth/UserDefault.php similarity index 94% rename from application/classes/model/auth/userdefault.php rename to application/classes/Model/Auth/UserDefault.php index 2a7f9d81..b6aa1521 100644 --- a/application/classes/model/auth/userdefault.php +++ b/application/classes/Model/Auth/UserDefault.php @@ -59,13 +59,6 @@ class Model_Auth_UserDefault extends Model_Auth_User { return $this->log('Logged In'); } - /** - * Test to see if a record has been changed - */ - public function changed() { - return (count($this->_changed)); - } - /** * Debug function to see that has() finds * @todo This function could be removed diff --git a/application/classes/model/country.php b/application/classes/Model/Country.php similarity index 85% rename from application/classes/model/country.php rename to application/classes/Model/Country.php index 1458f673..52cd7ea0 100644 --- a/application/classes/model/country.php +++ b/application/classes/Model/Country.php @@ -12,7 +12,7 @@ */ class Model_Country extends ORM_OSB { public function currency() { - return ORM::factory('currency')->where('country_id','=',$this->id)->find(); + return ORM::factory('Currency')->where('country_id','=',$this->id)->find(); } } ?> diff --git a/application/classes/model/currency.php b/application/classes/Model/Currency.php similarity index 100% rename from application/classes/model/currency.php rename to application/classes/Model/Currency.php diff --git a/application/classes/model/group.php b/application/classes/Model/Group.php similarity index 93% rename from application/classes/model/group.php rename to application/classes/Model/Group.php index a9fef7aa..64788183 100644 --- a/application/classes/model/group.php +++ b/application/classes/Model/Group.php @@ -47,7 +47,7 @@ class Model_Group extends Model_Auth_RoleDefault { if (! $this->loaded()) return $return; - foreach (ORM::factory('group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) { + foreach (ORM::factory('Group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) { array_push($return,$go); $return = array_merge($return,$go->list_childgrps()); @@ -69,7 +69,7 @@ class Model_Group extends Model_Auth_RoleDefault { if (! $this->loaded()) return $return; - foreach (ORM::factory('group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) { + foreach (ORM::factory('Group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) { array_push($return,$go); $return = array_merge($return,$go->list_parentgrps()); diff --git a/application/classes/model/group/method.php b/application/classes/Model/Group/Method.php similarity index 100% rename from application/classes/model/group/method.php rename to application/classes/Model/Group/Method.php diff --git a/application/classes/model/language.php b/application/classes/Model/Language.php similarity index 100% rename from application/classes/model/language.php rename to application/classes/Model/Language.php diff --git a/application/classes/model/module.php b/application/classes/Model/Module.php similarity index 88% rename from application/classes/model/module.php rename to application/classes/Model/Module.php index 183125d5..4fe6fa80 100644 --- a/application/classes/model/module.php +++ b/application/classes/Model/Module.php @@ -35,5 +35,9 @@ class Model_Module extends ORM_OSB { array('StaticList_YesNo::display',array(':value')), ), ); + + public function list_external() { + return $this->_where_active()->where('external','=',TRUE)->find_all(); + } } ?> diff --git a/application/classes/model/module/method.php b/application/classes/Model/Module/Method.php similarity index 100% rename from application/classes/model/module/method.php rename to application/classes/Model/Module/Method.php diff --git a/application/classes/model/module/method/token.php b/application/classes/Model/Module/Method/Token.php similarity index 90% rename from application/classes/model/module/method/token.php rename to application/classes/Model/Module/Method/Token.php index 48b56d5b..347ce546 100644 --- a/application/classes/model/module/method/token.php +++ b/application/classes/Model/Module/Method/Token.php @@ -28,9 +28,9 @@ class Model_Module_Method_Token extends ORM_OSB { if (! $method instanceof Model_Module_Method) { if (is_numeric($module)) - $mo = ORM::factory('module',$module); + $mo = ORM::factory('Module',$module); elseif (is_string($module)) - $mo = ORM::factory('module',array('name'=>$module)); + $mo = ORM::factory('Module',array('name'=>$module)); elseif (! $module instanceof Model_Module) throw new Kohana_Exception('Unknown module :module',array(':module'=>serialize($module))); else @@ -40,9 +40,9 @@ class Model_Module_Method_Token extends ORM_OSB { throw new Kohana_Exception('Unknown module :module - not loaded?',array(':module'=>$mo->id)); if (is_numeric($method)) - $mmo = ORM::factory('module_method',$method); + $mmo = ORM::factory('Module_Method',$method); elseif (is_string($method)) - $mmo = ORM::factory('module_method',array('name'=>$method,'module_id'=>$mo->id)); + $mmo = ORM::factory('Module_Method',array('name'=>$method,'module_id'=>$mo->id)); else throw new Kohana_Exception('Unknown method :method',array(':method'=>serialize($method))); } else @@ -59,7 +59,7 @@ class Model_Module_Method_Token extends ORM_OSB { public function account($account) { if (! $account instanceof Model_Account) { if (is_numeric($account)) - $ao = ORM::factory('account',$account); + $ao = ORM::factory('Account',$account); else throw new Kohana_Exception('Unknown account :account',array(':account'=>serialize($account))); } else @@ -88,7 +88,7 @@ class Model_Module_Method_Token extends ORM_OSB { return NULL; // Check we dont already have a valid token - $mmto = ORM::factory('module_method_token') + $mmto = ORM::factory('Module_Method_Token') ->where('account_id','=',$this->account_id) ->where('method_id','=',$this->method_id) ->find(); diff --git a/application/classes/model/record/id.php b/application/classes/Model/Record/Id.php similarity index 96% rename from application/classes/model/record/id.php rename to application/classes/Model/Record/Id.php index 926964ae..df7af859 100644 --- a/application/classes/model/record/id.php +++ b/application/classes/Model/Record/Id.php @@ -21,7 +21,7 @@ class Model_Record_Id extends ORM_OSB { $this->module_id = $mid; // We'll get the next ID as the MAX(id) of the table - $mo = ORM::factory('module',$mid); + $mo = ORM::factory('Module',$mid); $max = DB::select(array('MAX(id)','id')) ->from($mo->name) diff --git a/application/classes/model/setup.php b/application/classes/Model/Setup.php similarity index 97% rename from application/classes/model/setup.php rename to application/classes/Model/Setup.php index 4b1f8ec8..99aa03ec 100644 --- a/application/classes/model/setup.php +++ b/application/classes/Model/Setup.php @@ -42,7 +42,7 @@ class Model_Setup extends ORM_OSB { if (! $this->loaded() OR (is_null($value) AND ! $this->module_config)) return array(); - $mo = ORM::factory('module')->where('name','=',$key)->find(); + $mo = ORM::factory('Module')->where('name','=',$key)->find(); if (! $mo->loaded()) throw new Kohana_Exception('Unknown module :name',array(':name'=>$key)); diff --git a/application/classes/orm.php b/application/classes/ORM.php similarity index 64% rename from application/classes/orm.php rename to application/classes/ORM.php index f288d1dd..e5b23d1b 100644 --- a/application/classes/orm.php +++ b/application/classes/ORM.php @@ -22,7 +22,7 @@ abstract class ORM extends Kohana_ORM { final protected function _build($type) { // Exclude tables without site ID's if (! in_array($this->_table_name,Config::$no_site_id_tables)) - $this->where($this->_table_name.'.site_id','=',Config::siteid()); + $this->where($this->_object_name.'.site_id','=',Config::siteid()); return parent::_build($type); } @@ -58,12 +58,22 @@ abstract class ORM extends Kohana_ORM { } /** - * Override KH's ORM has() function, to include our site_id in the query. + * Override KH's ORM count_relations() function, to include our site_id in the query. * - * This is a copy of KH's ORM has() function, with the addition of a where + * This is a copy of KH's ORM count_relations() function, with the addition of a where * clause to include the site id. */ - public function has($alias, $far_keys) { + public function count_relations($alias, $far_keys = NULL) + { + if ($far_keys === NULL) + { + return (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found')) + ->from($this->_has_many[$alias]['through']) + ->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk()) + ->where('site_id', '=', Config::siteid()) + ->execute($this->_db)->get('records_found'); + } + $far_keys = ($far_keys instanceof ORM) ? $far_keys->pk() : $far_keys; // We need an array to simplify the logic @@ -71,9 +81,9 @@ abstract class ORM extends Kohana_ORM { // Nothing to check if the model isn't loaded or we don't have any far_keys if ( ! $far_keys OR ! $this->_loaded) - return FALSE; + return 0; - $count = (int) DB::select(array('COUNT("*")', 'records_found')) + $count = (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found')) ->from($this->_has_many[$alias]['through']) ->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk()) ->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys) @@ -81,32 +91,7 @@ abstract class ORM extends Kohana_ORM { ->execute($this->_db)->get('records_found'); // Rows found need to match the rows searched - return $count === count($far_keys); - } - - /** - * Tests if this object has a relationship to a different model, - * or an array of different models. - * - * // Check for any of the following roles - * $model->has('roles', array(1, 2, 3, 4)); - * - * @param string $alias Alias of the has_many "through" relationship - * @param mixed $far_keys An array of primary keys - * @return Database_Result - */ - public function has_any($alias, array $far_keys) { - // Nothing to check if the model isn't loaded or we don't have any far_keys - if ( ! $far_keys) - return FALSE; - - // Rows found need to match the rows searched - return (int) DB::select(array('COUNT("*")', 'records_found')) - ->from($this->_has_many[$alias]['through']) - ->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk()) - ->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys) - ->where('site_id', '=', Config::siteid()) - ->execute($this->_db)->get('records_found'); + return (int) $count; } protected function _where_active() { @@ -116,6 +101,5 @@ abstract class ORM extends Kohana_ORM { public function where_active() { return $this->_where_active(); } - } ?> diff --git a/application/classes/ORM/OSB.php b/application/classes/ORM/OSB.php index 6ce16d06..2f3afd4b 100644 --- a/application/classes/ORM/OSB.php +++ b/application/classes/ORM/OSB.php @@ -80,7 +80,7 @@ abstract class ORM_OSB extends ORM { $model->_changed[$field] = $field; - $ido = ORM::factory('module') + $ido = ORM::factory('Module') ->where('name','=',$model->_table_name) ->find(); diff --git a/application/classes/pwgen.php b/application/classes/PWgen.php similarity index 100% rename from application/classes/pwgen.php rename to application/classes/PWgen.php diff --git a/application/classes/period.php b/application/classes/Period.php similarity index 100% rename from application/classes/period.php rename to application/classes/Period.php diff --git a/application/classes/random.php b/application/classes/Random.php similarity index 100% rename from application/classes/random.php rename to application/classes/Random.php diff --git a/application/classes/response.php b/application/classes/Response.php similarity index 100% rename from application/classes/response.php rename to application/classes/Response.php diff --git a/application/classes/script.php b/application/classes/Script.php similarity index 100% rename from application/classes/script.php rename to application/classes/Script.php diff --git a/application/classes/sort.php b/application/classes/Sort.php similarity index 100% rename from application/classes/sort.php rename to application/classes/Sort.php diff --git a/application/classes/staticlist.php b/application/classes/StaticList.php similarity index 100% rename from application/classes/staticlist.php rename to application/classes/StaticList.php diff --git a/application/classes/staticlist/module.php b/application/classes/StaticList/Module.php similarity index 100% rename from application/classes/staticlist/module.php rename to application/classes/StaticList/Module.php diff --git a/application/classes/staticlist/pricetype.php b/application/classes/StaticList/PriceType.php similarity index 100% rename from application/classes/staticlist/pricetype.php rename to application/classes/StaticList/PriceType.php diff --git a/application/classes/staticlist/recurschedule.php b/application/classes/StaticList/RecurSchedule.php similarity index 100% rename from application/classes/staticlist/recurschedule.php rename to application/classes/StaticList/RecurSchedule.php diff --git a/application/classes/staticlist/recurtype.php b/application/classes/StaticList/RecurType.php similarity index 100% rename from application/classes/staticlist/recurtype.php rename to application/classes/StaticList/RecurType.php diff --git a/application/classes/staticlist/sweeptype.php b/application/classes/StaticList/SweepType.php similarity index 100% rename from application/classes/staticlist/sweeptype.php rename to application/classes/StaticList/SweepType.php diff --git a/application/classes/staticlist/title.php b/application/classes/StaticList/Title.php similarity index 100% rename from application/classes/staticlist/title.php rename to application/classes/StaticList/Title.php diff --git a/application/classes/staticlist/yesno.php b/application/classes/StaticList/YesNo.php similarity index 100% rename from application/classes/staticlist/yesno.php rename to application/classes/StaticList/YesNo.php diff --git a/application/classes/staticlistmodule.php b/application/classes/StaticListModule.php similarity index 100% rename from application/classes/staticlistmodule.php rename to application/classes/StaticListModule.php diff --git a/application/classes/style.php b/application/classes/Style.php similarity index 100% rename from application/classes/style.php rename to application/classes/Style.php diff --git a/application/classes/systemmessage.php b/application/classes/SystemMessage.php similarity index 100% rename from application/classes/systemmessage.php rename to application/classes/SystemMessage.php diff --git a/application/classes/table.php b/application/classes/Table.php similarity index 100% rename from application/classes/table.php rename to application/classes/Table.php diff --git a/application/classes/Task.php b/application/classes/Task.php new file mode 100644 index 00000000..0d10935d --- /dev/null +++ b/application/classes/Task.php @@ -0,0 +1,19 @@ +NULL, + 'id'=>NULL, + ); +} +?> diff --git a/application/classes/valid.php b/application/classes/Valid.php similarity index 93% rename from application/classes/valid.php rename to application/classes/Valid.php index d76a083c..ba42a612 100644 --- a/application/classes/valid.php +++ b/application/classes/Valid.php @@ -9,7 +9,7 @@ * @copyright (c) 2010 Deon George * @license http://dev.leenooks.net/license.html */ -class Valid extends Kohana_Valid { +abstract class Valid extends Kohana_Valid { /** * Checks if a field matches the value of another field, if it is set. * Field is ignored if it is blank. diff --git a/application/classes/xml.php b/application/classes/XML.php similarity index 100% rename from application/classes/xml.php rename to application/classes/XML.php diff --git a/application/classes/cache.php b/application/classes/cache.php deleted file mode 100644 index 09c92e3e..00000000 --- a/application/classes/cache.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/application/classes/lnapp/block.php b/application/classes/lnApp/Block.php similarity index 100% rename from application/classes/lnapp/block.php rename to application/classes/lnApp/Block.php diff --git a/application/classes/lnapp/block/sub.php b/application/classes/lnApp/Block/Sub.php similarity index 100% rename from application/classes/lnapp/block/sub.php rename to application/classes/lnApp/Block/Sub.php diff --git a/application/classes/lnapp/breadcrumb.php b/application/classes/lnApp/BreadCrumb.php similarity index 86% rename from application/classes/lnapp/breadcrumb.php rename to application/classes/lnApp/BreadCrumb.php index 8bcf4021..8671b636 100644 --- a/application/classes/lnapp/breadcrumb.php +++ b/application/classes/lnApp/BreadCrumb.php @@ -1,7 +1,7 @@ '; diff --git a/application/classes/lnapp/config.php b/application/classes/lnApp/Config.php similarity index 81% rename from application/classes/lnapp/config.php rename to application/classes/lnApp/Config.php index 36b68fbd..75acf1a3 100644 --- a/application/classes/lnapp/config.php +++ b/application/classes/lnApp/Config.php @@ -24,13 +24,6 @@ abstract class lnApp_Config extends Kohana_Config { public function __construct() { if (defined('PHPUNITTEST')) $_SERVER['SERVER_NAME'] = PHPUNITTEST; - - elseif (Kohana::$is_cli) { - if (! $site = CLI::options('site')) - throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI')); - else - $_SERVER['SERVER_NAME'] = $site['site']; - } } /** @@ -44,14 +37,14 @@ abstract class lnApp_Config extends Kohana_Config { * Work out our site ID for multiehosting */ public static function siteid() { - return Kohana::Config('config.site.id'); + return Kohana::$config->load('config.site.id'); } /** * Work out our site mode (dev,test,prod) */ public static function sitemode() { - return Kohana::Config('config.site.mode'); + return Kohana::$config->load('config.site.mode'); } public static function sitemodeverbose() { @@ -66,13 +59,13 @@ abstract class lnApp_Config extends Kohana_Config { } public static function submode() { - $submode = Kohana::Config('config.debug.submode'); + $submode = Kohana::$config->load('config.debug.submode'); return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE; } public static function sitename() { - return Kohana::Config('config.site.name'); + return Kohana::$config->load('config')->site_name; } // Called in Invoice/Emailing to embed the file. @@ -98,21 +91,21 @@ abstract class lnApp_Config extends Kohana_Config { * Return our caching mechanism */ public static function cachetype() { - return is_null(Kohana::config('config.cache_type')) ? 'file' : Kohana::config('config.cache_type'); + return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type; } /** * Show a date using a site configured format */ public static function date($date) { - return $date ? date(Kohana::config('config.date_format'),$date) : '>Not Set<'; + return $date ? date(Kohana::$config->load('config')->date_format,$date) : '>Not Set<'; } /** * Show a date using a site configured format */ public static function time($date) { - return date(Kohana::config('config.time_format'),$date); + return date(Kohana::$config->load('config')->time_format,$date); } /** @@ -129,7 +122,7 @@ abstract class lnApp_Config extends Kohana_Config { * @return mixed|array - Email to send test emails to */ public static function testmail($template) { - $config = Kohana::config('config.email_admin_only'); + $config = Kohana::$config->load('config')->email_admin_only; if (is_null($config) OR ! is_array($config) OR empty($config[$template])) return FALSE; @@ -138,7 +131,7 @@ abstract class lnApp_Config extends Kohana_Config { } public static function theme() { - return Kohana::config('config.theme'); + return Kohana::$config->load('config')->theme; } } ?> diff --git a/application/classes/lnapp/controller/default.php b/application/classes/lnApp/Controller/Default.php similarity index 92% rename from application/classes/lnapp/controller/default.php rename to application/classes/lnApp/Controller/Default.php index c90af833..350e87b2 100644 --- a/application/classes/lnapp/controller/default.php +++ b/application/classes/lnApp/Controller/Default.php @@ -52,7 +52,7 @@ abstract class lnApp_Controller_Default extends Controller { */ protected function _auth_required() { // If our global configurable is disabled, then continue - if (! Kohana::Config('config.method_security')) + if (! Kohana::$config->load('config')->method_security) return FALSE; return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) || @@ -71,11 +71,11 @@ abstract class lnApp_Controller_Default extends Controller { // For no AJAX/JSON requests, display an access page } elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) { - Request::current()->redirect('login/noaccess'); + HTTP::redirect('login/noaccess'); } else { Session::instance()->set('afterlogin',Request::detect_uri()); - Request::current()->redirect($this->noauth_redirect); + HTTP::redirect($this->noauth_redirect); } } } @@ -84,7 +84,7 @@ abstract class lnApp_Controller_Default extends Controller { parent::after(); // Generate and check the ETag for this file - $this->response->check_cache(NULL,$this->request); + $this->check_cache(sha1($this->response->body())); } } ?> diff --git a/application/classes/lnApp/Controller/Login.php b/application/classes/lnApp/Controller/Login.php new file mode 100644 index 00000000..377d9ad0 --- /dev/null +++ b/application/classes/lnApp/Controller/Login.php @@ -0,0 +1,70 @@ +logged_in()!= 0) { + // Redirect to the user account + HTTP::redirect('user/welcome/index'); + } + + // If there is a post and $_POST is not empty + if ($_POST) { + // Store our details in a session key + Session::instance()->set(Kohana::$config->load('auth')->session_key,$_POST['username']); + Session::instance()->set('password',$_POST['password']); + + // If the post data validates using the rules setup in the user model + if (Auth::instance()->login($_POST['username'],$_POST['password'])) { + // Redirect to the user account + if ($redir = Session::instance()->get('afterlogin')) { + Session::instance()->delete('afterlogin'); + HTTP::redirect($redir); + + } else + HTTP::redirect('user/welcome/index'); + + } else { + SystemMessage::add(array( + 'title'=>_('Invalid username or password'), + 'type'=>'error', + 'body'=>_('The username or password was invalid.') + )); + } + } + + Block::add(array( + 'title'=>_('Login to server'), + 'body'=>View::factory('login'), + 'style'=>array('css/login.css'=>'screen'), + )); + + Script::add(array('type'=>'stdin','data'=>' + $(document).ready(function() { + $("#ajxbody").click(function() {$("#ajBODY").load("'.$this->request->uri().'/"); return false;}); + });' + )); + } + + public function action_noaccess() { + SystemMessage::add(array( + '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/controller/logout.php b/application/classes/lnApp/Controller/Logout.php similarity index 86% rename from application/classes/lnapp/controller/logout.php rename to application/classes/lnApp/Controller/Logout.php index 8295e06b..f67cdd1b 100644 --- a/application/classes/lnapp/controller/logout.php +++ b/application/classes/lnApp/Controller/Logout.php @@ -19,10 +19,10 @@ class lnApp_Controller_Logout extends Controller { Auth::instance()->logout(); $ao->log('Logged Out'); - Request::current()->redirect('login'); + HTTP::redirect('login'); } - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); } } ?> diff --git a/application/classes/lnapp/controller/media.php b/application/classes/lnApp/Controller/Media.php similarity index 93% rename from application/classes/lnapp/controller/media.php rename to application/classes/lnApp/Controller/Media.php index 2b231392..9503b00c 100644 --- a/application/classes/lnapp/controller/media.php +++ b/application/classes/lnApp/Controller/Media.php @@ -52,7 +52,8 @@ abstract class lnApp_Controller_Media extends Controller { } // Generate and check the ETag for this file - $this->response->check_cache(NULL,$this->request); + if (Kohana::$environment === Kohana::PRODUCTION OR Kohana::$config->load('debug')->etag) + $this->check_cache(sha1($this->response->body())); // Set the proper headers to allow caching $this->response->headers('Content-Type',File::mime_by_ext($ext)); diff --git a/application/classes/lnapp/controller/task.php b/application/classes/lnApp/Controller/Task.php similarity index 100% rename from application/classes/lnapp/controller/task.php rename to application/classes/lnApp/Controller/Task.php diff --git a/application/classes/lnapp/controller/templatedefault.php b/application/classes/lnApp/Controller/TemplateDefault.php similarity index 90% rename from application/classes/lnapp/controller/templatedefault.php rename to application/classes/lnApp/Controller/TemplateDefault.php index 94717310..239b46ee 100644 --- a/application/classes/lnapp/controller/templatedefault.php +++ b/application/classes/lnApp/Controller/TemplateDefault.php @@ -61,7 +61,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { */ protected function _auth_required() { // If our global configurable is disabled, then continue - if (! Kohana::Config('config.method_security')) + if (! Kohana::$config->load('config')->method_security) return FALSE; return (($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE) || @@ -83,7 +83,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { } // Actions that start with ajax, should only be ajax - if (! Kohana::Config('debug.ajax') AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax()) + if (! Kohana::$config->load('debug')->ajax AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax()) die(); parent::before(); @@ -108,11 +108,11 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { echo _('You dont have enough permissions.'); die(); } else - Request::current()->redirect('login/noaccess'); + HTTP::redirect('login/noaccess'); } else { Session::instance()->set('afterlogin',Request::detect_uri()); - Request::current()->redirect($this->noauth_redirect); + HTTP::redirect($this->noauth_redirect); } } @@ -123,7 +123,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { } // Bind our template meta variable - $this->meta = new meta; + $this->meta = new Meta; View::bind_global('meta',$this->meta); // Add our logo @@ -159,10 +159,10 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { if ($this->auto_render) { // Application Title - if ($mo=ORM::factory('module',array('name'=>Request::current()->controller())) AND $mo->loaded()) - $this->meta->title = sprintf('%s: %s',Kohana::Config('config.appname'),$mo->display('name')); + if ($mo=ORM::factory('Module',array('name'=>Request::current()->controller())) AND $mo->loaded()) + $this->meta->title = sprintf('%s: %s',Kohana::$config->load('config')->appname,$mo->display('name')); else - $this->meta->title = Kohana::Config('config.appname'); + $this->meta->title = Kohana::$config->load('config')->appname; $this->template->title = ''; // Language @@ -196,7 +196,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { $this->response->bodyadd(Style::factory()); // Since we are ajax, we should re-render the breadcrumb - Session::instance()->set('breadcrumb',(string)Breadcrumb::factory()); + Session::instance()->set('breadcrumb',(string)BreadCrumb::factory()); $this->response->bodyadd(Script::add(array('type'=>'stdin','data'=>'$().ready($("#ajCONTROL").load("'.URL::site('welcome/breadcrumb').'",null,function(x,s,r) {}));'))); // In case there any javascript for this render. @@ -209,8 +209,8 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { parent::after(); // Generate and check the ETag for this file - if (Kohana::$environment === Kohana::PRODUCTION) - $this->response->check_cache(NULL,$this->request); + if (Kohana::$environment === Kohana::PRODUCTION OR Kohana::$config->load('debug')->etag) + $this->check_cache(sha1($this->response->body())); } /** @@ -258,15 +258,17 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { public function viewpath($plugin='') { $request = Request::current(); - $path = ''; - $path .= $request->controller(); + $path = $request->controller(); + if ($request->directory()) $path .= ($path ? '/' : '').$request->directory(); + if ($plugin) $path .= ($path ? '/' : '').$plugin; - $path .= ($path ? '/' : '').$request->action();; - return $path; + $path .= ($path ? '/' : '').$request->action(); + + return strtolower($path); } } ?> diff --git a/application/classes/lnapp/controller/tree.php b/application/classes/lnApp/Controller/Tree.php similarity index 100% rename from application/classes/lnapp/controller/tree.php rename to application/classes/lnApp/Controller/Tree.php diff --git a/application/classes/lnapp/html.php b/application/classes/lnApp/HTML.php similarity index 100% rename from application/classes/lnapp/html.php rename to application/classes/lnApp/HTML.php diff --git a/application/classes/lnapp/htmlrender.php b/application/classes/lnApp/HTMLRender.php similarity index 100% rename from application/classes/lnapp/htmlrender.php rename to application/classes/lnApp/HTMLRender.php diff --git a/application/classes/lnapp/headimages.php b/application/classes/lnApp/HeadImages.php similarity index 100% rename from application/classes/lnapp/headimages.php rename to application/classes/lnApp/HeadImages.php diff --git a/application/classes/lnapp/meta.php b/application/classes/lnApp/Meta.php similarity index 100% rename from application/classes/lnapp/meta.php rename to application/classes/lnApp/Meta.php diff --git a/application/classes/lnapp/pwgen.php b/application/classes/lnApp/PWgen.php similarity index 75% rename from application/classes/lnapp/pwgen.php rename to application/classes/lnApp/PWgen.php index db4d9331..c6c4862b 100644 --- a/application/classes/lnapp/pwgen.php +++ b/application/classes/lnApp/PWgen.php @@ -12,11 +12,11 @@ */ abstract class lnApp_PWgen { public static function get($pwonly=TRUE) { - if (! Kohana::Config('pwgen.host') OR ! Kohana::Config('pwgen.port')) - throw new Kohana_Exception('No configuration for host or port (:host/:port)',array(':host'=>Kohana::Config('pwgen.host'),':port'=>Kohana::Config('pwgen.port'))); + if (! Kohana::$config->load('pwgen')->host OR ! Kohana::$config->load('pwgen')->port) + throw new Kohana_Exception('No configuration for host or port (:host/:port)',array(':host'=>Kohana::$config->load('pwgen')->host,':port'=>Kohana::$config->load('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->load('pwgen')->host,Kohana::$config->load('pwgen')->port)) throw new Kohana_Exception('Unable to connect to password server'); // echo "Reading response:\n\n"; diff --git a/application/classes/lnapp/random.php b/application/classes/lnApp/Random.php similarity index 100% rename from application/classes/lnapp/random.php rename to application/classes/lnApp/Random.php diff --git a/application/classes/lnapp/script.php b/application/classes/lnApp/Script.php similarity index 100% rename from application/classes/lnapp/script.php rename to application/classes/lnApp/Script.php diff --git a/application/classes/lnapp/sort.php b/application/classes/lnApp/Sort.php similarity index 100% rename from application/classes/lnapp/sort.php rename to application/classes/lnApp/Sort.php diff --git a/application/classes/lnapp/style.php b/application/classes/lnApp/Style.php similarity index 100% rename from application/classes/lnapp/style.php rename to application/classes/lnApp/Style.php diff --git a/application/classes/lnapp/systemmessage.php b/application/classes/lnApp/SystemMessage.php similarity index 100% rename from application/classes/lnapp/systemmessage.php rename to application/classes/lnApp/SystemMessage.php diff --git a/application/classes/lnapp/table.php b/application/classes/lnApp/Table.php similarity index 100% rename from application/classes/lnapp/table.php rename to application/classes/lnApp/Table.php diff --git a/application/classes/lnapp/controller/login.php b/application/classes/lnapp/controller/login.php deleted file mode 100644 index 886cd590..00000000 --- a/application/classes/lnapp/controller/login.php +++ /dev/null @@ -1,193 +0,0 @@ -logged_in()!= 0) { - // Redirect to the user account - Request::current()->redirect('user/welcome/index'); - } - - // If there is a post and $_POST is not empty - if ($_POST) { - // Store our details in a session key - Session::instance()->set(Kohana::config('auth.session_key'),$_POST['username']); - Session::instance()->set('password',$_POST['password']); - - // If the post data validates using the rules setup in the user model - if (Auth::instance()->login($_POST['username'],$_POST['password'])) { - // Redirect to the user account - 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'), - 'type'=>'error', - 'body'=>_('The username or password was invalid.') - )); - } - } - - Block::add(array( - 'title'=>_('Login to server'), - 'body'=>View::factory('login'), - 'style'=>array('css/login.css'=>'screen'), - )); - - Script::add(array('type'=>'stdin','data'=>' - $(document).ready(function() { - $("#ajxbody").click(function() {$("#ajBODY").load("'.$this->request->uri().'/"); return false;}); - });' - )); - } - - public function action_register() { - // If user already signed-in - if (Auth::instance()->logged_in()!= 0) { - // Redirect to the user account - Request::current()->redirect('welcome/index'); - } - - // Instantiate a new user - $account = ORM::factory('account'); - - // If there is a post and $_POST is not empty - if ($_POST) { - // Check Auth - $status = $account->values($_POST)->check(); - - if (! $status) { - foreach ($account->validation()->errors('form/register') as $f => $r) { - // $r[0] has our reason for validation failure - switch ($r[0]) { - // Generic validation reason - default: - SystemMessage::add(array( - 'title'=>_('Validation failed'), - 'type'=>'error', - 'body'=>sprintf(_('The defaults on your submission were not valid for field %s (%s).'),$f,$r) - )); - } - } - } - - $ido = ORM::factory('module') - ->where('name','=','account') - ->find(); - - $account->id = $ido->record_id->next_id($ido->id); - // Save the user details - if ($account->save()) {} - - } - - SystemMessage::add(array( - 'title'=>_('Already have an account?'), - 'type'=>'info', - 'body'=>_('If you already have an account, please login..') - )); - - Block::add(array( - 'title'=>_('Register'), - 'body'=>View::factory('register') - ->set('account',$account) - ->set('errors',$account->validation()->errors('form/register')), - )); - - $this->template->left = HTML::anchor('login','Login').'...'; - } - - /** - * Enable user password reset - */ - public function action_reset() { - // Minutes to keep our token - $token_expire = 15; - - // If user already signed-in - if (Auth::instance()->logged_in()!= 0) { - // Redirect to the user account - Request::current()->redirect('welcome/index'); - } - - // If the user posted their details to reset their password - if ($_POST) { - // 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) - ->uses(2) - ->expire(time()+$token_expire*60); - - if ($mmto->generate()) { - // Send our email with the token - // @todo Need to provide an option if Email_Template is not installed/activited. - // @todo Need to provide an option if account_reset_password template doesnt exist. - $et = Email_Template::instance('account_reset_password'); - $et->to = array('account'=>array($mmto->account_id)); - $et->variables = array( - 'SITE'=>URL::base(TRUE,TRUE), - 'SITE_ADMIN'=>Config::sitename(), - 'SITE_NAME'=>Config::sitename(), - 'TOKEN'=>$mmto->token, - 'TOKEN_EXPIRE_MIN'=>$token_expire, - 'USER_NAME'=>sprintf('%s %s',$mmto->account->first_name,$mmto->account->last_name), - ); - $et->send(); - - // Log the password reset - $ao->log('Password reset token sent'); - } - - // Redirect to our password reset, the Auth will validate the token. - } elseif (! empty($_REQUEST['token'])) { - Request::current()->redirect(sprintf('user/account/resetpassword?token=%s',$_REQUEST['token'])); - } - - // Show our token screen even if the email was invalid. - if (isset($_POST['username'])) - Block::add(array( - 'title'=>_('Reset your password'), - 'body'=>View::factory('login_reset_sent'), - 'style'=>array('css/login.css'=>'screen'), - )); - else - Request::current()->redirect('login'); - - } else { - Block::add(array( - 'title'=>_('Reset your password'), - 'body'=>View::factory('login_reset'), - 'style'=>array('css/login.css'=>'screen'), - )); - } - } - - public function action_noaccess() { - SystemMessage::add(array( - '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/ormosb.php b/application/classes/ormosb.php deleted file mode 100644 index d25a22f5..00000000 --- a/application/classes/ormosb.php +++ /dev/null @@ -1,224 +0,0 @@ -'date_orig','format'=>TRUE); - protected $_updated_column = array('column'=>'date_last','format'=>TRUE); - - // Our attribute values that need to be stored as serialized - protected $_serialize_column = array(); - - // Our attributes used in forms. - protected $_form = array(); - - // Rules to assist with site ID and getting next record ID for inserts. - public function rules() { - return array( - 'id'=>array( - array('ORMOSB::get_next_id',array(':model',':field')), - ), - 'site_id'=>array( - array('ORMOSB::set_site_id',array(':model',':field')), - ), - ); - } - - /** - * This function will enhance the [Validate::filter], since it always passes - * the value as the first argument and sometimes functions need that to not - * be the first argument. - * - * Currently this implements: - * [date()][date-ref] - * - * [date-ref]: http://www.php.net/date - * - * This function will throw an exception if called without a function - * defined. - * - * @param mixed $val Value to be processed - * @param string $func Name of function to call - * @param string $arg Other arguments for the function - * @todo This has probably changed in KH 3.1 - */ - final public static function _filters($val,$func,$arg) { - switch ($func) { - case 'date': - return date($arg,$val); - default: - throw new Exception(sprintf(_('Unknown function: %s (%s,%s)'),$func,$arg,$val)); - } - } - - final public static function form($table,$blank=FALSE) { - return ORM::factory($table)->formselect($blank); - } - - /** - * Get Next record id - * - * @param array Validate object - * @param string Primary Key - */ - public static function get_next_id($model,$field) { - if (! is_null($model->$field)) - return TRUE; - - $model->_changed[$field] = $field; - - $ido = ORM::factory('module') - ->where('name','=',$model->_table_name) - ->find(); - - if (! $ido->loaded()) - throw new Kohana_Exception('Problem getting record_id for :table',array(':table'=>$model->_table_name)); - - $model->$field = $ido->record_id->next_id($ido->id); - - return TRUE; - } - - /** - * Set the site ID attribute for each row update - */ - public static function set_site_id($model,$field) { - if (! is_null($model->$field)) - return TRUE; - - $model->_changed[$field] = $field; - $model->$field = Config::siteid(); - - return TRUE; - } - - public function __get($column) { - if (array_key_exists($column,$this->_table_columns)) { - - // If the column is a blob, we'll decode it automatically - if ( - $this->_table_columns[$column]['data_type'] == 'blob' - AND ! is_null($this->_object[$column]) - AND ! isset($this->_changed[$column]) - AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert']) - ) { - - // In case our blob hasnt been saved as one. - try { - $this->_object[$column] = $this->blob($this->_object[$column]); - } - catch(Exception $e) { - // @todo Log this exception - echo Kohana_Exception::text($e), "\n"; - echo debug_print_backtrace(); - } - - $this->_table_columns[$column]['auto_convert'] = TRUE; - } - - // If the column is a serialized object, we'll unserialize it. - if ( - in_array($column,$this->_serialize_column) - AND is_string($this->_object[$column]) - AND ! is_null($this->_object[$column]) - AND ! isset($this->_changed[$column]) - AND (! isset($this->_table_columns[$column]['unserialized']) OR ! $this->_table_columns[$column]['unserialized']) - ) { - - // In case our object hasnt been saved as serialized. - try { - $this->_object[$column] = unserialize($this->_object[$column]); - } - catch(Exception $e) { - // @todo Log this exception - echo Kohana_Exception::text($e), "\n"; - echo debug_print_backtrace(); - } - - $this->_table_columns[$column]['unserialized'] = TRUE; - } - } - - return parent::__get($column); - } - - public function formselect($blank) { - $result = array(); - - if ($blank) - $result[] = ''; - - foreach ($this->find_all() as $o) - $result[$o->{$this->_form['id']}] = $o->{$this->_form['value']}; - - return $result; - } - - public function keyget($column,$key=NULL) { - if (is_null($key) OR ! is_array($this->$column)) - return $this->$column; - else - return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL; - } - - public function save(Validation $validation = NULL) { - // Find any fields that have changed, and process them. - if ($this->_changed) - foreach ($this->_changed as $c) - // Any fields that are blobs, and encode them. - if ($this->_table_columns[$c]['data_type'] == 'blob') { - $this->_object[$c] = $this->blob($this->_object[$c],TRUE); - - // We need to reset our auto_convert flag - if (isset($this->_table_columns[$c]['auto_convert'])) - $this->_table_columns[$c]['auto_convert'] = FALSE; - - // Any fields that should be seriailzed, we'll do that. - } elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) { - $this->_object[$c] = serialize($this->_object[$c]); - } - - return parent::save($validation); - } - - public function changed() { - return $this->_changed; - } - - /** - * Retrieve and Store DB BLOB data. - */ - private function blob($data,$set=FALSE) { - return $set ? gzcompress(serialize($data)) : unserialize(gzuncompress($data)); - } - - public function config($key) { - $mc = Config::instance()->so->module_config($this->_object_name); - - return empty($mc[$key]) ? '' : $mc[$key]; - } - - public function list_active() { - 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/config/debug.php b/application/config/debug.php index 70848b77..ac2fed04 100644 --- a/application/config/debug.php +++ b/application/config/debug.php @@ -13,6 +13,9 @@ return array ( - 'ajax'=>FALSE, // AJAX actions can only be run by ajax calls if set to FALSE + 'ajax'=>FALSE, // AJAX actions can only be run by ajax calls if set to FALSE + 'etag'=>FALSE, // Force generating ETAGS + 'invoice'=>0, // Number of invoices to generate in a pass + 'task_sim'=>FALSE, // Simulate running tasks ); ?> diff --git a/application/views/lnapp/default.php b/application/views/lnapp/default.php index 0937be98..a7e4fe5d 100644 --- a/application/views/lnapp/default.php +++ b/application/views/lnapp/default.php @@ -32,7 +32,7 @@
- +
diff --git a/application/views/yaml/page.php b/application/views/yaml/page.php index b6254f3e..38de4f14 100644 --- a/application/views/yaml/page.php +++ b/application/views/yaml/page.php @@ -51,7 +51,7 @@ diff --git a/includes/kohana/modules/cron/classes/kohana/cron.php b/includes/kohana/modules/cron/classes/kohana/cron.php index 2c28d29b..06320bc3 100644 --- a/includes/kohana/modules/cron/classes/kohana/cron.php +++ b/includes/kohana/modules/cron/classes/kohana/cron.php @@ -43,7 +43,7 @@ class Kohana_Cron */ protected static function _lock() { - $config = Kohana::config('cron'); + $config = Kohana::$config->load('cron'); $result = FALSE; if (file_exists($config->lock) AND ($stat = @stat($config->lock)) AND time() - $config->window < $stat['mtime']) @@ -80,7 +80,7 @@ class Kohana_Cron */ protected static function _save() { - Kohana::cache("Cron::run()", Cron::$_times, Kohana::config('cron')->window * 2); + Kohana::cache("Cron::run()", Cron::$_times, Kohana::$config->load('cron')->window * 2); } /** @@ -88,7 +88,7 @@ class Kohana_Cron */ protected static function _unlock() { - return @unlink(Kohana::config('cron')->lock); + return @unlink(Kohana::$config->load('cron')->lock); } /** @@ -107,7 +107,7 @@ class Kohana_Cron Cron::_load(); $now = time(); - $threshold = $now - Kohana::config('cron')->window; + $threshold = $now - Kohana::$config->load('cron')->window; foreach (Cron::$_jobs as $name => $job) { diff --git a/includes/kohana/modules/khemail/classes/email.php b/includes/kohana/modules/khemail/classes/email.php index 3b2d6f05..32ddec51 100644 --- a/includes/kohana/modules/khemail/classes/email.php +++ b/includes/kohana/modules/khemail/classes/email.php @@ -31,7 +31,7 @@ class Email { } // Load default configuration - ($config === NULL) and $config = Kohana::config('email'); + ($config === NULL) and $config = Kohana::$config->load('email'); switch ($config['driver']) { @@ -142,4 +142,4 @@ class Email { return Email::$mail->send($message); } -} // End email \ No newline at end of file +} // End email diff --git a/includes/kohana/modules/orm/classes/Kohana/ORM.php b/includes/kohana/modules/orm/classes/Kohana/ORM.php index 716e51d2..666af8a4 100644 --- a/includes/kohana/modules/orm/classes/Kohana/ORM.php +++ b/includes/kohana/modules/orm/classes/Kohana/ORM.php @@ -183,6 +183,15 @@ class Kohana_ORM extends Model implements serializable { */ protected $_table_names_plural = TRUE; + // Suppress ORMs inclusion of .* + protected $_disable_wild_select = FALSE; + + // Suppress ORMs inclusion of . to column joins + protected $_disable_join_table_name = FALSE; + + // Suppress ORMs use of limit + protected $_disable_limit = FALSE; + /** * Model configuration, reload on wakeup? * @var bool @@ -268,7 +277,7 @@ class Kohana_ORM extends Model implements serializable { else { // Passing the primary key - $this->where($this->_object_name.'.'.$this->_primary_key, '=', $id)->find(); + $this->where(($this->_disable_join_table_name ? '' : $this->_object_name.'.').$this->_primary_key, '=', $id)->find(); } } elseif ( ! empty($this->_cast_data)) @@ -351,6 +360,7 @@ class Kohana_ORM extends Model implements serializable { } $defaults['foreign_key'] = $this->_object_name.$this->_foreign_key_suffix; + $defaults['far_key'] = Inflector::singular($alias).$this->_foreign_key_suffix; $init['_has_one'][$alias] = array_merge($defaults, $details); } @@ -359,7 +369,7 @@ class Kohana_ORM extends Model implements serializable { { if ( ! isset($details['model'])) { - $defaults['model'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', Inflector::singular($alias)))); + $defaults['model'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', ($this->_model_names_plural ? Inflector::singular($alias) : $alias)))); } $defaults['foreign_key'] = $this->_object_name.$this->_foreign_key_suffix; @@ -626,7 +636,7 @@ class Kohana_ORM extends Model implements serializable { $model = $this->_related($column); // Use this model's column and foreign model's primary key - $col = $model->_object_name.'.'.$model->_primary_key; + $col = ($this->_disable_join_table_name ? '' : $model->_object_name.'.').$model->_primary_key; $val = $this->_object[$this->_belongs_to[$column]['foreign_key']]; // Make sure we don't run WHERE "AUTO_INCREMENT column" = NULL queries. This would @@ -643,9 +653,23 @@ class Kohana_ORM extends Model implements serializable { { $model = $this->_related($column); - // Use this model's primary key value and foreign model's column - $col = $model->_object_name.'.'.$this->_has_one[$column]['foreign_key']; - $val = $this->pk(); + if (! is_array($this->_has_one[$column]['foreign_key'])) + { + // Use this model's primary key value and foreign model's column + $col = ($this->_disable_join_table_name ? '' : $model->_object_name.'.').$this->_has_one[$column]['foreign_key']; + $val = $this->_object[$this->_has_one[$column]['far_key']]; + } + else + { + foreach ($this->_has_one[$column]['foreign_key'] as $fk) + { + // Simple has_many relationship, search where target model's foreign key is this model's primary key + $col = ($this->_disable_join_table_name ? '' : $model->_object_name.'.').$fk; + $val = $this->_object[$fk]; + + $model = $model->where($col, '=', $val); + } + } $model->where($col, '=', $val)->find(); @@ -655,29 +679,53 @@ class Kohana_ORM extends Model implements serializable { { $model = ORM::factory($this->_has_many[$column]['model']); - if (isset($this->_has_many[$column]['through'])) + if (! is_array($this->_has_many[$column]['foreign_key'])) { - // Grab has_many "through" relationship table - $through = $this->_has_many[$column]['through']; + if (isset($this->_has_many[$column]['through'])) + { + // Grab has_many "through" relationship table + $through = $this->_has_many[$column]['through']; - // Join on through model's target foreign key (far_key) and target model's primary key - $join_col1 = $through.'.'.$this->_has_many[$column]['far_key']; - $join_col2 = $model->_object_name.'.'.$model->_primary_key; + // Join on through model's target foreign key (far_key) and target model's primary key + $join_col1 = ($this->_disable_join_table_name ? '' : $through.'.').$this->_has_many[$column]['far_key']; + $join_col2 = ($this->_disable_join_table_name ? '' : $model->_object_name.'.').$model->_primary_key; - $model->join($through)->on($join_col1, '=', $join_col2); + $model->join($through)->on($join_col1, '=', $join_col2) + ->on(($this->_disable_join_table_name ? '' : $through.'.').'site_id', '=', ($this->_disable_join_table_name ? '' : $model->_object_name.'.').'site_id'); - // Through table's source foreign key (foreign_key) should be this model's primary key - $col = $through.'.'.$this->_has_many[$column]['foreign_key']; - $val = $this->pk(); + // Through table's source foreign key (foreign_key) should be this model's primary key + $col = ($this->_disable_join_table_name ? '' : $through.'.').$this->_has_many[$column]['foreign_key']; + $val = $this->pk(); + } + else + { + // Simple has_many relationship, search where target model's foreign key is this model's primary key + $col = ($this->_disable_join_table_name ? '' : $model->_object_name.'.').$this->_has_many[$column]['foreign_key']; + $val = $this->_object[$this->_has_many[$column]['far_key']]; + } + + return $model->where($col, '=', $val); } else { - // Simple has_many relationship, search where target model's foreign key is this model's primary key - $col = $model->_object_name.'.'.$this->_has_many[$column]['foreign_key']; - $val = $this->pk(); - } + foreach ($this->_has_many[$column]['foreign_key'] as $mk => $fk) + { + if (isset($this->_has_many[$column]['through'])) + { + throw new Kohana_Exception('This code hasnt been written yet!'); + } + else + { + // Simple has_many relationship, search where target model's foreign key is this model's primary key + $col = ($this->_disable_join_table_name ? '' : $model->_object_name.'.').$fk; + $val = $this->_object[$mk]; + } - return $model->where($col, '=', $val); + $model = $model->where($col, '=', $val); + } + + return $model; + } } else { @@ -1031,14 +1079,15 @@ class Kohana_ORM extends Model implements serializable { { $this->_db_builder->from(array($this->_table_name, $this->_object_name)); - if ($multiple === FALSE) + if ($multiple === FALSE AND ! $this->_disable_limit) { // Only fetch 1 record $this->_db_builder->limit(1); } // Select all columns by default - $this->_db_builder->select_array($this->_build_select()); + if (! $this->_disable_wild_select) + $this->_db_builder->select_array($this->_build_select()); if ( ! isset($this->_db_applied['order_by']) AND ! empty($this->_sorting)) { @@ -1047,7 +1096,7 @@ class Kohana_ORM extends Model implements serializable { if (strpos($column, '.') === FALSE) { // Sorting column for use in JOINs - $column = $this->_object_name.'.'.$column; + $column = ($this->_disable_join_table_name ? '' : $this->_object_name.'.').$column; } $this->_db_builder->order_by($column, $direction); @@ -1165,9 +1214,10 @@ class Kohana_ORM extends Model implements serializable { * @param string $value The value to filter * @return string */ - protected function run_filter($field, $value) + protected function run_filter($field, $value, $filters=NULL) { - $filters = $this->filters(); + if (is_null($filters)) + $filters = $this->filters(); // Get the filters for this column $wildcards = empty($filters[TRUE]) ? array() : $filters[TRUE]; diff --git a/includes/kohana/modules/pagination/classes/kohana/pagination.php b/includes/kohana/modules/pagination/classes/Kohana/Pagination.php similarity index 99% rename from includes/kohana/modules/pagination/classes/kohana/pagination.php rename to includes/kohana/modules/pagination/classes/Kohana/Pagination.php index 56b10d01..8f5d533b 100644 --- a/includes/kohana/modules/pagination/classes/kohana/pagination.php +++ b/includes/kohana/modules/pagination/classes/Kohana/Pagination.php @@ -111,7 +111,7 @@ class Kohana_Pagination { public function config_group($group = 'default') { // Load the pagination config file - $config_file = Kohana::config('pagination'); + $config_file = Kohana::$config->load('pagination'); // Initialize the $config array $config['group'] = (string) $group; @@ -332,4 +332,4 @@ class Kohana_Pagination { } } -} // End Pagination \ No newline at end of file +} // End Pagination diff --git a/includes/kohana/modules/pagination/classes/pagination.php b/includes/kohana/modules/pagination/classes/Pagination.php similarity index 100% rename from includes/kohana/modules/pagination/classes/pagination.php rename to includes/kohana/modules/pagination/classes/Pagination.php diff --git a/includes/kohana/modules/unittest/bootstrap.php b/includes/kohana/modules/unittest/bootstrap.php index 177dae15..2abe2389 100644 --- a/includes/kohana/modules/unittest/bootstrap.php +++ b/includes/kohana/modules/unittest/bootstrap.php @@ -15,13 +15,15 @@ $application = 'application'; */ $modules = 'modules'; +$sysmodules = 'includes/kohana/modules'; + /** * The directory in which the Kohana resources are located. The system * directory must contain the classes/kohana.php file. * * @link http://kohanaframework.org/guide/about.install#system */ -$system = 'system'; +$system = 'includes/kohana/system'; /** * The default extension of resource files. If you change this, all resources @@ -74,6 +76,12 @@ if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules)) $modules = DOCROOT.$modules; } +// Make the system relative to the docroot, for symlink'd index.php +if ( ! is_dir($sysmodules) AND is_dir(DOCROOT.$sysmodules)) +{ + $sysmodules = DOCROOT.$sysmodules; +} + // Make the system relative to the docroot if ( ! is_dir($system) AND is_dir(DOCROOT.$system)) { @@ -83,10 +91,11 @@ if ( ! is_dir($system) AND is_dir(DOCROOT.$system)) // Define the absolute paths for configured directories define('APPPATH', realpath($application).DIRECTORY_SEPARATOR); define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR); +define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR); define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR); // Clean up the configuration vars -unset($application, $modules, $system); +unset($application, $modules, $sysmodules, $system); /** * Define the start time of the application, used for profiling. @@ -104,6 +113,8 @@ if ( ! defined('KOHANA_START_MEMORY')) define('KOHANA_START_MEMORY', memory_get_usage()); } +define('PHPUNITTEST','192.168.242.3'); + // Bootstrap the application require APPPATH.'bootstrap'.EXT; @@ -122,4 +133,4 @@ if (($ob_len = ob_get_length()) !== FALSE) } // Enable the unittest module -Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest')); \ No newline at end of file +Kohana::modules(Kohana::modules() + array('unittest' => SMDPATH.'unittest')); diff --git a/includes/kohana/system/classes/Kohana/Debug.php b/includes/kohana/system/classes/Kohana/Debug.php index 9d1efdf5..ccc141dd 100644 --- a/includes/kohana/system/classes/Kohana/Debug.php +++ b/includes/kohana/system/classes/Kohana/Debug.php @@ -252,13 +252,17 @@ class Kohana_Debug { { $file = 'APPPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APPPATH)); } + elseif (strpos($file, MODPATH) === 0) + { + $file = 'MODPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(MODPATH)); + } elseif (strpos($file, SYSPATH) === 0) { $file = 'SYSPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYSPATH)); } - elseif (strpos($file, MODPATH) === 0) + elseif (strpos($file, SMDPATH) === 0) { - $file = 'MODPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(MODPATH)); + $file = 'SMDPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SMDPATH)); } elseif (strpos($file, DOCROOT) === 0) { diff --git a/includes/kohana/system/classes/Kohana/Request/Client/Curl.php b/includes/kohana/system/classes/Kohana/Request/Client/Curl.php index c5c85d31..84157291 100644 --- a/includes/kohana/system/classes/Kohana/Request/Client/Curl.php +++ b/includes/kohana/system/classes/Kohana/Request/Client/Curl.php @@ -64,7 +64,7 @@ class Kohana_Request_Client_Curl extends Request_Client_External { $this->_options[CURLOPT_HEADER] = FALSE; // Apply any additional options set to - $options += $this->_options; + $options = Arr::merge($options, $this->_options); $uri = $request->uri(); @@ -132,4 +132,4 @@ class Kohana_Request_Client_Curl extends Request_Client_External { return $options; } -} // End Kohana_Request_Client_Curl \ No newline at end of file +} // End Kohana_Request_Client_Curl diff --git a/includes/kohana/system/tests/kohana/CoreTest.php b/includes/kohana/system/tests/kohana/CoreTest.php index beb508bf..17d6a7ae 100644 --- a/includes/kohana/system/tests/kohana/CoreTest.php +++ b/includes/kohana/system/tests/kohana/CoreTest.php @@ -250,7 +250,7 @@ class Kohana_CoreTest extends Unittest_TestCase { return array( array(array('unittest' => MODPATH.'fo0bar')), - array(array('unittest' => MODPATH.'unittest', 'fo0bar' => MODPATH.'fo0bar')), + array(array('unittest' => SMDPATH.'unittest', 'fo0bar' => MODPATH.'fo0bar')), ); } @@ -292,7 +292,7 @@ class Kohana_CoreTest extends Unittest_TestCase { return array( array(array(), array()), - array(array('unittest' => MODPATH.'unittest'), array('unittest' => $this->dirSeparator(MODPATH.'unittest/'))), + array(array('unittest' => SMDPATH.'unittest'), array('unittest' => $this->dirSeparator(SMDPATH.'unittest/'))), ); } diff --git a/includes/kohana/system/tests/kohana/DebugTest.php b/includes/kohana/system/tests/kohana/DebugTest.php index 39176ec1..5bc7149e 100644 --- a/includes/kohana/system/tests/kohana/DebugTest.php +++ b/includes/kohana/system/tests/kohana/DebugTest.php @@ -59,8 +59,8 @@ class Kohana_DebugTest extends Unittest_TestCase 'SYSPATH'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'kohana.php' ), array( - MODPATH.$this->dirSeparator('unittest/classes/kohana/unittest/runner').EXT, - $this->dirSeparator('MODPATH/unittest/classes/kohana/unittest/runner').EXT + SMDPATH.$this->dirSeparator('unittest/classes/kohana/unittest/runner').EXT, + $this->dirSeparator('SMDPATH/unittest/classes/kohana/unittest/runner').EXT ), ); } diff --git a/index.php b/index.php index 6c352aa3..c7bb26f2 100644 --- a/index.php +++ b/index.php @@ -15,13 +15,18 @@ $application = 'application'; */ $modules = 'modules'; +/** + * The directory in which upstream Kohana resources (modules) are located. + */ +$sysmodules = 'includes/kohana/modules'; + /** * The directory in which the Kohana resources are located. The system * directory must contain the classes/kohana.php file. * * @link http://kohanaframework.org/guide/about.install#system */ -$system = 'system'; +$system = 'includes/kohana/system'; /** * The default extension of resource files. If you change this, all resources @@ -64,6 +69,10 @@ if ( ! is_dir($application) AND is_dir(DOCROOT.$application)) if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules)) $modules = DOCROOT.$modules; +// Make the system relative to the docroot, for symlink'd index.php +if ( ! is_dir($sysmodules) AND is_dir(DOCROOT.$sysmodules)) + $sysmodules = DOCROOT.$sysmodules; + // Make the system relative to the docroot, for symlink'd index.php if ( ! is_dir($system) AND is_dir(DOCROOT.$system)) $system = DOCROOT.$system; @@ -71,10 +80,11 @@ if ( ! is_dir($system) AND is_dir(DOCROOT.$system)) // Define the absolute paths for configured directories define('APPPATH', realpath($application).DIRECTORY_SEPARATOR); define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR); +define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR); define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR); // Clean up the configuration vars -unset($application, $modules, $system); +unset($application, $modules, $sysmodules, $system); if (file_exists('install'.EXT)) { diff --git a/modules/adsl/classes/adsl.php b/modules/adsl/classes/ADSL.php similarity index 98% rename from modules/adsl/classes/adsl.php rename to modules/adsl/classes/ADSL.php index 73dd1b10..db178bcd 100644 --- a/modules/adsl/classes/adsl.php +++ b/modules/adsl/classes/ADSL.php @@ -33,7 +33,7 @@ class ADSL { if (preg_match('/^a:/',$data)) throw new Kohana_Exception('Data shouldnt be a serialized array'); - $ao = ORM::factory('adsl_plan',$data); + $ao = ORM::factory('ADSL_Plan',$data); $output = View::factory('adsl/contract_view') ->set('record',$ao) ->set('price_base',$price_base) diff --git a/modules/adsl/classes/model/adsl/plan.php b/modules/adsl/classes/Model/ADSL/Plan.php similarity index 100% rename from modules/adsl/classes/model/adsl/plan.php rename to modules/adsl/classes/Model/ADSL/Plan.php diff --git a/modules/adsl/classes/model/adsl/supplier.php b/modules/adsl/classes/Model/ADSL/Supplier.php similarity index 86% rename from modules/adsl/classes/model/adsl/supplier.php rename to modules/adsl/classes/Model/ADSL/Supplier.php index dd642f5d..8e899aae 100644 --- a/modules/adsl/classes/model/adsl/supplier.php +++ b/modules/adsl/classes/Model/ADSL/Supplier.php @@ -13,7 +13,7 @@ class Model_ADSL_Supplier extends ORM_OSB { // Relationships protected $_has_many = array( - 'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'), + 'ADSL_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'), ); protected $_updated_column = FALSE; @@ -22,7 +22,7 @@ class Model_ADSL_Supplier extends ORM_OSB { * Return a list of plans that this supplier makes available */ public function plans($active=TRUE) { - $a = $this->adsl_supplier_plan; + $a = $this->ADSL_supplier_plan; if ($active) $a->where_active(); @@ -37,7 +37,7 @@ class Model_ADSL_Supplier extends ORM_OSB { $return = array(); foreach ($this->plans($active)->find_all() as $po) - foreach ($po->adsl_plan->find_all() as $apo) + foreach ($po->ADSL_plan->find_all() as $apo) $return[$apo->id] = $apo; return $return; @@ -55,14 +55,14 @@ class Model_ADSL_Supplier extends ORM_OSB { $plans = array_keys($this->adsl_plans(FALSE)); // Start with all our ADSL Plans - foreach (ORM::factory('service')->list_bylistgroup('ADSL') as $so) + foreach (ORM::factory('Service')->list_bylistgroup('ADSL') as $so) 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) + foreach (ORM::factory('Service')->list_bylistgroup('HSPA') as $so) 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); diff --git a/modules/adsl/classes/model/adsl/supplier/plan.php b/modules/adsl/classes/Model/ADSL/Supplier/Plan.php similarity index 90% rename from modules/adsl/classes/model/adsl/supplier/plan.php rename to modules/adsl/classes/Model/ADSL/Supplier/Plan.php index 26781deb..7c8ad355 100644 --- a/modules/adsl/classes/model/adsl/supplier/plan.php +++ b/modules/adsl/classes/Model/ADSL/Supplier/Plan.php @@ -13,10 +13,10 @@ class Model_ADSL_Supplier_Plan extends ORM_OSB { // Relationships protected $_has_many = array( - 'adsl_plan'=>array('far_key'=>'id'), + 'ADSL_plan'=>array('far_key'=>'id'), ); protected $_belongs_to = array( - 'adsl_supplier'=>array('foreign_key'=>'supplier_id'), + 'ADSL_supplier'=>array('foreign_key'=>'supplier_id'), ); /** diff --git a/modules/adsl/classes/model/product/plugin/adsl.php b/modules/adsl/classes/Model/Product/Plugin/ADSL.php similarity index 100% rename from modules/adsl/classes/model/product/plugin/adsl.php rename to modules/adsl/classes/Model/Product/Plugin/ADSL.php diff --git a/modules/adsl/classes/model/service/plugin/adsl.php b/modules/adsl/classes/Model/Service/Plugin/ADSL.php similarity index 99% rename from modules/adsl/classes/model/service/plugin/adsl.php rename to modules/adsl/classes/Model/Service/Plugin/ADSL.php index bb3ed426..6e221d21 100644 --- a/modules/adsl/classes/model/service/plugin/adsl.php +++ b/modules/adsl/classes/Model/Service/Plugin/ADSL.php @@ -132,7 +132,7 @@ class Model_Service_Plugin_ADSL extends Model_Service_Plugin { if (is_null($period)) $period = strtotime('yesterday'); - $t = ORM::factory('service_plugin_adsl_traffic') + $t = ORM::factory('Service_Plugin_ADSL_Traffic') ->where('service','=',$this->service_username) ->and_where('date','>=',date('Y-m-d',mktime(0,0,0,date('m',$period),1,date('Y',$period)))) ->and_where('date','<=',date('Y-m-d',strtotime('last day of '.date('M Y',$period)))) @@ -160,7 +160,7 @@ class Model_Service_Plugin_ADSL extends Model_Service_Plugin { if (is_null($period)) $period = strtotime('yesterday'); - $t = ORM::factory('service_plugin_adsl_traffic') + $t = ORM::factory('Service_Plugin_ADSL_Traffic') ->select( array('date_format(date,\'%y-%m\')','month'), array('sum(up_peak)','up_peak'), diff --git a/modules/adsl/classes/model/service/plugin/adsl/traffic.php b/modules/adsl/classes/Model/Service/Plugin/ADSL/Traffic.php similarity index 100% rename from modules/adsl/classes/model/service/plugin/adsl/traffic.php rename to modules/adsl/classes/Model/Service/Plugin/ADSL/Traffic.php diff --git a/modules/adsl/classes/service/traffic/adsl.php b/modules/adsl/classes/Service/Traffic/ADSL.php similarity index 94% rename from modules/adsl/classes/service/traffic/adsl.php rename to modules/adsl/classes/Service/Traffic/ADSL.php index e810cf0e..4396186e 100644 --- a/modules/adsl/classes/service/traffic/adsl.php +++ b/modules/adsl/classes/Service/Traffic/ADSL.php @@ -34,7 +34,7 @@ class Service_Traffic_ADSL { // Our DB record must be the suffix of this class name $supplier = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this)); - $so = ORM::factory('adsl_supplier') + $so = ORM::factory('Adsl_Supplier') ->where('name','=',$supplier) ->find(); @@ -70,7 +70,7 @@ class Service_Traffic_ADSL { * Traffic data from supplier */ public function update_traffic() { - if (CLI::options('verbose')) + if (Minion_CLI::options('verbose')) echo ' - Last: '.date('Y-m-d',strtotime($this->last_update().'+1 day'))."\n"; $alreadyrun = FALSE; @@ -78,7 +78,7 @@ class Service_Traffic_ADSL { $querydate<=$this->today; $querydate=date('Y-m-d',strtotime($querydate.'+1 day'))) { - if (CLI::options('verbose')) + if (Minion_CLI::options('verbose')) echo " - Date: $querydate\n"; $goodfetch = false; @@ -88,7 +88,7 @@ class Service_Traffic_ADSL { // Data returned should be in MB's $data = $this->getdata($querydate); - if (CLI::options('verbose')) + if (Minion_CLI::options('verbose')) print_r($data); if (! $this->fetchresult) { @@ -96,7 +96,7 @@ class Service_Traffic_ADSL { break; } - $traffic = ORM::factory('service_plugin_adsl_traffic'); + $traffic = ORM::factory('Service_Plugin_Adsl_Traffic'); foreach ($data as $item) { $traffic->values($item,array_keys($item)); $traffic->supplier_id = $this->so->id; @@ -122,7 +122,7 @@ class Service_Traffic_ADSL { foreach ($this->so->services() as $so) { if ($charge = $so->plugin()->traffic_lastmonth_exceed(FALSE,$date)) { foreach ($charge as $metric => $details) { - $co = ORM::factory('charge'); + $co = ORM::factory('Charge'); $co->status = 0; $co->sweep_type = 6; diff --git a/modules/adsl/classes/service/traffic/adsl/exetelhspa.php b/modules/adsl/classes/Service/Traffic/ADSL/ExetelHSPA.php similarity index 97% rename from modules/adsl/classes/service/traffic/adsl/exetelhspa.php rename to modules/adsl/classes/Service/Traffic/ADSL/ExetelHSPA.php index 7d74c4ce..ee5fe51d 100644 --- a/modules/adsl/classes/service/traffic/adsl/exetelhspa.php +++ b/modules/adsl/classes/Service/Traffic/ADSL/ExetelHSPA.php @@ -39,7 +39,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { $update = array(); foreach ($this->so->services() as $so) { - if (CLI::options('verbose')) + if (Minion_CLI::options('verbose')) echo " = Service: ".$so->name()."\n"; if ($so->plugin()->service_stats_collect AND $so->plugin()->service_stats_lastupdate < $date) { @@ -51,7 +51,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { ->post('doLogin',1) ->post('submit','Login'); - $request->get_client()->options($this->curlopts+array( + $request->client()->options($this->curlopts+array( CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number), )); @@ -87,7 +87,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { ->post('end_day_search_key',date('d',strtotime($lastday))) ->post('do_usage_search',1); - $request->get_client()->options($this->curlopts+array( + $request->client()->options($this->curlopts+array( CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number), )); diff --git a/modules/adsl/classes/service/traffic/adsl/exetelpe.php b/modules/adsl/classes/Service/Traffic/ADSL/ExetelPE.php similarity index 98% rename from modules/adsl/classes/service/traffic/adsl/exetelpe.php rename to modules/adsl/classes/Service/Traffic/ADSL/ExetelPE.php index 2fec6dc8..b0566706 100644 --- a/modules/adsl/classes/service/traffic/adsl/exetelpe.php +++ b/modules/adsl/classes/Service/Traffic/ADSL/ExetelPE.php @@ -48,7 +48,7 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL { ->post('doLogin',1) ->post('submit','Login'); - $request->get_client()->options($this->curlopts+array( + $request->client()->options($this->curlopts+array( CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number), )); @@ -83,7 +83,7 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL { ->post('end_day_search_key',date('d',strtotime($lastday))) ->post('do_usage_search',1); - $request->get_client()->options($this->curlopts+array( + $request->client()->options($this->curlopts+array( CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number), )); diff --git a/modules/adsl/classes/service/traffic/adsl/exetelvisp.php b/modules/adsl/classes/Service/Traffic/ADSL/ExetelVISP.php similarity index 96% rename from modules/adsl/classes/service/traffic/adsl/exetelvisp.php rename to modules/adsl/classes/Service/Traffic/ADSL/ExetelVISP.php index 8340f2c2..4a0c1c2f 100644 --- a/modules/adsl/classes/service/traffic/adsl/exetelvisp.php +++ b/modules/adsl/classes/Service/Traffic/ADSL/ExetelVISP.php @@ -27,7 +27,7 @@ class Service_Traffic_ADSL_ExetelVisp extends Service_Traffic_ADSL { ->post($this->login_pass_field,$this->so->stats_password) ->post($this->date_field,$date); - $request->get_client()->options($this->curlopts+array( + $request->client()->options($this->curlopts+array( CURLOPT_POST => TRUE, )); diff --git a/modules/adsl/classes/service/traffic/adsl/peopleagent.php b/modules/adsl/classes/Service/Traffic/ADSL/PeopleAgent.php similarity index 100% rename from modules/adsl/classes/service/traffic/adsl/peopleagent.php rename to modules/adsl/classes/Service/Traffic/ADSL/PeopleAgent.php diff --git a/modules/adsl/classes/service/traffic/adsl/iinetadsl.php b/modules/adsl/classes/Service/Traffic/ADSL/iiNetADSL.php similarity index 100% rename from modules/adsl/classes/service/traffic/adsl/iinetadsl.php rename to modules/adsl/classes/Service/Traffic/ADSL/iiNetADSL.php diff --git a/modules/affiliate/classes/model/affiliate.php b/modules/affiliate/classes/Model/Affiliate.php similarity index 100% rename from modules/affiliate/classes/model/affiliate.php rename to modules/affiliate/classes/Model/Affiliate.php diff --git a/modules/cart/classes/cart.php b/modules/cart/classes/Cart.php similarity index 98% rename from modules/cart/classes/cart.php rename to modules/cart/classes/Cart.php index f1698a4d..37fbd0d2 100644 --- a/modules/cart/classes/cart.php +++ b/modules/cart/classes/Cart.php @@ -19,7 +19,7 @@ class Cart { * Return a list of items in the cart */ public function contents() { - return ORM::factory('cart') + return ORM::factory('Cart') ->where('session_id','=',Session::instance()->id()); } diff --git a/modules/cart/classes/controller/cart.php b/modules/cart/classes/Controller/Cart.php similarity index 96% rename from modules/cart/classes/controller/cart.php rename to modules/cart/classes/Controller/Cart.php index c1df38a8..4ae91047 100644 --- a/modules/cart/classes/controller/cart.php +++ b/modules/cart/classes/Controller/Cart.php @@ -83,7 +83,7 @@ class Controller_Cart extends Controller_TemplateDefault { * Add an item to the cart */ public function action_add() { - $cart = ORM::factory('cart'); + $cart = ORM::factory('Cart'); $cart->session_id = Session::instance()->id(); @@ -96,13 +96,13 @@ class Controller_Cart extends Controller_TemplateDefault { echo Kohana::debug($cart->validate()->errors()); if ($cart->saved()) - Request::current()->redirect('cart/index'); + HTTP::redirect('cart/index'); else throw new Kohana_Exception(_('There was a problem adding the item to the cart.')); } public function action_empty() { - $cart = ORM::factory('cart') + $cart = ORM::factory('Cart') ->where('session_id','=',session_id()); $cart->delete_all(); diff --git a/modules/cart/classes/model/cart.php b/modules/cart/classes/Model/Cart.php similarity index 100% rename from modules/cart/classes/model/cart.php rename to modules/cart/classes/Model/Cart.php diff --git a/modules/charge/classes/controller/admin/charge.php b/modules/charge/classes/Controller/Admin/Charge.php similarity index 97% rename from modules/charge/classes/controller/admin/charge.php rename to modules/charge/classes/Controller/Admin/Charge.php index 869290ba..b4d19831 100644 --- a/modules/charge/classes/controller/admin/charge.php +++ b/modules/charge/classes/Controller/Admin/Charge.php @@ -24,7 +24,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Customer Charges'), 'body'=>Table::display( - ORM::factory('charge')->where('sweep_type','>=',0)->order_by('date_orig DESC')->find_all(), + ORM::factory('Charge')->where('sweep_type','>=',0)->order_by('date_orig DESC')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'user/charge/view/'), @@ -50,7 +50,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin { public function action_add() { $output = ''; - $co = ORM::factory('charge'); + $co = ORM::factory('Charge'); if ($_POST) { // Trim down our attributes diff --git a/modules/charge/classes/model/charge.php b/modules/charge/classes/Model/Charge.php similarity index 100% rename from modules/charge/classes/model/charge.php rename to modules/charge/classes/Model/Charge.php diff --git a/modules/checkout/classes/controller/checkout.php b/modules/checkout/classes/Controller/Checkout.php similarity index 98% rename from modules/checkout/classes/controller/checkout.php rename to modules/checkout/classes/Controller/Checkout.php index 992272c5..b5383b10 100644 --- a/modules/checkout/classes/controller/checkout.php +++ b/modules/checkout/classes/Controller/Checkout.php @@ -62,7 +62,7 @@ class Controller_Checkout extends Controller_TemplateDefault { 'body'=>$output, )); - $po = ORM::factory('checkout') + $po = ORM::factory('Checkout') ->payment_options_cart(); // @todo Country value should come from somewhere? @@ -104,7 +104,7 @@ class Controller_Checkout extends Controller_TemplateDefault { * Process checkout */ private function checkout() { - $invoice = ORM::factory('invoice'); + $invoice = ORM::factory('Invoice'); // Add our individual items to the invoice foreach (Cart::instance()->contents()->find_all() as $item) { diff --git a/modules/checkout/classes/model/checkout.php b/modules/checkout/classes/Model/Checkout.php similarity index 100% rename from modules/checkout/classes/model/checkout.php rename to modules/checkout/classes/Model/Checkout.php diff --git a/modules/domain/classes/domain.php b/modules/domain/classes/Domain.php similarity index 100% rename from modules/domain/classes/domain.php rename to modules/domain/classes/Domain.php diff --git a/modules/domain/classes/model/domain/registrar.php b/modules/domain/classes/Model/Domain/Registrar.php similarity index 100% rename from modules/domain/classes/model/domain/registrar.php rename to modules/domain/classes/Model/Domain/Registrar.php diff --git a/modules/domain/classes/model/domain/tld.php b/modules/domain/classes/Model/Domain/TLD.php similarity index 90% rename from modules/domain/classes/model/domain/tld.php rename to modules/domain/classes/Model/Domain/TLD.php index ece00130..adbeefc6 100644 --- a/modules/domain/classes/model/domain/tld.php +++ b/modules/domain/classes/Model/Domain/TLD.php @@ -10,7 +10,7 @@ * @copyright (c) 2010 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Domain_TLD extends ORM_OSB { +class Model_Domain_Tld extends ORM_OSB { protected $_display_filters = array( 'name'=>array( array('strtoupper',array(':value')), diff --git a/modules/domain/classes/model/product/plugin/domain.php b/modules/domain/classes/Model/Product/Plugin/DOMAIN.php similarity index 90% rename from modules/domain/classes/model/product/plugin/domain.php rename to modules/domain/classes/Model/Product/Plugin/DOMAIN.php index c6af99ce..71b90803 100644 --- a/modules/domain/classes/model/product/plugin/domain.php +++ b/modules/domain/classes/Model/Product/Plugin/DOMAIN.php @@ -10,7 +10,7 @@ * @copyright (c) 2010 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Product_Plugin_Domain extends Model_Product_Plugin { +class Model_Product_Plugin_DOMAIN extends Model_Product_Plugin { // This model doesnt have a database table public function __construct() { } @@ -22,7 +22,7 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin { // @todo This is not used, but should be. public function order_features() { $output = ''; - $t = ORM::factory('domain_tld'); + $t = ORM::factory('Domain_TLD'); // @todo Change this to a view. $output = sprintf('
%s
',_('Domains are available with the following suffixes')); diff --git a/modules/domain/classes/model/service/plugin/domain.php b/modules/domain/classes/Model/Service/Plugin/DOMAIN.php similarity index 90% rename from modules/domain/classes/model/service/plugin/domain.php rename to modules/domain/classes/Model/Service/Plugin/DOMAIN.php index 2ca5e67d..5d4e9b1f 100644 --- a/modules/domain/classes/model/service/plugin/domain.php +++ b/modules/domain/classes/Model/Service/Plugin/DOMAIN.php @@ -10,15 +10,15 @@ * @copyright (c) 2010 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Service_Plugin_Domain extends Model_Service_Plugin { +class Model_Service_Plugin_DOMAIN extends Model_Service_Plugin { protected $_table_name = 'service__domain'; protected $_updated_column = FALSE; // Relationships protected $_has_one = array( - 'domain_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'), + 'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'), 'domain_registrar'=>array('foreign_key'=>'id','far_key'=>'domain_registrar_id'), - 'service_plugin_host'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'), + 'service_plugin_HOST'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'), ); protected $_belongs_to = array( 'service'=>array(), @@ -49,7 +49,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin { } public function name() { - return sprintf('%s.%s',$this->display('domain_name'),$this->domain_tld->display('name')); + return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name')); } public function service_name() { diff --git a/modules/domain/classes/service/domain.php b/modules/domain/classes/Service/Domain.php similarity index 96% rename from modules/domain/classes/service/domain.php rename to modules/domain/classes/Service/Domain.php index e9248145..49007fed 100644 --- a/modules/domain/classes/service/domain.php +++ b/modules/domain/classes/Service/Domain.php @@ -31,7 +31,7 @@ abstract class Service_Domain { * Setup this class. We need to get our supplier details out of the database. */ public function __construct($sid) { - $this->so = ORM::factory('domain_registrar',$sid); + $this->so = ORM::factory('Domain_Registrar',$sid); } /** diff --git a/modules/domain/classes/service/domain/manual.php b/modules/domain/classes/Service/Domain/Manual.php similarity index 88% rename from modules/domain/classes/service/domain/manual.php rename to modules/domain/classes/Service/Domain/Manual.php index cbacefc0..f74b37ee 100644 --- a/modules/domain/classes/service/domain/manual.php +++ b/modules/domain/classes/Service/Domain/Manual.php @@ -16,7 +16,7 @@ class Service_Domain_Manual extends Service_Domain { private $login_pass_field = ''; // Our required abstract classes - public function manage_button($u,$p,$d) { + public function manage_button(Model_Service_Plugin_Domain $spdo,$t) { return _('Please contact us'); } } diff --git a/modules/domain/classes/service/domain/planetdomain.php b/modules/domain/classes/Service/Domain/PlanetDomain.php similarity index 62% rename from modules/domain/classes/service/domain/planetdomain.php rename to modules/domain/classes/Service/Domain/PlanetDomain.php index 8542f6a3..55ffb97e 100644 --- a/modules/domain/classes/service/domain/planetdomain.php +++ b/modules/domain/classes/Service/Domain/PlanetDomain.php @@ -16,18 +16,18 @@ class Service_Domain_PlanetDomain extends Service_Domain { private $login_pass_field = 'login.password'; // Our required abstract classes - public function manage_button($u,$p,$d) { + public function manage_button(Model_Service_Plugin_Domain $spdo,$t) { $output = ''; $output .= Form::open( sprintf('%s/%s',$this->so->whitelabel_url,'newdnr/action/user/login.jsp'), - array('target'=>'pd','method'=>'post') + array('target'=>'pd','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t)) ); - $output .= Form::input($this->login_user_field,$u,array('type'=>'hidden')); - $output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden')); + $output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t))); + $output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); $output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden')); - $output .= Form::button('submit',_('Manage'),array('class'=>'form_button')); $output .= Form::close(); + $output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spdo->service_id,$t))); return $output; } diff --git a/modules/domain/classes/service/domain/tpp.php b/modules/domain/classes/Service/Domain/TPP.php similarity index 100% rename from modules/domain/classes/service/domain/tpp.php rename to modules/domain/classes/Service/Domain/TPP.php diff --git a/modules/email/classes/controller/admin/email.php b/modules/email/classes/Controller/Admin/Email.php similarity index 92% rename from modules/email/classes/controller/admin/email.php rename to modules/email/classes/Controller/Admin/Email.php index 42e8c9ad..637b39f2 100644 --- a/modules/email/classes/controller/admin/email.php +++ b/modules/email/classes/Controller/Admin/Email.php @@ -25,7 +25,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('System Emails Sent'), 'body'=>Table::display( - ORM::factory('email_log')->find_all(), + ORM::factory('Email_Log')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'user/email/view/'), @@ -47,7 +47,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin { * List our defined email templates */ public function action_templatelist() { - $eto = ORM::factory('email_template'); + $eto = ORM::factory('Email_Template'); $output = ''; // @todo Change this to use Table:: @@ -68,7 +68,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin { * Add a template */ public function action_templateadd() { - $eto = ORM::factory('email_template'); + $eto = ORM::factory('Email_Template'); $output = ''; if ($_POST AND $eto->values($_POST)->check()) { @@ -102,11 +102,13 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin { * Edit Template Definition * @todo Change this into an add_view function like payment() */ - public function action_templateedit($id) { - $eto = ORM::factory('email_template',$id); + public function action_templateedit() { + $id = $this->request->param('id'); + + $eto = ORM::factory('Email_Template',$id); if (! $eto->loaded()) - Request::current()->redirect('email/admin/template/list'); + HTTP::redirect('email/admin/template/list'); $output = ''; diff --git a/modules/email/classes/controller/email.php b/modules/email/classes/Controller/Email.php similarity index 100% rename from modules/email/classes/controller/email.php rename to modules/email/classes/Controller/Email.php diff --git a/modules/email/classes/controller/email/template.php b/modules/email/classes/Controller/Email/Template.php similarity index 100% rename from modules/email/classes/controller/email/template.php rename to modules/email/classes/Controller/Email/Template.php diff --git a/modules/email/classes/controller/user/email.php b/modules/email/classes/Controller/User/Email.php similarity index 97% rename from modules/email/classes/controller/user/email.php rename to modules/email/classes/Controller/User/Email.php index 6a646e24..b5544628 100644 --- a/modules/email/classes/controller/user/email.php +++ b/modules/email/classes/Controller/User/Email.php @@ -41,7 +41,7 @@ class Controller_User_Email extends Controller_TemplateDefault_User { public function action_view() { list($id,$output) = Table::page(__METHOD__); - $elo = ORM::factory('email_log',$id); + $elo = ORM::factory('Email_Log',$id); if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account_id)) { $this->template->content = 'Unauthorised or doesnt exist?'; diff --git a/modules/email/classes/email/template.php b/modules/email/classes/Email/Template.php similarity index 96% rename from modules/email/classes/email/template.php rename to modules/email/classes/Email/Template.php index 760c76a6..aa5d8a69 100644 --- a/modules/email/classes/email/template.php +++ b/modules/email/classes/Email/Template.php @@ -20,7 +20,7 @@ class Email_Template { private $components = array('subject','message_text','message_html'); public function __construct($template,$language_id=NULL) { - $this->template = ORM::factory('email_template',array('name'=>$template)); + $this->template = ORM::factory('Email_Template',array('name'=>$template)); if (! $this->template->loaded()) throw new Kohana_Exception('Email template :template not defined in DB',array(':template'=>$template)); @@ -75,7 +75,7 @@ class Email_Template { $list = array(); foreach ($this->email_data[$key]['account'] as $id) { - $ao = ORM::factory('account',$id); + $ao = ORM::factory('Account',$id); if ($ao->loaded()) $list[$ao->email] = $ao->name(); } @@ -111,7 +111,7 @@ class Email_Template { public function send(array $admin=array()) { $e = Email::connect(); $sm = Swift_Message::newInstance() - ->setFrom(Kohana::config('config.email_from')); + ->setFrom(Kohana::$config->load('config')->email_from); foreach ($this->components as $component) { if ($this->etto->loaded()) { @@ -154,7 +154,7 @@ class Email_Template { if ($result) { // Store our email log. - $elo = ORM::factory('email_log'); + $elo = ORM::factory('Email_Log'); foreach ($sa as $id) { $elo->clear(); diff --git a/modules/email/classes/model/email/log.php b/modules/email/classes/Model/Email/Log.php similarity index 100% rename from modules/email/classes/model/email/log.php rename to modules/email/classes/Model/Email/Log.php diff --git a/modules/email/classes/model/email/template.php b/modules/email/classes/Model/Email/Template.php similarity index 100% rename from modules/email/classes/model/email/template.php rename to modules/email/classes/Model/Email/Template.php diff --git a/modules/email/classes/model/email/template/translate.php b/modules/email/classes/Model/Email/Template/Translate.php similarity index 100% rename from modules/email/classes/model/email/template/translate.php rename to modules/email/classes/Model/Email/Template/Translate.php diff --git a/modules/export/classes/controller/admin/export.php b/modules/export/classes/Controller/Admin/Export.php similarity index 93% rename from modules/export/classes/controller/admin/export.php rename to modules/export/classes/Controller/Admin/Export.php index 2d0e50e8..51a6cea6 100644 --- a/modules/export/classes/controller/admin/export.php +++ b/modules/export/classes/Controller/Admin/Export.php @@ -21,11 +21,11 @@ class Controller_Admin_Export extends Controller_TemplateDefault_Admin { * Add Export Maping items */ public function action_add() { - $eo = ORM::factory('export'); + $eo = ORM::factory('Export'); $output = ''; if ($_POST AND $eo->values($_POST)->check()) { - $eo->module_id = ORM::factory('module',array('name'=>'product'))->id; // @todo This probably should be in the form. + $eo->module_id = ORM::factory('Module',array('name'=>'product'))->id; // @todo This probably should be in the form. $eo->plugin_name = 'quicken'; // @todo This should be in the form. // Entry updated if (! $eo->save()) diff --git a/modules/export/classes/controller/affiliate/export.php b/modules/export/classes/Controller/Affiliate/Export.php similarity index 94% rename from modules/export/classes/controller/affiliate/export.php rename to modules/export/classes/Controller/Affiliate/Export.php index 50ba4a4b..af12c848 100644 --- a/modules/export/classes/controller/affiliate/export.php +++ b/modules/export/classes/Controller/Affiliate/Export.php @@ -24,7 +24,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate { if (empty($_POST['plugin'])) $this->request->redirect('affiliate/export/index'); - $sc = sprintf('Export_%s',$_POST['plugin']); + $sc = sprintf('Export_%s',ucfirst($_POST['plugin'])); if (! class_exists($sc)) throw new Kohana_Exception('Export Class doesnt exist for :plugin',array(':plugin'=>$_POST['plugin'])); else @@ -43,7 +43,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate { $TBRexportplugins = array('quicken'=>'Export to Quicken'); // @todo: Need to limit this to affiliate acounts - $p = ORM::factory('payment'); + $p = ORM::factory('Payment'); if ($p->find_all()->count()) { Block::add(array( @@ -80,7 +80,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate { 'title'=>_('No payments to export'), 'type'=>'info', 'body'=>sprintf(_('There are no payments within the last %s days (since %s) to show.'), - $daysago,date(Kohana::config('osb')->get('date_format'),$daysago*86400+time())), + $daysago,date(Kohana::$config->load('osb')->date_format,$daysago*86400+time())), )); } } diff --git a/modules/export/classes/controller/export.php b/modules/export/classes/Controller/Export.php similarity index 100% rename from modules/export/classes/controller/export.php rename to modules/export/classes/Controller/Export.php diff --git a/modules/export/classes/export.php b/modules/export/classes/Export.php similarity index 100% rename from modules/export/classes/export.php rename to modules/export/classes/Export.php diff --git a/modules/export/classes/export/quicken.php b/modules/export/classes/Export/Quicken.php similarity index 97% rename from modules/export/classes/export/quicken.php rename to modules/export/classes/Export/Quicken.php index fc0b7813..f648f7e0 100644 --- a/modules/export/classes/export/quicken.php +++ b/modules/export/classes/Export/Quicken.php @@ -16,7 +16,7 @@ class Export_Quicken extends Export { $qo = new Quicken; foreach ($_POST['id'] as $pid) { - $po = ORM::factory('payment',$pid); + $po = ORM::factory('Payment',$pid); if ($po->loaded()) { $invoice_ids = array(); @@ -85,9 +85,9 @@ class Export_Quicken extends Export { $daterange = ''; if ($iio->product_id) { - $mo = ORM::factory('module',array('name'=>'product')); - $eo = ORM::factory('export') - ->where('plugin_name','=',$this->plugin) + $mo = ORM::factory('Module',array('name'=>'product')); + $eo = ORM::factory('Export') + ->where('plugin_name','=',strtolower($this->plugin)) ->and_where('module_id','=',$mo->id) ->and_where('item_id','=',$iio->product_id) ->find(); diff --git a/modules/export/classes/model/export.php b/modules/export/classes/Model/Export.php similarity index 80% rename from modules/export/classes/model/export.php rename to modules/export/classes/Model/Export.php index b9d8055a..b8f5aec4 100644 --- a/modules/export/classes/model/export.php +++ b/modules/export/classes/Model/Export.php @@ -18,12 +18,12 @@ class Model_Export extends ORM_OSB { public function list_itemsnoexport() { $result = array(); - $mo = ORM::factory('module',array('name'=>'product')); - $p = ORM::factory('product') + $mo = ORM::factory('Module',array('name'=>'product')); + $p = ORM::factory('Product') ->order_by('id'); foreach ($p->find_all() as $po) - if (! ORM::factory('export')->where('module_id','=',$mo->id)->where('item_id','=',$po->id)->find()->loaded()) + if (! ORM::factory('Export')->where('module_id','=',$mo->id)->where('item_id','=',$po->id)->find()->loaded()) $result[$po->id] = $po; return $result; diff --git a/modules/export/classes/osbexport.php b/modules/export/classes/OSBExport.php similarity index 100% rename from modules/export/classes/osbexport.php rename to modules/export/classes/OSBExport.php diff --git a/modules/export/classes/quicken.php b/modules/export/classes/Quicken.php similarity index 100% rename from modules/export/classes/quicken.php rename to modules/export/classes/Quicken.php diff --git a/modules/export/classes/quicken/invoice.php b/modules/export/classes/Quicken/Invoice.php similarity index 100% rename from modules/export/classes/quicken/invoice.php rename to modules/export/classes/Quicken/Invoice.php diff --git a/modules/export/classes/quicken/invoiceitem.php b/modules/export/classes/Quicken/InvoiceItem.php similarity index 100% rename from modules/export/classes/quicken/invoiceitem.php rename to modules/export/classes/Quicken/InvoiceItem.php diff --git a/modules/export/classes/quicken/payment.php b/modules/export/classes/Quicken/Payment.php similarity index 100% rename from modules/export/classes/quicken/payment.php rename to modules/export/classes/Quicken/Payment.php diff --git a/modules/host/classes/controller/admin/host.php b/modules/host/classes/Controller/Admin/Host.php similarity index 89% rename from modules/host/classes/controller/admin/host.php rename to modules/host/classes/Controller/Admin/Host.php index 7a9e9f39..054e44ee 100644 --- a/modules/host/classes/controller/admin/host.php +++ b/modules/host/classes/Controller/Admin/Host.php @@ -19,7 +19,7 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin { public function action_ajaxmanage() { $this->auto_render = FALSE; - $hso = ORM::factory('host_server',$this->request->param('id')); + $hso = ORM::factory('Host_Server',$this->request->param('id')); $k = Session::instance()->get_once('manage_button'); $o = array( @@ -38,7 +38,7 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Customer Services'), 'body'=>Table::display( - ORM::factory('host_server')->find_all(), + ORM::factory('Host_Server')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'admin/host/update/'), @@ -53,11 +53,11 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin { } public function action_update() { - $hso = ORM::factory('host_server',$this->request->param('id')); + $hso = ORM::factory('Host_Server',$this->request->param('id')); $output = ''; if (! $hso->loaded()) - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); if ($_POST) { $hso->values($_POST); diff --git a/modules/host/classes/controller/task/host.php b/modules/host/classes/Controller/Task/Host.php similarity index 97% rename from modules/host/classes/controller/task/host.php rename to modules/host/classes/Controller/Task/Host.php index 891eab1d..16ff68de 100644 --- a/modules/host/classes/controller/task/host.php +++ b/modules/host/classes/Controller/Task/Host.php @@ -29,7 +29,7 @@ class Controller_Task_Host extends Controller_Task { case 'setdisablemail': case 'setexpire': case 'setpasswd': - $this->so = ORM::factory('service',$this->request->param('id')); + $this->so = ORM::factory('Service',$this->request->param('id')); if (! $this->so->loaded()) throw new Kohana_Exception('Unknown service :sid',array(':sid'=>$this->request->param('id'))); @@ -138,7 +138,7 @@ class Controller_Task_Host extends Controller_Task { list($sid,$svrs) = preg_split('/:/',$ids,2); list($fsid,$tsid) = preg_split('/-/',$svrs,2); - $so = ORM::factory('service',$sid); + $so = ORM::factory('Service',$sid); if (! $so->loaded()) throw new Kohana_Exception('Service :sid doesnt exist?',array(':sid'=>$sid)); @@ -154,7 +154,7 @@ class Controller_Task_Host extends Controller_Task { throw new Kohana_Exception('Service :sid is not on server :tsid?',array(':sid'=>$sid,':tsid'=>$tsid)); // Temporarily set our host_server_id to $fsid - $hpo = ORM::factory('host_server',$fsid); + $hpo = ORM::factory('Host_Server',$fsid); if (! $hpo->loaded()) throw new Kohana_Exception('Host server :fsid not defined?',array(':fsid'=>$fsid)); @@ -230,7 +230,7 @@ class Controller_Task_Host extends Controller_Task { $cats = array(); if ($mode) - $cats = ORM::factory('product_category')->list_bylistgroup($mode); + $cats = ORM::factory('Product_Category')->list_bylistgroup($mode); foreach (ORM::Factory('service')->list_provision()->find_all() as $so) { $pc = array(); diff --git a/modules/host/classes/host/plugin.php b/modules/host/classes/Host/Plugin.php similarity index 100% rename from modules/host/classes/host/plugin.php rename to modules/host/classes/Host/Plugin.php diff --git a/modules/host/classes/host/plugin/plesk.php b/modules/host/classes/Host/Plugin/Plesk.php similarity index 98% rename from modules/host/classes/host/plugin/plesk.php rename to modules/host/classes/Host/Plugin/Plesk.php index 58d97e81..7b06d4b1 100644 --- a/modules/host/classes/host/plugin/plesk.php +++ b/modules/host/classes/Host/Plugin/Plesk.php @@ -88,7 +88,7 @@ abstract class Host_Plugin_Plesk extends Host_Plugin { $request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path)) ->method('POST'); - $request->get_client()->options(Arr::merge($this->curlopts,array( + $request->client()->options(Arr::merge($this->curlopts,array( CURLOPT_HTTPHEADER => array( 'HTTP_AUTH_LOGIN: '.$this->hso->manage_username, 'HTTP_AUTH_PASSWD: '.$this->hso->manage_password, diff --git a/modules/host/classes/host/plugin/plesk/10.php b/modules/host/classes/Host/Plugin/Plesk/10.php similarity index 99% rename from modules/host/classes/host/plugin/plesk/10.php rename to modules/host/classes/Host/Plugin/Plesk/10.php index 40e4772a..61454f48 100644 --- a/modules/host/classes/host/plugin/plesk/10.php +++ b/modules/host/classes/Host/Plugin/Plesk/10.php @@ -110,7 +110,7 @@ class Host_Plugin_Plesk_10 extends Host_Plugin_Plesk { $this->init(); $items = array_keys($this->_template['reseller']); - $hsao = ORM::factory('host_server_affiliate',array('affiliate_id'=>$so->affiliate_id,'host_server_id'=>$so->plugin()->host_server_id))->find(); + $hsao = ORM::factory('Host_Server_Affiliate',array('affiliate_id'=>$so->affiliate_id,'host_server_id'=>$so->plugin()->host_server_id))->find(); if (! $hsao->loaded()) return NULL; diff --git a/modules/host/classes/host/plugin/plesk/9.php b/modules/host/classes/Host/Plugin/Plesk/9.php similarity index 100% rename from modules/host/classes/host/plugin/plesk/9.php rename to modules/host/classes/Host/Plugin/Plesk/9.php diff --git a/modules/host/classes/model/host/server.php b/modules/host/classes/Model/Host/Server.php similarity index 100% rename from modules/host/classes/model/host/server.php rename to modules/host/classes/Model/Host/Server.php diff --git a/modules/host/classes/model/host/server/affiliate.php b/modules/host/classes/Model/Host/Server/Affiliate.php similarity index 100% rename from modules/host/classes/model/host/server/affiliate.php rename to modules/host/classes/Model/Host/Server/Affiliate.php diff --git a/modules/host/classes/model/product/plugin/host.php b/modules/host/classes/Model/Product/Plugin/HOST.php similarity index 90% rename from modules/host/classes/model/product/plugin/host.php rename to modules/host/classes/Model/Product/Plugin/HOST.php index 4ccfbf5b..827dfa6d 100644 --- a/modules/host/classes/model/product/plugin/host.php +++ b/modules/host/classes/Model/Product/Plugin/HOST.php @@ -10,7 +10,7 @@ * @copyright (c) 2010 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Product_Plugin_Host extends Model_Product_Plugin { +class Model_Product_Plugin_HOST extends Model_Product_Plugin { // @todo This model doesnt have a database table public function __construct() { } diff --git a/modules/host/classes/model/service/plugin/host.php b/modules/host/classes/Model/Service/Plugin/HOST.php similarity index 95% rename from modules/host/classes/model/service/plugin/host.php rename to modules/host/classes/Model/Service/Plugin/HOST.php index 88792c30..03de0afa 100644 --- a/modules/host/classes/model/service/plugin/host.php +++ b/modules/host/classes/Model/Service/Plugin/HOST.php @@ -20,7 +20,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin { // Relationships protected $_has_one = array( - 'domain_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'), + 'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'), 'host_server'=>array('far_key'=>'host_server_id','foreign_key'=>'id'), ); protected $_belongs_to = array( @@ -46,7 +46,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin { } public function name() { - return sprintf('%s.%s',$this->display('domain_name'),$this->domain_tld->display('name')); + return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name')); } public function service_view() { diff --git a/modules/invoice/classes/controller/admin/invoice.php b/modules/invoice/classes/Controller/Admin/Invoice.php similarity index 98% rename from modules/invoice/classes/controller/admin/invoice.php rename to modules/invoice/classes/Controller/Admin/Invoice.php index 8f5d73b1..45a77e02 100644 --- a/modules/invoice/classes/controller/admin/invoice.php +++ b/modules/invoice/classes/Controller/Admin/Invoice.php @@ -43,7 +43,7 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('System Customer Invoices'), 'body'=>Table::display( - ORM::factory('invoice')->find_all(), + ORM::factory('Invoice')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'user/invoice/view/'), diff --git a/modules/invoice/classes/controller/invoice.php b/modules/invoice/classes/Controller/Invoice.php similarity index 100% rename from modules/invoice/classes/controller/invoice.php rename to modules/invoice/classes/Controller/Invoice.php diff --git a/modules/invoice/classes/controller/task/invoice.php b/modules/invoice/classes/Controller/Task/Invoice.php similarity index 92% rename from modules/invoice/classes/controller/task/invoice.php rename to modules/invoice/classes/Controller/Task/Invoice.php index 25447866..75aa587c 100644 --- a/modules/invoice/classes/controller/task/invoice.php +++ b/modules/invoice/classes/Controller/Task/Invoice.php @@ -20,7 +20,7 @@ class Controller_Task_Invoice extends Controller_Task { public function action_list() { $mode = $this->request->param('id'); - $i = ORM::factory('invoice'); + $i = ORM::factory('Invoice'); $tm = 'list_'.$mode; if (! method_exists($i,$tm)) @@ -59,9 +59,9 @@ class Controller_Task_Invoice extends Controller_Task { public function action_remind_due() { $action = array(); $key = 'remind_due'; - $days = ORM::factory('invoice')->config('REMIND_DUE'); + $days = ORM::factory('Invoice')->config('REMIND_DUE'); - foreach (ORM::factory('invoice')->list_due(time()+86400*$days) as $io) { + foreach (ORM::factory('Invoice')->list_due(time()+86400*$days) as $io) { // @todo Use another option to supress reminders // If we have already sent a reminder, we'll skip to the next one. if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1)) @@ -105,7 +105,7 @@ class Controller_Task_Invoice extends Controller_Task { case 1: case 2: case 3: - $days = ORM::factory('invoice')->config('REMIND_OVERDUE_'.$notice); + $days = ORM::factory('Invoice')->config('REMIND_OVERDUE_'.$notice); break; default: @@ -115,7 +115,7 @@ class Controller_Task_Invoice extends Controller_Task { $key = 'remind_overdue_'.$notice; - foreach (ORM::factory('invoice')->list_overdue_billing(time()-86400*$days,FALSE) as $io) { + foreach (ORM::factory('Invoice')->list_overdue_billing(time()-86400*$days,FALSE) as $io) { // @todo Use another option to supress reminders // If we have already sent a reminder, we'll skip to the next one. if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1)) @@ -154,7 +154,7 @@ class Controller_Task_Invoice extends Controller_Task { */ public function action_services() { // Used to only process X invoices in a row. - $max = ORM::factory('invoice')->config('GEN_INV_MAX'); + $max = ($x=Kohana::$config->load('debug')->invoice) ? $x : ORM::factory('Invoice')->config('GEN_INV_MAX'); // Our service next billing dates that need to be updated if this is successful. $snd = array(); // Our charges that need to be updated if this is successful. @@ -162,7 +162,7 @@ class Controller_Task_Invoice extends Controller_Task { // If we are invoicing a specific service $sid = is_null($this->request->param('id')) ? NULL : explode(':',$this->request->param('id')); // Sort our service by account_id, then we can generate 1 invoice. - $svs = ORM::factory('service')->list_invoicesoon()->as_array(); + $svs = ORM::factory('Service')->list_invoicesoon()->as_array(); Sort::MAsort($svs,'account_id,date_next_invoice'); $aid = $due = $io = NULL; @@ -186,7 +186,7 @@ class Controller_Task_Invoice extends Controller_Task { break; // Start a new invoice. - $io = ORM::factory('invoice'); + $io = ORM::factory('Invoice'); $io->due_date = $due = $io->min_due($so->date_next_invoice); $io->account_id = $aid = $so->account_id; $io->status = TRUE; @@ -210,7 +210,7 @@ class Controller_Task_Invoice extends Controller_Task { $snd[$so->id] = $pdata['end_time']+86400; // Check if there are any charges - $c = ORM::factory('charge') + $c = ORM::factory('Charge') ->where('service_id','=',$so->id) ->where('status','=',0) ->where('sweep_type','=',6); // @todo This needs to be dynamic, not "6" @@ -244,7 +244,7 @@ class Controller_Task_Invoice extends Controller_Task { // Update our service next billing dates. // @todo Catch any update errors foreach ($snd as $sid=>$date) { - $so = ORM::factory('service',$sid); + $so = ORM::factory('Service',$sid); $so->date_next_invoice = $date; $so->save(); } @@ -252,7 +252,7 @@ class Controller_Task_Invoice extends Controller_Task { // Update any processed charges as such // @todo Catch any update errors foreach ($chgs as $cid) { - $co = ORM::factory('charge',$cid); + $co = ORM::factory('Charge',$cid); $co->status=1; $co->save(); } @@ -262,7 +262,7 @@ class Controller_Task_Invoice extends Controller_Task { public function action_send() { // Used to only process X invoices in a row. - $max = ORM::factory('invoice')->config('EMAIL_INV_MAX'); + $max = ORM::factory('Invoice')->config('EMAIL_INV_MAX'); $action = array(); $iid = $this->request->param('id'); @@ -272,7 +272,7 @@ class Controller_Task_Invoice extends Controller_Task { list($iid,$x) = explode(':',$iid); // Get our list of invoices to send - $i = $iid ? ORM::factory('invoice')->where('id','=',$iid) : ORM::factory('invoice')->list_tosend(); + $i = $iid ? ORM::factory('Invoice')->where('id','=',$iid) : ORM::factory('Invoice')->list_tosend(); $key = 'send'; @@ -288,7 +288,7 @@ class Controller_Task_Invoice extends Controller_Task { // Send our email $et = Email_Template::instance('task_invoice_'.$key); - $token = ORM::factory('module_method_token') + $token = ORM::factory('Module_Method_Token') ->method(array('invoice','user_download')) ->account($io->account) ->expire(time()+86400*21) @@ -324,7 +324,7 @@ class Controller_Task_Invoice extends Controller_Task { public function action_audit_invoice_items() { $output = ''; - foreach (ORM::factory('invoice_item')->find_all() as $iio) { + foreach (ORM::factory('Invoice_Item')->find_all() as $iio) { if ($iio->product_name AND $iio->product_id) { if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->name()))) { $iio->product_name = NULL; diff --git a/modules/invoice/classes/controller/user/invoice.php b/modules/invoice/classes/Controller/User/Invoice.php similarity index 97% rename from modules/invoice/classes/controller/user/invoice.php rename to modules/invoice/classes/Controller/User/Invoice.php index d7c71ef8..ff32c318 100644 --- a/modules/invoice/classes/controller/user/invoice.php +++ b/modules/invoice/classes/Controller/User/Invoice.php @@ -49,7 +49,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User { public function action_view() { list($id,$output) = Table::page(__METHOD__); - $io = ORM::factory('invoice',$id); + $io = ORM::factory('Invoice',$id); if (! $io->loaded() OR (! Auth::instance()->authorised($io->account_id,$io->affiliate_id) AND ! in_array($this->ao->affiliate->id,$io->service_affiliates()))) { $this->template->content = 'Unauthorised or doesnt exist?'; @@ -123,7 +123,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User { * Download an invoice */ public function action_download() { - $io = ORM::factory('invoice',$this->request->param('id')); + $io = ORM::factory('Invoice',$this->request->param('id')); $this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D')); $this->response->headers(array('Content-Type' => 'application/pdf')); diff --git a/modules/invoice/classes/invoice.php b/modules/invoice/classes/Invoice.php similarity index 95% rename from modules/invoice/classes/invoice.php rename to modules/invoice/classes/Invoice.php index a0448806..69356b04 100644 --- a/modules/invoice/classes/invoice.php +++ b/modules/invoice/classes/Invoice.php @@ -87,14 +87,14 @@ SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE // @todo Function Not Used public static function balance($id) { - return ORM::factory('invoice',$id)->due(); + return ORM::factory('Invoice',$id)->due(); } /** * Generate a PDF invoice */ public function pdf() { - $invoice_class = sprintf('invoice_tcpdf_%s',Kohana::config('invoice.driver')); + $invoice_class = sprintf('Invoice_TCPDF_%s',ucfirst(Kohana::$config->load('invoice')->driver)); $pdf = new $invoice_class($this->io); diff --git a/modules/invoice/classes/invoice/tcpdf.php b/modules/invoice/classes/Invoice/TCPDF.php similarity index 100% rename from modules/invoice/classes/invoice/tcpdf.php rename to modules/invoice/classes/Invoice/TCPDF.php diff --git a/modules/invoice/classes/invoice/tcpdf/default.php b/modules/invoice/classes/Invoice/TCPDF/Default.php similarity index 98% rename from modules/invoice/classes/invoice/tcpdf/default.php rename to modules/invoice/classes/Invoice/TCPDF/Default.php index bcb95655..ea50d57d 100644 --- a/modules/invoice/classes/invoice/tcpdf/default.php +++ b/modules/invoice/classes/Invoice/TCPDF/Default.php @@ -357,9 +357,9 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { // Calculate our rounding error // @todo This shouldnt be required. - $subtotal = round($subtotal-$this->io->discount_amt,Kohana::config('config.currency_format')); + $subtotal = Currency::round($subtotal-$this->io->discount_amt); - if (round($this->io->subtotal(),Kohana::config('config.currency_format')) != $subtotal) { + if (Currency::round($this->io->subtotal()) != $subtotal) { $this->SetFont('helvetica','',9); $this->SetX($x); $this->Cell(0,0,'Other'); diff --git a/modules/invoice/classes/model/invoice.php b/modules/invoice/classes/Model/Invoice.php similarity index 98% rename from modules/invoice/classes/model/invoice.php rename to modules/invoice/classes/Model/Invoice.php index 984c441e..21280d39 100644 --- a/modules/invoice/classes/model/invoice.php +++ b/modules/invoice/classes/Model/Invoice.php @@ -377,13 +377,13 @@ class Model_Invoice extends ORM_OSB { $c = count($this->invoice_items); - $this->invoice_items[$c] = ORM::factory('invoice_item'); + $this->invoice_items[$c] = ORM::factory('Invoice_Item'); return $this->invoice_items[$c]; } public function min_due($date) { - return strtotime(date('Y-M-d',($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) { @@ -577,7 +577,7 @@ class Model_Invoice extends ORM_OSB { * @todo This should be optimised a little to return only invoices to send, instead of looking for them. */ public function list_tosend() { - return ORM::factory('invoice')->where_active()->where_open()->where('print_status','is',NULL)->or_where('print_status','!=',1)->where_close(); + return ORM::factory('Invoice')->where_active()->where_open()->where('print_status','is',NULL)->or_where('print_status','!=',1)->where_close(); } public function html() { diff --git a/modules/invoice/classes/model/invoice/item.php b/modules/invoice/classes/Model/Invoice/Item.php similarity index 99% rename from modules/invoice/classes/model/invoice/item.php rename to modules/invoice/classes/Model/Invoice/Item.php index cfbfbc81..049c3870 100644 --- a/modules/invoice/classes/model/invoice/item.php +++ b/modules/invoice/classes/Model/Invoice/Item.php @@ -169,7 +169,7 @@ class Model_Invoice_Item extends ORM_OSB { // Need to save the discounts associated with the invoice_item if ($this->saved()) { - $iito = ORM::factory('invoice_item_tax'); + $iito = ORM::factory('Invoice_Item_Tax'); if ($this->subitems_loaded) { foreach (array('tax') as $i) diff --git a/modules/invoice/views/invoice/user/email.php b/modules/invoice/views/invoice/user/email.php index 6f2166ea..81ef9062 100644 --- a/modules/invoice/views/invoice/user/email.php +++ b/modules/invoice/views/invoice/user/email.php @@ -64,7 +64,7 @@ items_services($items) as $sid => $ito) { ?> - + @@ -122,7 +122,7 @@ tax_summary() as $tid => $amount) { - $m = ORM::factory('tax',$tid); + $m = ORM::factory('Tax',$tid); ?> diff --git a/modules/invoice/views/invoice/user/view.php b/modules/invoice/views/invoice/user/view.php index 7acccf64..d2b309a9 100644 --- a/modules/invoice/views/invoice/user/view.php +++ b/modules/invoice/views/invoice/user/view.php @@ -189,7 +189,7 @@ tax_summary() as $tid => $amount) { - $m = ORM::factory('tax',$tid); ?> + $m = ORM::factory('Tax',$tid); ?> diff --git a/modules/payment/classes/controller/admin/payment.php b/modules/payment/classes/Controller/Admin/Payment.php similarity index 93% rename from modules/payment/classes/controller/admin/payment.php rename to modules/payment/classes/Controller/Admin/Payment.php index dc31041f..878556cc 100644 --- a/modules/payment/classes/controller/admin/payment.php +++ b/modules/payment/classes/Controller/Admin/Payment.php @@ -24,8 +24,8 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin { $return = array(); if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) { - $return += ORM::factory('account')->list_autocomplete($_REQUEST['term']); - $return += ORM::factory('invoice')->list_autocomplete($_REQUEST['term'],'account_id'); + $return += ORM::factory('Account')->list_autocomplete($_REQUEST['term']); + $return += ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'account_id'); } $this->auto_render = FALSE; @@ -44,7 +44,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin { $i = 0; $list = array(); if (isset($_REQUEST['pid'])) - foreach (ORM::factory('payment',$_REQUEST['pid'])->items() as $pio) { + foreach (ORM::factory('Payment',$_REQUEST['pid'])->items() as $pio) { $output .= View::factory($this->viewpath().'/body') ->set('trc',$i++%2 ? 'odd' : 'even') ->set('pio',$pio) @@ -54,12 +54,12 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin { array_push($list,$pio->invoice_id); } - foreach (ORM::factory('account',$_REQUEST['key'])->invoices_due() as $io) + foreach (ORM::factory('Account',$_REQUEST['key'])->invoices_due() as $io) // Only list invoices not yet listed if (! in_array($io->id,$list)) $output .= View::factory($this->viewpath().'/body') ->set('trc',$i++%2 ? 'odd' : 'even') - ->set('pio',ORM::factory('payment_item')) + ->set('pio',ORM::factory('Payment_Item')) ->set('io',$io); // @todo Need the JS to add up the payment allocation before submission @@ -76,7 +76,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Customer Payments'), 'body'=>Table::display( - ORM::factory('payment')->find_all(), + ORM::factory('Payment')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'admin/payment/view/'), @@ -97,7 +97,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin { } private function add_view($id=NULL,$output='') { - $po = ORM::factory('payment',$id); + $po = ORM::factory('Payment',$id); if ($_POST) { // Update our invoice payment items @@ -210,7 +210,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin { $output = ''; if ($_POST AND isset($_POST['payer'])) { - $c = sprintf('payment_bulk_%s',$_POST['payer']); + $c = sprintf('Payment_Bulk_%s',ucfirst($_POST['payer'])); $o = new $c(); if (! $_FILES) { diff --git a/modules/payment/classes/controller/payment.php b/modules/payment/classes/Controller/Payment.php similarity index 100% rename from modules/payment/classes/controller/payment.php rename to modules/payment/classes/Controller/Payment.php diff --git a/modules/payment/classes/controller/user/payment.php b/modules/payment/classes/Controller/User/Payment.php similarity index 100% rename from modules/payment/classes/controller/user/payment.php rename to modules/payment/classes/Controller/User/Payment.php diff --git a/modules/payment/classes/model/payment.php b/modules/payment/classes/Model/Payment.php similarity index 96% rename from modules/payment/classes/model/payment.php rename to modules/payment/classes/Model/Payment.php index 0f79e54b..944c1da6 100644 --- a/modules/payment/classes/model/payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -64,7 +64,7 @@ class Model_Payment extends ORM_OSB { // New Item $c = count($this->payment_items); - $this->payment_items[$c] = ORM::factory('payment_item'); + $this->payment_items[$c] = ORM::factory('Payment_Item'); $this->payment_items[$c]->invoice_id = $iid; return $this->payment_items[$c]; @@ -76,7 +76,7 @@ class Model_Payment extends ORM_OSB { * @param int $start List payments that were modified this many days ago */ public function export($start) { - return ORM::factory('payment') + return ORM::factory('Payment') ->where('date_payment','>=',time()-$start*86400) ->find_all(); } @@ -165,9 +165,9 @@ class Model_Payment extends ORM_OSB { foreach ($items as $pio) { // Only need to check items that ave actually changed. if ($pio->changed()) { - $old_pio = ORM::factory('payment_item',$pio->id); + $old_pio = ORM::factory('Payment_Item',$pio->id); - if (($it = $pio->invoice->due()+ORM::factory('payment_item',$pio->id)->alloc_amt-$pio->alloc_amt) < 0) + if (($it = $pio->invoice->due()+ORM::factory('Payment_Item',$pio->id)->alloc_amt-$pio->alloc_amt) < 0) $msg .= ($msg ? ' ' : '').sprintf('Invoice %s over allocated by %3.2f.',$pio->invoice_id,$it); } diff --git a/modules/payment/classes/model/payment/item.php b/modules/payment/classes/Model/Payment/Item.php similarity index 100% rename from modules/payment/classes/model/payment/item.php rename to modules/payment/classes/Model/Payment/Item.php diff --git a/modules/payment/classes/payment/bulk/ezypay.php b/modules/payment/classes/Payment/Bulk/Ezypay.php similarity index 92% rename from modules/payment/classes/payment/bulk/ezypay.php rename to modules/payment/classes/Payment/Bulk/Ezypay.php index 442611bd..ee04d990 100644 --- a/modules/payment/classes/payment/bulk/ezypay.php +++ b/modules/payment/classes/Payment/Bulk/Ezypay.php @@ -44,7 +44,7 @@ class Payment_Bulk_Ezypay { if (preg_match('/^'.Config::siteid(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') { $aid = preg_replace('/^'.Config::siteid(TRUE).'-/','',$array[4]); - $po = ORM::factory('payment'); + $po = ORM::factory('Payment'); $po->account_id = $aid; $po->total_amt = $array[7]; $po->notes = $array[2].':'.$array[3]; @@ -85,7 +85,7 @@ class Payment_Bulk_Ezypay { } $return = ''; - $return .= View::Factory('payment/admin/addbulk/ezypay/head'); + $return .= View::Factory('Payment/Admin/Addbulk/Ezypay/head'); $total = $fees = 0; foreach ($payments as $po) { @@ -94,11 +94,11 @@ class Payment_Bulk_Ezypay { $total += $po->total_amt; $fees += $po->fees_amt; - $return .= View::Factory('payment/admin/addbulk/ezypay/body') + $return .= View::Factory('Payment/Admin/Addbulk/Ezypay/body') ->set('o',$po); } - $return .= View::Factory('payment/admin/addbulk/ezypay/foot') + $return .= View::Factory('Payment/Admin/Addbulk/Ezypay/foot') ->set('total',$total) ->set('fees',$fees);; diff --git a/modules/product/classes/controller/admin/product.php b/modules/product/classes/Controller/Admin/Product.php similarity index 88% rename from modules/product/classes/controller/admin/product.php rename to modules/product/classes/Controller/Admin/Product.php index 6c940ec1..fc64aa76 100644 --- a/modules/product/classes/controller/admin/product.php +++ b/modules/product/classes/Controller/Admin/Product.php @@ -21,7 +21,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { public function action_ajaxtranslateform() { $this->auto_render = FALSE; - $po = ORM::factory('product',$this->request->param('id')); + $po = ORM::factory('Product',$this->request->param('id')); if (! $this->request->is_ajax() OR ! $po->loaded() OR ! isset($_REQUEST['key'])) $this->response->body(_('Unable to find translate data')); @@ -39,9 +39,9 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { */ public function action_list() { if ($this->request->param('id')) - $prods = ORM::factory('product')->list_category($this->request->param('id'),FALSE); + $prods = ORM::factory('Product')->list_category($this->request->param('id'),FALSE); else - $prods = ORM::factory('product')->order_by('status 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'), @@ -72,13 +72,13 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { * Edit a product configuration */ public function action_update() { - $po = ORM::factory('product',$this->request->param('id')); + $po = ORM::factory('Product',$this->request->param('id')); if (! $po->loaded()) - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); if ($_POST) { - if (isset($_POST['product_translate']['id']) AND ($pto=ORM::factory('product_translate',$_POST['product_translate']['id'])) AND $pto->loaded()) + if (isset($_POST['product_translate']['id']) AND ($pto=ORM::factory('Product_Translate',$_POST['product_translate']['id'])) AND $pto->loaded()) if (! $pto->values($_POST['product_translate'])->save()) throw new Kohana_Exception('Failed to save updates to product_translate data for record :record',array(':record'=>$po->id())); @@ -118,12 +118,12 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin { } public function action_view() { - $po = ORM::factory('product',$this->request->param('id')); + $po = ORM::factory('Product',$this->request->param('id')); Block::add(array( 'title'=>sprintf('%s: %s',_('Current Services Using this Product'),$po->name()), 'body'=>Table::display( - ORM::factory('service')->where('product_id','=',$po->id)->find_all(), + ORM::factory('Service')->where('product_id','=',$po->id)->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'user/service/view/'), diff --git a/modules/product/classes/controller/product.php b/modules/product/classes/Controller/Product.php similarity index 65% rename from modules/product/classes/controller/product.php rename to modules/product/classes/Controller/Product.php index 91f3c18c..1bbd7519 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 .= '
    '; - foreach (ORM::factory('product_category')->list_active() as $pco) { + foreach (ORM::factory('Product_Category')->list_active() as $pco) { $a = '

    '.$pco->display('name').'

    '; $a .= '

    '.$pco->description().'

    '; @@ -35,15 +35,17 @@ class Controller_Product extends Controller_TemplateDefault { * @todo Only show categories according to their validity dates * @todo Obey sort order */ - public function action_category($id) { - $cat = ORM::factory('product_category',$id); + public function action_category() { + $id = $this->request->param('id'); + + $cat = ORM::factory('Product_Category',$id); if (! $cat->loaded()) - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); - Breadcrumb::name($this->request->uri(),$cat->name); - Breadcrumb::url('product','product/categorys'); - Breadcrumb::url('product/category','product/categorys'); + BreadCrumb::name($this->request->uri(),$cat->name); + BreadCrumb::url('product','product/categorys'); + BreadCrumb::url('product/category','product/categorys'); Block::add(array( 'title'=>sprintf('%s: %s',_('Category'),$cat->name), @@ -57,31 +59,33 @@ class Controller_Product extends Controller_TemplateDefault { * Obtain a list of pages in a category */ private function _get_category($id) { - return ORM::factory('product')->list_category($id); + return ORM::factory('Product')->list_category($id); } /** * Show a product */ - public function action_view($id) { - $po = ORM::factory('product',$id); + public function action_view() { + $id = $this->request->param('id'); + + $po = ORM::factory('Product',$id); if (! $po->loaded()) - Request::current()->redirect('product_category/index'); + HTTP::redirect('Product_Category/index'); - Breadcrumb::name($this->request->uri(),$po->product_translate->find()->name); - Breadcrumb::url('product','product/categorys'); + BreadCrumb::name($this->request->uri(),$po->product_translate->find()->name); + BreadCrumb::url('product','product/categorys'); // Work out our category id for the control line if (! empty($_GET['cid'])) { - $co = ORM::factory('product_category',$_GET['cid']); + $co = ORM::factory('Product_Category',$_GET['cid']); // If the product category doesnt exist, or doesnt match the product if (! $co->loaded() OR ! in_array($co->id,unserialize($po->avail_category))) - Request::current()->redirect('product_category/index'); + HTTP::redirect('Product_Category/index'); - Breadcrumb::name('product/view',$co->name); - Breadcrumb::url('product/view','product/category/'.$co->id); + BreadCrumb::name('product/view',$co->name); + BreadCrumb::url('product/view','product/category/'.$co->id); } Block::add(array( diff --git a/modules/product/classes/controller/product/category.php b/modules/product/classes/Controller/Product/Category.php similarity index 90% rename from modules/product/classes/controller/product/category.php rename to modules/product/classes/Controller/Product/Category.php index 95aa3f5f..f73ff308 100644 --- a/modules/product/classes/controller/product/category.php +++ b/modules/product/classes/Controller/Product/Category.php @@ -15,7 +15,7 @@ class Controller_Product_Category extends Controller_TemplateDefault { * By default show a menu of available categories */ public function action_index() { - Request::current()->redirect('product_category/list'); + HTTP::redirect('product_category/list'); } public function action_list() { @@ -33,7 +33,7 @@ class Controller_Product_Category extends Controller_TemplateDefault { * @todo Move this to the model */ private function _get_categories() { - return ORM::factory('product_category') + return ORM::factory('Product_Category') ->list_active(); } } diff --git a/modules/product/classes/model/product.php b/modules/product/classes/Model/Product.php similarity index 98% rename from modules/product/classes/model/product.php rename to modules/product/classes/Model/Product.php index b11f654e..c7e4ba4c 100644 --- a/modules/product/classes/model/product.php +++ b/modules/product/classes/Model/Product.php @@ -56,7 +56,7 @@ class Model_Product extends ORM_OSB { if (! is_numeric($this->prod_plugin_data)) throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->id,':type'=>$this->prod_plugin_file)); - return ORM::factory(sprintf('product_plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data); + return ORM::factory(sprintf('Product_Plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data); } /** diff --git a/modules/product/classes/model/product/category.php b/modules/product/classes/Model/Product/Category.php similarity index 100% rename from modules/product/classes/model/product/category.php rename to modules/product/classes/Model/Product/Category.php diff --git a/modules/product/classes/model/product/category/translate.php b/modules/product/classes/Model/Product/Category/Translate.php similarity index 100% rename from modules/product/classes/model/product/category/translate.php rename to modules/product/classes/Model/Product/Category/Translate.php diff --git a/modules/product/classes/model/product/plugin.php b/modules/product/classes/Model/Product/Plugin.php similarity index 100% rename from modules/product/classes/model/product/plugin.php rename to modules/product/classes/Model/Product/Plugin.php diff --git a/modules/product/classes/model/product/translate.php b/modules/product/classes/Model/Product/Translate.php similarity index 100% rename from modules/product/classes/model/product/translate.php rename to modules/product/classes/Model/Product/Translate.php diff --git a/modules/product/views/product/admin/update.php b/modules/product/views/product/admin/update.php index c134c0aa..654daaea 100644 --- a/modules/product/views/product/admin/update.php +++ b/modules/product/views/product/admin/update.php @@ -27,7 +27,7 @@ availPriceGroups() as $g) { ?> availPriceOptions() as $o) { ?>
- + @@ -48,7 +48,7 @@ - + diff --git a/modules/service/classes/controller/admin/service.php b/modules/service/classes/Controller/Admin/Service.php similarity index 94% rename from modules/service/classes/controller/admin/service.php rename to modules/service/classes/Controller/Admin/Service.php index 3361a783..9b92c1ed 100644 --- a/modules/service/classes/controller/admin/service.php +++ b/modules/service/classes/Controller/Admin/Service.php @@ -36,7 +36,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_ajaxlist() { $return = array(); - $return += ORM::factory('service')->list_autocomplete( + $return += ORM::factory('Service')->list_autocomplete( isset($_REQUEST['term']) ? $_REQUEST['term'] : '', 'id', isset($_REQUEST['aid']) ? array(array('account_id','=',$_REQUEST['aid'])) : array()); @@ -48,7 +48,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_ajaxjson_traffic() { $return = array(); - $svs = ORM::factory('service')->list_bylistgroup('ADSL'); + $svs = ORM::factory('Service')->list_bylistgroup('ADSL'); $data = $this->consoltraffic($svs,time()); $google = GoogleChart::factory('ComboChart'); @@ -70,7 +70,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Customer Services'), 'body'=>Table::display( - ORM::factory('service')->find_all(), + ORM::factory('Service')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'user/service/view/'), @@ -95,9 +95,9 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_listbycheckout() { $svs = array(); // @todo This needs to be configurable - $go = ORM::factory('group',array('name'=>'Personal')); + $go = ORM::factory('Group',array('name'=>'Personal')); - foreach (ORM::factory('account')->list_active() as $ao) + foreach (ORM::factory('Account')->list_active() as $ao) if ($ao->has_any('group',array($go))) foreach ($ao->service->list_active() as $so) if (! $so->service_billing->checkout_plugin_id) @@ -127,7 +127,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { )), )); - foreach (ORM::factory('checkout')->list_active() as $co) { + foreach (ORM::factory('Checkout')->list_active() as $co) { $svs = array(); foreach ($co->account->find_all() as $ao) @@ -194,7 +194,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listadslservices() { - $svs = ORM::factory('service')->list_bylistgroup('ADSL'); + $svs = ORM::factory('Service')->list_bylistgroup('ADSL'); $data = $this->consoltraffic($svs,time()); $google = GoogleChart::factory('ComboChart') @@ -238,7 +238,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { * Show a list of services that are expiring or have expired */ public function action_listexpiring() { - $svs = ORM::factory('service')->list_expiring(); + $svs = ORM::factory('Service')->list_expiring(); Sort::MAsort($svs,'expire()'); @@ -261,7 +261,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listhspaservices() { - $svs = ORM::factory('service')->list_bylistgroup('HSPA'); + $svs = ORM::factory('Service')->list_bylistgroup('HSPA'); $data = $this->consoltraffic($svs,time()); $google = GoogleChart::factory('Legacy') @@ -302,7 +302,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listdomainservices() { - $svs = ORM::factory('service')->list_bylistgroup('DOMAIN'); + $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); Sort::MAsort($svs,'name()'); Block::add(array( @@ -329,7 +329,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listdomainservicesbysupplier() { - $svs = ORM::factory('service')->list_bylistgroup('DOMAIN'); + $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); Sort::MAsort($svs,'plugin()->domain_registrar_id,name()'); $list = array(); @@ -362,13 +362,13 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listdomainservicesbydnshost() { - $svs = ORM::factory('service')->list_bylistgroup('DOMAIN'); - Sort::MAsort($svs,'plugin()->service_plugin_host,name()'); + $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); + Sort::MAsort($svs,'plugin()->service_plugin_HOST,name()'); $list = array(); foreach ($svs as $so) - $list[$so->plugin()->service_plugin_host->host_server_id][] = $so; + $list[$so->plugin()->service_plugin_HOST->host_server_id][] = $so; foreach (array_keys($list) as $sid) Block::add(array( @@ -392,7 +392,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listhostservices() { - $svs = ORM::factory('service')->list_bylistgroup('HOST'); + $svs = ORM::factory('Service')->list_bylistgroup('HOST'); Sort::MAsort($svs,'name()'); Block::add(array( @@ -419,7 +419,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listhostservicesbysupplier() { - $svs = ORM::factory('service')->list_bylistgroup('HOST'); + $svs = ORM::factory('Service')->list_bylistgroup('HOST'); Sort::MAsort($svs,'plugin()->host_server,name()'); $list = array(); @@ -452,7 +452,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listwebservices() { - $svs = ORM::factory('service')->list_bylistgroup('WEB'); + $svs = ORM::factory('Service')->list_bylistgroup('WEB'); Sort::MAsort($svs,'name()'); Block::add(array( @@ -482,8 +482,10 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { * * @todo this should really be in a different class, since adsl wont be part of the main app */ - public function action_listadslbilling($id) { - $aso = ORM::factory('adsl_supplier',$id); + public function action_listadslbilling() { + $id = $this->request->param('id'); + + $aso = ORM::factory('ADSL_Supplier',$id); // Process upload // @todo This should be separated out by supplier in case each supplier has a different format @@ -646,7 +648,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Services to Invoice'), 'body'=>Table::display( - ORM::factory('service')->list_invoicesoon(ORM::factory('invoice')->config('GEN_SOON_DAYS')), + ORM::factory('Service')->list_invoicesoon(ORM::factory('Invoice')->config('GEN_SOON_DAYS')), 25, array( 'id'=>array('label'=>'ID','url'=>'user/service/view/'), @@ -669,10 +671,10 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_update() { $id = $this->request->param('id'); - $so = ORM::factory('service',$id); + $so = ORM::factory('Service',$id); if (! $so->loaded()) - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); if ($_POST) { if (isset($_POST['plugin']) AND $_POST['plugin']) @@ -717,7 +719,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_view() { list($id,$output) = Table::page(__METHOD__); - $so = ORM::factory('service',$id); + $so = ORM::factory('Service',$id); if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) { $this->template->content = 'Unauthorised or doesnt exist?'; @@ -781,7 +783,8 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } if (isset($_REQUEST['go'])) - $this->request->redirect('admin/service/view/'.$so->id); + HTTP::redirect('admin/service/view/'.$so->id); + Block::add(array( 'title'=>sprintf('Transaction History for %s: %s',$so->id(),$so->name()), 'body'=>$loutput, @@ -803,7 +806,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { public function action_adslstat() { $output = ''; - $svs = ORM::factory('service')->list_bylistgroup('ADSL'); + $svs = ORM::factory('Service')->list_bylistgroup('ADSL'); $stats = array(); // @todo This needs to be configurable. $traffic = array(1000,2000,5000,10000,25000,50000,75000,100000); diff --git a/modules/service/classes/controller/affiliate/service.php b/modules/service/classes/Controller/Affiliate/Service.php similarity index 94% rename from modules/service/classes/controller/affiliate/service.php rename to modules/service/classes/Controller/Affiliate/Service.php index c3232ce6..1fd5f24d 100644 --- a/modules/service/classes/controller/affiliate/service.php +++ b/modules/service/classes/Controller/Affiliate/Service.php @@ -27,7 +27,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate Block::add(array( 'title'=>_('Customer Services'), 'body'=>Table::display( - $this->filter(ORM::factory('service')->list_active(),$this->ao->affiliate->id), + $this->filter(ORM::factory('Service')->list_active(),$this->ao->affiliate->id), 25, array( 'id'=>array('label'=>'ID','url'=>'user/service/view/'), @@ -52,9 +52,9 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate public function action_listbycheckout() { $svs = array(); // @todo This needs to be configurable - $go = ORM::factory('group',array('name'=>'Personal')); + $go = ORM::factory('Group',array('name'=>'Personal')); - foreach (ORM::factory('account')->list_active() as $ao) + foreach (ORM::factory('Account')->list_active() as $ao) if ($ao->has_any('group',array($go))) foreach ($this->filter($ao->service->list_active(),$this->ao->affiliate->id,'name()') as $so) if (! $so->service_billing->checkout_plugin_id) @@ -89,7 +89,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate 'body'=>_('None found'), )); - foreach (ORM::factory('checkout')->list_active() as $co) { + foreach (ORM::factory('Checkout')->list_active() as $co) { $svs = array(); foreach ($co->account->find_all() as $ao) @@ -156,7 +156,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate } public function action_listadslservices() { - $svs = $this->filter(ORM::factory('service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()'); + $svs = $this->filter(ORM::factory('Service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()'); $data = $this->consoltraffic($svs,time()); $google = GoogleChart::factory('Legacy') @@ -197,7 +197,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate } public function action_listhspaservices() { - $svs = $this->filter(ORM::factory('service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()'); + $svs = $this->filter(ORM::factory('Service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()'); $data = $this->consoltraffic($svs,time()); $google = GoogleChart::factory('Legacy') @@ -241,7 +241,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate Block::add(array( 'title'=>_('Domain Names'), 'body'=>Table::display( - $this->filter(ORM::factory('service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'), + $this->filter(ORM::factory('Service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'), 25, array( 'id'=>array('label'=>'ID','url'=>'user/service/view/'), @@ -265,7 +265,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate Block::add(array( 'title'=>_('Hosting Services'), 'body'=>Table::display( - $this->filter(ORM::factory('service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'), + $this->filter(ORM::factory('Service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'), 25, array( 'id'=>array('label'=>'ID','url'=>'user/service/view/'), diff --git a/modules/service/classes/controller/service.php b/modules/service/classes/Controller/Service.php similarity index 100% rename from modules/service/classes/controller/service.php rename to modules/service/classes/Controller/Service.php diff --git a/modules/service/classes/controller/task/service.php b/modules/service/classes/Controller/Task/Service.php similarity index 93% rename from modules/service/classes/controller/task/service.php rename to modules/service/classes/Controller/Task/Service.php index aad3bdf1..7fac9123 100644 --- a/modules/service/classes/controller/task/service.php +++ b/modules/service/classes/Controller/Task/Service.php @@ -12,7 +12,7 @@ */ class Controller_Task_Service extends Controller_Task { private function _traffic_suppliers($active=FALSE) { - $suppliers = ORM::factory('adsl_supplier'); + $suppliers = ORM::factory('Adsl_Supplier'); return $active ? $suppliers->list_active() : $suppliers->find_all(); } @@ -22,7 +22,7 @@ class Controller_Task_Service extends Controller_Task { */ public function action_gettraffic() { foreach ($this->_traffic_suppliers(TRUE) as $aso) { - if (CLI::options('verbose')) + if (Minion_CLI::options('verbose')) echo $aso->name."\n"; $traffic = Service_Traffic_ADSL::instance($aso->name)->update_traffic(); diff --git a/modules/service/classes/controller/user/service.php b/modules/service/classes/Controller/User/Service.php similarity index 95% rename from modules/service/classes/controller/user/service.php rename to modules/service/classes/Controller/User/Service.php index a01b2a08..7cba88e4 100644 --- a/modules/service/classes/controller/user/service.php +++ b/modules/service/classes/Controller/User/Service.php @@ -20,7 +20,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User { public function action_ajaxmanage() { $this->auto_render = FALSE; - $so = ORM::factory('service',$this->request->param('id')); + $so = ORM::factory('Service',$this->request->param('id')); $k = Session::instance()->get_once('manage_button'); $amo = $so->plugin(isset($_REQUEST['t']) ? $_REQUEST['t'] : ''); @@ -60,7 +60,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User { public function action_view() { list($id,$output) = Table::page(__METHOD__); - $so = ORM::factory('service',$id); + $so = ORM::factory('Service',$id); if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) { $this->template->content = 'Unauthorised or doesnt exist?'; diff --git a/modules/service/classes/model/service.php b/modules/service/classes/Model/Service.php similarity index 97% rename from modules/service/classes/model/service.php rename to modules/service/classes/Model/Service.php index 0579d8fd..a97155e9 100644 --- a/modules/service/classes/model/service.php +++ b/modules/service/classes/Model/Service.php @@ -56,7 +56,7 @@ class Model_Service extends ORM_OSB { if (! is_numeric($this->product->prod_plugin_data)) throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->product->id,':type'=>$this->product->prod_plugin_file)); - $o = ORM::factory(sprintf('service_plugin_%s',$this->product->prod_plugin_file),array('service_id'=>$this->id)); + $o = ORM::factory(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file),array('service_id'=>$this->id)); return $type ? $o->$type : $o; } @@ -208,7 +208,7 @@ class Model_Service extends ORM_OSB { public function list_bylistgroup($cat) { $result = array(); - $cats = ORM::factory('product_category')->list_bylistgroup($cat); + $cats = ORM::factory('Product_Category')->list_bylistgroup($cat); foreach ($this->list_active() as $so) { if (! $so->product->avail_category OR ! preg_match('/^a:/',$so->product->avail_category)) @@ -256,7 +256,7 @@ class Model_Service extends ORM_OSB { public function list_invoicesoon($days=0) { return $this->_where_active() ->where_open()->where('suspend_billing','IS',NULL)->or_where('suspend_billing','=','0')->where_close() - ->where('date_next_invoice','<',time()+(ORM::factory('invoice')->config('GEN_DAYS')+$days)*86400) + ->where('date_next_invoice','<',time()+(ORM::factory('Invoice')->config('GEN_DAYS')+$days)*86400) ->find_all(); } diff --git a/modules/service/classes/model/service/billing.php b/modules/service/classes/Model/Service/Billing.php similarity index 100% rename from modules/service/classes/model/service/billing.php rename to modules/service/classes/Model/Service/Billing.php diff --git a/modules/service/classes/model/service/plugin.php b/modules/service/classes/Model/Service/Plugin.php similarity index 100% rename from modules/service/classes/model/service/plugin.php rename to modules/service/classes/Model/Service/Plugin.php diff --git a/modules/ssl/classes/controller/admin/ssl.php b/modules/ssl/classes/Controller/Admin/Ssl.php similarity index 93% rename from modules/ssl/classes/controller/admin/ssl.php rename to modules/ssl/classes/Controller/Admin/Ssl.php index ab997d86..b49dfa27 100644 --- a/modules/ssl/classes/controller/admin/ssl.php +++ b/modules/ssl/classes/Controller/Admin/Ssl.php @@ -21,7 +21,7 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('SSL CA Certificates'), 'body'=>Table::display( - ORM::factory('ssl_ca')->find_all(), + ORM::factory('SSL_CA')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'admin/ssl/view/'), @@ -38,7 +38,7 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin { } private function add_view($id=NULL,$output='') { - $so = ORM::factory('ssl_ca',$id); + $so = ORM::factory('SSL_CA',$id); if ($_POST) { if ($so->values($_POST)->changed()) { @@ -84,14 +84,14 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin { list($id,$output) = Table::page(__METHOD__); Block::add(array( - 'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('ssl_ca',$id)->display('sign_cert')), + 'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('SSL_CA',$id)->display('sign_cert')), 'body'=>$this->add_view($id,$output), )); Block::add(array( 'title'=>_('Services using this Certificate'), 'body'=>Table::display( - ORM::factory('ssl_ca',$id)->list_issued(), + ORM::factory('SSL_CA',$id)->list_issued(), 25, array( 'id'=>array('label'=>'ID','url'=>'admin/service/view/'), diff --git a/modules/ssl/classes/controller/user/ssl.php b/modules/ssl/classes/Controller/User/Ssl.php similarity index 82% rename from modules/ssl/classes/controller/user/ssl.php rename to modules/ssl/classes/Controller/User/Ssl.php index 4748af9d..48960663 100644 --- a/modules/ssl/classes/controller/user/ssl.php +++ b/modules/ssl/classes/Controller/User/Ssl.php @@ -17,20 +17,20 @@ class Controller_User_SSL extends Controller_TemplateDefault_User { public function action_download() { $id = $_POST['sid']; - $so = ORM::factory('service',$id); + $so = ORM::factory('Service',$id); if (! $so->loaded()) - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); $passwd = $_POST['passwd']; - if (strlen($passwd) < Kohana::config('ssl.minpass_length')) { + if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) { SystemMessage::add(array( 'title'=>_('Validation failed'), 'type'=>'error', 'body'=>_('Your requested password is too short.'), )); - Request::current()->redirect('user/service/view/'.$so->id); + HTTP::redirect('user/service/view/'.$so->id); } if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) { @@ -38,7 +38,7 @@ class Controller_User_SSL extends Controller_TemplateDefault_User { return FALSE; } - $file = Kohana::config('config.tmpdir').'/'.$so->name().'.pkcs12'; + $file = sprintf('%s/%s.pkcs12',Kohana::$config->load('config')->tmpdir,$so->name()); openssl_pkcs12_export_to_file($so->plugin()->cert,$file,$so->plugin()->pk,$passwd,array('extracerts'=>$so->plugin()->cacerts())); $x = file_get_contents($file); unlink($file); diff --git a/modules/ssl/classes/model/product/plugin/ssl.php b/modules/ssl/classes/Model/Product/Plugin/SSL.php similarity index 100% rename from modules/ssl/classes/model/product/plugin/ssl.php rename to modules/ssl/classes/Model/Product/Plugin/SSL.php diff --git a/modules/ssl/classes/model/ssl.php b/modules/ssl/classes/Model/SSL.php similarity index 100% rename from modules/ssl/classes/model/ssl.php rename to modules/ssl/classes/Model/SSL.php diff --git a/modules/ssl/classes/model/ssl/ca.php b/modules/ssl/classes/Model/SSL/CA.php similarity index 100% rename from modules/ssl/classes/model/ssl/ca.php rename to modules/ssl/classes/Model/SSL/CA.php diff --git a/modules/ssl/classes/model/service/plugin/ssl.php b/modules/ssl/classes/Model/Service/Plugin/SSL.php similarity index 89% rename from modules/ssl/classes/model/service/plugin/ssl.php rename to modules/ssl/classes/Model/Service/Plugin/SSL.php index 2fd63778..7b2d9e03 100644 --- a/modules/ssl/classes/model/service/plugin/ssl.php +++ b/modules/ssl/classes/Model/Service/Plugin/SSL.php @@ -19,7 +19,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { 'service'=>array(), ); protected $_has_one = array( - 'ssl_ca'=>array('far_key'=>'ssl_ca_id','foreign_key'=>'id'), + 'SSL_CA'=>array('far_key'=>'ssl_ca_id','foreign_key'=>'id'), ); protected $_display_filters = array( @@ -74,7 +74,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { } public function name() { - return ($this->cert) ? sprintf('%s:%s',$this->ssl_ca->subject(),$this->display('cert')) : $this->display('csr'); + return ($this->cert AND $this->SSL_CA->loaded()) ? sprintf('%s:%s',$this->SSL_CA->subject(),$this->display('cert')) : $this->display('csr'); } public function service_view() { @@ -124,7 +124,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { $x = $this->ssl_ca_id; while ($x) { - $sco = ORM::factory('ssl_ca',$x); + $sco = ORM::factory('SSL_CA',$x); array_push($return,$sco->sign_cert); $x = $sco->parent_ssl_ca_id; } @@ -134,7 +134,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { public function renew() { $d = SSL::details($this->cert); - $ssl_conf = Kohana::config('ssl'); + $ssl_conf = Kohana::$config->load('ssl'); // @todo change this so an admin can force this. $force = TRUE; @@ -142,7 +142,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { 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->service->product->plugin()->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->service->product->plugin()->extensions, 'digest_alg'=>'sha1', @@ -156,8 +156,8 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { } else { print_r(array( 'csr'=>$this->csr, - 'ca'=>$this->ssl_ca->sign_cert, - 'capk'=>$this->ssl_ca->sign_pk, + 'ca'=>$this->SSL_CA->sign_cert, + 'capk'=>$this->SSL_CA->sign_pk, 'days'=>$this->service->product->plugin()->days, 'ssl'=>$ssl_conf, 'x509e'=>$this->service->product->plugin()->extensions diff --git a/modules/ssl/classes/ssl.php b/modules/ssl/classes/SSL.php similarity index 98% rename from modules/ssl/classes/ssl.php rename to modules/ssl/classes/SSL.php index 9bbbd3be..6c580b0b 100644 --- a/modules/ssl/classes/ssl.php +++ b/modules/ssl/classes/SSL.php @@ -202,10 +202,6 @@ class SSL { return $this->_details('version'); } - public static function xdn($cert) { - return static::instance($cert)->get_dn(); - } - public static function xexpire($cert,$format=FALSE) { return static::instance($cert)->get_expire($format); } diff --git a/modules/ssl/classes/controller/task/ssl.php b/modules/ssl/classes/Task/SSL/Renew.php similarity index 56% rename from modules/ssl/classes/controller/task/ssl.php rename to modules/ssl/classes/Task/SSL/Renew.php index 493e5015..fadd45e5 100644 --- a/modules/ssl/classes/controller/task/ssl.php +++ b/modules/ssl/classes/Task/SSL/Renew.php @@ -1,25 +1,22 @@ request->param('id'); - $so = ORM::factory('service',$id); - - $so->plugin()->renew(); + ORM::factory('Service',$params['id'])->plugin()->renew(); } } ?> diff --git a/modules/ssl/views/service/user/plugin/ssl/view.php b/modules/ssl/views/service/user/plugin/ssl/view.php index 856880b6..13e26b7c 100644 --- a/modules/ssl/views/service/user/plugin/ssl/view.php +++ b/modules/ssl/views/service/user/plugin/ssl/view.php @@ -19,7 +19,7 @@ - + diff --git a/modules/statement/classes/controller/statement.php b/modules/statement/classes/Controller/Statement.php similarity index 100% rename from modules/statement/classes/controller/statement.php rename to modules/statement/classes/Controller/Statement.php diff --git a/modules/statement/classes/controller/user/statement.php b/modules/statement/classes/Controller/User/Statement.php similarity index 100% rename from modules/statement/classes/controller/user/statement.php rename to modules/statement/classes/Controller/User/Statement.php diff --git a/modules/static_page/classes/controller/staticpage.php b/modules/static_page/classes/controller/staticpage.php index b8a69696..017a6fe5 100644 --- a/modules/static_page/classes/controller/staticpage.php +++ b/modules/static_page/classes/controller/staticpage.php @@ -15,7 +15,9 @@ class Controller_StaticPage extends Controller_TemplateDefault { * By default show a menu of available categories * @todo Only show categories according to their validity dates */ - public function action_view($id) { + public function action_view() { + $id = $this->request->param('id'); + $sp = ORM::factory('staticpage',$id); if (! $sp->loaded()) diff --git a/modules/static_page/classes/controller/staticpage/category.php b/modules/static_page/classes/controller/staticpage/category.php index a14c313b..bca01f95 100644 --- a/modules/static_page/classes/controller/staticpage/category.php +++ b/modules/static_page/classes/controller/staticpage/category.php @@ -15,7 +15,7 @@ class Controller_StaticPage_Category extends Controller_TemplateDefault { * By default show a menu of available categories */ public function action_index() { - Request::current()->redirect('staticpage_category/list'); + HTTP::redirect('staticpage_category/list'); } public function action_list() { @@ -31,11 +31,13 @@ class Controller_StaticPage_Category extends Controller_TemplateDefault { * @todo Only show categories according to their validity dates * @todo Obey sort order */ - public function action_view($id) { + public function action_view() { + $id = $this->request->param('id'); + $spc = ORM::factory('staticpage_category',$id); if (! $spc->loaded()) - Request::current()->redirect('welcome/index'); + HTTP::redirect('welcome/index'); Breadcrumb::name($this->request->uri(),$spc->name); diff --git a/modules/task/classes/controller/admin/task.php b/modules/task/classes/Controller/Admin/Task.php similarity index 93% rename from modules/task/classes/controller/admin/task.php rename to modules/task/classes/Controller/Admin/Task.php index 68a2f623..68944d11 100644 --- a/modules/task/classes/controller/admin/task.php +++ b/modules/task/classes/Controller/Admin/Task.php @@ -22,7 +22,7 @@ class Controller_Admin_Task extends Controller_TemplateDefault_Admin { Block::add(array( 'title'=>_('Task Log'), 'body'=>Table::display( - ORM::factory('task_log')->order_by('id','DESC')->find_all(), + ORM::factory('Task_Log')->order_by('id','DESC')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>'admin/task/view/'), diff --git a/modules/task/classes/model/task.php b/modules/task/classes/Model/Task.php similarity index 98% rename from modules/task/classes/model/task.php rename to modules/task/classes/Model/Task.php index 62453833..818cd10f 100644 --- a/modules/task/classes/model/task.php +++ b/modules/task/classes/Model/Task.php @@ -19,7 +19,7 @@ class Model_Task extends ORM_OSB { public function run() { $r = rand(0,9999); - $tlo = ORM::factory('task_log'); + $tlo = ORM::factory('Task_Log'); $tlo->task_id = $this->id; if (! $this->loaded()) diff --git a/modules/task/classes/model/task/log.php b/modules/task/classes/Model/Task/Log.php similarity index 100% rename from modules/task/classes/model/task/log.php rename to modules/task/classes/Model/Task/Log.php diff --git a/modules/task/classes/Task/Task/ListActive.php b/modules/task/classes/Task/Task/ListActive.php new file mode 100644 index 00000000..fb3a5912 --- /dev/null +++ b/modules/task/classes/Task/Task/ListActive.php @@ -0,0 +1,36 @@ +list_active() as $t) { + $output .= sprintf('%2s %30s %21s %21s %40s', + $t['task']->id, + $t['task']->command, + $t['task']->display('date_run'), + Config::datetime($t['next']), + $t['task']->display('description') + ); + + $output .= "\n"; + }; + + echo $output; + } +} +?> diff --git a/modules/task/classes/Task/Task/Run.php b/modules/task/classes/Task/Task/Run.php new file mode 100644 index 00000000..4a691372 --- /dev/null +++ b/modules/task/classes/Task/Task/Run.php @@ -0,0 +1,47 @@ +loaded()) { + if (! $to->status) + throw new Minion_Exception_InvalidTask('Task :task (:name) NOT active',array(':task'=>$params['id'],':name'=>$to->name)); + + if (! Kohana::$config->load('debug')->task_sim) + $to->run(); + else + printf('Would Run task: (%s) %s',$params['id'],$to->name); + + echo "\n"; + + } else + throw new Minion_Exception_InvalidTask('Unknown task :task',array(':task'=>$params['id'])); + + } else { + $tlo = ORM::factory('Task'); + $t = time(); + + foreach ($tlo->list_active() as $to) + if ($to['next'] < $t) { + if (! Kohana::$config->load('debug')->task_sim) + $to['task']->run(); + else + printf('Would Run task: (%s) %s',$to['task']->id,$to['task']->name); + echo "\n"; + } + } + } +} +?> diff --git a/modules/task/classes/controller/task/task.php b/modules/task/classes/controller/task/task.php deleted file mode 100644 index bcda0ba7..00000000 --- a/modules/task/classes/controller/task/task.php +++ /dev/null @@ -1,59 +0,0 @@ -request->param('id'); - - if (! method_exists($to,$tm)) - throw new Kohana_Exception('Unknown Task List command :command',array(':command'=>$tm)); - - $output .= sprintf('%2s %30s %21s %21s %40s', - 'ID','Command','Last Run','Next Run','Description'); - $output .= "\n"; - - foreach ($to->$tm() as $t) { - $output .= sprintf('%2s %30s %21s %21s %40s', - $t['task']->id, - $t['task']->command, - $t['task']->display('date_run'), - Config::datetime($t['next']), - $t['task']->display('description') - ); - - $output .= "\n"; - }; - - $this->response->body($output); - } - - public function action_run() { - if ($id = $this->request->param('id')) { - $to = ORM::factory('task',$id); - $to->run(); - - } else { - $tlo = ORM::factory('task'); - $t = time(); - - foreach ($tlo->list_active() as $to) - if ($to['next'] < $t) - $to['task']->run(); - } - } -} -?> diff --git a/modules/tax/classes/model/invoice/item/tax.php b/modules/tax/classes/Model/Invoice/Item/Tax.php similarity index 100% rename from modules/tax/classes/model/invoice/item/tax.php rename to modules/tax/classes/Model/Invoice/Item/Tax.php diff --git a/modules/tax/classes/model/tax.php b/modules/tax/classes/Model/Tax.php similarity index 100% rename from modules/tax/classes/model/tax.php rename to modules/tax/classes/Model/Tax.php diff --git a/modules/tax/classes/tax.php b/modules/tax/classes/Tax.php similarity index 97% rename from modules/tax/classes/tax.php rename to modules/tax/classes/Tax.php index 62699faa..e82c183f 100644 --- a/modules/tax/classes/tax.php +++ b/modules/tax/classes/Tax.php @@ -20,7 +20,7 @@ class Tax { * @return array Tax Information */ public static function detail($cid,$zone,$value=0) { - $tax = ORM::factory('tax') + $tax = ORM::factory('Tax') ->where('country_id','=',$cid) ->and_where('zone','=',$zone) ->find_all();
id(); ?>
 Taxes Included:
  description; ?>
name; ?>name; ?> price($g,$k,$o),array('size'=>5)); ?>
Product Descriptions
 
CAssl_ca->subject(); ?>SSL_CA->loaded() ? $so->SSL_CA->subject() : $so->issuer(); ?>
Valid From