diff --git a/ci4/app/Controllers/Group.php b/ci4/app/Controllers/Group.php index cb7ab367..4c52769c 100644 --- a/ci4/app/Controllers/Group.php +++ b/ci4/app/Controllers/Group.php @@ -156,9 +156,11 @@ class Group extends BaseController $exp = explode('_',$key); $controller[] = $exp[0]; } + if($controller != null){ foreach (array_unique($controller) as $item){ $rules_access[$item] = []; + foreach ($getChecked as $key=>$value){ $exp = explode('_',$key); if($exp[0] == $item){ @@ -167,8 +169,10 @@ class Group extends BaseController } } } + $listPost['rules'] = json_encode($rules_access??'{}'); + if(empty($listPost['id_group'])){ $listPost['token'] = md5(uniqid(rand(), true)); } diff --git a/ci4/app/Controllers/Impresion/Cliente.php b/ci4/app/Controllers/Impresion/Impresioncliente.php similarity index 77% rename from ci4/app/Controllers/Impresion/Cliente.php rename to ci4/app/Controllers/Impresion/Impresioncliente.php index d5d12b64..76b259c4 100644 --- a/ci4/app/Controllers/Impresion/Cliente.php +++ b/ci4/app/Controllers/Impresion/Impresioncliente.php @@ -4,8 +4,8 @@ namespace App\Controllers\Impresion; use App\Controllers\BaseController; -class Cliente extends BaseController -{ +class Impresioncliente extends BaseController +{ function __construct() { @@ -13,8 +13,8 @@ class Cliente extends BaseController public function index() { - echo 'Hola2'; - } + } } + \ No newline at end of file diff --git a/ci4/app/Controllers/Tarifas.php b/ci4/app/Controllers/Tarifas.php deleted file mode 100644 index 914db980..00000000 --- a/ci4/app/Controllers/Tarifas.php +++ /dev/null @@ -1,20 +0,0 @@ -setLocale(session()->lang); @@ -23,6 +24,13 @@ class Test extends BaseController foreach ($getWhiteList as $item){ if(strtolower($item) == $uri->getSegment(1)){ + + + echo '
';
+ var_dump('1');
+ echo '';
+ dd();
+
return true;
}
}
@@ -31,6 +39,12 @@ class Test extends BaseController
foreach ($this->whiteListMethod() as $item){
if(strtolower($item) == $uri->getSegment(2)){
+
+ echo '';
+ var_dump('2');
+ echo '';
+ dd();
+
return true;
}
}
@@ -38,24 +52,68 @@ class Test extends BaseController
foreach ($getRules as $key=>$value){
if(strtolower($key) == $uri->getSegment(1)){
if($uri->getTotalSegments() <= 1){
+
+ echo '';
+ var_dump('3');
+ echo '';
+ dd();
+
return true;
}
+
foreach ($value as $item){
if(strtolower($item) == $uri->getSegment(2)){
+
+ echo '';
+ var_dump('4');
+ echo '';
+ dd();
+
return true;
}
}
+
+ }
+ else{
+ foreach($this->controllerFolderList() as $folder){
+ if(strtolower($folder) == $uri->getSegment(1)){
+ var_dump($key);
+ if(strtolower($key) == $uri->getSegment(2)){
+ if($uri->getTotalSegments() <= 2){
+
+ echo '';
+ var_dump('5');
+ echo '';
+ dd();
+
+ return true;
+ }
+
+ foreach ($value as $item){
+ if(strtolower($item) == $uri->getSegment(3)){
+
+ echo '';
+ var_dump('6');
+ echo '';
+ dd();
+
+ return true;
+ }
+ }
+
+ }
+ }
+ }
+
}
}
- session()->setFlashdata('sweet', ['error',lang("App.dashboard_alert_rules")]);
- header('Location: /home');
- exit();
-
- echo ''; - var_dump($controllers); - echo ''; - + echo '
'; + var_dump($uri->getSegment(1)); + var_dump($uri->getSegment(2)); + var_dump($uri->getSegment(3)); + echo ''; + dd(); } @@ -81,4 +139,46 @@ class Test extends BaseController ]; } + + /** + * JJO + * Returns the controller folder list + */ + public function controllerFolderList(){ + return [ + 'impresion', + ]; + } + + + /** + * Returns the whitelist of public controllers. + */ + public function ignoreListController(){ + return [ + ]; + } + + public function validateIgnoreControllerAccess(){ + $request = \Config\Services::request(); + $uri = $request->uri; + + $getList = $this->ignoreListController(); + foreach ($getList as $item){ + if(strtolower($item) == $uri->getSegment(1)){ + return true; + } + } + return false; + } + + public function whiteListMethod(){ + return [ + 'initController', + '__construct', + 'validateControllerAccess', + 'whiteListController', + 'whiteListMethod' + ]; + } } diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index d189fb22..d014012f 100644 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -66,22 +66,33 @@ class LoginAuthFilter implements FilterInterface if($uri->getTotalSegments() <= 1){ return true; } - echo '
'; - var_dump($value); - /*var_dump($uri->getSegment(0)); - var_dump($uri->getSegment(1)); - var_dump($uri->getSegment(2)); - var_dump($uri->getTotalSegments());*/ - echo ''; - /*foreach ($value as $item){ + foreach ($value as $item){ if(strtolower($item) == $uri->getSegment(2)){ return true; } - }*/ + } + + } + else{ + foreach($this->controllerFolderList() as $folder){ + if(strtolower($folder) == $uri->getSegment(1)){ + if(strtolower($key) == $uri->getSegment(2)){ + if($uri->getTotalSegments() <= 2){ + return true; + } + + foreach ($value as $item){ + if(strtolower($item) == $uri->getSegment(3)){ + return true; + } + } + + } + } + } } - dd(); } session()->setFlashdata('sweet', ['error',lang("App.dashboard_alert_rules")]); header('Location: /home'); @@ -110,6 +121,17 @@ class LoginAuthFilter implements FilterInterface ]; } + /** + * JJO + * Returns the controller folder list + */ + public function controllerFolderList(){ + return [ + 'impresion', + ]; + } + + /** * Returns the whitelist of public controllers. */ diff --git a/ci4/app/Helpers/general_helper.php b/ci4/app/Helpers/general_helper.php index e967b196..a75ddd2f 100644 --- a/ci4/app/Helpers/general_helper.php +++ b/ci4/app/Helpers/general_helper.php @@ -156,7 +156,7 @@ function getDictionary($word=''){ 'oauth_store' => lang("App.group_rules_label_oauth_store"), 'template_store' => lang("App.group_rules_label_template_store"), 'Tarifas' => 'Tarifas', - 'Cliente' => 'Cliente' + 'ImpresionCliente' => 'Cliente' ]; return array_key_exists($word,$dictionary)?$dictionary[$word] : $word; } catch (Exception $e) {