From 4b432d2eb44bc8cf264c3082b009f9918c5e552b Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 25 Aug 2016 23:23:25 +1000 Subject: [PATCH] Updates from OSB --- classes/lnAuth/Controller/Admin/Module.php | 10 ++++-- .../lnAuth/Controller/Admin/Module/Method.php | 36 +++++++------------ classes/lnAuth/Controller/TemplateDefault.php | 6 ++-- classes/lnAuth/Menu.php | 11 +++--- classes/lnAuth/Model/Account.php | 2 +- views/module/method/admin/add.php | 16 --------- views/module/method/admin/edit.php | 29 +++++++-------- 7 files changed, 41 insertions(+), 69 deletions(-) delete mode 100644 views/module/method/admin/add.php diff --git a/classes/lnAuth/Controller/Admin/Module.php b/classes/lnAuth/Controller/Admin/Module.php index 8644a0c..61355c3 100644 --- a/classes/lnAuth/Controller/Admin/Module.php +++ b/classes/lnAuth/Controller/Admin/Module.php @@ -100,6 +100,8 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module { HTTP::redirect(URL::link('admin','module/list')); } + $this->meta->title = 'A|Module: '.$mo->name(); + $mm = $this->_methods($mo->name); $methods['exist'] = array(); foreach ($mo->module_method->find_all() as $mmo) { @@ -131,7 +133,7 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module { Block::factory() ->title(sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name'))) - ->title_icon('icon-cog') + ->title_icon('fa fa-cog') ->body(Table::factory() ->data($methods['exist']) ->columns(array( @@ -148,7 +150,7 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module { Block::factory() ->title(sprintf('%s: %s ',_('Missing Module Methods For'),$mo->display('name'))) - ->title_icon('icon-exclamation-sign') + ->title_icon('fa fa-question') ->body(Table::factory() ->data($methods['missing']) ->columns(array( @@ -165,9 +167,11 @@ abstract class lnAuth_Controller_Admin_Module extends Controller_Module { * List our installed modules */ public function action_list() { + $this->meta->title = 'A|Module List'; + Block::factory() ->title('Defined Modules') - ->title_icon('icon-cog') + ->title_icon('fa fa-cog') ->body(Table::factory() ->data(ORM::factory('Module')->where('parent_id','is',NULL)->find_all()) ->jssort(TRUE) diff --git a/classes/lnAuth/Controller/Admin/Module/Method.php b/classes/lnAuth/Controller/Admin/Module/Method.php index ad19238..5047d85 100644 --- a/classes/lnAuth/Controller/Admin/Module/Method.php +++ b/classes/lnAuth/Controller/Admin/Module/Method.php @@ -23,26 +23,14 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo if (! $mo->loaded() OR ! in_array($method,$mm['methods'])) HTTP::redirect(URL::link('admin','module/list')); - if ($_POST) { - $mmo = $mo->module_method; - $mmo->name = $method; - $mmo->module_id = $mo->id; - $mmo->values($_POST); + $mmo = $mo->module_method; + $mmo->name = $method; + $mmo->module_id = $mo->id; - if (! $this->save($mmo)) - throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST))); + if (! $this->save($mmo)) + 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)); - } - - 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) - ); + HTTP::redirect(URL::link('admin','module_method/edit/'.$mmo->id)); } /** @@ -61,15 +49,15 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo HTTP::redirect(URL::link('admin','module/list')); } - if ($_POST) { - $mmo->values($_POST); + if ($this->request->post()) { + $mmo->values($this->request->post()); 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) { // 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)); 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)); // 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') ->values(array( 'method_id'=>$mmo->id, @@ -99,7 +87,7 @@ abstract class lnAuth_Controller_Admin_Module_Method extends Controller_Admin_Mo Block::factory() ->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') ->body(View::factory('module/method/admin/edit')->set('o',$mmo)); } diff --git a/classes/lnAuth/Controller/TemplateDefault.php b/classes/lnAuth/Controller/TemplateDefault.php index f002df0..b9f1287 100644 --- a/classes/lnAuth/Controller/TemplateDefault.php +++ b/classes/lnAuth/Controller/TemplateDefault.php @@ -53,13 +53,13 @@ abstract class lnAuth_Controller_TemplateDefault extends lnApp_Controller_Templa 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])) - Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save(); + if ($this->request->post() AND array_key_exists($mo->id,$this->request->post('module_config'))) + Config::instance()->module_config($mo->name,$this->request->post('module_config.'.$mo->id))->save(); if ($config_items) { Block::factory() ->title('Update Module Configuration') - ->title_icon('icon-wrench') + ->title_icon('fa fa-wrench') ->type('form-horizontal') ->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id)); } diff --git a/classes/lnAuth/Menu.php b/classes/lnAuth/Menu.php index a2b3f3a..63af772 100644 --- a/classes/lnAuth/Menu.php +++ b/classes/lnAuth/Menu.php @@ -46,10 +46,11 @@ abstract class lnAuth_Menu extends lnApp_Menu { if (! $ao->loaded()) return FALSE; - foreach ($ao->methods() as $mmo) - if ($mmo->menu_display AND $type == $mmo->directory()) - if (empty($result[$mmo->id])) - $result[$mmo->id] = $mmo; + if (is_object($ao)) + foreach ($ao->methods() as $mmo) + if ($mmo->menu_display AND $type == $mmo->directory()) + if (empty($result[$mmo->id])) + $result[$mmo->id] = $mmo; return self::collapse($result); } @@ -61,7 +62,7 @@ abstract class lnAuth_Menu extends lnApp_Menu { if (is_array($v)) $output .= sprintf(''); else - $output .= '
  • '.HTML::anchor($v->url(),$v->menu_display,array('tabindex'=>-1,'nocg'=>TRUE)).'
  • '; + $output .= '
  • '.HTML::anchor($v->url(),$v->menu_display(),array('tabindex'=>-1,'nocg'=>TRUE)).'
  • '; if ($append) { $output .= '
  • '; diff --git a/classes/lnAuth/Model/Account.php b/classes/lnAuth/Model/Account.php index fdaecc9..8185717 100644 --- a/classes/lnAuth/Model/Account.php +++ b/classes/lnAuth/Model/Account.php @@ -61,7 +61,7 @@ abstract class lnAuth_Model_Account extends lnApp_Model_Account { ->method(array($module,$method)) ->account($this) ->uses($uses) - ->expire(time()+$token_expire) + ->expire(time()+$token_expire*60) ->generate(); } } diff --git a/views/module/method/admin/add.php b/views/module/method/admin/add.php deleted file mode 100644 index 71110e6..0000000 --- a/views/module/method/admin/add.php +++ /dev/null @@ -1,16 +0,0 @@ -
    -
    - Add Method - - 'Method','disabled','divclass'=>'col-sm-5')); ?> - 'Description','placeholder'=>'Method Description','divclass'=>'col-sm-7')); ?> - 'Menu Title','placeholder'=>'Menu Title','divclass'=>'col-sm-7')); ?> -
    - -
    -
    - - -
    -
    -
    diff --git a/views/module/method/admin/edit.php b/views/module/method/admin/edit.php index e7a6899..34254d8 100644 --- a/views/module/method/admin/edit.php +++ b/views/module/method/admin/edit.php @@ -1,22 +1,22 @@ -
    -
    +
    +
    Method Details - notes,array('label'=>'Desc','placeholder'=>'Method Description','divclass'=>'col-md-9')); ?> - menu_display,array('label'=>'Title','placeholder'=>'Menu Title','divclass'=>'col-md-9')); ?> +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']); +?>
    -
    -
    -
    +
    Method Security - - + + @@ -24,7 +24,7 @@ - + @@ -32,10 +32,5 @@
    Method NotesGroup ActiveMethod EnableActiveEnabled
    id,TRUE),$go->display('name')); ?> display('notes'); ?>display('active'); ?>display('status'); ?> id,$o->has('group',$go),array('nocg'=>TRUE)); ?>
    -
    -
    - - -
    -
    -
    + +