Empezando a trabajar en menus

This commit is contained in:
Jaime Jiménez
2023-04-29 11:26:41 +02:00
parent 688642f5ea
commit 59c05ee5fd
6 changed files with 150 additions and 44 deletions

View File

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

View File

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

View File

@ -1,20 +0,0 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
class Tarifas extends BaseController
{
function __construct()
{
}
public function index()
{
echo 'Hola';
}
}

View File

@ -14,8 +14,9 @@ class Test extends BaseController
public function index()
{
$request = \Config\Services::request();
$uri = 'https://sk-jjo.imnavajas.es/tarifas';
$uri = new \CodeIgniter\HTTP\URI('https://sk-jjo.imnavajas.es/impresion/impresioncliente');
$language = \Config\Services::language();
$language->setLocale(session()->lang);
@ -23,6 +24,13 @@ class Test extends BaseController
foreach ($getWhiteList as $item){
if(strtolower($item) == $uri->getSegment(1)){
echo '<pre>';
var_dump('1');
echo '</pre>';
dd();
return true;
}
}
@ -31,6 +39,12 @@ class Test extends BaseController
foreach ($this->whiteListMethod() as $item){
if(strtolower($item) == $uri->getSegment(2)){
echo '<pre>';
var_dump('2');
echo '</pre>';
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 '<pre>';
var_dump('3');
echo '</pre>';
dd();
return true;
}
foreach ($value as $item){
if(strtolower($item) == $uri->getSegment(2)){
echo '<pre>';
var_dump('4');
echo '</pre>';
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 '<pre>';
var_dump('5');
echo '</pre>';
dd();
return true;
}
foreach ($value as $item){
if(strtolower($item) == $uri->getSegment(3)){
echo '<pre>';
var_dump('6');
echo '</pre>';
dd();
return true;
}
}
}
}
}
}
}
session()->setFlashdata('sweet', ['error',lang("App.dashboard_alert_rules")]);
header('Location: /home');
exit();
echo '<pre>';
var_dump($controllers);
echo '</pre>';
echo '<pre>';
var_dump($uri->getSegment(1));
var_dump($uri->getSegment(2));
var_dump($uri->getSegment(3));
echo '</pre>';
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'
];
}
}

View File

@ -66,22 +66,33 @@ class LoginAuthFilter implements FilterInterface
if($uri->getTotalSegments() <= 1){
return true;
}
echo '<pre>';
var_dump($value);
/*var_dump($uri->getSegment(0));
var_dump($uri->getSegment(1));
var_dump($uri->getSegment(2));
var_dump($uri->getTotalSegments());*/
echo '</pre>';
/*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.
*/

View File

@ -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) {