diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32c75ebcc..bd9142271 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -134,7 +134,7 @@ Our tests are located in the `test/` directory, containing a PHPUnit config file When your code is working, please: -* stash as much as possible your commits, +* squash as much as possible your commits, * rebase your branch on our repo last commit, * create a pull request * mind to check the "[Allow edits from maintainers](https://docs.github.com/en/github-ae@latest/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)" option ! diff --git a/application/twigextension.class.inc.php b/application/twigextension.class.inc.php index 5234eb96a..ed045862e 100644 --- a/application/twigextension.class.inc.php +++ b/application/twigextension.class.inc.php @@ -111,23 +111,6 @@ class TwigExtension return utils::IsDevelopmentEnvironment(); })); - // Function to get configuration parameter - // Usage in twig: {{ get_config_parameter('foo') }} - $oTwigEnv->addFunction(new TwigFunction('get_config_parameter', function ($sParamName) { - $oConfig = MetaModel::GetConfig(); - - return $oConfig->Get($sParamName); - })); - - // Function to get a module setting - // Usage in twig: {{ get_module_setting(, [, ]) }} - // since 3.0.0, but see N°4034 for upcoming evolutions in the 3.1 - $oTwigEnv->addFunction(new TwigFunction('get_module_setting', function (string $sModuleCode, string $sPropertyCode, $defaultValue = null) { - $oConfig = MetaModel::GetConfig(); - - return $oConfig->GetModuleSetting($sModuleCode, $sPropertyCode, $defaultValue); - })); - // Function to get the URL of a static page in a module // Usage in twig: {{ get_static_page_module_url('itop-my-module', 'path-to-my-page') }} $oTwigEnv->addFunction(new TwigFunction('get_static_page_module_url', function ($sModuleName, $sPage) { diff --git a/composer.json b/composer.json index 52d6fe3ee..970f8f5fb 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "ext-json": "*", "ext-mysqli": "*", "ext-soap": "*", - "apereo/phpcas" : "~1.3", + "apereo/phpcas" : "~1.6.0", "combodo/tcpdf": "~6.4.4", "guzzlehttp/guzzle": "^7.4.5", "laminas/laminas-mail": "^2.11", diff --git a/composer.lock b/composer.lock index a9a26c686..31399cd97 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "276d2024de344c0d4105b15850560696", + "content-hash": "1fee7c7fd7649286a09641ae53e216de", "packages": [ { "name": "apereo/phpcas", - "version": "1.5.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/apereo/phpCAS.git", - "reference": "d6f5797fb568726f34c8e48741776d81e4a2646b" + "reference": "f817c72a961484afef95ac64a9257c8e31f063b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/apereo/phpCAS/zipball/d6f5797fb568726f34c8e48741776d81e4a2646b", - "reference": "d6f5797fb568726f34c8e48741776d81e4a2646b", + "url": "https://api.github.com/repos/apereo/phpCAS/zipball/f817c72a961484afef95ac64a9257c8e31f063b9", + "reference": "f817c72a961484afef95ac64a9257c8e31f063b9", "shasum": "" }, "require": { @@ -70,9 +70,9 @@ ], "support": { "issues": "https://github.com/apereo/phpCAS/issues", - "source": "https://github.com/apereo/phpCAS/tree/1.5.0" + "source": "https://github.com/apereo/phpCAS/tree/1.6.0" }, - "time": "2022-05-03T21:12:54+00:00" + "time": "2022-10-31T20:39:27+00:00" }, { "name": "combodo/tcpdf", diff --git a/datamodels/2.x/authent-cas/composer.json b/datamodels/2.x/authent-cas/composer.json new file mode 100644 index 000000000..0ef4b4858 --- /dev/null +++ b/datamodels/2.x/authent-cas/composer.json @@ -0,0 +1,10 @@ +{ + "config" : { + "classmap-authoritative" : true + }, + "autoload" : { + "psr-4" : { + "Combodo\\iTop\\Cas\\" : "src" + } + } +} \ No newline at end of file diff --git a/datamodels/2.x/authent-cas/composer.lock b/datamodels/2.x/authent-cas/composer.lock new file mode 100644 index 000000000..fd0bcbcb7 --- /dev/null +++ b/datamodels/2.x/authent-cas/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "d751713988987e9331980363e24189ce", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/datamodels/2.x/authent-cas/main.php b/datamodels/2.x/authent-cas/main.php deleted file mode 100644 index f30c02829..000000000 --- a/datamodels/2.x/authent-cas/main.php +++ /dev/null @@ -1,3 +0,0 @@ - array( 'model.authent-cas.php', - 'main.php' + 'vendor/autoload.php', + 'src/CASLoginExtension.php', ), 'webservice' => array( @@ -50,6 +51,7 @@ SetupWebPage::AddModule( 'cas_port' => '', 'cas_context' => '', 'cas_version' => '', + 'service_base_url' => '', ), ) ); diff --git a/datamodels/2.x/authent-cas/src/CASLog.php b/datamodels/2.x/authent-cas/src/CASLog.php new file mode 100644 index 000000000..85d3c7e59 --- /dev/null +++ b/datamodels/2.x/authent-cas/src/CASLog.php @@ -0,0 +1,17 @@ + LogAPI::LEVEL_ERROR, + LogLevel::ALERT => LogAPI::LEVEL_ERROR, + LogLevel::CRITICAL => LogAPI::LEVEL_ERROR, + LogLevel::ERROR => LogAPI::LEVEL_ERROR, + LogLevel::WARNING => LogAPI::LEVEL_WARNING, + LogLevel::NOTICE => LogAPI::LEVEL_INFO, + LogLevel::INFO => LogAPI::LEVEL_INFO, + LogLevel::DEBUG => LogAPI::LEVEL_DEBUG, + ]; + + public function emergency($message, array $context = array()) + { + CASLog::Error('EMERGENCY: '.$message, CASLog::CHANNEL_DEFAULT, $context); + IssueLog::Error('EMERGENCY: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function alert($message, array $context = array()) + { + CASLog::Error('ALERT: '.$message, CASLog::CHANNEL_DEFAULT, $context); + IssueLog::Error('ALERT: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function critical($message, array $context = array()) + { + CASLog::Error('CRITICAL: '.$message, CASLog::CHANNEL_DEFAULT, $context); + IssueLog::Error('CRITICAL: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function error($message, array $context = array()) + { + CASLog::Error('ERROR: '.$message, CASLog::CHANNEL_DEFAULT, $context); + IssueLog::Error('ERROR: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function warning($message, array $context = array()) + { + CASLog::Warning('WARNING: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function notice($message, array $context = array()) + { + CASLog::Info('NOTICE: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function info($message, array $context = array()) + { + CASLog::Info('INFO: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function debug($message, array $context = array()) + { + CASLog::Debug('DEBUG: '.$message, CASLog::CHANNEL_DEFAULT, $context); + } + + public function log($level, $message, array $context = array()) + { + $sLevel = self::LEVEL_COMPAT[$level] ?? LogAPI::LEVEL_ERROR; + CASLog::Log($sLevel, strtoupper($level).": $message", CASLog::CHANNEL_DEFAULT, $context); + } +} \ No newline at end of file diff --git a/datamodels/2.x/authent-cas/src/CASLoginExtension.php b/datamodels/2.x/authent-cas/src/CASLoginExtension.php index 9d8d6e6c0..b092cac13 100644 --- a/datamodels/2.x/authent-cas/src/CASLoginExtension.php +++ b/datamodels/2.x/authent-cas/src/CASLoginExtension.php @@ -153,7 +153,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte $bCASDebug = Config::Get('cas_debug'); if ($bCASDebug) { - phpCAS::setDebug(APPROOT.'log/cas.log'); + phpCAS::setLogger(new CASLogger(APPROOT.'log/cas.log')); } // Initialize phpCAS @@ -161,7 +161,8 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte $sCASHost = Config::Get('cas_host'); $iCASPort = Config::Get('cas_port'); $sCASContext = Config::Get('cas_context'); - phpCAS::client($sCASVersion, $sCASHost, $iCASPort, $sCASContext, false /* session already started */); + $sServiceBaseURL = Config::Get('service_base_url', self::GetServiceBaseURL()); + phpCAS::client($sCASVersion, $sCASHost, $iCASPort, $sCASContext, $sServiceBaseURL, false /* session already started */); $sCASCACertPath = Config::Get('cas_server_ca_cert_path'); if (empty($sCASCACertPath)) { @@ -177,6 +178,38 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte } } + private static function GetServiceBaseURL() + { + $protocol = $_SERVER['REQUEST_SCHEME']; + $protocol .= '://'; + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + // explode the host list separated by comma and use the first host + $hosts = explode(',', $_SERVER['HTTP_X_FORWARDED_HOST']); + // see rfc7239#5.3 and rfc7230#2.7.1: port is in HTTP_X_FORWARDED_HOST if non default + return $protocol . $hosts[0]; + } else if (!empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) { + $server_url = $_SERVER['HTTP_X_FORWARDED_SERVER']; + } else { + if (empty($_SERVER['SERVER_NAME'])) { + $server_url = $_SERVER['HTTP_HOST']; + } else { + $server_url = $_SERVER['SERVER_NAME']; + } + } + if (!strpos($server_url, ':')) { + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { + $server_port = $_SERVER['SERVER_PORT']; + } else { + $ports = explode(',', $_SERVER['HTTP_X_FORWARDED_PORT']); + $server_port = $ports[0]; + } + + $server_url .= ':'; + $server_url .= $server_port; + } + return $protocol . $server_url; + } + private function DoUserProvisioning($sLogin) { $bCASUserSynchro = Config::Get('cas_user_synchro'); diff --git a/datamodels/2.x/authent-cas/vendor/autoload.php b/datamodels/2.x/authent-cas/vendor/autoload.php new file mode 100644 index 000000000..9b40f3c15 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var ?string */ + private $vendorDir; + + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ + private $missingClasses = array(); + + /** @var ?string */ + private $apcuPrefix; + + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array[] + * @psalm-return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return string[] Array of classname => path + * @psalm-var array + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private + */ +function includeFile($file) +{ + include $file; +} diff --git a/datamodels/2.x/authent-cas/vendor/composer/InstalledVersions.php b/datamodels/2.x/authent-cas/vendor/composer/InstalledVersions.php new file mode 100644 index 000000000..7c5502ca4 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/InstalledVersions.php @@ -0,0 +1,337 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + */ +class InstalledVersions +{ + private static $installed; + private static $canGetVendors; + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } +} diff --git a/datamodels/2.x/authent-cas/vendor/composer/LICENSE b/datamodels/2.x/authent-cas/vendor/composer/LICENSE new file mode 100644 index 000000000..f27399a04 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/datamodels/2.x/authent-cas/vendor/composer/autoload_classmap.php b/datamodels/2.x/authent-cas/vendor/composer/autoload_classmap.php new file mode 100644 index 000000000..329956949 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/autoload_classmap.php @@ -0,0 +1,14 @@ + $baseDir . '/src/CASLog.php', + 'Combodo\\iTop\\Cas\\CASLogger' => $baseDir . '/src/CASLogger.php', + 'Combodo\\iTop\\Cas\\CASLoginExtension' => $baseDir . '/src/CASLoginExtension.php', + 'Combodo\\iTop\\Cas\\Config' => $baseDir . '/src/Config.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', +); diff --git a/datamodels/2.x/authent-cas/vendor/composer/autoload_namespaces.php b/datamodels/2.x/authent-cas/vendor/composer/autoload_namespaces.php new file mode 100644 index 000000000..b7fc0125d --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/src'), +); diff --git a/datamodels/2.x/authent-cas/vendor/composer/autoload_real.php b/datamodels/2.x/authent-cas/vendor/composer/autoload_real.php new file mode 100644 index 000000000..06a1b3556 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/autoload_real.php @@ -0,0 +1,46 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit1878ad96115c3aa0fa5e9fd9807f5db0::getInitializer($loader)); + } else { + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->setClassMapAuthoritative(true); + $loader->register(true); + + return $loader; + } +} diff --git a/datamodels/2.x/authent-cas/vendor/composer/autoload_static.php b/datamodels/2.x/authent-cas/vendor/composer/autoload_static.php new file mode 100644 index 000000000..2f08d48c5 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/autoload_static.php @@ -0,0 +1,40 @@ + + array ( + 'Combodo\\iTop\\Cas\\' => 17, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Combodo\\iTop\\Cas\\' => + array ( + 0 => __DIR__ . '/../..' . '/src', + ), + ); + + public static $classMap = array ( + 'Combodo\\iTop\\Cas\\CASLog' => __DIR__ . '/../..' . '/src/CASLog.php', + 'Combodo\\iTop\\Cas\\CASLogger' => __DIR__ . '/../..' . '/src/CASLogger.php', + 'Combodo\\iTop\\Cas\\CASLoginExtension' => __DIR__ . '/../..' . '/src/CASLoginExtension.php', + 'Combodo\\iTop\\Cas\\Config' => __DIR__ . '/../..' . '/src/Config.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit1878ad96115c3aa0fa5e9fd9807f5db0::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit1878ad96115c3aa0fa5e9fd9807f5db0::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit1878ad96115c3aa0fa5e9fd9807f5db0::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/datamodels/2.x/authent-cas/vendor/composer/installed.json b/datamodels/2.x/authent-cas/vendor/composer/installed.json new file mode 100644 index 000000000..87fda747e --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/installed.json @@ -0,0 +1,5 @@ +{ + "packages": [], + "dev": true, + "dev-package-names": [] +} diff --git a/datamodels/2.x/authent-cas/vendor/composer/installed.php b/datamodels/2.x/authent-cas/vendor/composer/installed.php new file mode 100644 index 000000000..f2779c751 --- /dev/null +++ b/datamodels/2.x/authent-cas/vendor/composer/installed.php @@ -0,0 +1,23 @@ + array( + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '5a1627632aa2e605996c1c556c60c2a2cddc0a05', + 'name' => '__root__', + 'dev' => true, + ), + 'versions' => array( + '__root__' => array( + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '5a1627632aa2e605996c1c556c60c2a2cddc0a05', + 'dev_requirement' => false, + ), + ), +); diff --git a/datamodels/2.x/itop-oauth-client/vendor/composer/InstalledVersions.php b/datamodels/2.x/itop-oauth-client/vendor/composer/InstalledVersions.php index d50e0c9fc..7c5502ca4 100644 --- a/datamodels/2.x/itop-oauth-client/vendor/composer/InstalledVersions.php +++ b/datamodels/2.x/itop-oauth-client/vendor/composer/InstalledVersions.php @@ -24,21 +24,8 @@ use Composer\Semver\VersionParser; */ class InstalledVersions { - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null - */ private static $installed; - - /** - * @var bool|null - */ private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array}> - */ private static $installedByVendor = array(); /** diff --git a/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_classmap.php b/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_classmap.php index 25e360e9d..830aee37d 100644 --- a/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_classmap.php +++ b/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_classmap.php @@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir); return array( 'Combodo\\iTop\\OAuthClient\\Controller\\AjaxOauthClientController' => $baseDir . '/src/Controller/AjaxOauthClientController.php', 'Combodo\\iTop\\OAuthClient\\Controller\\OAuthClientController' => $baseDir . '/src/Controller/OAuthClientController.php', + 'Combodo\\iTop\\OAuthClient\\Service\\ApplicationUIExtension' => $baseDir . '/src/Service/ApplicationUIExtension.php', 'Combodo\\iTop\\OAuthClient\\Service\\PopupMenuExtension' => $baseDir . '/src/Service/PopupMenuExtension.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', ); diff --git a/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_static.php b/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_static.php index 3f16c1e01..d88f44a19 100644 --- a/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_static.php +++ b/datamodels/2.x/itop-oauth-client/vendor/composer/autoload_static.php @@ -23,6 +23,7 @@ class ComposerStaticInitd52424b43ff18219f2ec935428aff074 public static $classMap = array ( 'Combodo\\iTop\\OAuthClient\\Controller\\AjaxOauthClientController' => __DIR__ . '/../..' . '/src/Controller/AjaxOauthClientController.php', 'Combodo\\iTop\\OAuthClient\\Controller\\OAuthClientController' => __DIR__ . '/../..' . '/src/Controller/OAuthClientController.php', + 'Combodo\\iTop\\OAuthClient\\Service\\ApplicationUIExtension' => __DIR__ . '/../..' . '/src/Service/ApplicationUIExtension.php', 'Combodo\\iTop\\OAuthClient\\Service\\PopupMenuExtension' => __DIR__ . '/../..' . '/src/Service/PopupMenuExtension.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', ); diff --git a/datamodels/2.x/itop-oauth-client/vendor/composer/installed.php b/datamodels/2.x/itop-oauth-client/vendor/composer/installed.php index 78d9f7563..16e860ca4 100644 --- a/datamodels/2.x/itop-oauth-client/vendor/composer/installed.php +++ b/datamodels/2.x/itop-oauth-client/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'itop-extension', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '1135896b3d084aa9df778bfbb724b7e992534989', + 'reference' => '5a1627632aa2e605996c1c556c60c2a2cddc0a05', 'name' => 'combodo/itop-oauth-client', 'dev' => true, ), @@ -16,7 +16,7 @@ 'type' => 'itop-extension', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '1135896b3d084aa9df778bfbb724b7e992534989', + 'reference' => '5a1627632aa2e605996c1c556c60c2a2cddc0a05', 'dev_requirement' => false, ), ), diff --git a/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php b/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php index 47ec052af..7c3128456 100644 --- a/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php +++ b/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php @@ -139,6 +139,7 @@ if (!defined('PORTAL_ID')) // Env. vars to be used in templates and others $_ENV['COMBODO_CURRENT_ENVIRONMENT'] = utils::GetCurrentEnvironment(); $_ENV['COMBODO_ABSOLUTE_URL'] = utils::GetAbsoluteUrlAppRoot(); +$_ENV['COMBODO_CONF_APP_ICON_URL'] = MetaModel::GetConfig()->Get('app_icon_url'); $_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/'; diff --git a/datamodels/2.x/itop-portal-base/portal/config/services.yaml b/datamodels/2.x/itop-portal-base/portal/config/services.yaml index 17e82f3f1..6b69915a7 100644 --- a/datamodels/2.x/itop-portal-base/portal/config/services.yaml +++ b/datamodels/2.x/itop-portal-base/portal/config/services.yaml @@ -28,6 +28,7 @@ parameters: # Used in templates combodo.current_environment: '%env(string:COMBODO_CURRENT_ENVIRONMENT)%' combodo.absolute_url: '%env(string:COMBODO_ABSOLUTE_URL)%' + combodo.conf.app_icon_url: '%env(string:COMBODO_CONF_APP_ICON_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)%' diff --git a/datamodels/2.x/itop-portal-base/portal/src/Twig/AppExtension.php b/datamodels/2.x/itop-portal-base/portal/src/Twig/AppExtension.php index b783fb79b..6ad776794 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Twig/AppExtension.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Twig/AppExtension.php @@ -19,35 +19,192 @@ namespace Combodo\iTop\Portal\Twig; -use Combodo\iTop\Application\TwigBase\Twig\Extension; +use AttributeDate; +use AttributeDateTime; +use AttributeText; +use Dict; use Twig\Extension\AbstractExtension; +use Twig_SimpleFilter; +use Twig_SimpleFunction; +use utils; /** * Class AppExtension * - * Automatically loaded by portal's Symfony configuration to register TWIG extensions. - * The class must be kept by it is using the factorized filters/functions of the iTop core. - * * @package Combodo\iTop\Portal\Twig * @since 2.7.0 * @author Bruno Da Silva + * @deprected 3.1.0 N°4287 */ class AppExtension extends AbstractExtension { /** - * @inheritDoc + * @return array|\Twig\TwigFilter[]|\Twig_SimpleFilter[] */ public function getFilters() { - return Extension::GetFilters(); + $filters = array(); + // Filter to translate a string via the Dict::S function + // Usage in twig: {{ 'String:ToTranslate'|dict_s }} + $filters[] = new Twig_SimpleFilter('dict_s', + function ($sStringCode, $sDefault = null, $bUserLanguageOnly = false) { + return Dict::S($sStringCode, $sDefault, $bUserLanguageOnly); + } + ); + + // Filter to format a string via the Dict::Format function + // Usage in twig: {{ 'String:ToTranslate'|dict_format() }} + $filters[] = new Twig_SimpleFilter('dict_format', + function ($sStringCode, $sParam01 = null, $sParam02 = null, $sParam03 = null, $sParam04 = null) { + return Dict::Format($sStringCode, $sParam01, $sParam02, $sParam03, $sParam04); + } + ); + + /** + * Filter to format output + * example a DateTime is converted to user format + * Usage in twig: {{ 'String:ToFormat'|output_format }} + * + * @since 3.0.0 + */ + $filters[] = new Twig_SimpleFilter('date_format', + function ($sDate) { + try + { + if (preg_match('@^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$@', trim($sDate))) + { + return AttributeDateTime::GetFormat()->Format($sDate); + } + if (preg_match('@^\d\d\d\d-\d\d-\d\d$@', trim($sDate))) + { + return AttributeDate::GetFormat()->Format($sDate); + } + } + catch (Exception $e) + { + } + + return $sDate; + } + ); + + /** + * Filter to format output + * example a DateTime is converted to user format + * Usage in twig: {{ 'String:ToFormat'|output_format }} + * + * @since 3.0.0 + */ + $filters[] = new Twig_SimpleFilter('size_format', + function ($sSize) { + return utils::BytesToFriendlyFormat($sSize); + } + ); + + // Filter to enable base64 encode/decode + // Usage in twig: {{ 'String to encode'|base64_encode }} + $filters[] = new Twig_SimpleFilter('base64_encode', 'base64_encode'); + $filters[] = new Twig_SimpleFilter('base64_decode', 'base64_decode'); + + // Filter to enable json decode (encode already exists) + // Usage in twig: {{ aSomeArray|json_decode }} + $filters[] = new Twig_SimpleFilter('json_decode', function ($sJsonString, $bAssoc = false) { + return json_decode($sJsonString, $bAssoc); + } + ); + + /** + * Filter to sanitize a text + * Usage in twig: {{ 'variable_name:to-sanitize'|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) }} + * + * @uses \utils::Sanitize() + * @since 3.0.0 + */ + $filters[] = new Twig_SimpleFilter('sanitize', function (string $sString, string $sFilter) { + return utils::Sanitize($sString, '', $sFilter); + } + ); + + /** + * Filter to transform the wiki syntax ONLY into HTML. + * + * @uses \AttributeText::RenderWikiHtml() + * @since 3.0.0 + */ + $filters[] = new Twig_SimpleFilter('render_wiki_to_html', function ($sString) { + return AttributeText::RenderWikiHtml($sString, true /* Important, otherwise hyperlinks will be tranformed as well */); + } + ); + + // Filter to add itopversion to an url + $filters[] = new Twig_SimpleFilter('add_itop_version', function ($sUrl) { + $sUrl = utils::AddParameterToUrl($sUrl, 'itopversion', ITOP_VERSION); + + return $sUrl; + }); + + // Filter to add a module's version to an url + $filters[] = new Twig_SimpleFilter('add_module_version', function ($sUrl, $sModuleName) { + $sModuleVersion = utils::GetCompiledModuleVersion($sModuleName); + $sUrl = utils::AddParameterToUrl($sUrl, 'moduleversion', $sModuleVersion); + + return $sUrl; + }); + + /** + * var_export can be used for example to transform a PHP boolean to 'true' or 'false' strings + * @see https://www.php.net/manual/fr/function.var-export.php + * + * @since 3.0.0 + */ + $filters[] = new Twig_SimpleFilter('var_export', 'var_export'); + + //since 2.7.7 3.0.2 3.1.0 N°4867 "Twig content not allowed" error when use the extkey widget search icon in the user portal + //overwrite native twig filter : disable use of 'system' filter + $filters[] = new Twig_SimpleFilter('filter', function ($array, $arrow) { + if ($arrow == 'system'){ + return json_encode($array); + } + return twig_array_filter($array, $arrow); + }); + + return $filters; } /** - * @inheritDoc + * @return array|\Twig\TwigFunction[]|\Twig_SimpleFunction[] */ public function getFunctions() { - return Extension::GetFunctions(); + $functions = array(); + + // Function to check our current environment + // Usage in twig: {% if is_development_environment() %} + $functions[] = new Twig_SimpleFunction('is_development_environment', function () { + return utils::IsDevelopmentEnvironment(); + }); + + /** + * Function to get iTop's app root absolute URL (eg. https://aaa.bbb.ccc/xxx/yyy/) + * Usage in twig: {{ get_absolute_url_app_root() }} + * + * @since 3.0.0 + */ + $functions[] = new Twig_SimpleFunction('get_absolute_url_app_root', function () { + return utils::GetAbsoluteUrlAppRoot(); + }); + + /** + * Function to get iTop's modules root absolute URL (eg. https://aaa.bbb.ccc/xxx/yyy/env-zzz/) + * Usage in twig: {{ get_absolute_url_modules_root() }} + * + * @since 3.0.0 + */ + $functions[] = new Twig_SimpleFunction('get_absolute_url_modules_root', function () { + return utils::GetAbsoluteUrlModulesRoot(); + }); + + return $functions; } diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig index 123c2ad74..474e71e90 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig @@ -188,7 +188,7 @@ {% block pNavigationTopMenuLogo %} - + {% if app['combodo.portal.instance.conf'].properties.logo is not null %} {{ app['combodo.portal.instance.conf'].properties.name|dict_s }} {% else %} @@ -316,7 +316,7 @@ {% if app['kernel'].debug == true %}
Debug: Screen size
{% endif %} -
+ {{ app['combodo.portal.instance.conf'].properties.name|dict_s }} {% endblock %} diff --git a/lib/apereo/phpcas/source/CAS.php b/lib/apereo/phpcas/source/CAS.php index c30e22d0a..8243a83e3 100644 --- a/lib/apereo/phpcas/source/CAS.php +++ b/lib/apereo/phpcas/source/CAS.php @@ -57,7 +57,7 @@ if (!isset($_SERVER['REQUEST_URI']) && isset($_SERVER['SCRIPT_NAME']) && isset($ /** * phpCAS version. accessible for the user by phpCAS::getVersion(). */ -define('PHPCAS_VERSION', '1.5.0'); +define('PHPCAS_VERSION', '1.6.0'); /** * @addtogroup public @@ -327,6 +327,14 @@ class phpCAS * @param string $server_hostname the hostname of the CAS server * @param int $server_port the port the CAS server is running on * @param string $server_uri the URI the CAS server is responding on + * @param string|string[]|CAS_ServiceBaseUrl_Interface + * $service_base_url the base URL (protocol, host and the + * optional port) of the CAS client; pass + * in an array to use auto discovery with + * an allowlist; pass in + * CAS_ServiceBaseUrl_Interface for custom + * behavior. Added in 1.6.0. Similar to + * serverName config in other CAS clients. * @param bool $changeSessionID Allow phpCAS to change the session_id * (Single Sign Out/handleLogoutRequests * is based on that change) @@ -338,7 +346,8 @@ class phpCAS * and phpCAS::setDebug()). */ public static function client($server_version, $server_hostname, - $server_port, $server_uri, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null + $server_port, $server_uri, $service_base_url, + $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null ) { phpCAS :: traceBegin(); if (is_object(self::$_PHPCAS_CLIENT)) { @@ -357,7 +366,7 @@ class phpCAS // initialize the object $_PHPCAS_CLIENT try { self::$_PHPCAS_CLIENT = new CAS_Client( - $server_version, false, $server_hostname, $server_port, $server_uri, + $server_version, false, $server_hostname, $server_port, $server_uri, $service_base_url, $changeSessionID, $sessionHandler ); } catch (Exception $e) { @@ -373,6 +382,14 @@ class phpCAS * @param string $server_hostname the hostname of the CAS server * @param string $server_port the port the CAS server is running on * @param string $server_uri the URI the CAS server is responding on + * @param string|string[]|CAS_ServiceBaseUrl_Interface + * $service_base_url the base URL (protocol, host and the + * optional port) of the CAS client; pass + * in an array to use auto discovery with + * an allowlist; pass in + * CAS_ServiceBaseUrl_Interface for custom + * behavior. Added in 1.6.0. Similar to + * serverName config in other CAS clients. * @param bool $changeSessionID Allow phpCAS to change the session_id * (Single Sign Out/handleLogoutRequests * is based on that change) @@ -384,7 +401,8 @@ class phpCAS * and phpCAS::setDebug()). */ public static function proxy($server_version, $server_hostname, - $server_port, $server_uri, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null + $server_port, $server_uri, $service_base_url, + $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null ) { phpCAS :: traceBegin(); if (is_object(self::$_PHPCAS_CLIENT)) { @@ -403,7 +421,7 @@ class phpCAS // initialize the object $_PHPCAS_CLIENT try { self::$_PHPCAS_CLIENT = new CAS_Client( - $server_version, true, $server_hostname, $server_port, $server_uri, + $server_version, true, $server_hostname, $server_port, $server_uri, $service_base_url, $changeSessionID, $sessionHandler ); } catch (Exception $e) { diff --git a/lib/apereo/phpcas/source/CAS/Client.php b/lib/apereo/phpcas/source/CAS/Client.php index 1a40f63e4..91642ee52 100644 --- a/lib/apereo/phpcas/source/CAS/Client.php +++ b/lib/apereo/phpcas/source/CAS/Client.php @@ -918,6 +918,14 @@ class CAS_Client * @param bool $changeSessionID Allow phpCAS to change the session_id * (Single Sign Out/handleLogoutRequests * is based on that change) + * @param string|string[]|CAS_ServiceBaseUrl_Interface + * $service_base_url the base URL (protocol, host and the + * optional port) of the CAS client; pass + * in an array to use auto discovery with + * an allowlist; pass in + * CAS_ServiceBaseUrl_Interface for custom + * behavior. Added in 1.6.0. Similar to + * serverName config in other CAS clients. * @param \SessionHandlerInterface $sessionHandler the session handler * * @return self a newly created CAS_Client object @@ -928,6 +936,7 @@ class CAS_Client $server_hostname, $server_port, $server_uri, + $service_base_url, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null ) { @@ -945,6 +954,8 @@ class CAS_Client if (gettype($changeSessionID) != 'boolean') throw new CAS_TypeMismatchException($changeSessionID, '$changeSessionID', 'boolean'); + $this->_setServiceBaseUrl($service_base_url); + if (empty($sessionHandler)) { $sessionHandler = new CAS_Session_PhpSession; } @@ -1049,7 +1060,7 @@ class CAS_Client if ( $this->_isCallbackMode() ) { //callback mode: check that phpCAS is secured - if ( !$this->_isHttps() ) { + if ( !$this->getServiceBaseUrl()->isHttps() ) { phpCAS::error( 'CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server' ); @@ -2578,8 +2589,7 @@ class CAS_Client // the URL is built when needed only if ( empty($this->_callback_url) ) { // remove the ticket if present in the URL - $final_uri = 'https://'; - $final_uri .= $this->_getClientUrl(); + $final_uri = $this->getServiceBaseUrl()->get(); $request_uri = $_SERVER['REQUEST_URI']; $request_uri = preg_replace('/\?.*$/', '', $request_uri); $final_uri .= $request_uri; @@ -3947,10 +3957,7 @@ class CAS_Client // the URL is built when needed only if ( empty($this->_url) ) { // remove the ticket if present in the URL - $final_uri = ($this->_isHttps()) ? 'https' : 'http'; - $final_uri .= '://'; - - $final_uri .= $this->_getClientUrl(); + $final_uri = $this->getServiceBaseUrl()->get(); $request_uri = explode('?', $_SERVER['REQUEST_URI'], 2); $final_uri .= $request_uri[0]; @@ -3987,65 +3994,61 @@ class CAS_Client return $this->_server['base_url'] = $url; } + /** + * The ServiceBaseUrl object that provides base URL during service URL + * discovery process. + * + * @var CAS_ServiceBaseUrl_Interface + * + * @hideinitializer + */ + private $_serviceBaseUrl = null; /** - * Try to figure out the phpCAS client URL with possible Proxys / Ports etc. + * Answer the CAS_ServiceBaseUrl_Interface object for this client. * - * @return string Server URL with domain:port + * @return CAS_ServiceBaseUrl_Interface */ - private function _getClientUrl() + public function getServiceBaseUrl() { - if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { - // explode the host list separated by comma and use the first host - $hosts = explode(',', $_SERVER['HTTP_X_FORWARDED_HOST']); - // see rfc7239#5.3 and rfc7230#2.7.1: port is in HTTP_X_FORWARDED_HOST if non default - return $hosts[0]; - } else if (!empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) { - $server_url = $_SERVER['HTTP_X_FORWARDED_SERVER']; - } else { - if (empty($_SERVER['SERVER_NAME'])) { - $server_url = $_SERVER['HTTP_HOST']; - } else { - $server_url = $_SERVER['SERVER_NAME']; - } + if (empty($this->_serviceBaseUrl)) { + phpCAS::error("ServiceBaseUrl object is not initialized"); } - if (!strpos($server_url, ':')) { - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { - $server_port = $_SERVER['SERVER_PORT']; - } else { - $ports = explode(',', $_SERVER['HTTP_X_FORWARDED_PORT']); - $server_port = $ports[0]; - } - - if ( ($this->_isHttps() && $server_port!=443) - || (!$this->_isHttps() && $server_port!=80) - ) { - $server_url .= ':'; - $server_url .= $server_port; - } - } - return $server_url; + return $this->_serviceBaseUrl; } /** - * This method checks to see if the request is secured via HTTPS + * This method sets the service base URL used during service URL discovery process. * - * @return bool true if https, false otherwise + * This is required since phpCAS 1.6.0 to protect the integrity of the authentication. + * + * @since phpCAS 1.6.0 + * + * @param $name can be any of the following: + * - A base URL string. The service URL discovery will always use this (protocol, + * hostname and optional port number) without using any external host names. + * - An array of base URL strings. The service URL discovery will check against + * this list before using the auto discovered base URL. If there is no match, + * the first base URL in the array will be used as the default. This option is + * helpful if your PHP website is accessible through multiple domains without a + * canonical name, or through both HTTP and HTTPS. + * - A class that implements CAS_ServiceBaseUrl_Interface. If you need to customize + * the base URL discovery behavior, you can pass in a class that implements the + * interface. + * + * @return void */ - private function _isHttps() + private function _setServiceBaseUrl($name) { - if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) { - return ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'); - } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])) { - return ($_SERVER['HTTP_X_FORWARDED_PROTOCOL'] === 'https'); - } elseif ( isset($_SERVER['HTTPS']) - && !empty($_SERVER['HTTPS']) - && strcasecmp($_SERVER['HTTPS'], 'off') !== 0 - ) { - return true; + if (is_array($name)) { + $this->_serviceBaseUrl = new CAS_ServiceBaseUrl_AllowedListDiscovery($name); + } else if (is_string($name)) { + $this->_serviceBaseUrl = new CAS_ServiceBaseUrl_Static($name); + } else if ($name instanceof CAS_ServiceBaseUrl_Interface) { + $this->_serviceBaseUrl = $name; + } else { + throw new CAS_TypeMismatchException($name, '$name', 'array, string, or CAS_ServiceBaseUrl_Interface object'); } - return false; - } /** diff --git a/lib/apereo/phpcas/source/CAS/Request/CurlRequest.php b/lib/apereo/phpcas/source/CAS/Request/CurlRequest.php index 3eaa0d3c1..e30dd0d19 100644 --- a/lib/apereo/phpcas/source/CAS/Request/CurlRequest.php +++ b/lib/apereo/phpcas/source/CAS/Request/CurlRequest.php @@ -160,6 +160,11 @@ implements CAS_Request_RequestInterface curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postBody); } + /********************************************************* + * Set User Agent + *********************************************************/ + curl_setopt($ch, CURLOPT_USERAGENT, 'phpCAS/' . phpCAS::getVersion()); + return $ch; } diff --git a/lib/composer/InstalledVersions.php b/lib/composer/InstalledVersions.php index d50e0c9fc..7c5502ca4 100644 --- a/lib/composer/InstalledVersions.php +++ b/lib/composer/InstalledVersions.php @@ -24,21 +24,8 @@ use Composer\Semver\VersionParser; */ class InstalledVersions { - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null - */ private static $installed; - - /** - * @var bool|null - */ private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array}> - */ private static $installedByVendor = array(); /** diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 5f47496fb..c74acc1c2 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -145,6 +145,10 @@ return array( 'CAS_Request_Exception' => $vendorDir . '/apereo/phpcas/source/CAS/Request/Exception.php', 'CAS_Request_MultiRequestInterface' => $vendorDir . '/apereo/phpcas/source/CAS/Request/MultiRequestInterface.php', 'CAS_Request_RequestInterface' => $vendorDir . '/apereo/phpcas/source/CAS/Request/RequestInterface.php', + 'CAS_ServiceBaseUrl_AllowedListDiscovery' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/AllowedListDiscovery.php', + 'CAS_ServiceBaseUrl_Base' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Base.php', + 'CAS_ServiceBaseUrl_Interface' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Interface.php', + 'CAS_ServiceBaseUrl_Static' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Static.php', 'CAS_Session_PhpSession' => $vendorDir . '/apereo/phpcas/source/CAS/Session/PhpSession.php', 'CAS_TypeMismatchException' => $vendorDir . '/apereo/phpcas/source/CAS/TypeMismatchException.php', 'CLILikeWebPage' => $baseDir . '/sources/Application/WebPage/CLILikeWebPage.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index f3e5238ac..d89144835 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -510,6 +510,10 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f 'CAS_Request_Exception' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Request/Exception.php', 'CAS_Request_MultiRequestInterface' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Request/MultiRequestInterface.php', 'CAS_Request_RequestInterface' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Request/RequestInterface.php', + 'CAS_ServiceBaseUrl_AllowedListDiscovery' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/AllowedListDiscovery.php', + 'CAS_ServiceBaseUrl_Base' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Base.php', + 'CAS_ServiceBaseUrl_Interface' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Interface.php', + 'CAS_ServiceBaseUrl_Static' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Static.php', 'CAS_Session_PhpSession' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Session/PhpSession.php', 'CAS_TypeMismatchException' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/TypeMismatchException.php', 'CLILikeWebPage' => __DIR__ . '/../..' . '/sources/Application/WebPage/CLILikeWebPage.php', diff --git a/lib/composer/installed.json b/lib/composer/installed.json index 71821afa0..d7e143a1f 100644 --- a/lib/composer/installed.json +++ b/lib/composer/installed.json @@ -2,17 +2,17 @@ "packages": [ { "name": "apereo/phpcas", - "version": "1.5.0", - "version_normalized": "1.5.0.0", + "version": "1.6.0", + "version_normalized": "1.6.0.0", "source": { "type": "git", "url": "https://github.com/apereo/phpCAS.git", - "reference": "d6f5797fb568726f34c8e48741776d81e4a2646b" + "reference": "f817c72a961484afef95ac64a9257c8e31f063b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/apereo/phpCAS/zipball/d6f5797fb568726f34c8e48741776d81e4a2646b", - "reference": "d6f5797fb568726f34c8e48741776d81e4a2646b", + "url": "https://api.github.com/repos/apereo/phpCAS/zipball/f817c72a961484afef95ac64a9257c8e31f063b9", + "reference": "f817c72a961484afef95ac64a9257c8e31f063b9", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ "phpstan/phpstan": "^1.5", "phpunit/phpunit": ">=7.5" }, - "time": "2022-05-03T21:12:54+00:00", + "time": "2022-10-31T20:39:27+00:00", "type": "library", "extra": { "branch-alias": { @@ -67,7 +67,7 @@ ], "support": { "issues": "https://github.com/apereo/phpCAS/issues", - "source": "https://github.com/apereo/phpCAS/tree/1.5.0" + "source": "https://github.com/apereo/phpCAS/tree/1.6.0" }, "install-path": "../apereo/phpcas" }, diff --git a/lib/composer/installed.php b/lib/composer/installed.php index 21e2f87ab..fff50ab0f 100644 --- a/lib/composer/installed.php +++ b/lib/composer/installed.php @@ -5,18 +5,18 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '0520e72b9d1190cab294aebc5ab7542a18d2bc51', + 'reference' => 'cdde765a85ee0262181e3c493183b1fb80536e74', 'name' => 'combodo/itop', 'dev' => true, ), 'versions' => array( 'apereo/phpcas' => array( - 'pretty_version' => '1.5.0', - 'version' => '1.5.0.0', + 'pretty_version' => '1.6.0', + 'version' => '1.6.0.0', 'type' => 'library', 'install_path' => __DIR__ . '/../apereo/phpcas', 'aliases' => array(), - 'reference' => 'd6f5797fb568726f34c8e48741776d81e4a2646b', + 'reference' => 'f817c72a961484afef95ac64a9257c8e31f063b9', 'dev_requirement' => false, ), 'combodo/itop' => array( @@ -25,7 +25,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '0520e72b9d1190cab294aebc5ab7542a18d2bc51', + 'reference' => 'cdde765a85ee0262181e3c493183b1fb80536e74', 'dev_requirement' => false, ), 'combodo/tcpdf' => array( diff --git a/sources/Application/TwigBase/Twig/Extension.php b/sources/Application/TwigBase/Twig/Extension.php index 8b96f7e8f..e08c77483 100644 --- a/sources/Application/TwigBase/Twig/Extension.php +++ b/sources/Application/TwigBase/Twig/Extension.php @@ -1,6 +1,6 @@ Get($sParamName); - }); - - /** - * Function to get a module setting - * Usage in twig: {{ get_module_setting(, [, ]) }} - * - * @uses Config::GetModuleSetting() - * @since 3.0.0 - */ - $aFunctions[] = new TwigFunction('get_module_setting', - function (string $sModuleCode, string $sPropertyCode, $defaultValue = null) { - $oConfig = MetaModel::GetConfig(); - - return $oConfig->GetModuleSetting($sModuleCode, $sPropertyCode, $defaultValue); - }); - // Function to get iTop's app root absolute URL (eg. https://aaa.bbb.ccc/xxx/yyy/) // Usage in twig: {{ get_absolute_url_app_root() }} /** @since 3.0.0 */ diff --git a/sources/Application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php b/sources/Application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php index a4c917ffa..794914318 100644 --- a/sources/Application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php +++ b/sources/Application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php @@ -24,6 +24,7 @@ use AttributeDateTime; use Combodo\iTop\Application\UI\Base\UIBlock; use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin; use DateTime; +use MetaModel; use UserRights; use utils; @@ -74,6 +75,8 @@ class ActivityEntry extends UIBlock */ protected $sOrigin; + protected $bShowAuthorNameBelowEntries; + /** * ActivityEntry constructor. * @@ -94,6 +97,7 @@ class ActivityEntry extends UIBlock $this->SetDateTime($oDateTime); $this->SetAuthor($sAuthorLogin); $this->SetOrigin(static::DEFAULT_ORIGIN); + $this->SetShowAuthorNameBelowEntries(MetaModel::GetConfig()->Get('activity_panel.show_author_name_below_entries')); } /** @@ -306,6 +310,22 @@ class ActivityEntry extends UIBlock return $this->sOrigin; } + /** + * @return mixed + */ + public function ShowAuthorNameBelowEntries(): bool + { + return $this->bShowAuthorNameBelowEntries; + } + + /** + * @param bool $bShowAuthorNameBelowEntries + */ + public function SetShowAuthorNameBelowEntries($bShowAuthorNameBelowEntries): void + { + $this->bShowAuthorNameBelowEntries = $bShowAuthorNameBelowEntries; + } + /** * @return string|null The CSS decoration classes for the origin of the entry * @see \CMDBChangeOrigin diff --git a/sources/Application/UI/Base/Layout/ActivityPanel/ActivityPanel.php b/sources/Application/UI/Base/Layout/ActivityPanel/ActivityPanel.php index aabe1b1e7..d7f67a348 100644 --- a/sources/Application/UI/Base/Layout/ActivityPanel/ActivityPanel.php +++ b/sources/Application/UI/Base/Layout/ActivityPanel/ActivityPanel.php @@ -90,6 +90,17 @@ class ActivityPanel extends UIBlock protected $oComposeMenu; /** @var bool Whether a confirmation dialog should be prompt when multiple entries are about to be submitted at once */ protected $bShowMultipleEntriesSubmitConfirmation; + /** @var int */ + protected $iDatetimesReformatLimit; + /** @var int */ + protected $iLockWatcherPeriod; + /** @var bool */ + protected $bPrefilterOnlyCurrentLog; + /** @var bool */ + protected $bPrefilterStateChangesOnLogs; + /** @var bool */ + protected $bPrefilterEditsOnLogs; + /** * ActivityPanel constructor. @@ -105,12 +116,18 @@ class ActivityPanel extends UIBlock { parent::__construct($sId); + $oConfig = MetaModel::GetConfig(); $this->InitializeCaseLogTabs(); $this->InitializeCaseLogTabsEntryForms(); $this->InitializeComposeMenu(); $this->SetObjectMode(cmdbAbstractObject::DEFAULT_DISPLAY_MODE); $this->SetObject($oObject); $this->SetEntries($aEntries); + $this->SetDatetimesReformatLimit($oConfig->Get('activity_panel.datetimes_reformat_limit')); + $this->SetLockWatcherPeriod($oConfig->Get('activity_panel.lock_watcher_period')); + $this->SetPrefilterOnlyCurrentLog($oConfig->Get('activity_panel.prefilter_only_current_log')); + $this->SetPrefilterStateChangesOnLogs($oConfig->Get('activity_panel.prefilter_state_changes_on_logs')); + $this->SetPrefilterEditsOnLogs($oConfig->Get('activity_panel.prefilter_edits_on_logs')); $this->bAreEntriesSorted = false; $this->bHasMoreEntriesToLoad = false; $this->aLastLoadedEntriesIds = []; @@ -846,6 +863,86 @@ class ActivityPanel extends UIBlock return utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php'; } + /** + * @return int + */ + public function GetDatetimesReformatLimit(): int + { + return $this->iDatetimesReformatLimit; + } + + /** + * @param int $iDatetimesReformatLimit + */ + public function SetDatetimesReformatLimit(int $iDatetimesReformatLimit): void + { + $this->iDatetimesReformatLimit = $iDatetimesReformatLimit; + } + + /** + * @return int + */ + public function GetLockWatcherPeriod(): int + { + return $this->iLockWatcherPeriod; + } + + /** + * @param int $iLockWatcherPeriod + */ + public function SetLockWatcherPeriod(int $iLockWatcherPeriod): void + { + $this->iLockWatcherPeriod = $iLockWatcherPeriod; + } + + /** + * @return bool + */ + public function GetPrefilterOnlyCurrentLog(): bool + { + return $this->bPrefilterOnlyCurrentLog; + } + + /** + * @param bool $bPrefilterOnlyCurrentLog + */ + public function SetPrefilterOnlyCurrentLog(bool $bPrefilterOnlyCurrentLog): void + { + $this->bPrefilterOnlyCurrentLog = $bPrefilterOnlyCurrentLog; + } + + /** + * @return bool + */ + public function GetPrefilterStateChangesOnLogs(): bool + { + return $this->bPrefilterStateChangesOnLogs; + } + + /** + * @param bool $bPrefilterStateChangesOnLogs + */ + public function SetPrefilterStateChangesOnLogs(bool $bPrefilterStateChangesOnLogs): void + { + $this->bPrefilterStateChangesOnLogs = $bPrefilterStateChangesOnLogs; + } + + /** + * @return bool + */ + public function GetPrefilterEditsOnLogs(): bool + { + return $this->bPrefilterEditsOnLogs; + } + + /** + * @param bool $bPrefilterEditsOnLogs + */ + public function SetPrefilterEditsOnLogs(bool $bPrefilterEditsOnLogs): void + { + $this->bPrefilterEditsOnLogs = $bPrefilterEditsOnLogs; + } + /** * @inheritdoc */ diff --git a/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php b/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php index 6dd7b91d6..7fe6197fa 100644 --- a/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php +++ b/sources/Application/UI/Base/Layout/NavigationMenu/NavigationMenu.php @@ -85,6 +85,9 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut protected $bIsExpanded; /** @var bool Whether the hint on how the menu filter works shoudl be displayed or not */ protected $bShowMenuFilterHint; + /** @var bool */ + protected $bShowMenusCount; + /** * NavigationMenu constructor. @@ -105,10 +108,13 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut ) { parent::__construct($sId); + $oConfig = MetaModel::GetConfig(); + $this->sAppRevisionNumber = utils::GetAppRevisionNumber(); $this->sAppSquareIconUrl = Branding::GetCompactMainLogoAbsoluteUrl(); $this->sAppFullIconUrl = Branding::GetFullMainLogoAbsoluteUrl(); - $this->sAppIconLink = MetaModel::GetConfig()->Get('app_icon_url'); + $this->sAppIconLink = $oConfig->Get('app_icon_url'); + $this->SetShowMenusCount($oConfig->Get('navigation_menu.show_menus_count')); $this->aSiloSelection = array(); $this->aMenuGroups = ApplicationMenu::GetMenuGroups($oAppContext->GetAsHash()); $this->oUserMenu = $oUserMenu; @@ -490,4 +496,21 @@ JS; { return "[data-role='".static::BLOCK_CODE."']"; } + + /** + * @return bool + */ + public function GetShowMenusCount(): bool + { + return $this->bShowMenusCount; + } + + /** + * @param bool $bShowMenusCount + */ + public function SetShowMenusCount(bool $bShowMenusCount): void + { + $this->bShowMenusCount = $bShowMenusCount; + } + } diff --git a/templates/base/layouts/activity-panel/activity-entry/layout.html.twig b/templates/base/layouts/activity-panel/activity-entry/layout.html.twig index d7fa10811..a302cabca 100644 --- a/templates/base/layouts/activity-panel/activity-entry/layout.html.twig +++ b/templates/base/layouts/activity-panel/activity-entry/layout.html.twig @@ -39,7 +39,7 @@ {% endif %} - {% if get_config_parameter('activity_panel.show_author_name_below_entries') %} + {% if oUIBlock.ShowAuthorNameBelowEntries() %} {% endif %}