Misc fixes from live site

This commit is contained in:
Deon George
2013-07-05 16:11:37 +10:00
parent 3499776ddc
commit f3d2c1fe8d
21 changed files with 80 additions and 65 deletions

View File

@@ -170,7 +170,7 @@ class Config extends Kohana_Config {
public static function theme() {
// If we are using user admin pages (and login), we'll choose the admin theme.
return URL::admin_url() ? 'theme/'.Kohana::$config->load('config')->theme_admin : 'theme/'.Kohana::$config->load('config')->theme;
return 'theme/'.(URL::admin_url() ? Kohana::$config->load('config')->theme_admin : Kohana::$config->load('config')->theme);
}
public static function time($date) {

View File

@@ -22,8 +22,8 @@ class Controller_User_Search extends Controller_Search {
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>'r/account/view/')));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>'u/invoice/view/')));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>'u/invoice/view/')));
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));

View File

@@ -3,7 +3,7 @@
/**
* This class overrides Kohana's Cookie
*
* @package OSB
* @package OSB/Modifications
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing

View File

@@ -11,6 +11,9 @@
*/
class Currency {
public static function display($amount) {
if (! is_numeric($amount))
$amount = 0;
return Num::format($amount,Company::instance()->decimals(),TRUE);
}

View File

@@ -0,0 +1,18 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends the core Kohana class by adding some core application
* specific functions, and configuration.
*
* @package OSB
* @category Modifications
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class Database extends Kohana_Database {
public function caching() {
return isset($this->_config['caching']) ? $this->_config['caching'] : FALSE;
}
}
?>

View File

@@ -37,11 +37,9 @@ abstract class Kohana extends Kohana_Core {
$prefixes = array('');
// Our search order.
if (! preg_match('/^theme\//',$file)) {
array_unshift($prefixes,Config::theme().'/');
array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
}
array_unshift($prefixes,Config::theme().'/');
array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
foreach ($prefixes as $p)
if ($x = parent::find_file($dir,$p.$file,$ext,$array))

View File

@@ -21,7 +21,7 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
try {
$eo = ORM::factory('Log_Error');
$eo->message = Kohana_Exception::text($e);
$eo->account_id = Auth::instance()->get_user()->id;
$eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id;
if (Request::current()) {
$eo->module = (Request::current()->directory() ? Request::current()->directory().'_' : '').Request::current()->controller();

View File

@@ -65,6 +65,13 @@ abstract class ORM extends Kohana_ORM {
return $this->where('status','=',TRUE);
}
/**
* Overrides Kohana cache so that it can be globally disabled.
*/
public function cached($lifetime=NULL) {
return $this->_db->caching() ? parent::cached($lifetime) : $this;
}
public function clear() {
$this->_formated = FALSE;
$this->_object_formated = array();
@@ -151,7 +158,7 @@ abstract class ORM extends Kohana_ORM {
$query->and_where($k,$s,$v);
}
$c = 0;
$c = 0;
foreach ((empty($options['object']) ? $query->find_all() : $query->execute()) as $o) {
// If we got here via a DB query, we need to reload our ORM object from the result.
if (! is_object($o)) {
@@ -174,7 +181,7 @@ abstract class ORM extends Kohana_ORM {
}
$k = '';
foreach ($label as $k => $details)
foreach ($label as $k => $details)
foreach ($details as $lvalue)
$k = preg_replace('/%s/',$o->resolve($lvalue),$k,1);