This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/email/classes/Model/Email/Template.php

56 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2013-10-10 02:44:53 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package Email
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Email_Template extends ORM_OSB {
protected $_has_many = array(
'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_id','far_key'=>'id'),
2013-10-10 02:44:53 +00:00
);
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
protected $_sorting = array(
'name'=>'ASC',
);
protected $_display_filters = array(
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
2013-10-10 02:44:53 +00:00
),
);
protected $_save_message = TRUE;
public function name() {
return ! is_null($this->description) ? $this->description : $this->name;
}
public function save(Validation $validation=NULL) {
parent::save();
// Save our Translated Message
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['translate']) AND is_array($_POST['translate'])) {
$to = $this->translate->where('language_id','=',$_POST['language_id'])->find();
// For a new entry, we need to set the product_id
if (! $to->loaded()) {
$to->product_id = $this->id;
$to->language_id = $_POST['language_id'];
}
$to->values($x['translate'])->save();
}
return $this;
}
2013-10-10 02:44:53 +00:00
}
?>