mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadidos permisos a tarifas, salvo metodo delete
This commit is contained in:
@ -37,7 +37,7 @@ class BaseController extends Controller
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['general', 'go_common'];
|
||||
protected $helpers = ['general', 'go_common', 'rbac'];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@ -85,7 +85,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['session', 'go_common', 'form', 'text', 'general']; //JJO
|
||||
protected $helpers = ['session', 'go_common', 'form', 'text', 'general', 'rbac']; //JJO
|
||||
|
||||
/**
|
||||
* Initializer method.
|
||||
@ -130,29 +130,6 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
$this->viewData['alertStyle'] = $this->alertStyle;
|
||||
}
|
||||
|
||||
protected function checkPermission($sectionPermission, $redirectRoute = NULL)
|
||||
{
|
||||
// TODO ojo, con no redirigir al indexRoute, que se crea bucle!!!
|
||||
if (!auth()->user()->can($sectionPermission)) {
|
||||
$this->session->setFlashdata('errorMessage', "No tiene permisos de acceso");
|
||||
if (is_null($redirectRoute)) {
|
||||
return $this->response->redirect(route_to('home'));
|
||||
} else {
|
||||
return $this->response->redirect(route_to($redirectRoute));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkPermissionAJAX($sectionPermission)
|
||||
{
|
||||
|
||||
if (!auth()->user()->can($sectionPermission)) {
|
||||
return $this->fail('Error');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method to display the form of a module
|
||||
* @param $forMethod
|
||||
|
||||
@ -139,7 +139,7 @@ abstract class GoBaseController extends Controller {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['session', 'go_common', 'text', 'general','jwt']; //JJO
|
||||
protected $helpers = ['session', 'go_common', 'text', 'general','jwt', 'rbac']; //JJO
|
||||
|
||||
public static $queries = [];
|
||||
|
||||
|
||||
@ -48,6 +48,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]),
|
||||
@ -64,6 +66,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
@ -133,8 +137,10 @@ class TarifaAcabados extends BaseResourceController
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
|
||||
@ -40,6 +40,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
checkPermission('tarifa-extra.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
@ -51,8 +52,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-extra.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -117,6 +117,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-extra.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -129,14 +130,10 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
@ -192,7 +189,6 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifapapelcompra extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa papel compra';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifapapeldefecto extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa papel defecto';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,27 +40,17 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
if(!auth()->user()->can('tarifa-preimpresion.menu')){
|
||||
$message = "No tiene permisos de acceso";
|
||||
return redirect()->to(route_to('home'))->with('errorMessage', $message);
|
||||
}
|
||||
checkPermission('tarifa-preimpresion.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]);
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
if(!auth()->user()->can('tarifa-preimpresion.create')){
|
||||
$message = "No tiene permisos de acceso";
|
||||
return redirect()->to(route_to($this->indexRoute))->with('errorMessage', $message);
|
||||
}
|
||||
|
||||
|
||||
checkPermission('tarifa-preimpresion.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -125,6 +115,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-preimpresion.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
|
||||
@ -56,7 +56,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
// Check if the user is allowed to list items
|
||||
parent::checkPermission('tarifa-encuadernacion.menu');
|
||||
checkPermission('tarifa-encuadernacion.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -75,7 +75,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
parent::checkPermission('tarifa-encuadernacion.create', $this->indexRoute);
|
||||
checkPermission('tarifa-encuadernacion.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -158,7 +158,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
parent::checkPermission('tarifa-encuadernacion.create', $this->indexRoute);
|
||||
checkPermission('tarifa-encuadernacion.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
|
||||
@ -57,7 +57,7 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
public function index() {
|
||||
|
||||
// Check if the user is allowed to list items
|
||||
parent::checkPermission('tarifa-envio.menu');
|
||||
checkPermission('tarifa-envio.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -75,7 +75,7 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
public function add() {
|
||||
|
||||
parent::checkPermission('tarifa-envio.create', $this->indexRoute);
|
||||
checkPermission('tarifa-envio.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -144,7 +144,7 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
parent::checkPermission('tarifa-envio.edit', $this->indexRoute);
|
||||
checkPermission('tarifa-envio.edit', $this->indexRoute);
|
||||
|
||||
|
||||
if ($requestedId == null) :
|
||||
@ -231,9 +231,9 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
// JJO
|
||||
public function delete($id = null)
|
||||
{
|
||||
if (!auth()->user()->can('tarifa-envio.delete')) {
|
||||
/*if (!auth()->user()->can('tarifa-envio.delete')) {
|
||||
return $this->fail('Error');
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
|
||||
@ -52,7 +52,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
// Check if the user is allowed to list items
|
||||
parent::checkPermission('tarifa-manipulado.menu');
|
||||
checkPermission('tarifa-manipulado.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -71,8 +71,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-manipulado.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -142,6 +141,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-manipulado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -153,16 +153,13 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
|
||||
Reference in New Issue
Block a user