Work on Email and other major consistency work
This commit is contained in:
parent
89deb9c97b
commit
c18d5a3881
@ -29,14 +29,9 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
||||
$mmo->module_id = $mo->id;
|
||||
$mmo->values($_POST);
|
||||
|
||||
if (! $mmo->check() OR ! $mmo->save())
|
||||
if (! $this->save($mmo))
|
||||
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
|
||||
|
||||
SystemMessage::factory()
|
||||
->title('Record added')
|
||||
->type('success')
|
||||
->body(_('Method record has been added.'));
|
||||
|
||||
HTTP::redirect(URL::link('admin','module/edit/'.$mo->id));
|
||||
}
|
||||
|
||||
@ -69,7 +64,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
||||
if ($_POST) {
|
||||
$mmo->values($_POST);
|
||||
|
||||
if (! $mmo->check() OR ! $mmo->save())
|
||||
if (! $this->save($mmo))
|
||||
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
|
||||
|
||||
foreach (ORM::factory('Group')->find_all() as $go) {
|
||||
@ -91,7 +86,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
||||
'group_id'=>$go->id,
|
||||
));
|
||||
|
||||
if (! $gmo->check() OR ! $gmo->save())
|
||||
if (! $this->save($gmo))
|
||||
SystemMessage::factory()
|
||||
->title(_('Unable to SAVE Group Method'))
|
||||
->type('error')
|
||||
|
@ -20,16 +20,8 @@ class Controller_Admin_Setup extends Controller_TemplateDefault {
|
||||
public function action_edit() {
|
||||
$o = Company::instance()->so();
|
||||
|
||||
// Store our new values
|
||||
$o->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($o->changed())
|
||||
if ($o->check() AND $o->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your setup record has been updated.'));
|
||||
if ($_POST AND $o->values($_POST)->changed() AND (! $this->save($o)))
|
||||
$o->reload();
|
||||
|
||||
Block::factory()
|
||||
->title('Update Site Configuration')
|
||||
|
22
application/classes/Controller/Admin/Welcome.php
Normal file
22
application/classes/Controller/Admin/Welcome.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB Admin Main home page
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Welcome extends Controller_Welcome {
|
||||
protected $auth_required = TRUE;
|
||||
public $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
HTTP::redirect(URL::link('reseller','welcome'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -50,17 +50,29 @@ abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefau
|
||||
parent::after();
|
||||
}
|
||||
|
||||
protected function save(Model $o) {
|
||||
try {
|
||||
$o->save();
|
||||
|
||||
return $o->saved();
|
||||
|
||||
} catch (ORM_Validation_Exception $e) {
|
||||
SystemMessage::factory()
|
||||
->title('Record NOT updated')
|
||||
->type('error')
|
||||
->body(join('<br/>',array_values($e->errors('models'))));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setup(array $config_items=array()) {
|
||||
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
|
||||
if (! $mo->loaded())
|
||||
throw HTTP_Exception::factory(501,'Unknown module :module',array(':module'=>Request::current()->controller()));
|
||||
|
||||
if ($_POST AND isset($_POST['module_config'][$mo->id]))
|
||||
if (Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your setup record has been updated.'));
|
||||
Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save();
|
||||
|
||||
if ($config_items) {
|
||||
Block::factory()
|
||||
@ -68,7 +80,6 @@ abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefau
|
||||
->title_icon('icon-wrench')
|
||||
->type('form-horizontal')
|
||||
->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,34 +19,8 @@ class Controller_User_Account extends Controller_Account {
|
||||
* Enable User to Edit their Account Details
|
||||
*/
|
||||
public function action_edit() {
|
||||
// Store our new values
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your account record has been updated.'));
|
||||
|
||||
$this->ao->save();
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
|
||||
// @todo Need to check that this still works with the new bootstrap theming
|
||||
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
||||
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||
|
||||
if ($output)
|
||||
$output = sprintf('<ul>%s</ul>',$output);
|
||||
|
||||
SystemMessage::factory()
|
||||
->title(_('Record NOT updated'))
|
||||
->type('error')
|
||||
->body(_('Your updates didnt pass validation.').'<br/>'.$output);
|
||||
}
|
||||
if ($_POST AND $this->ao->values($_POST)->changed() AND (! $this->save($this->ao)))
|
||||
$this->ao->reload();
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('Account: %s',$this->ao->accnum()))
|
||||
@ -70,7 +44,7 @@ class Controller_User_Account extends Controller_Account {
|
||||
->title(_('Record NOT updated'))
|
||||
->type('error')
|
||||
->body(_('Your password didnt pass validation.'));
|
||||
|
||||
|
||||
// Run validation and save
|
||||
elseif ($this->ao->changed())
|
||||
if ($this->ao->save()) {
|
||||
|
@ -40,6 +40,8 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
/**
|
||||
* Our account number format
|
||||
*/
|
||||
|
@ -22,8 +22,18 @@ class Model_Setup extends ORM_OSB {
|
||||
'language'=>array('foreign_key'=>'id','far_key'=>'language_id'),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
// Validation rules
|
||||
public function rules() {
|
||||
$r = parent::rules();
|
||||
$r = Arr::merge(parent::rules(), array(
|
||||
'url' => array(
|
||||
array('not_empty'),
|
||||
array('min_length', array(':value', 8)),
|
||||
array('max_length', array(':value', 127)),
|
||||
array('url'),
|
||||
),
|
||||
));
|
||||
|
||||
// This module doesnt use site_id.
|
||||
unset($r['site_id']);
|
||||
|
@ -22,6 +22,9 @@ abstract class ORM extends Kohana_ORM {
|
||||
// Tables that do not have a site_id column
|
||||
public static $no_site_id_tables = array('setup','country','currency','language','tax');
|
||||
|
||||
// Whether to show a SystemMessage when a record is saved.
|
||||
protected $_save_message = FALSE;
|
||||
|
||||
/**
|
||||
* Add our OSB site_id to each SELECT query
|
||||
* @see parent::__build()
|
||||
@ -215,6 +218,18 @@ abstract class ORM extends Kohana_ORM {
|
||||
return $x;
|
||||
}
|
||||
|
||||
public function save(Validation $validation=NULL) {
|
||||
parent::save();
|
||||
|
||||
if ($this->saved() AND $this->_save_message)
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Record %s:%s Updated',$this->_table_name,$this->id));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function where_active() {
|
||||
return $this->_where_active();
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ abstract class ORM_OSB extends ORM {
|
||||
return ORM::factory('Module',array('name'=>$this->_table_name));
|
||||
}
|
||||
|
||||
public function save(Validation $validation = NULL) {
|
||||
public function save(Validation $validation=NULL) {
|
||||
// Find any fields that have changed, and process them.
|
||||
if ($this->_changed)
|
||||
foreach ($this->_changed as $c) {
|
||||
@ -218,6 +218,10 @@ abstract class ORM_OSB extends ORM {
|
||||
} elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) {
|
||||
$this->_object[$c] = serialize($this->_object[$c]);
|
||||
}
|
||||
|
||||
// Test if the value has still changed
|
||||
if ($this->_original_values AND $this->_object[$c] == $this->_original_values[$c])
|
||||
unset($this->_changed[$c]);
|
||||
}
|
||||
|
||||
return parent::save($validation);
|
||||
|
@ -18,14 +18,10 @@
|
||||
echo HTML::style('media/theme/bootstrap/css/bootstrap.min.css');
|
||||
echo HTML::style('media/theme/bootstrap/css/bootstrap-responsive.min.css');
|
||||
echo HTML::style('media/vendor/font-awesome/css/font-awesome.min.css');
|
||||
// @todo Work out how to delay this loading until required
|
||||
echo HTML::style('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.css');
|
||||
} else {
|
||||
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.min.css');
|
||||
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css');
|
||||
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css');
|
||||
// @todo Work out how to delay this loading until required
|
||||
echo HTML::style($meta->secure().'cdn.jsdelivr.net/bootstrap.wysihtml5/0.0.2/bootstrap-wysihtml5-0.0.2.css');
|
||||
}
|
||||
|
||||
echo HTML::style($meta->secure().'fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,800italic,400,600,800');
|
||||
@ -73,7 +69,7 @@
|
||||
</li>
|
||||
<?php if (($ao = Auth::instance()->get_user()) AND $ao->isAdmin()) : ?>
|
||||
<li class="">
|
||||
<a href="<?php echo URL::link('reseller','welcome',TRUE); ?>"><i class="icon-tasks"></i> <span>Admin</span></a>
|
||||
<a href="<?php echo URL::link('admin','welcome',TRUE); ?>"><i class="icon-tasks"></i> <span>Admin</span></a>
|
||||
</li>
|
||||
<?php elseif ($ao->isReseller()) : ?>
|
||||
<li class="">
|
||||
@ -109,16 +105,10 @@
|
||||
if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure()) {
|
||||
echo HTML::script('media/js/jquery/jquery-1.9.1.min.js');
|
||||
echo HTML::script('media/theme/bootstrap/js/bootstrap.min.js');
|
||||
// @todo Work out how to delay this loading until required
|
||||
echo HTML::script('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/libs/js/wysihtml5-0.3.0_rc2.min.js');
|
||||
echo HTML::script('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js');
|
||||
echo HTML::script('media/js/lodash/lodash-1.2.1.min.js');
|
||||
} else {
|
||||
echo HTML::script($meta->secure().'code.jquery.com/jquery-1.9.1.min.js');
|
||||
echo HTML::script($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js');
|
||||
// @todo Work out how to delay this loading until required
|
||||
echo HTML::script($meta->secure().'cdn.jsdelivr.net/wysihtml5/0.3.0/wysihtml5-0.3.0.min.js');
|
||||
echo HTML::script($meta->secure().'cdn.jsdelivr.net/bootstrap.wysihtml5/0.0.2/bootstrap-wysihtml5-0.0.2.min.js');
|
||||
echo HTML::script($meta->secure().'cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js');
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<div class="shortcuts">
|
||||
<a href="<?php echo URL::link('user','email/list',TRUE); ?>" class="shortcut"><i class="shortcut-icon icon-list-alt"></i><span class="shortcut-label">Emails</span></a>
|
||||
<a href="<?php echo URL::link('user','invoice/list',TRUE); ?>" class="shortcut"><i class="shortcut-icon icon-list-alt"></i><span class="shortcut-label">Invoices</span></a>
|
||||
<a href="<?php echo URL::link('user','service/list',TRUE); ?>" class="shortcut"><i class="shortcut-icon icon-list-alt"></i><span class="shortcut-label">Services</span></a>
|
||||
</div>
|
||||
|
@ -68,26 +68,8 @@ class Controller_Admin_Adsl extends Controller_Adsl {
|
||||
HTTP::redirect(URL::link('admin','adsl/list'));
|
||||
|
||||
if ($_POST) {
|
||||
// Entry updated
|
||||
if ($apo->values($_POST)->check() AND $apo->changed()) {
|
||||
try {
|
||||
if ($apo->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your Charge record has been recorded/updated.'));
|
||||
|
||||
} catch (ORM_Validation_Exception $e) {
|
||||
$errors = $e->errors('models');
|
||||
|
||||
SystemMessage::factory()
|
||||
->title('Record NOT updated')
|
||||
->type('error')
|
||||
->body(join('<br/>',array_values($errors)));
|
||||
|
||||
$sco->reload();
|
||||
}
|
||||
}
|
||||
if ($apo->values($_POST)->changed() AND (! $this->save($apo)))
|
||||
$apo->reload();
|
||||
|
||||
if (isset($_POST['test'])) {
|
||||
$charge = isset($_POST['test']['charge']) ? $_POST['test']['charge'] : FALSE;
|
||||
|
@ -43,7 +43,7 @@ class Controller_Reseller_Service_Adsl extends Controller_Service {
|
||||
public function action_list() {
|
||||
$highchart = HighChart::factory('Combo');
|
||||
$highchart->title(sprintf('Monthly DSL traffic usage as at %s',date('Y-m-d',strtotime('yesterday'))));
|
||||
$highchart->xmetric('MB');
|
||||
$highchart->ymetric('MB');
|
||||
|
||||
$c = 0;
|
||||
foreach ($this->consoltraffic(time()) as $k => $details) {
|
||||
|
@ -352,9 +352,9 @@ $(document).ready(function() {
|
||||
$highchart = HighChart::factory('Combo');
|
||||
|
||||
switch ($this->plan()->metric) {
|
||||
case '1000' : $highchart->xmetric('GB'); break;
|
||||
case '1' : $highchart->xmetric('MB'); break;
|
||||
default: $highchart->xmetric('?');
|
||||
case '1000' : $highchart->ymetric('GB'); break;
|
||||
case '1' : $highchart->ymetric('MB'); break;
|
||||
default: $highchart->ymetric('?');
|
||||
}
|
||||
|
||||
$c=0;
|
||||
|
@ -31,6 +31,8 @@ class Task_Adsl_Trafficalert extends Minion_Task {
|
||||
// Get our variable data
|
||||
$et->to = array('account'=>array($so->account_id));
|
||||
$et->variables = $so->plugin()->template_variables($et->variables(),$data);
|
||||
$et->module = $so->mid();
|
||||
$et->module_data = $so->id;
|
||||
|
||||
$et->send();
|
||||
|
||||
|
@ -54,14 +54,8 @@ class Controller_Reseller_Charge extends Controller_Charge {
|
||||
private function add_edit($id=NULL,$output='') {
|
||||
$co = ORM::factory('Charge',$id);
|
||||
|
||||
if ($_POST) {
|
||||
// Entry updated
|
||||
if ($co->values($_POST)->check() AND $co->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your Charge record has been recorded/updated.'));
|
||||
}
|
||||
if ($_POST AND $co->values($_POST)->changed() AND (! $this->save($co)))
|
||||
$co->reload();
|
||||
|
||||
Script::factory()
|
||||
->type('file')
|
||||
|
@ -11,90 +11,87 @@
|
||||
*/
|
||||
class Controller_Admin_Email extends Controller_Email {
|
||||
protected $secure_actions = array(
|
||||
'ajaxtemplatetranslate'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'templateadd'=>TRUE,
|
||||
'templateedit'=>TRUE,
|
||||
'templatelist'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_ajaxtemplatetranslate() {
|
||||
$eto = ORM::factory('Email_Template',$this->request->param('id'));
|
||||
|
||||
if (! $eto->loaded() OR ! isset($_REQUEST['key'])) {
|
||||
$output = _('Unable to find translate data');
|
||||
|
||||
} else {
|
||||
$eto = $eto->translate->where('language_id','=',$_REQUEST['key'])->find();
|
||||
|
||||
$output = View::factory('email/admin/ajaxtemplatetranslate')
|
||||
->set('o',$eto);
|
||||
}
|
||||
|
||||
$this->template->content = $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of emails
|
||||
*/
|
||||
public function action_list() {
|
||||
Block::add(array(
|
||||
'title'=>_('System Emails Sent'),
|
||||
'body'=>Table::display(
|
||||
ORM::factory('Email_Log')->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','email/view/')),
|
||||
'date_orig'=>array('label'=>'Date'),
|
||||
'email'=>array('label'=>'To'),
|
||||
'translate_resolve("subject")'=>array('label'=>'Subject'),
|
||||
'account->accnum()'=>array('label'=>'Cust ID'),
|
||||
'account->name()'=>array('label'=>'Customer'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('user','email/view'),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* List our defined email templates
|
||||
*/
|
||||
public function action_templatelist() {
|
||||
$eto = ORM::factory('Email_Template');
|
||||
$output = '';
|
||||
|
||||
// @todo Change this to use Table::
|
||||
$output .= View::factory($this->viewpath().'/head');
|
||||
foreach ($eto->find_all() as $et) {
|
||||
$output .= View::factory($this->viewpath().'/body')
|
||||
->set('template',$et);
|
||||
}
|
||||
$output .= View::factory($this->viewpath().'/foot');
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Available Email Templates'),
|
||||
'body'=>$output,
|
||||
));
|
||||
Block::factory()
|
||||
->title(_('System Emails Sent'))
|
||||
->title_icon('icon-th')
|
||||
->body(Table::factory()
|
||||
->page_items(25)
|
||||
->data(ORM::factory('Email_Log')->find_all())
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'date_orig'=>'Date',
|
||||
'email'=>'To',
|
||||
'resolve("subject")'=>'Subject',
|
||||
'account->accnum()'=>'Cust ID',
|
||||
'account->name()'=>'Customer',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','email/view/')),
|
||||
))
|
||||
->postproc(array(
|
||||
'resolve("subject")'=>array('trim'=>60),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a template
|
||||
*/
|
||||
public function action_templateadd() {
|
||||
$eto = ORM::factory('Email_Template');
|
||||
$output = '';
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Add Email Template')
|
||||
->title_icon('icon-wrench')
|
||||
->body($this->add_edit_template());
|
||||
}
|
||||
|
||||
if ($_POST AND $eto->values($_POST)->check()) {
|
||||
// @todo To update the setup ID
|
||||
$eto->email_setup_id=1;
|
||||
|
||||
// Entry updated
|
||||
if ($eto->save()) {
|
||||
$x = $eto->email_template_translate->values($_POST['translate']['new']);
|
||||
|
||||
$x->email_template_id = $eto->id;
|
||||
if ($x->check())
|
||||
$x->save();
|
||||
}
|
||||
}
|
||||
|
||||
$output .= Form::open();
|
||||
$output .= View::factory($this->viewpath());
|
||||
$output .= View::factory($this->viewpath().'/translate');
|
||||
$output .= '<div>'.Form::submit('submit',_('Add'),array('class'=>'form_button')).'</div>';
|
||||
$output .= Form::close();
|
||||
|
||||
Editor::add();
|
||||
Block::add(array(
|
||||
'title'=>_('Available Email Templates'),
|
||||
'body'=>$output,
|
||||
));
|
||||
/**
|
||||
* List our defined email templates
|
||||
*/
|
||||
public function action_templatelist() {
|
||||
Block::factory()
|
||||
->title(_('System Emails Templates Available'))
|
||||
->title_icon('icon-th')
|
||||
->body(Table::factory()
|
||||
->page_items(25)
|
||||
->data(ORM::factory('Email_Template')->find_all())
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'name'=>'Name',
|
||||
'status'=>'Active',
|
||||
'description'=>'Descrption',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('admin','email/templateedit/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,51 +99,64 @@ class Controller_Admin_Email extends Controller_Email {
|
||||
* @todo Change this into an add_view function like payment()
|
||||
*/
|
||||
public function action_templateedit() {
|
||||
$id = $this->request->param('id');
|
||||
list($id,$output) = Table::page(__METHOD__);
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Update Email Template')
|
||||
->title_icon('icon-wrench')
|
||||
->body($this->add_edit_template($id,$output));
|
||||
}
|
||||
|
||||
private function add_edit_template($id=NULL,$output='') {
|
||||
$eto = ORM::factory('Email_Template',$id);
|
||||
|
||||
if (! $eto->loaded())
|
||||
HTTP::redirect(URL::link('admin','email/template/list'));
|
||||
if ($_POST) {
|
||||
// @todo To update the setup ID
|
||||
$eto->email_setup_id = '1';
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($_POST AND $eto->values($_POST)->check()) {
|
||||
// Entry updated
|
||||
if ($eto->save()) {
|
||||
foreach ($_POST['translate'] as $id => $details) {
|
||||
$x = $eto->email_template_translate->where('id','=',$id)->find();
|
||||
|
||||
if ($x->values($details)->check())
|
||||
$x->save();
|
||||
}
|
||||
}
|
||||
if (! $this->save($eto))
|
||||
$eto->reload();
|
||||
}
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// If we select a blank, then dont continue
|
||||
if (this.value == 0)
|
||||
return false;
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','email/ajaxtemplatetranslate/'.$eto->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
return View::factory('email/admin/add_edit_template')
|
||||
->set('o',$eto);
|
||||
|
||||
$output .= Form::open();
|
||||
|
||||
$output .= View::factory($this->viewpath())
|
||||
->set('template',$eto);
|
||||
|
||||
foreach ($eto->email_template_translate->find_all() as $to) {
|
||||
$output .= View::factory($this->viewpath().'/translate')
|
||||
->set('translate',$to);
|
||||
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Available Variables'),
|
||||
'type'=>'info',
|
||||
'body'=>sprintf('This template uses the following TEXT variables (%s) and HTML variables (%s)',
|
||||
implode('|',array_values($to->variables('message_text'))),
|
||||
implode('|',array_values($to->variables('message_html')))),
|
||||
));
|
||||
}
|
||||
|
||||
$output .= '<div>'.Form::submit('submit',_('Update'),array('class'=>'form_button')).'</div>';
|
||||
$output .= View::factory($this->viewpath());
|
||||
$output .= View::factory($this->viewpath().'/translate');
|
||||
$output .= '<div>'.Form::submit('submit',_('Add'),array('class'=>'form_button')).'</div>';
|
||||
$output .= Form::close();
|
||||
|
||||
Editor::add();
|
||||
Block::add(array(
|
||||
'title'=>sprintf(_('Edit Template '),$eto->name),
|
||||
'title'=>_('Available Email Templates'),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides email management
|
||||
*
|
||||
* @package Email
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_EmailTemplate extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_User_Email extends Controller_TemplateDefault_User {
|
||||
class Controller_User_Email extends Controller_Email {
|
||||
protected $secure_actions = array(
|
||||
'list'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
@ -19,22 +19,24 @@ class Controller_User_Email extends Controller_TemplateDefault_User {
|
||||
* Show a list of emails
|
||||
*/
|
||||
public function action_list() {
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Email For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>Table::display(
|
||||
$this->ao->email_log->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','email/view/')),
|
||||
'date_orig'=>array('label'=>'Date'),
|
||||
'translate_resolve("subject")'=>array('label'=>'Subject'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('user','email/view'),
|
||||
)),
|
||||
));
|
||||
Block::factory()
|
||||
->title(sprintf(_('System Emails Sent for %s: %s'),$this->ao->accnum(),$this->ao->name(TRUE)))
|
||||
->title_icon('icon-th')
|
||||
->body(Table::factory()
|
||||
->page_items(25)
|
||||
->data($this->ao->email_log->find_all())
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'date_orig'=>'Date',
|
||||
'resolve("subject")'=>'Subject',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','email/view/')),
|
||||
))
|
||||
->postproc(array(
|
||||
'resolve("subject")'=>array('trim'=>60),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
public function action_view() {
|
||||
@ -42,18 +44,16 @@ class Controller_User_Email extends Controller_TemplateDefault_User {
|
||||
|
||||
$elo = ORM::factory('Email_Log',$id);
|
||||
|
||||
if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account)) {
|
||||
$this->template->content = 'Unauthorised or doesnt exist?';
|
||||
return FALSE;
|
||||
}
|
||||
if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account))
|
||||
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
$output .= View::factory($this->viewpath())
|
||||
$output .= View::factory('email/user/view')
|
||||
->set('elo',$elo);
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',_('Email'),$elo->translate_resolve('subject')),
|
||||
'body'=>$output,
|
||||
));
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s',$elo->id,$elo->resolve('subject')))
|
||||
->title_icon('icon-list-alt')
|
||||
->body($output);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -10,31 +10,32 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Email_Template {
|
||||
// We'll store the template here
|
||||
private $template;
|
||||
private $etto;
|
||||
private $email_data = array();
|
||||
// @todo Default lang should be the site setup
|
||||
private $default_lang = 1;
|
||||
private $components = array('subject','message_text','message_html');
|
||||
// Our components that need resolving
|
||||
private $_components = array('subject','message_text','message_html');
|
||||
// Our Email Data
|
||||
private $_data = array();
|
||||
// Our Email Template Object
|
||||
private $_etto;
|
||||
|
||||
public function __construct($template,$language_id=NULL) {
|
||||
$this->template = ORM::factory('Email_Template',array('name'=>$template));
|
||||
$eto = ORM::factory('Email_Template',array('name'=>$template));
|
||||
|
||||
if (! $this->template->loaded())
|
||||
if (! $eto->loaded())
|
||||
throw new Kohana_Exception('Email template :template not defined in DB',array(':template'=>$template));
|
||||
|
||||
if (is_null($language_id))
|
||||
$language_id = $this->default_lang;
|
||||
$language_id = Config::language();
|
||||
|
||||
$this->etto = $this->template->email_template_translate->where('language_id','=',$language_id)->find();
|
||||
if (! $this->etto->loaded())
|
||||
$this->etto = $this->template->email_template_translate->where('language_id','=',$this->default_lang)->find();
|
||||
$this->_etto = $eto->translate
|
||||
->where_open()
|
||||
->where('language_id','=',$language_id)
|
||||
->or_where('language_id','=',Config::language())
|
||||
->where_close()
|
||||
->find();
|
||||
|
||||
// @todo Change this to log/email the admin
|
||||
return;
|
||||
#throw new Kohana_Exception('No template (:template) found for user language (:language_id) or default language (:default_lang)',
|
||||
# array(':template'=>$this->template->name,':language_id'=>$language_id,':default_lang'=>$this->default_lang));
|
||||
if (! $this->_etto->loaded())
|
||||
throw new Kohana_Exception('No template (:template) found for user language (:language_id) or default language (:default_lang)',
|
||||
array(':template'=>$eto->name,':language_id'=>$language_id,':default_lang'=>Config::language()));
|
||||
}
|
||||
|
||||
public function __set($key,$value) {
|
||||
@ -44,7 +45,15 @@ class Email_Template {
|
||||
if (! is_array($value) OR ! array_intersect(array('email','account'),array_keys($value)))
|
||||
throw new Kohana_Exception('Values for to should be an array of either "mail" or "account", however :value was given',array(':value'=>serialize($value)));
|
||||
|
||||
$this->email_data[$key] = $value;
|
||||
$this->_data[$key] = $value;
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
$this->_data[$key] = $value;
|
||||
break;
|
||||
|
||||
case 'module_data':
|
||||
$this->_data[$key] = $value;
|
||||
break;
|
||||
|
||||
case 'variables':
|
||||
@ -52,7 +61,7 @@ class Email_Template {
|
||||
if (! is_array($value))
|
||||
throw new Kohana_Exception('Values for variables should be an array, however :value was given',array(':value'=>$value));
|
||||
|
||||
$this->email_data[$key] = $value;
|
||||
$this->_data[$key] = $value;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -64,16 +73,16 @@ class Email_Template {
|
||||
switch ($key) {
|
||||
case 'bcc':
|
||||
case 'to':
|
||||
if (empty($this->email_data[$key]))
|
||||
if (empty($this->_data[$key]))
|
||||
return array();
|
||||
|
||||
elseif (isset($this->email_data[$key]['email']))
|
||||
return $this->email_data[$key]['email'];
|
||||
elseif (isset($this->_data[$key]['email']))
|
||||
return $this->_data[$key]['email'];
|
||||
|
||||
elseif (isset($this->email_data[$key]['account'])) {
|
||||
elseif (isset($this->_data[$key]['account'])) {
|
||||
$list = array();
|
||||
|
||||
foreach ($this->email_data[$key]['account'] as $id) {
|
||||
foreach ($this->_data[$key]['account'] as $id) {
|
||||
$ao = ORM::factory('Account',$id);
|
||||
if ($ao->loaded())
|
||||
$list[$ao->email] = $ao->name();
|
||||
@ -85,7 +94,7 @@ class Email_Template {
|
||||
break;
|
||||
|
||||
case 'variables':
|
||||
return $this->email_data[$key];
|
||||
return $this->_data[$key];
|
||||
|
||||
default:
|
||||
throw new Kohana_Exception('Unknown variable :key (:value)',array(':key'=>$key,':value'=>is_string($value) ? $value : serialize($value)));
|
||||
@ -96,25 +105,14 @@ class Email_Template {
|
||||
return new Email_Template($template);
|
||||
}
|
||||
|
||||
public function variables() {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->components as $v)
|
||||
foreach ($this->etto->variables($v) as $x => $y)
|
||||
if (! in_array($y,$result))
|
||||
array_push($result,$y);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function send(array $admin=array()) {
|
||||
$e = Email::connect();
|
||||
$sm = Swift_Message::newInstance()
|
||||
->setFrom(Kohana::$config->load('config')->email_from);
|
||||
|
||||
foreach ($this->components as $component) {
|
||||
if ($this->etto->loaded()) {
|
||||
$s = $this->etto->rresolve($this->email_data['variables'],$component);
|
||||
foreach ($this->_components as $component) {
|
||||
if ($this->_etto->loaded()) {
|
||||
$s = $this->_etto->complete($this->_data['variables'],$component);
|
||||
|
||||
switch ($component) {
|
||||
case 'message_html':
|
||||
@ -132,14 +130,14 @@ class Email_Template {
|
||||
}
|
||||
} else {
|
||||
$sm->setSubject(_('Email from').' '.Company::instance()->name());
|
||||
$sm->setBody(print_r($this->email_data['variables'],TRUE),'text/plain');
|
||||
$sm->setBody(print_r($this->_data['variables'],TRUE),'text/plain');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->email_data['bcc']))
|
||||
if (isset($this->_data['bcc']))
|
||||
$sm->setBcc($this->bcc);
|
||||
|
||||
if ($admin OR ($admin = Config::testmail($this->template->name))) {
|
||||
if ($admin OR ($admin = Config::testmail($this->_etto->template->name))) {
|
||||
$sm->setTo($admin);
|
||||
$sa = array(1);
|
||||
|
||||
@ -153,18 +151,22 @@ class Email_Template {
|
||||
// Store our email log.
|
||||
$elo = ORM::factory('Email_Log');
|
||||
|
||||
if ($result) {
|
||||
|
||||
if ($result)
|
||||
foreach ($sa as $id) {
|
||||
$elo->clear();
|
||||
|
||||
$elo->account_id = $id;
|
||||
$elo->email = implode(',',array_keys($this->to));
|
||||
$elo->email_template_translate_id = $this->etto->id;
|
||||
$elo->data = $this->email_data['variables'];
|
||||
$elo->email_template_translate_id = $this->_etto->id;
|
||||
$elo->data = $this->_data['variables'];
|
||||
|
||||
if (isset($this->_data['module']) AND isset($this->_data['module_data'])) {
|
||||
$elo->module_id = $this->_data['module'];
|
||||
$elo->module_data = $this->_data['module_data'];
|
||||
}
|
||||
|
||||
$elo->save();
|
||||
}
|
||||
}
|
||||
|
||||
return ($result AND $elo->saved()) ? $elo->id : $result;
|
||||
}
|
||||
@ -173,10 +175,24 @@ class Email_Template {
|
||||
// @todo Set the default account in a configuration file.
|
||||
$default = array(1);
|
||||
|
||||
if (! isset($this->email_data['to']) OR ! is_array($this->email_data['to']) OR ! array_intersect(array('email','account'),array_keys($this->email_data['to'])))
|
||||
if (! isset($this->_data['to']) OR ! is_array($this->_data['to']) OR ! array_intersect(array('email','account'),array_keys($this->_data['to'])))
|
||||
return $default;
|
||||
|
||||
return isset($this->email_data['to']['account']) ? $this->email_data['to']['account'] : $default;
|
||||
return isset($this->_data['to']['account']) ? $this->_data['to']['account'] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out all the required variables for this message
|
||||
*/
|
||||
public function variables() {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->_components as $v)
|
||||
foreach ($this->_etto->variables($v) as $x => $y)
|
||||
if (! in_array($y,$result))
|
||||
array_push($result,$y);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -15,7 +15,7 @@ class Model_Email_Log extends ORM_OSB {
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'account'=>array('far_key'=>'id'),
|
||||
'email_template_translate'=>array('far_key'=>'id'),
|
||||
'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_translate_id'),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
@ -28,11 +28,11 @@ class Model_Email_Log extends ORM_OSB {
|
||||
),
|
||||
);
|
||||
|
||||
public function translate_resolve($column) {
|
||||
if (! $this->data OR ! ($this->email_template_translate->variables($column)))
|
||||
return $this->email_template_translate->display($column);
|
||||
else
|
||||
return $this->email_template_translate->rresolve($this->data,$column);
|
||||
/**
|
||||
* Resolve a data variable into
|
||||
*/
|
||||
public function resolve($column) {
|
||||
return (! $this->data OR ! $this->translate->variables($column)) ? $this->translate->display($column) : $this->translate->complete($this->data,$column);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -13,11 +13,26 @@ class Model_Email_Template_Translate extends ORM_OSB {
|
||||
protected $_created_column = FALSE;
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'template'=>array('model'=>'Email_Template','foreign_key'=>'email_template_id'),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
public function complete($data,$column) {
|
||||
$output = $this->display($column);
|
||||
|
||||
foreach ($this->variables($column) as $k => $v)
|
||||
$output = str_replace('$'.$v.'$',$data[$v],$output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function variables($field) {
|
||||
$results = array();
|
||||
$matches = array();
|
||||
|
||||
preg_match_all('/%([A-Z0-9_]+)%/U',$this->$field,$matches,PREG_OFFSET_CAPTURE);
|
||||
preg_match_all('/\$([A-Z0-9_]+)\$/U',$this->$field,$matches,PREG_OFFSET_CAPTURE);
|
||||
|
||||
foreach ($matches[1] as $k => $v)
|
||||
$results[$v[1]] = $v[0];
|
||||
@ -27,14 +42,5 @@ class Model_Email_Template_Translate extends ORM_OSB {
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function rresolve($data,$column) {
|
||||
$output = $this->display($column);
|
||||
|
||||
foreach ($this->variables($column) as $k => $v)
|
||||
$output = str_replace('%'.$v.'%',$data[$v],$output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
38
modules/email/views/email/admin/add_edit_template.php
Normal file
38
modules/email/views/email/admin/add_edit_template.php
Normal file
@ -0,0 +1,38 @@
|
||||
<div class="row">
|
||||
<div class="span9 offset1">
|
||||
<div class="row">
|
||||
<div class="span3">
|
||||
<?php echo Form::input('name',$o->name,array('label'=>'Name','class'=>'span3')); ?>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="span3">
|
||||
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Email Template Active','class'=>'span1')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span8">
|
||||
<?php echo Form::textarea('notes',$o->notes,array('label'=>'Notes','class'=>'span8')); ?>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="span5">
|
||||
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
||||
|
||||
<div class="row">
|
||||
<div id="translate"></div>
|
||||
</div> <!-- /row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="offset2">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
30
modules/email/views/email/admin/ajaxtemplatetranslate.php
Normal file
30
modules/email/views/email/admin/ajaxtemplatetranslate.php
Normal file
@ -0,0 +1,30 @@
|
||||
<div id="translate">
|
||||
<div class="span9">
|
||||
<?php echo Form::input('translate[subject]',$o->subject,array(
|
||||
'label'=>'Email Subject',
|
||||
'placeholder'=>'Email Subject',
|
||||
'class'=>'span8',
|
||||
'required',
|
||||
'help-block'=>sprintf('This is the subject line on the email. Uses variables: %s',implode(', ',array_values($o->variables('subject')))))); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<?php echo Form::textarea('translate[message_text]',$o->message_text,array(
|
||||
'label'=>'Message Text',
|
||||
'placeholder'=>'Message Text',
|
||||
'class'=>'span8',
|
||||
'required',
|
||||
'help-block'=>sprintf('The message in plain text that is used in the email for email clients that cannot render HTML. Uses variables: %s',implode(', ',array_values($o->variables('message_text')))))); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<?php echo Form::textarea('translate[message_html]',$o->message_html,array(
|
||||
'label'=>'Message HTML',
|
||||
'placeholder'=>'Message HTML',
|
||||
'class'=>'span8',
|
||||
'required',
|
||||
'editor'=>'tinymce',
|
||||
'help-block'=>sprintf('The message in HTML that is used in the email. Uses variables: %s',implode(', ',array_values($o->variables('message_html')))))); ?>'
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo Style::factory()->render_all(); ?>
|
||||
<?php echo Script::factory()->render_all(); ?>
|
@ -1,14 +0,0 @@
|
||||
<table class="box-left">
|
||||
<tr>
|
||||
<td class="head">Name:</td>
|
||||
<td><?php echo Form::input('name','',array('size'=>30)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Active:</td>
|
||||
<td><?php echo StaticList_YesNo::form('status',TRUE); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Notes:</td>
|
||||
<td><?php echo Form::input('notes','',array('size'=>80)); ?></td>
|
||||
</tr>
|
||||
</table>
|
@ -1,18 +0,0 @@
|
||||
<table class="box-left">
|
||||
<tr>
|
||||
<td class="head">Language:</td>
|
||||
<td><?php echo Form::input(sprintf('translate[%s][language_id]','new'),'',array('size'=>5)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Subject:</td>
|
||||
<td><?php echo Form::input(sprintf('translate[%s][subject]','new'),'',array('size'=>80)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Text:</td>
|
||||
<td><?php echo Form::textarea(sprintf('translate[%s][message_text]','new'),'',array('cols'=>120,'rows'=>10)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">HTML:</td>
|
||||
<td><?php echo Form::textarea(sprintf('translate[%s][message_html]','new'),'',array('cols'=>120,'rows'=>10,'class'=>'mceEditor')); ?></td>
|
||||
</tr>
|
||||
</table>
|
@ -1,14 +0,0 @@
|
||||
<table class="box-left">
|
||||
<tr>
|
||||
<td class="head">Name:</td>
|
||||
<td><?php echo Form::input('name',$template->name,array('size'=>30)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Active:</td>
|
||||
<td><?php echo StaticList_YesNo::form('status',$template->status); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Notes:</td>
|
||||
<td><?php echo Form::input('notes',$template->notes,array('size'=>80)); ?></td>
|
||||
</tr>
|
||||
</table>
|
@ -1,18 +0,0 @@
|
||||
<table class="box-left">
|
||||
<tr>
|
||||
<td class="head">Language:</td>
|
||||
<td><?php echo Form::input(sprintf('translate[%s][language_id]',$translate->id),$translate->language_id,array('size'=>5)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Subject:</td>
|
||||
<td><?php echo Form::input(sprintf('translate[%s][subject]',$translate->id),$translate->subject,array('size'=>80)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Text:</td>
|
||||
<td><?php echo Form::textarea(sprintf('translate[%s][message_text]',$translate->id),$translate->message_text,array('cols'=>120,'rows'=>10)); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">HTML:</td>
|
||||
<td><?php echo Form::textarea(sprintf('translate[%s][message_html]',$translate->id),$translate->message_html,array('cols'=>120,'rows'=>20,'class'=>'mceEditor')); ?></td>
|
||||
</tr>
|
||||
</table>
|
@ -1,4 +0,0 @@
|
||||
<tr>
|
||||
<td><a href="<?php echo URL::link('admin','email/templateedit/'.$template->id,TRUE); ?>" alt=""><?php echo $template->name; ?></a></td>
|
||||
<td><?php echo $template->display('status'); ?></td>
|
||||
</tr>
|
@ -1 +0,0 @@
|
||||
</table>
|
@ -1,6 +0,0 @@
|
||||
<!-- //@todo Translation required -->
|
||||
<table class="box-left">
|
||||
<tr class="head">
|
||||
<td>Template</td>
|
||||
<td>Active</td>
|
||||
</tr>
|
@ -1,20 +1,32 @@
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>To:</td><td class="data"><?php printf('%s (%s)',$elo->account->name(),$elo->display('email')); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date:</td><td class="data"><?php echo $elo->display('date_orig'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Subject:</td><td class="data"><?php echo $elo->translate_resolve('subject'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 100%;" colspan="2">
|
||||
<table class="box-full">
|
||||
<tr>
|
||||
<td><?php echo $elo->translate_resolve('message_html'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="span11">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong>To:</strong></td>
|
||||
<td><?php printf('%s (%s)',$elo->account->name(),$elo->display('email')); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Date:</strong></td>
|
||||
<td><?php echo $elo->display('date_orig'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Subject:</strong></td>
|
||||
<td><?php echo $elo->resolve('subject'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><hr/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<table>
|
||||
<tr>
|
||||
<td><?php echo $elo->resolve('message_html'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div> <!-- /span -->
|
||||
</div> <!-- /row -->
|
||||
|
@ -25,16 +25,10 @@ class Controller_Admin_Export extends Controller_Export {
|
||||
|
||||
$edo = ORM::factory('Export_DataMap');
|
||||
|
||||
if ($_POST AND isset($_POST['item_id']) AND $edo->values($_POST)->check()) {
|
||||
if ($_POST AND isset($_POST['item_id']) AND $edo->values($_POST)->changed()) {
|
||||
$edo->status = 1;
|
||||
|
||||
if (! $edo->save())
|
||||
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
|
||||
|
||||
SystemMessage::factory()
|
||||
->title('Record added')
|
||||
->type('success')
|
||||
->body(_('Export DataMap record has been added.'));
|
||||
$this->save($edo);
|
||||
}
|
||||
|
||||
Block::factory()
|
||||
@ -87,16 +81,8 @@ class Controller_Admin_Export extends Controller_Export {
|
||||
if ($_POST AND isset($_POST['export_module_id'])) {
|
||||
$emo = ORM::factory('Export_Module',$_POST['export_module_id']);
|
||||
|
||||
if ($emo->loaded()) {
|
||||
$emo->values($_POST);
|
||||
$emo->save();
|
||||
|
||||
if ($emo->saved())
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Export Module record has been updated.'));
|
||||
}
|
||||
if ($emo->loaded() AND $emo->values($_POST)->changed() AND ! $this->save($emo))
|
||||
$emo->reload();
|
||||
}
|
||||
|
||||
if ($x = $this->request->param('id')) {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9ed797b1d2e9a2b3b8227bbb42be01ea620916d4
|
||||
Subproject commit 4bd8d1ffae3d89ee85de63e1a80a3d7aeb7b0fa5
|
@ -22,6 +22,9 @@ class Controller_User_Invoice extends Controller_Invoice {
|
||||
public function action_download() {
|
||||
$io = ORM::factory('Invoice',$this->request->param('id'));
|
||||
|
||||
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account))
|
||||
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
// Log the download
|
||||
$imo = $io->invoice_memo;
|
||||
$imo->invoice_id = $io->id;
|
||||
|
@ -215,7 +215,6 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
return $format ? Currency::display($result) : $result;
|
||||
}
|
||||
|
||||
//ZZ
|
||||
/**
|
||||
* Return a list of valid checkout options for this invoice
|
||||
*/
|
||||
@ -508,11 +507,6 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
if (! $iio->changed())
|
||||
continue;
|
||||
|
||||
if (! $iio->check()) {
|
||||
// @todo Mark invoice as cancelled and write a memo, then...
|
||||
throw new Kohana_Exception('Problem saving invoice_item for invoice :invoice - Failed check()',array(':invoice'=>$this->id));
|
||||
}
|
||||
|
||||
$iio->save();
|
||||
|
||||
if (! $iio->saved()) {
|
||||
@ -548,7 +542,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
} else
|
||||
throw new Kohana_Exception('Couldnt save invoice for some reason?');
|
||||
|
||||
return TRUE;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_remind($key,$value,$add=FALSE) {
|
||||
|
@ -188,9 +188,6 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
}
|
||||
|
||||
public function save(Validation $validation = NULL) {
|
||||
if (! $this->changed())
|
||||
return;
|
||||
|
||||
// Save the invoice item
|
||||
parent::save($validation);
|
||||
|
||||
@ -214,9 +211,6 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
// @todo Rounding here should come from a global config
|
||||
$iito->amount = round($tax['amount'],2);
|
||||
|
||||
if (! $iito->check())
|
||||
throw new Kohana_Exception('Couldnt save tax for some reason - failed check()?');
|
||||
|
||||
$iito->save();
|
||||
|
||||
if (! $iito->saved())
|
||||
@ -224,6 +218,8 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
}
|
||||
} else
|
||||
throw new Kohana_Exception('Couldnt save invoice_item for some reason?');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 610c223cb823f2b16df3e1f49912e8ef42dc6bd7
|
||||
Subproject commit 1ec370f07af319e5deda43dce6585ad9e0240c18
|
@ -96,12 +96,7 @@ class Controller_Admin_Payment extends Controller_Payment {
|
||||
$pio->alloc_amt = is_numeric($v) ? $v : 0;
|
||||
}
|
||||
|
||||
// Entry updated
|
||||
if ($po->values($_POST)->check() AND $po->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your Payment record has been recorded/updated.'));
|
||||
$this->save($po);
|
||||
}
|
||||
|
||||
Script::factory()
|
||||
|
@ -200,7 +200,7 @@ class Model_Payment extends ORM_OSB {
|
||||
throw HTTP_Exception::factory(501,'Problem saving payment :id - Failed save()',array(':id'=>$this->id));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,8 +65,8 @@ class Controller_Admin_Product extends Controller_Product {
|
||||
if (! $pco->loaded())
|
||||
HTTP::redirect(URL::link('admin','product/list'));
|
||||
|
||||
if ($_POST)
|
||||
$pco->values($_POST)->save();
|
||||
if ($_POST AND $pco->values($_POST)->changed() AND (! $this->save($pco)))
|
||||
$pco->reload();
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
@ -113,8 +113,8 @@ $(document).ready(function() {
|
||||
if (! $po->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST)
|
||||
$po->values($_POST)->save();
|
||||
if ($_POST AND $po->values($_POST)->changed() AND (! $this->save($po)))
|
||||
$po->reload();
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
|
@ -14,9 +14,9 @@
|
||||
*/
|
||||
class Model_Product extends ORM_OSB {
|
||||
protected $_has_many = array(
|
||||
'product_translate'=>array('far_key'=>'id'),
|
||||
'service'=>array('far_key'=>'id'),
|
||||
'invoice'=>array('through'=>'invoice_item'),
|
||||
'service'=>array('far_key'=>'id'),
|
||||
'translate'=>array('model'=>'Product_Translate','far_key'=>'id'),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
@ -44,6 +44,8 @@ class Model_Product extends ORM_OSB {
|
||||
'price_group',
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
/**
|
||||
* Which categories is this product available in
|
||||
*/
|
||||
@ -106,29 +108,22 @@ class Model_Product extends ORM_OSB {
|
||||
}
|
||||
|
||||
public function save(Validation $validation=NULL) {
|
||||
if ($this->changed())
|
||||
if (parent::save($validation))
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Record %s Updated',$this->id));
|
||||
parent::save($validation);
|
||||
|
||||
// Save our Translated Message
|
||||
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['product_translate']) AND is_array($_POST['product_translate'])) {
|
||||
$pto = $this->product_translate->where('language_id','=',$_POST['language_id'])->find();
|
||||
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 (! $pto->loaded()) {
|
||||
$pto->product_id = $this->id;
|
||||
$pto->language_id = $_POST['language_id'];
|
||||
if (! $to->loaded()) {
|
||||
$to->product_id = $this->id;
|
||||
$to->language_id = $_POST['language_id'];
|
||||
}
|
||||
|
||||
if ($pto->values($x['product_translate'])->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Translation for Record %s Updated',$this->id));
|
||||
$to->values($x['translate'])->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +138,7 @@ class Model_Product extends ORM_OSB {
|
||||
}
|
||||
|
||||
private function translate() {
|
||||
return $this->product_translate->where('language_id','=',Config::language())->find();
|
||||
return $this->translate->where('language_id','=',Config::language())->find();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,14 +20,16 @@ class Model_Product_Category extends ORM_OSB {
|
||||
);
|
||||
|
||||
protected $_has_many = array(
|
||||
'product_category_translate'=>array('foreign_key'=>'product_cat_id','far_key'=>'id'),
|
||||
'subcategories'=>array('model'=>'product_category','foreign_key'=>'parent_id','far_key'=>'id'),
|
||||
'translate'=>array('model'=>'Product_Category_Translate','foreign_key'=>'product_cat_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'position'=>'ASC',
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
/**
|
||||
* Return the translated description for a category.
|
||||
*/
|
||||
@ -51,29 +53,22 @@ class Model_Product_Category extends ORM_OSB {
|
||||
}
|
||||
|
||||
public function save(Validation $validation=NULL) {
|
||||
if ($this->changed())
|
||||
if (parent::save($validation))
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Record %s Updated',$this->id));
|
||||
parent::save($validation);
|
||||
|
||||
// Save our Translated Message
|
||||
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['product_category_translate']) AND is_array($_POST['product_category_translate'])) {
|
||||
$pcto = $this->product_category_translate->where('language_id','=',$_POST['language_id'])->find();
|
||||
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_cat_id
|
||||
if (! $pcto->loaded()) {
|
||||
$pcto->product_cat_id = $this->id;
|
||||
$pcto->language_id = $_POST['language_id'];
|
||||
if (! $to->loaded()) {
|
||||
$to->product_cat_id = $this->id;
|
||||
$to->language_id = $_POST['language_id'];
|
||||
}
|
||||
|
||||
if ($pcto->values($x['product_category_translate'])->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Translation for Record %s Updated',$this->id));
|
||||
$to->values($x['translate'])->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +106,7 @@ class Model_Product_Category extends ORM_OSB {
|
||||
|
||||
|
||||
private function translate() {
|
||||
return $this->product_category_translate->where('language_id','=',Config::language())->find();
|
||||
return $this->translate->where('language_id','=',Config::language())->find();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -17,5 +17,7 @@ class Model_Product_Category_Translate extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'product_category'=>array(),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
}
|
||||
?>
|
||||
|
@ -16,5 +16,7 @@ class Model_Product_Translate extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
}
|
||||
?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div id="translate">
|
||||
<div class="span6">
|
||||
<?php echo Form::input('product_translate[name]',$o->name,array(
|
||||
<?php echo Form::input('translate[name]',$o->name,array(
|
||||
'label'=>'Category Title',
|
||||
'placeholder'=>'Descriptive Title',
|
||||
'class'=>'span3',
|
||||
@ -8,20 +8,24 @@
|
||||
'help-block'=>'The title is shown when uses search products by category')); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<?php echo Form::textarea('product_translate[description_short]',$o->description_short,array(
|
||||
<?php echo Form::textarea('translate[description_short]',$o->description_short,array(
|
||||
'label'=>'Short Product Description',
|
||||
'placeholder'=>'Short Description',
|
||||
'class'=>'span6',
|
||||
'required',
|
||||
'editor'=>'wysihtml5',
|
||||
'help-block'=>'Complete description of this category')); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<?php echo Form::textarea('product_translate[description_full]',$o->description_full,array(
|
||||
<?php echo Form::textarea('translate[description_full]',$o->description_full,array(
|
||||
'label'=>'Full Product Description',
|
||||
'placeholder'=>'Full Description',
|
||||
'class'=>'span6',
|
||||
'required',
|
||||
'editor'=>'wysihtml5',
|
||||
'help-block'=>'Complete description of this category')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo Style::factory()->render_all(); ?>
|
||||
<?php echo Script::factory()->render_all(); ?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div id="translate">
|
||||
<div class="span6">
|
||||
<?php echo Form::input('product_category_translate[name]',$o->name,array(
|
||||
<?php echo Form::input('translate[name]',$o->name,array(
|
||||
'label'=>'Category Title',
|
||||
'placeholder'=>'Descriptive Title',
|
||||
'class'=>'span3',
|
||||
@ -8,12 +8,15 @@
|
||||
'help-block'=>'The title is shown when uses search products by category')); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<?php echo Form::textarea('product_category_translate[description]',$o->description,array(
|
||||
<?php echo Form::textarea('translate[description]',$o->description,array(
|
||||
'label'=>'Category Description',
|
||||
'placeholder'=>'Description',
|
||||
'class'=>'span6',
|
||||
'required',
|
||||
'editor'=>'wysihtml5',
|
||||
'help-block'=>'Complete description of this category')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo Style::factory()->render_all(); ?>
|
||||
<?php echo Script::factory()->render_all(); ?>
|
||||
|
@ -127,46 +127,12 @@ class Controller_Admin_Service extends Controller_Service {
|
||||
if (isset($_POST['plugin']) AND $_POST['plugin']) {
|
||||
$p = $so->plugin();
|
||||
|
||||
if ($p->values($_POST['plugin'])->changed() AND $p->check()) {
|
||||
try {
|
||||
$p->values($_POST['plugin'])->save();
|
||||
SystemMessage::factory()
|
||||
->title('Record PLUGIN updated')
|
||||
->type('success')
|
||||
->body(_('Your Charge record has been recorded/updated.'));
|
||||
|
||||
} catch (ORM_Validation_Exception $e) {
|
||||
$errors = $e->errors('models');
|
||||
|
||||
SystemMessage::factory()
|
||||
->title('Record PLUGIN NOT updated')
|
||||
->type('error')
|
||||
->body(join('<br/>',array_values($errors)));
|
||||
|
||||
$so->reload();
|
||||
}
|
||||
}
|
||||
if ($p->values($_POST['plugin'])->changed() AND ! $this->save($p))
|
||||
$p->reload();
|
||||
}
|
||||
|
||||
if ($so->values($_POST)->changed() AND $so->check()) {
|
||||
try {
|
||||
$so->values($_POST)->save();
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your Charge record has been recorded/updated.'));
|
||||
|
||||
} catch (ORM_Validation_Exception $e) {
|
||||
$errors = $e->errors('models');
|
||||
|
||||
SystemMessage::factory()
|
||||
->title('Record NOT updated')
|
||||
->type('error')
|
||||
->body(join('<br/>',array_values($errors)));
|
||||
|
||||
$so->reload();
|
||||
}
|
||||
}
|
||||
if ($so->values($_POST)->changed() AND ! $this->save($so))
|
||||
$so->reload();
|
||||
}
|
||||
|
||||
Script::factory()
|
||||
@ -211,10 +177,8 @@ $(document).ready(function() {
|
||||
|
||||
$so = ORM::factory('Service',$id);
|
||||
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
|
||||
$this->template->content = 'Unauthorised or doesnt exist?';
|
||||
return FALSE;
|
||||
}
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
|
||||
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
$doutput = $loutput = '';
|
||||
|
||||
|
@ -91,6 +91,12 @@ class Model_Service extends ORM_OSB {
|
||||
return $format ? Currency::display($total) : $total;
|
||||
}
|
||||
|
||||
public function email() {
|
||||
return ORM::factory('Email_Log')
|
||||
->where('module_id','=',$this->mid())
|
||||
->where('module_data','=',$this);
|
||||
}
|
||||
|
||||
/**
|
||||
* When does this service expire
|
||||
*/
|
||||
|
@ -109,3 +109,24 @@
|
||||
</fieldset>
|
||||
</div> <!-- /row -->
|
||||
<?php endif ?>
|
||||
|
||||
<?php $x=$o->email()->find_all(); if ($x->count()) : ?>
|
||||
<div class="row">
|
||||
<fieldset class="span5">
|
||||
<legend>Emails about this service</legend>
|
||||
<?php echo Table::factory()
|
||||
->data($x)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'date_orig'=>'Date',
|
||||
'resolve("subject")'=>'Subject',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','email/view/')),
|
||||
))
|
||||
->postproc(array(
|
||||
'resolve("subject")'=>array('trim'=>45),
|
||||
)); ?>
|
||||
</fieldset>
|
||||
</div> <!-- /row -->
|
||||
<?php endif ?>
|
||||
|
@ -116,44 +116,19 @@ class Controller_Reseller_SSL extends Controller_SSL {
|
||||
public function action_renew() {
|
||||
$so = ORM::factory('Service',Request::current()->param('id'));
|
||||
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
|
||||
SystemMessage::factory()
|
||||
->title('SSL Certificate not updated')
|
||||
->type('error')
|
||||
->body('Either the Service doesnt exist, or you are not authorised to see it');
|
||||
|
||||
HTTP::redirect('welcome');
|
||||
}
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
|
||||
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
$so->plugin()->renew();
|
||||
|
||||
HTTP::redirect(URL::link('user','service/view/'.$so->id));
|
||||
}
|
||||
|
||||
private function add_edit($id=NULL,$output='') {
|
||||
$sco = ORM::factory('SSL_CA',$id);
|
||||
|
||||
if ($_POST) {
|
||||
// Entry updated
|
||||
if ($sco->values($_POST)->check()) {
|
||||
try {
|
||||
$sco->save();
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your Charge record has been recorded/updated.'));
|
||||
|
||||
} catch (ORM_Validation_Exception $e) {
|
||||
$errors = $e->errors('models');
|
||||
|
||||
SystemMessage::factory()
|
||||
->title('Record NOT updated')
|
||||
->type('error')
|
||||
->body(join('<br/>',array_values($errors)));
|
||||
|
||||
$sco->reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_POST AND $sco->values($_POST)->changed() AND ! ($this->save($sco)))
|
||||
$sco->reload();
|
||||
|
||||
return View::factory('ssl/reseller/add_edit')
|
||||
->set('o',$sco);
|
||||
|
@ -15,13 +15,13 @@ class Controller_User_SSL extends Controller_SSL {
|
||||
);
|
||||
|
||||
public function action_download() {
|
||||
$id = $_POST['sid'];
|
||||
$so = ORM::factory('Service',$id);
|
||||
$so = ORM::factory('Service',$this->request->post('sid'));
|
||||
|
||||
if (! $so->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
|
||||
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
$passwd = $this->request->post('passwd');
|
||||
|
||||
$passwd = $_POST['passwd'];
|
||||
if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Validation failed'),
|
||||
@ -32,11 +32,6 @@ class Controller_User_SSL extends Controller_SSL {
|
||||
HTTP::redirect(URL::link('user','service/view/'.$so->id));
|
||||
}
|
||||
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
|
||||
$this->template->content = 'Unauthorised or doesnt exist?';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Log the download
|
||||
$smo = $so->service_memo;
|
||||
$smo->service_id = $so->id;
|
||||
@ -49,10 +44,11 @@ class Controller_User_SSL extends Controller_SSL {
|
||||
openssl_pkcs12_export_to_file($so->plugin()->cert,$file,$so->plugin()->pk,$passwd,array('extracerts'=>$so->plugin()->cacerts()));
|
||||
$x = file_get_contents($file);
|
||||
unlink($file);
|
||||
|
||||
$this->auto_render = FALSE;
|
||||
$this->response->headers('Content-Type','application/pks12');
|
||||
$this->response->headers('Content-Disposition','attachment; filename="'.basename($file).'"');
|
||||
$this->response->body($x);
|
||||
$this->auto_render = FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,17 +1,17 @@
|
||||
<div class="row">
|
||||
<div class="span6">
|
||||
<?php echo Form::textarea('plugin[csr]',$o->service->plugin()->csr,array('class'=>'span6','label'=>'CSR','placeholder'=>'CSR','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr))); ?>
|
||||
<?php echo Form::textarea('plugin[csr]',$o->service->plugin()->csr,array('class'=>'span6','label'=>'CSR','placeholder'=>'CSR','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr))); ?>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="span6">
|
||||
<?php echo Form::textarea('plugin[pk]',$o->service->plugin()->pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk))); ?>
|
||||
<?php echo Form::textarea('plugin[pk]',$o->service->plugin()->pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk))); ?>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="span6">
|
||||
<?php echo Form::textarea('plugin[cert]',$o->service->plugin()->cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert))); ?>
|
||||
<?php echo Form::textarea('plugin[cert]',$o->service->plugin()->cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert))); ?>
|
||||
</div>
|
||||
</div> <!-- /row -->
|
||||
|
@ -50,8 +50,8 @@
|
||||
</div> <!-- /dl-horizontal -->
|
||||
<br/>
|
||||
|
||||
<?php echo Form::textarea('sign_pk',$o->sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?>
|
||||
<?php echo Form::textarea('sign_cert',$o->sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?>
|
||||
<?php echo Form::textarea('sign_pk',$o->sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?>
|
||||
<?php echo Form::textarea('sign_cert',$o->sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?>
|
||||
|
||||
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
|
||||
</div> <!-- /span -->
|
||||
|
Reference in New Issue
Block a user