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

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