Move emailtemplate under email

This commit is contained in:
Deon George 2011-08-26 12:01:45 +10:00
parent 1c66acd7e4
commit 495da41e0d
16 changed files with 37 additions and 41 deletions

View File

@ -152,7 +152,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
$mt->save();
// Send our email with the token
$et = EmailTemplate::instance('account_reset_password');
$et = Email_Template::instance('account_reset_password');
$et->to = array($mt->account->email=>sprintf('%s %s',$mt->account->first_name,$mt->account->last_name));
$et->variables = array(
'SITE'=>URL::base(TRUE,TRUE),

View File

@ -10,26 +10,26 @@
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
class Controller_Admin_Email extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'add'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
'templateadd'=>TRUE,
'templateedit'=>TRUE,
'templatelist'=>TRUE,
);
/**
* List our defined email templates
*/
public function action_list() {
$eto = ORM::factory('emailtemplate');
public function action_templatelist() {
$eto = ORM::factory('email_template');
$output = '';
$output .= View::factory('admin/emailtemplate/list_header');
$output .= View::factory('email/admin/template/list_head');
foreach ($eto->find_all() as $et) {
$output .= View::factory('admin/emailtemplate/list_body')
$output .= View::factory('email/admin/template/list_body')
->set('template',$et);
}
$output .= View::factory('admin/emailtemplate/list_footer');
$output .= View::factory('email/admin/template/list_foot');
Block::add(array(
'title'=>_('Available Email Templates'),
@ -40,8 +40,8 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
/**
* Add a template
*/
public function action_add() {
$eto = ORM::factory('emailtemplate');
public function action_templateadd() {
$eto = ORM::factory('email_template');
$output = '';
if ($_POST AND $eto->values($_POST)->check()) {
@ -50,7 +50,7 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
// Entry updated
if ($eto->save()) {
$x = $eto->emailtemplate_translate->values($_POST['translate']['new']);
$x = $eto->email_template_translate->values($_POST['translate']['new']);
$x->email_template_id = $eto->id;
if ($x->check())
@ -59,8 +59,8 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
}
$output .= Form::open();
$output .= View::factory('admin/emailtemplate/add');
$output .= View::factory('admin/emailtemplate/add_translate');
$output .= View::factory('email/admin/template/add');
$output .= View::factory('email/admin/template/translate/add');
$output .= '<div>'.Form::submit('submit',_('Add')).'</div>';
$output .= Form::close();
@ -74,11 +74,11 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
/**
* Edit Template Definition
*/
public function action_edit($id) {
$eto = ORM::factory('emailtemplate',$id);
public function action_templateedit($id) {
$eto = ORM::factory('email_template',$id);
if (! $eto->loaded())
Request::current()->redirect('admin/emailtemplate/list');
Request::current()->redirect('email/admin/template/list');
$output = '';
@ -86,7 +86,7 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
// Entry updated
if ($eto->save()) {
foreach ($_POST['translate'] as $id => $details) {
$x = $eto->emailtemplate_translate->where('id','=',$id)->find();
$x = $eto->email_template_translate->where('id','=',$id)->find();
if ($x->values($details)->check())
$x->save();
@ -96,11 +96,11 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
$output .= Form::open();
$output .= View::factory('admin/emailtemplate/edit')
$output .= View::factory('email/admin/template/edit')
->set('template',$eto);
foreach ($eto->emailtemplate_translate->find_all() as $to) {
$output .= View::factory('admin/emailtemplate/edit_translate')
foreach ($eto->email_template_translate->find_all() as $to) {
$output .= View::factory('email/admin/template/translate/edit')
->set('translate',$to);
SystemMessage::add(array(

View File

@ -4,13 +4,13 @@
* This class provides email template functions
*
* @package OSB
* @subpackage EmailTemplate
* @subpackage Email_Template
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class EmailTemplate {
class Email_Template {
// We'll store the template here
private $template;
private $template_mail;
@ -19,7 +19,7 @@ class EmailTemplate {
private $components = array('subject','message_text','message_html');
public function __construct($template,$language_id=NULL) {
$this->template = ORM::factory('emailtemplate',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));
@ -27,9 +27,9 @@ class EmailTemplate {
if (is_null($language_id))
$language_id=$this->default_lang;
$this->template_mail = $this->template->emailtemplate_translate->where('language_id','=',$language_id)->find();
$this->template_mail = $this->template->email_template_translate->where('language_id','=',$language_id)->find();
if (! $this->template_mail->loaded() AND
($this->template_mail = $this->template->emailtemplate_translate->where('language_id','=',$this->default_lang)->find()) AND ! $this->template_mail->loaded())
($this->template_mail = $this->template->email_template_translate->where('language_id','=',$this->default_lang)->find()) AND ! $this->template_mail->loaded())
// @todo Change this to log/email the admin
throw new Kohana_Exception('No template (:template) found for user language (:language_id) or default language (:default_lang)',
@ -90,7 +90,7 @@ class EmailTemplate {
}
public static function instance($template) {
return new EmailTemplate($template);
return new Email_Template($template);
}
public function variables() {

View File

@ -9,11 +9,9 @@
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_EmailTemplate extends ORMOSB {
protected $_table_name = 'email_template';
class Model_Email_Template extends ORMOSB {
protected $_has_many = array(
'emailtemplate_translate'=>array('foreign_key'=>'email_template_id','far_key'=>'id'),
'email_template_translate'=>array('foreign_key'=>'email_template_id','far_key'=>'id'),
);
// This module doesnt keep track of column updates automatically

View File

@ -9,9 +9,7 @@
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_EmailTemplate_Translate extends ORMOSB {
protected $_table_name = 'email_template_translate';
class Model_Email_Template_Translate extends ORMOSB {
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;

View File

@ -0,0 +1,4 @@
<tr>
<td><a href="<?php echo URL::site(sprintf('/admin/email/templateedit/%s',$template->id)); ?>" alt=""><?php echo $template->name; ?></a></td>
<td><?php echo $template->display('active'); ?></td>
</tr>

View File

@ -1,4 +0,0 @@
<tr>
<td><a href="<?php echo URL::site(sprintf('/admin/emailtemplate/edit/%s',$template->id)); ?>" alt=""><?php echo $template->name; ?></a></td>
<td><?php echo $template->display('active'); ?></td>
</tr>

View File

@ -30,7 +30,7 @@ class Controller_Task_Invoice extends Controller_Task {
$duelist .= View::factory('invoice/task/'.$tm.'_footer');
// Send our email
$et = EmailTemplate::instance('task_invoice_overdue');
$et = Email_Template::instance('task_invoice_overdue');
// @todo Update this to be dynamic
$et->to = array('account'=>array(1,68));

View File

@ -141,7 +141,7 @@ class Service_Traffic_ADSL {
}
public function alert_traffic() {
$et = EmailTemplate::instance('adsl_traffic_notice');
$et = Email_Template::instance('adsl_traffic_notice');
foreach ($this->so->services() as $so) {
if (! $so->service_adsl->report_traffic())