| #0 | Phalcon\Mvc\Model\MetaData\Strategy\Introspection->getMetaData(Object(Colindar\Models\Translations: 19), Object(Phalcon\Di\FactoryDefault)) |
| #1 | Phalcon\Mvc\Model\MetaData->_initialize(Object(Colindar\Models\Translations: 19), colindar\models\translations-translations, translations, ) |
| #2 | Phalcon\Mvc\Model\MetaData->readMetaData(Object(Colindar\Models\Translations: 19)) |
| #3 | Phalcon\Mvc\Model\MetaData->hasAttribute(Object(Colindar\Models\Translations: 19), key_name) |
| #4 | Phalcon\Mvc\Model\Query->_getQualified(Array([type] => 355, [name] => key_name)) |
| #5 | Phalcon\Mvc\Model\Query->_getExpression(Array([type] => 355, [name] => key_name), true) |
| #6 | Phalcon\Mvc\Model\Query->_getExpression(Array([type] => 61, [left] => Array([type] => 355, [name] => key_name), [right] => Array([type] => 266, [left] => Array([type] => 273, [value] => ?0), [right] => Array([type] => 355, [name] => lang))), true) |
| #7 | Phalcon\Mvc\Model\Query->_getExpression(Array([type] => 61, [left] => Array([type] => 61, [left] => Array([type] => 355, [name] => key_name), [right] => Array([type] => 266, [left] => Array(), [right] => Array())), [right] => Array([type] => 273, [value] => ?1))) |
| #8 | Phalcon\Mvc\Model\Query->_prepareSelect() |
| #9 | Phalcon\Mvc\Model\Query->parse() |
| #10 | Phalcon\Mvc\Model\Query->execute() |
| #11 | Phalcon\Mvc\Model::findFirst(Array([0] => key_name = ?0 and lang= ?1, [bind] => Array([0] => Tu app de reservas para espacios comunes, instalaciones deportivas, comedores, salas, eventos, etc., [1] => es))) /app/app/library/Translate/Translate.php (90) <?php
namespace Colindar\Translate;
use Phalcon\Translate\Adapter\NativeArray as Adaptor;
use Colindar\Models\Translations;
class Translate extends Adaptor
{
public const DEEPL_API_KEY = '2eabc7be-9c5a-3b4e-42f9-701310eb2f3e:fx';
public const DEEPL_API_VERSION = 2;
public const MAIN_LANGUAJE = 'es';
/*
* PROTOCOLO PARA AÑADIR UN NUEVO IDIOMA
*
* 1.- Se añade al array inferior $languajes
* 2.- Se replican todos los registros del idioma ES (que es la base) de la tabla
* translations cambiando el campo 'lang' al nuevo idioma
* 3.- Creamos la carpeta dentro de /app/lang/{$nuevoIdioma}
* 4.- Se mira tema de las banderas dentro de las carptas
* 5.- Se puede empezar con la traducción
*/
/**
* ISO de dos letras en minúsculas
* https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/
public static $languajes
= [
'es' => 'es',
'en' => 'en',
'ca' => 'ca',
'fr' => 'fr'
];
/**
* Returns the translation string of the given key
*
* Using:
* {{ t._('Mis Hogares') }}
* <?php echo $t->_('Mis Hogares)?>
*
* @param string $translateKey
* @param array $placeholders
*
* @return string
*/
public
function _(
$translateKey,
$placeholders = null
) {
$this->findOrCreateRegister($translateKey);
return parent::_($translateKey, $placeholders);
}
/**
* @param $translateKey
*/
private
function findOrCreateRegister(
String $translateKey
): void {
if (DEBUG) {
/*
* Comprobamos si existe
* SI -> no hacemos nada
* NO -> lo añadimos a la bbdd para traducir en todos los idiomas
*/
$trans = $this->findKey($translateKey);
if (!$trans) {
$this->createRegisterBbdd($translateKey);
}
}
}
private
function findKey(
string $translateKey
) {
$translateKey250 = substr($translateKey, 0, 250);
return Translations::findFirst([
'key_name = ?0 and lang= ?1',
'bind' => [
$translateKey250,
'es'
]
]);
}
private
function createRegisterBbdd(
String $translateKey
): void {
$trans = new Translations();
$trans->key_name = substr($translateKey, 0, 250);
$trans->lang = self::MAIN_LANGUAJE;
@$trans->save();
}
public static
function generateArrayFile(
$lang
): void {
$transArray = [];
$todas = Translations::find([
'lang = ?0 and trans != ?1',
'bind' => [$lang, '']
]);
foreach ($todas as $toda) {
if ($toda->trans !== '') {
$transArray[$toda->key_name] = $toda->trans;
}
}
if ($lang !== 'es') {
$transBase = Translations::find([
"conditions" => "lang = ?0 and key_name like '_MSG_%'",
'bind' => [
'es'
]
]);
foreach ($transBase as $item) {
if (!isset($transArray[$item->key_name]) || $transArray[$item->key_name] === '') {
$transArray[$item->key_name] = $item->trans;
}
}
}
$filepath = APP_DIR . "/lang/{$lang}/{$lang}.php";
$datetime = date("Y-m-d H:i:s");
if (file_exists($filepath)) {
//destruimos para después regenerar
unlink($filepath);
}
file_put_contents($filepath,
"<?php \n //Generado $datetime\n\n \$messages = " . var_export($transArray, true) . ";");
}
public static
function regenerateNewTranslationsFromES(): void
{
$transBase = Translations::findByLang('es');
foreach ($transBase as $base) {
foreach (self::$languajes as $lang) {
$transDest = Translations::findFirst([
'lang = ?0 and key_name = ?1',
'bind' => [
$lang,
$base->key_name
]
]);
if (!$transDest) {
$tran = new Translations();
$tran->lang = $lang;
$tran->key_name = $base->key_name;
$tran->trans = '';
$tran->save();
}
}
}
}
} |
| #12 | Colindar\Translate\Translate->findKey(Tu app de reservas para espacios comunes, instalaciones deportivas, comedores, salas, eventos, etc.) /app/app/library/Translate/Translate.php (71) <?php
namespace Colindar\Translate;
use Phalcon\Translate\Adapter\NativeArray as Adaptor;
use Colindar\Models\Translations;
class Translate extends Adaptor
{
public const DEEPL_API_KEY = '2eabc7be-9c5a-3b4e-42f9-701310eb2f3e:fx';
public const DEEPL_API_VERSION = 2;
public const MAIN_LANGUAJE = 'es';
/*
* PROTOCOLO PARA AÑADIR UN NUEVO IDIOMA
*
* 1.- Se añade al array inferior $languajes
* 2.- Se replican todos los registros del idioma ES (que es la base) de la tabla
* translations cambiando el campo 'lang' al nuevo idioma
* 3.- Creamos la carpeta dentro de /app/lang/{$nuevoIdioma}
* 4.- Se mira tema de las banderas dentro de las carptas
* 5.- Se puede empezar con la traducción
*/
/**
* ISO de dos letras en minúsculas
* https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/
public static $languajes
= [
'es' => 'es',
'en' => 'en',
'ca' => 'ca',
'fr' => 'fr'
];
/**
* Returns the translation string of the given key
*
* Using:
* {{ t._('Mis Hogares') }}
* <?php echo $t->_('Mis Hogares)?>
*
* @param string $translateKey
* @param array $placeholders
*
* @return string
*/
public
function _(
$translateKey,
$placeholders = null
) {
$this->findOrCreateRegister($translateKey);
return parent::_($translateKey, $placeholders);
}
/**
* @param $translateKey
*/
private
function findOrCreateRegister(
String $translateKey
): void {
if (DEBUG) {
/*
* Comprobamos si existe
* SI -> no hacemos nada
* NO -> lo añadimos a la bbdd para traducir en todos los idiomas
*/
$trans = $this->findKey($translateKey);
if (!$trans) {
$this->createRegisterBbdd($translateKey);
}
}
}
private
function findKey(
string $translateKey
) {
$translateKey250 = substr($translateKey, 0, 250);
return Translations::findFirst([
'key_name = ?0 and lang= ?1',
'bind' => [
$translateKey250,
'es'
]
]);
}
private
function createRegisterBbdd(
String $translateKey
): void {
$trans = new Translations();
$trans->key_name = substr($translateKey, 0, 250);
$trans->lang = self::MAIN_LANGUAJE;
@$trans->save();
}
public static
function generateArrayFile(
$lang
): void {
$transArray = [];
$todas = Translations::find([
'lang = ?0 and trans != ?1',
'bind' => [$lang, '']
]);
foreach ($todas as $toda) {
if ($toda->trans !== '') {
$transArray[$toda->key_name] = $toda->trans;
}
}
if ($lang !== 'es') {
$transBase = Translations::find([
"conditions" => "lang = ?0 and key_name like '_MSG_%'",
'bind' => [
'es'
]
]);
foreach ($transBase as $item) {
if (!isset($transArray[$item->key_name]) || $transArray[$item->key_name] === '') {
$transArray[$item->key_name] = $item->trans;
}
}
}
$filepath = APP_DIR . "/lang/{$lang}/{$lang}.php";
$datetime = date("Y-m-d H:i:s");
if (file_exists($filepath)) {
//destruimos para después regenerar
unlink($filepath);
}
file_put_contents($filepath,
"<?php \n //Generado $datetime\n\n \$messages = " . var_export($transArray, true) . ";");
}
public static
function regenerateNewTranslationsFromES(): void
{
$transBase = Translations::findByLang('es');
foreach ($transBase as $base) {
foreach (self::$languajes as $lang) {
$transDest = Translations::findFirst([
'lang = ?0 and key_name = ?1',
'bind' => [
$lang,
$base->key_name
]
]);
if (!$transDest) {
$tran = new Translations();
$tran->lang = $lang;
$tran->key_name = $base->key_name;
$tran->trans = '';
$tran->save();
}
}
}
}
} |
| #13 | Colindar\Translate\Translate->findOrCreateRegister(Tu app de reservas para espacios comunes, instalaciones deportivas, comedores, salas, eventos, etc.) /app/app/library/Translate/Translate.php (53) <?php
namespace Colindar\Translate;
use Phalcon\Translate\Adapter\NativeArray as Adaptor;
use Colindar\Models\Translations;
class Translate extends Adaptor
{
public const DEEPL_API_KEY = '2eabc7be-9c5a-3b4e-42f9-701310eb2f3e:fx';
public const DEEPL_API_VERSION = 2;
public const MAIN_LANGUAJE = 'es';
/*
* PROTOCOLO PARA AÑADIR UN NUEVO IDIOMA
*
* 1.- Se añade al array inferior $languajes
* 2.- Se replican todos los registros del idioma ES (que es la base) de la tabla
* translations cambiando el campo 'lang' al nuevo idioma
* 3.- Creamos la carpeta dentro de /app/lang/{$nuevoIdioma}
* 4.- Se mira tema de las banderas dentro de las carptas
* 5.- Se puede empezar con la traducción
*/
/**
* ISO de dos letras en minúsculas
* https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/
public static $languajes
= [
'es' => 'es',
'en' => 'en',
'ca' => 'ca',
'fr' => 'fr'
];
/**
* Returns the translation string of the given key
*
* Using:
* {{ t._('Mis Hogares') }}
* <?php echo $t->_('Mis Hogares)?>
*
* @param string $translateKey
* @param array $placeholders
*
* @return string
*/
public
function _(
$translateKey,
$placeholders = null
) {
$this->findOrCreateRegister($translateKey);
return parent::_($translateKey, $placeholders);
}
/**
* @param $translateKey
*/
private
function findOrCreateRegister(
String $translateKey
): void {
if (DEBUG) {
/*
* Comprobamos si existe
* SI -> no hacemos nada
* NO -> lo añadimos a la bbdd para traducir en todos los idiomas
*/
$trans = $this->findKey($translateKey);
if (!$trans) {
$this->createRegisterBbdd($translateKey);
}
}
}
private
function findKey(
string $translateKey
) {
$translateKey250 = substr($translateKey, 0, 250);
return Translations::findFirst([
'key_name = ?0 and lang= ?1',
'bind' => [
$translateKey250,
'es'
]
]);
}
private
function createRegisterBbdd(
String $translateKey
): void {
$trans = new Translations();
$trans->key_name = substr($translateKey, 0, 250);
$trans->lang = self::MAIN_LANGUAJE;
@$trans->save();
}
public static
function generateArrayFile(
$lang
): void {
$transArray = [];
$todas = Translations::find([
'lang = ?0 and trans != ?1',
'bind' => [$lang, '']
]);
foreach ($todas as $toda) {
if ($toda->trans !== '') {
$transArray[$toda->key_name] = $toda->trans;
}
}
if ($lang !== 'es') {
$transBase = Translations::find([
"conditions" => "lang = ?0 and key_name like '_MSG_%'",
'bind' => [
'es'
]
]);
foreach ($transBase as $item) {
if (!isset($transArray[$item->key_name]) || $transArray[$item->key_name] === '') {
$transArray[$item->key_name] = $item->trans;
}
}
}
$filepath = APP_DIR . "/lang/{$lang}/{$lang}.php";
$datetime = date("Y-m-d H:i:s");
if (file_exists($filepath)) {
//destruimos para después regenerar
unlink($filepath);
}
file_put_contents($filepath,
"<?php \n //Generado $datetime\n\n \$messages = " . var_export($transArray, true) . ";");
}
public static
function regenerateNewTranslationsFromES(): void
{
$transBase = Translations::findByLang('es');
foreach ($transBase as $base) {
foreach (self::$languajes as $lang) {
$transDest = Translations::findFirst([
'lang = ?0 and key_name = ?1',
'bind' => [
$lang,
$base->key_name
]
]);
if (!$transDest) {
$tran = new Translations();
$tran->lang = $lang;
$tran->key_name = $base->key_name;
$tran->trans = '';
$tran->save();
}
}
}
}
} |
| #14 | Colindar\Translate\Translate->_(Tu app de reservas para espacios comunes, instalaciones deportivas, comedores, salas, eventos, etc.) /app/app/controllers/ControllerBase.php (129) <?php
namespace Colindar\Controllers;
use Colindar\Helpers\CodeHelpers;
use Colindar\Marcas\Marca;
use Colindar\Models\Community;
use Colindar\Models\Files;
use Colindar\Models\Providers;
use Colindar\Models\Users;
use Exception;
use Phalcon\Assets\Filters\Cssmin;
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Tag;
/**
* ControllerBase
* This is the base controller for all controllers in the application
*/
class ControllerBase extends Controller
{
public CONST LIFETIME_CACHE_OPTIONS = 300; //ms
/**
* Constante que usaremos para decir que acciones necesitan permisos de escritura
*/
public const ACTIONS_EDITABLES
= [
'new',
'edit',
'create',
'save',
'delete'
];
public const LIMIT_PAGINATION = 10;
public static
function isEditablesActions(
$actionName
) {
return in_array($actionName, static::ACTIONS_EDITABLES, true);
}
protected $user;
public
function initialize()
{
$this->assetsmanager
->collection('jsFooter')
->setTargetPath('js/cache/general.js')
->setTargetUri('js/cache/general.js')
->addJs('components/metisMenu/dist/metisMenu.min.js')
->addJs('components/pace/pace.min.js')
->addJs('components/sweetalert/dist/sweetalert.min.js')
->addJs('components/jquery.slimscroll/jquery.slimscroll.min.js')
->addJs('js/plugins/dropzone/dropzone.js')
->addJs('components/jquery.slimscroll/jquery.slimscroll.min.js')
->addJs('components/select2/dist/js/select2.min.js')
->addJs('js/chosen.jquery.js')
->addJs('components/bootstrap-tour/build/js/bootstrap-tour.min.js')
->addJs('components/moment/min/moment-with-locales.min.js')
->addJs('components/iCheck/icheck.min.js')
->addJs('components/switchery/dist/switchery.min.js')
->addJs('components/toastr/toastr.min.js')
->addJs('js/plugins/jquery.sparkline/jquery.sparkline.min.js')
->addJs('components/jquery-i18n/src/jquery.i18n.js')
->addJs('components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js')
//datatables
->addJs('https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js', false, false)
->addJs('https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js', false, false)
->addJs('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js', false, false)
->addJs('https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js', false, false)
// ->addJs('https://cdn.datatables.net/buttons/1.5.6/js/buttons.flash.min.js', false, false)
->addJs('https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js', false, false)
->addJs('https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.56/pdfmake.min.js', false, false)
->addJs('https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.56/vfs_fonts.js', false, false)
->addJs('https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js', false, false)
->addJs('https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js', false, false)
->addJs('https://cdn.datatables.net/buttons/1.5.6/js/buttons.colVis.min.js', false, false)
->addJs('js/plugins/jQuery-autoComplete-master/jquery.auto-complete.js')
->addJs('js/colindar.js')
// ->join(true)
// ->addFilter(new Jsmin())
;
$pathJsAsset = 'js/cache/' . $this->dispatcher->getControllerName() . '.js';
$this->assetsmanager
->collection('js')
->setTargetPath($pathJsAsset)
->setTargetUri($pathJsAsset);
$this->assetsmanager
->collection('cssHeader')
->setTargetPath('css/cache/general.css')
->setTargetUri('css/cache/general.css')
->addCss('css/animate.css')
->addCss('css/style.css')
->addCss('components/sweetalert/dist/sweetalert.css')
->addCss('css/plugins/select2/select2.min.css')
->addCss('components/chosen/chosen.css')
->addCss('css/plugins/dropzone/dropzone.css')
->addCss('css/plugins/iCheck/custom.css')
->addCss('components/switchery/dist/switchery.min.css')
->addCss('components/bootstrap-tour/build/css/bootstrap-tour.min.css')
->addCss('components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css')
->addCss('components/toastr/toastr.min.css')
->addCss('https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css', false, false)
->addCss('https://cdn.datatables.net/responsive/2.2.1/css/responsive.bootstrap.min.css', false, false)
->addCss('js/plugins/jQuery-autoComplete-master/jquery.auto-complete.css')
->addCss('css/timeline.css')
->addCss('css/colindar.css')
->join(true)
->addFilter(new Cssmin());
$pathCssAsset = 'css/cache/' . $this->dispatcher->getControllerName() . '.css';
$this->assetsmanager
->collection('css')
->setTargetPath($pathCssAsset)
->setTargetUri($pathCssAsset);
Tag::setTitle(Marca::get()->getTitle());
Tag::setTitleSeparator(' | ');
$this->view->descriptionTag = $this->translation->_(Marca::get()->getDescriptive());
//añadimos el poder de la traducción!! yeahhh!!
$this->view->t = $this->translation;
$code = getLanguage();
$this->view->code = $code;
$this->view->formatDateWithTime = getFormatDateWithTime();
$this->view->formatDate = getFormatDate();
//esta options se sobrescribe en CommunityControllerBase
$this->view->option = [];
$this->view->options_admin = [];
$this->view->communitiesList = [];
$this->view->user = $this->getUser();
$this->user = $this->getUser();
$this->view->logo_marca = Marca::get()->getLogo();
$this->view->imagotipo_marca = Marca::get()->getImagotipo();
$this->view->logo = false;
$this->view->logoBase64 = Files::DEFAULT_BASE64;
$this->session->remove('url_redirect');
}
public
function beforeExecuteRoute(
Dispatcher $dispatcher
) {
//check consent cookie
// if (!isset($_COOKIE['consentCookie']) || $_COOKIE['consentCookie'] !== 'true'){
// return $this->response->redirect('/index/cookies');
// }
//comprobamos que el user está y sino a login
$userSession = $this->checkAndGetUser();
$this->checkUserForPrivatedController($userSession, $dispatcher);
}
protected
function checkUserForPrivatedController(
$user,
Dispatcher $dispatcher
) {
// Only check permissions on private controllers
if ($this->acl->isPrivate($dispatcher->getControllerName())) {
// Get the current identity
$identity = $this->auth->getIdentity();
if (!is_array($identity)) {
if (!$user) {
$this->flashSession->notice('Su sesión ha caducado, por políticas de seguridad pasado un tiempo de inactividad el sistema se desloguea automáticamente');
return $dispatcher->forward([
'controller' => 'session',
'action' => 'login'
]);
}
$user->setSession();
$profileName = $user->profile->name;
$this->checkUserPermissionFormACL($profileName);
return $dispatcher->forward([
'controller' => 'dashboard',
'action' => 'index'
]);
}
}
}
public
function getUser()
{
if ($this->user === null) {
$this->user = $this->auth->getUser();
}
return $this->user;
}
/**
* Función que de forma predefinida comprueba si el usuario existe, si no es asi lo manda a login.
*
* Para algunas secciones (invitaciones por ejemplo) necesitamos que tengan paso para poder aceptar y crear su
* usuario, asi que sobreescribimos esta funcion donde haga falta para que no haga nada.
*/
protected
function checkAndGetUser()
{
$user = $this->auth->getUser();
$this->checkStatusUsersAndRedirect($user);
return $user;
}
protected
function checkStatusUsersAndRedirect(
$user
) {
$controllerName = $this->dispatcher->getControllerName();
if ($this->acl->isPrivate($controllerName)) {
if (!$user) {
return $this->response->redirect('/session/login');
}
$this->checkUsersFlagsAndRedirect($user);
$this->checkUserMustChangePasswordAndRedirect($user);
}
}
private
function checkUsersFlagsAndRedirect(
Users $user
) {
try {
// Check if the user was flagged: banned or suspended
$this->auth->checkUserFlags($user);
} catch (Exception $e) {
$this->flashSession->error('<strong>ERROR LOGIN</strong><br><br> ' . $e->getMessage());
return $this->response->redirect('/session/login');
}
}
/**
* @deprecated
*/
private
function checkUserIsActiveAndRedirect(
Users $user
) {
$actionName = $this->dispatcher->getActionName();
$controllerName = $this->dispatcher->getControllerName();
if (!$user->isActive()
&& ($controllerName !== 'session' && $controllerName !== 'users') //avoid ciclyng
) {
$this->flashSession->error($this->translation->_('Aun no has validado tu email. <br><br> Si no lo tienes o no encuentras el email puede introducirlo en el formulario inferior y mandar una copia.'));
return $this->response->redirect('/session/activateAccount');
}
}
public
function checkUserMustChangePasswordAndRedirect(
Users $user
) {
$actionName = $this->dispatcher->getActionName();
$controllerName = $this->dispatcher->getControllerName();
if ($user->mustChangePassword === 'Y'
&& ($controllerName !== 'users' && $actionName !== 'changePassword') //avoid ciclyng
) {
$this->flashSession->error($this->translation->_('Es obligatorio que cambie su contraseña.'));
return $this->response->redirect('/users/changePassword');
}
}
/*
* Función para extraer el despacho en el que estamos, esto solo sirve para AAFF y proveedores
*/
public
function getCurrentBusiness()
{
$user = $this->getUser();
if (!$user || $user->isNormal()) {
return false;
}
return $user->mybusiness;
}
protected
function _redirectBack(
$redirect = null
) {
if ($redirect === null) {
$url_redirect = $this->session->get('url_redirect');
$this->session->remove('url_redirect');
if ($url_redirect !== null){
return $this->response->redirect($url_redirect);
}
return $this->response->redirect($this->request->getHTTPReferer());
}
$redirect = base64_decode($redirect);
return $this->response->redirect($redirect);
}
protected
function checkIsNotPost(
$destination
) {
if (!$this->request->isPost()) {
$this->dispatcher->forward([
'controller' => $destination,
'action' => 'index'
]);
return true;
}
return false;
}
// la anterior debe desaparecer
protected
function generateError_v2(
$message,
$action = 'index',
$controller = null
) {
$this->flashSession->error($this->translation->_($message));
if (!$action) {
return $this->_redirectBack();
}
return $this->dispatcher->forward([
'controller' => $controller ?: $this->dispatcher->getControllerName(),
'action' => $action
]);
}
protected
function generalDelete(
$object,
$messageOK,
$action = false,
$controller = null
) {
if (!$object) {
$this->generateError_v2('No se ha encontrado o no tiene permisos para eliminarlo.', $action, $controller);
return;
}
if (!$object->delete()) {
foreach ($object->getMessages() as $message) {
$this->flashSession->error($message);
}
} else {
$this->flashSession->success($this->translation->_($messageOK));
}
if (!$action) {
//si no especificamos nada volvemos para atras
return $this->_redirectBack();
}
//en otro caso vamos donde se especifique
return $this->dispatcher->forward([
'controller' => $controller ?: $this->dispatcher->getControllerName(),
'action' => $action
]);
}
protected
function generateErrorCommunity()
{
$this->generateError_v2(
$this->translation->_('Debido a un tiempo de inactividad y por motivos de seguridad se ha caducado su sessión. Le devolvemos a su página principal.'),
'index', 'dashboard');
}
protected
function saveObjectOrRedirect(
$object,
string $controllerDestination = '',
string $actionDestination = ''
) {
if ($controllerDestination === '') {
$controllerDestination = $this->dispatcher->getControllerName();
}
if ($actionDestination === '') {
$actionDestination = $this->dispatcher->getActionName();
}
if (!$object->save()) {
$this->getMessagesErrorInFlash($object);
$this->dispatcher->forward([
'controller' => $controllerDestination,
'action' => $actionDestination
]);
return false;
}
return true;
}
protected
function saveObjectOrException(
$object
) {
CodeHelpers::saveObjectOrException($object);
}
protected
function getMessagesErrorInFlash(
$object,
$persist = true
): void {
foreach ($object->getMessages() as $message) {
if ($persist) {
$this->flashSession->error($message);
} else {
$this->flash->error($message);
}
}
}
private
function checkUserPermissionFormACL(
string $profile
) {
// Check if the user have permission to the current option
$actionName = $this->dispatcher->getActionName();
$controllerName = $this->dispatcher->getControllerName();
if (!$this->acl->isAllowed($profile, $controllerName, $actionName)) {
$this->flash->notice($this->translation->_('No tienes acceso a esta acción: ') . ucfirst($controllerName) . ':' . $this->acl->getActionDescription($actionName));
return $this->dispatcher->forward([
'controller' => 'dashboard',
'action' => 'index',
]);
}
}
protected
function getCommunitiesForSelectInHeaders()
{
$user = $this->getUser();
if (!$user){
return [];
}
if (!$user->isNormal()) {
return $this->getCommunitiesForBusiness($user);
}
return $this->getCommunitiesForUserNormal($user);
}
protected
function getCommunitiesForUserNormal(
$user
) {
return [];
}
protected
function getCommunitiesForBusiness(
$user
) {
$communities = [];
if ($user->isAAFF() && !$user->isSuperAdmin()) {
$business = $user->mybusiness;
$communities = Community::find([
'adminFincas = ?0',
'bind' => [
$business->id
],
'order' => 'name'
]);
if ($this->isAAFFWithTotalPermissions($user)){
$this->view->communities = $communities;
} else {
//comprobamos que permisos puede ver
$permisos = $user->permisos;
if (!$permisos) {
$this->flashSession->notice($this->translation->_('No tiene ningún permiso dado. Contacte con el Administrador de su Despacho si cree que debería tener permisos.'));
return false;
}
foreach ($communities as $community) {
$hasPermission = false;
foreach ($permisos as $permiso) {
if ($permiso->isAllowedAaffIncommunity($community->id, $this->dispatcher)) {
$hasPermission = true;
}
}
if ($hasPermission){
$communitiesAllowed[$community->id] = $community;
}
}
$this->view->communities = $communitiesAllowed;
$communities = $communitiesAllowed;
}
} elseif ($user->isProvider()) {
$provider = Providers::findFirstById($user->id);
$communities = $provider->communities;
$this->view->communities = $communities;
$this->view->provider = $provider;
}
/**********************
* PARCHEEE!!!
*********************/
$num = 1;
foreach ($communities as $community) {
if ($community->id_own === null){
$community->id_own = $num;
$community->save();
}
$num++;
}
/**********************
* PARCHEEE!!!
*********************/
return $communities;
}
/**
* PAGINACIÓN
*/
public
function getNumberPage(): int
{
$numberPage = 1;
if (!$this->request->isPost() && $this->request->getQuery('page', 'int') !== null) {
$numberPage = $this->request->getQuery('page', 'int');
}
return $numberPage;
}
public
function getLimitPage(): int
{
$limit = self::LIMIT_PAGINATION;
if ($this->persistent->limit !== null){
$limit = $this->persistent->limit;
}
if ($this->request->isPost()
&& $this->request->getPost('limit', 'int') !== null
) {
$limit = $this->request->getPost('limit', 'int');
$this->persistent->limit = $this->request->getPost('limit', 'int');
}
//limit por view
$this->tag->setDefault('limit', $limit);
return $limit;
}
}
|
| #15 | Colindar\Controllers\ControllerBase->initialize() |
| #16 | Phalcon\Dispatcher->dispatch() |
| #17 | Phalcon\Mvc\Application->handle() /app/public/index.php (75) <?php
use Colindar\Auth\Exception as AuthException;
use Phalcon\Di;
use Phalcon\Mvc\Application;
try {
/**
* Define some useful constants
*/
define('BASE_DIR', dirname(__DIR__));
define('APP_DIR', BASE_DIR . '/app');
defined('PUBLIC_DIR') || define('PUBLIC_DIR', BASE_DIR . '/public');
// http://stackoverflow.com/questions/16383776/detect-in-app-browser-webview-with-php-javascript
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] === 'com.colindar.ionic' || $_SERVER['HTTP_X_REQUESTED_WITH'] === 'com.Reservar_Zona_Comun.reservarzonacomun')) {
define('MOBILE', 'TRUE');
} elseif (isset($_SERVER['HTTP_USER_AGENT'])
&& ((strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false)
&& (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') !== false))) {
define('MOBILE', 'TRUE');
} else {
define('MOBILE', 'FALSE');
}
define('HTTPS',
((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443)) ? "https" : "http");
define('DOMINIO', $_SERVER['HTTP_HOST'] ?? 'app.colindar.es');
define('IP', $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0');
if (strpos(DOMINIO, "colindar") !== false) {
define('MARCA', 'COLINDAR');
} elseif (strpos(DOMINIO, "graman") !== false) {
define('MARCA', 'GRAMAN');
} elseif (strpos(DOMINIO, "reservarzonacomun") !== false) {
define('MARCA', 'RZC');
} elseif (strpos(DOMINIO, "reserbando") !== false) {
define('MARCA', 'RESERBANDO');
} else {
define('MARCA', 'MICOMUNIWEB');
}
if (strpos(DOMINIO, "dev") !== false || strpos(DOMINIO, "localhost") !== false || getenv('DOCKER_ENV') === 'true') {
//estamos trabajando en desarrollo (TARA o Docker local)
define('DEBUG', true);
error_reporting(E_ALL);
ini_set("display_errors", "1");
} else {
//estamos en app.colindar.es o app.reservarzonacomun.com, osea en MAX
define('DEBUG', false);
}
/**
* Read the configuration
*/
$config = include APP_DIR . '/config/config.php';
/**
* Read auto-loader
*/
include APP_DIR . '/config/loader.php';
/**
* Read services
*/
include APP_DIR . '/config/services.php';
/**
* Handle the request
*/
$application = new Application($di);
echo $application->handle()->getContent();
} catch (AuthException $e) {
Di::getDefault()->getFlashSession()->error($e->getMessage());
header("Location: " . HTTPS . "://" . DOMINIO . "/406");
die();
} catch (Error $e) {
sendReportError($e);
triggerDebugPanel($e);
header("Location: " . HTTPS . "://" . DOMINIO . "/406");
die();
} catch (Exception $e) {
triggerDebugPanel($e);
if ((int)$e->getCode() === 2) {
Di::getDefault()
->getFlashSession()
->error(t("Enlace roto, el Equipo de Colindar ha recibido un aviso. Pronto lo solucionarán.<br> Se le redirige a la página principal. "));
header("Location: " . HTTPS . "://" . DOMINIO . "/");
}
sendReportError($e);
header("Location: " . HTTPS . "://" . DOMINIO . "/406");
die();
} |
| Key | Value |
|---|---|
| _url | /sitemap.xml |
| Key | Value |
|---|---|
| BEANSTALK_DISABLED | false |
| MAIL_USERNAME | AKIA3AUYQAJ7A6PHD67C |
| STRIPE_TEST_PUBLIC_KEY | pk_test_2OmMb8y89JIuZFtt17Mr2JIm |
| HOSTNAME | 64fcb79f2085 |
| DEBUG | false |
| MAIL_FROM_ADDRESS | webapp@colindar.com |
| DB_PORT | 3306 |
| PHP_INI_DIR | /usr/local/etc/php |
| CRYPT_SALT | eEAfR|_&G&f,+vU]+)0\!\!4Zziw |
| HOME | /var/www |
| DB_NAME | colindar |
| STRIPE_CONNECT_LIVE | ca_HYUi3IQLk1IDZd2orNuEMO6lOWToCmwx |
| AWS_BACKUP_BUCKET | s3://colindarbackup |
| MAIL_FROM_NAME | ColindarApp |
| STRIPE_TEST_SECRET_KEY | sk_test_UR2iOZiTI3hwxLzrex22yaji |
| PHP_LDFLAGS | -Wl,-O1 -pie |
| PHP_CFLAGS | -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 |
| PHP_VERSION | 7.3.33 |
| MEMCACHED_HOST | memcached |
| GPG_KEYS | CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D |
| PHP_CPPFLAGS | -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 |
| PHP_ASC_URL | https://www.php.net/distributions/php-7.3.33.tar.xz.asc |
| PHP_URL | https://www.php.net/distributions/php-7.3.33.tar.xz |
| PATH | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
| MEMCACHED_PORT | 11211 |
| MAIL_PASSWORD | BCnCn1SWP10Yfr4Hlzod041JmP6635BYjyLA3haRlDkq |
| STRIPE_CONNECT_TEST | ca_HYUi9ZvRbhcEZ1c8HtCqEFYPBI2P6MK1 |
| DOCKER_ENV | true |
| BEANSTALK_HOST | beanstalkd |
| RECAPTCHA_PUBLIC_KEY | 6LesWhETAAAAAMTVGNTPFbMxwwlb1KNLmL-zLfAf |
| MAIL_HOST | email-smtp.eu-central-1.amazonaws.com |
| STRIPE_LIVE_PUBLIC_KEY | pk_live_51BbSLGHVfExhUgldwSaCCscytIuCkqynMmfap3EtHGr3j7ZEQ69PjaE7TPW9G2FwDRa3TJ3mIzYGcy0abH60Jmbb000N6TuiIr |
| JWT_SECRET | VzMNhRNXw7Aq05WHvJmdU+b9xcE0HqXG/7PN6Gf3CF4= |
| AWS_ACCESS_KEY_ID | AKIA3AUYQAJ7MNJL2MGN |
| AWS_SECRET_ACCESS_KEY | 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 |
| MAIL_PORT | 587 |
| RECAPTCHA_SECRET_KEY | 6LesWhETAAAAADGmI44WUfOB3wEhraE5qS1Wu-Ex |
| DB_PASSWORD | fca5285262092659b7fc81e22f39656d |
| STRIPE_LIVE_SECRET_KEY | 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 |
| APP_ENV | production |
| PHPIZE_DEPS | autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c |
| PWD | /app |
| PHP_SHA256 | 166eaccde933381da9516a2b70ad0f447d7cec4b603d07b9a916032b215b90cc |
| DB_HOST | mysql |
| DB_USER | colindar |
| USER | www-data |
| HTTP_X_REAL_IP | 216.73.216.152 |
| HTTP_X_FORWARDED_SERVER | ba2893d54494 |
| HTTP_X_FORWARDED_PROTO | https |
| HTTP_X_FORWARDED_PORT | 443 |
| HTTP_X_FORWARDED_HOST | new.colindar.es |
| HTTP_X_FORWARDED_FOR | 216.73.216.152 |
| HTTP_ACCEPT_ENCODING | gzip, br, zstd, deflate |
| HTTP_ACCEPT | */* |
| HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) |
| HTTP_HOST | new.colindar.es |
| SCRIPT_FILENAME | /app/public/index.php |
| PATH_TRANSLATED | /app/public |
| PATH_INFO | |
| REDIRECT_STATUS | 200 |
| SERVER_NAME | _ |
| SERVER_PORT | 80 |
| SERVER_ADDR | 172.19.0.4 |
| REMOTE_PORT | 35828 |
| REMOTE_ADDR | 172.19.0.2 |
| SERVER_SOFTWARE | nginx/1.24.0 |
| GATEWAY_INTERFACE | CGI/1.1 |
| REQUEST_SCHEME | http |
| SERVER_PROTOCOL | HTTP/1.1 |
| DOCUMENT_ROOT | /app/public |
| DOCUMENT_URI | /index.php |
| REQUEST_URI | /sitemap.xml |
| SCRIPT_NAME | /index.php |
| CONTENT_LENGTH | |
| CONTENT_TYPE | |
| REQUEST_METHOD | GET |
| QUERY_STRING | _url=/sitemap.xml& |
| FCGI_ROLE | RESPONDER |
| PHP_SELF | /index.php |
| REQUEST_TIME_FLOAT | 1772779868.7914 |
| REQUEST_TIME | 1772779868 |
| argv | Array([0] => _url=/sitemap.xml&) |
| argc | 1 |
| # | Path |
|---|---|
| 0 | /app/public/index.php |
| 1 | /app/app/config/config.php |
| 2 | /app/app/config/loader.php |
| 3 | /app/vendor/autoload.php |
| 4 | /app/vendor/composer/autoload_real.php |
| 5 | /app/vendor/composer/platform_check.php |
| 6 | /app/vendor/composer/ClassLoader.php |
| 7 | /app/vendor/composer/autoload_static.php |
| 8 | /app/vendor/symfony/polyfill-mbstring/bootstrap.php |
| 9 | /app/vendor/symfony/deprecation-contracts/function.php |
| 10 | /app/vendor/symfony/polyfill-intl-normalizer/bootstrap.php |
| 11 | /app/vendor/symfony/polyfill-php72/bootstrap.php |
| 12 | /app/vendor/symfony/polyfill-php80/bootstrap.php |
| 13 | /app/vendor/ralouphie/getallheaders/src/getallheaders.php |
| 14 | /app/vendor/symfony/polyfill-intl-idn/bootstrap.php |
| 15 | /app/vendor/guzzlehttp/promises/src/functions_include.php |
| 16 | /app/vendor/guzzlehttp/promises/src/functions.php |
| 17 | /app/vendor/symfony/polyfill-php81/bootstrap.php |
| 18 | /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php |
| 19 | /app/vendor/guzzlehttp/guzzle/src/functions_include.php |
| 20 | /app/vendor/guzzlehttp/guzzle/src/functions.php |
| 21 | /app/vendor/symfony/polyfill-ctype/bootstrap.php |
| 22 | /app/vendor/symfony/polyfill-iconv/bootstrap.php |
| 23 | /app/vendor/symfony/translation/Resources/functions.php |
| 24 | /app/vendor/globalcitizen/php-iban/oophp-iban.php |
| 25 | /app/vendor/globalcitizen/php-iban/php-iban.php |
| 26 | /app/vendor/ramsey/uuid/src/functions.php |
| 27 | /app/vendor/swiftmailer/swiftmailer/lib/swift_required.php |
| 28 | /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php |
| 29 | /app/app/library/functions.php |
| 30 | /app/app/config/services.php |
| 31 | /app/app/config/routes.php |
| 32 | /app/app/controllers/IndexController.php |
| 33 | /app/app/controllers/ControllerBase.php |
| 34 | /app/app/library/Assets/AssetsManager.php |
| 35 | /app/app/library/Marcas/Marca.php |
| 36 | /app/app/library/Marcas/Base.php |
| 37 | /app/app/library/Translate/Translate.php |
| 38 | /app/app/lang/en/en.php |
| 39 | /app/app/models/Translations.php |
| Memory | |
|---|---|
| Usage | 2097152 |