Work on Email and other major consistency work
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
class Model_Email_Template extends ORM_OSB {
|
||||
protected $_has_many = array(
|
||||
'email_template_translate'=>array('foreign_key'=>'email_template_id','far_key'=>'id'),
|
||||
'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
// This module doesnt keep track of column updates automatically
|
||||
@@ -27,8 +27,29 @@ class Model_Email_Template extends ORM_OSB {
|
||||
),
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user