Cart work for payments and Paypal work to test

This commit is contained in:
Deon George
2013-01-15 17:07:54 +11:00
parent 133ae4d5c6
commit 69645c4eea
42 changed files with 968 additions and 801 deletions

View File

@@ -37,77 +37,8 @@ abstract class ORM_OSB extends ORM {
);
}
/**
* 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'
@@ -155,7 +86,94 @@ abstract class ORM_OSB extends ORM {
return parent::__get($column);
}
public function formselect($blank) {
/**
* 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 x_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 xform($table,$blank=FALSE) {
return ORM::factory($table)->formselect($blank);
}
/**
* Retrieve and Store DB BLOB data.
*/
private function blob($data,$set=FALSE) {
try {
return $set ? gzcompress(serialize($data)) : unserialize(gzuncompress($data));
// Maybe the data isnt compressed?
} catch (Exception $e) {
return $set ? serialize($data) : unserialize($data);
}
}
public function config($key) {
$mc = Config::instance()->so->module_config($this->_object_name);
return empty($mc[$key]) ? '' : $mc[$key];
}
/**
* Get Next record id
*
* @param array Validate object
* @param string Primary Key
*/
final 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
*/
final 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 xformselect($blank) {
$result = array();
if ($blank)
@@ -174,6 +192,10 @@ abstract class ORM_OSB extends ORM {
return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL;
}
final public function mid() {
return ORM::factory('Module',array('name'=>$this->_table_name));
}
public function save(Validation $validation = NULL) {
// Find any fields that have changed, and process them.
if ($this->_changed)
@@ -194,19 +216,6 @@ abstract class ORM_OSB extends ORM {
return parent::save($validation);
}
/**
* 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();
}