diff --git a/core/cmdbsource.class.inc.php b/core/cmdbsource.class.inc.php index 376b47664..39817aa85 100644 --- a/core/cmdbsource.class.inc.php +++ b/core/cmdbsource.class.inc.php @@ -29,100 +29,6 @@ use Combodo\iTop\Core\DbConnectionWrapper; require_once('MyHelpers.class.inc.php'); require_once(APPROOT.'core/kpi.class.inc.php'); -class MySQLException extends CoreException -{ - /** - * MySQLException constructor. - * - * @param string $sIssue - * @param array $aContext - * @param \Exception $oException - * @param \mysqli $oMysqli to use when working with a custom mysqli instance - */ - public function __construct($sIssue, $aContext, $oException = null, $oMysqli = null) - { - - if ($oException != null) - { - $aContext['mysql_errno'] = $oException->getCode(); - $this->code = $oException->getCode(); - $aContext['mysql_error'] = $oException->getMessage(); - } - else if ($oMysqli != null) - { - $aContext['mysql_errno'] = $oMysqli->errno; - $this->code = $oMysqli->errno; - $aContext['mysql_error'] = $oMysqli->error; - } - else - { - $aContext['mysql_errno'] = CMDBSource::GetErrNo(); - $this->code = CMDBSource::GetErrNo(); - $aContext['mysql_error'] = CMDBSource::GetError(); - } - parent::__construct($sIssue, $aContext); - //if is connection error, don't log the default message with password in - if (mysqli_connect_errno()) { - error_log($this->message); - error_reporting(0); - } - } -} - -/** - * Class MySQLQueryHasNoResultException - * - * @since 2.5.0 - */ -class MySQLQueryHasNoResultException extends MySQLException -{ - -} - -/** - * Class MySQLHasGoneAwayException - * - * @since 2.5.0 - * @see itop bug 1195 - * @see https://dev.mysql.com/doc/refman/5.7/en/gone-away.html - */ -class MySQLHasGoneAwayException extends MySQLException -{ - /** - * can not be a constant before PHP 5.6 (http://php.net/manual/fr/language.oop5.constants.php) - * - * @return int[] - */ - public static function getErrorCodes() - { - return array( - 2006, - 2013, - ); - } - - public function __construct($sIssue, $aContext) - { - parent::__construct($sIssue, $aContext, null); - } -} - -/** - * @since 2.7.0 N°679 - */ -class MySQLNoTransactionException extends MySQLException -{ - -} - -/** - * @since 2.7.8 3.0.3 3.1.0 N°5538 - */ -class MySQLTransactionNotClosedException extends MySQLException -{ - -} - /** * CMDBSource diff --git a/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php b/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php index 58caab5f8..1cad8d894 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php @@ -533,7 +533,7 @@ class ContextManipulatorHelper $sPPrivateKey = self::GetPrivateKey(); $oCrypt = new SimpleCrypt(MetaModel::GetConfig()->GetEncryptionLibrary()); - return base64_encode($oCrypt->Encrypt($sPPrivateKey, json_encode($aTokenRules))); + return self::base64url_encode($oCrypt->Encrypt($sPPrivateKey, json_encode($aTokenRules))); } /** @@ -566,7 +566,7 @@ class ContextManipulatorHelper { $sPrivateKey = self::GetPrivateKey(); $oCrypt = new SimpleCrypt(MetaModel::GetConfig()->GetEncryptionLibrary()); - $sDecryptedToken = $oCrypt->Decrypt($sPrivateKey, base64_decode($sToken)); + $sDecryptedToken = $oCrypt->Decrypt($sPrivateKey, self::base64url_decode($sToken)); $aTokenRules = json_decode($sDecryptedToken, true); if (!is_array($aTokenRules)) @@ -577,6 +577,13 @@ class ContextManipulatorHelper return $aTokenRules; } + private static function base64url_encode($sData) { + return rtrim(strtr(base64_encode($sData), '+/', '-_'), '='); + } + + private static function base64url_decode($sData) { + return base64_decode(str_pad(strtr($sData, '-_', '+/'), strlen($sData) % 4, '=', STR_PAD_RIGHT)); + } /** * @return string diff --git a/sources/Application/UI/Links/Indirect/BlockIndirectLinkSetEditTable.php b/sources/Application/UI/Links/Indirect/BlockIndirectLinkSetEditTable.php index a5854f8bb..85187862b 100644 --- a/sources/Application/UI/Links/Indirect/BlockIndirectLinkSetEditTable.php +++ b/sources/Application/UI/Links/Indirect/BlockIndirectLinkSetEditTable.php @@ -37,6 +37,7 @@ class BlockIndirectLinkSetEditTable extends UIContentBlock // Overloaded constants public const BLOCK_CODE = 'ibo-block-indirect-linkset-edit-table'; public const DEFAULT_JS_TEMPLATE_REL_PATH = 'application/links/indirect/block-indirect-linkset-edit-table/layout'; + public const DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH = 'application/links/indirect/block-indirect-linkset-edit-table/layout'; public const DEFAULT_JS_FILES_REL_PATH = [ 'js/links/links_widget.js', ]; @@ -327,20 +328,20 @@ EOF if ($iUniqueId > 0) { // Rows created with ajax call need OnLinkAdded call. // - $oP->add_ready_script( - <<add_ready_script( + <<oUILinksWidget->GetInputId()}.OnLinkAdded($iUniqueId, $iRemoteObjKey); EOF - ); + ); } else { // Rows added before loading the form don't have to call OnLinkAdded. // Listeners are already present and DOM is not recreated $iPositiveUniqueId = -$iUniqueId; - $oP->add_ready_script(<<add_ready_script(<<oUILinksWidget->GetInputId()}.AddLink($iPositiveUniqueId, $iRemoteObjKey); EOF - ); + ); } foreach ($this->oUILinksWidget->GetEditableFields() as $sFieldCode) { @@ -352,11 +353,11 @@ EOF $aFieldsMap[$sFieldCode] = $sSafeFieldId; $sValue = $oNewLinkObj->Get($sFieldCode); - $oP->add_ready_script( - <<add_ready_script( + <<oUILinksWidget->GetInputId()}.OnValueChange($iKey, $iUniqueId, '$sFieldCode', '$sValue'); JS - ); + ); } $sState = ''; diff --git a/templates/application/links/indirect/block-indirect-linkset-edit-table/layout.ready.js.twig b/templates/application/links/indirect/block-indirect-linkset-edit-table/layout.ready.js.twig new file mode 100644 index 000000000..f52b3cd6c --- /dev/null +++ b/templates/application/links/indirect/block-indirect-linkset-edit-table/layout.ready.js.twig @@ -0,0 +1,5 @@ +{# @copyright Copyright (C) 2010-2024 Combodo SAS #} +{# @license http://opensource.org/licenses/AGPL-3.0 #} +{% apply spaceless %} +oWidget{{ oUIBlock.oUILinksWidget.GetInputId() }}.RegisterChange(); +{% endapply %} \ No newline at end of file