Merge branch 'feature/b2060-migrate-silex-to-symfony' into develop
# Conflicts: # core/dbsearch.class.php # datamodels/2.x/itop-portal-base/module.itop-portal-base.php # datamodels/2.x/itop-portal-base/portal/src/controllers/userprofilebrickcontroller.class.inc.php # datamodels/2.x/itop-portal-base/portal/src/helpers/applicationhelper.class.inc.php # datamodels/2.x/itop-portal/module.itop-portal.php
@@ -1,51 +1,40 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2017 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
// iTop is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// iTop is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Executes a portal without having a dedicated module.
|
||||
* This allows to make a portal directly from the ITSM Designer.
|
||||
*/
|
||||
|
||||
if (file_exists(__DIR__ . '/../../approot.inc.php'))
|
||||
// Load current environment
|
||||
if (file_exists(__DIR__.'/../../approot.inc.php'))
|
||||
{
|
||||
require_once __DIR__ . '/../../approot.inc.php'; // When in env-xxxx folder
|
||||
require_once __DIR__.'/../../approot.inc.php'; // When in env-xxxx folder
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once __DIR__ . '/../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
require_once __DIR__.'/../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
}
|
||||
require_once APPROOT . '/application/startup.inc.php';
|
||||
require_once APPROOT.'application/startup.inc.php';
|
||||
|
||||
// If PORTAL_ID is not already defined, we look for it in a parameter
|
||||
if(!defined('PORTAL_ID'))
|
||||
{
|
||||
// Retrieving portal id from request params
|
||||
$sPortalId = utils::ReadParam('portal_id', '');
|
||||
if ($sPortalId == '')
|
||||
{
|
||||
echo "Missing argument 'portal_id'";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Defining portal constants
|
||||
define('PORTAL_MODULE_ID', $sPortalId);
|
||||
define('PORTAL_ID', $sPortalId);
|
||||
}
|
||||
|
||||
require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/web/index.php';
|
||||
// Load frontal
|
||||
require_once MODULESROOT.'itop-portal-base/portal/public/index.php';
|
||||
|
||||
24
datamodels/2.x/itop-portal-base/model.itop-portal-base.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// This file may be amended with XML snippets
|
||||
|
||||
@@ -2,37 +2,37 @@
|
||||
|
||||
SetupWebPage::AddModule(
|
||||
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
|
||||
'itop-portal-base/2.6.2',
|
||||
array(
|
||||
// Identification
|
||||
'label' => 'Portal Development Library',
|
||||
'itop-portal-base/2.7.0', array(
|
||||
// Identification
|
||||
'label' => 'Portal Development Library',
|
||||
'category' => 'Portal',
|
||||
// Setup
|
||||
'dependencies' => array(),
|
||||
'mandatory' => false,
|
||||
'visible' => true,
|
||||
// Components
|
||||
'datamodel' => array(
|
||||
'portal/src/controllers/abstractcontroller.class.inc.php',
|
||||
'portal/src/controllers/brickcontroller.class.inc.php',
|
||||
'portal/src/entities/abstractbrick.class.inc.php',
|
||||
'portal/src/entities/portalbrick.class.inc.php',
|
||||
'portal/src/routers/abstractrouter.class.inc.php',
|
||||
),
|
||||
'webservice' => array(//'webservices.itop-portal-base.php',
|
||||
),
|
||||
'dictionary' => array(
|
||||
'fr.dict.itop-portal-base.php',
|
||||
//'de.dict.itop-portal-base.php',
|
||||
),
|
||||
'data.struct' => array(//'data.struct.itop-portal-base.xml',
|
||||
),
|
||||
'data.sample' => array(//'data.sample.itop-portal-base.xml',
|
||||
),
|
||||
// Documentation
|
||||
'doc.manual_setup' => '',
|
||||
'doc.more_information' => '',
|
||||
// Default settings
|
||||
'settings' => array(),
|
||||
// Setup
|
||||
'dependencies' => array(
|
||||
),
|
||||
'mandatory' => false,
|
||||
'visible' => true,
|
||||
// Components
|
||||
'datamodel' => array(
|
||||
'model.itop-portal-base.php',
|
||||
),
|
||||
'webservice' => array(
|
||||
//'webservices.itop-portal-base.php',
|
||||
),
|
||||
'dictionary' => array(
|
||||
'fr.dict.itop-portal-base.php',
|
||||
//'de.dict.itop-portal-base.php',
|
||||
),
|
||||
'data.struct' => array(
|
||||
//'data.struct.itop-portal-base.xml',
|
||||
),
|
||||
'data.sample' => array(
|
||||
//'data.sample.itop-portal-base.xml',
|
||||
),
|
||||
// Documentation
|
||||
'doc.manual_setup' => '',
|
||||
'doc.more_information' => '',
|
||||
// Default settings
|
||||
'settings' => array(
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
21
datamodels/2.x/itop-portal-base/portal/.env
Normal file
@@ -0,0 +1,21 @@
|
||||
# In all environments, the following files are loaded if they exist,
|
||||
# the later taking precedence over the former:
|
||||
#
|
||||
# * .env contains default values for the environment variables needed by the app
|
||||
# * .env.local uncommitted file with local overrides
|
||||
# * .env.$APP_ENV committed environment-specific defaults
|
||||
# * .env.$APP_ENV.local uncommitted environment-specific overrides
|
||||
#
|
||||
# Real environment variables win over .env files.
|
||||
#
|
||||
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
|
||||
#
|
||||
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
|
||||
|
||||
###> symfony/framework-bundle ###
|
||||
#APP_ENV=prod
|
||||
#APP_SECRET=40ef8b29be00df19cec62edf08f73808
|
||||
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
|
||||
#TRUSTED_HOSTS='^localhost|example\.com$'
|
||||
###< symfony/framework-bundle ###
|
||||
9
datamodels/2.x/itop-portal-base/portal/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
###> symfony/framework-bundle ###
|
||||
/.env.local
|
||||
/.env.local.php
|
||||
/.env.*.local
|
||||
/public/bundles/
|
||||
/var/
|
||||
/vendor/
|
||||
###< symfony/framework-bundle ###
|
||||
61
datamodels/2.x/itop-portal-base/portal/bin/console
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Combodo\iTop\Portal\Kernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true))
|
||||
{
|
||||
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
|
||||
}
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
if (!defined('APPROOT'))
|
||||
{
|
||||
if (file_exists(__DIR__.'/../../../../approot.inc.php'))
|
||||
{
|
||||
require_once __DIR__.'/../../../../approot.inc.php'; // When in env-xxxx folder
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once __DIR__.'/../../../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
}
|
||||
}
|
||||
require_once APPROOT.'lib/composer-vendor/autoload.php';
|
||||
|
||||
if (!class_exists(Application::class))
|
||||
{
|
||||
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
|
||||
}
|
||||
|
||||
// Remove --portal_id from CLI params to avoid SF CLI conflicts
|
||||
// Note: The parameter is needed when calling the bin/console to determine which portal to select
|
||||
$aCleanedArgv = $_SERVER['argv'];
|
||||
foreach ($aCleanedArgv as $iArg => $sArg)
|
||||
{
|
||||
if (preg_match('/^--portal_id=(.*)$/', $sArg, $aMatches))
|
||||
{
|
||||
unset($aCleanedArgv[$iArg]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$oInput = new ArgvInput($aCleanedArgv);
|
||||
if (null !== $sEnv = $oInput->getParameterOption(['--env', '-e'], null, true))
|
||||
{
|
||||
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $sEnv);
|
||||
}
|
||||
|
||||
if ($oInput->hasParameterOption('--no-debug', true))
|
||||
{
|
||||
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
|
||||
}
|
||||
|
||||
require_once MODULESROOT.'itop-portal-base/portal/config/bootstrap.php';
|
||||
|
||||
$oKernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
|
||||
$oApplication = new Application($oKernel);
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$oApplication->run($oInput);
|
||||
52
datamodels/2.x/itop-portal-base/portal/composer.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"type": "project",
|
||||
"license": "AGPLv3",
|
||||
"require": {
|
||||
"php": ">=5.6.0",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"symfony/console": "3.4.*",
|
||||
"symfony/dotenv": "3.4.*",
|
||||
"symfony/framework-bundle": "3.4.*",
|
||||
"symfony/twig-bundle": "3.4.*",
|
||||
"symfony/yaml": "3.4.*",
|
||||
"symfony/polyfill-php70": "1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/stopwatch": "3.4.*",
|
||||
"symfony/web-profiler-bundle": "3.4.*"
|
||||
},
|
||||
"config": {
|
||||
"vendor-dir": "../../../../lib/composer-vendor",
|
||||
"preferred-install": {
|
||||
"*": "dist"
|
||||
},
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "5.6.0"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Combodo\\iTop\\Portal\\": "src/"
|
||||
},
|
||||
"classmap": [
|
||||
"../../../../core",
|
||||
"../../../../application"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Combodo\\iTop\\Portal\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/symfony": "*"
|
||||
},
|
||||
"extra": {
|
||||
"symfony": {
|
||||
"allow-contrib": false,
|
||||
"require": "3.4.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
1912
datamodels/2.x/itop-portal-base/portal/composer.lock
generated
Normal file
157
datamodels/2.x/itop-portal-base/portal/config/bootstrap.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Disable PhpUnhandledExceptionInspection as the exception handling is made by the file including this one
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
require_once APPROOT.'/lib/composer-vendor/autoload.php';
|
||||
|
||||
// Load current environment if necessary
|
||||
if (!defined('MODULESROOT'))
|
||||
{
|
||||
if (file_exists(__DIR__.'/../../../../approot.inc.php'))
|
||||
{
|
||||
require_once __DIR__.'/../../../../approot.inc.php'; // When in env-xxxx folder
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once __DIR__.'/../../../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
}
|
||||
require_once APPROOT.'/application/startup.inc.php';
|
||||
}
|
||||
|
||||
// Load cached env vars if the .env.local.php file exists
|
||||
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
|
||||
if (is_array($sEnv = @include dirname(__DIR__).'/.env.local.php'))
|
||||
{
|
||||
$_ENV += $sEnv;
|
||||
}
|
||||
elseif (!class_exists(Dotenv::class))
|
||||
{
|
||||
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sPath = dirname(__DIR__).'/.env';
|
||||
$oDotenv = new Dotenv();
|
||||
|
||||
// load all the .env files
|
||||
if (method_exists($oDotenv, 'loadEnv'))
|
||||
{
|
||||
$oDotenv->loadEnv($sPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)
|
||||
|
||||
if (file_exists($sPath) || !file_exists($sPathDist = "$sPath.dist"))
|
||||
{
|
||||
$oDotenv->load($sPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
}
|
||||
|
||||
if (null === $sEnv = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)))
|
||||
{
|
||||
$oDotenv->populate(array('APP_ENV' => $sEnv = 'prod'));
|
||||
}
|
||||
|
||||
if ('test' !== $sEnv && file_exists($sPathDist = "$sPath.local"))
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
$sEnv = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : $sEnv);
|
||||
}
|
||||
|
||||
if (file_exists($sPathDist = "$sPath.$sEnv"))
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
}
|
||||
|
||||
if (file_exists($sPathDist = "$sPath.$sEnv.local"))
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set debug mode only when necessary
|
||||
if (utils::ReadParam('debug', 'false') === 'true')
|
||||
{
|
||||
$_SERVER['APP_DEBUG'] = true;
|
||||
}
|
||||
|
||||
$_SERVER += $_ENV;
|
||||
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) ?: 'prod';
|
||||
$_SERVER['APP_DEBUG'] = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : (isset($_ENV['APP_DEBUG']) ? $_ENV['APP_DEBUG'] : ('prod' !== $_SERVER['APP_ENV']));
|
||||
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int)$_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'],
|
||||
FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
|
||||
|
||||
if ($_SERVER['APP_DEBUG'])
|
||||
{
|
||||
umask(0000);
|
||||
|
||||
if (class_exists(Debug::class))
|
||||
{
|
||||
Debug::enable();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_ENV['PORTAL_ID']))
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
// Note: Default value is set to "false" to differentiate an empty value from a non given parameter
|
||||
elseif ($sPortalId = utils::ReadParam('portal_id', false, true))
|
||||
{
|
||||
|
||||
$_ENV['PORTAL_ID'] = $sPortalId;
|
||||
}
|
||||
elseif (defined('PORTAL_ID'))
|
||||
{
|
||||
$_ENV['PORTAL_ID'] = PORTAL_ID;
|
||||
@trigger_error(
|
||||
sprintf(
|
||||
'Usage of legacy "PORTAL_ID" constant ("%s") is deprecated. You should pass "portal_id" in the URL as GET parameter.',
|
||||
PORTAL_ID
|
||||
),
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($_ENV['PORTAL_ID']))
|
||||
{
|
||||
echo "Missing argument 'portal_id'";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Env. vars to be used in templates and others
|
||||
$_ENV['COMBODO_CURRENT_ENVIRONMENT'] = utils::GetCurrentEnvironment();
|
||||
$_ENV['COMBODO_ABSOLUTE_URL'] = utils::GetAbsoluteUrlAppRoot();
|
||||
$_ENV['COMBODO_MODULES_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot();
|
||||
$_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().'itop-portal-base/portal/public/';
|
||||
$_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'] = MODULESROOT.'/itop-portal-base/portal/public/';
|
||||
$_ENV['COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().$_ENV['PORTAL_ID'].'/';
|
||||
26
datamodels/2.x/itop-portal-base/portal/config/bundles.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true],
|
||||
];
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Disable PhpUnhandledExceptionInspection as the exception handling is made by the file including this one
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
// Loading file
|
||||
use Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration\Basic;
|
||||
use Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration\Forms;
|
||||
use Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration\Lists;
|
||||
|
||||
// Note: ModuleDesign service is not available yet as this script is processed before services generation,
|
||||
// that's why we have to instantiate it manually.
|
||||
$oModuleDesign = new ModuleDesign($_ENV['PORTAL_ID']);
|
||||
|
||||
// TODO: The following code needs to be refactored to more independent and atomic services.
|
||||
|
||||
// Load portal conf. such as properties, themes, templates, ...
|
||||
// Append into %combodo.portal.instance.conf%
|
||||
$oBasicCompat = new Basic($oModuleDesign);
|
||||
$oBasicCompat->Process($container);
|
||||
|
||||
// Load portal forms definition
|
||||
// Append into %combodo.portal.instance.conf%
|
||||
$oFormsCompat = new Forms($oModuleDesign);
|
||||
$oFormsCompat->Process($container);
|
||||
|
||||
// Load portal lists definition
|
||||
// Append into %combodo.portal.instance.conf%
|
||||
$oListsCompat = new Lists($oModuleDesign);
|
||||
$oListsCompat->Process($container);
|
||||
|
||||
// Generating CSS files
|
||||
$aImportPaths = array($_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/');
|
||||
$aPortalConf = $container->getParameter('combodo.portal.instance.conf');
|
||||
foreach ($aPortalConf['properties']['themes'] as $sKey => $value)
|
||||
{
|
||||
if (!is_array($value))
|
||||
{
|
||||
$aPortalConf['properties']['themes'][$sKey] = $_ENV['COMBODO_ABSOLUTE_URL'].utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$value,
|
||||
$aImportPaths);
|
||||
}
|
||||
else
|
||||
{
|
||||
$aValues = array();
|
||||
foreach ($value as $sSubValue)
|
||||
{
|
||||
$aValues[] = $_ENV['COMBODO_ABSOLUTE_URL'].utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$sSubValue,
|
||||
$aImportPaths);
|
||||
}
|
||||
$aPortalConf['properties']['themes'][$sKey] = $aValues;
|
||||
}
|
||||
}
|
||||
$container->setParameter('combodo.portal.instance.conf', $aPortalConf);
|
||||
|
||||
//TODO: The following needs to be refactored
|
||||
// Session messages
|
||||
$aAllMessages = array();
|
||||
if ((array_key_exists('obj_messages', $_SESSION)) && (!empty($_SESSION['obj_messages'])))
|
||||
{
|
||||
foreach ($_SESSION['obj_messages'] as $sMessageKey => $aMessageObjectData)
|
||||
{
|
||||
$aObjectMessages = array();
|
||||
$aRanks = array();
|
||||
foreach ($aMessageObjectData as $sMessageId => $aMessageData)
|
||||
{
|
||||
$sMsgClass = 'alert alert-';
|
||||
switch ($aMessageData['severity'])
|
||||
{
|
||||
case 'info':
|
||||
$sMsgClass .= 'info';
|
||||
break;
|
||||
case 'error':
|
||||
$sMsgClass .= 'danger';
|
||||
break;
|
||||
case 'ok':
|
||||
default:
|
||||
$sMsgClass .= 'success';
|
||||
break;
|
||||
}
|
||||
$aObjectMessages[] = array('cssClass' => $sMsgClass, 'message' => $aMessageData['message']);
|
||||
$aRanks[] = $aMessageData['rank'];
|
||||
}
|
||||
unset($_SESSION['obj_messages'][$sMessageKey]);
|
||||
array_multisort($aRanks, $aObjectMessages);
|
||||
foreach ($aObjectMessages as $aObjectMessage)
|
||||
{
|
||||
$aAllMessages[] = $aObjectMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
$container->setParameter('combodo.current_user.session_messages', $aAllMessages);
|
||||
@@ -0,0 +1,19 @@
|
||||
framework:
|
||||
cache:
|
||||
# Put the unique name of your app here: the prefix seed
|
||||
# is used to compute stable namespaces for cache keys.
|
||||
#prefix_seed: your_vendor_name/app_name
|
||||
|
||||
# The app cache caches to the filesystem by default.
|
||||
# Other options include:
|
||||
|
||||
# Redis
|
||||
#app: cache.adapter.redis
|
||||
#default_redis_provider: redis://localhost
|
||||
|
||||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||
#app: cache.adapter.apcu
|
||||
|
||||
# Namespaced pools use the above "app" backend by default
|
||||
#pools:
|
||||
#my.dedicated.cache: ~
|
||||
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
@@ -0,0 +1,6 @@
|
||||
web_profiler:
|
||||
toolbar: true
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { only_exceptions: false }
|
||||
@@ -0,0 +1,15 @@
|
||||
framework:
|
||||
secret: '%env(APP_SECRET)%'
|
||||
#default_locale: en
|
||||
#csrf_protection: true
|
||||
#http_method_override: true
|
||||
|
||||
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
||||
# Remove or comment this section to explicitly disable session support.
|
||||
session:
|
||||
handler_id: ~
|
||||
|
||||
#esi: true
|
||||
#fragments: true
|
||||
php_errors:
|
||||
log: true
|
||||
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: ~
|
||||
@@ -0,0 +1,4 @@
|
||||
framework:
|
||||
test: true
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
||||
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
@@ -0,0 +1,6 @@
|
||||
web_profiler:
|
||||
toolbar: false
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { collect: false }
|
||||
@@ -0,0 +1,4 @@
|
||||
twig:
|
||||
default_path: '%combodo.modules.absolute_path%'
|
||||
debug: '%kernel.debug%'
|
||||
strict_variables: '%kernel.debug%'
|
||||
43
datamodels/2.x/itop-portal-base/portal/config/routes.yaml
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
# This file is the entry point to configure your own HTTP routes.
|
||||
# Files in the routes/ subdirectory configure the routes for your dependencies.
|
||||
|
||||
defaults:
|
||||
resource: 'routes/default.yaml'
|
||||
|
||||
user_profile_brick:
|
||||
resource: 'routes/user_profile_brick.yaml'
|
||||
|
||||
object_brick:
|
||||
resource: 'routes/object_brick.yaml'
|
||||
|
||||
create_brick:
|
||||
resource: 'routes/create_brick.yaml'
|
||||
|
||||
browse_brick:
|
||||
resource: 'routes/browse_brick.yaml'
|
||||
|
||||
manage_brick:
|
||||
resource: 'routes/manage_brick.yaml'
|
||||
|
||||
aggregatepage_brick:
|
||||
resource: 'routes/aggregatepage_brick.yaml'
|
||||
|
||||
extensions_extra_routes:
|
||||
resource: 'routes/extensions_extra_routes.php'
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_aggregatepage_brick:
|
||||
path: /aggregate-page/{sBrickId}
|
||||
defaults:
|
||||
_controller: Combodo\iTop\Portal\Controller\AggregatePageBrickController::DisplayAction
|
||||
@@ -0,0 +1,52 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_browse_brick:
|
||||
path: '/browse/{sBrickId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\BrowseBrickController::DisplayAction'
|
||||
|
||||
|
||||
p_browse_brick_mode:
|
||||
path: '/browse/{sBrickId}/{sBrowseMode}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\BrowseBrickController::DisplayAction'
|
||||
|
||||
|
||||
p_browse_brick_mode_list:
|
||||
path: '/browse/{sBrickId}/list/page/{iPageNumber}/show/{iListLength}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\BrowseBrickController::DisplayAction'
|
||||
sBrowseMode: 'list'
|
||||
sDataLoading: 'lazy'
|
||||
iPageNumber: 1
|
||||
iListLength: 20
|
||||
requirements:
|
||||
sBrowseMode: 'list'
|
||||
iPageNumber: '\d+'
|
||||
iListLength: '\d+'
|
||||
|
||||
|
||||
p_browse_brick_mode_tree:
|
||||
path: '/browse/{sBrickId}/tree/expand/{sLevelAlias}/{sNodeId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\BrowseBrickController::DisplayAction'
|
||||
sBrowseMode: 'tree'
|
||||
sDataLoading: 'lazy'
|
||||
sNodeId: ~
|
||||
requirements:
|
||||
sBrowseMode: 'tree'
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_create_brick:
|
||||
path: '/create/{sBrickId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\CreateBrickController::DisplayAction'
|
||||
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_home:
|
||||
path: '/'
|
||||
controller: 'Combodo\iTop\Portal\Controller\DefaultController::HomeAction'
|
||||
|
||||
# Example route
|
||||
#p_example:
|
||||
# path: /url-pattern
|
||||
# controller: 'Combodo\iTop\Portal\Controller\DefaultController::ExampleAction'
|
||||
# _defaults:
|
||||
# _fragment: 'string-to-be-append-to-the-pattern-after-a-#'
|
||||
@@ -0,0 +1,3 @@
|
||||
_errors:
|
||||
resource: '@TwigBundle/Resources/config/routing/errors.xml'
|
||||
prefix: /_error
|
||||
@@ -0,0 +1,7 @@
|
||||
web_profiler_wdt:
|
||||
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
|
||||
prefix: /_wdt
|
||||
|
||||
web_profiler_profiler:
|
||||
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
|
||||
prefix: /_profiler
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Portal\Routing\ItopExtensionsExtraRoutes;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
$oRouteCollection = new RouteCollection();
|
||||
|
||||
$aRoutes = ItopExtensionsExtraRoutes::GetRoutes();
|
||||
foreach ($aRoutes as $aRoute)
|
||||
{
|
||||
$aRoute['values'] = (isset($aRoute['values'])) ? $aRoute['values'] : [];
|
||||
$aRoute['asserts'] = (isset($aRoute['asserts'])) ? $aRoute['asserts'] : [];
|
||||
|
||||
$oRouteCollection->add(
|
||||
$aRoute['bind'],
|
||||
new Route(
|
||||
$aRoute['pattern'],
|
||||
array_merge(
|
||||
['_controller' => $aRoute['callback']],
|
||||
$aRoute['values']
|
||||
),
|
||||
$aRoute['asserts']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $oRouteCollection;
|
||||
@@ -0,0 +1,48 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_manage_brick:
|
||||
path: '/manage/{sBrickId}/{sGroupingTab}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ManageBrickController::DisplayAction'
|
||||
sGroupingTab: ~
|
||||
|
||||
p_manage_brick_display_as:
|
||||
path: '/manage/{sBrickId}/display-as/{sDisplayMode}/{sGroupingTab}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ManageBrickController::DisplayAction'
|
||||
sGroupingTab: ~
|
||||
requirements:
|
||||
sDisplayMode: 'list|pie-chart|bar-chart'
|
||||
|
||||
p_manage_brick_lazy:
|
||||
path: '/manage/{sBrickId}/{sGroupingTab}/{sGroupingArea}/page/{iPageNumber}/show/{iListLength}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ManageBrickController::DisplayAction'
|
||||
sDataLoading: 'lazy'
|
||||
iPageNumber: 1
|
||||
iListLength: 20
|
||||
requirements:
|
||||
iPageNumber: '\d+'
|
||||
iListLength: '\d+'
|
||||
|
||||
p_manage_brick_excel_export_start:
|
||||
path: '/manage/export/excel/start/{sBrickId}/{sGroupingTab}/{sGroupingArea}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ManageBrickController::ExcelExportStartAction'
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_object_create:
|
||||
path: '/object/create/{sObjectClass}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::CreateAction'
|
||||
|
||||
p_object_create_from_factory:
|
||||
path: '/object/create-from-factory/{sObjectClass}/{sObjectId}/{sEncodedMethodName}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::CreateFromFactoryAction'
|
||||
|
||||
p_object_edit:
|
||||
path: '/object/edit/{sObjectClass}/{sObjectId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::EditAction'
|
||||
|
||||
p_object_view:
|
||||
path: '/object/view/{sObjectClass}/{sObjectId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::ViewAction'
|
||||
|
||||
p_object_apply_stimulus:
|
||||
path: '/object/apply-stimulus/{sStimulusCode}/{sObjectClass}/{sObjectId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::ApplyStimulusAction'
|
||||
|
||||
p_object_search_from_attribute:
|
||||
path: '/object/search/from-attribute/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::SearchFromAttributeAction'
|
||||
sHostObjectClass: ~
|
||||
sHostObjectId: ~
|
||||
|
||||
p_object_search_autocomplete:
|
||||
path: '/object/search/autocomplete/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::SearchAutocompleteAction'
|
||||
sHostObjectClass: ~
|
||||
sHostObjectId: ~
|
||||
|
||||
# This one has the same path pattern as p_object_search_from_attribute and p_object_search_autocomplete
|
||||
# It is used to render search URL dynamically without knowing the route name
|
||||
#
|
||||
# Warning: It has NO default controller!
|
||||
p_object_search_generic:
|
||||
path: '/object/search/{sMode}/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}'
|
||||
defaults:
|
||||
sMode: '-sMode-'
|
||||
sHostObjectClass: ~
|
||||
sHostObjectId: ~
|
||||
|
||||
p_object_get_informations_json:
|
||||
path: '/object/get-informations/json'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::GetInformationsAsJsonAction'
|
||||
|
||||
p_object_document_display:
|
||||
path: '/object/document/display/{sObjectClass}/{sObjectId}/{sObjectField}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::DocumentAction'
|
||||
sOperation: 'display'
|
||||
|
||||
p_object_document_download:
|
||||
path: '/object/document/download/{sObjectClass}/{sObjectId}/{sObjectField}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::DocumentAction'
|
||||
sOperation: 'download'
|
||||
|
||||
p_object_attachment_add:
|
||||
path: '/object/attachment/add'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::AttachmentAction'
|
||||
|
||||
p_object_attachment_download:
|
||||
path: '/object/attachment/download/{sAttachmentId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\ObjectController::AttachmentAction'
|
||||
sOperation: 'download'
|
||||
@@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
p_user_profile_brick:
|
||||
path: '/user/{sBrickId}'
|
||||
defaults:
|
||||
_controller: 'Combodo\iTop\Portal\Controller\UserProfileBrickController::DisplayAction'
|
||||
sBrickId: ~
|
||||
133
datamodels/2.x/itop-portal-base/portal/config/services.yaml
Normal file
@@ -0,0 +1,133 @@
|
||||
# Copyright (C) 2010-2018 Combodo SARL
|
||||
#
|
||||
# This file is part of iTop.
|
||||
#
|
||||
# iTop is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# iTop is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
# This file is the entry point to configure your own services.
|
||||
# Files in the packages/ subdirectory configure your dependencies.
|
||||
|
||||
imports:
|
||||
- { resource: "legacy_silex_compat_layer.php" }
|
||||
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||
parameters:
|
||||
# Replace default url generator service
|
||||
router.options.generator_base_class: Combodo\iTop\Portal\Routing\UrlGenerator
|
||||
|
||||
# Used in templates
|
||||
combodo.current_environment: '%env(string:COMBODO_CURRENT_ENVIRONMENT)%'
|
||||
combodo.absolute_url: '%env(string:COMBODO_ABSOLUTE_URL)%'
|
||||
combodo.modules.absolute_url: '%env(string:COMBODO_MODULES_ABSOLUTE_URL)%'
|
||||
combodo.modules.absolute_path: !php/const MODULESROOT
|
||||
combodo.portal.base.absolute_url: '%env(string:COMBODO_PORTAL_BASE_ABSOLUTE_URL)%'
|
||||
combodo.portal.base.absolute_path: '%env(string:COMBODO_PORTAL_BASE_ABSOLUTE_PATH)%'
|
||||
combodo.portal.instance.absolute_url: '%env(string:COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL)%'
|
||||
combodo.portal.instance.id: '%env(string:PORTAL_ID)%'
|
||||
|
||||
services:
|
||||
# Default configuration for services in *this* file
|
||||
_defaults:
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
public: false # Allows optimizing the container by removing unused services; this also means
|
||||
# fetching services directly from the container via $container->get() won't work.
|
||||
# The best practice is to be explicit about your dependencies anyway.
|
||||
bind:
|
||||
$bDebug: '%kernel.debug%'
|
||||
$sPortalCachePath: '%kernel.cache_dir%/'
|
||||
$sPortalId: '%env(string:PORTAL_ID)%'
|
||||
$aCombodoPortalInstanceConf: '%combodo.portal.instance.conf%'
|
||||
$sCombodoPortalInstanceAbsoluteUrl: '%env(string:COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL)%'
|
||||
|
||||
# Makes classes in src/ available to be used as services
|
||||
# This creates a service per class whose id is the fully-qualified class name
|
||||
Combodo\iTop\Portal\:
|
||||
resource: '../src/*'
|
||||
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
|
||||
|
||||
# Controllers are imported separately to make sure services can be injected
|
||||
# as action arguments even if you don't extend any base controller class
|
||||
Combodo\iTop\Portal\Controller\:
|
||||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
# Tag services without defining them (see https://symfony.com/doc/current/service_container/tags.html#autoconfiguring-tags)
|
||||
_instanceof:
|
||||
Combodo\iTop\Portal\EventListener\UserProvider:
|
||||
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
|
||||
calls:
|
||||
- [setContainer, ['@service_container']]
|
||||
Combodo\iTop\Portal\EventListener\ApplicationContextSetUrlMakerClass:
|
||||
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
|
||||
|
||||
# Add more service definitions when explicit configuration is needed
|
||||
# Please note that last definitions always *replace* previous ones
|
||||
|
||||
# Legacy code as a service: since it is not in the auto-wiring path, it needs to be explicitly declared
|
||||
ModuleDesign:
|
||||
public: true
|
||||
class: ModuleDesign
|
||||
arguments:
|
||||
- '%combodo.portal.instance.id%'
|
||||
|
||||
# Decoration
|
||||
# - Compatibility layer with Silex\Application which was used almost everywhere in the portal's templates
|
||||
Combodo\iTop\Portal\Twig\AppVariable:
|
||||
decorates: twig.app_variable
|
||||
arguments:
|
||||
- '@Combodo\iTop\Portal\Twig\AppVariable.inner'
|
||||
- '@service_container'
|
||||
|
||||
# Standard services
|
||||
combodo.current_contact.photo_url:
|
||||
public: true
|
||||
class: Combodo\iTop\Portal\VariableAccessor\CombodoCurrentContactPhotoUrl
|
||||
arguments: ['@combodo.current_user']
|
||||
# Note: This service is initialized with a UserLocal object as it needs a class that can be instantiated.
|
||||
# Anyway, it will be replaced with the real class by UserProvider in onKernelRequestEvent.
|
||||
# Note: Services relying on this one should use \User in their signature and not \UserLocal.
|
||||
combodo.current_user:
|
||||
public: true
|
||||
class: UserLocal
|
||||
|
||||
# Aliases
|
||||
brick_collection:
|
||||
alias: Combodo\iTop\Portal\Brick\BrickCollection
|
||||
public: true
|
||||
request_manipulator:
|
||||
alias: Combodo\iTop\Portal\Helper\RequestManipulatorHelper
|
||||
public: true
|
||||
scope_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\ScopeValidatorHelper
|
||||
public: true
|
||||
security_helper:
|
||||
alias: Combodo\iTop\Portal\Helper\SecurityHelper
|
||||
public: true
|
||||
context_manipulator:
|
||||
alias: Combodo\iTop\Portal\Helper\ContextManipulatorHelper
|
||||
public: true
|
||||
lifecycle_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\LifecycleValidatorHelper
|
||||
public: true
|
||||
url_generator:
|
||||
alias: router
|
||||
public: true
|
||||
object_form_handler:
|
||||
alias: Combodo\iTop\Portal\Helper\ObjectFormHandlerHelper
|
||||
public: true
|
||||
browse_brick:
|
||||
alias: Combodo\iTop\Portal\Helper\BrowseBrickHelper
|
||||
public: true
|
||||
@@ -123,6 +123,9 @@ footer {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
#sidebar .menu .navbar-nav {
|
||||
width: 100%;
|
||||
}
|
||||
#sidebar .menu .navbar-nav > li {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -128,6 +128,9 @@ footer{
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
#sidebar .menu .navbar-nav{
|
||||
width: 100%;
|
||||
}
|
||||
#sidebar .menu .navbar-nav > li{
|
||||
width: 100%;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 780 B After Width: | Height: | Size: 780 B |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
44
datamodels/2.x/itop-portal-base/portal/public/index.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Portal\Kernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
require_once MODULESROOT.'itop-portal-base/portal/config/bootstrap.php';
|
||||
|
||||
// Note: Manually refactored ternary condition to be PHP 5.x compatible
|
||||
if ($trustedProxies = isset($_SERVER['TRUSTED_PROXIES']) ? $_SERVER['TRUSTED_PROXIES'] : (isset($_ENV['TRUSTED_PROXIES']) ? $_ENV['TRUSTED_PROXIES'] : false))
|
||||
{
|
||||
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
|
||||
}
|
||||
|
||||
// Note: Manually refactored ternary condition to be PHP 5.x compatible
|
||||
if ($trustedHosts = isset($_SERVER['TRUSTED_HOSTS']) ? $_SERVER['TRUSTED_HOSTS'] : (isset($_ENV['TRUSTED_HOSTS']) ? $_ENV['TRUSTED_HOSTS'] : false))
|
||||
{
|
||||
Request::setTrustedHosts([$trustedHosts]);
|
||||
}
|
||||
|
||||
$oKernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
|
||||
$oRequest = Request::createFromGlobals();
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$oResponse = $oKernel->handle($oRequest);
|
||||
$oResponse->send();
|
||||
$oKernel->terminate($oRequest, $oResponse);
|
||||
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 160 B |
|
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 201 B |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 146 B |
@@ -1,26 +1,29 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2018 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
// iTop is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// iTop is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Portal\Brick;
|
||||
|
||||
require_once APPROOT . '/core/moduledesign.class.inc.php';
|
||||
require_once APPROOT . '/setup/compiler.class.inc.php';
|
||||
require_once APPROOT.'/core/moduledesign.class.inc.php';
|
||||
require_once APPROOT.'/setup/compiler.class.inc.php';
|
||||
|
||||
use DOMFormatException;
|
||||
use ModuleDesign;
|
||||
@@ -28,40 +31,68 @@ use Combodo\iTop\DesignElement;
|
||||
|
||||
/**
|
||||
* Description of AbstractBrick
|
||||
*
|
||||
* Bricks are used mostly in the portal for now, not the console.
|
||||
* This class defines common functionnalities for the extended classes.
|
||||
*
|
||||
* Bricks are used mostly in the portal for now, not the console.
|
||||
* This class defines common functionalities for the extended classes.
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
* @since 2.3.0
|
||||
*/
|
||||
abstract class AbstractBrick
|
||||
{
|
||||
/** @var string ENUM_DATA_LOADING_LAZY */
|
||||
const ENUM_DATA_LOADING_LAZY = 'lazy';
|
||||
/** @var string ENUM_DATA_LOADING_FULL */
|
||||
const ENUM_DATA_LOADING_FULL = 'full';
|
||||
/** @var string ENUM_DATA_LOADING_AUTO */
|
||||
const ENUM_DATA_LOADING_AUTO = 'auto';
|
||||
|
||||
/** @var bool DEFAULT_MANDATORY */
|
||||
const DEFAULT_MANDATORY = true;
|
||||
/** @var bool DEFAULT_ACTIVE */
|
||||
const DEFAULT_ACTIVE = true;
|
||||
/** @var bool DEFAULT_VISIBLE */
|
||||
const DEFAULT_VISIBLE = true;
|
||||
/** @var float DEFAULT_RANK */
|
||||
const DEFAULT_RANK = 1.0;
|
||||
/** @var string|null DEFAULT_PAGE_TEMPLATE_PATH */
|
||||
const DEFAULT_PAGE_TEMPLATE_PATH = null;
|
||||
/** @var string DEFAULT_TITLE */
|
||||
const DEFAULT_TITLE = '';
|
||||
/** @var string|null DEFAULT_DESCRIPTION */
|
||||
const DEFAULT_DESCRIPTION = null;
|
||||
/** @var string DEFAULT_DATA_LOADING */
|
||||
const DEFAULT_DATA_LOADING = self::ENUM_DATA_LOADING_AUTO;
|
||||
/** @var string DEFAULT_ALLOWED_PROFILES_OQL */
|
||||
const DEFAULT_ALLOWED_PROFILES_OQL = '';
|
||||
/** @var string DEFAULT_DENIED_PROFILES_OQL */
|
||||
const DEFAULT_DENIED_PROFILES_OQL = '';
|
||||
|
||||
/** @var string $sId */
|
||||
protected $sId;
|
||||
/** @var bool $bMandatory */
|
||||
protected $bMandatory;
|
||||
/** @var bool $bActive */
|
||||
protected $bActive;
|
||||
/** @var bool $bVisible */
|
||||
protected $bVisible;
|
||||
/** @var float $fRank */
|
||||
protected $fRank;
|
||||
/** @var string|null $sPageTemplatePath */
|
||||
protected $sPageTemplatePath;
|
||||
/** @var string $sTitle */
|
||||
protected $sTitle;
|
||||
/** @var string|null $sDescription */
|
||||
protected $sDescription;
|
||||
/** @var string $sDataLoading */
|
||||
protected $sDataLoading;
|
||||
/** @var array $aAllowedProfiles */
|
||||
protected $aAllowedProfiles;
|
||||
/** @var array $aDeniedProfiles */
|
||||
protected $aDeniedProfiles;
|
||||
/** @var string $sAllowedProfilesOql */
|
||||
protected $sAllowedProfilesOql;
|
||||
/** @var string $sDeniedProfilesOql */
|
||||
protected $sDeniedProfilesOql;
|
||||
|
||||
/**
|
||||
@@ -77,7 +108,7 @@ abstract class AbstractBrick
|
||||
/**
|
||||
* Default attributes values of AbstractBrick are specified in the definition, not the constructor.
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$this->bMandatory = static::DEFAULT_MANDATORY;
|
||||
$this->bActive = static::DEFAULT_ACTIVE;
|
||||
@@ -253,8 +284,8 @@ abstract class AbstractBrick
|
||||
* Sets if the brick is visible
|
||||
*
|
||||
* @param boolean $bVisible
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function SetVisible($bVisible)
|
||||
{
|
||||
@@ -344,12 +375,13 @@ abstract class AbstractBrick
|
||||
* Sets the allowed profiles for the brick
|
||||
*
|
||||
* @param array $aAllowedProfiles
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function SetAllowedProfiles($aAllowedProfiles)
|
||||
{
|
||||
$this->aAllowedProfiles = $aAllowedProfiles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -357,8 +389,8 @@ abstract class AbstractBrick
|
||||
* Sets the denied profiles for the brick
|
||||
*
|
||||
* @param array $aDeniedProfiles
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function SetDeniedProfiles($aDeniedProfiles)
|
||||
{
|
||||
@@ -382,7 +414,7 @@ abstract class AbstractBrick
|
||||
/**
|
||||
* Sets the denied profiles oql query for the brick
|
||||
*
|
||||
* @param array $sDeniedProfilesOql
|
||||
* @param string $sDeniedProfilesOql
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
@@ -396,12 +428,13 @@ abstract class AbstractBrick
|
||||
* Adds $sProfile to the list of allowed profiles for that brick
|
||||
*
|
||||
* @param string $sProfile
|
||||
*
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function AddAllowedProfile($sProfile)
|
||||
{
|
||||
$this->aAllowedProfiles[] = $sProfile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -409,7 +442,7 @@ abstract class AbstractBrick
|
||||
* Removes $sProfile from the list of allowed profiles
|
||||
*
|
||||
* @param string $sProfile
|
||||
*
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function RemoveAllowedProfile($sProfile)
|
||||
@@ -418,6 +451,7 @@ abstract class AbstractBrick
|
||||
{
|
||||
unset($this->aAllowedProfiles[$sProfile]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -435,12 +469,13 @@ abstract class AbstractBrick
|
||||
* Adds $sProfile to the list of denied profiles for that brick
|
||||
*
|
||||
* @param string $sProfile
|
||||
*
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function AddDeniedProfile($sProfile)
|
||||
{
|
||||
$this->aDeniedProfiles[] = $sProfile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -448,7 +483,7 @@ abstract class AbstractBrick
|
||||
* Removes $sProfile from the list of denied profiles
|
||||
*
|
||||
* @param string $sProfile
|
||||
*
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*/
|
||||
public function RemoveDeniedProfile($sProfile)
|
||||
@@ -457,6 +492,7 @@ abstract class AbstractBrick
|
||||
{
|
||||
unset($this->aDeniedProfiles[$sProfile]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -477,7 +513,7 @@ abstract class AbstractBrick
|
||||
* Priority is deny/allow
|
||||
*
|
||||
* @param string $sProfile
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function IsGrantedForProfile($sProfile)
|
||||
@@ -492,7 +528,7 @@ abstract class AbstractBrick
|
||||
* Priority is deny/allow
|
||||
*
|
||||
* @param array $aProfiles
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function IsGrantedForProfiles($aProfiles)
|
||||
@@ -543,9 +579,9 @@ abstract class AbstractBrick
|
||||
* This is used to set all the brick attributes at once.
|
||||
*
|
||||
* @param \Combodo\iTop\DesignElement $oMDElement
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AbstractBrick
|
||||
*
|
||||
* @throws \DOMFormatException
|
||||
*/
|
||||
public function LoadFromXml(DesignElement $oMDElement)
|
||||
@@ -558,28 +594,31 @@ abstract class AbstractBrick
|
||||
$this->SetId($oMDElement->getAttribute('id'));
|
||||
|
||||
// Checking others elements
|
||||
/** @var \Combodo\iTop\DesignElement $oBrickSubNode */
|
||||
foreach ($oMDElement->GetNodes('./*') as $oBrickSubNode)
|
||||
{
|
||||
switch ($oBrickSubNode->nodeName)
|
||||
{
|
||||
case 'mandatory':
|
||||
$this->SetMandatory(($oBrickSubNode->GetText() === 'no') ? false : true );
|
||||
$this->SetMandatory(($oBrickSubNode->GetText() === 'no') ? false : true);
|
||||
break;
|
||||
case 'active':
|
||||
$this->SetActive(($oBrickSubNode->GetText() === 'false') ? false : true );
|
||||
$this->SetActive(($oBrickSubNode->GetText() === 'false') ? false : true);
|
||||
break;
|
||||
case 'rank':
|
||||
$oOptionalNode = $oBrickSubNode->GetOptionalElement('default');
|
||||
if ($oOptionalNode !== null)
|
||||
{
|
||||
$this->SetRank((float) $oOptionalNode->GetText(static::DEFAULT_RANK));
|
||||
$this->SetRank((float)$oOptionalNode->GetText(static::DEFAULT_RANK));
|
||||
}
|
||||
break;
|
||||
case 'templates':
|
||||
$oTemplateNodeList = $oBrickSubNode->GetNodes('template[@id=' . ModuleDesign::XPathQuote('page') . ']');
|
||||
$oTemplateNodeList = $oBrickSubNode->GetNodes('template[@id='.ModuleDesign::XPathQuote('page').']');
|
||||
if ($oTemplateNodeList->length > 0)
|
||||
{
|
||||
$this->SetPageTemplatePath($oTemplateNodeList->item(0)->GetText(static::DEFAULT_PAGE_TEMPLATE_PATH));
|
||||
/** @var \Combodo\iTop\DesignElement $oTemplateNode */
|
||||
$oTemplateNode = $oTemplateNodeList->item(0);
|
||||
$this->SetPageTemplatePath($oTemplateNode->GetText(static::DEFAULT_PAGE_TEMPLATE_PATH));
|
||||
}
|
||||
break;
|
||||
case 'title':
|
||||
@@ -596,11 +635,13 @@ abstract class AbstractBrick
|
||||
$this->SetDataLoading($oBrickSubNode->GetText(static::DEFAULT_DATA_LOADING));
|
||||
break;
|
||||
case 'security':
|
||||
/** @var \Combodo\iTop\DesignElement $oSecurityNode */
|
||||
foreach ($oBrickSubNode->childNodes as $oSecurityNode)
|
||||
{
|
||||
if ($oSecurityNode->nodeType === XML_TEXT_NODE && $oSecurityNode->GetText() === '')
|
||||
{
|
||||
throw new DOMFormatException('Brick security node "' . $oSecurityNode->nodeName . '" must contain an OQL query, it cannot be empty', null, null, $oMDElement);
|
||||
throw new DOMFormatException('Brick security node "'.$oSecurityNode->nodeName.'" must contain an OQL query, it cannot be empty',
|
||||
null, null, $oMDElement);
|
||||
}
|
||||
|
||||
switch ($oSecurityNode->nodeName)
|
||||
@@ -1,35 +1,49 @@
|
||||
<?php
|
||||
|
||||
// Copyright (c) 2010-2018 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
// iTop is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// iTop is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
//
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Portal\Brick;
|
||||
|
||||
use Combodo\iTop\DesignElement;
|
||||
use Dict;
|
||||
use DOMFormatException;
|
||||
|
||||
/**
|
||||
* Class AggregatePageBrick
|
||||
*
|
||||
* @package Combodo\iTop\Portal\Brick
|
||||
* @since 2.5.0
|
||||
* @author Eric Espie <eric.espie@combodo.com>
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
* @author Pierre Goiffon <pierre.goiffon@combodo.com>
|
||||
*/
|
||||
class AggregatePageBrick extends PortalBrick
|
||||
{
|
||||
// Overloaded constants
|
||||
const DEFAULT_DECORATION_CLASS_HOME = 'fa fa-dashboard';
|
||||
const DEFAULT_DECORATION_CLASS_NAVIGATION_MENU = 'fa fa-dashboard fa-2x';
|
||||
const DEFAULT_PAGE_TEMPLATE_PATH = 'itop-portal-base/portal/src/views/bricks/aggregate-page/layout.html.twig';
|
||||
const DEFAULT_PAGE_TEMPLATE_PATH = 'itop-portal-base/portal/templates/bricks/aggregate-page/layout.html.twig';
|
||||
|
||||
static $sRouteName = 'p_aggregatepage_brick';
|
||||
// Overloaded variables
|
||||
public static $sRouteName = 'p_aggregatepage_brick';
|
||||
|
||||
/**
|
||||
* @var string[] list of bricks to use, ordered by rank (key=id, value=rank)
|
||||
@@ -50,23 +64,25 @@ class AggregatePageBrick extends PortalBrick
|
||||
* @param \Combodo\iTop\DesignElement $oMDElement
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\AggregatePageBrick
|
||||
*
|
||||
*
|
||||
* @throws \DOMFormatException
|
||||
*/
|
||||
public function LoadFromXml(DesignElement $oMDElement)
|
||||
{
|
||||
parent::LoadFromXml($oMDElement);
|
||||
|
||||
/** @var \Combodo\iTop\DesignElement $oBrickSubNode */
|
||||
foreach ($oMDElement->GetNodes('./*') as $oBrickSubNode)
|
||||
{
|
||||
switch ($oBrickSubNode->nodeName)
|
||||
{
|
||||
case 'aggregate_page_bricks':
|
||||
/** @var \Combodo\iTop\DesignElement $oAggregatePageBrickNode */
|
||||
foreach ($oBrickSubNode->GetNodes('./aggregate_page_brick') as $oAggregatePageBrickNode)
|
||||
{
|
||||
if (!$oAggregatePageBrickNode->hasAttribute('id'))
|
||||
{
|
||||
throw new \DOMFormatException('AggregatePageBrick : must have an id attribute', null,
|
||||
throw new DOMFormatException('AggregatePageBrick : must have an id attribute', null,
|
||||
null, $oAggregatePageBrickNode);
|
||||
}
|
||||
$sBrickName = $oAggregatePageBrickNode->getAttribute('id');
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Portal\Brick;
|
||||
|
||||
use DOMFormatException;
|
||||
use Exception;
|
||||
use UserRights;
|
||||
use ModuleDesign;
|
||||
use Combodo\iTop\Portal\Helper\ApplicationHelper;
|
||||
|
||||
/**
|
||||
* Class BrickCollection
|
||||
*
|
||||
* @package Combodo\iTop\Portal\Brick
|
||||
* @author Bruno Da Silva <bruno.dasilva@combodo.com>
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
* @since 2.7.0
|
||||
*/
|
||||
class BrickCollection
|
||||
{
|
||||
/** @var \ModuleDesign $oModuleDesign */
|
||||
private $oModuleDesign;
|
||||
/** @var array|null $aAllowedBricks Lazily computed */
|
||||
private $aAllowedBricks;
|
||||
/** @var int $iDisplayedInHome Lazily computed */
|
||||
private $iDisplayedInHome;
|
||||
/** @var int $iDisplayedInNavigationMenu Lazily computed */
|
||||
private $iDisplayedInNavigationMenu;
|
||||
/** @var array $aHomeOrdering */
|
||||
private $aHomeOrdering;
|
||||
/** @var array $aNavigationMenuOrdering */
|
||||
private $aNavigationMenuOrdering;
|
||||
|
||||
/**
|
||||
* BrickCollection constructor.
|
||||
*
|
||||
* @param \ModuleDesign $oModuleDesign
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(ModuleDesign $oModuleDesign)
|
||||
{
|
||||
$this->oModuleDesign = $oModuleDesign;
|
||||
$this->aAllowedBricks = null;
|
||||
$this->iDisplayedInHome = 0;
|
||||
$this->iDisplayedInNavigationMenu = 0;
|
||||
$this->aHomeOrdering = array();
|
||||
$this->aNavigationMenuOrdering = array();
|
||||
|
||||
$this->Load();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
* @param $arguments
|
||||
*
|
||||
* @return array|\Combodo\iTop\Portal\Brick\PortalBrick[]|null
|
||||
* @throws \Combodo\iTop\Portal\Brick\PropertyNotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
// Made for cleaner/easier access from twig (eg. app['brick_collection'].bricks)
|
||||
switch ($method)
|
||||
{
|
||||
case 'bricks':
|
||||
return $this->GetBricks();
|
||||
break;
|
||||
case 'home_ordering':
|
||||
return $this->GetHomeOrdering();
|
||||
break;
|
||||
case 'navigation_menu_ordering':
|
||||
return $this->GetNavigationMenuOrdering();
|
||||
break;
|
||||
default:
|
||||
throw new PropertyNotFoundException("The property '$method' do not exists in BricksCollection");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Combodo\iTop\Portal\Brick\PortalBrick[]|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetBricks()
|
||||
{
|
||||
return $this->aAllowedBricks;
|
||||
}
|
||||
|
||||
public function GetHomeOrdering()
|
||||
{
|
||||
return $this->aHomeOrdering;
|
||||
}
|
||||
|
||||
public function GetNavigationMenuOrdering()
|
||||
{
|
||||
return $this->aNavigationMenuOrdering;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Portal\Brick\PortalBrick
|
||||
* @throws \Combodo\iTop\Portal\Brick\BrickNotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetBrickById($sId)
|
||||
{
|
||||
foreach ($this->GetBricks() as $oBrick)
|
||||
{
|
||||
if ($oBrick->GetId() === $sId)
|
||||
{
|
||||
return $oBrick;
|
||||
}
|
||||
}
|
||||
|
||||
throw new BrickNotFoundException('Brick with id = "'.$sId.'" was not found among loaded bricks.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function Load()
|
||||
{
|
||||
$aRawBrickList = $this->GetRawBrickList();
|
||||
|
||||
foreach ($aRawBrickList as $oBrick)
|
||||
{
|
||||
ApplicationHelper::LoadBrickSecurity($oBrick);
|
||||
|
||||
if ($oBrick->GetActive() && $oBrick->IsGrantedForProfiles(UserRights::ListProfiles()))
|
||||
{
|
||||
$this->aAllowedBricks[] = $oBrick;
|
||||
if ($oBrick->GetVisibleHome())
|
||||
{
|
||||
$this->iDisplayedInHome++;
|
||||
}
|
||||
if ($oBrick->GetVisibleNavigationMenu())
|
||||
{
|
||||
$this->iDisplayedInNavigationMenu++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - Sorting bricks by rank
|
||||
// - Home
|
||||
$this->aHomeOrdering = $this->aAllowedBricks;
|
||||
usort($this->aHomeOrdering, function (PortalBrick $a, PortalBrick $b) {
|
||||
return $a->GetRankHome() > $b->GetRankHome();
|
||||
});
|
||||
// - Navigation menu
|
||||
$this->aNavigationMenuOrdering = $this->aAllowedBricks;
|
||||
usort($this->aNavigationMenuOrdering, function (PortalBrick $a, PortalBrick $b) {
|
||||
return $a->GetRankNavigationMenu() > $b->GetRankNavigationMenu();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function GetRawBrickList()
|
||||
{
|
||||
$aBricks = array();
|
||||
/** @var \Combodo\iTop\DesignElement $oBrickNode */
|
||||
foreach ($this->oModuleDesign->GetNodes('/module_design/bricks/brick') as $oBrickNode)
|
||||
{
|
||||
$sBrickClass = $oBrickNode->getAttribute('xsi:type');
|
||||
try
|
||||
{
|
||||
if (class_exists($sBrickClass))
|
||||
{
|
||||
/** @var \Combodo\iTop\Portal\Brick\PortalBrick $oBrick */
|
||||
$oBrick = new $sBrickClass();
|
||||
$oBrick->LoadFromXml($oBrickNode);
|
||||
|
||||
$aBricks[] = $oBrick;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new DOMFormatException('Unknown brick class "'.$sBrickClass.'" from xsi:type attribute', null,
|
||||
null, $oBrickNode);
|
||||
}
|
||||
}
|
||||
catch (DOMFormatException $e)
|
||||
{
|
||||
throw new Exception('Could not create brick ('.$sBrickClass.') from XML because of a DOM problem : '.$e->getMessage());
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('Could not create brick ('.$sBrickClass.') from XML : '.$oBrickNode->Dump().' '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $aBricks;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Portal\Brick;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class BrickNotFoundException
|
||||
*
|
||||
* @package Combodo\iTop\Portal\Brick
|
||||
* @since 2.7.0
|
||||
* @author Bruno Da Silva <bruno.dasilva@combodo.com>
|
||||
*/
|
||||
class BrickNotFoundException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||