Updates from OSB

This commit is contained in:
Deon George 2016-08-25 23:23:25 +10:00
parent 932252b620
commit 4b432d2eb4
7 changed files with 41 additions and 69 deletions

View File

@ -100,6 +100,8 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module {
HTTP::redirect(URL::link('admin','module/list')); HTTP::redirect(URL::link('admin','module/list'));
} }
$this->meta->title = 'A|Module: '.$mo->name();
$mm = $this->_methods($mo->name); $mm = $this->_methods($mo->name);
$methods['exist'] = array(); $methods['exist'] = array();
foreach ($mo->module_method->find_all() as $mmo) { foreach ($mo->module_method->find_all() as $mmo) {
@ -131,7 +133,7 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module {
Block::factory() Block::factory()
->title(sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name'))) ->title(sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name')))
->title_icon('icon-cog') ->title_icon('fa fa-cog')
->body(Table::factory() ->body(Table::factory()
->data($methods['exist']) ->data($methods['exist'])
->columns(array( ->columns(array(
@ -148,7 +150,7 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module {
Block::factory() Block::factory()
->title(sprintf('%s: %s ',_('Missing Module Methods For'),$mo->display('name'))) ->title(sprintf('%s: %s ',_('Missing Module Methods For'),$mo->display('name')))
->title_icon('icon-exclamation-sign') ->title_icon('fa fa-question')
->body(Table::factory() ->body(Table::factory()
->data($methods['missing']) ->data($methods['missing'])
->columns(array( ->columns(array(
@ -165,9 +167,11 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module {
* List our installed modules * List our installed modules
*/ */
public function action_list() { public function action_list() {
$this->meta->title = 'A|Module List';
Block::factory() Block::factory()
->title('Defined Modules') ->title('Defined Modules')
->title_icon('icon-cog') ->title_icon('fa fa-cog')
->body(Table::factory() ->body(Table::factory()
->data(ORM::factory('Module')->where('parent_id','is',NULL)->find_all()) ->data(ORM::factory('Module')->where('parent_id','is',NULL)->find_all())
->jssort(TRUE) ->jssort(TRUE)

View File

@ -23,26 +23,14 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo
if (! $mo->loaded() OR ! in_array($method,$mm['methods'])) if (! $mo->loaded() OR ! in_array($method,$mm['methods']))
HTTP::redirect(URL::link('admin','module/list')); HTTP::redirect(URL::link('admin','module/list'));
if ($_POST) { $mmo = $mo->module_method;
$mmo = $mo->module_method; $mmo->name = $method;
$mmo->name = $method; $mmo->module_id = $mo->id;
$mmo->module_id = $mo->id;
$mmo->values($_POST);
if (! $this->save($mmo)) if (! $this->save($mmo))
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST))); throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($this->request->post())));
HTTP::redirect(URL::link('admin','module/edit/'.$mo->id)); HTTP::redirect(URL::link('admin','module_method/edit/'.$mmo->id));
}
Block::factory()
->title(sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($method),strtoupper($mo->name)))
->title_icon('icon-plus-sign')
->type('form-horizontal')
->body(View::factory('module/method/admin/add')
->set('name',$method)
->set('o',$mo)
);
} }
/** /**
@ -61,15 +49,15 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo
HTTP::redirect(URL::link('admin','module/list')); HTTP::redirect(URL::link('admin','module/list'));
} }
if ($_POST) { if ($this->request->post()) {
$mmo->values($_POST); $mmo->values($this->request->post());
if (! $this->save($mmo)) if (! $this->save($mmo))
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST))); throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($this->request->post())));
foreach (ORM::factory('Group')->find_all() as $go) { foreach (ORM::factory('Group')->find_all() as $go) {
// If the group was defined and no longer // If the group was defined and no longer
if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) { if ($mmo->has('group',$go) AND (! $this->request->post('groups') OR ! in_array($go->id,$this->request->post('groups')))) {
$gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id)); $gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
if (! $gmo->delete()) if (! $gmo->delete())
@ -79,7 +67,7 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo
->body(sprintf(_('Unable to delete Group Method for method %s and group %s'),$mmo->name,$go->name)); ->body(sprintf(_('Unable to delete Group Method for method %s and group %s'),$mmo->name,$go->name));
// If the group was not defined and now is // If the group was not defined and now is
} elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) { } elseif (! $mmo->has('group',$go) AND $this->request->post('groups') AND in_array($go->id,$this->request->post('groups'))) {
$gmo = ORM::factory('Group_Method') $gmo = ORM::factory('Group_Method')
->values(array( ->values(array(
'method_id'=>$mmo->id, 'method_id'=>$mmo->id,
@ -99,7 +87,7 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo
Block::factory() Block::factory()
->title(sprintf(_('Configure access to method (%s::%s)'),$mmo->controller(),$mmo->method())) ->title(sprintf(_('Configure access to method (%s::%s)'),$mmo->controller(),$mmo->method()))
->title_icon('icon-plus-sign') ->title_icon('fa fa-lock')
->type('form-horizontal') ->type('form-horizontal')
->body(View::factory('module/method/admin/edit')->set('o',$mmo)); ->body(View::factory('module/method/admin/edit')->set('o',$mmo));
} }

View File

@ -53,13 +53,13 @@ abstract class lnAuth_Controller_TemplateDefault extends lnApp_Controller_Templa
if (! $mo->loaded()) if (! $mo->loaded())
throw HTTP_Exception::factory(501,'Unknown module :module',array(':module'=>Request::current()->controller())); throw HTTP_Exception::factory(501,'Unknown module :module',array(':module'=>Request::current()->controller()));
if ($_POST AND isset($_POST['module_config'][$mo->id])) if ($this->request->post() AND array_key_exists($mo->id,$this->request->post('module_config')))
Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save(); Config::instance()->module_config($mo->name,$this->request->post('module_config.'.$mo->id))->save();
if ($config_items) { if ($config_items) {
Block::factory() Block::factory()
->title('Update Module Configuration') ->title('Update Module Configuration')
->title_icon('icon-wrench') ->title_icon('fa fa-wrench')
->type('form-horizontal') ->type('form-horizontal')
->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id)); ->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id));
} }

View File

@ -46,10 +46,11 @@ abstract class lnAuth_Menu extends lnApp_Menu {
if (! $ao->loaded()) if (! $ao->loaded())
return FALSE; return FALSE;
foreach ($ao->methods() as $mmo) if (is_object($ao))
if ($mmo->menu_display AND $type == $mmo->directory()) foreach ($ao->methods() as $mmo)
if (empty($result[$mmo->id])) if ($mmo->menu_display AND $type == $mmo->directory())
$result[$mmo->id] = $mmo; if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo;
return self::collapse($result); return self::collapse($result);
} }
@ -61,7 +62,7 @@ abstract class lnAuth_Menu extends lnApp_Menu {
if (is_array($v)) if (is_array($v))
$output .= sprintf('<li class="dropdown-submenu">%s%s',HTML::anchor('#',$k,array('nocg'=>TRUE)),self::ul($type,$v,NULL,TRUE).'</li>'); $output .= sprintf('<li class="dropdown-submenu">%s%s',HTML::anchor('#',$k,array('nocg'=>TRUE)),self::ul($type,$v,NULL,TRUE).'</li>');
else else
$output .= '<li>'.HTML::anchor($v->url(),$v->menu_display,array('tabindex'=>-1,'nocg'=>TRUE)).'</li>'; $output .= '<li>'.HTML::anchor($v->url(),$v->menu_display(),array('tabindex'=>-1,'nocg'=>TRUE)).'</li>';
if ($append) { if ($append) {
$output .= '<li class="divider"></li>'; $output .= '<li class="divider"></li>';

View File

@ -61,7 +61,7 @@ abstract class lnAuth_Model_Account extends lnApp_Model_Account {
->method(array($module,$method)) ->method(array($module,$method))
->account($this) ->account($this)
->uses($uses) ->uses($uses)
->expire(time()+$token_expire) ->expire(time()+$token_expire*60)
->generate(); ->generate();
} }
} }

View File

@ -1,16 +0,0 @@
<div class="col-md-11">
<fieldset>
<legend>Add Method</legend>
<?php echo Form::input('name',$name,array('label'=>'Method','disabled','divclass'=>'col-sm-5')); ?>
<?php echo Form::input('notes','',array('label'=>'Description','placeholder'=>'Method Description','divclass'=>'col-sm-7')); ?>
<?php echo Form::input('menu_display','',array('label'=>'Menu Title','placeholder'=>'Menu Title','divclass'=>'col-sm-7')); ?>
</fieldset>
<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> <!-- /span -->

View File

@ -1,22 +1,22 @@
<div class="col-md-5"> <div class="col-md-12">
<fieldset> <fieldset class="col-md-5">
<legend>Method Details</legend> <legend>Method Details</legend>
<?php echo Form::input('notes',$o->notes,array('label'=>'Desc','placeholder'=>'Method Description','divclass'=>'col-md-9')); ?> <?php
<?php echo Form::input('menu_display',$o->menu_display,array('label'=>'Title','placeholder'=>'Menu Title','divclass'=>'col-md-9')); ?> echo View::factory('field/text')->set('data',['field'=>'notes','value'=>$o->notes,'text'=>'Description','class'=>'col-md-9','classlabel'=>'col-md-3']);
echo View::factory('field/text')->set('data',['field'=>'menu_display','value'=>$o->menu_display,'text'=>'Menu Title','class'=>'col-md-9','classlabel'=>'col-md-3']);
?>
</fieldset> </fieldset>
</div> <!-- /col-md-->
<div class="col-md-6"> <fieldset class="col-md-7">
<fieldset>
<legend>Method Security</legend> <legend>Method Security</legend>
<table class="table table-striped table-condensed table-hover" id="list-table"> <table class="table table-striped table-condensed table-hover" id="list-table">
<thead><tr> <thead><tr>
<th>Method</th> <th>Method</th>
<th>Notes</th> <th>Notes</th>
<th>Group Active</th> <th>Active</th>
<th>Method Enable</th> <th>Enabled</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
@ -24,7 +24,7 @@
<tr> <tr>
<td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td> <td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td>
<td><?php echo $go->display('notes'); ?></td> <td><?php echo $go->display('notes'); ?></td>
<td><?php echo $go->display('active'); ?></td> <td><?php echo $go->display('status'); ?></td>
<td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go),array('nocg'=>TRUE)); ?></td> <td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go),array('nocg'=>TRUE)); ?></td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
@ -32,10 +32,5 @@
</table> </table>
</fieldset> </fieldset>
<div class="row"> <?php echo View::factory('field/submit'); ?>
<div class="col-md-offset-2"> </div>
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /col-md -->