From 495da41e0db4022651d4bf7a42752e6a3cab9d8b Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 26 Aug 2011 12:01:45 +1000 Subject: [PATCH] Move emailtemplate under email --- .../classes/controller/lnapp/login.php | 2 +- .../classes/controller/admin/email.php} | 42 +++++++++---------- .../classes/controller/email/template.php} | 0 .../classes/email/template.php} | 12 +++--- .../classes/model/email/template.php} | 6 +-- .../model/email/template}/translate.php | 4 +- .../views/email/admin/template}/add.php | 0 .../views/email/admin/template}/edit.php | 0 .../views/email/admin/template/list_body.php | 4 ++ .../views/email/admin/template/list_foot.php} | 0 .../views/email/admin/template/list_head.php} | 0 .../email/admin/template/translate/add.php} | 0 .../email/admin/template/translate/edit.php} | 0 .../views/admin/emailtemplate/list_body.php | 4 -- .../classes/controller/task/invoice.php | 2 +- .../service/classes/service/traffic/adsl.php | 2 +- 16 files changed, 37 insertions(+), 41 deletions(-) rename modules/{emailtemplate/classes/controller/admin/emailtemplate.php => email/classes/controller/admin/email.php} (64%) rename modules/{emailtemplate/classes/controller/emailtemplate.php => email/classes/controller/email/template.php} (100%) rename modules/{emailtemplate/classes/emailtemplate.php => email/classes/email/template.php} (91%) rename modules/{emailtemplate/classes/model/emailtemplate.php => email/classes/model/email/template.php} (77%) rename modules/{emailtemplate/classes/model/emailtemplate => email/classes/model/email/template}/translate.php (86%) rename modules/{emailtemplate/views/admin/emailtemplate => email/views/email/admin/template}/add.php (100%) rename modules/{emailtemplate/views/admin/emailtemplate => email/views/email/admin/template}/edit.php (100%) create mode 100644 modules/email/views/email/admin/template/list_body.php rename modules/{emailtemplate/views/admin/emailtemplate/list_footer.php => email/views/email/admin/template/list_foot.php} (100%) rename modules/{emailtemplate/views/admin/emailtemplate/list_header.php => email/views/email/admin/template/list_head.php} (100%) rename modules/{emailtemplate/views/admin/emailtemplate/add_translate.php => email/views/email/admin/template/translate/add.php} (100%) rename modules/{emailtemplate/views/admin/emailtemplate/edit_translate.php => email/views/email/admin/template/translate/edit.php} (100%) delete mode 100644 modules/emailtemplate/views/admin/emailtemplate/list_body.php diff --git a/application/classes/controller/lnapp/login.php b/application/classes/controller/lnapp/login.php index 919d3801..e6fe1297 100644 --- a/application/classes/controller/lnapp/login.php +++ b/application/classes/controller/lnapp/login.php @@ -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), diff --git a/modules/emailtemplate/classes/controller/admin/emailtemplate.php b/modules/email/classes/controller/admin/email.php similarity index 64% rename from modules/emailtemplate/classes/controller/admin/emailtemplate.php rename to modules/email/classes/controller/admin/email.php index ab18d5d9..c3909f12 100644 --- a/modules/emailtemplate/classes/controller/admin/emailtemplate.php +++ b/modules/email/classes/controller/admin/email.php @@ -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 .= '
'.Form::submit('submit',_('Add')).'
'; $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( diff --git a/modules/emailtemplate/classes/controller/emailtemplate.php b/modules/email/classes/controller/email/template.php similarity index 100% rename from modules/emailtemplate/classes/controller/emailtemplate.php rename to modules/email/classes/controller/email/template.php diff --git a/modules/emailtemplate/classes/emailtemplate.php b/modules/email/classes/email/template.php similarity index 91% rename from modules/emailtemplate/classes/emailtemplate.php rename to modules/email/classes/email/template.php index c3da2150..e576b65b 100644 --- a/modules/emailtemplate/classes/emailtemplate.php +++ b/modules/email/classes/email/template.php @@ -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() { diff --git a/modules/emailtemplate/classes/model/emailtemplate.php b/modules/email/classes/model/email/template.php similarity index 77% rename from modules/emailtemplate/classes/model/emailtemplate.php rename to modules/email/classes/model/email/template.php index 22d5282f..10aff29e 100644 --- a/modules/emailtemplate/classes/model/emailtemplate.php +++ b/modules/email/classes/model/email/template.php @@ -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 diff --git a/modules/emailtemplate/classes/model/emailtemplate/translate.php b/modules/email/classes/model/email/template/translate.php similarity index 86% rename from modules/emailtemplate/classes/model/emailtemplate/translate.php rename to modules/email/classes/model/email/template/translate.php index eb7f3308..b1dabe32 100644 --- a/modules/emailtemplate/classes/model/emailtemplate/translate.php +++ b/modules/email/classes/model/email/template/translate.php @@ -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; diff --git a/modules/emailtemplate/views/admin/emailtemplate/add.php b/modules/email/views/email/admin/template/add.php similarity index 100% rename from modules/emailtemplate/views/admin/emailtemplate/add.php rename to modules/email/views/email/admin/template/add.php diff --git a/modules/emailtemplate/views/admin/emailtemplate/edit.php b/modules/email/views/email/admin/template/edit.php similarity index 100% rename from modules/emailtemplate/views/admin/emailtemplate/edit.php rename to modules/email/views/email/admin/template/edit.php diff --git a/modules/email/views/email/admin/template/list_body.php b/modules/email/views/email/admin/template/list_body.php new file mode 100644 index 00000000..60c03190 --- /dev/null +++ b/modules/email/views/email/admin/template/list_body.php @@ -0,0 +1,4 @@ + + name; ?> + display('active'); ?> + diff --git a/modules/emailtemplate/views/admin/emailtemplate/list_footer.php b/modules/email/views/email/admin/template/list_foot.php similarity index 100% rename from modules/emailtemplate/views/admin/emailtemplate/list_footer.php rename to modules/email/views/email/admin/template/list_foot.php diff --git a/modules/emailtemplate/views/admin/emailtemplate/list_header.php b/modules/email/views/email/admin/template/list_head.php similarity index 100% rename from modules/emailtemplate/views/admin/emailtemplate/list_header.php rename to modules/email/views/email/admin/template/list_head.php diff --git a/modules/emailtemplate/views/admin/emailtemplate/add_translate.php b/modules/email/views/email/admin/template/translate/add.php similarity index 100% rename from modules/emailtemplate/views/admin/emailtemplate/add_translate.php rename to modules/email/views/email/admin/template/translate/add.php diff --git a/modules/emailtemplate/views/admin/emailtemplate/edit_translate.php b/modules/email/views/email/admin/template/translate/edit.php similarity index 100% rename from modules/emailtemplate/views/admin/emailtemplate/edit_translate.php rename to modules/email/views/email/admin/template/translate/edit.php diff --git a/modules/emailtemplate/views/admin/emailtemplate/list_body.php b/modules/emailtemplate/views/admin/emailtemplate/list_body.php deleted file mode 100644 index a4cbb605..00000000 --- a/modules/emailtemplate/views/admin/emailtemplate/list_body.php +++ /dev/null @@ -1,4 +0,0 @@ - - name; ?> - display('active'); ?> - diff --git a/modules/invoice/classes/controller/task/invoice.php b/modules/invoice/classes/controller/task/invoice.php index 97342a7e..06490553 100644 --- a/modules/invoice/classes/controller/task/invoice.php +++ b/modules/invoice/classes/controller/task/invoice.php @@ -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)); diff --git a/modules/service/classes/service/traffic/adsl.php b/modules/service/classes/service/traffic/adsl.php index 64cdf44b..bee7372b 100644 --- a/modules/service/classes/service/traffic/adsl.php +++ b/modules/service/classes/service/traffic/adsl.php @@ -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())