Work on Email and other major consistency work
This commit is contained in:
@@ -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>
|
||||
|
Reference in New Issue
Block a user