From 52074d239b584b3041f5aab4a8a5c1a6467980c1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 31 Aug 2011 16:54:44 +1000 Subject: [PATCH] Form button class update, fixes to module_method_token, fixes to json --- .../controller/admin/module/method.php | 2 +- .../classes/controller/lnapp/login.php | 10 ++- application/classes/controller/tree.php | 70 ++++++++++--------- application/media/css/default.css | 3 - application/views/login.php | 2 +- application/views/login_reset.php | 2 +- application/views/login_reset_sent.php | 2 +- application/views/module/admin/method_add.php | 2 +- modules/account/classes/auth/osb.php | 6 +- .../account/views/account/password_reset.php | 3 +- modules/account/views/account/user/edit.php | 2 +- modules/account/views/register.php | 2 +- .../email/classes/controller/admin/email.php | 4 +- .../classes/controller/admin/export.php | 2 +- .../export/views/export/payment/header.php | 2 +- modules/product/views/product/view.php | 2 +- .../classes/controller/admin/service.php | 2 +- .../service/views/service/admin/update.php | 2 +- .../service/views/service/user/adsl/view.php | 2 +- 19 files changed, 62 insertions(+), 60 deletions(-) diff --git a/application/classes/controller/admin/module/method.php b/application/classes/controller/admin/module/method.php index b97f615a..045bc775 100644 --- a/application/classes/controller/admin/module/method.php +++ b/application/classes/controller/admin/module/method.php @@ -123,7 +123,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { } $output .= View::factory('module/admin/method_detail_foot'); - $output .= '
'.Form::submit('submit',_('Update')).'
'; + $output .= '
'.Form::submit('submit',_('Update'),array('class'=>'form_button')).'
'; $output .= Form::close(); Block::add(array( diff --git a/application/classes/controller/lnapp/login.php b/application/classes/controller/lnapp/login.php index bfd43c8c..f37c50a2 100644 --- a/application/classes/controller/lnapp/login.php +++ b/application/classes/controller/lnapp/login.php @@ -119,6 +119,9 @@ class Controller_lnApp_Login extends Controller_TemplateDefault { * Enable user password reset */ public function action_reset() { + // Minutes to keep our token + $token_expire = 15; + // If user already signed-in if (Auth::instance()->logged_in()!= 0) { // Redirect to the user account @@ -138,7 +141,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault { // Check to see if there is already a token, if so, do nothing. if ($mt->where('account_id','=',$ao->id)->and_where('method_id','=',$mmo->id)->find()) { - if ($mt->date_expire < time()) { + if ($mt->loaded() AND ($mt->date_expire < time())) { $mt->delete(); $mt->clear(); } @@ -147,18 +150,19 @@ class Controller_lnApp_Login extends Controller_TemplateDefault { if (! $mt->loaded()) { $mt->account_id = $ao->id; $mt->method_id = $mmo->id; - $mt->date_expire = time() + 15*3600; + $mt->date_expire = time() + $token_expire*60; $mt->token = md5(sprintf('%s:%s:%s',$mt->account_id,$mt->method_id,$mt->date_expire)); $mt->save(); // Send our email with the token $et = Email_Template::instance('account_reset_password'); - $et->to = array($mt->account->email=>sprintf('%s %s',$mt->account->first_name,$mt->account->last_name)); + $et->to = array('account'=>array($mt->account_id)); $et->variables = array( 'SITE'=>URL::base(TRUE,TRUE), 'SITE_ADMIN'=>Config::sitename(), 'SITE_NAME'=>Config::sitename(), 'TOKEN'=>$mt->token, + 'TOKEN_EXPIRE_MIN'=>$token_expire, 'USER_NAME'=>sprintf('%s %s',$mt->account->first_name,$mt->account->last_name), ); $et->send(); diff --git a/application/classes/controller/tree.php b/application/classes/controller/tree.php index 709f77bf..e7132397 100644 --- a/application/classes/controller/tree.php +++ b/application/classes/controller/tree.php @@ -21,49 +21,51 @@ class Controller_Tree extends Controller_lnApp_Tree { * * @param id */ - public function action_json($id=null,array $data=array()) { + public function action_json($id=NULL,array $data=array()) { // Get the user details - $id = (is_null($id) && isset($_REQUEST['id'])) ? substr($_REQUEST['id'],2) : $id; + $id = (is_null($id) AND isset($_REQUEST['id'])) ? substr($_REQUEST['id'],2) : $id; $user = Auth::instance()->get_user(); - if (! $id) { - $modules = array(); - foreach ($user->groups() as $go) - $modules = array_merge($modules,Module_Method::groupmodules($go->id)); + if ($user) { + if (! $id) { + $modules = array(); + foreach ($user->groups() as $go) + $modules = array_merge($modules,Module_Method::groupmodules($go->id)); - ksort($modules); + ksort($modules); - $data = array(); - foreach ($modules as $module => $details) - if (! $details['parent_id']) - array_push($data, - array('id'=>$details['id'],'name'=>$module,'state'=>'closed') - ); + $data = array(); + foreach ($modules as $module => $details) + if (! $details['parent_id']) + array_push($data, + array('id'=>$details['id'],'name'=>$module,'state'=>'closed') + ); - } else { - $module = preg_replace('/^N_/','',$id); - $methods = array(); - foreach ($user->groups() as $go) - $methods = array_merge($methods,Module_Method::groupmethods($go->id,$module)); + } else { + $module = preg_replace('/^N_/','',$id); + $methods = array(); + foreach ($user->groups() as $go) + $methods = array_merge($methods,Module_Method::groupmethods($go->id,$module)); - ksort($methods); + ksort($methods); - $data = array(); - foreach ($methods as $method => $details) { - if (preg_match('/_/',$method)) { - list($mode,$action) = explode('_',$method); - $url = URL::site(sprintf('/%s/%s/%s',$mode,$details['module'],$action)); - } else { - $url = URL::site(sprintf('/%s/%s',$details['module'],$method)); + $data = array(); + foreach ($methods as $method => $details) { + if (preg_match('/_/',$method)) { + list($mode,$action) = explode('_',$method); + $url = URL::site(sprintf('/%s/%s/%s',$mode,$details['module'],$action)); + } else { + $url = URL::site(sprintf('/%s/%s',$details['module'],$method)); + } + + array_push($data,array( + 'id'=>sprintf('%s_%s',$module,$details['id']), + 'name'=>$method, + 'state'=>'none', + 'attr_id'=>sprintf('%s_%s',$module,$details['id']), + 'attr_href'=>(empty($details['page']) ? $url : $details['page']) + )); } - - array_push($data,array( - 'id'=>sprintf('%s_%s',$module,$details['id']), - 'name'=>$method, - 'state'=>'none', - 'attr_id'=>sprintf('%s_%s',$module,$details['id']), - 'attr_href'=>(empty($details['page']) ? $url : $details['page']) - )); } } diff --git a/application/media/css/default.css b/application/media/css/default.css index 56bdf1ba..76e0d87c 100644 --- a/application/media/css/default.css +++ b/application/media/css/default.css @@ -4,9 +4,6 @@ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; - background-color: #E1E1E3; - border-color: #AAAACC; - border-width: 1px; padding: 1px; } diff --git a/application/views/login.php b/application/views/login.php index fd491b15..5761fb70 100644 --- a/application/views/login.php +++ b/application/views/login.php @@ -9,7 +9,7 @@   - + 'form_button'));?> diff --git a/application/views/login_reset.php b/application/views/login_reset.php index 5d4294d6..465963f7 100644 --- a/application/views/login_reset.php +++ b/application/views/login_reset.php @@ -7,7 +7,7 @@ - +
Email Address
'login-uid','size'=>40));?>
'form_button'));?>
diff --git a/application/views/login_reset_sent.php b/application/views/login_reset_sent.php index dd2554be..b08f6f39 100644 --- a/application/views/login_reset_sent.php +++ b/application/views/login_reset_sent.php @@ -6,7 +6,7 @@ - +
Pass code
'login-pwd','size'=>40));?>
'form_button'));?>
diff --git a/application/views/module/admin/method_add.php b/application/views/module/admin/method_add.php index c14616e9..8934ada1 100644 --- a/application/views/module/admin/method_add.php +++ b/application/views/module/admin/method_add.php @@ -17,5 +17,5 @@ - +'form_button')); ?> diff --git a/modules/account/classes/auth/osb.php b/modules/account/classes/auth/osb.php index 61fbe12d..b0da3719 100644 --- a/modules/account/classes/auth/osb.php +++ b/modules/account/classes/auth/osb.php @@ -109,7 +109,6 @@ class Auth_OSB extends Auth_ORM { // Check and see if we have a token to login and run the method } elseif ((! empty($_REQUEST['token']) AND $token = $_REQUEST['token']) OR $token=Session::instance()->get('token')) { - if ($user=$this->_get_token_user($token) AND $user !== FALSE) $status = TRUE; @@ -149,7 +148,6 @@ class Auth_OSB extends Auth_ORM { */ private function _get_token_user($token) { $mmto = ORM::factory('module_method_token',array('token'=>$token)); - $request = Request::current(); $user = FALSE; if ($mmto->loaded()) { @@ -164,9 +162,9 @@ class Auth_OSB extends Auth_ORM { } else { // Check that the token is for this URI - $mo = ORM::factory('module',array('name'=>$request->controller)); + $mo = ORM::factory('module',array('name'=>Request::current()->controller())); $mmo = ORM::factory('module_method', - array('name'=>$request->directory ? sprintf('%s_%s',$request->directory,$request->action) : $request->action)); + array('name'=>Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action())); // Ignore the token if this is not the right method. if ($mmo->id == $mmto->method_id) { diff --git a/modules/account/views/account/password_reset.php b/modules/account/views/account/password_reset.php index 39dc627d..eda089bd 100644 --- a/modules/account/views/account/password_reset.php +++ b/modules/account/views/account/password_reset.php @@ -1,4 +1,5 @@ +
@@ -10,7 +11,7 @@ - +
'form_button')); ?>
diff --git a/modules/account/views/account/user/edit.php b/modules/account/views/account/user/edit.php index 11012102..16a09632 100644 --- a/modules/account/views/account/user/edit.php +++ b/modules/account/views/account/user/edit.php @@ -78,7 +78,7 @@ - + 'form_button')); ?> diff --git a/modules/account/views/register.php b/modules/account/views/register.php index 07f1bf56..3fb356fc 100644 --- a/modules/account/views/register.php +++ b/modules/account/views/register.php @@ -125,7 +125,7 @@   - + 'form_button'));?> diff --git a/modules/email/classes/controller/admin/email.php b/modules/email/classes/controller/admin/email.php index 3d225087..6b44a9af 100644 --- a/modules/email/classes/controller/admin/email.php +++ b/modules/email/classes/controller/admin/email.php @@ -88,7 +88,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin { $output .= Form::open(); $output .= View::factory('email/admin/template/add'); $output .= View::factory('email/admin/template/translate/add'); - $output .= '
'.Form::submit('submit',_('Add')).'
'; + $output .= '
'.Form::submit('submit',_('Add'),array('class'=>'form_button')).'
'; $output .= Form::close(); Editor::add(); @@ -139,7 +139,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin { )); } - $output .= '
'.Form::submit('submit',_('Update')).'
'; + $output .= '
'.Form::submit('submit',_('Update'),array('class'=>'form_button')).'
'; $output .= Form::close(); Editor::add(); diff --git a/modules/export/classes/controller/admin/export.php b/modules/export/classes/controller/admin/export.php index c2ed5870..f69a6061 100644 --- a/modules/export/classes/controller/admin/export.php +++ b/modules/export/classes/controller/admin/export.php @@ -62,7 +62,7 @@ class Controller_Admin_Export extends Controller_TemplateDefault_Admin { } $output .= ''; - $output .= Form::submit('submit','export'); + $output .= Form::submit('submit','export',array('class'=>'form_button')); $output .= Form::close(); Style::add(array( diff --git a/modules/export/views/export/payment/header.php b/modules/export/views/export/payment/header.php index 900b348a..290e585c 100644 --- a/modules/export/views/export/payment/header.php +++ b/modules/export/views/export/payment/header.php @@ -1,6 +1,6 @@ - + 'form_button')); ?> diff --git a/modules/product/views/product/view.php b/modules/product/views/product/view.php index 2fe45370..3567a08a 100644 --- a/modules/product/views/product/view.php +++ b/modules/product/views/product/view.php @@ -77,7 +77,7 @@ echo Form::open('cart/add'); - | 'disabled')); ?> + 'form_button')); ?> | 'disabled'),array('class'=>'form_button')); ?> diff --git a/modules/service/classes/controller/admin/service.php b/modules/service/classes/controller/admin/service.php index 4a040888..495a0312 100644 --- a/modules/service/classes/controller/admin/service.php +++ b/modules/service/classes/controller/admin/service.php @@ -380,7 +380,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID $output .= Form::open(NULL,array('enctype'=>'multipart/form-data')); $output .= '
'; $output .= Form::file('csv'); - $output .= Form::submit('submit','upload'); + $output .= Form::submit('submit','upload',array('class'=>'form_button')); $output .= '
'; $output .= Form::close(); diff --git a/modules/service/views/service/admin/update.php b/modules/service/views/service/admin/update.php index 62f802da..5c12421a 100644 --- a/modules/service/views/service/admin/update.php +++ b/modules/service/views/service/admin/update.php @@ -64,5 +64,5 @@ - +'form_button')); ?> diff --git a/modules/service/views/service/user/adsl/view.php b/modules/service/views/service/user/adsl/view.php index 74db3ee0..82c1c760 100644 --- a/modules/service/views/service/user/adsl/view.php +++ b/modules/service/views/service/user/adsl/view.php @@ -61,7 +61,7 @@ - +
View Daily Traffic for Monthget_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show')); echo Form::close(); ?>get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show'),array('class'=>'form_button')); echo Form::close(); ?>