From c1a7a36896dd3f6b771201dd02762171de0c820c Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 6 Apr 2020 09:02:06 +0200 Subject: [PATCH 1/6] Compatibility with MySQL 5.6 --- test/OQL/OQLToSQLTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/OQL/OQLToSQLTest.php b/test/OQL/OQLToSQLTest.php index d12b03f39..dec00c31e 100644 --- a/test/OQL/OQLToSQLTest.php +++ b/test/OQL/OQLToSQLTest.php @@ -341,6 +341,7 @@ class OQLToSQLTest extends ItopDataTestCase ); $aData = array( + "SELECT UNION 5.6" => array("SELECT `Organization` AS `Organization` WHERE ((`Organization`.`status` != 'inactive') AND (`Organization`.`id` = '1')) UNION SELECT `Organization` AS `Organization` WHERE ((`Organization`.`id` = '1') AND (`Organization`.`id` = '1'))", array(), array(), array(), null, null, 3, 0), "SELECT WebServer 150" => array("SELECT `WebServer` FROM WebServer AS `WebServer` WHERE 1", array(), array(), $aAttToLoad150, null, null, 3, 0), "SELECT WebServer 151" => array("SELECT `WebServer` FROM WebServer AS `WebServer` WHERE 1", array(), array(), array(), null, null, 3, 0), "SELECT L JOIN 176" => array("SELECT `L` FROM Location AS `L` JOIN Person AS `P` ON `P`.location_id = `L`.id WHERE 1", unserialize('a:1:{s:14:"L.friendlyname";b:1;}'), array(), null, null, 3, 0), From 5b60ec9edf85728379a3e9fc708ad7f83408df89 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 10 Apr 2020 18:11:36 +0200 Subject: [PATCH 2/6] =?UTF-8?q?N=C2=B02919=20-=20Dashboard=20-=20Fix=20das?= =?UTF-8?q?hboard=20not=20saved=20the=20sanitization=20was=20too=20strong.?= =?UTF-8?q?=20Some=20names=20can=20contain=20':'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ajax.render.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 07d75b609..f2930d174 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -1197,7 +1197,7 @@ EOF break; case 'dashboard_editor': - $sId = utils::ReadParam('id', '', false, 'element_identifier'); + $sId = utils::ReadParam('id', '', false, 'context_param'); $aExtraParams = utils::ReadParam('extra_params', array(), false, 'raw_data'); $aExtraParams['dashboard_div_id'] = utils::Sanitize($sId, '', 'element_identifier'); $sDashboardFile = utils::ReadParam('file', '', false, 'raw_data'); From 1f750bb12d3b342eb8d48abbca68a927c43bbecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Mon, 20 Apr 2020 14:06:14 +0200 Subject: [PATCH 3/6] =?UTF-8?q?N=C2=B02902=20Fix=20alias=20renaming=20when?= =?UTF-8?q?=20already=20exists=20in=20one=20OQL=20of=20an=20UNION=20The=20?= =?UTF-8?q?legacy=20impl=20is=20not=20modified?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobjectsearch.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index bff609535..8ee0863bb 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -223,9 +223,9 @@ class DBObjectSearch extends DBSearch public function RenameAlias($sOldName, $sNewName) { $bFound = false; - if (array_key_exists($sOldName, $this->m_aClasses)) + if (!array_key_exists($sOldName, $this->m_aClasses)) { - $bFound = true; + return false; } if (array_key_exists($sNewName, $this->m_aClasses)) { From 1b2d3d1e84b1c170a284222b1df7cdc9aff54bbc Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 21 Apr 2020 11:58:08 +0200 Subject: [PATCH 4/6] =?UTF-8?q?N=C2=B02952=20-=20Provisioning=20for=20hybr?= =?UTF-8?q?id=20auth=20fails=20Changed=20Origin=20for=20change=20to=20an?= =?UTF-8?q?=20allowed=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/loginwebpage.class.inc.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index 09eaa9073..8361a8904 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -790,12 +790,13 @@ class LoginWebPage extends NiceWebPage $oPerson = null; try { - $sOrigin = 'External User provisioning'; + CMDBObject::SetTrackOrigin('custom-extension'); + $sInfo = 'External User provisioning'; if (isset($_SESSION['login_mode'])) { - $sOrigin .= " ({$_SESSION['login_mode']})"; + $sInfo .= " ({$_SESSION['login_mode']})"; } - CMDBObject::SetTrackOrigin($sOrigin); + CMDBObject::SetTrackInfo($sInfo); $oPerson = MetaModel::NewObject('Person'); $oPerson->Set('first_name', $sFirstName); @@ -843,6 +844,14 @@ class LoginWebPage extends NiceWebPage $oUser = null; try { + CMDBObject::SetTrackOrigin('custom-extension'); + $sInfo = 'External User provisioning'; + if (isset($_SESSION['login_mode'])) + { + $sInfo .= " ({$_SESSION['login_mode']})"; + } + CMDBObject::SetTrackInfo($sInfo); + $oUser = MetaModel::GetObjectByName('UserExternal', $sAuthUser, false); if (is_null($oUser)) { From 1904bfdba633a1dd85e83d04a91168966ef1de61 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 21 Apr 2020 16:35:41 +0200 Subject: [PATCH 5/6] css-variables : update to 2.7.0-2 --- css/css-variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/css-variables.scss b/css/css-variables.scss index 524c792b0..76e3f6183 100644 --- a/css/css-variables.scss +++ b/css/css-variables.scss @@ -17,7 +17,7 @@ */ // Beware the version number MUST be enclosed with quotes otherwise v2.3.0 becomes v2 0.3 .0 -$version: "v2.7.0-1"; +$version: "v2.7.0-2"; $approot-relative: "../../../../../" !default; // relative to env-***/branding/themes/***/main.css // Base colors From 96d888fcf31707ffad74e5b3eecb2d79d01f9f90 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 28 Apr 2020 16:55:10 +0200 Subject: [PATCH 6/6] =?UTF-8?q?N=C2=B02968=20fix=20email-reply=20notificat?= =?UTF-8?q?ion=20not=20updated=20-=20add=20a=20specific=20container=20for?= =?UTF-8?q?=20attachments=20list,=20upload=20button=20and=20#attachment=5F?= =?UTF-8?q?plugin=20hidden=20input=20is=20outside=20of=20it=20-=20refactor?= =?UTF-8?q?=20code=20between=20abstract=20class=20and=20implementation,=20?= =?UTF-8?q?add=20some=20comments=20-=20now=20refreshes=20only=20the=20atta?= =?UTF-8?q?chment=20list=20instead=20of=20the=20whole=20content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itop-attachments/ajax.itop-attachment.php | 2 +- .../renderers.itop-attachments.php | 86 +++++++++++-------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/datamodels/2.x/itop-attachments/ajax.itop-attachment.php b/datamodels/2.x/itop-attachments/ajax.itop-attachment.php index 902922781..317482b08 100644 --- a/datamodels/2.x/itop-attachments/ajax.itop-attachment.php +++ b/datamodels/2.x/itop-attachments/ajax.itop-attachment.php @@ -46,7 +46,7 @@ function RenderAttachments(ajax_page $oPage, $iTransactionId) : AttachmentPlugIn::IsReadonlyState($oObject, $oObject->GetState(), AttachmentPlugIn::ENUM_GUI_BACKOFFICE); if ($bEditMode && !$bIsReadOnlyState) { - $oAttachmentsRenderer->RenderEditAttachmentsList($aAttachmentsDeleted); + $oAttachmentsRenderer->AddAttachmentsListContent(true, $aAttachmentsDeleted); } else { diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php index 8774a08f8..e39b61c06 100644 --- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php @@ -69,6 +69,14 @@ abstract class AbstractAttachmentsRenderer */ const MAX_SIZE_FOR_PREVIEW = 500000; + /** + * Attachments list container HTML id, that must be generated in {@link RenderEditAttachmentsList} + * + * @since 2.7.0-2 N°2968 ajax buttons (on especially the #attachment_plugin hidden input) should not be refreshed + * so we are refreshing only the content of this container + */ + const ATTACHMENTS_LIST_CONTAINER_ID = 'AttachmentsListContainer'; + /** @var \WebPage */ protected $oPage; /** @@ -129,13 +137,38 @@ abstract class AbstractAttachmentsRenderer } /** + * Can be overriden to change display order, but must generate an HTML container of ID {@link ATTACHMENTS_LIST_CONTAINER_ID} for JS refresh. + * * @param int[] $aAttachmentsDeleted Attachments id that should be deleted after form submission * - * @return string + * @return void will print using {@link oPage} */ - abstract public function RenderEditAttachmentsList($aAttachmentsDeleted = array()); + public function RenderEditAttachmentsList($aAttachmentsDeleted = array()) + { + $this->AddUploadButton(); - abstract public function RenderViewAttachmentsList(); + $this->oPage->add('
'); + $this->AddAttachmentsListContent(true, $aAttachmentsDeleted); + $this->oPage->add('
'); + } + + /** + * Generates the attachments list content + * + * @param bool $bWithDeleteButton + * @param array $aAttachmentsDeleted + * + * @throws \ArchivedObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MySQLException + */ + abstract public function AddAttachmentsListContent($bWithDeleteButton, $aAttachmentsDeleted = array()); + + public function RenderViewAttachmentsList() + { + $this->AddAttachmentsListContent(false, array()); + } protected function AddUploadButton() { @@ -154,9 +187,9 @@ abstract class AbstractAttachmentsRenderer $this->oPage->add_ready_script( <<tbody>tr[id^="display_attachment_"]>td input[name="removed_attachments[]"]'), aAttachmentsDeletedIds = aAttachmentsDeletedHiddenInputs.map(function() { return $(this).val() }).toArray(); $(sContentNode).block(); @@ -172,6 +205,8 @@ abstract class AbstractAttachmentsRenderer function(data) { $(sContentNode).html(data); $(sContentNode).unblock(); + + $('#attachment_plugin').trigger('add_attachment', [dataUpload.result.att_id, dataUpload.result.msg, false]); } ); } @@ -181,7 +216,17 @@ abstract class AbstractAttachmentsRenderer formData: { operation: 'add', temp_id: '$this->sTransactionId', obj_class: '$sClass' }, dataType: 'json', pasteZone: null, // Don't accept files via Chrome's copy/paste - done: RefreshAttachmentsDisplay, + done: function(e, data) { + if(typeof(data.result.error) != 'undefined') + { + if(data.result.error !== '') + { + alert(data.result.error); + return; + } + } + RefreshAttachmentsDisplay(data); + }, send: function(e, data){ // Don't send attachment if size is greater than PHP post_max_size, otherwise it will break the request and all its parameters (\$_REQUEST, \$_POST, ...) // Note: We loop on the files as the data structures is an array but in this case, we only upload 1 file at a time. @@ -325,16 +370,7 @@ JS; */ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer { - /** - * @param bool $bWithDeleteButton - * @param array $aAttachmentsDeleted - * - * @throws \ArchivedObjectException - * @throws \CoreException - * @throws \CoreUnexpectedValue - * @throws \MySQLException - */ - private function AddAttachmentsTable($bWithDeleteButton, $aAttachmentsDeleted = array()) + public function AddAttachmentsListContent($bWithDeleteButton, $aAttachmentsDeleted = array()) { if ($this->GetAttachmentsCount() === 0) { @@ -522,22 +558,4 @@ JS HTML ); } - - /** - * @inheritDoc - */ - public function RenderEditAttachmentsList($aAttachmentsDeleted = array()) - { - $this->AddUploadButton(); - - $this->AddAttachmentsTable(true, $aAttachmentsDeleted); - } - - /** - * @inheritDoc - */ - public function RenderViewAttachmentsList() - { - $this->AddAttachmentsTable(false); - } }