Move emailtemplate under email
This commit is contained in:
parent
1c66acd7e4
commit
495da41e0d
@ -152,7 +152,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
$mt->save();
|
$mt->save();
|
||||||
|
|
||||||
// Send our email with the token
|
// 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->to = array($mt->account->email=>sprintf('%s %s',$mt->account->first_name,$mt->account->last_name));
|
||||||
$et->variables = array(
|
$et->variables = array(
|
||||||
'SITE'=>URL::base(TRUE,TRUE),
|
'SITE'=>URL::base(TRUE,TRUE),
|
||||||
|
@ -10,26 +10,26 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @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(
|
protected $secure_actions = array(
|
||||||
'add'=>TRUE,
|
'templateadd'=>TRUE,
|
||||||
'edit'=>TRUE,
|
'templateedit'=>TRUE,
|
||||||
'list'=>TRUE,
|
'templatelist'=>TRUE,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List our defined email templates
|
* List our defined email templates
|
||||||
*/
|
*/
|
||||||
public function action_list() {
|
public function action_templatelist() {
|
||||||
$eto = ORM::factory('emailtemplate');
|
$eto = ORM::factory('email_template');
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
$output .= View::factory('admin/emailtemplate/list_header');
|
$output .= View::factory('email/admin/template/list_head');
|
||||||
foreach ($eto->find_all() as $et) {
|
foreach ($eto->find_all() as $et) {
|
||||||
$output .= View::factory('admin/emailtemplate/list_body')
|
$output .= View::factory('email/admin/template/list_body')
|
||||||
->set('template',$et);
|
->set('template',$et);
|
||||||
}
|
}
|
||||||
$output .= View::factory('admin/emailtemplate/list_footer');
|
$output .= View::factory('email/admin/template/list_foot');
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>_('Available Email Templates'),
|
'title'=>_('Available Email Templates'),
|
||||||
@ -40,8 +40,8 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
|||||||
/**
|
/**
|
||||||
* Add a template
|
* Add a template
|
||||||
*/
|
*/
|
||||||
public function action_add() {
|
public function action_templateadd() {
|
||||||
$eto = ORM::factory('emailtemplate');
|
$eto = ORM::factory('email_template');
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
if ($_POST AND $eto->values($_POST)->check()) {
|
if ($_POST AND $eto->values($_POST)->check()) {
|
||||||
@ -50,7 +50,7 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
|||||||
|
|
||||||
// Entry updated
|
// Entry updated
|
||||||
if ($eto->save()) {
|
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;
|
$x->email_template_id = $eto->id;
|
||||||
if ($x->check())
|
if ($x->check())
|
||||||
@ -59,8 +59,8 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$output .= Form::open();
|
$output .= Form::open();
|
||||||
$output .= View::factory('admin/emailtemplate/add');
|
$output .= View::factory('email/admin/template/add');
|
||||||
$output .= View::factory('admin/emailtemplate/add_translate');
|
$output .= View::factory('email/admin/template/translate/add');
|
||||||
$output .= '<div>'.Form::submit('submit',_('Add')).'</div>';
|
$output .= '<div>'.Form::submit('submit',_('Add')).'</div>';
|
||||||
$output .= Form::close();
|
$output .= Form::close();
|
||||||
|
|
||||||
@ -74,11 +74,11 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
|||||||
/**
|
/**
|
||||||
* Edit Template Definition
|
* Edit Template Definition
|
||||||
*/
|
*/
|
||||||
public function action_edit($id) {
|
public function action_templateedit($id) {
|
||||||
$eto = ORM::factory('emailtemplate',$id);
|
$eto = ORM::factory('email_template',$id);
|
||||||
|
|
||||||
if (! $eto->loaded())
|
if (! $eto->loaded())
|
||||||
Request::current()->redirect('admin/emailtemplate/list');
|
Request::current()->redirect('email/admin/template/list');
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
|||||||
// Entry updated
|
// Entry updated
|
||||||
if ($eto->save()) {
|
if ($eto->save()) {
|
||||||
foreach ($_POST['translate'] as $id => $details) {
|
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())
|
if ($x->values($details)->check())
|
||||||
$x->save();
|
$x->save();
|
||||||
@ -96,11 +96,11 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
|||||||
|
|
||||||
$output .= Form::open();
|
$output .= Form::open();
|
||||||
|
|
||||||
$output .= View::factory('admin/emailtemplate/edit')
|
$output .= View::factory('email/admin/template/edit')
|
||||||
->set('template',$eto);
|
->set('template',$eto);
|
||||||
|
|
||||||
foreach ($eto->emailtemplate_translate->find_all() as $to) {
|
foreach ($eto->email_template_translate->find_all() as $to) {
|
||||||
$output .= View::factory('admin/emailtemplate/edit_translate')
|
$output .= View::factory('email/admin/template/translate/edit')
|
||||||
->set('translate',$to);
|
->set('translate',$to);
|
||||||
|
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
@ -4,13 +4,13 @@
|
|||||||
* This class provides email template functions
|
* This class provides email template functions
|
||||||
*
|
*
|
||||||
* @package OSB
|
* @package OSB
|
||||||
* @subpackage EmailTemplate
|
* @subpackage Email_Template
|
||||||
* @category Helpers
|
* @category Helpers
|
||||||
* @author Deon George
|
* @author Deon George
|
||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class EmailTemplate {
|
class Email_Template {
|
||||||
// We'll store the template here
|
// We'll store the template here
|
||||||
private $template;
|
private $template;
|
||||||
private $template_mail;
|
private $template_mail;
|
||||||
@ -19,7 +19,7 @@ class EmailTemplate {
|
|||||||
private $components = array('subject','message_text','message_html');
|
private $components = array('subject','message_text','message_html');
|
||||||
|
|
||||||
public function __construct($template,$language_id=NULL) {
|
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())
|
if (! $this->template->loaded())
|
||||||
throw new Kohana_Exception('Email template :template not defined in DB',array(':template'=>$template));
|
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))
|
if (is_null($language_id))
|
||||||
$language_id=$this->default_lang;
|
$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
|
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
|
// @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)',
|
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) {
|
public static function instance($template) {
|
||||||
return new EmailTemplate($template);
|
return new Email_Template($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function variables() {
|
public function variables() {
|
@ -9,11 +9,9 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_EmailTemplate extends ORMOSB {
|
class Model_Email_Template extends ORMOSB {
|
||||||
protected $_table_name = 'email_template';
|
|
||||||
|
|
||||||
protected $_has_many = array(
|
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
|
// This module doesnt keep track of column updates automatically
|
@ -9,9 +9,7 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_EmailTemplate_Translate extends ORMOSB {
|
class Model_Email_Template_Translate extends ORMOSB {
|
||||||
protected $_table_name = 'email_template_translate';
|
|
||||||
|
|
||||||
// This module doesnt keep track of column updates automatically
|
// This module doesnt keep track of column updates automatically
|
||||||
protected $_created_column = FALSE;
|
protected $_created_column = FALSE;
|
||||||
protected $_updated_column = FALSE;
|
protected $_updated_column = FALSE;
|
4
modules/email/views/email/admin/template/list_body.php
Normal file
4
modules/email/views/email/admin/template/list_body.php
Normal 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>
|
@ -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>
|
|
@ -30,7 +30,7 @@ class Controller_Task_Invoice extends Controller_Task {
|
|||||||
$duelist .= View::factory('invoice/task/'.$tm.'_footer');
|
$duelist .= View::factory('invoice/task/'.$tm.'_footer');
|
||||||
|
|
||||||
// Send our email
|
// Send our email
|
||||||
$et = EmailTemplate::instance('task_invoice_overdue');
|
$et = Email_Template::instance('task_invoice_overdue');
|
||||||
|
|
||||||
// @todo Update this to be dynamic
|
// @todo Update this to be dynamic
|
||||||
$et->to = array('account'=>array(1,68));
|
$et->to = array('account'=>array(1,68));
|
||||||
|
@ -141,7 +141,7 @@ class Service_Traffic_ADSL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function alert_traffic() {
|
public function alert_traffic() {
|
||||||
$et = EmailTemplate::instance('adsl_traffic_notice');
|
$et = Email_Template::instance('adsl_traffic_notice');
|
||||||
|
|
||||||
foreach ($this->so->services() as $so) {
|
foreach ($this->so->services() as $so) {
|
||||||
if (! $so->service_adsl->report_traffic())
|
if (! $so->service_adsl->report_traffic())
|
||||||
|
Reference in New Issue
Block a user