Form button class update, fixes to module_method_token, fixes to json

This commit is contained in:
Deon George
2011-08-31 16:54:44 +10:00
parent c55a8fe4cc
commit 52074d239b
19 changed files with 62 additions and 60 deletions

View File

@@ -123,7 +123,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
}
$output .= View::factory('module/admin/method_detail_foot');
$output .= '<div>'.Form::submit('submit',_('Update')).'</div>';
$output .= '<div>'.Form::submit('submit',_('Update'),array('class'=>'form_button')).'</div>';
$output .= Form::close();
Block::add(array(

View File

@@ -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();

View File

@@ -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'])
));
}
}