Compare commits

...

1389 Commits

Author SHA1 Message Date
Molkobain
827a108a38 N°4252 - Force form modals to have a max height of 90% of the window's height to avoid overflowing from the viewport 2021-12-03 13:27:57 +01:00
Stephen Abello
4b50f5e1db N°4481 Fix caselog edition in transition 2021-12-03 11:34:52 +01:00
Stephen Abello
5b742c97c9 N°4481 Fix activity panel in printable object pages 2021-12-03 10:29:04 +01:00
Stephen Abello
16a2137777 N°4481 Fix printable object pages when using vertical tabs 2021-12-03 10:29:04 +01:00
Stephen Abello
e8316782aa N°4481 Fix double encoding for delete pages 2021-12-03 10:29:04 +01:00
Molkobain
edcf9e6a1e N°4498 - Introduce new APIs due to iPageUIExtension deprecation (#245)
* Introduce new APIs due to iPageUIExtension deprecation

* Fix typo in interface name

* Rename interface to more consistent names
2021-12-02 13:38:05 +01:00
Stephen Abello
7db97c6804 N°3835 Upload file name security hardening 2021-12-02 10:40:18 +01:00
Stephen Abello
f039d54a51 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	webservices/export-v2.php
2021-12-02 10:36:16 +01:00
Stephen Abello
dab0e372d0 N°4499 Security hardening 2021-12-02 10:32:29 +01:00
Stephen Abello
dc8c6ed7a9 N°3835 Tagsets displayed in history security hardening 2021-12-02 10:21:55 +01:00
Stephen Abello
18e341b0b7 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	application/displayblock.class.inc.php
#	js/search/search_form_criteria_enum.js
#	test/core/ormLinkSetTest.php
2021-12-02 10:04:04 +01:00
Stephen Abello
2722f305e0 Fix C3 scss variable 2021-12-02 09:59:12 +01:00
Stephen Abello
469e2e6e0e N°3835 Tagset's tooltip security hardening 2021-12-02 09:57:26 +01:00
Stephen Abello
05301d4191 N°3835 Dashlets' Pill label security hardening 2021-12-02 09:57:26 +01:00
Stephen Abello
3df5febd3e N°3835 Autocomplete security hardening 2021-12-02 09:57:26 +01:00
Stephen Abello
dfd1d5fe35 N°4493 Security hardening 2021-12-02 09:54:31 +01:00
Stephen Abello
d289457c0c N°4495 Security hardening 2021-12-02 09:39:10 +01:00
Stephen Abello
f52b3bff0d N°4492 Security hardening 2021-12-01 15:53:52 +01:00
Stephen Abello
b6b17733bf N°4491 Security hardening 2021-12-01 10:29:29 +01:00
acognet
fc2b00699e Change the name of the css class to a valid name 2021-12-01 09:00:07 +01:00
acognet
b00b08d08b Remove role="row" in tr This selector is not used 2021-12-01 08:56:21 +01:00
Molkobain
c02ea05883 Fix AttributePassword rendering in the backoffice 2021-11-30 16:25:55 +01:00
Molkobain
61a0028d02 Change welcome message to remove "responsive" mention to be honest with ourselves 🤡 2021-11-30 15:45:47 +01:00
acognet
c1c2d027c3 N°4402 - DbObject::ListPreviousValuesForUpdatedAttributes() returns new values for _list-attributes (at least in DbObject::AfterUpdate()) Fix test 2021-11-30 12:11:04 +01:00
acognet
5269096ecd Merge branch 'support/2.7' of github.com:Combodo/iTop into support/2.7 2021-11-29 15:07:14 +01:00
Molkobain
e6511e049a N°4283 - Fix textarea padding in some pages, also fix "Run query" parameters header 2021-11-29 10:26:41 +01:00
Pierre Goiffon
74fbd12709 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	datamodels/2.x/itop-portal-base/portal/src/Helper/ObjectFormHandlerHelper.php
#	datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
2021-11-26 17:24:41 +01:00
Pierre Goiffon
4db5d4c08d N°4213 Allow all AttributeSet impl to be saved in portal 2021-11-26 17:14:01 +01:00
Molkobain
c40394638a N°4252 - Fix bad initialization of DesignerFormField::$aCssClasses 2021-11-26 16:01:22 +01:00
Stephen Abello
cc2862837a Fix activity panel header links color 2021-11-26 15:52:48 +01:00
Stephen Abello
e27c6b1cd7 Allow Selectize input color css rules to be overloaded through iTop 3.0 themes 2021-11-26 15:52:48 +01:00
Stephen Abello
ae00686e58 Allow C3 css rules to be overloaded through iTop 3.0 themes 2021-11-26 15:52:48 +01:00
Pierre Goiffon
7934f9b9dc N°4213 Fix EnumSet modifications cannot be saved in portal 2021-11-26 15:25:30 +01:00
Molkobain
7f2eef4a24 Merge remote-tracking branch 'origin/support/2.6' into support/2.7 2021-11-26 13:59:29 +01:00
Molkobain
8a65a592f3 N°4360 - Rename class to match other classes convention 2021-11-26 13:47:05 +01:00
Pierre Goiffon
7d6b019cfa Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	sources/renderer/bootstrap/fieldrenderer/bslinkedsetfieldrenderer.class.inc.php
2021-11-26 11:45:11 +01:00
Pierre Goiffon
5e48400cb1 N°4478 Fix line selection (global and unique) not checking checkbox anymore 2021-11-26 11:44:32 +01:00
Pierre Goiffon
252562ace9 N°4478 Fix "Requested unknown parameter '' for row 0, column 0" when opening search on related object
Forgotten file :/
2021-11-26 11:08:25 +01:00
Pierre Goiffon
c9c32b0de1 Merge remote-tracking branch 'origin/support/2.6' into support/2.7 2021-11-26 10:58:30 +01:00
Pierre Goiffon
770ac8ffe5 N°4478 Fix "Requested unknown parameter '' for row 0, column 0" when opening search on related object 2021-11-26 10:58:17 +01:00
Molkobain
db137d3816 N°4283 - Fix spacing for Pills when wrapping
Also repalce some spacing with variables
2021-11-26 10:34:57 +01:00
Molkobain
77768e8400 N°4252 - Fix DesignerFormField CSS classes for better integration within the Designer 2021-11-26 09:24:36 +01:00
Molkobain
5621eb2191 SCSS: Center on both axis DesignerField apply/cancel buttons 2021-11-26 09:24:35 +01:00
Stephen Abello
2bf970932e N°3515 Add missing icon for default welcome dashboard 2021-11-26 08:50:40 +01:00
Pierre Goiffon
b6fac4b411 N°4384 Security hardening 2021-11-25 16:07:40 +01:00
Pierre Goiffon
d8a77c22a3 Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	datamodels/2.x/itop-portal-base/portal/public/lib/datatables/js/dataTables.fixedHeader.min.js
#	datamodels/2.x/itop-portal-base/portal/public/lib/datatables/js/dataTables.responsive.min.js
#	datamodels/2.x/itop-portal-base/portal/public/lib/datatables/js/dataTables.scroller.min.js
#	datamodels/2.x/itop-portal-base/portal/public/lib/datatables/js/dataTables.select.min.js
#	datamodels/2.x/itop-portal-base/portal/public/lib/datatables/js/jquery.dataTables.min.js
2021-11-25 15:33:52 +01:00
Stephen Abello
b75a495336 N°4283 Add more blocks to RenderAllUiBlocks.php 2021-11-25 11:39:14 +01:00
Pierre Goiffon
ed3c387712 N°4478 Update Datatables lib 2021-11-25 10:55:48 +01:00
Stephen Abello
bbadc1f0be Replace hardcoded font size with SCSS variables 2021-11-25 10:34:38 +01:00
Stephen Abello
a141db4737 N°4283 Fix some spacing/sizing issue on specific pages 2021-11-25 10:09:49 +01:00
Stephen Abello
cb67dd1f1c Fix French dict typo 2021-11-25 09:42:09 +01:00
Stephen Abello
af653608ef N°4283 Replace hardcoded spacing values by SCSS spacing variables 2021-11-24 17:02:48 +01:00
Stephen Abello
9dac061b04 N°4283 Centralize blocks spacing between each other in block-integration 2021-11-24 17:02:48 +01:00
Stephen Abello
ccf1bba235 N°4283 Introduce SCSS variables for size and spacing 2021-11-24 17:02:48 +01:00
Pierre Goiffon
312a5b246b N°4399 Fix memory error on setup when lots of attachment in DB 2021-11-24 16:55:34 +01:00
Pierre Goiffon
ddd6bf22af Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	core/attributedef.class.inc.php
#	core/config.class.inc.php
#	core/htmlsanitizer.class.inc.php
#	sources/Renderer/RenderingOutput.php
#	test/core/sanitizer/HTMLDOMSanitizerTest.php
#	test/integration/DictionariesConsistencyTest.php
2021-11-24 15:01:38 +01:00
acognet
903de43589 N°4402 - DbObject::ListPreviousValuesForUpdatedAttributes() returns new values for _list-attributes (at least in DbObject::AfterUpdate()) Add tests 2021-11-24 12:10:30 +01:00
Pierre Goiffon
2d67594ccf N°4213 Fix EnumSet rendering on details form in portal 2021-11-24 12:07:10 +01:00
Pierre Goiffon
0c7eee7f9c 💡 Add doc for why phpinfo ext is mandatory 2021-11-24 12:01:44 +01:00
Pierre Goiffon
65f9f86bcc N°3635 DictionariesConsistencyTest : now we can have multiple possible localized language desc
The 'Español, Castellaño' to 'Español, Castellano' was causing problem on builds with other modules that we don't want to update !
2021-11-23 18:59:10 +01:00
Pierre Goiffon
efaf53e568 Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	core/htmlsanitizer.class.inc.php
2021-11-23 18:07:02 +01:00
Pierre Goiffon
81a2a9278c N°4360 Fix SvgDOMSanitizer expected data 2021-11-23 17:38:30 +01:00
Pierre Goiffon
e15d4bfab6 N°4360 Security hardening 2021-11-23 17:25:50 +01:00
acognet
e23c41232d N°4465 - Polishing iTop 3.0 beta6 - fix "configure this list" 2021-11-23 15:34:53 +01:00
Stephen Abello
e25d070a38 N°4465 Fix tagset and enumset dropdown overflowing out of the screen and not autoplacing themselves 2021-11-23 13:33:08 +01:00
Stephen Abello
499c97b914 N°4465 Fix transition button not grouping/ungrouping in some cases 2021-11-23 11:51:31 +01:00
Molkobain
c472b8ad3b N°4466 - Fix line breaks not displayed correctly 2021-11-23 11:40:52 +01:00
Molkobain
94ceb98b9e N°4466 - Fix line breaks not displayed correctly 2021-11-23 11:32:26 +01:00
Stephen Abello
b1de8683f0 N°3523 Adjust buttons and links colors to make application more accessible 2021-11-23 11:26:16 +01:00
Stephen Abello
cff2105908 Remove debug line 2021-11-23 11:06:23 +01:00
Stephen Abello
e11d5c142c N°3523 Adjust buttons and links colors to make application more accessible 2021-11-23 10:39:11 +01:00
Molkobain
f77b3bedaf N°2370 - Change PHPDoc to reflect reality, method will not be removed 2021-11-23 10:15:28 +01:00
Molkobain
3654df1cae N°4466 - SCSS: Improve readability 2021-11-23 09:57:53 +01:00
Molkobain
f3d2e89c68 N°4466 - Revert changes that broke contraints for fields to stay in their column (d0f9868 and c9aa6938) 2021-11-23 09:40:33 +01:00
Molkobain
dd46536f7c N°4477 - Update dataTables lib. to 1.11.3 in iTop 3.0 2021-11-22 17:31:48 +01:00
Molkobain
e249907a9c N°4475 N°4408 - Fix update on external key not refreshing dependents fields 2021-11-22 16:45:35 +01:00
Eric Espie
4ded943a43 N°2527 - Fix require approot 2021-11-22 16:00:45 +01:00
Molkobain
bd52f4fefb N°4468 - Add data-resource-id meta-data on all buttons 2021-11-22 15:44:27 +01:00
Pierre Goiffon
f57785e422 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	datamodels/2.x/authent-local/dictionaries/es_cr.dict.authent-local.php
#	datamodels/2.x/itop-config-mgmt/dictionaries/es_cr.dict.itop-config-mgmt.php
#	datamodels/2.x/itop-knownerror-mgmt/dictionaries/es_cr.dict.itop-knownerror-mgmt.php
#	datamodels/2.x/itop-service-mgmt/dictionaries/es_cr.dict.itop-service-mgmt.php
#	datamodels/2.x/itop-tickets/dictionaries/es_cr.dict.itop-tickets.php
#	datamodels/2.x/itop-welcome-itil/es_cr.dict.itop-welcome-itil.php
#	dictionaries/es_cr.dictionary.itop.ui.php
#	test/integration/DictionariesConsistencyTest.php
2021-11-22 09:08:34 +01:00
Pierre Goiffon
77880c3675 🌐 N°3635 ES dict : change 'Español, Castellaño' to 'Español, Castellano' 2021-11-22 08:55:08 +01:00
Molkobain
bb369e68b5 N°4283 - Rename some SCSS partials to match conventions 2021-11-20 18:52:54 +01:00
Molkobain
2a2d68e204 N°4283 - Textarea: Make sure to use monospace font for code
- CSV import is now using monospace font
- Simplify SCSS code

Note: TextArea and all input UIBlocks need to be reworked as they are not properly organized, see comment in _input-text.scss
2021-11-20 18:42:41 +01:00
Molkobain
b49fbf1a97 N°4283 - Textarea: Make them take all available width 2021-11-20 18:12:41 +01:00
Molkobain
308bff7875 SCSS: Fix typo in variable name 2021-11-20 14:23:13 +01:00
Molkobain
9444e61856 N°4283 - Improve spacing of HTML inputs with their labels 2021-11-19 18:35:50 +01:00
Molkobain
2f114701a1 N°4283 - AttributeOneWayPassword: Fix spacing between the fields / button 2021-11-19 17:40:48 +01:00
Molkobain
5128db05cf N°4283 - AttributeBlob: Fix extra between the value and the links / input 2021-11-19 17:39:54 +01:00
Molkobain
9675202bb2 N°4283 - Force field labels to wrap even if it is a single giant word 2021-11-19 17:09:23 +01:00
Molkobain
cbe42cd727 N°4283 - Improve textarea and OQL inputs style
- All textarea app. wide avec the same padding
- OQL fields have the same padding as the other textareas
- OQL fields have the monospaced font
2021-11-19 16:34:01 +01:00
Pierre Goiffon
3559425fc1 N°°4463 Trigger : remove user rights check when controlling filter 2021-11-19 15:20:21 +01:00
Molkobain
a246528eec Update DoPostRequest() in itoprest.examples.php to fix optional headers like in utils::DoPostRequest 2021-11-19 14:47:51 +01:00
Stephen Abello
7fbbf1088a N°4460 Fix SCSS variable usage 2021-11-19 12:22:08 +01:00
Molkobain
fa4a5e2990 Merge spanish translations and remove duplicated files due to merge 2021-11-19 11:49:48 +01:00
Molkobain
b662a7e3c6 Remove (some) redundant description in spanish translations 2021-11-19 11:49:36 +01:00
Stephen Abello
cdc452282e Fix dictionnary entries 2021-11-19 11:38:08 +01:00
Molkobain
d8c4251c03 Remove (some) redundant description in spanish translations 2021-11-19 11:27:46 +01:00
Stephen Abello
72d1ab5cbc N°3523 Add accessibility to silo selection and user menu toggler 2021-11-19 11:16:19 +01:00
Stephen Abello
18b8e7093a N°3515 Update Enclosure icon (thanks to icons8 quick response ❤️) 2021-11-19 11:16:19 +01:00
Stephen Abello
aedb9ccbba N°3525 Make colors more accessible 2021-11-19 11:16:18 +01:00
Pierre Goiffon
67fa156c0e Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	application/dashboard.class.inc.php
#	core/action.class.inc.php
#	datamodels/2.x/combodo-db-tools/dictionaries/es_cr.dict.combodo-db-tools.php
#	datamodels/2.x/itop-attachments/dictionaries/es_cr.dict.itop-attachments.php
#	datamodels/2.x/itop-config-mgmt/dictionaries/es_cr.dict.itop-config-mgmt.php
#	datamodels/2.x/itop-core-update/dictionaries/es_cr.dict.itop-core-update.php
#	datamodels/2.x/itop-hub-connector/dictionaries/es_cr.dict.itop-hub-connector.php
#	datamodels/2.x/itop-knownerror-mgmt/dictionaries/es_cr.dict.itop-knownerror-mgmt.php
#	datamodels/2.x/itop-portal-base/dictionaries/es_cr.dict.itop-portal-base.php
#	datamodels/2.x/itop-request-mgmt-itil/dictionaries/es_cr.dict.itop-request-mgmt-itil.php
#	datamodels/2.x/itop-request-mgmt/dictionaries/es_cr.dict.itop-request-mgmt.php
#	datamodels/2.x/itop-sla-computation/dictionaries/es_cr.dict.itop-sla-computation.php
#	datamodels/2.x/itop-storage-mgmt/dictionaries/es_cr.dict.itop-storage-mgmt.php
#	datamodels/2.x/itop-tickets/dictionaries/es_cr.dict.itop-tickets.php
#	datamodels/2.x/itop-virtualization-mgmt/dictionaries/es_cr.dict.itop-virtualization-mgmt.php
#	datamodels/2.x/itop-welcome-itil/es_cr.dict.itop-welcome-itil.php
#	dictionaries/es_cr.dictionary.itop.core.php
#	dictionaries/es_cr.dictionary.itop.ui.php
#	pages/ajax.render.php
#	setup/wizardsteps.class.inc.php
#	synchro/synchro_import.php
2021-11-19 10:28:46 +01:00
Pierre Goiffon
9437e689fd N°3635 Update ES translations
Many thanks to Miguel Turrubiates !
2021-11-18 17:48:43 +01:00
Pierre Goiffon
a79459bc53 N°4162 Portal exception page : restore exception message
Was removed with Silex to Symfony migration
2021-11-18 14:56:17 +01:00
Pierre Goiffon
500bd15843 Merge remote-tracking branch 'origin/support/2.6' into support/2.7 2021-11-18 08:54:32 +01:00
Pierre Goiffon
3e8dd2f4a5 N°4286 Setup : fix loop in first steps
Setup token wasn't removed at the right place :/
2021-11-18 08:54:10 +01:00
Pierre Goiffon
d0fade9ce1 Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	pages/ajax.render.php
#	setup/wizardsteps.class.inc.php
2021-11-17 17:39:36 +01:00
Pierre Goiffon
51a49dfce8 Remove warnings, use finally block, formatting 2021-11-17 16:10:50 +01:00
Molkobain
db8462ccc9 N°2788 - Constraint table to fit as much as possible in its column 2021-11-17 15:55:01 +01:00
Pierre Goiffon
066b71686d N°4286 Setup : restore backup download on WizStepDone
Setup token was put with N°2016 (6b5cc7c)
But later on we refactored the token handling in SetupUtils methods, and we had token removal in WizStepDone (43daa2ef) : so the backup download cannot be done :/
2021-11-17 14:39:44 +01:00
Pierre Goiffon
be633001a5 Revert "N°4360 Security hardening"
This reverts commit 8adf743cc7.

We will implement a different solution later (hopefully for 2.6.5 / 2.7.6 / 3.0.0 as well)
2021-11-17 11:13:29 +01:00
Molkobain
b0904cabfd N°4447 - Update german translations thanks to Martin Raeker from @itomig-de ! 2021-11-17 10:26:12 +01:00
Pierre Goiffon
84426c6634 N°4365 Security hardening 2021-11-17 10:15:12 +01:00
Molkobain
9d19c189e6 N°4420 N°4421 - Decrease transition duration a bit to match other transitions feeling 2021-11-16 22:41:42 +01:00
Molkobain
91d030933b Rename cmdbAbstractObject::EnumDisplayMode() to be consistent with the rest 2021-11-16 21:38:51 +01:00
Molkobain
d0f9868a19 N°2788 - Constraint table with <pre> to fit as much as possible in its column 2021-11-16 18:20:31 +01:00
Molkobain
2a913cd484 Restore prototypes of cmdbAbstractObject methods in which we added $sMode to preserve compatibility with existing extensions (#240)
* Restore prototypes of cmdbAbstractObject methods in which we added $sMode to preserve compatibility with existing extensions

* Rename cmdbAbstractObject::ENUM_OBJECT_MODE_XXX

* Add cmdbAbstractObject::ENUM_OBJECT_MODE_BULK_EDIT

* Refactor usage of $sDisplayMode in cmdbAbstractObject::DisplayModifyForm()
2021-11-16 17:47:09 +01:00
Pierre Goiffon
dbaf924171 N°4363 Security hardening 2021-11-16 17:19:19 +01:00
Pierre Goiffon
1b2d75efd6 N°4420 N°4421 Table selectable lines : restore style, restore script inclusion in object edition (#242) 2021-11-16 16:05:07 +01:00
Stephen Abello
d66a1e8c10 N°3515 Update some classes/dashboard icons to match 3.0 UI 2021-11-16 15:21:53 +01:00
Molkobain
a5ad981d70 N°4408 - Fix visual glitches on transition buttons in object details 2021-11-16 14:42:32 +01:00
Pierre Goiffon
8adf743cc7 N°4360 Security hardening 2021-11-16 12:01:16 +01:00
Molkobain
4e544a8eab Object details: Fix header buttons being too close to the right border when editing with a sticky header 2021-11-15 18:42:11 +01:00
Pierre Goiffon
75450ded1d N°4359 Security hardening 2021-11-15 16:38:11 +01:00
Molkobain
2b97fed5db Fix unclosed TWIG tag in toolbar spacer 2021-11-15 16:24:41 +01:00
Molkobain
62d8a2ba1f Fix crash in activity panel when entry user is unknown 2021-11-15 16:24:41 +01:00
acognet
fe9a442500 N°4370 - Field content overlapping on rest of the UI (Backoffice) - 2 2021-11-15 15:48:51 +01:00
acognet
11d2991286 N°4417 - Fix portal user not seeing support agent avatar on caselog in portal 2021-11-15 15:36:03 +01:00
Pierre Goiffon
bcca6ac720 Merge remote-tracking branch 'origin/support/2.6' into support/2.7 2021-11-15 15:07:19 +01:00
Molkobain
abb63182e3 N°4346 - Fix operator 2021-11-15 12:08:28 +01:00
Molkobain
4409162eb7 N°2875 - Fix mentions not working with some non url encoded "markers" (eg. '#') 2021-11-14 22:53:10 +01:00
Molkobain
0dc3d249da N°3526 - Clean up pass on UIBlocks
- Add ancestors CSS classes on UIBlocks when missing (programmatically)
- Fix SCSS due to some blocks inheriting their ancestors rules
2021-11-14 22:33:48 +01:00
Molkobain
3598da8808 N°3526 - Clean up pass on UIBlocks
- Move UIBlock::ENUM_BLOCK_FILES_TYPE_XXX to iUIBlock
- Add PHPDoc
- Remove Object return type hint on overloadable methods
- Add scalar return type hint
- Add type hint on parameters
2021-11-14 22:33:48 +01:00
Molkobain
a9b30e160f N°3526 - Clean up pass on UIBlockFactories
- Add PHPDoc
- Remove (Object) return type hint on overloadable methods
2021-11-14 22:33:48 +01:00
Stephen Abello
249fa6ca93 N°3515 Update some classes icon to match 3.0 UI 2021-11-13 11:57:00 +01:00
acognet
50d73e7fca N°4346 - Restore HTML metadata (data-xxx) on lists in the backoffice 2021-11-12 11:20:48 +01:00
Molkobain
1b9e67dc6e SCSS: Fix Quick Create / Global Search drawers being slightly visible when closed and with a full history 2021-11-11 11:09:40 +01:00
Molkobain
ca2124130f N°3517 - Clean-up pass on all block factories 2021-11-10 19:51:59 +01:00
Molkobain
fffd4cf962 N°4346 - Remove duplicated loop and factorize code 2021-11-10 19:12:14 +01:00
Molkobain
4a6b351c37 N°4440 - Fix hierarchy tooltip on ext. key widget 2021-11-10 18:49:25 +01:00
Molkobain
206143824b N°4408 - Improve transition buttons UX in object details
Transition buttons are now grouped in the "Apply" button when there is not enough space to display them all
2021-11-10 18:44:25 +01:00
Molkobain
90c866f696 N°4427 - Fix bouncing results in search page 2021-11-09 19:22:50 +01:00
vdumas
0bbdbdb1cd N°3735 revert typo fix on Known Error module as it would remove the module on all iTop having it installed today 2021-11-09 18:03:11 +01:00
Stephen Abello
395c9c288b N°4355/1745 Prevent malformed caselog entries from breaking activity panel DOM 2021-11-09 16:19:16 +01:00
acognet
60a17c9a65 N°4406 - Warning: Missing constant ITOP_DESIGN_LATEST_VERSION 2021-11-09 15:20:42 +01:00
acognet
2de6ba2827 N°3928 - Polishing: Impact analysis 2021-11-09 15:18:08 +01:00
Pierre Goiffon
2beb795f9a N°4304 Security hardening 2021-11-09 11:32:53 +01:00
Pierre Goiffon
6847d8a5c7 N°4414 Startup error handler : fix message logged twice (#243) 2021-11-09 10:25:29 +01:00
Stephen Abello
f6885567eb N°4408 Add correct CSS class to console renderer richtext field 2021-11-09 09:49:37 +01:00
Stephen Abello
4b888a3805 N°4378 Restore keyboard shortcuts behavior for object details 2021-11-09 09:49:37 +01:00
odain
07f470024a N°4367 : renamed the phpunit annotation for ci purpose 2021-11-09 08:55:54 +01:00
Molkobain
4c69865480 N°2875 - Fix error when trigger has an OQL on a root class which is not abstract 2021-11-08 19:21:43 +01:00
Pierre Goiffon
06985d3cf2 N°4387 synchro_import restore previous set_time_limit call
Was changed in b1761e04 (iTop 2.7.0) by mistake

Added noinspection as the IDE warning (https://github.com/kalessil/phpinspectionsea/blob/master/docs/control-flow.md#statement-could-be-decoupled-from-foreach) seems to be a false positive ?
2021-11-08 16:14:19 +01:00
acognet
ab40c67678 N°4346 - Restore HTML metadata (data-xxx) on lists in the backoffice - after configure this list 2021-11-08 15:02:45 +01:00
odain
a286564345 N°4367 : add phpunit annotation for ci 2021-11-08 06:42:45 +01:00
Stephen Abello
c9e592c07d N°3904 Avoid restore buttons from asking for confirmation multiple times 2021-11-05 15:51:04 +01:00
denis.flaven@combodo.com
5bcdcb52b2 N°4534 - creation of a new category 'filter' to hide admins to
non-admins without breaking legacy code.
2021-11-05 11:29:41 +01:00
Pierre Goiffon
456283866c ✏️ Fix typo in code comment 2021-11-05 11:24:18 +01:00
Stephen Abello
821c14ee86 N°3904 Fix scheduled backups not being restorable from user interface 2021-11-05 10:28:09 +01:00
Stephen Abello
30f1ad8da8 N°4412 Activity panel's notification entries weren't expandable since c0fc62b 2021-11-05 10:07:30 +01:00
vdumas
6d0b979bcd N°3735 revert one part of the previous commit done by mistake 2021-11-04 17:58:49 +01:00
Pierre Goiffon
e16425ab8a Revert behavior change in \UserRights::FindUser v2
Was made in 2ab0fab0 by mistake, committed incorrectly in 2e426d37 (wooops)
2021-11-04 17:28:06 +01:00
Pierre Goiffon
2e426d373d Revert behavior change in \UserRights::FindUser
Was made in 2ab0fab0 by mistake
2021-11-04 17:26:09 +01:00
vdumas
a1a38ca224 N°3735 Add missing translation for older methods 2021-11-04 17:10:17 +01:00
vdumas
05830de4e7 N°3735 Add Method Parameters translation for ITSM Designer 2021-11-04 16:42:10 +01:00
Pierre Goiffon
2e8920f3d1 N°4367 Fix \privUITransactionFileTest::testIsTransactionValid
Was crashing because of limitations on loading User objects
2021-11-04 16:15:01 +01:00
Stephen Abello
4450c28295 N°4408 Prevent dependent field from being triggered twice 2021-11-04 16:02:51 +01:00
Stephen Abello
aa43201cbe N°4408 Do not display non-interpreted HTML when richtext fields are loading 2021-11-04 16:02:51 +01:00
Eric Espie
3d7df7600f N°4346 - Restore HTML metadata (data-xxx) on lists in the backoffice 2021-11-04 14:56:06 +01:00
Stephen Abello
aba0d4144c N°4408 Fix inputs flickering when widgets are loading 2021-11-04 10:49:17 +01:00
Stephen Abello
fe82f54066 N°4396 Fix graphs not displaying anymore in Dashboard Attribute 2021-11-03 15:26:33 +01:00
Pierre Goiffon
2d44d9d1c6 N°4367 disable test for now
On develop we have an error on Jenkins :
> Login with user2 throw an error
2021-11-03 15:19:42 +01:00
Molkobain
8c03525fbb N°2875 - Fix missing argument ":this" when submitting an entry in the activity panel 2021-11-03 12:01:20 +01:00
Eric Espie
79c17970f8 Fix tests on packages missing composer.json file 2021-11-03 11:31:43 +01:00
Pierre Goiffon
04f7660267 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	js/utils.js
2021-11-03 11:19:23 +01:00
Pierre Goiffon
8c7f7abaab Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	test/application/privUITransactionFileTest.php
2021-11-03 11:10:43 +01:00
Eric Espie
e963a6741f N°3985 - avoid sql request for notifications in case of object creation and avoid reloads on requesting triggers 2021-11-03 11:00:41 +01:00
Pierre Goiffon
e8d314e1f6 N°4367 Fix \privUITransactionFileTest::testIsTransactionValid
* change user name for when password policy is active
* admin user doesn't exist on Jenkins : create a second user
* test UserRights::Login return value
* document that we depend on the sample data
2021-11-03 10:50:25 +01:00
Molkobain
ebe493f7f7 Set attribute: Add tooltip on items when attribute is in edition 2021-11-02 18:48:03 +01:00
Pierre Goiffon
e29f1825be N°4367 Fix "redeclaration of const CombodoSanitizer"
The utils.js can be included more than once in old iTop branches :( This is fixed in 3.0.0 (develop branch)

Also add missing ";"
2021-11-02 17:14:16 +01:00
vdumas
2df8bb1707 N°3735 - Add SetComputedDate on DBObject 2021-11-02 16:55:25 +01:00
Eric Espie
27995c14bf N°3985 - avoid sql request for history in case of object creation 2021-11-02 15:35:51 +01:00
Molkobain
890d0f64ce Add @ilya-stukalov to the constributors, thanks! 2021-11-01 18:18:17 +01:00
Vladimir Kunin
a29bb83a20 Fix typos 2021-10-29 18:27:04 +02:00
Vladimir Kunin
413820a22b Update general UI translations: many typos & errors, "iTop" replaced by constant ITOP_APPLICATION_SHORT, add new & improve existing strings. 2021-10-29 18:27:04 +02:00
Vladimir Kunin
860472beea Update CMDBChangeOp UI translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
dd4283199e Update NavigationMenu translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
e147aa31aa Add KeyboardShortcuts translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
b8aa3dfb0c Update Activity panel translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
83e2dbc30a Update Newsroom translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
f63dad7a3a Update tab container translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
c75bb6b892 Update Navigation Menu translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
15ffb82257 Update preferences translations 2021-10-29 18:27:04 +02:00
Vladimir Kunin
5e2ae18570 Typo 2021-10-29 18:27:04 +02:00
ilya.stukalov
070a23e61b Add UI translations for iTop 3.0. 2021-10-29 18:27:04 +02:00
acognet
0ab6655ae7 N°4385 - MetaModel::GetRelatedObjectsUp does yield correct results, while DBObject->GetRelatedObjectsUp does not 2021-10-29 13:36:32 +02:00
acognet
322371dd9f N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-29 13:33:44 +02:00
Molkobain
b8e974cfd1 N°4398 - Add object name in the tab name when browsing datamodel viewer 2021-10-28 15:58:32 +02:00
odain
e03eb1e279 N°3556: fix broken ci temporarly for test using ItopDataTestCase 2021-10-28 11:48:14 +02:00
bruno-ds
6d2b75df9e N°4261 - test correctness: log deactivation is performed using bool false and not Error level
thanks @BenGrenoble
2021-10-26 15:54:44 +02:00
Stephen Abello
ab1b6837a2 N°3800 Fix line spacing in rich text editor and in its displayed content 2021-10-26 15:26:29 +02:00
Stephen Abello
5c02b5c38c N°4396 Fix graphs not displaying anymore in Dashboard Attribute 2021-10-26 10:50:32 +02:00
Stephen Abello
dd486dd015 N°3911 Fix datamodel viewer table overflowing in some case 2021-10-26 10:11:12 +02:00
Molkobain
b7e8c0de8a N°4400 - Restore PHP debug output being displayed in a modal 2021-10-25 21:34:03 +02:00
Molkobain
32dae59b9b N°4400 - Move inline JS functions to corresponding JS file 2021-10-25 19:51:07 +02:00
acognet
5540988001 N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-25 15:50:43 +02:00
Stephen Abello
f8c59e6171 N°3911 Allow datamodel viewer graph to be horizontally scrolled when overflowing out of page 2021-10-25 15:35:33 +02:00
acognet
ab23ea1da0 N°3928 - Polishing: Impact analysis 2021-10-25 14:12:11 +02:00
Molkobain
3d49cd199a Fix Panel not being collapsible anymore (regression from 1c11cef2f, thanks @accognet !) 2021-10-25 12:15:02 +02:00
denis.flaven@combodo.com
ee848129b7 New methods for creating/import test data from XML files. 2021-10-25 11:49:56 +02:00
Molkobain
63448276cc Tooltips: Add possibility to define theme through meta-data 2021-10-24 11:12:07 +02:00
Stephen Abello
d5af6e9061 N°4319 Backup page datatable no longer grow off limits, even on Chrome, also fix restore button 2021-10-22 14:39:30 +02:00
Molkobain
2fc3e7ad38 N°2875 - Fix empty mention results when host object is being created 2021-10-22 13:23:24 +02:00
Stephen Abello
465ed58471 N°4319 Backup page datatable no longer grow off limits 2021-10-22 10:35:43 +02:00
Eric Espie
fac454595a removing meaningless information 2021-10-22 10:10:14 +02:00
acognet
89ea4adbce N°4366 - RCSS in /pages/ajax.searchform.php on develop 2021-10-21 17:15:27 +02:00
bruno-ds
427f107ddf N°4261 - Fix CI and add a test case 2021-10-21 17:04:08 +02:00
Pierre Goiffon
59d674d744 Fix broken export
Argument 1 passed to Combodo\iTop\Controller\AjaxRenderController::ExportBuild() must be an instance of Combodo\iTop\Controller\ajax_page, instance of AjaxPage given,

Caused by merge of support/2.7 with 2 conflicts on the same line (347cbca5)
2021-10-21 17:03:36 +02:00
Molkobain
54db7243bf N°2875 - Restore correct app. version check in the module installer 🥶 2021-10-21 16:36:41 +02:00
Eric Espie
e6d2b0bc18 N°4346 - Restore HTML metadata (data-xxx) on lists in the backoffice 2021-10-21 16:18:57 +02:00
bruno-ds
9e1f5a1b63 N°4261 - ExceptionLog restore Portal log level to Error as for iTop 2.7 (no more BC break)
- default level is now Error,
 - for "write in DB": each level (including error) are ignored by default
2021-10-21 16:18:27 +02:00
Stephen Abello
5b42b8983a N°3515 Update some classes icon to match 3.0 UI 2021-10-21 16:00:18 +02:00
Molkobain
5bae964064 Setup: Fix spacing between module's label and module's more info link 2021-10-21 15:58:19 +02:00
Molkobain
ef9c18e393 Fix setup crash on upgrade when env-production / data/cache-production have been deleted (missing dict files) 2021-10-21 15:16:15 +02:00
Pierre Goiffon
ed43d00afe Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	application/transaction.class.inc.php
#	core/userrights.class.inc.php
2021-10-21 15:12:23 +02:00
Pierre Goiffon
908a48e0a1 Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	application/transaction.class.inc.php
#	test/application/privUITransactionFileTest.php
2021-10-21 15:09:50 +02:00
Pierre Goiffon
9b854dbcc7 N°4289 skip test (not working on Jenkins) 2021-10-21 14:52:59 +02:00
Pierre Goiffon
7757f1f2d2 N°4289 Security hardening 2021-10-21 12:43:03 +02:00
bruno-ds
5e2f8a4ea6 N°4261 - ExceptionLog: improve readability 2021-10-21 11:07:44 +02:00
bruno-ds
62f7eca0a8 N°4261 - Log in db: change default level.
In order to preserve the existing behavior: not EventIssue creation (unless configured otherwise).
2021-10-21 11:07:44 +02:00
Stephen Abello
820f2cbed6 N°4015 Set a minimum height for last tab in scrollable mode and allow customizing tabs minimum height in themes 2021-10-21 10:37:38 +02:00
bruno-ds
d03718681f N°4261 - Log in db: change default configuration.
As since the latest changes by Pir, the default value is handled directly in the class.
2021-10-21 10:11:26 +02:00
Pierre Goiffon
a353317746 N°4289 Fix privUITransactionFile generating error if MetaModel not loaded 2021-10-20 17:26:32 +02:00
Pierre Goiffon
723eb90160 N°4289 privUITransactionSession phpDoc 2021-10-20 17:25:58 +02:00
Pierre Goiffon
0e14be8b15 N°4261 Refactor ExceptionLog (#239)
Doing a code review with Bruno, we agreed to do some little refactoring :

* Level per exception class
  - Before the whole ExceptionLog::Log method was a total rewrite of its parent, with some code duplicates... not a good idea : we should better improve LogAPI to make other similar uses possible in the future !
  - The logic to get level from config must be in a GetMinLogLevel override
* Write to DB
  - Pull up this functionnality in LogAPI
  - Add a sCode parameter in GetLevelDefault

Doing this refactoring, I also improved :

* Test the attributes set when creating the EventIssue object : during my dev I had crashes because I didn't filled all the mandatory fields... Having a PHPUnit test checking this will prevent future bugs to happen if attributes are modified in the class or in the object creation method
* Use Throwable instead of Exception : this was added in PHP 7.0 and will allow to catch both Exception and Error
* Because we need to have 2 statements on the same line in \Combodo\iTop\Test\UnitTest\Core\Log\ExceptionLogTest::testLogInFile, I modified the editorConfig file to allow disabling the formatter using comments.
2021-10-20 16:01:08 +02:00
Pierre Goiffon
ef6d7925fc Log : always log the same structure, and add a delimiter at the end
This will allow to parse the logs more easily !
2021-10-20 15:16:57 +02:00
acognet
ec8c2ca122 N°4374 - Add sanitizer helper for front end (JS) - Rollback 2021-10-20 10:31:41 +02:00
acognet
ebe50b319a N°4357 - Autocomplete issue with accent in a list 2021-10-20 10:31:40 +02:00
Eric Espie
48b1a15bf7 N°4369 - updated autoloader 2021-10-20 09:52:32 +02:00
Eric Espie
5102400be4 N°4369 - Return product and version in status rest ws 2021-10-20 08:52:25 +02:00
Molkobain
4bde828dbb 🌐 N°2875 - Fix missing word in TriggerOnObjectMention:mentioned_filter(+) thanks to @jbostoen 2021-10-19 21:36:23 +02:00
Eric Espie
e0929f4d0d N°4375 - Change CKEditor plugins init 2021-10-19 17:16:17 +02:00
Eric Espie
ef1903dabe N°4369 - Return product and version in status rest ws 2021-10-19 16:20:06 +02:00
Molkobain
e53a45ec5d N°2875 - Update config. param. 2021-10-19 15:40:42 +02:00
Molkobain
0811fd4aa7 N°2875 - Default triggers/action are created during first install/upgrade of 3.0.0 for DM classes with a log attribute in order to allow Person mention out of the box 2021-10-19 15:16:43 +02:00
Molkobain
cdf5789d62 N°2875 - Add $bRootFirst param. to MetaModel::EnumChildClasses() to be iso with MetaModel::EnumParentClasses() 2021-10-19 15:16:43 +02:00
Molkobain
8f2b5ad8e2 N°2875 - Invert TriggerOnObjectMention approach
- Trigger is now positioned on a specific "host" class (eg. Ticket)
- Trigger now has a "mentioned objects" filter which determines the scope of mentioned objects which will activate the trigger
2021-10-19 15:16:42 +02:00
Molkobain
df49e9c3b5 N°2875 - Add class icon to Trigger and Action 2021-10-19 15:16:42 +02:00
Molkobain
6915b0b824 N°2875 - RichText: Fix config property being an array instead of a string (also add a setter) 2021-10-19 15:16:42 +02:00
Molkobain
0b0c99c935 🌐 N°2875 - Add TriggerOnObjectMention:mentioned_filter(+) translations 2021-10-19 15:16:42 +02:00
Molkobain
b9a68f4aeb 🌐 N°2875 - Add TriggerOnObject:filter description
Note: The new translations are based on the russian one as it seemed pretty good, hence the russian translation is not "reset".
2021-10-19 15:16:41 +02:00
Eric Espie
c611b11981 N°4369 - About box with reduced information for non-administrators 2021-10-19 14:52:57 +02:00
Stephen Abello
25763c2d2e N°4351 Fix case log own entries overflowing when unnecessary 2021-10-19 14:49:44 +02:00
acognet
c8f3d23d30 N°4361 - XSS in csvimport on develop 2021-10-19 11:32:05 +02:00
acognet
88fda1466e N°4374 - Add sanitizer helper for front end (JS) 2021-10-19 11:26:29 +02:00
Eric Espie
8a7f0d346d N°4375 - Change CKEditor plugins init 2021-10-19 11:04:33 +02:00
acognet
3e5440aa3b N°3928 - Polishing: Impact analysis - remove icons in pdf list 2021-10-19 10:19:41 +02:00
acognet
6f08038f34 N°4347 - Fix JS errors in custom dashboards for list dahslets 2021-10-19 09:50:53 +02:00
Pierre Goiffon
216e62c448 N°4367 Replace uses of utils.js EncodeHtml() 2021-10-19 08:48:58 +02:00
Eric Espie
f4856150ed N°4375 - Upgrade to CKEditor 4.16.2 2021-10-19 08:46:58 +02:00
Pierre Goiffon
d73d39e71a utils.js : deprecate EncodeHtml and copy it to CombodoSanitizer.EscapeHtml 2021-10-19 08:43:27 +02:00
Pierre Goiffon
6abdabd197 Removing config file writing in OQL PHPUnit tests (#238) 2021-10-18 16:37:24 +02:00
Pierre Goiffon
020460d048 N°4367 update test to use new utils constants 2021-10-18 15:24:10 +02:00
Pierre Goiffon
347cbca5cf Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	application/transaction.class.inc.php
#	application/ui.extkeywidget.class.inc.php
#	composer.json
#	composer.lock
#	js/utils.js
#	lib/composer/InstalledVersions.php
#	lib/composer/installed.json
#	lib/composer/installed.php
#	lib/pear/archive_tar/Archive/Tar.php
#	lib/pear/archive_tar/package.xml
#	setup/wizardsteps.class.inc.php
#	sources/Controller/AjaxRenderController.php
2021-10-18 14:57:19 +02:00
Pierre Goiffon
8ea5be4ead Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	application/transaction.class.inc.php
2021-10-18 14:32:27 +02:00
Pierre Goiffon
b3f827ed5e N°4367 Security hardening 2021-10-18 14:27:58 +02:00
Pierre Goiffon
eaf8a187aa N°3332 report function rename
The method was renamed in 18d52319 but only on support/2.7 and above
2021-10-18 11:36:17 +02:00
Pierre Goiffon
34f64c61f6 privUITransaction fix inspections errors + formatting 2021-10-18 11:32:38 +02:00
acognet
1d28bbe3f4 N°3928 - Polishing: Impact analysis 2021-10-18 11:15:22 +02:00
Molkobain
54c89dcbb5 PHPDoc 2021-10-14 18:03:27 +02:00
acognet
06dac2417a Rollback N°4361 - XSS in csvimport on develop 2021-10-14 16:25:16 +02:00
acognet
83125d9ae1 N°4362 - XSS in ajax.render.php?operation=wizard_helper on develop 2021-10-14 15:46:46 +02:00
odain
20f4419062 ci: add phpunit annotation to exclude/include test 2021-10-14 14:26:07 +02:00
acognet
0f4ca4237d N°4362 - XSS in ajax.render.php?operation=wizard_helper on develop 2021-10-14 10:14:01 +02:00
acognet
bc2c12a8c3 N°3928 - Polishing: Impact analysis 2021-10-14 09:31:21 +02:00
Pierre Goiffon
8154e718a1 N°4356 modifications after code review
Thanks @Molkobain !
2021-10-13 17:23:29 +02:00
Eric Espie
9ec6c2098b N°3928 - Fix iTop logo 2021-10-13 17:21:44 +02:00
Eric Espie
4305e40ae5 Fix warning 2021-10-13 17:15:58 +02:00
Pierre Goiffon
0f149ed852 N°4381 remove old deprecations.md file
Content wasn't up to date
Check the wiki instead (https://www.itophub.io/wiki/page?id=3_0_0%3Ainstall%3A270_to_300_migration_notes)
2021-10-13 16:50:27 +02:00
Pierre Goiffon
d5f9ca9c4b N°4381 CONTRIBUTING : move badge image 2021-10-13 16:48:11 +02:00
Pierre Goiffon
198c63dd79 N°4381 Replace documentation/itop-tickets.htm by a wiki link
Page wasn't maintained anymore
A link was displayed at the end of the setup
2021-10-13 16:40:06 +02:00
acognet
96ae91494b N°3928 - Polishing: Impact analysis 2021-10-13 14:25:55 +02:00
acognet
ceaa98f4ef N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-13 14:25:38 +02:00
acognet
af4b9aaa52 N°4370 - Field content overlapping on rest of the UI (Backoffice) - 2 2021-10-13 14:25:23 +02:00
acognet
d2662b608b N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-13 14:12:23 +02:00
Molkobain
591d189a33 N°3935 - Increase size a bit 2021-10-13 13:36:08 +02:00
Molkobain
36bea54bac N°3935 - Improve transition form UI with different style for cancel button and wider inputs 2021-10-13 13:11:11 +02:00
Pierre Goiffon
b5369a0c03 N°4356 Fix portal attachment download
Was opening the attachment directly in the browser (HTTP header Content-Disposition set to 'inline' instead of 'download')
2021-10-13 12:10:22 +02:00
Molkobain
1c11cef2f8 N°3939 - Keep current tab when editing an object (regression from 1e99ad436) 2021-10-12 21:51:51 +02:00
Molkobain
d8bd5528d3 Merge remote-tracking branch 'origin/support/3.0.0-beta5' into develop 2021-10-12 20:11:36 +02:00
Molkobain
9ed8cf7970 Setup: Ease usage of the UI when zoomed up to 150% (licenses fieldset being too height) 2021-10-12 18:44:47 +02:00
Molkobain
be24d409ed Config: Move security.hide_administrators parameter with other security.xxx parameters 2021-10-12 18:01:56 +02:00
Molkobain
64d91b194f PHPDoc 2021-10-12 18:01:45 +02:00
Eric
2bc61caab1 N°4207 N°4298 Fix data/.maintenance flag not removed by setup anymore
Was already fixed in the develop branch
(cherry picked from commit d0986c048a)
(cherry picked from commit 9126635cf2)
2021-10-12 12:23:49 +02:00
Pierre Goiffon
8f0a5fcaf9 N°4231 Security hardening 2021-10-12 11:11:11 +02:00
Eric Espie
b6df73bdcc N°2527 - Fix dependencies 2021-10-12 09:04:52 +02:00
Eric Espie
836a35d0dd N°4352 - Fix unlock message 2021-10-12 08:55:59 +02:00
acognet
c7a7bfcd68 N°3928 - Polishing: Impact analysis 2021-10-12 08:17:50 +02:00
Molkobain
e7e09b5023 N°4372 - Fix AttributeText limited dimensions in fullscreen when height/width is defined in the DM 2021-10-11 18:08:52 +02:00
Molkobain
3f24b80043 Code cleanup 2021-10-11 18:00:33 +02:00
Pierre Goiffon
fe3512cb5f N°4335 Fix export with PHP < 7.0+ 2021-10-11 17:05:30 +02:00
acognet
2a32c5691b N°4370 - Field content overlapping on rest of the UI (Backoffice) - 2 2021-10-11 16:17:19 +02:00
acognet
dce244f5aa N°4370 - Field content overlapping on rest of the UI (Backoffice) - 2 2021-10-11 15:28:37 +02:00
acognet
63bd1643ce N°4370 - Field content overlapping on rest of the UI (Backoffice) - 2 2021-10-11 09:11:38 +02:00
acognet
3c84a74ea4 N°4357 - Autocomplete issue with accent in a list 2021-10-11 09:09:59 +02:00
acognet
d9870c2513 N°4361 - XSS in csvimport on develop 2021-10-11 09:09:13 +02:00
acognet
7f0493c91d N°3928 - Polishing: Impact analysis 2021-10-07 18:11:04 +02:00
acognet
26e32b1759 Remove console.log 2021-10-07 14:04:22 +02:00
acognet
1b1a6321d7 N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-07 14:04:22 +02:00
acognet
0eba00259a N°3928 - Polishing: Impact analysis 2021-10-07 11:45:53 +02:00
denis.flaven@combodo.com
a7a9e5f0eb N°4354 - Fixed the test which was using a (now fixed) edge case! 2021-10-06 18:45:41 +02:00
denis.flaven@combodo.com
bf4835eec0 N°4354 - Hide Administrator profile to non-admins 2021-10-06 15:34:23 +02:00
acognet
9fbc631b07 N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-05 14:18:28 +02:00
acognet
c6cb7c41cd N°4349 - Drop-down mandatory template field documented still required in modification 2021-10-05 11:47:45 +02:00
acognet
0cb1583688 N°1731 - Allow Transitions without unnecessary confirmation - add force_transition_confirmation param 2021-10-05 11:36:08 +02:00
acognet
370b42d1fd N°3835 - Make global pass on all inputs (objects, dashlets, ...) to ensure XSS and double encoding have been dealt with 2021-10-04 17:28:05 +02:00
Eric Espie
0da8c761c7 N°2527 - Manage hierarchical keys in database maintenance tools 2021-10-04 16:26:16 +02:00
Eric Espie
8c39374abb N°2527 - Manage hierarchical keys in database maintenance tools 2021-10-04 16:23:35 +02:00
acognet
eb239843aa N°4347 - Fix JS errors in custom dashboards for list dahslets 2021-10-04 15:57:17 +02:00
acognet
e38ca54691 N°3835 - Make global pass on all inputs (objects, dashlets, ...) to ensure XSS and double encoding have been dealt with 2021-10-04 15:57:17 +02:00
Eric Espie
f9fc85e763 N°4326 - Fix error in dashboard when no tooltip exist on Pill
(cherry picked from commit 6caf78fdcd)
2021-10-04 11:27:14 +02:00
Eric Espie
94d99a4109 N°2527 - Manage hierarchical keys in database maintenance tools 2021-10-04 11:25:20 +02:00
Eric Espie
f39e801719 N°2527 - Manage hierarchical keys in database maintenance tools 2021-10-04 11:24:30 +02:00
acognet
645f20742c N°3934 - Polishing: User Preferences 2021-10-04 11:00:23 +02:00
acognet
d86065b4a6 N°3934 - Polishing: User Preferences 2021-10-04 10:01:10 +02:00
Molkobain
8af54efd44 N°4068 - Object details: Avoid image attributes to overlap other attributes when they are very large
- Keep its width contained in the column
- Maintain aspect ratio of the container div to hint the user on which size the image should be
- Keep image real size as long as it fits in the container
2021-10-02 10:25:19 +02:00
Molkobain
c96ee4fafc Fix typo 2021-10-01 18:30:03 +02:00
Molkobain
ced4d1c5f1 Fix dictionary entry verbal form 2021-10-01 18:28:24 +02:00
acognet
6d3e8df3e4 N°3934 - Polishing: User Preferences 2021-10-01 18:22:17 +02:00
acognet
963fae243c N°3835 - Make global pass on all inputs (objects, dashlets, ...) to ensure XSS and double encoding have been dealt with 2021-10-01 18:22:17 +02:00
Molkobain
5a09365221 N°3925 - External key: Use more vertical space when possible (30% of the window tops) and fit within the window if not enough space (below or above the input) 2021-10-01 17:38:55 +02:00
Eric Espie
49c5f75c6c N°3520 - Fix static datatables rows 2021-10-01 15:18:29 +02:00
Molkobain
bd67bc8838 N°3882 - Handle use of transparent colors in dynamic header dashlet 2021-10-01 11:48:05 +02:00
Molkobain
c9aa693872 AttributeSet: Avoid items' label to wrap on display in the backoffice (regression from 42be0c20) 2021-10-01 09:37:51 +02:00
acognet
776c03ef6a fix loading of ckeditor 2021-10-01 09:15:34 +02:00
Molkobain
ae6f8fba5c N°3520 - Add missing data-role on UIBlocks 2021-09-30 22:07:39 +02:00
Molkobain
a139dc7e6e N°3520 - HTML metadata: Add data-role to backoffice logos 2021-09-30 21:31:27 +02:00
Molkobain
7d46626d9c N°3520 - HTML metadata: Add object state in object details if present 2021-09-30 21:30:56 +02:00
Molkobain
9ea25188ba N°3925 - Fix state flags not taken into account correctly by a child class (regression from f2ff5a4e) 2021-09-30 19:41:56 +02:00
Molkobain
fadafa8267 N°3925 - Fix stimulus not applied after submission of multiple logs in an object (read-only) 2021-09-30 19:13:33 +02:00
Molkobain
e0d6bc18be N°3925 - Improve display of long external keys in autocomplete / dropdowns
- Show ellipsis if label is overflowing
- Show tooltip on hover (useful for overflowing labels)
2021-09-30 19:13:33 +02:00
Molkobain
2ae01c19e1 Advanced search: Fix checkbox / label alignment on multi choices criteria 2021-09-30 17:49:33 +02:00
Stephen Abello
a5e2831e31 N°3931 Allow HTML in DataTables' Panel title 2021-09-30 15:53:40 +02:00
acognet
e86454ff74 N°3912 - Polishing: Export 2021-09-30 15:06:21 +02:00
acognet
62be3f9f58 fix loading of ckeditor 2021-09-30 15:06:21 +02:00
acognet
cddbe27182 N°4315 - Polish bulk modify screens 2021-09-30 15:06:21 +02:00
Stephen Abello
1f56e39577 N°3931 Make object deletion errors more visible 2021-09-30 15:01:30 +02:00
Stephen Abello
a35c80de57 Align FormTable row metadata forwarding with Datatables/StaticTables ones 2021-09-30 15:01:29 +02:00
Eric Espie
4b8ef4f919 N°3572 - Fix Data Integrity tab results display
- fix synchrodatasource SQL definitions
- fix Hierarchical keys warnings due to bad parameters
2021-09-30 14:53:00 +02:00
Pierre Goiffon
c3d23981fb 💡 Document limitation in \LogAPI::GetConfig 2021-09-30 14:45:06 +02:00
Pierre Goiffon
9c6d8253f4 Fix \Combodo\iTop\Test\UnitTest\Core\CMDBSourceTest::testIsOpenedDbConnectionUsingTls 2021-09-30 10:49:11 +02:00
acognet
4d6a8a76aa N°3904 - Polishing: Backup 2021-09-30 10:20:11 +02:00
Pierre Goiffon
8fa6ae6703 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	core/cmdbsource.class.inc.php
2021-09-30 09:51:13 +02:00
Pierre Goiffon
fdc987f367 Merge remote-tracking branch 'origin/support/2.7.5' into support/2.7 2021-09-29 17:51:17 +02:00
Eric Espie
be9bb10606 N°4339 - Fix page title for object creation 2021-09-29 17:03:53 +02:00
Eric Espie
11d3d5af49 N°3908 - Fix button location (moved to the right of the screen) 2021-09-29 15:56:52 +02:00
Eric Espie
b630492d7a N°4337 - Fix "Missing TWIG template" error 2021-09-29 15:16:13 +02:00
Eric Espie
1a1439946b N°4338 - Fix indirect links removal 2021-09-29 14:32:01 +02:00
Molkobain
1db32c6dee N°4315 - Cleanup in SCSS 2021-09-29 14:21:24 +02:00
Eric Espie
dade45308c N°4332 - Fix table name 2021-09-29 11:30:07 +02:00
acognet
b1597f7d90 recompile styles 2021-09-29 11:24:09 +02:00
acognet
e2904fb0ee N°4230 - Printable version issues 2021-09-29 11:21:00 +02:00
acognet
8dbbc9a124 N°4315 - Polish bulk modify screens 2021-09-29 11:21:00 +02:00
bruno-ds
4297b854e1 N°4034 - Add the get_module_setting function to TwigBase.
This is temporary, as in the 3.1, this file will be deprecated in favor of `sources/application/TwigBase/Twig/Extension.php`.
More info in the N°4034.
2021-09-29 10:58:23 +02:00
Eric Espie
c53c1d5b9c N°4332 - Fix table name 2021-09-29 10:33:46 +02:00
Molkobain
a3db7f0e83 Merge remote-tracking branch 'origin/support/3.0.0-beta5' into develop 2021-09-29 10:18:53 +02:00
Stephen Abello
157c031236 N°4296 Correctly unescape dashboard title tooltip when switching dashboard 2021-09-29 10:15:57 +02:00
denis.flaven@combodo.com
78b1ee04e8 N°4336 - Improve tooltip pertinence, by hiding useless entries 2021-09-28 18:17:16 +02:00
Molkobain
30da7d2ea4 Add deprecated annotations on duplicated TwigExtension files to ease choose for developers 2021-09-28 17:38:59 +02:00
denis.flaven@combodo.com
d467cb5c79 N°4078 - Use the icon AND tooltip when the hyperlink is put as 'shortcut' 2021-09-28 17:25:35 +02:00
Eric Espie
142699c3b1 N°4332 - Fix table prefix 2021-09-28 17:14:05 +02:00
Eric Espie
9dcb789cfd N°3908 - Polishing: Application Upgrade - move the buttons at the bottom 2021-09-28 17:04:08 +02:00
Stephen Abello
aac504ec0b N°3917 Fix object details icon cover method when using class highlight icon as object icon 2021-09-28 16:25:47 +02:00
denis.flaven@combodo.com
a7a7ce77fb N°4096 - Automatic email sending retry in case of error. 2021-09-28 15:42:28 +02:00
Eric Espie
6caf78fdcd N°4326 - Fix error in dashboard when no tooltip exist on Pill 2021-09-28 15:07:27 +02:00
Stephen Abello
5680d9579c N°3917 Refactor algorithm to get object details semantic image icon in object's GetIcon method in order to propagate this feature anywhere where GetIcon is called 2021-09-28 15:01:06 +02:00
Molkobain
ec47645ef7 Merge branch 'support/3.0.0-beta5' into develop 2021-09-28 12:58:08 +02:00
Molkobain
4c6a7ca30b N°3791 - Fix crash when displaying object with a null state value 2021-09-28 12:51:21 +02:00
Molkobain
a70acf29ae Simplify double if condition 2021-09-28 12:35:02 +02:00
Eric Espie
57b08b5b24 N°4328 - Fix XML version 2021-09-28 10:10:10 +02:00
Molkobain
90906912cc N°3556 - Fix CaptureWebPage not retrieve parts from UIBlocks 2021-09-28 10:09:43 +02:00
Eric Espie
3064d868b7 N°4328 - Fix Overview tab displayed before object creation 2021-09-28 10:01:03 +02:00
Eric Espie
548d08b1ec N°4332 - Merge multi-LDAP module into iTop 2021-09-28 09:10:26 +02:00
denis.flaven@combodo.com
f226916bb8 N°4078 - Use the icon when the hyperlink is put as 'shortcut' 2021-09-27 19:06:46 +02:00
Eric Espie
47fcddc9a6 N°4326 - Fix external keys in dynamic header dashlet 2021-09-27 17:35:52 +02:00
Molkobain
86b03b9e92 Set back @covers annotation 2021-09-27 17:34:48 +02:00
acognet
9811d6f8ea N°3912 - Polishing: Export 2021-09-27 15:08:04 +02:00
Eric Espie
f67f3eaf74 N°4326 - Fix unknown attribute when no state attcode is given 2021-09-27 14:43:12 +02:00
odain
0b4d4764bd ci testing: use proper annotation to include/exlude test linked to composer.json 2021-09-27 11:57:25 +02:00
acognet
580deb655d Remove unused tablesorter 2021-09-27 09:25:20 +02:00
acognet
5e2bfdf660 N°3912 - Polishing: Export 2021-09-27 09:23:52 +02:00
Molkobain
0d51dc61f9 N°4001 - Fix double title & extra space on object creation failure page 2021-09-26 22:37:41 +02:00
Molkobain
9949b1b11a N°4318 - Improve large field limits visualization with scrollbar's track color 2021-09-26 22:27:18 +02:00
Molkobain
8be141f692 N°3791 - Replace all hard-coded style colors in the DM with corresponding semantic / palette colors 2021-09-26 17:45:18 +02:00
Molkobain
a11bc9ad33 N°3791 - Enable use of SCSS variables in the DM classes / (meta)enum attributes style 2021-09-26 16:53:42 +02:00
Molkobain
3214ae91c7 N°3791 - Panel: Use style defined in the DM for classes
Note that for now, semantic colors cannot be used directly in a <main_color> or <complementary_color> tag. Only valid CSS color (hexa, hsla, ...)
2021-09-26 15:15:34 +02:00
Molkobain
21545da062 Rename Panel / Alert / Button color constants for something more accurate
Done now before their as used too widely. We are most likely to allow dev. to use custom colors soon, so we want to avoid confusing / renaming then. (iTop extensions have been verified, none had to be migrated)
2021-09-26 01:26:42 +02:00
Molkobain
7476b6d059 Button group: Fix button groups always being on a new line instead of staying in the flow 2021-09-26 01:22:53 +02:00
Molkobain
b15c8e30bc N°3791 - Panel: Use style defined in the DM for classes
Note that for now, semantic colors cannot be used directly in a <main_color> or <complementary_color> tag. Only valid CSS color (hexa, hsla, ...)
2021-09-26 01:17:28 +02:00
Molkobain
39d71c9c43 N°3882 - Pill: Fix default color scheme when in a panel 2021-09-26 00:51:04 +02:00
Molkobain
75d913a003 Compiler: Factorize DM classes style and add them to the DM CSS rules 2021-09-25 23:51:52 +02:00
Molkobain
2b38c98183 Compiler: Update unit tests for DM classes / (meta)enum attributes style 2021-09-25 23:27:29 +02:00
Molkobain
ca7f6362bf ormStyle: Fix icon URL including the app. root in the MetaModel to ease usage with load balancers 2021-09-25 17:00:50 +02:00
Molkobain
4d8ac5fee5 PHPDoc 2021-09-25 17:00:50 +02:00
acognet
938de4c71c N°3787 - Use data loader for auto refresh 2021-09-24 17:28:52 +02:00
Pierre Goiffon
3ff117596d 💡 N°4325 add phpdoc 2021-09-24 17:16:59 +02:00
Molkobain
194459e0de Breadcrumbs: Harmonize spacing with other top bar elements 2021-09-24 17:04:55 +02:00
Molkobain
95179b0c18 Dashboard: Fix multi-select field padding on selected values 2021-09-24 17:02:53 +02:00
Molkobain
d76c9cee6f N°3900 - Breadcrumbs: Better fix than 7ae4fe06e 2021-09-24 17:02:53 +02:00
odain
6e45b74665 Composer: Fix required versions => rename cover annotation 2021-09-24 15:01:08 +02:00
acognet
3d8259a083 N°3923 - Polishing: External key 2021-09-24 15:00:32 +02:00
Molkobain
6d8a36e061 N°3882 - Fix null status color when class has no style defined 2021-09-24 14:54:29 +02:00
acognet
814038f5fd recompile styles 2021-09-24 12:12:14 +02:00
acognet
f237b4dd30 N°3705 - Migrate module to new UIBlock system : Kanban board - fix z-index of selectize dropdown list 2021-09-24 12:05:09 +02:00
Pierre Goiffon
4cf4c0e4c3 ♻️ N°4325 refactor CMDBSource mysqli attributes to a separate wrapper class (#237)
In 2.7.5 with N°3513 we added a second mysqli attribute in CMDBSource, so that we can test transactions (see TransactionsTest).

But this wasn't documented, and was really causing confusion !

This refactor wraps both attributes in a dedicated object so that the logic is clearer.
2021-09-24 11:45:39 +02:00
Stephen Abello
86538cf88e Add metadata to legacy search elements 2021-09-24 10:53:02 +02:00
acognet
722cae240e align style of spinner 2021-09-24 10:09:02 +02:00
acognet
f0d3149a1c N°3787 - Use data loader for auto refresh 2021-09-24 10:09:02 +02:00
Stephen Abello
92e315e2c7 Re-dump autoloader since 7c7386a broke it -- with platform check enabled 2021-09-24 10:04:37 +02:00
Stephen Abello
6150881154 Re-dump autoloader since 7c7386a broke it 2021-09-24 09:31:34 +02:00
Molkobain
cf223b583e N°3882 - Protection against ormStyle being null for an object 2021-09-24 09:04:24 +02:00
Molkobain
eb5e5591d7 N°4326 - Improve robustness of DesignerComboField::SetAllowedValues() 2021-09-23 22:25:57 +02:00
Molkobain
dcf4053c30 Setup: Improve components' licenses display 2021-09-23 21:46:36 +02:00
Molkobain
fedc3d4d76 N°3556 - Fix JS dict. entries not available in SetupPage anymore 2021-09-23 21:46:36 +02:00
Molkobain
e93c0123aa PHPDoc 2021-09-23 18:12:52 +02:00
Molkobain
0004586779 N°4327 - Fix JS "ReferenceError" in Application Upgrade 2021-09-23 17:40:48 +02:00
Molkobain
7ae4fe06ed N°3900 - Breadcrumbs: Fix all items being hidden even when they should not (when browser's window is zoomed in/out) 2021-09-23 16:41:12 +02:00
Pierre Goiffon
ec1dcc8df6 💡 N°3513 PHPDoc 2021-09-23 14:42:16 +02:00
Pierre Goiffon
47ed863da9 N°4215 N°3513 Fix DB errors fetch from the wrong object n°2 2021-09-23 14:32:43 +02:00
Molkobain
7404599721 N°3882 - Fix unit tests 2021-09-23 14:16:22 +02:00
Pierre Goiffon
88290f9e91 N°4215 N°3513 Fix DB errors fetch from the wrong object 2021-09-23 13:55:23 +02:00
Molkobain
eb8aed19c2 Code cleanup 2021-09-23 13:10:23 +02:00
Molkobain
3a05e9159d PHPDoc 2021-09-23 12:29:34 +02:00
Pierre Goiffon
cfdbc8ae62 N°4215 When checking for TLS cnx, don't set anymore CMDBSource mysql attributes ! 2021-09-23 11:59:44 +02:00
Molkobain
99026cec1f N°3882 - Compiler: Prepare unit test for DM CSS rules (needs to be completed with the team) 2021-09-23 11:44:12 +02:00
Molkobain
029d2ad526 N°3882 - Compiler: Factorize AttributeEnum/AttributeMetaEnum style compilation 2021-09-23 11:44:12 +02:00
Molkobain
1cb100b010 N°3882 - Header dynamic: Pills now shows the real color from the DM 2021-09-23 11:44:12 +02:00
Molkobain
197864ff83 N°3882 - Object details: Status indicator (dot) now shows the real state color 2021-09-23 11:44:11 +02:00
Molkobain
1e73ee8ccd N°3882 - Refactor display of field badges (meta enums / enums) in lists to match original mockups 2021-09-23 11:44:11 +02:00
Molkobain
e2b73995e1 N°3882 - Move DataModel classes fields' style to theme instead of (duplicated) inline CSS 2021-09-23 11:44:11 +02:00
Molkobain
24cedbdebd PHPDoc 2021-09-23 11:44:11 +02:00
Molkobain
0dc95f93a9 Code conventions 2021-09-23 11:44:10 +02:00
Molkobain
b6bd7fe400 Portal: Remove deprecated message for ItopExtensionsExtraRoutes as there is no alternative yet.
YAML routes can only be declared by the core, not modules.
2021-09-23 11:44:10 +02:00
acognet
03a19ab3f4 N°2573 - Remove MetaModel::GetNextKey 2021-09-23 11:36:10 +02:00
Stephen Abello
50849ae4ea N°4315 Harmonize bulk modify screen with other bulk actions 2021-09-23 11:34:54 +02:00
Stephen Abello
70d7f576f3 N°4001 Remove empty lines from tag set tooltips 2021-09-23 10:31:06 +02:00
acognet
bf491b7298 recompile styles 2021-09-23 09:30:30 +02:00
acognet
40ec7e35fd N°4245 - Using customfield in notifications triggered by TriggerOnObjectUpdate via ApplyStimulus 2021-09-23 09:20:33 +02:00
acognet
ffe5541361 N°2259 - iTop Compilation of branding images ignore real format of source image 2021-09-23 09:19:55 +02:00
acognet
73c55748d7 N°3904 - Polishing: Backup 2021-09-23 09:19:54 +02:00
acognet
0754dda1d9 N°3905 - Polishing: CSV Import 2021-09-23 09:19:54 +02:00
acognet
057bea196e Fix setTitleBlock 2021-09-23 09:19:54 +02:00
acognet
e97a266c44 N°3946 - LogAPI : log config parameters aren't used when logging in the setup wizard context 2021-09-23 09:19:54 +02:00
Eric Espie
b4278a6987 Supportability: Add UserId in EventIssue if 'userinfo' field is empty 2021-09-23 08:25:32 +02:00
Pierre Goiffon
aaa8f6d311 N°4215 Fix call to a function on null error when setting TLS connection in the setup
Regression introduced by b1ca1f2630 / N°3513
2021-09-22 15:59:39 +02:00
Stephen Abello
50f860a0e8 N°3974 When editing an object, align fields synchro icons 2021-09-22 15:05:17 +02:00
Stephen Abello
198c9ed479 N°4296 When switching dashboard, update dashboard title tooltip with new value 2021-09-22 14:03:57 +02:00
Stephen Abello
6e076ae1fa N°3911 Fix HTML content in external key tooltip not showing 2021-09-22 13:49:48 +02:00
Stephen Abello
9d44f0982c N°3911 Fix spacing between attribute label and attribute code 2021-09-22 13:49:44 +02:00
Molkobain
fd933ce49a N°4245 - Temporary partial rollback 2021-09-22 13:34:13 +02:00
odain
ae0c43a099 N°4227 - enhance cli restore feedback when backup file not accessible 2021-09-22 11:42:27 +02:00
Stephen Abello
7c7386afc7 N°3851 Update Emogrifier to a version supporting iTop PHP versions range 2021-09-21 16:45:12 +02:00
bruno-ds
c306c6e30d N°4261 - code review with @PirGoif 2021-09-21 16:38:10 +02:00
Molkobain
d9ccac3aea Composer: Fix required versions of PHP in order to keep our package constraints up-to-date 2021-09-21 16:12:22 +02:00
Eric Espie
d8316734e2 N°4305 - n-n links to same class - Be more robust on original search given to ormLinkSet 2021-09-21 15:46:20 +02:00
Molkobain
7ac5c1bbbb Composer: Fix target PHP version in platform to the min. supported version.
Having this set to the minimum supported version ensure that when packages versions are retrieved/updated, only versions compatible with this PHP version are selected.
2021-09-21 15:22:56 +02:00
Molkobain
37585614ba Branding: Cleanup of old references since refactoring of logos compilation 2021-09-21 15:12:05 +02:00
Molkobain
03b728b394 PHPDoc 2021-09-21 14:38:43 +02:00
Pierre Goiffon
ae2072f4d5 N°3002 Get developer_mode.enabled config param first normally, and if not set from disk 2021-09-21 13:56:15 +02:00
Molkobain
2f6ed8f8af Code conventions 2021-09-21 13:37:35 +02:00
Molkobain
1f5dabf8f6 Code conventions 2021-09-21 13:36:11 +02:00
Stephen Abello
eb5cdb053e Fix unsanitized table id 2021-09-21 12:10:53 +02:00
Pierre Goiffon
25ee577eba 💡 phpdoc 2021-09-21 12:07:37 +02:00
Pierre Goiffon
f0aaf21a79 💚 N°3002 Fix php-mock-objects notices
The error handler now checks if logger is enabled before doing anything
2021-09-21 12:01:42 +02:00
acognet
a906086751 recompile styles 2021-09-21 11:18:40 +02:00
acognet
ab17eaad27 N°4260 - Fix display of log attributes in list 2021-09-21 10:57:47 +02:00
Molkobain
469c1553bf Fix typo in icon filename 2021-09-21 10:45:04 +02:00
Pierre Goiffon
4f72f8be0c N°4158 developer_mode.enabled config param is now always read from disk
If no config file on disk then will return default value
Was failing in the compilation process as during a moment we have in MetaModel a Config instance only containing data from params, and without previous params that were on disk :/
2021-09-21 10:37:17 +02:00
Pierre Goiffon
5f2323f10b N°4092 Symlinks flag : now always update the flag
Before this commit we were only creating/removing the flag is the functionnality was available : but this was causing confusions !
2021-09-21 10:36:07 +02:00
Eric Espie
98013a68a4 N°4305 - n-n links to same class - Fix fatal error when original set is already provided with the target class 2021-09-21 10:23:30 +02:00
Stephen Abello
f55193604c N°3929 Fix carets on dashboard editor's select fields 2021-09-21 10:00:24 +02:00
Stephen Abello
586b8c5c71 N°3929 Fix apply/undo button on specific dashboard editor fields 2021-09-21 09:58:34 +02:00
Molkobain
a771d35197 N°3685 - Fix missing C3 lib in a dashboard menu node 2021-09-21 09:51:25 +02:00
Molkobain
96e4ef68df Code conventions 2021-09-21 09:38:01 +02:00
Molkobain
df40b53b6b Code format 2021-09-21 09:24:26 +02:00
acognet
6d4f919519 Refactor -> create utils::AddParamToUrl - renaming of function + encode parameters 2021-09-20 17:29:50 +02:00
Molkobain
8af116275c Change use of "sizeof()" by "count()" to avoid confusion 2021-09-20 17:02:06 +02:00
Eric Espie
e930d34963 N°4305 - n-n links to same class - Fix aliases in request 2021-09-20 16:09:32 +02:00
Molkobain
4de79afe56 Fix non updated image for contributing guide 2021-09-20 13:19:05 +02:00
bruno-ds
daf24d8cb3 N°4261 - implement feedbacks from the team
plus:
 - the entrypoint is now `LogException()` instead of `FromException()` which sounded more like a factory and less like an active method.
 - merge conflicting commit with @molkobain (CC fix)
 - remove the writing of the exception object in the error.log context (adding it was an error, it's way too verbose!!).
   - Technical note: The context is still used to propagate the exception across several call stack, so it now uses a less generic naming in order to avoid conflicts (see `ExceptionLog::CONTEXT_EXCEPTION`). another solution would have been to add a new parameter to `ExceptionLog::Log()`, but I didn't want to add constraint over the hypothetical evolution of the base class method.
2021-09-20 12:27:39 +02:00
bruno-ds
6e0d570d41 N°4261 - Portal exception logging: Add exception's file and line to the context.
plus:
 - the exception object is no more automatically added to the error.log context (it's way too verbose)
 - code cleanup (use constant instead of repeated strings)
 - ExceptionLog main method is now named `LogException` instead of `FromException`
2021-09-20 12:27:39 +02:00
Molkobain
ce4379920d Update contributing guide with new stickers 👀 2021-09-20 12:17:13 +02:00
acognet
291bbdf3da recompile styles 2021-09-18 23:13:43 +02:00
acognet
61f6c1fe33 N°2259 - iTop Compilation of branding images ignore real format of source image 2021-09-17 16:36:40 +02:00
acognet
a1d6a705ca N°4260 - Fix display of log attributes in list 2021-09-17 16:29:33 +02:00
acognet
b861d45b08 Refactor -> create utils::AddParamToUrl 2021-09-17 16:29:06 +02:00
Molkobain
fc7d2551cd N°4302 - Fix hard-coded image att. code in UserRights::GetUserPictureAbsUrl() 2021-09-17 12:04:13 +02:00
Stephen Abello
b15267d8db N°4239 Update bulk transition/modify mono/multi values indicator style 2021-09-17 11:35:01 +02:00
Stephen Abello
94ce62e424 Remove unintentional function overload committed in e3687b3 2021-09-16 15:16:19 +02:00
Molkobain
6271a33fdb Code review: Fix code conventions 2021-09-16 14:53:40 +02:00
Molkobain
4b6db53e84 Update current version 2021-09-16 13:38:41 +02:00
Eric Espie
540b9f8164 N°3908 - Polishing: Application Upgrade - display the installation progress bar 2021-09-16 11:24:22 +02:00
Eric Espie
5839bab042 N°3908 - Polishing: Application Upgrade - clickable checkbox label, remove history menu, filter history with most recent first, remove unnecessary columns in history 2021-09-16 11:14:50 +02:00
Pierre Goiffon
adc7666dd0 💚 Change setup.css test
Was checking comment presence, but we removed the comments (N°3865)
2021-09-16 10:21:21 +02:00
Stephen Abello
e3687b3cbb N°3685 Use minified versions of jQuery UI timepicker library 2021-09-16 10:09:33 +02:00
Stephen Abello
e81c02b25a N°3685 Fix combodo webfont preloading file name 2021-09-16 10:09:33 +02:00
Pierre Goiffon
28a8a4457e 📦 Update setup.css 2021-09-16 09:38:52 +02:00
Molkobain
eee0f453da N°3685 - Use minified versions of dataTables libs. 2021-09-16 09:20:54 +02:00
Molkobain
164a5501c0 Add missing condition for compiled JS dictionaries 2021-09-15 22:58:09 +02:00
Molkobain
ab3c1ad4af Add TWIG comment 2021-09-15 20:22:30 +02:00
Molkobain
83a3530880 Activity panel: Improve accessibility 2021-09-15 20:16:09 +02:00
Molkobain
0ad23e272b Update precompiled themes 2021-09-15 16:16:20 +02:00
Stephen Abello
b28ef803a3 N°3685 Display text while font is loading 2021-09-15 16:16:20 +02:00
Stephen Abello
b2155c042e N°3685 Fix twig variable name 2021-09-15 16:16:20 +02:00
Stephen Abello
b1b1d25186 N°3685 Preload necessary fonts to speed up display 2021-09-15 16:16:20 +02:00
Stephen Abello
61ee4d6807 N°3685 Replace Raleway truetype font files with woff ones 2021-09-15 16:16:20 +02:00
Molkobain
443292e1f6 PHPDoc 2021-09-15 16:16:20 +02:00
Molkobain
c025a7aa3b N°3685 - Add unit test for WebResourcesHelper 2021-09-15 16:16:20 +02:00
Stephen Abello
86ebb93149 N°3685 Compile SCSS files as a compressed CSS file and fix SCSS copyright comment so that they don't end up in compiled CSS 2021-09-15 16:16:20 +02:00
Molkobain
120670240c PHPDoc 2021-09-15 16:16:20 +02:00
Molkobain
5bd8a25440 N°3685 - Use WebResourcesHelper for D3/C3.js usages 2021-09-15 16:16:20 +02:00
Molkobain
754f755141 N°3685 - Use WebResourcesHelper for D3/C3.js usages 2021-09-15 16:16:20 +02:00
Molkobain
74b7223d44 N°3685 - Introduce WebResourcesHelper and use it for SimpleGraph usages 2021-09-15 16:16:20 +02:00
Stephen Abello
1fb2ff355d N°3685 Optimize CSS size: .ibo-button is extended at multiple places, reducing its use in loops when possible greatly improves compiled selectors 2021-09-15 16:16:20 +02:00
Molkobain
61f3d3aeda N°3685 - Front-end performances: Use only necessary parts of Bulma SCSS 2021-09-15 16:16:20 +02:00
Molkobain
99860e9e20 N°3685 - Front-end performances: Split compatibility files for easier maintenance / inclusion 2021-09-15 16:16:20 +02:00
Molkobain
eb164b47e2 N°3685 - Front-end performances: Update comments 2021-09-15 16:16:20 +02:00
Molkobain
dbd197d9bc N°3685 - Front-end performances: Include advanced search resources only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
e638c65685 N°3685 - Front-end performances: Remove clipboard lib. as it is not used in the backoffice yet 2021-09-15 16:16:20 +02:00
Molkobain
42b779d301 N°3685 - Front-end performances: Include dataTables lib. only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
da3bab9647 N°3685 - Front-end performances: Include jQuery.popup_menu lib. only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
94d53575ae N°3685 - Front-end performances: Include dataTables lib. only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
c26cfad062 Fix JS widget name in comment (decrease false positives in grep) 2021-09-15 16:16:20 +02:00
Molkobain
9cd9087cc7 N°3685 - Front-end performances: Move deprecated JS files to optional compatibility scripts 2021-09-15 16:16:20 +02:00
Molkobain
df7991adeb N°3685 - Front-end performances: Remove JS lib. already included in parent class 2021-09-15 16:16:20 +02:00
Molkobain
2dcfe0e281 N°3685 - Front-end performances: Include ScrollMagic lib. only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
bac584a6b4 N°3685 - Front-end performances: Include graph libs. (Raphael, simple_graph, ...) only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
e4d7bf7dbb N°3685 - Front-end performances: Identify used libs. 2021-09-15 16:16:20 +02:00
Molkobain
2d907f31dd N°3685 - Front-end performances: Use minified versions of libs. 2021-09-15 16:16:20 +02:00
Molkobain
e2001f4585 N°3685 - Front-end performances: Move deprecated JS files to optional compatibility scripts 2021-09-15 16:16:20 +02:00
Molkobain
9810f666fd N°3685 - Front-end performances: Use minified versions of libs. 2021-09-15 16:16:20 +02:00
Molkobain
de5f47d43e N°3685 - UIBlock resources: Add CKEditor resources to RichText 2021-09-15 16:16:20 +02:00
Molkobain
d2662e27e1 N°3685 - Front-end performances: Include BBQ lib. only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
9ac0100d3a N°3685 - Front-end performances: Remove JS lib. already included in parent class 2021-09-15 16:16:20 +02:00
Molkobain
1ea5983464 N°3685 - Front-end performances: Move deprecated JS files to optional compatibility scripts 2021-09-15 16:16:20 +02:00
Molkobain
15081ba82c N°3685 - Front-end performances: Include graph lib. (D3/C3.js) only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
df189bd1f2 N°3685 - Front-end performances: Include advanced search resources only when necessary 2021-09-15 16:16:20 +02:00
Molkobain
06f469faf2 N°3685 - Front-end performances: Add conf. param. to include deprecated JS/CSS files back if necessary 2021-09-15 16:16:20 +02:00
Molkobain
b27aa70a1e N°4247 - Button group: Make sure buttons of a same group always stay on the same line 2021-09-15 15:40:29 +02:00
Molkobain
0e35b8e4fa N°4247 - Activity panel: Make sure that cancel / send buttons always stay on the same line 2021-09-15 15:39:25 +02:00
Molkobain
c0fc62bcb8 N°4247 - Activity panel: All entries are now expanded / collapsed by the corresponding icons 2021-09-15 14:48:17 +02:00
bruno-ds
d1721b0834 N°4261 -Fix CI
Try to repair an odd error in the CI:
> Fatal error: Uncaught Exception: Serialization of 'ReflectionClass' is not allowed

avoid instantiation in the provider, delay them to the actual test
2021-09-15 14:39:00 +02:00
bruno-ds
66e4f369f7 N°4261 -Fix CI
Try to repair an odd error in the CI:
> Fatal error: Uncaught Exception: Serialization of 'ReflectionClass' is not allowed

Maybe it's triggered by the mocks being a property of the test class, so I inlined them.
+ misc. minor modification in order to try to figure out what is causing this behavior.
2021-09-15 13:34:04 +02:00
Pierre Goiffon
c5e1dbce88 💡 PHPDoc for \cmdbAbstractObject::UpdateObjectFromArg 2021-09-14 17:54:28 +02:00
bruno-ds
5d23a250ae N°4261 - New log handler dedicated to Exceptions & use of it in the portal's Exception listener
Such Exceptions are triggered with a Warning level and default the minimum default level in order to write in DB is above, so the behavior is not modified:
 - logs are written in errors.log (with a warning elvel instead of an error)
 - logs are not written in DB unless `log_level_min.write_in_db` is changed
2021-09-14 17:40:11 +02:00
Molkobain
b46357a1bd N°4254 - Fix autocomplete results being hidden below the modal after first opening 2021-09-14 17:31:59 +02:00
Eric Espie
4433cdb21b N°4047 - Fix undefined offset in core\dbobject.class.php - rewrite duplicate check 2021-09-14 16:13:43 +02:00
Eric Espie
45dc79f5af N°4211 - Remove DBObject::Reload calls added in 3.0.0 - Fix Highlight code (computed only for lifecycle and stopwatch) 2021-09-14 15:01:42 +02:00
Eric Espie
2ab0fab051 N°4211 - Remove DBObject::Reload calls added in 3.0.0 - Fix User cache when user not in DB 2021-09-14 15:01:42 +02:00
acognet
be81d1f6c0 N°3901 - Polishing: Menu - count 2021-09-14 12:21:10 +02:00
acognet
ddedce1589 Fix shortcut 2021-09-14 12:01:06 +02:00
Eric Espie
b557f16cfa N°4211 - Remove DBObject::Reload calls added in 3.0.0 - Try Person for User's Contact 2021-09-14 11:06:36 +02:00
Pierre Goiffon
30bf2015cb GitHook install : update create symlink message to add target path 2021-09-14 09:42:23 +02:00
acognet
14b6e903cb N°4245 - Using customfield in notifications triggered by TriggerOnObjectUpdate via ApplyStimulus 2021-09-14 09:41:40 +02:00
acognet
4f6e040346 N°3907 - Polishing: Run query - update of precompiled css 2021-09-14 09:15:22 +02:00
acognet
3e12799d1d N°3907 - Polishing: Run query 2021-09-14 09:10:54 +02:00
acognet
7d0550879f N°3910 - Polishing: data synchro 2021-09-14 09:09:36 +02:00
acognet
6a765fad50 N°3685 - Performance checks on the front end - Avoid reload 2021-09-13 09:19:08 +02:00
Stephen Abello
cbb70c94e5 Update precompiled stylesheets 2021-09-10 10:29:11 +02:00
Stephen Abello
b120488085 N°3922 Restyle one way password inputs, reset buttons and displayed hints 2021-09-10 10:28:38 +02:00
Pierre Goiffon
191891ac35 💬 Pre-commit hook : change message to avoid confusions
"push" is a git verb, so changed it to "add" instead
2021-09-10 08:38:53 +02:00
Molkobain
f171380396 Modals: Fix close "x" not being aligned 2021-09-09 18:01:03 +02:00
Molkobain
f9e54e1dde JSDoc 2021-09-09 18:01:03 +02:00
Eric Espie
15e99a898e N°3985 - Performance checks on the back end - Enhance KPIs 2021-09-09 17:21:57 +02:00
odain
27c397cc1a N°4225/4227: recommit lost restore.php + refactor duplicated code for cli restore/backup in common-cli.execution.php 2021-09-09 16:57:42 +02:00
acognet
616229140e N°3901 - Polishing: Menu 2021-09-09 14:27:36 +02:00
acognet
04e016c919 N°3919 - Polishing: IP Attribute 2021-09-09 14:27:36 +02:00
Eric Espie
a4e43d3f17 N°4225 - Remove Read-only mode for backup 2021-09-09 14:25:19 +02:00
Eric Espie
ed6969be2c N°4227 - Manual iTop restore - maintenance mode 2021-09-09 13:56:07 +02:00
Stephen Abello
8105c4d6cd N°3913 Fix last step double scrollbar on smaller screen 2021-09-09 11:02:18 +02:00
Stephen Abello
3b7073ad4e Remove commented lines 2021-09-09 10:01:52 +02:00
Stephen Abello
dbb84fa4e6 N°4239 Use blocks for bulk modify/transition/delete, harmonize and polish display 2021-09-09 09:52:09 +02:00
Pierre Goiffon
91c7ed9f4d pre-commit hook to disallow commit with SCSS file but without CSS file 2021-09-09 09:28:45 +02:00
Molkobain
e4c818cacb N°4288 - Portal: Update TWIG extensions to match those available in the backoffice 2021-09-08 21:47:05 +02:00
Molkobain
5b6b07af48 N°2007 - Portal: Don't show tooltip if empty on BrowseBrick items 2021-09-08 20:12:03 +02:00
Molkobain
1331bc2139 Add PHPDoc 2021-09-08 15:38:42 +02:00
Molkobain
08946066fb Session management: Add PHPDoc 2021-09-08 14:54:20 +02:00
Molkobain
0de4e62fcd Session management: Revert modification in third-party lib 2021-09-08 14:49:29 +02:00
Molkobain
8edd155351 N°4254 - Fix jQuery dialogs not being stacked correctly 2021-09-08 13:31:58 +02:00
Molkobain
3980ba81e7 Fix typo 2021-09-08 12:33:19 +02:00
acognet
0193868581 N°3901 - Polishing: Menu 2021-09-08 11:48:45 +02:00
Stephen Abello
d2b3de9734 Update precompiled stylesheets 2021-09-08 11:16:58 +02:00
Stephen Abello
d1c39c5e10 N°3929 Fix dashboard properties buttons and change semantics colors/icons 2021-09-08 11:16:06 +02:00
Stephen Abello
e29ae488a1 N°3929 Align dashboard switch button with specifications 2021-09-08 11:16:06 +02:00
Molkobain
ad3e3195a8 Compiler: Add log message in case a profile (user rights) relies on a missing group 2021-09-08 10:58:00 +02:00
Eric Espie
738411005b Fix CI 2021-09-08 10:20:16 +02:00
Pierre Goiffon
40b095e407 📦 Update compiled CSS 2021-09-08 08:04:46 +02:00
Pierre Goiffon
3b7cb9a554 💄 Setup : fix (v2) missing space on backup checkbox
Replaces &nbsp; added in 7890cbd7 with CSS
As the other setup checkboxes seems to be OK (space might already be added, or we might have a line feed in the code between checkbox and label), we are only modifying the backup checkbox
2021-09-07 17:57:25 +02:00
Eric Espie
f474b3de06 Fix CI 2021-09-07 16:58:36 +02:00
Pierre Goiffon
7890cbd701 💄 Setup : fix missing space on backup checkbox 2021-09-07 16:56:47 +02:00
Eric Espie
eef3e9b7ae Merge branch 'develop' into SessionManagement 2021-09-07 16:33:10 +02:00
odain
3c081461b0 fix ci: use env-production instead 2021-09-07 15:22:46 +02:00
Eric Espie
a916df64c9 Merge branch 'develop' into feature/cli-backup-restore 2021-09-07 14:48:06 +02:00
Eric Espie
1d0b96e10f Merge branch 'develop' into feature/cli-backup-restore 2021-09-07 14:45:35 +02:00
Stephen Abello
28070f8682 Update precompiled stylesheets 2021-09-07 14:41:39 +02:00
Stephen Abello
3e428000bd N°3914 Fix "Configure this list" buttons being narrowed when reconstructing modal 2021-09-07 14:40:43 +02:00
Stephen Abello
165b11f948 N°3914 Avoid table header sorting icons from overlapping with header label 2021-09-07 14:40:36 +02:00
acognet
c6495e7212 N°3907 - Polishing: Run query - update of precompiled css 2021-09-07 14:06:28 +02:00
acognet
0fb0b9deab N°3907 - Polishing: Run query 2021-09-07 10:59:14 +02:00
Molkobain
ecb1acf5af Update precompiled stylesheets 2021-09-07 10:54:34 +02:00
Eric Espie
b239e822ef N°4227 / N°4225 - Check cron context in WaitCronTermination 2021-09-07 10:54:27 +02:00
Eric Espie
615aa594f0 N°4227 / N°4225 - Fix cron backup 2021-09-07 10:47:26 +02:00
acognet
2e346a7e80 N°4184 - Alert UI block is collapsible only if there is a title 2021-09-07 10:45:37 +02:00
acognet
f5b557b0bc N°4191 - Fix not selectable caller in NormalChange when only 1 organization 2021-09-07 10:45:37 +02:00
Molkobain
2703075d39 SCSS: Rename variables to match conventions 2021-09-07 10:42:55 +02:00
Molkobain
f6fbd5a7a5 N°3900 - Breadcrumbs: Improve behavior when items are too many for the screen width
When the screen isn't large enough we now put the oldest entries in a dropdown menu like on a browser to access the previous pages.
2021-09-07 10:22:38 +02:00
Molkobain
d1a05f41e5 Button: Fix position to relative to allow absolute positioning of child elements 2021-09-07 10:22:38 +02:00
Stephen Abello
6b67ad93b9 Update precompiled stylesheets 2021-09-07 09:35:53 +02:00
Stephen Abello
884d3c9477 N°3920 On a fullscreen text field and clicking on an image, make popup display on top of current text field 2021-09-07 09:35:53 +02:00
Stephen Abello
26426123b8 N°3920 Move fullscreen button for text field next to field label 2021-09-07 09:35:53 +02:00
Pierre Goiffon
6725a9f1ef N°3807 Fix HTML licenses not displayed correctly 2021-09-07 08:58:00 +02:00
Eric Espie
8e0ae67803 N°4227 / N°4225 - Enhance SetupUtils interface 2021-09-06 17:53:46 +02:00
acognet
979a43edc9 N°3551 - Migrate module to new UIBlock system : Customer Survey - Fix problems of id in checkbox after action like "configure this list" 2021-09-06 15:57:34 +02:00
Eric Espie
2aaac00015 N°3985 - Performance checks on the back end - Fix KPI logs 2021-09-06 14:16:42 +02:00
Stephen Abello
c46cd1c514 Add hover and active style to add caselog entry button 2021-09-03 11:27:37 +02:00
Stephen Abello
74d2a6e46c Activity form can now have extra inputs 2021-09-02 17:27:48 +02:00
Stephen Abello
1d57b4330b Correctly trigger iTop API when adding a caselog entry through quick edit 2021-09-02 17:27:48 +02:00
acognet
034516d0ef Fix on ready script 2021-09-02 15:29:53 +02:00
acognet
72d7758259 N°3905 - Polishing: CSV Import - typo + fix loading js for Panel 2021-09-02 15:26:07 +02:00
acognet
3e9a19b0ea Fix empty page size 2021-09-02 10:11:45 +02:00
Molkobain
6118ee6876 Update precompiled themes 2021-09-01 15:10:15 +02:00
Molkobain
fea3c719af Top bar: Force page title to stay on 1 line 2021-09-01 14:56:21 +02:00
Molkobain
78eda6a2fc N°3800 - Fix text color in code blocks for the activity entries (also update comment to explain both cases) 2021-09-01 14:29:07 +02:00
Molkobain
65db576654 PHPDoc 2021-09-01 09:55:28 +02:00
Pierre Goiffon
69bca189fd N°3800 Update compiled CSS 2021-08-31 16:53:21 +02:00
Pierre Goiffon
5b78820b32 N°3800 Fix color for highlighted code blocks
We want content in a simple code tag to be black
But the color set by Highligh.js must be kept
2021-08-31 16:44:59 +02:00
acognet
79954d3cee N°4259 - Migrate object-copier to itop 3.0 style 2021-08-31 12:07:32 +02:00
Molkobain
8a5c144e3b Fix typo 2021-08-31 09:30:15 +02:00
Stephen Abello
af28a2e01d Update precompiled stylesheets 2021-08-31 09:28:44 +02:00
Stephen Abello
55513b2f4b Move horizontal scroll from tabcontainer to tabs element 2021-08-31 09:26:00 +02:00
Molkobain
e4bf15feb3 Tab container: Hide ellipsis at first to only show if necessary (better UX) 2021-08-30 18:00:03 +02:00
Molkobain
0080caf55f N°2788 - Revert hand-made adjustments for some HTML as it is now handled by .ibo-is-html-content 2021-08-30 17:32:30 +02:00
Molkobain
aed8135d56 N°2788 - Improve how small/large fields value wrap without overlapping the content next to them 2021-08-30 17:32:29 +02:00
Pierre Goiffon
d0ba84068d N°3002 Better log deprecated call location
Now logs file location when called by a function
2021-08-30 16:43:30 +02:00
Pierre Goiffon
d6d1a5cc23 N°3002 Fix undefined index notice in \DeprecatedCallsLog::DeprecatedNoticesErrorHandler 2021-08-30 15:58:55 +02:00
Molkobain
6700de097a N°3712 - Activity panel: Fix origin icon for log entries 2021-08-27 17:28:01 +02:00
Molkobain
cf556de76e Add method to get number of entries of an ormCaseLog 2021-08-27 17:28:01 +02:00
Stephen Abello
72cddf30fb Update demo objects with fresher data 2021-08-27 10:55:36 +02:00
Stephen Abello
5ec6a1cc0c Fix sso buttons alignment with login inputs 2021-08-27 10:55:36 +02:00
Eric
fe0db8f357 N°3985 - Performance checks on the back end - Fix Session helper 2021-08-27 09:08:14 +02:00
Eric
1ab2b9c5d4 N°3985 - Performance checks on the back end - better KPI logs 2021-08-26 17:14:46 +02:00
Eric
67cd5e321e N°3985 - Performance checks on the back end - Fix Session helper 2021-08-26 16:14:14 +02:00
Eric
81d9ea389d N°3985 - Performance checks on the back end - Fix Session helper 2021-08-26 15:33:07 +02:00
Eric
3ee9757a85 🔊 Log when no Twig template is found in controller 2021-08-26 12:06:21 +02:00
Eric
97e0150974 N°3224 - migration audit tool - allow php functions in XPath 2021-08-26 11:54:45 +02:00
acognet
7f37c5912a N°3914 - Polishing: Lists - fix display of datatable and rename attribute for init data 2021-08-26 11:37:17 +02:00
Stephen Abello
2f5a1c99a5 Add variables to class icon size CSS classes 2021-08-26 11:22:31 +02:00
Eric
5ce9b6ca99 Merge branch 'develop' into SessionManagement 2021-08-26 10:28:43 +02:00
Eric
bd9286f903 N°3985 - Performance checks on the back end - Use Session helper 2021-08-26 10:27:26 +02:00
Molkobain
4ae7090a51 N°4062 - Advanced search: Fix visual glitch when submitting the search while the results are sticking 2021-08-25 20:55:58 +02:00
Stephen Abello
335074701f Update precompiled stylesheets 2021-08-25 16:57:26 +02:00
Stephen Abello
76f70d45dd N°4182 Large own caselog entries were not scrolling in activity panel 2021-08-25 16:34:29 +02:00
Stephen Abello
6f147acd76 Update precompiled stylesheets 2021-08-25 16:20:12 +02:00
Stephen Abello
a84d2ce6bb N°3928 Avoid double carret on multiselect 2021-08-25 16:18:56 +02:00
Stephen Abello
ea9c1ab0b3 Add helpers to set size to class icons 2021-08-25 16:18:56 +02:00
Molkobain
e1dc269171 SCSS: Rename variable to something more semantic lik in other blocks 2021-08-25 15:46:08 +02:00
Molkobain
16dc7de8e2 Rename method for consistency across the widget 2021-08-25 15:13:03 +02:00
Stephen Abello
88e210d84d N°3928 Use a more precise selector for tooltips singleton 2021-08-25 14:55:26 +02:00
Stephen Abello
4f6bd5444b N°3928 Create tooltip singleton for impact analysis matching elements (icon/text) 2021-08-25 14:34:40 +02:00
Stephen Abello
0f204f94eb Add helper to create tooltip singleton 2021-08-25 14:34:40 +02:00
Vincent Dumas
f5ae76360e Simple typo in declaration of an entry
No associated bug
2021-08-25 14:18:14 +02:00
vdumas
8d59024d8e N°463 use CDATA on oql tags 2021-08-25 14:13:14 +02:00
Molkobain
32e0031242 N°4254 - Fix items list not visible for external key in modals 2021-08-25 11:25:28 +02:00
Stephen Abello
3fdebdc217 Update precompiled stylesheets 2021-08-25 11:07:14 +02:00
Stephen Abello
7083807319 N°3928 Migrate impact analysis page to 3.0 style 2021-08-25 11:06:26 +02:00
Stephen Abello
0f01dbc3e5 Allow to add an icon to lists display block 2021-08-25 11:06:26 +02:00
Stephen Abello
8289b028cf N°3928 Limit impact analysis size 2021-08-25 11:06:25 +02:00
Stephen Abello
f72a6ee963 Hints that disabled tabs are not clickable 2021-08-25 11:06:25 +02:00
Stephen Abello
08359cdd05 N°3928 Replace legacy loading gif 2021-08-25 11:06:25 +02:00
Stephen Abello
de17439f55 N°3928 Remove function messing up tabs height while giving no real benefit 2021-08-25 11:06:25 +02:00
Stephen Abello
6e555e29d1 N°3928 Fix impact analysis not showing when displaying list first 2021-08-25 11:06:25 +02:00
Stephen Abello
9dae34461b Use tab widget prefix for our slightly modified tabs widgets 2021-08-25 11:06:25 +02:00
Stephen Abello
06b1e581fe N°3928 Use right tab widget in impact analysis and make sure widget is initialized before using it 2021-08-25 11:06:24 +02:00
acognet
d4b515c7b7 Fix id in checkbox 2021-08-25 10:31:33 +02:00
Molkobain
20759eca23 Fix "Configure this list" due to regression in 280afb35 2021-08-25 09:30:53 +02:00
Molkobain
4e420cbcd6 N°4062 - Advanced search: Fix sticky header glitches with pagination 2021-08-24 17:55:41 +02:00
vdumas
0e60c67910 N°463 Add 3 predefined OQL queries 2021-08-24 10:29:33 +02:00
Molkobain
808c1fa571 N°3712 - Activity panel: Fix origin indicator being displayed on all type of entries 2021-08-24 10:17:56 +02:00
Molkobain
dbf8475883 N°4256 - Fix CMDBChange origin to 'csv-interactive' on the CSV Import page 2021-08-24 10:01:44 +02:00
Eric
2c2155a8e0 N°3985 - Performance checks on the back end 2021-08-23 13:57:03 +02:00
Stephen Abello
ffbd94d671 Cleanup 2021-08-20 16:53:38 +02:00
Molkobain
3abcdc9c58 Rename CSS prefixes of autocomplete to match conventions 2021-08-20 16:50:16 +02:00
Molkobain
242f499101 Remove require as the class is handled by the autoloader 2021-08-20 16:50:16 +02:00
Molkobain
6b0106ff73 PHPDoc 2021-08-20 16:50:16 +02:00
acognet
bf991ffb8a N°3685 - Performance checks on the front end - Minimize size of generated javascript 2021-08-20 16:03:22 +02:00
acognet
280afb35a9 Datatable : on init load data for the first page 2021-08-20 15:54:34 +02:00
acognet
e095749c90 Fix typo 2021-08-20 15:54:34 +02:00
Stephen Abello
ced0e7cc8f N°4093 When clicking on a tab before tab widget is loaded, prevent AjaxTabs from redirecting our page to their target 2021-08-20 11:18:13 +02:00
Molkobain
6df98c3d41 N°4248 - Change demo samples icons for services / service families 2021-08-20 09:41:19 +02:00
Stephen Abello
21e16fd2e8 Make extension source clearer in setup and about box 2021-08-19 18:01:40 +02:00
Molkobain
bc2e25be99 N°3918 - Change missing object tooltip text to "Object not found" 2021-08-19 15:02:04 +02:00
Molkobain
0c5ebc3a84 N°1616 - Fix large HTML table overflowing in HTML fields or logs 2021-08-19 15:02:04 +02:00
Stephen Abello
43412b78e3 N°1632 Remove unused autoloader in UnauthenticatedWebPage 2021-08-19 14:08:21 +02:00
Eric
9126635cf2 Allow setup ends correctly when problem occurs 2021-08-19 13:50:16 +02:00
Eric
d0986c048a Allow setup again when problem occurs 2021-08-19 12:14:14 +02:00
Eric
fe0c52bedd themes 2021-08-19 11:48:26 +02:00
Eric
8926c6783a 🐛 scss reference was in bulma not in iTop scss 2021-08-19 11:48:25 +02:00
Stephen Abello
95b6dd0cc3 N°1632 Add a common webpage to be used for unauthenticated/token based actions, guarantees harmony between extensions style and a common API 2021-08-19 11:41:01 +02:00
Eric
121e39b738 fix themes 2021-08-19 11:26:31 +02:00
Eric
48dee9c136 🐛 remove undefined scss reference 2021-08-19 10:55:58 +02:00
Eric
befde44215 🐛 fix non-existing variable 2021-08-19 10:41:36 +02:00
acognet
a827eed59d Restore unwanted changes 2021-08-19 10:41:18 +02:00
Molkobain
1613c1bbdc Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	application/itopwebpage.class.inc.php
#	core/config.class.inc.php
#	setup/setuputils.class.inc.php
2021-08-18 18:55:56 +02:00
Molkobain
909af7f59c JSDoc 2021-08-18 18:53:42 +02:00
vdumas
495b39a7ab N°4246 - Add missing class parameter 2021-08-18 17:05:16 +02:00
vdumas
f9ff66941d N°4079 - FR Dictionnary typo 2021-08-18 17:03:14 +02:00
acognet
29871bc6da Fix precompiled css 2021-08-18 16:49:52 +02:00
Molkobain
1c983e8093 Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	core/config.class.inc.php
#	datamodels/2.x/itop-portal-base/portal/src/controllers/objectcontroller.class.inc.php
#	pages/ajax.render.php
2021-08-18 16:12:22 +02:00
Molkobain
92a9a8c65f N°4129 - Security hardening 2021-08-18 15:57:18 +02:00
Federico Lazcano
a3e1b95c8e Update install.txt
Change old URL for new, linking to iTop Hub.
2021-08-18 14:35:35 +02:00
acognet
bf2d98a1bf N°580 - Jean Dupont - Jean Dupont, auto-complete avec homonyme 2021-08-18 10:41:38 +02:00
acognet
abe103eade N°580 - Jean Dupont - Jean Dupont, auto-complete avec homonyme 2021-08-18 09:32:26 +02:00
acognet
034052cf4b avoid 404 error when loading image in autocomplete 2021-08-18 09:32:26 +02:00
Molkobain
4458f26379 N°3750 - Behat: Add metadata about logs label 2021-08-17 17:49:22 +02:00
Molkobain
007e1ded0d N°3786 - Fix unload XHR call being always sent, even when no draft entries 2021-08-17 16:11:21 +02:00
Molkobain
5651512f68 N°4244 - Add protection against unfortunate massive delete of inline images / attachments when a null temp ID is passed 2021-08-17 15:58:52 +02:00
Molkobain
8c043f137c N°3750 - Behat: Add missing metadata to DesignerFormField 2021-08-17 10:01:22 +02:00
acognet
b3cce54ee9 Fix precompiled css 2021-08-17 10:00:19 +02:00
acognet
e4e4e3b0bf Fix precompiled css 2021-08-17 09:18:58 +02:00
acognet
1cb3b4bd96 Remove lines in double 2021-08-16 21:56:39 +02:00
acognet
97ee6570d2 N°3572 - Migrate backoffice pages to new UIBlock system : Toolkit 2021-08-16 15:17:05 +02:00
acognet
8c8f711fe8 N°3551 - Migrate module to new UIBlock system : Customer Survey 2021-08-16 15:16:08 +02:00
acognet
f140efd95c N°4007 - When a search is on auto submit, auto submit it also on first display - new fix in order to avoid reload in case of OQLMenuNode - rollback some deleted lines 2021-08-16 12:53:27 +02:00
acognet
6b19758654 Add deprecated 2021-08-16 11:24:58 +02:00
acognet
2899c82ef2 Fix Typo 2021-08-16 09:55:40 +02:00
acognet
12c2929f1d Context menu remains in place while scrolling 2021-08-16 09:54:51 +02:00
acognet
9d28e43804 N°4232 - Order By error on query with two classes 2021-08-16 09:53:19 +02:00
Molkobain
27217815d1 N°2510 - Fix expand/collapse buttons of log entries in a list 2021-08-16 09:37:36 +02:00
Molkobain
8e3cc471df N°1836 - Cancel of an object creation form now redirects to the search page of the same class (instead of just showing "operation cancelled") 2021-08-14 23:33:21 +02:00
Molkobain
58e35ea33b N°1047 - Replace hard coded 'iTop' occurrences with ITOP_APPLICATION_SHORT 2021-08-14 22:43:29 +02:00
Stephen Abello
0b81601699 N°3913 Allow iTop Hub iframe to fully display after setup 2021-08-13 17:46:24 +02:00
Stephen Abello
4d3ba6edd0 N°3913 Make setup's collapsable sections' arrow clickable 2021-08-13 17:08:26 +02:00
Stephen Abello
9de014c9cb Add favicon to setup pages 2021-08-13 15:54:43 +02:00
Stephen Abello
75dbaada72 Update favicon style 2021-08-13 15:52:34 +02:00
Stephen Abello
0d4dd0c67b Harmonize iTop's logo and fluent icons 2021-08-13 15:28:17 +02:00
Stephen Abello
fabdef37d2 N°3913 UI improvements for setup, also remove A LOT of <table> 😬 2021-08-13 12:23:52 +02:00
Molkobain
e666631f63 N°3918 - Restore style on broken wiki links (also add a tooltip to explain what it means) 2021-08-13 11:56:40 +02:00
odain
280feca863 Revert "N°4225 - Protect manual backups from cron (and vice versa) - minimal work ie protect manual backup from cron only"
This reverts commit e3dc1b77cc.
2021-08-13 11:16:48 +02:00
DudekArtur
7690e43b39 Update pl.dictionary.itop.core.php 2021-08-13 10:11:16 +02:00
Molkobain
0c66882990 N°3918 - Fix regression on mentions display introduced by 7af10e51 2021-08-12 21:04:50 +02:00
Molkobain
7613ac7a9b Graphviz: Remove generated SVG image after usage as it won't be cached 2021-08-12 19:56:02 +02:00
Molkobain
7af10e5197 N°3918 - Fix wiki syntax "[[CLASS:ID]]" not working in logs 2021-08-12 17:28:50 +02:00
odain
095c975ec6 N°4227 / N°4225 - require cleanup + fix manual restore 2021-08-12 16:25:50 +02:00
odain
9e1e5a8a47 N°4227 - Manual iTop restore - protect any restore from cron or db updates and release readonly mode afterward only if restore set it itself 2021-08-12 16:25:50 +02:00
odain
2c026fa891 N°4225 - Protect manual backups from cron (and vice versa) - protect any backup from cron/db updates and release readonly mode only when backup set it itself 2021-08-12 16:25:50 +02:00
odain
00d65aeb45 N°4227 - Manual iTop restore - create manual CLI restore 2021-08-12 16:25:50 +02:00
odain
5702f603ac N°4227 - Manual iTop restore - move restore mutex management inside in DBRestore->RestoreFromCompressedBackup primitive 2021-08-12 16:25:50 +02:00
odain
e3dc1b77cc N°4225 - Protect manual backups from cron (and vice versa) - minimal work ie protect manual backup from cron only 2021-08-12 16:25:50 +02:00
Stephen Abello
c304f70ff4 Harmonize external key's autocomplete items display with dropdown ones 2021-08-12 14:40:36 +02:00
Stephen Abello
53fd41e748 N°4127 Fix XSS vulnerability in autocomplete lists 2021-08-12 14:21:05 +02:00
Molkobain
7577fbb8bf N°4236 - Fix user with no admin right can't connect in iTop when log_usage set to true 2021-08-12 11:13:59 +02:00
Molkobain
0fc912b357 Rename MetaModel::IsObjectExistsInDb() to MetaModel::IsObjectInDB() 2021-08-12 09:37:24 +02:00
Molkobain
c475e66176 Add documentation 2021-08-12 09:35:14 +02:00
Pierre Goiffon
cd1ba097cb N°3867 Fix error "LEVEL_WARNING of type Identifier is forbidden" error when saving valid config in configuration editor 2021-08-11 18:07:38 +02:00
Molkobain
fdca4d4cc3 N°3786 - Fix object locked hint (on activity panel) not displayed until message removed 2021-08-11 17:41:31 +02:00
Pierre Goiffon
4379b4d908 N°3800 Fix HTML content display for table borders v2 2021-08-11 17:31:08 +02:00
Pierre Goiffon
5b42f67a99 N°3867 Code review: remove condition that is quite too strict (danger !!)
Thanks @odain !
2021-08-11 17:22:21 +02:00
Pierre Goiffon
0b9ccc8e67 N°3800 Fix HTML content display for table borders and code color 2021-08-11 17:08:00 +02:00
Pierre Goiffon
2d98ca2318 N°3867 Fix "Invalid configuration: Stmt_Expression is forbidden in line 10" error when saving valid config in configuration editor
Now this is tested in \ConfigValidator\iTopConfigAstValidatorTest
2021-08-11 16:38:56 +02:00
odain
92add2bbfe add annotation to datasynchro test 2021-08-11 10:17:35 +02:00
Pierre Goiffon
f15bdb75ca N°4173 Fix memory_limit error on target object hyperlink generation 2021-08-10 19:08:00 +02:00
Pierre Goiffon
a66830de17 N°4173 Fix memory_limit error when saving an object pointing to a big AttributeBlob
Check of pointed object was loading the whole object instead of just doing a count
2021-08-10 19:08:00 +02:00
Pierre Goiffon
714294e1b4 N°4173 Fix memory_limit exhausted when having ExtKey widget pointing on class with AttributeBlob
Was failing when opening an object form, and when the list contained target objects with total file size above memory_limit
2021-08-10 18:46:10 +02:00
Molkobain
e3d2c1d761 Advanced search: Restore "more criteria" inputs color 2021-08-10 16:27:08 +02:00
Molkobain
59d95cc14b Field: Change how field's value wrap to fix unwanted "new line" between some elements (lists, ...) 2021-08-10 16:27:08 +02:00
Pierre Goiffon
ddc5bbd1bb N°3867 Fix write config now removes PHP vars
Now the PhpParser tree has a different structure, beginning with a PhpParser\Node\Stmt\Expression
2021-08-10 15:47:01 +02:00
Pierre Goiffon
9bbee0d603 ⬆️ N°3867 Upgrade php-parser from 3.1.5 to latest version 4.12.0
The 3.1.5 version wasn't maintained anymore and was compatible with PHP 7.2 maximum
2021-08-10 15:45:02 +02:00
acognet
be1ef5b452 N°3634 - Feedback alpha 3.0 : finish list - display printable object 2021-08-10 12:10:54 +02:00
Pierre Goiffon
cbdc48b7e1 iTopConfigParserTest now works on Windows 2021-08-10 11:48:13 +02:00
denis.flaven@combodo.com
bb5679959e Fixed unit tests for password_renewed_date, broken by the correction of
n°4095.
2021-08-10 10:40:54 +02:00
Molkobain
cdbb4470fc N°4039 - Add margin below an object details
- Easier read of the fields at the bottom of it
- Better display of a dropdown at the bottom of it
2021-08-09 17:20:56 +02:00
Molkobain
252d752bf5 Navigation menu: Improve french translations for the current user tooltip 2021-08-09 17:20:56 +02:00
denis.flaven@combodo.com
99d0c05c1c N°4095 - Provisions for future implementation of users password
expiration.
2021-08-09 17:13:08 +02:00
Molkobain
5926e9d110 Navigation menu: Add current user's login to the tooltip 2021-08-09 16:28:53 +02:00
Molkobain
c8dd8c3806 Code cleanup: Remove forgotten commented line 2021-08-09 13:54:02 +02:00
Molkobain
70b07721e6 N°2875 - Fix typo in config example 2021-08-09 10:46:42 +02:00
Molkobain
bd050dfe69 N°2875 - Add possibility to configure the marker scope by either a class or an OQL 2021-08-09 10:38:27 +02:00
Molkobain
9eb477ce83 N°2875 - Fix visual glitches on long results
- Medallion could be horizontally compressed
- Title wrapped instead of overflowing, making reading across entries difficult
2021-08-09 10:38:27 +02:00
Pierre Goiffon
a742b6c610 🔊 N°3002 DeprecatedCallsLog error handler : add trigger_error message 2021-08-09 09:06:17 +02:00
Pierre Goiffon
fcf769666e N°3913 setup : in "done" step, add back styling on HTML content 2021-08-06 17:59:42 +02:00
Pierre Goiffon
72e628c5d5 💡 Reference in PHPDoc for \LogAPI::GetMinLogLevel 2021-08-06 17:39:34 +02:00
Pierre Goiffon
bf28602ae6 💡 Improve PHPDoc for \LogAPI::GetMinLogLevel 2021-08-06 17:37:56 +02:00
Pierre Goiffon
b8a0d899f4 Fix \coreExtensions\UserLocalTest::testValidatePassword failing because of DEPRECATED notices 2021-08-06 17:13:24 +02:00
Pierre Goiffon
d335736cfc 🔊 N°3002 Add trigger_error to catch deprecated notices inside DeprecatedCallsLog
They are logged as WARNING level in \DeprecatedCallsLog::ENUM_CHANNEL_PHP_LIBMETHOD channel

Such deprecated notices are generated inside Symfony for example using @trigger_error(..., E_DEPRECATED).
Having such a log will help us migrate to the next lib version !
2021-08-06 17:13:24 +02:00
Molkobain
80f7d07378 N°3592 - Fix alignment of custom fields in the backoffice 2021-08-06 17:04:26 +02:00
Molkobain
0be6a8aef4 N°3592 - Remove part of 146a95bae as it was unnecessary 2021-08-06 17:04:26 +02:00
Stephen Abello
0fe857071d Fix login css glitches with iTop 3.0 2021-08-06 15:41:43 +02:00
acognet
05981c8af8 N°4156 - GUI broken when a external key contains "\" 2021-08-06 11:56:25 +02:00
Molkobain
0abea749fa N°3786 - Fix lock removal when leaving an object details page in read-only with lock on the activity panel 2021-08-06 11:12:56 +02:00
Molkobain
78af6fdc84 N°3944 - Add comment to explain the 2 similar IFs 2021-08-06 11:11:57 +02:00
acognet
1e97b5a8c0 Revert N°3423 - Allow AttributeImage / AttributeDocument content to be cached by the browser + N°4029 - Caching images in chrome does not work 2021-08-06 09:51:59 +02:00
acognet
0214243b63 N°3914 - Polishing: Lists - remove pagination when it is unnecessary 2021-08-06 09:19:31 +02:00
Pierre Goiffon
d30871ac59 Revert "N°3002 Add trigger_error to catch deprecated notices inside DeprecatedCallsLog"
This reverts commit d247ea915d.
Will solve CI build errors... I will work in my own branch to tweak this !
2021-08-05 17:35:17 +02:00
Pierre Goiffon
d247ea915d N°3002 Add trigger_error to catch deprecated notices inside DeprecatedCallsLog
Such notices are generated inside Symfony for example using @trigger_error(..., E_DEPRECATED).
Having such a log will help us migrate to the next version !
2021-08-05 17:18:19 +02:00
acognet
0e0aed1ba4 N°3423 - Allow AttributeImage / AttributeDocument content to be cached by the browser + N°4029 - Caching images in chrome does not work 2021-08-05 16:34:24 +02:00
acognet
bc770ef3d5 N°4007 - When a search is on auto submit, auto submit it also on first display - new fix in order to avoid reload in case of OQLMenuNode -add param in searchFormHandler 2021-08-05 16:20:56 +02:00
Pierre Goiffon
56a4fb0b42 Allow to run all tests from within the IDE
Just :
* configure the config file (test\phpunit.xml.dist)
* add runner parameters : --fail-on-risky --exclude-group beforeSetup
* specify iTop root as custom working directory
2021-08-05 15:21:41 +02:00
acognet
3139628dd8 N°4007 - When a search is on auto submit, auto submit it also on first display - new fix in order to avoid reload in case of OQLMenuNode 2021-08-05 15:08:48 +02:00
acognet
7d9b19cd9e N°4119 - Loose application context in advanced search ajax call 2021-08-05 12:15:47 +02:00
Stephen Abello
b3cb95d2f1 Removed inline background color 2021-08-05 11:56:17 +02:00
Stephen Abello
a6765cdc3a Update precompiled stylesheets 2021-08-05 10:38:40 +02:00
Stephen Abello
97d52fb539 N°3685 Revert most of e4f58b5b changes, replace @extend .ibo-button calls with classes in markup for most cases, except jquery-ui buttons 2021-08-05 10:20:30 +02:00
Pierre Goiffon
ad936d7a2f 🔇 N°3731 Remove DeprecatedCallLog in \MetaModel::BulkUpdate
Method is still called in \ObsolescenceDateUpdater !
2021-08-04 17:37:10 +02:00
Pierre Goiffon
090eb9a560 🔇 N°3731 Remove DeprecatedCallLog in \MetaModel::GetFilterCodeOrigin
Method is still called !
2021-08-04 17:34:13 +02:00
Stephen Abello
e4f58b5b98 N°3685 Greatly optimize SCSS rules to reduce compiled CSS file size (4.7Mo -> 620ko) 2021-08-04 16:38:40 +02:00
acognet
c99a22c9f7 N°4025 - Universal search : cannot select class anymore 2021-08-04 14:41:25 +02:00
Pierre Goiffon
29cf20beaf N°3909 Fix notification configuration help layout 2021-08-04 12:00:48 +02:00
denis.flaven@combodo.com
e325d535ae N°4096 - Add automatic email reprocessing in case of error 2021-08-04 11:24:59 +02:00
Pierre Goiffon
11cfdb2a17 N°3807 Fix container added for all Html components
This was causing issues for example in the setup, as any raw content is sent using \WebPage::add, which create an HTML component.
I reverted the layout update, and created a new factory method to be used when needed : \Combodo\iTop\Application\UI\Base\Component\Html\HtmlFactory::MakeHtmlContent
2021-08-04 11:19:35 +02:00
Pierre Goiffon
66720b9731 N°3807 Update theme CSS 2021-08-04 11:19:35 +02:00
acognet
234f46cafa N°1731 - Allow Transitions without unnecessary confirmation 2021-08-04 10:51:04 +02:00
acognet
27c3ce0389 N°3907 - Polishing: Run query - Add dictionary entry 2021-08-04 10:44:26 +02:00
Pierre Goiffon
9d0e2fa64a N°3807 Bring back styling to raw HTML content
Bulma minireset (https://github.com/jgthms/bulma/blob/master/sass/base/minireset.sass) was applied everywhere in iTop. This was causing HTML content without any Bulma or iTop 3.0.* CSS classes to render with no styles anymore, not even the default browser's ones. Especially rendering for content styled in CK Editor was problematic...

This commit creates a new `ibo-is-html-content` CSS class (in css/backoffice/utils/helpers/_misc.scss) that just extends the `content` Bulma class (indirection to reduce framework coupling).
This new iTop CSS class is added in :
* AttributeText and its children when format is HTML
* HTML components
* activity entries in HTML format

The class can also be used elsewhere when needed, for example in modules having custom pages that aren't using yet the iTop 3.0.* UI components or CSS classes.
2021-08-04 10:37:54 +02:00
acognet
e211633fed N°4039 - List contain stays in place when scrolling on a screen 2021-08-04 10:37:02 +02:00
denis.flaven@combodo.com
29967aa41a N°3944 - LogAPI : fix default log level in config when logging using a channel 2021-08-04 10:07:58 +02:00
Pierre Goiffon
3ebb1cfc66 💡 phpDoc 2021-08-03 17:15:38 +02:00
Molkobain
6c2221b8b6 Datatables: Remove extra white space in template 2021-08-03 16:16:21 +02:00
Molkobain
c0b3aed12c N°3712 - Code cleanup thanks to @piR 2021-08-03 16:15:09 +02:00
Stephen Abello
53efc9f75e Update precompiled stylesheets 2021-08-03 15:55:06 +02:00
Stephen Abello
0d566f2e47 Fix panel collapsible toggler display 2021-08-03 15:49:27 +02:00
Stephen Abello
b294e3c734 N°3928 Correctly align impact analysis's filter refresh button 2021-08-03 15:49:27 +02:00
Stephen Abello
6704f9eccf N°3928 Allow user to collapse impact analysis' filter 2021-08-03 15:49:27 +02:00
Molkobain
90cb6e1d49 N°4124 - Extract computations into variables for easier comprehension 2021-08-03 11:37:01 +02:00
Molkobain
c0aa4f2d69 Initialize array properly 2021-08-03 11:11:02 +02:00
Molkobain
01984c24c0 Fix wrong usage of spaceless filter 2021-08-02 20:15:16 +02:00
Molkobain
1da1e0b1bd N°3712 - Activity panel: Improve history entries to have a different icon depending the origin (interactive, webservices, csv, ...) 2021-08-02 19:42:32 +02:00
Molkobain
39bcd3e4cd 🌐 N°3712 - Add dict. entries for CMDBChange->origin values 2021-08-02 19:42:32 +02:00
Molkobain
156cce6098 N°3712 - Extract CMDBChange origin values in a dedicated class 2021-08-02 19:42:32 +02:00
acognet
3130e95f4f N°3907 - Polishing: Run query 2021-08-02 18:56:07 +02:00
Molkobain
e28f704f3e N°4076 - Revert regression in global search from 344cce9fd
Current query was not visible when reaching the results page
2021-08-02 15:20:05 +02:00
Stephen Abello
5c6c59941a N°3901 Correctly hide menu search placeholder 2021-08-02 15:18:06 +02:00
Stephen Abello
bc9d47933e Update precompiled stylesheets 2021-08-02 11:43:28 +02:00
Stephen Abello
07a10e4146 N°3930 Fix dashlet blocker position 2021-08-02 11:42:57 +02:00
Stephen Abello
e8a21870ad Update precompiled stylesheets 2021-08-02 11:28:37 +02:00
Stephen Abello
2e132d5c53 N°3930 Restore dashlet blocker on dashboard editor 2021-08-02 11:28:37 +02:00
Eric
3359609349 Allow mode selection for queries 2021-07-31 15:23:19 +02:00
Molkobain
2966759466 Code cleanup 2021-07-30 17:09:51 +02:00
Molkobain
25395405e5 N°3905 - Remove remaining spaces 2021-07-30 17:09:50 +02:00
Stephen Abello
b589e2d001 Update precompiled stylesheets 2021-07-30 16:48:48 +02:00
Stephen Abello
27f3619cf5 Fix undefined variable used in scss 2021-07-30 16:48:23 +02:00
Stephen Abello
616fc436d0 CSS improvements 2021-07-30 16:40:33 +02:00
acognet
4f2f765207 N°3912 - Polishing: Export - fix page webservices/export.php - revert delete of utils.js 2021-07-30 15:16:51 +02:00
Pierre Goiffon
9931fa1a6b 🎨 N°4092 rename method
Thanks @Molkobain !
2021-07-30 12:09:30 +02:00
Pierre Goiffon
a13f2750ea 🎨 Replace call_user_func call to \cmdbAbstractObject::GetShortcutActions for better IDE recognition
And also :
* removed an obsolete use statement
* fix method phpdoc
2021-07-30 11:41:41 +02:00
Stephen Abello
243d105f59 Fix return value from new method added in 49fd482 2021-07-30 10:54:16 +02:00
Stephen Abello
7783ba570e PHPDoc 2021-07-30 10:37:52 +02:00
acognet
5a9fa2ac32 N°3912 - Polishing: Export - fix page webservices/export.php 2021-07-29 17:59:51 +02:00
Pierre Goiffon
619e3de5a8 N°4092 Setup : add symlinks option in install
Was only available during update
2021-07-29 17:34:24 +02:00
Pierre Goiffon
83064d68c7 N°4092 Setup : symlink option now always displayed if functionality enabled
Previously we were also testing for flag presence.
In consequence the confirmation dialog when unchecking the option is also removed (we can enable back the option using the setup)
2021-07-29 17:24:20 +02:00
Stephen Abello
f3c11e72cf N°3552 Add method to retrieve User object from Person object 2021-07-29 16:37:03 +02:00
Stephen Abello
c9e887a264 N°3552 Allow AddLogEntry to set entry's user_id from another user using a new parameter 2021-07-29 16:37:02 +02:00
Stephen Abello
49fd482389 N°3552 Correctly display case log entry with no iTop user linked (such as mail to ticket entries) 2021-07-29 16:37:02 +02:00
acognet
96de4e1796 N°4117 - Text field display, too many empty lines 2021-07-29 11:52:39 +02:00
acognet
44f413583c N°4124 - Unable to scroll down on some object 2021-07-29 11:38:20 +02:00
acognet
91104002ea N°4037 - Missing close button on list export on portal - rollback commit for N°3746 2021-07-28 16:02:35 +02:00
acognet
f98ba1594c N°3705 - Migrate module to new UIBlock system : Kanban board - css and dictionnary in ajax page 2021-07-28 16:02:35 +02:00
Molkobain
431dc5532b Change comment / test for clarification 2021-07-28 15:59:43 +02:00
Molkobain
df473ae313 PHPDoc 2021-07-28 15:31:22 +02:00
Molkobain
40ce74cffa N°4203 - Activity panel: Add button to load all entries at once 2021-07-28 14:58:15 +02:00
Molkobain
7598c18ad6 N°4203 - Activity panel: Hide "load more entries" button when only "logs" filter is active 2021-07-28 14:55:17 +02:00
Molkobain
d38b655f5f Activity panel: Limit visual glitches on entries on first display by hiding them all before displaying only the relevant.
Otherwise, entries from the other logs / activity tabs are visible for a second before filtering on the entry of the current tab only.
2021-07-28 14:55:17 +02:00
Eric
f4345ef312 N°4199 - Add <code> to EnumSet values to fix XML conversion 2021-07-28 14:40:19 +02:00
Eric
13b548e95d N°4199 - Add <code> to EnumSet values to fix XML conversion 2021-07-28 14:39:52 +02:00
Eric
3a988ab499 N°4175 - Adding a lifecycle to an existing class fails on setup (using xml version < 3.0) 2021-07-28 13:30:39 +02:00
Eric
14a5f87d62 N°4036 - User edition controls : a user cannot remove contact 2021-07-28 13:09:18 +02:00
Eric
8dae459b12 N°4036 - User edition controls : the profiles selection should allow the User modification (when editing your own User) 2021-07-28 11:45:02 +02:00
Eric
8dc10424e8 🎨 cleanup code 2021-07-28 09:59:10 +02:00
Eric
54a6573948 N°4036 - User edition controls : the profiles selection should allow the User modification (when editing your own User) 2021-07-28 09:13:47 +02:00
Eric
1d5e0b6fe9 Temporary ignored test for CI 2021-07-27 18:01:39 +02:00
Eric
acb8a377dd N°4036 - User edition controls : a user cannot change his own status (fix) 2021-07-27 17:40:00 +02:00
odain
d86f489c89 fix provided themes to avoid scss setup compilation 2021-07-27 17:22:24 +02:00
Eric
2c154b601d N°4036 - User edition controls : allowed orgs must contain user org 2021-07-27 15:57:03 +02:00
Eric
7dad079688 N°4036 - User edition controls : a user cannot remove contact 2021-07-27 15:57:03 +02:00
Eric
ace2eb6dab N°4036 - User edition controls : a user cannot change his own status 2021-07-27 15:57:03 +02:00
Eric
25f3c1cbc4 N°4036 - User edition controls : a user cannot add to himself a profile denying the backoffice 2021-07-27 15:57:03 +02:00
Eric
8f7e7c136d Fix links when object edition fails 2021-07-27 15:57:03 +02:00
Eric
71a7e060e4 N°4036 - User edition controls : a user cannot delete himself 2021-07-27 15:57:03 +02:00
Pierre Goiffon
c450f1d02f 💡 aModifierProperties documentation 2021-07-27 15:54:47 +02:00
acognet
4431762c10 N°3592 - Migrate module to new UIBlock system : Customized request forms - precompiled css v2 2021-07-27 15:33:47 +02:00
acognet
97170892e6 N°3905 - Polishing: CSV Import - remove spaces 2021-07-27 15:08:38 +02:00
acognet
5137d634e3 N°3592 - Migrate module to new UIBlock system : Customized request forms - precompiled css 2021-07-27 15:03:04 +02:00
acognet
146a95baec N°3592 - Migrate module to new UIBlock system : Customized request forms - remove space in edit screen 2021-07-27 14:38:44 +02:00
Pierre Goiffon
2b71ea108a Setup memory_limit check : clearer message
Now the current value is displayed as entered in the PHP conf
And the recommended value is displayed in a friendly format (32M instead of raw bytes value)
2021-07-27 11:37:05 +02:00
Molkobain
a7ac9126a2 PHPDoc 2021-07-26 18:07:12 +02:00
Eric
ee544b646d N°4076 - PHPDoc 2021-07-26 17:48:36 +02:00
Eric
344cce9fdd N°4076 - Allow block parameters to change the behaviour of blocks on the page 2021-07-26 17:20:45 +02:00
Stephen Abello
bfcfcdd4cc N°3930 Fix dashlet group by preview not displaying 2021-07-26 14:26:44 +02:00
Molkobain
4410bf7e1f N°4144 - Portal: Fix caselog fullscreen icon too small to be clickable 2021-07-26 12:07:49 +02:00
Eric
d1fda1dbc6 composer classmap changed 2021-07-23 16:47:15 +02:00
Stephen Abello
5c702be641 Update precompiled themes 2021-07-23 11:29:33 +02:00
Stephen Abello
8a9ad78e9c N°3930 Bring back error icons on dashlet property 2021-07-23 11:29:33 +02:00
Molkobain
778be8abce N°4195 - Avoid dictionary entries to be added to the setup page as it breaks the fresh install
In fresh install there is no env-xxx yet, so when the setup tries to load the english dictionary from there it crashes.
In setup pages, all string are hard coded, no dictionary entries are available (yet)
2021-07-23 09:00:19 +02:00
Molkobain
0760adcef6 Object details: Fix status code being set to the color instead of the code 2021-07-22 18:12:11 +02:00
Pierre Goiffon
29ca291860 N°4192 Fix error on Contract classes object details
Was crashing on all classes without state attribute, or with state attribute nullable
2021-07-22 11:07:07 +02:00
Stephen Abello
93d0e4ae7c Update jQuery datepicker z-index 2021-07-22 10:43:22 +02:00
Molkobain
61bc07b598 Add PHPDoc to explain behavior change (as in the migration notes) 2021-07-21 17:46:39 +02:00
Pierre Goiffon
00ee36f938 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	README.md
2021-07-21 12:22:20 +02:00
Pierre Goiffon
1aa5185c93 Merge remote-tracking branch 'origin/support/2.6' into support/2.7
# Conflicts:
#	README.md
2021-07-21 12:19:52 +02:00
Pierre Goiffon
834ac00d37 📝 README : update latest releases
Was made in #143 but on develop only, but we are still maintaining older branches !
2021-07-21 12:15:22 +02:00
Molkobain
957cb87b8d N°3786 - Fix lock removal when leaving an object details page in edition
The main problem was WebPage::$a_scripts are now printed after the DOM when the mechanism actually prints some JS to redirect to another page immediately.
As there are a LOT of calls to WebPage::add_script(), we kept it to ensure the compatibility; and we add a new WebPage::add_early_script() for JS snippets that explicitly need to be execute before the DOM interpretation.
2021-07-20 20:13:44 +02:00
Eric
d0813f6607 N°4169 - Fix forms properties for designer 2021-07-20 17:49:30 +02:00
Stephen Abello
cf4673d284 Update precompiled stylesheets 2021-07-20 10:21:06 +02:00
Stephen Abello
e3422f5fd9 CSS improvements 2021-07-20 10:20:31 +02:00
Stephen Abello
d7a0878a39 Fix broken variables import in 3.0 themes 2021-07-20 10:04:12 +02:00
Molkobain
076f0e00a7 N°4178 - Stay on the same page when logging again from the "Login again" prompt 2021-07-18 22:58:33 +02:00
Molkobain
eb04ecb5b4 Fix new URL parameter being append after the '#' in CombodoGlobalToolbox.AddParameterToUrl 2021-07-18 22:37:01 +02:00
Molkobain
3323d5532b JSDoc 2021-07-18 22:04:39 +02:00
Molkobain
d68d8204f2 N°4176 - Portal: Deprecate "AddParameterToUrl" function 2021-07-18 22:02:47 +02:00
Molkobain
4a50b95069 N°3924 - Fix misleading orphan activity entries when creating an object 2021-07-17 00:11:16 +02:00
Molkobain
fd9e4f413c N°3924 - Fix missing activity panel on object details when cancelling transition form 2021-07-16 22:53:28 +02:00
Molkobain
dca3fc996c N°3924 - Fix double encoding of the object name in transition page title 2021-07-16 22:39:15 +02:00
Molkobain
c58c1bbf1d N°3924 - Fix notification link in activity panel not opening notifications tab 2021-07-16 22:29:54 +02:00
Molkobain
524919b946 N°4171 - Remove lock message from the log entry form when object is in edition 2021-07-16 20:13:49 +02:00
Molkobain
e15953524a N°3786 - Add pause at the end of the page unload async request to follow the guideline used in N°2763 2021-07-16 20:08:25 +02:00
Molkobain
68f3c53faa N°4171 - Concurrent lock: Fix expiration modal being duplicated sometimes 2021-07-16 16:44:35 +02:00
Molkobain
82e3ddaacd N°4142 - Improve backoffice rendering by showing system avatar no matter what 2021-07-15 21:34:58 +02:00
Molkobain
dfbbee2a1c N°4142 - Add config. param. to hide user avatars in the GUIs -mostly in logs- (backoffice, end-users portal, ...) 2021-07-15 21:23:20 +02:00
Molkobain
4843545171 N°4142 - Fix UserRights::GetUserPictureAbsUrl() returning user's placeholder picture for users with an unknown login 2021-07-15 17:33:38 +02:00
Molkobain
4e58b8616a N°3203 - PHPDoc and small variable refactor 2021-07-15 17:31:30 +02:00
Molkobain
1a79dcd773 N°3203 - Portal: Fix image attribute of an object not authorized if object out of scope 2021-07-15 11:41:07 +02:00
Molkobain
a4104d4315 N°3539 - Remove viewport meta tag as we won't be able to make the backoffice responsive in 3.0 2021-07-15 09:09:47 +02:00
Molkobain
4e1db7d7e2 Merge remote-tracking branch 'origin/support/2.7' into develop 2021-07-13 11:44:42 +02:00
Molkobain
8e6379a112 Merge branch 'support/2.7.5' into support/2.7 2021-07-13 11:42:30 +02:00
Molkobain
da217a1cb3 N°4161 - Fix ManageBrick crash when no item listed 2021-07-12 18:10:22 +02:00
Pierre Goiffon
a683634a05 N°4126 Fix HTML escaped in \SetupUtils::CheckDbServer messages
As content is sent to JS returned to the AJAX request, we need to escape JS string delimiter (single quote)
We had previously a \utils::HtmlEntities call, but this isn't necessary as all content is generated internally, without calling any dict or extensibility interface.
2021-07-12 14:41:26 +02:00
Molkobain
2f1b5d2736 Fix typo in method parameter 2021-07-12 12:47:43 +02:00
Molkobain
c9bf784fce Revert space introduced by 418312bca 2021-07-12 11:37:17 +02:00
Molkobain
4ef10ae7c9 PHPDoc 2021-07-12 10:58:38 +02:00
Molkobain
5174250ff1 N°3836 - Dashlet: Refactor part of the code to match conventions 2021-07-12 10:51:45 +02:00
Pierre Goiffon
7b6ac202c6 N°4518 Add config parameter to set platform as dev env (#220)
developer_mode.enabled, default value null
If true or false then will be used by \utils::IsDevelopmentEnvironment as return value, in all other cases will follow previous behavior
2021-07-12 09:27:36 +02:00
Molkobain
d960183403 Merge remote-tracking branch 'origin/support/3.0.0-beta2' into develop 2021-07-09 16:28:00 +02:00
Eric
ece3e0490d N°3573 - Allow retrieving operation
(cherry picked from commit e6a38a8055)
2021-07-09 15:24:20 +02:00
Eric
1562cb1f38 🎨 Allow tab stickiness for twig based extensions
(cherry picked from commit 1a7755365c)
2021-07-09 15:23:35 +02:00
Molkobain
11a22abfd5 SCSS: Fix horizontal scrollbars being ticker than vertical ones on webkit browsers 2021-07-09 12:52:32 +02:00
Stephen Abello
5254c9a633 N°3930 Fix dashlets select property with a set size 2021-07-08 10:32:41 +02:00
Stephen Abello
f7a35072f5 N°4075 Fix autocompletes in modals 2021-07-07 16:59:50 +02:00
Molkobain
b5f5780f35 Merge remote-tracking branch 'origin/support/3.0.0-beta2' into develop
# Conflicts:
#	datamodels/2.x/itop-structure/precompiled-themes/fullmoon/main.css
#	datamodels/2.x/itop-structure/precompiled-themes/test-red/main.css
2021-07-07 15:08:38 +02:00
Molkobain
f9064084f9 N°4130 - Activity panel: Remove edits and transitions from default filters on logs 2021-07-07 14:11:03 +02:00
Molkobain
67afbd1d8d N°4146 - Fix crash on object deletion 2021-07-07 13:18:10 +02:00
Molkobain
d6b9172e26 N°4131 - Fix multiple "User disconnected" dialogs in the backoffice
(cherry picked from commit d8f36a8aa9)
2021-07-07 09:32:01 +02:00
Molkobain
8e1e71c740 N°4109 - Fix JS message "Gateway timeout" / "Unauthorized" / "" being displayed on object details page
(cherry picked from commit e279799bf8)
2021-07-07 09:31:53 +02:00
Molkobain
ebbf6e56be N°4127 - Security: Fix XSS vulnerability in object attribute's tooltip 2021-07-07 09:28:41 +02:00
Pierre Goiffon
bd67b71f3d Merge remote-tracking branch 'origin/support/2.7' into develop 2021-07-06 11:36:34 +02:00
Pierre Goiffon
69ad10785b 🔧 .editorConfig : disable PHP variables alignement
Still enabled for key/value pairs though ! Example in \UtilsTest::ConvertToBytesProvider
2021-07-05 12:34:20 +02:00
Pierre Goiffon
9aead898e2 Fix Wiki URL to use iTop Hub instead of wiki.openitop
Thanks @Molkobain and @Hipska !
2021-07-05 12:29:07 +02:00
Pierre Goiffon
a48ebfefba N°4126 Change max_allowed_packet error message
Thanks @Molkobain !
2021-07-05 09:54:47 +02:00
Pierre Goiffon
e2a6e6b846 💚 Fix compiled CSS 2021-07-05 09:53:11 +02:00
Molkobain
7ca689e190 Setup: Fix sizes being displayed as bits instead of bytes 2021-07-04 22:49:54 +02:00
Molkobain
d8f36a8aa9 N°4131 - Fix multiple "User disconnected" dialogs in the backoffice 2021-07-04 21:54:56 +02:00
Molkobain
e279799bf8 N°4109 - Fix JS message "Gateway timeout" / "Unauthorized" / "" being displayed on object details page 2021-07-04 16:46:49 +02:00
Eric
a117906ff6 🎨 Add constant for cmdbsource log channel 2021-07-02 17:01:46 +02:00
Pierre Goiffon
c76d4f12fd Fix constant remove in iTopHub:DBBackupSentence ZN dict key
Thanks Hipska for your feedback in the original commit 67e92120 !
2021-07-02 16:30:31 +02:00
Molkobain
b16529e337 Update version.xml to 3.0.0-beta2 2021-07-02 12:28:58 +02:00
Molkobain
67e9212008 Massively update dictionaries 2021-07-02 12:26:51 +02:00
acognet
35b70bfc00 N°3929 - Polishing: Dashboards 2021-07-02 11:29:10 +02:00
acognet
418312bca5 N°3930 - Polishing: Dashlets 2021-07-02 11:22:57 +02:00
Pierre Goiffon
4748717e50 N°4126 Improve max_allowed_packet checks messages 2021-07-02 10:10:35 +02:00
Pierre Goiffon
d90b1a3d82 🐛 N°4020 Fix syntax error for PHP < 7.1
`syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /var/www/itop274/setup/compiler.class.inc.php on line 61`
Was added in 1059befa
2021-07-02 09:26:03 +02:00
acognet
76a237aad4 N°3930 - Polishing: Dashlets 2021-07-01 17:28:35 +02:00
Pierre Goiffon
3694108f42 N°3870 updateLicenses : fix generating wrong product names on Windows
Was including paths fragments.

Example :
<product scope="datamodels">C:\Dev\wamp64\www\itop-dev\.make\license/../..//datamodels/2.x/authent-cas/vendor/apereo/phpcas</product>

Instead of :
<product scope="datamodels">apereo/phpcas</product>
2021-07-01 17:20:55 +02:00
Eric
1a7755365c 🎨 Allow tab stickiness for twig based extensions 2021-07-01 16:08:03 +02:00
Pierre Goiffon
8cf75f826f 🔨 updateLicenses : add logs and replace rm -f by unlink() 2021-07-01 15:30:33 +02:00
Molkobain
a1da086a64 Revert "Fix and simplify dynamic dictionaries load in ajax pages"
This reverts commit e46743af
2021-07-01 13:38:16 +02:00
Molkobain
5d1d6d07a6 Fix regression introduced in 9048d09bf 2021-07-01 10:55:50 +02:00
Eric
e6a38a8055 N°3573 - Allow retrieving operation 2021-07-01 10:40:04 +02:00
Molkobain
3b3f1806ce Fix resources URL not being printed correctly
If there was any parameters in the URL it would not work as the `&` would have been printed as `&amp;`, see similar issue in the previous commit
2021-07-01 09:55:01 +02:00
Molkobain
e46743af2a Fix and simplify dynamic dictionaries load in ajax pages 2021-07-01 09:55:00 +02:00
Molkobain
9048d09bf6 Fix JS dictionaries not being load in \WebPage 2021-07-01 09:55:00 +02:00
Molkobain
3cd03729b9 Setup: Fix "Reload" button style when config file is read-only 2021-07-01 09:55:00 +02:00
Eric
ff760dacbe N°3573 - Allow disabling buttons 2021-06-30 17:05:03 +02:00
Thomas Casteleyn
94f662c71a Show real next backup date (#196)
* Get the next backup date from what is scheduled in the background task.
* Show different message if cron is not running.
2021-06-30 14:59:36 +02:00
Eric
c7d87ad5b0 🎨 Display human readable sizes in bytes as int instead of float 2021-06-30 11:18:08 +02:00
Pierre Goiffon
ad9726b64c 🔧 .editorConfig : restore old ij_visual_guides value
Was overwritten by mistake in 19505649
2021-06-30 10:24:19 +02:00
Pierre Goiffon
e32e275f40 🎨 Align dataprovider elements 2021-06-29 16:45:34 +02:00
Pierre Goiffon
195056492e 🔧 .editorConfig : enable var alignement 2021-06-29 16:45:18 +02:00
Pierre Goiffon
aa9ab1ace5 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	css/css-variables.scss
#	datamodels/2.x/authent-cas/module.authent-cas.php
#	datamodels/2.x/authent-external/module.authent-external.php
#	datamodels/2.x/authent-ldap/module.authent-ldap.php
#	datamodels/2.x/authent-local/module.authent-local.php
#	datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php
#	datamodels/2.x/itop-attachments/module.itop-attachments.php
#	datamodels/2.x/itop-backup/module.itop-backup.php
#	datamodels/2.x/itop-bridge-virtualization-storage/module.itop-bridge-virtualization-storage.php
#	datamodels/2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php
#	datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php
#	datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php
#	datamodels/2.x/itop-config/module.itop-config.php
#	datamodels/2.x/itop-core-update/module.itop-core-update.php
#	datamodels/2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php
#	datamodels/2.x/itop-endusers-devices/module.itop-endusers-devices.php
#	datamodels/2.x/itop-files-information/module.itop-files-information.php
#	datamodels/2.x/itop-full-itil/module.itop-full-itil.php
#	datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php
#	datamodels/2.x/itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php
#	datamodels/2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php
#	datamodels/2.x/itop-portal-base/module.itop-portal-base.php
#	datamodels/2.x/itop-portal/module.itop-portal.php
#	datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php
#	datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php
#	datamodels/2.x/itop-request-mgmt-itil/module.itop-request-mgmt-itil.php
#	datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php
#	datamodels/2.x/itop-service-mgmt-provider/module.itop-service-mgmt-provider.php
#	datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php
#	datamodels/2.x/itop-sla-computation/module.itop-sla-computation.php
#	datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php
#	datamodels/2.x/itop-tickets/module.itop-tickets.php
#	datamodels/2.x/itop-virtualization-mgmt/module.itop-virtualization-mgmt.php
#	datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php
#	datamodels/2.x/version.xml
2021-06-29 16:12:49 +02:00
acognet
bfe22b4ec0 3836 - Dashlet: Finish visual rework 2021-06-29 16:08:02 +02:00
Molkobain
f84bc9fbbc N°4063 - Fix dashboard attribute's actions menu's dropdown being hidden behind dashlets 2021-06-29 14:37:53 +02:00
Pierre Goiffon
0dc03de7b2 Log channels : switch 3.0.0 channels to constant also
Those channels constants were introduced in support/2.7 with 8259a79c
2021-06-29 11:59:34 +02:00
Pierre Goiffon
af338de17f 🔨 Changelog generation script 2021-06-29 11:05:59 +02:00
Molkobain
0cffd567c2 N°4110 - Fix JS error message when no provider for the newsroom 2021-06-29 10:04:40 +02:00
acognet
9d006c279b N°3905 - Polishing: CSV Import - manage friendlyname 2021-06-29 10:01:19 +02:00
Molkobain
f410bff309 Object details: Fix columns overlapping (regression from 11f6c88ac) 2021-06-28 23:04:07 +02:00
Molkobain
0e9ff71c0a SCSS: Fix rules from 108bc2fa
- Don't nest selectors when there is no need to
- Use SCSS variables instead of CSS3 variables in SCSS files, otherwise we can't use SCSS functions. CSS3 variables should be kept for the front-end manipulations
2021-06-28 22:07:34 +02:00
Molkobain
a599a5c5b7 Add PHPDoc 2021-06-28 17:35:54 +02:00
Molkobain
84dae0fb37 Object details: Fix icon / color lost since 27e68404 2021-06-28 17:35:54 +02:00
Pierre Goiffon
65e3ef32ed N°3575 Change curl extension check error message
Thanks @Hipska !
2021-06-28 17:04:48 +02:00
Eric
0396914068 N°3513 - Write object creation history within the same DB transaction for better consistency 2021-06-28 16:59:05 +02:00
Eric
0e55a30e5a Fix DB transaction tests 2021-06-28 16:54:44 +02:00
Eric
c0fbf0c735 Fix DBObject::EvaluateExpression() tests 2021-06-28 16:21:46 +02:00
Molkobain
e59d472cec N°4108 - Portal: Fix linkedset items not correctly saved on add/remove (follow-up of N°3914) 2021-06-28 16:10:01 +02:00
acognet
27e6840442 N°4068 - Polishing: Object Creation 2021-06-28 15:35:37 +02:00
Pierre Goiffon
a6aa183e26 🔖 Prepare 2.7.5 2021-06-28 15:03:17 +02:00
Pierre Goiffon
b5074c4cee N°3806 Fix saying memory_limit isn't enough in CLI scripts and setup
This was caused by the strict comparison in \utils::IsMemoryLimitOk for the special "-1" value of memory_limit, which was added in c2f5cafa.
Fix was to change \utils::ConvertToBytes : it was returning original value when input was numeric (so if input is '-1' output was '-1')  now it always returns an int (input '-1' output -1)
2021-06-28 14:53:39 +02:00
Molkobain
fbb54c6d6d Add PHPDoc 2021-06-28 14:13:53 +02:00
acognet
95066fbc49 N°4085 - Polishing : bulk modify - remove console.warn 2021-06-28 14:02:18 +02:00
Molkobain
e2958bd43f Add missing quotes in JS selector 2021-06-28 14:01:38 +02:00
Eric
382135fde8 N°4106 - Deprecate usage of DBObject::GetName() 2021-06-28 14:00:44 +02:00
Eric
4d80235d89 🎨 add phpDoc 2021-06-28 13:58:12 +02:00
acognet
8b9589744b N°4020 - timeout on updating the hierarchical key during setup - php 5.6 compatibility 2021-06-28 13:56:49 +02:00
Molkobain
250d95c3eb N°4106 - Remove overloads of DBObject::GetName() 2021-06-28 13:19:41 +02:00
Molkobain
0997189969 N°4106 - Deprecate usage of DBObject::GetName() 2021-06-28 12:06:25 +02:00
Molkobain
410948fb4e Rename method to better match its usage 2021-06-28 10:36:43 +02:00
Molkobain
9f75fae33f Navigation menu: Restore user menu entries API 2021-06-28 10:36:42 +02:00
Pierre Goiffon
b1aebc6c7a DBObject : fix lines altered wrongly in merge commit 2021-06-28 09:12:18 +02:00
Pierre Goiffon
85526b1983 N°3575 Add curl as optional PHP ext 2021-06-28 09:04:50 +02:00
Pierre Goiffon
2a1e0b7429 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	core/dbobject.class.php
#	core/log.class.inc.php
#	setup/compiler.class.inc.php
2021-06-28 08:58:34 +02:00
jbostoen
3a73bd3b24 Version 2021-06-18 12:10:49
* support decimals in aggregate functions in dashlets
2021-06-25 17:43:37 +02:00
Eric
d7ba0aac82 N°4099 - remove unused DBObject::GetLoadedAttributes() method 2021-06-25 17:17:36 +02:00
Pierre Goiffon
8259a79cd2 🎨 Factorize LogAPI channels value in LogChannels class 2021-06-25 17:13:35 +02:00
Eric
de71d490c1 N°4099 - Fix object lists being very slow for classes with a overloaded GetName() function 2021-06-25 17:13:14 +02:00
acognet
60b015919d N°3912 - Polishing: Export - error message + ccs for pdf 2021-06-25 10:25:24 +02:00
acognet
2ca11aa2b7 N°3903 - Polishing: Query phrasebook 2021-06-25 10:15:40 +02:00
acognet
275daf3b0d N°4085 - Polishing : bulk modify 2021-06-25 10:11:57 +02:00
Eric
671d112452 Add Echoing for all pages KPI 2021-06-24 15:12:13 +02:00
acognet
a23ea9a01f N°3678 - Portal : a modification of field cannot hide another one 2021-06-24 14:11:41 +02:00
Eric
949b213f9d N°3513 - revert crud sequence 2021-06-24 13:32:43 +02:00
acognet
a940adc4ba N°3678 - Portal : a modification of field cannot hide another one 2021-06-24 10:35:01 +02:00
Pierre Goiffon
5d994edd62 N°4012 Fix debug trace syntax
Thanks @Molkobain !
2021-06-23 17:26:34 +02:00
Eric
2a9ce75db0 fix precompiled css 2021-06-23 12:22:11 +02:00
Pierre Goiffon
f8fcfc4d7d N°4083 - Polishing: Modal 2021-06-23 10:42:45 +02:00
Pierre Goiffon
663a9ab224 Fix code injection heredoc 2021-06-23 10:01:29 +02:00
acognet
f604821bdf N°4083 - Polishing: Modal 2021-06-23 09:38:22 +02:00
acognet
ac83c0334c N°3906 - Polishing: Users and profiles -> change size of datatable 2021-06-22 18:09:42 +02:00
acognet
457165b2fc N°4085 - Polishing : bulk modify 2021-06-22 17:34:14 +02:00
Eric
b1ca1f2630 N°3513 - ObjectFormManager : remove transaction
* Add automatic tests
* Fix object consistency
2021-06-22 16:09:41 +02:00
acognet
bce1bd8192 N°3912 - Polishing: Export 2021-06-22 12:24:32 +02:00
odain
4d123e1450 fix ci 2021-06-22 10:00:18 +02:00
acognet
58e315d7f6 N°4020 - timeout on updating the hierarchical key during setup - fix git ignore 2021-06-21 17:16:08 +02:00
acognet
1281d475e4 N°3912 - Polishing: Export : fix date entry + size of datatable 2021-06-21 16:50:19 +02:00
acognet
32ac999ff5 N°3912 - Polishing: Export - display of tabular fields 2021-06-21 16:47:02 +02:00
acognet
1059befa39 N°4020 - timeout on updating the hierarchical key during setup 2021-06-21 16:39:58 +02:00
Pierre Goiffon
5db8bd06ba Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	core/cmdbsource.class.inc.php
#	core/coreexception.class.inc.php
#	core/log.class.inc.php
2021-06-21 16:24:27 +02:00
Eric
0f5130611d Fix log API tests 2021-06-21 16:07:36 +02:00
Eric
a1271da74a N°3513 - ObjectFormManager : remove transaction 2021-06-21 15:03:17 +02:00
Denis
0d40235791 🗃️ N°3968 Fix mutex being silently released after connection timeout (#209)
Mutex are using their own DB connection
Because the `wait_timeout` isn't specified when opening the connection, it could be closed before we released the lock : if so the lock is silently released !
We are now setting this variable directly when opening the connection to avoid such case (setting 86400s, so 1 day : this should be enough !)
2021-06-21 12:33:15 +02:00
acognet
d1e594e225 Fix precompiled themes 2021-06-21 11:59:08 +02:00
acognet
bcc2d7140e N°3905 - Polishing: CSV Import 2021-06-21 09:41:36 +02:00
acognet
ee5847ec82 N°3912 - Polishing: Export - export of impact analysis 2021-06-21 09:22:07 +02:00
Eric
108bc2fa1d N°3573 - Migrate backoffice pages to new UIBlock system : System Information 2021-06-18 17:16:22 +02:00
acognet
efb7f84ec4 Fix precompiled themes 2021-06-18 17:12:31 +02:00
acognet
224031e0d6 N°3905 - Polishing: CSV Import 2021-06-18 17:00:39 +02:00
Stephen Abello
e905838733 Revert layout changes from 11f6c88 as they break dashlet table 2021-06-18 13:54:54 +02:00
Pierre Goiffon
dd63f2b817 N°4012 Debug trace for objects lists in portal : ManageBrick and BrowseBrick
'portal' channel, debug level
2021-06-18 10:58:04 +02:00
Pierre Goiffon
8f84c3b84b 🎨 LogAPI code formatting 2021-06-18 10:58:04 +02:00
Stephen Abello
bc4f384948 N°4082 Add missing German translation (many thanks to ITOMIG!) 2021-06-18 10:02:09 +02:00
Pierre Goiffon
00c58bb245 💡 updateLicenses.php : copy phpdoc from develop branch 2021-06-17 17:11:30 +02:00
acognet
11f6c88ac7 N°3905 - Polishing: CSV Import 2021-06-17 11:16:31 +02:00
acognet
77cf879f4f N°3912 - Polishing: Export 2021-06-17 10:43:06 +02:00
acognet
13f6f6ebe6 N°3551 - Migrate module to new UIBlock system : Customer Survey 2021-06-17 09:42:28 +02:00
odain
c413ac989e fix ci: add anotations to be able to exclude tests 2021-06-16 18:25:10 +02:00
Stephen Abello
7a770b32ee N°4082 Update German translations (many thanks to ITOMIG!) 2021-06-16 14:44:51 +02:00
vdumas
9d8adae5c7 N°4079 fix FR dictionary typo 2021-06-15 18:10:54 +02:00
Stephen Abello
b0531597f0 Update precompiled themes 2021-06-15 15:22:28 +02:00
Stephen Abello
0bdf43b085 Fix "Enter iTop" button 2021-06-15 15:21:51 +02:00
Stephen Abello
27da8470b7 Harmonize setup look with backoffice one and force navigation buttons to remain at the same position at every setup step 🙉🙉🙉 2021-06-15 15:03:50 +02:00
Stephen Abello
c0be48ceee Remove deprecated import 2021-06-15 14:00:51 +02:00
Stephen Abello
6c561029e9 N°4074 Show date picker above object and display today's date / selected date 2021-06-15 10:38:29 +02:00
Pierre Goiffon
c417a454d6 New symlink flag set by the compiler, new compile with symlinks checkbox in the setup (#190)
The flag consists of the new `data/.compilation-symlinks` file, which is included in the code base (but not available in the Combodo packages).

It will be used and generated if and only if : 
* we are on a dev env (`\utils::IsDevelopmentEnvironment`)
* the `symlink` PHP function exists

The flag is generated low level in the compiler (\MFCompiler::DoCompile)

In the setup, if the flag is present and all conditions are met then a new option will be displayed in the "Miscellaneous Parameters" wizard step. When unchecking/checking the flag will be updated accordingly by an ajax query.

All other compiler consumers (Designer / Hub connectors, Core Update, scripts using `RunTimeEnvironment` class) will : 
* if they provide a value for the symlink option, it will be used
* otherwise the flag will be used instead, if conditions are met
2021-06-14 16:44:34 +02:00
Pierre Goiffon
d8e2a1cc7c Merge branch 'support/2.7' into develop
# Conflicts:
#	README.md
#	composer.json
#	composer.lock
#	core/cmdbsource.class.inc.php
#	core/dbobject.class.php
#	datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php
#	datamodels/2.x/combodo-db-tools/dbtools.php
#	datamodels/2.x/combodo-db-tools/dictionaries/zh_cn.dict.combodo-db-tools.php
#	datamodels/2.x/itop-attachments/dictionaries/zh_cn.dict.itop-attachments.php
#	datamodels/2.x/itop-core-update/dictionaries/zh_cn.dict.itop-core-update.php
#	dictionaries/zh_cn.dictionary.itop.core.php
#	dictionaries/zh_cn.dictionary.itop.ui.php
#	lib/composer/InstalledVersions.php
#	lib/composer/autoload_classmap.php
#	lib/composer/autoload_static.php
#	lib/composer/installed.php
#	lib/composer/platform_check.php
#	pages/ajax.render.php
#	pages/csvimport.php
#	setup/ajax.dataloader.php
#	setup/index.php
#	setup/setuputils.class.inc.php
#	test/application/UtilsTest.php
2021-06-14 16:19:56 +02:00
Stephen Abello
51e24a4e35 Replace htmlentitites() call with escapehtml() 2021-06-14 12:15:09 +02:00
Stephen Abello
a82f172ca4 Fix wrong id being used for datatables twig variable name 2021-06-14 12:01:29 +02:00
Stephen Abello
8ef43452f8 Fix multiple typo in datatables twig variables 2021-06-14 12:01:29 +02:00
Molkobain
18a4867b4d Accessibility: Add missing aria-label / tooltip attributes on the advanced search 2021-06-13 09:43:22 +02:00
Molkobain
ff05a1d35e Accessibility: Add missing alt attribute on decorative images
- Dashlet badge
- Dashlet header static
2021-06-12 22:52:48 +02:00
Molkobain
5a4c9393a4 Add missing viewport meta from webpage template
(Backoffice won't be responsive in iTop 3.0)
2021-06-12 19:26:25 +02:00
Molkobain
4b03b42494 Remove inline CSS from NavigationMenu 2021-06-12 19:13:41 +02:00
Molkobain
215dcfb465 Dictionaries: Group files by block for an easier navigation through them 2021-06-12 18:47:32 +02:00
Molkobain
b965138d57 Accessibility: Add missing aria-label to some UIBlock
- Button
- Global search
- Quick create
- Navigation menu
- Tab container
2021-06-12 18:35:55 +02:00
Molkobain
485262ec0a Accessibility: Add missing alt attribute on decorative images
- Quick create
- Global search
- Breadcrumbs
2021-06-12 18:35:54 +02:00
Stephen Abello
dd8a51ea1b N°3910 Correctly escape object tags (such as "synchronized") tooltip content 2021-06-11 13:54:43 +02:00
acognet
d85729803d N°3907 - Polishing: Run query 2021-06-11 11:42:11 +02:00
acognet
3132d665e0 forgot an addSubBlock 2021-06-11 11:42:11 +02:00
Stephen Abello
be03f3c6de N°4048 Fix default sorting on lists when using custom list settings without sort order 2021-06-11 10:48:06 +02:00
Eric
3a876d5c75 Log complete error on Memory Limit or max execution time 2021-06-11 09:36:01 +02:00
Pierre Goiffon
147916062b 🎨 Fix local variable names
Was copy/paste and wasn't consistent with the functionnality :/
2021-06-10 16:28:17 +02:00
Stephen Abello
bcfdf76b71 N°4051 Make sure js dependencies are met before resuming ajax calls js code 2021-06-10 15:12:16 +02:00
Stephen Abello
679542eaaa N°4051 Add robustness 2021-06-10 15:12:16 +02:00
Stephen Abello
4d5ff22b60 Fix variable declaration in datatables 2021-06-10 15:12:16 +02:00
Eric
d54c5b5f55 🐛 fix parameters for OptimizeColumnLoad() 2021-06-09 14:43:38 +02:00
Pierre Goiffon
0de6f98add 🔊 When ordering objects search list, log problems due to low max_input_vars php.ini option (#211)
iTop is sending large volume of data to the server, and those data can be truncated due to this php.ini option.
Now we are checking for common issues : if the data is truncated a log is done (IssueLog, warning level, no channel) and the corresponding column is set as not selected.
User will still see an inconsistent result, but we won't have PHP notices generated anymore, and a log can tell what caused the issue.
2021-06-08 18:43:43 +02:00
acognet
5bf6035bcf N°3592 - Migrate module to new UIBlock system : Customized request forms - fix input select 2021-06-08 18:40:49 +02:00
Pierre Goiffon
a076792e77 ⬆️ N°3973 Update update pear/archive_tar 2021-06-08 18:16:12 +02:00
dependabot[bot]
73132f981e Bump pear/archive_tar from 1.4.10 to 1.4.12 (#219) 2021-06-08 16:06:48 +00:00
Stephen Abello
80e4a46a20 Fix Selectize being re-instantiated (and destroying extkey selectize plugin instance) when creating an inline object containi tagsets 2021-06-08 16:09:37 +02:00
Molkobain
95d9b845b6 SCSS: Enlarge pills max width 2021-06-04 17:16:05 +02:00
Eric
609d9c7a60 ♻️ rework of Select UIBlock with labels 2021-06-04 11:52:24 +02:00
Stephen Abello
3d338aff33 Fix block loader style for datatables 2021-06-04 11:44:28 +02:00
Stephen Abello
8a46900df9 Fix collapsible section widget being called before dependency was loaded 2021-06-04 11:17:57 +02:00
Molkobain
8efbfd13d0 Update precompiled themes 2021-06-04 11:10:46 +02:00
Molkobain
19264a7d64 Fix iTopWebPage::DisableBreadCrumb() not working since 3.0 rework 2021-06-04 11:01:51 +02:00
Molkobain
742e3a2a20 SCSS: Replace font global redefinition with more accurate overloads (only size, only weight, ...) to simplify styles inheritance 2021-06-04 11:01:50 +02:00
Molkobain
117bf3046d Attribute file: Fix delete button not on the same line as the filename 2021-06-04 11:01:50 +02:00
Molkobain
b072e1bb3d SCSS: Add font size variables / helpers 2021-06-04 11:01:50 +02:00
Molkobain
d405fc0675 SCSS: Fix base font 2021-06-04 11:01:50 +02:00
Molkobain
77527987ee SCSS: Add font weight variables / helpers 2021-06-04 11:01:49 +02:00
Stephen Abello
2e6b773ba4 Fix non existing variable usage 2021-06-04 10:57:06 +02:00
Stephen Abello
dd6a9fe16a Restyle block loader 2021-06-04 10:52:24 +02:00
Stephen Abello
d9ccc620c9 Remove trailing quote 2021-06-04 10:50:51 +02:00
Stephen Abello
b245275c7d N°3914 Fix configure this list button alignment and add background color to selected fields 2021-06-04 10:28:12 +02:00
Stephen Abello
bf22c8b67a N°3914 Fix highlighted rows highlighting following rows too 2021-06-04 10:28:11 +02:00
Stephen Abello
1b58d9b801 N°3914 Fix add criteria buttons style 2021-06-04 10:28:11 +02:00
acognet
2d2a6857de N°3797 - [MariaDB] crash while converting utf8mb4 + add index 2021-06-04 09:10:28 +02:00
Pierre Goiffon
373641e01d 🎨 Code formatting 2021-06-03 17:31:34 +02:00
Eric
d11eceac62 N°4052 - OQL parser limit for huge request - fix CI 2021-06-03 17:07:17 +02:00
Eric
3965806fa0 N°4052 - OQL parser limit for huge request - add better feedback 2021-06-03 16:49:21 +02:00
Molkobain
74eabafe31 N°4022 - Fix scroll not working on search menu nodes 2021-06-03 16:19:06 +02:00
Pierre Goiffon
2625d2da80 💡 PHPDoc 2021-06-03 15:29:13 +02:00
Molkobain
1b9eb2a6ad N°4022 - Rework search page to improve UX and usable height 2021-06-03 09:54:21 +02:00
Molkobain
94c37b2e14 Update CONTRIBUTING.md with thanks stickers (#213)
* Update CONTRIBUTING.md with thanks stickers

* Update CONTRIBUTING.md

Co-authored-by: Pierre Goiffon <pierre.goiffon@combodo.com>

Co-authored-by: Pierre Goiffon <pierre.goiffon@combodo.com>
2021-06-03 09:53:01 +02:00
Pierre Goiffon
71d2d61c4e 💡 Fix phpdoc for \MenuBlock::GetEnumAllowedActions 2021-06-03 09:04:26 +02:00
Stephen Abello
020dc8b819 N°4049 Remove dashlet list free will 👾 2021-06-02 16:59:14 +02:00
Stephen Abello
c11ad30134 N°4048 Correctly set default sorting on lists 2021-06-02 15:22:03 +02:00
Eric
02d32a556d N°4052 - OQL parser limit for huge request 2021-06-02 15:15:00 +02:00
Eric
71fcc6f026 N°4031 - OQL Error when AttributeObjectKey is used in JOIN condition 2021-06-02 14:45:03 +02:00
Molkobain
dd614f5931 Fix regression introduced by c6b8526d: FormTable not working in edition 2021-06-02 10:22:24 +02:00
Stephen Abello
499d429a0e N°3927 Fix Attachments delete button 2021-06-02 10:01:37 +02:00
Purple Grape
7168860a0b 🌐 Improved chinese for 2.7 (#218) 2021-06-02 08:06:16 +02:00
Pierre Goiffon
a395c1760a N°4047 skip test generating a PHP notice
Will be fixed later
2021-06-01 16:51:44 +02:00
Stephen Abello
4033773849 N°3932 Fix button style for hierarchical key selector 2021-06-01 15:43:42 +02:00
Stephen Abello
9fd6ba414d N°3914 Fix search from external key widget 2021-06-01 10:20:57 +02:00
Molkobain
2aee978790 Update precompiled themes 2021-06-01 09:11:30 +02:00
Molkobain
39efe1237e Fix regression in AJAX calls introduced by c6b8526d 2021-06-01 09:04:20 +02:00
acognet
684c88e0b8 N°4038 - Pop up erreur portail utilisateur 2021-05-31 23:43:58 +02:00
Molkobain
e7c7ca76ac Switch page class to non deprecated 2021-05-31 17:41:06 +02:00
Molkobain
a6e5969201 N°4021 - Fix header jumping out of sticky positioning when getting near some tabs
Reason: DataTables' dynamic height cannot work we a static "duration" (height) based on the initial panel's height
2021-05-31 13:15:10 +02:00
Molkobain
1e99ad436f N°4021 - Add support for tab container for the sticky header 2021-05-31 09:32:37 +02:00
Molkobain
8580eb6d2b PHPDoc 2021-05-28 22:45:37 +02:00
Molkobain
c6b8526dc0 UIBlock: Add external JS/CSS files (optional) inheritance
This way we ensure that a block always have the external resources from its ancestors as this will be necessary most of the time. From now on, the JS widget of the blocks will inherit from a common ancestor to factorize some mechanisms that are duplicates at many levels.
This can be disabled in a particular block by overloading the INCLUDE_ANCESTORS_DEFAULT_XXX_FILES constants in which case, only the external files of the block itself will be included.
2021-05-28 22:45:37 +02:00
Molkobain
03c7d63588 JsonPage: Add option to output only the data, typically when feeding a third party lib that doesn't understand our structuration 2021-05-28 22:45:37 +02:00
Molkobain
32e714f4a6 Panel: Fix scrollable tabs with sticky header 2021-05-28 22:45:36 +02:00
Molkobain
b8ef4885e5 N°4021 - Change approach for sticky header, use the ScrollMagic lib as in the scrolling tabs to use the same abstraction level everywhere 2021-05-28 22:45:36 +02:00
Molkobain
e669cfcea1 SCSS: Add 2 helpers classes to make elements transparent or opaque 2021-05-28 22:45:36 +02:00
Molkobain
82f0cd5f3d SCSS: Improve container space occupation 2021-05-28 22:45:36 +02:00
Molkobain
b6661fde86 SCSS: Improve panel space occupation by removing unnecessary margins 2021-05-28 22:45:36 +02:00
Eric
e46480032e PHP doc 2021-05-28 18:04:11 +02:00
Thomas Casteleyn
aed1e7dfdc 🌐 Update Dutch dictionaries for 3.0 (#199)
* Update UI components

* Global cleanup

* Update UI layouts

* Update UI pages

* Update core dictionaries

* Minor change

* Fix newline

* Conform with English text

* Applied changes suggested by @jbostoen

* Changed to capital as in original English value
2021-05-28 17:17:08 +02:00
Stephen Abello
b32fd7e018 N°3914 Fix tagset taking too much space in lists 2021-05-28 11:15:50 +02:00
Stephen Abello
3ae8575c1d N°3914 Fix portal tables getting backoffice markup for enum attributes 2021-05-28 11:00:40 +02:00
Stephen Abello
cc4b307bc9 N°3914 Fix class friendlyname in lists using class aliases 2021-05-28 10:48:57 +02:00
Stephen Abello
6d004f83dd N°3914 Correctly remove entries from linksets' datatable 2021-05-28 10:21:41 +02:00
Eric
5691ca0327 Fix CI 2021-05-28 08:48:47 +02:00
Stephen Abello
8f68ca3f67 N°3914 Display label on "Add criterion" button when there's no criterion. Add tooltips to "Add criterion" and "Refresh" button 2021-05-27 17:12:14 +02:00
Eric
84741c19f0 N°4002 - code hardening (merge from support/2.6) 2021-05-27 16:36:00 +02:00
Eric
96126d235f N°2214 Add PHP check in CLI scripts (fix some checks and title) 2021-05-27 16:31:15 +02:00
Stephen Abello
4de40e289f N°3914 Add row highlight colors to Datatables block when an object has a triggered tto/ttr 2021-05-27 16:14:29 +02:00
Eric
86f649affc N°4002 - code hardening 2021-05-27 16:13:27 +02:00
Eric
4f5c987d8b N°4002 - code hardening 2021-05-27 15:57:04 +02:00
Stephen Abello
9ccd26a541 N°3914 Harmonize linkset display 2021-05-27 12:15:58 +02:00
Eric
e7b5953feb documentation 2021-05-27 11:52:38 +02:00
Eric
e441e5e78a documentation 2021-05-27 11:49:32 +02:00
Stephen Abello
6d57945bd1 N°3914 Hide lists pagination when there's only 1 page 2021-05-27 11:20:48 +02:00
Stephen Abello
0cb0f52b12 N°3914 Fix lists header and data being misaligned when resizing them 2021-05-27 09:59:31 +02:00
Eric
6be9a87c15 N°3952 - code hardening (merged from support/2.6) 2021-05-27 09:55:16 +02:00
Eric
43daa2ef08 N°3952 - code hardening 2021-05-27 09:29:50 +02:00
Molkobain
8f9a69fa60 SCSS: Fix field badge display being in 2 lines 2021-05-26 22:00:55 +02:00
Molkobain
1d94e12da8 Update precompiled themes 2021-05-26 16:57:31 +02:00
Molkobain
0a04fe5917 SCSS: Add fallback fonts to minimize visual glitch while Raleway is not loaded 2021-05-26 16:55:10 +02:00
Molkobain
b03389068e SCSS: Fix large field not taking whole width 2021-05-26 16:55:10 +02:00
Stephen Abello
c9171ef30e N°3923 Cleanup css files 2021-05-26 15:55:57 +02:00
Stephen Abello
3853d38d69 N°3923 Fix up, down, enter key usage in ext key widget 2021-05-26 15:43:32 +02:00
Pierre Goiffon
caa2a05bf4 🔧 restore .editorconfig
Was moved to /test by mistake
And also editorconfig syntax was removed :(
Those mistakes were done in 7f15eed9
Thanks Molkobain, good catch !
2021-05-26 15:19:40 +02:00
Pierre Goiffon
fc39d8aca9 💡 PHPDoc type hinting 2021-05-26 14:24:29 +02:00
Stephen Abello
022887258f N°3923 Hide caret in autocomplete ext key input 2021-05-26 14:11:13 +02:00
Eric
cf12578289 N°3452 - DB tools : better formatting 2021-05-26 12:14:14 +02:00
Stephen Abello
3105a7ef77 N°3923 Vertical align ext key action buttons 2021-05-26 11:20:43 +02:00
Molkobain
f5ee19370c Update precompiled themes 2021-05-26 10:43:49 +02:00
Molkobain
923134d67d Code cleanup
- "v-resizable" class is not used anymore in the UI
- Logoff menu is now handled in a dedicated block
- Caselog headers are now handled in a dedicated block
2021-05-26 10:37:03 +02:00
Molkobain
3c2c2d7a51 Code cleanup: Remove unused methods from early implementation 2021-05-26 10:37:02 +02:00
Molkobain
3ee4a14c56 N°4021 - Introduce sticky header for panels and object details (tab container to be done) 2021-05-26 10:37:02 +02:00
Molkobain
dd284a6c1d SCSS: Fix base content layout not behaving the same way as the one with side content 2021-05-26 10:37:02 +02:00
Molkobain
c240a8991d SCSS: Fix import ordering of the custom root folders 2021-05-26 10:37:02 +02:00
Molkobain
0948c46dc7 SCSS: Add more variables for jQuery UI 2021-05-26 10:37:02 +02:00
Molkobain
d9755fe59d Code format 2021-05-26 10:37:02 +02:00
Stephen Abello
7f82e9262b N°3923 Fix date picker widget not initialized in ajax forms 2021-05-26 10:21:30 +02:00
Pierre Goiffon
44952d1ea0 Fix \UtilsTest::testIsMemoryLimit 2021-05-25 17:04:32 +02:00
Pierre Goiffon
7f15eed9a8 🔧 Update .editorconfig
* Preserve XML line breaks
* Add markdown
* Add editorconfig
2021-05-25 15:50:23 +02:00
Stephen Abello
14930fbab2 N°3914 Fix configure this list "sort fields" feature 2021-05-25 15:38:52 +02:00
Stephen Abello
2cbca93d77 N°3914 Fix modal backdrop on lists' "configure this list" modal 2021-05-25 14:54:54 +02:00
BGdu38
c2f5cafaf3 Avoid setting memory_limit to lower value than the one already configured (#215)
Some scripts are setting the memory_limit PHP option : setup, csvimport and XLSX export. This was done to avoid crashing when dealing with such large amount of data.
But sometimes we were setting the value without any prior check, so we could actually lower the memory_limit value :/

Now this memory_limit change is done using \utils::SetMinMemoryLimit, which will call ini_set if and only if the current value is lower than the one to be set.

Setup calls (setup/ajax.dataloader.php and webservices/backoffice.dataloader.php) were left as is as they weren't subject to this bug, and also they are more complex (logging done on each case).
2021-05-25 12:03:19 +02:00
Pierre Goiffon
81822efa0f 💡 PHPDoc for \DBObject::ApplyStimulus 2021-05-25 10:52:12 +02:00
Molkobain
104cf9479c List: Remove vertical scrolling for all lists except dashlets 2021-05-21 17:06:12 +02:00
Molkobain
a36632def6 Fix modal title displaying behind closing "X" on long titles 2021-05-21 17:06:12 +02:00
Molkobain
6a1b1d7740 Code format 2021-05-21 17:06:11 +02:00
Molkobain
f544d53c36 List: Fix height / scroll for linkedsets add items modal 2021-05-21 17:06:10 +02:00
Pierre Goiffon
3188204d05 📝 CONTRIBUTING : add "allow edits from maintainers" PR option 2021-05-21 11:28:48 +02:00
Molkobain
a7294d48a6 Update precompiled themes 2021-05-20 19:08:46 +02:00
Molkobain
42be0c20cb Field: Rework on the SCSS file
- Fix button being too large on AttributeImage
- Reorganize the classes a bit
2021-05-20 18:18:29 +02:00
Molkobain
1c6ffab0e3 Remove index variable from foreach as it was misleading ($sClass does not contain classes but a numeric index) 2021-05-20 18:18:29 +02:00
Molkobain
095d61b6f9 N°3171 - Rollback on the AttributeExternalKey::GetPrerequisites() as it was introducing more regressions than fixes (acf0548c) 2021-05-20 18:18:29 +02:00
Pierre Goiffon
923a025f1c 🌐 N°4017 Report pt_br translations for TTO/TTR made in combodo-dispatch-incident
Those dict keys were wrongly duplicated in this module, but they are core iTop !
Original commit 75f00d993c
Thanks to @rokam !
2021-05-20 15:51:21 +02:00
Pierre Goiffon
a4b6f4e37c 👥 Add @rokam to contributors list
Thanks to him for his PT-BR translations !
2021-05-20 15:44:24 +02:00
Stephen Abello
78b2824c13 N°3914 Harmonize advanced search's external key search buttons style and positions on modals and fix add button id 2021-05-20 15:38:31 +02:00
Pierre Goiffon
f0c73451a2 🌐 N°4017 Report pt_br translations for TTO/TTR made in combodo-dispatch-userrequest
Those dict keys were wrongly duplicated in this module, but they are core iTop !
Original commit 9725897623
Thanks to @rokam !
2021-05-20 15:30:00 +02:00
Stephen Abello
62f5eb5ae9 N°3914 Harmonize external key / linksets buttons style and positions on modals 2021-05-20 15:06:39 +02:00
Stephen Abello
7d9416cc81 Fix indirect links block height 2021-05-20 15:02:51 +02:00
Molkobain
a82a2df6aa N°1964 - Add informative message on dashboard when its container (eg. an object) is currently in edition 2021-05-20 10:32:28 +02:00
Molkobain
f1e4120364 Fix text decoration icon size being too big 2021-05-20 10:32:28 +02:00
Pierre Goiffon
3471d9d693 Protect \iApplicationUIExtension::EnumAllowedActions uses (#214)
Some impl just return null while we expect to have an array... This is causing PHP notices in lots of iTop instances with modules implementing this method incorrectly !

This modification get rid of the notice and : 
* add a log (warning level) indicating the impl classes
* if dev env, then throw an exception after browsing all impl (so you get a complete invalid impl list)

Note : since iTop 2.7.0 you should use \AbstractApplicationUIExtension instead of implementing the whole interface !
2021-05-19 14:58:55 +02:00
Molkobain
6d7bcb8a7c N°3956 - Fix AJAX error when creating an object which has a linkedset with a friendlyname composed of its own external keys' friendlynames 🤪 2021-05-18 17:58:37 +02:00
acognet
db6e813cba N°3945 - Password database is visible in the setup process 2021-05-18 17:34:57 +02:00
Pierre Goiffon
d74e3e6b42 💡 ItopTestCase : some PHPDoc 2021-05-18 17:16:04 +02:00
acognet
e9648ad75e N°3766 - Migrate module to new UIBlock system : Gantt view - fix error message when the class doesn't exist 2021-05-18 13:46:07 +02:00
Molkobain
e53da47647 UIBlock: Add MakeRaw to the HTML factory 2021-05-18 10:46:27 +02:00
Molkobain
1128490d47 N°2982 - Branding: Theme imports with no xsi:type are ignored 2021-05-17 17:51:08 +02:00
Molkobain
186ef1689e CI: Fix folder creation on Windows environments 2021-05-17 17:44:01 +02:00
Molkobain
0487cb8701 N°3914 - Fix single row selection in the portal's datatables 2021-05-17 13:49:17 +02:00
Molkobain
27b930c31c N°3914 - Fix rows selection in the portal's datatables 2021-05-17 13:47:41 +02:00
Molkobain
a8ef1c7899 N°3796 - Make designer compatible with iTop 3.0 2021-05-17 08:55:21 +02:00
Molkobain
644f0bc94c N°1964 - Fix missing parenthesis in previous commit 2021-05-14 11:31:35 +02:00
Eric
f3b0f79a59 N°3796 - Make designer compatible with iTop 3.0 2021-05-12 15:42:57 +02:00
Molkobain
eaae79a5f0 N°1964 - Fix focus moving to another tab on modification when one tab is readonly 2021-05-12 10:34:00 +02:00
Pierre Goiffon
bc10baed3e :bulb PHPDoc 2021-05-12 09:06:48 +02:00
acognet
b740cb2afd N°2540 - prevent the mysql password to appear on misconfigured servers 2021-05-12 08:17:35 +02:00
Molkobain
c0ec7e02f8 N°3939 - Keep focus on current tab on object modification 2021-05-11 16:34:54 +02:00
Stephen Abello
5977c5dd9e N°4007 - When a search is on auto submit, auto submit it also on first display 2021-05-11 14:16:40 +02:00
Molkobain
1c2dcc7b9a Merge remote-tracking branch 'origin/support/2.7' into develop 2021-05-11 12:22:47 +02:00
Molkobain
6ad3c40c42 Merge branch 'support/2.7.4' into support/2.7 2021-05-11 12:14:36 +02:00
Molkobain
f49c8ce188 Merge branch 'support/2.7.3' into support/2.7.4 2021-05-11 12:13:29 +02:00
Molkobain
acf828b72e N°3995 - Portal: Fix loader not displaying in BrowseBrick for tree/mosaic modes with huge amount of data 2021-05-11 12:10:31 +02:00
Molkobain
cb61d85572 N°3990 - Forgot to update descending migration method so it applies _delta flag where its needed 2021-05-11 09:28:04 +02:00
Molkobain
626316e8d1 N°3990 - Compiler: Set "_delta" flag on moved node if no ancestors has one 2021-05-10 19:05:08 +02:00
Molkobain
ab30bae46a Tests: Rename test and move samples to dedicated directory 2021-05-10 19:05:07 +02:00
Molkobain
bd2c0d1121 Tests: Simplify XML sample 2021-05-10 19:05:07 +02:00
Molkobain
64764228a9 DownloadPage: Fix ->add() method replacing all existing content instead of appending 2021-05-10 10:32:50 +02:00
Molkobain
463593d6cf PHPDoc 2021-05-10 10:28:51 +02:00
Molkobain
85aac7bf52 N°3949 - Fix XSS vulnerability on file attribute 2021-05-10 10:23:56 +02:00
Molkobain
dc36b4648d Add spaces to avoid errors on concatenation when used with spaceless filter 2021-05-06 12:34:46 +02:00
Molkobain
25145a68af Fix disabled property on textarea input 2021-05-06 12:33:46 +02:00
Molkobain
dab522caca SCSS: WIP attempt to apply some of the UIBlocks style to bare HTML markup 2021-05-05 18:38:12 +02:00
Molkobain
88634bcd92 SCSS: Refactor .is-code by moving it to helper file and renaming it 2021-05-05 18:29:33 +02:00
Molkobain
6ab6930986 SCSS: Refactor code typography
- New variables to defines base / code font families
- New helpers for code typography in all sizes
2021-05-05 18:25:37 +02:00
Molkobain
1f3b467083 SCSS Doc 2021-05-05 18:23:16 +02:00
Molkobain
34647cc402 Fix MetaModel::EnumPlugins unit tests 2021-05-05 14:58:50 +02:00
Molkobain
2a9e16bd2c Fix PluginManager not returning plugin classes as keys of the array (broke iQueryModifier) 2021-05-05 14:27:19 +02:00
Molkobain
ed1fdfa830 Update precompiled stylesheets 2021-05-05 11:59:30 +02:00
Molkobain
1124a584cd Fix iPopupMenuExtension::MENU_OBJLIST_TOOLKIT being called in an object's details 2021-05-05 11:16:34 +02:00
Molkobain
d2c014f718 Remove deprecated / autoloaded files calls 2021-05-04 18:26:37 +02:00
Molkobain
e488ec8c38 N°3914 - Fix "toolkit" actions not being displayed in the menu 2021-05-04 18:26:37 +02:00
Molkobain
18b2e54581 N°3914 - Popover menu: Refactor PopoverMenuFactory::MakeMenuForActions() to benefit from the new PopoverMenuItemFactory methods 2021-05-04 18:26:37 +02:00
Molkobain
3c89313795 N°3914 - Popover menu: Add method to add several items in a section at once 2021-05-04 18:26:37 +02:00
Molkobain
11278d7ba5 N°3914 - Popover menu: Add 2 methods to the items factory
- Create a separator
- Create an item from the array data as prepared by \DisplayBlock
2021-05-04 18:26:37 +02:00
acognet
a6eeb3a50a N°3907 - Polishing: Run query - css -add precompiled themes 2021-05-04 12:58:39 +02:00
acognet
1f1028bbc0 Migrate CCS style of checkbox to new UIBlock system 2021-05-04 12:42:09 +02:00
acognet
08f973f8c0 N°3907 - Polishing: Run query - css 2021-05-04 12:42:09 +02:00
odain
ad22113881 add annotation to be able to exclude test 2021-05-04 12:28:07 +02:00
acognet
e5498e3292 Fix link on key in datatable 2021-05-04 11:58:05 +02:00
acognet
16c9599739 N°3819 - Input: Migrate request templates input to new UIBlock system 2021-05-04 11:55:20 +02:00
acognet
a7040a911d Value from search popup is now correctly selected 2021-05-04 11:19:33 +02:00
Pierre Goiffon
8227796c87 💄 N°3913 Setup : fix license content overflow in "license agreement" step
Added `white-space: pre-wrap;` in setup.scss as all pre tags inside the setup container are subject to this problem because this container has a specific width set.
2021-05-04 09:38:00 +02:00
Pierre Goiffon
bac92716f3 📄 Update Font Awesome license
Was duplicated...
And also not the correct license !
Source for new license text : https://github.com/FortAwesome/Font-Awesome/blob/master/LICENSE.txt

(modification already committed to develop : f8f9c2d7)
2021-05-04 08:58:34 +02:00
odain
993dbed7e7 document IsDevelopmentEnvironment defensive behaviour 2021-05-04 08:55:46 +02:00
odain
390dc1c945 document IsDevelopmentEnvironment defensive behaviour 2021-05-04 08:55:20 +02:00
Pierre Goiffon
09b12bd06e 🎨 Add check to prevent setup crash when creating config
In a4782942 a !empty() test was added but this was useless
The problem that was causing the issue was an undefined index when doing $aAvailableModules[$sModuleId]
2021-05-03 16:56:33 +02:00
acognet
3a06f2eaa9 N°3988 - Investigate small list taking a very long time to load 2021-05-03 12:54:50 +02:00
acognet
a8e1db8b3c Fix render 2021-04-30 22:45:30 +02:00
acognet
2cc4448a15 extract methods for apply context on oql 2021-04-30 22:44:03 +02:00
Molkobain
d0d254ad59 Update test-red theme 2021-04-29 18:35:38 +02:00
Molkobain
8f62b63309 N°2788 - Improve HTML fields/caselogs content overlapping for corner cases 2021-04-29 18:17:58 +02:00
acognet
227c90b47f N°3988 - Investigate small list taking a very long time to load 2021-04-29 15:00:05 +02:00
acognet
6fc3033100 Migrate attribute RedundancySetting in new look 2021-04-29 12:15:24 +02:00
Molkobain
cfab20519e N°2922 - Revert 93a1f027 and add support for LabelField in the ConsoleFormRenderer (was already done in PortalFormRenderer) 2021-04-29 12:02:13 +02:00
Molkobain
cbc5bb70d0 Performance: Change theme signature check to be done only when necessary at runtime in a production environment 2021-04-28 19:35:03 +02:00
Molkobain
d5d3a7af47 Performance: Fix NavigationMenu being instantiated several times in the page 2021-04-28 19:35:03 +02:00
Molkobain
03fcc94b1f iTopWebPage: Move TopBar methods near other layouts' methods 2021-04-28 19:35:03 +02:00
Ben
4a28aa316f N°3217 Change module version to 3.0
In dependencies
2021-04-28 16:51:33 +02:00
Eric
88a615528f Add missing reference 2021-04-27 11:58:36 +02:00
acognet
b3e1b7124a N°3980 - Manage dictionary entries for JS script in AjaxPage 2021-04-27 10:45:04 +02:00
acognet
48d0fc6ddb N°3907 - Polishing: Run query 2021-04-27 10:18:32 +02:00
acognet
8bf9987174 N°3592 - Migrate module to new UIBlock system : Customized request forms : allow null for value in function AddMetadata 2021-04-27 10:16:43 +02:00
acognet
0f4c325aab Fix id of datatable 2021-04-26 09:03:11 +02:00
acognet
93a1f027cb N°2922 - Dependent fields in Request template - Error management 2021-04-26 09:03:11 +02:00
Molkobain
3e0971597b Medallion icon: Fix message log "Twig : missing file '' : Unable to find template "base/components/medallion-icon/layout.js.twig"" 2021-04-23 22:41:44 +02:00
Molkobain
fce3934977 Improve PHPDoc 2021-04-23 22:34:33 +02:00
Molkobain
d8feda89a5 N°2875 - Add return example in the PHPDoc 2021-04-23 17:03:29 +02:00
Molkobain
7aecdd0dc7 N°2875 - Extract method to find mentioned objects into utils so it can used by extensions, not only the trigger 2021-04-23 17:01:17 +02:00
odain
a478294211 cannot write itop conf error durring setup wizard: add preventive check when empty dependencies 2021-04-22 14:57:06 +02:00
Stephen Abello
9de1f1800d Add icons on PopoverMenu items and allow to add them through PopupMenu API 2021-04-21 14:45:32 +02:00
Stephen Abello
94c8dbac18 Update precompiled stylesheets 2021-04-21 11:15:46 +02:00
BenGrenoble
efc745f574 N°3217 Added OR dependency to ensure if the portal is loaded it's done before faq (according to Molkobain) 2021-04-21 10:50:36 +02:00
Stephen Abello
3e45dcdbb1 Update jQueryUi style 2021-04-21 10:37:47 +02:00
bruno-ds
07257cc2d2 N°3671 - fix a code comment too evasive
thanks @Hipska
2021-04-21 09:25:10 +02:00
BenGrenoble
ae6e08d430 N°3217 add if_exists on FAQ itop_portal and removed knownerror-mgmt portal dependancies 2021-04-21 09:06:25 +02:00
BenGrenoble
473a49ab6b N°3217 Change itop-knownerror-light by itop-knownerror-mgmt. 2021-04-20 17:27:30 +02:00
BenGrenoble
0c58d67f41 N°3217 Autoindent datamodel and removed dependencies on itop-config-mgmt to fix ci error. 2021-04-20 17:08:46 +02:00
Molkobain
d2c4a6e2e9 UIContentBlock: Add PrependSubBlock() to add a block in first position 2021-04-20 16:32:57 +02:00
Molkobain
d1ccd5c8eb MenuBlock: Put ID prefix in a class constant to be able to reuse it 2021-04-20 16:32:56 +02:00
Molkobain
370a07f596 Use real indexes instead of numerics for the object header blocks (easier to manipulate them) 2021-04-20 16:32:56 +02:00
BenGrenoble
9ae056e663 N°3217 Renamed KnownErrorMgmtInstaller in FAQLightInstaller
Add itop-config-mgmt dependancies for Support.combodo.com compatibility
2021-04-20 15:46:47 +02:00
odain
ce596877a4 fix ci 2021-04-16 14:28:09 +02:00
odain
3d9540e895 Merge branch 'feature/2982-finalize' into develop 2021-04-16 14:04:17 +02:00
odain
27d8869665 N°3593 - rename xsi-type to utilities 2021-04-16 14:01:06 +02:00
odain
3b3fa7b1f8 N°2982 - rename imports_utility and imports_variable in precompilation signature 2021-04-16 11:56:16 +02:00
odain
135b5e8adb N°2982 - PR reviews 2021-04-16 11:46:14 +02:00
odain
52dbf23245 protect IsDevelopmentEnvironment function from warning 2021-04-16 11:33:14 +02:00
Purple Grape
6b899d3f77 🌐 improved chinese for 3.0 (#207) 2021-04-16 11:00:16 +02:00
Pierre Goiffon
87ba67225a 💡 Add since phpdoc tags for \DeadLockLog::Log 2021-04-16 08:36:21 +02:00
Pierre Goiffon
2ad3b3c27e 🎨 Fix \DeadLockLog::Log parameter name + PHPDoc
Thanks @Hipska !
2021-04-15 15:03:13 +02:00
Molkobain
46dc7709ab Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php
2021-04-15 12:02:23 +02:00
Molkobain
92a640e41a Merge branch 'support/2.7.4' into support/2.7 2021-04-15 10:37:17 +02:00
Molkobain
842df7646b Merge branch 'support/2.7.3' into support/2.7.4 2021-04-15 10:35:56 +02:00
Molkobain
01b38d2ed6 N°3869 - Portal: Fix the Notice "Undefined index: max_display_limit" 2021-04-15 10:34:46 +02:00
Molkobain
ddb5ffc11a N°3959 - Truncate vertical tabs label when too long, label can be read entirely through a tooltip 2021-04-15 09:30:22 +02:00
Molkobain
2a62e28c66 Code format 2021-04-15 09:30:21 +02:00
Molkobain
973133ce0b N°3959 - Fix vertical tabs inner alignment 2021-04-15 09:30:21 +02:00
BenGrenoble
be0a728f42 N°3913 fix additional ITIL tickets icon missing 2021-04-15 09:05:54 +02:00
Pierre Goiffon
1bb7d9947c N°2522 SetupPage log methods : fix phpdoc, remove deprecated methods calls 2021-04-14 12:18:06 +02:00
odain
65d94bd914 revert d951d0def 2021-04-13 23:48:32 +02:00
odain
d951d0def0 N°3593 - correct GetDefaultThemeInformation returned structure 2021-04-13 23:45:31 +02:00
odain
beadd9cd03 N°3593 - GetVariablesFromFile and precompilation signature fixes + tests 2021-04-13 23:42:53 +02:00
Pierre Goiffon
fac97324a3 🔇 N°3731 Remove some more depreciation notice for methods still used in iTop core 2021-04-13 18:28:39 +02:00
Pierre Goiffon
f33919c312 🔇 N°3731 Remove some more depreciation notice for methods still used in iTop core 2021-04-13 18:22:24 +02:00
Pierre Goiffon
74d8eda713 🔇 N°3731 Remove some more depreciation notice (...) for methods still used in iTop core 2021-04-13 18:13:30 +02:00
Pierre Goiffon
6790fdb9e8 🔇 N°3731 Remove some more depreciation notice for methods still used in iTop core 2021-04-13 18:07:43 +02:00
Pierre Goiffon
d545123ca7 🔇 N°3731 Remove some depreciation notice for methods still used in iTop core 2021-04-13 17:56:21 +02:00
Pierre Goiffon
59678ef8c6 🔊 N°3731 Log calls to deprecated files / PHP methods
POC for the log API was added in #193
2021-04-13 17:56:21 +02:00
Pierre Goiffon
a6d20ab648 N°3731 \DeprecatedCallsLog : always catch errors so that we won't crash the caller 2021-04-13 17:56:20 +02:00
Pierre Goiffon
e5559a1899 N°3731 Add DeprecatedCallsLog to autoloader 2021-04-13 17:42:04 +02:00
Pierre Goiffon
f8757c6d5d 🔇 Remove depreciation log in \WebPage::outputCollapsibleSectionInit as this call must be kept for compatibility
The log will be added but elsewhere, in methods only called by consumers and not by the API itself (like \WebPage::StartCollapsibleSection ?)
2021-04-13 15:45:55 +02:00
Pierre Goiffon
7f4ef12c04 🐛 Fix \DeprecatedCallsLog::NotifyDeprecatedPhpMethod log message
This was bringed by #193
The stack trace wasn't used correctly :/ This is now fixed !

Sample message for deprecated PHP method call :
`2021-04-13 15:31:47 | Warning | Call to WebPage:outputCollapsibleSectionInit in  C:\...\itop-dev\sources\application\WebPage\AjaxPage.php#L170 (AjaxPage::output) | deprecated-php-method`

Log message for deprecated PHP file remains the same :
`2021-04-13 10:31:12 | Warning | C:\...\itop-dev\sources\application\WebPage\WebPage.php L32 including/requiring C:\...\itop-dev\core\coreexception.class.inc.php : Classes were moved to /application/exceptions | deprecated-file`
2021-04-13 15:38:38 +02:00
Pierre Goiffon
2a90557782 💚 Move DeprecatedCallsLog activation from bootstrap to \MetaModel::LoadConfig, same as existing LogAPI impl
As this is called from \MetaModel::Startup, our log will be available everywhere !
\DeprecatedCallsLog::Enable call in bootstrap was causing some tests to fail
Modification from what was done in #193
2021-04-13 14:58:48 +02:00
Pierre Goiffon
7b3595357a 💚 Removing invalid provider for \Combodo\iTop\Test\UnitTest\Core\LogAPITest::LogApiProvider
Config can never be an array
Was working since now, but LogAPI was modified in f6d9d0f0 and it now correctly pick the config, so this provider was failing
2021-04-13 14:37:54 +02:00
Pierre Goiffon
f6d9d0f08b N°3731 Log deprecated calls (#193)
* New DeprecatedCallsLog logger enabled directly in bootstrap so that we can use it in the most situations
* Default Log level is now DEBUG for dev env, ERROR for others
* Logs the caller and the deprecated method called, like :
`2021-04-06 10:52:25 | Warning | AjaxPage::output L2857 calling WebPage:outputCollapsibleSectionInit | deprecated-method`
* Sample file consumer
* Sample php consumer
2021-04-13 13:55:25 +02:00
Molkobain
f3cf154969 N°3899 - Navigation menu: Filter hot key text now corresponds to the one defined in the user preferences 2021-04-13 11:46:35 +02:00
Molkobain
923a4048d3 Keyboard shortcuts: Add method to retrieve info about a particular shortcut 2021-04-13 11:46:34 +02:00
Molkobain
0816d27456 N°3899 - Navigation menu: Fix hotkey position across browsers 2021-04-13 11:46:34 +02:00
odain
d07199db7c N°2982 - add theme_precompilation_enabled to be able to deactivate precompilation from conf + update provided precompiled files when IsDevelopmentEnvironment 2021-04-13 00:49:08 +02:00
odain
903afff687 N°2982 - fix delta xml variables not used in themes 2021-04-12 22:14:00 +02:00
Molkobain
c0f5906dce Fix crash when accessing a backoffice page in maintenance mode (regression from e2f30182) 2021-04-12 12:08:33 +02:00
Molkobain
fa3140cc13 N°3916 - Attribute date: Fix picker's icon position 2021-04-12 12:08:33 +02:00
Molkobain
22aaba3c65 Update precompiled themes 2021-04-12 10:25:38 +02:00
Molkobain
5878b18b02 N°3921 - Attribute file: Simplify size format in the backoffice (similar to the portal) 2021-04-12 10:25:38 +02:00
Molkobain
530ec111ef N°3921 - Attribute file: Simplify open and download links text in the backoffice (similar to the portal) 2021-04-12 10:25:37 +02:00
Molkobain
430049d7c4 N°3921 - Attribute file: Fix "delete" button not displaying 2021-04-12 10:25:37 +02:00
Molkobain
e45fd92022 SCSS: Move depression/elevation variables to proper files 2021-04-12 10:25:37 +02:00
Molkobain
605165fc5a SCSS: Add font sizes CSS variables 2021-04-12 10:25:36 +02:00
Molkobain
644944c6fd SCSS: Add border radius placeholders 2021-04-12 10:25:36 +02:00
Molkobain
8313d61521 SCSS documentation 2021-04-12 10:25:36 +02:00
Molkobain
81d30ca9f4 N°3916 - Date(time) picker: Fix selects and buttons display. 2021-04-12 10:25:36 +02:00
Molkobain
6078ccc144 N°3916 - Attribute date(time): Remove browser autocompletion on focus in the input 2021-04-12 10:24:35 +02:00
Molkobain
7b9d89e485 Activity entry: Remove old markup from AttributeHTML change 2021-04-12 10:24:35 +02:00
Molkobain
48bc8b2341 Activity entry: Fix change description being displayed twice when only 1 attribute changed 2021-04-12 10:24:35 +02:00
Molkobain
8f03ac4aa3 Activity entry: Fix french dict. entry when more than 4 attributes changed 2021-04-12 10:24:34 +02:00
Molkobain
97f5f0b50d Activity entry: Fix "more" toggler being at the bottom of the entry with text attributes 2021-04-12 10:24:34 +02:00
Molkobain
05594ccdd6 N°3915 - Fix very long strings (typically URLs) overflowing from their containers in text attributes and activity panel entries. 2021-04-12 10:24:34 +02:00
Molkobain
e2f301827a N°3936 - Add protection to avoid crashes in certain conditions since d6695d3a 2021-04-12 09:06:56 +02:00
odain
067cbe2afa fix ci: DataSynchroTest adapted for Admin profile renaming 2021-04-09 12:03:20 +02:00
Eric
a99f4c0666 💚 Fix precompiled themes 2021-04-09 10:42:51 +02:00
Eric
d594f28ed9 N°3573 - Migrate backoffice pages to new UIBlock system : System Information 2021-04-09 09:55:58 +02:00
Molkobain
deed948f54 N°3936 - Remove 🌕 emoji from the theme label, it's was a bit too much 😁 2021-04-09 09:05:52 +02:00
Molkobain
25e88b889d N°3936 - Fix designation of the default theme 2021-04-09 09:05:52 +02:00
Molkobain
d6695d3ad8 N°3936 - Add config parameter to disable theme selection in the user preferences ("user_preferences.allow_backoffice_theme_override") 2021-04-09 09:05:52 +02:00
acognet
0bc9aed3fe Remove development logs 2021-04-08 22:23:01 +02:00
acognet
98ec4bba53 N°2738 - Remove unused dict keys - fix Lost translations author 2021-04-08 22:23:00 +02:00
Molkobain
e527324468 N°3936 - Update dictionaries 2021-04-08 18:26:18 +02:00
Molkobain
8ccada40d1 N°3936 - Add user preference to choose backoffice theme 2021-04-08 18:26:18 +02:00
BenGrenoble
80d974f2b4 N°3217 rollback itop-knownerror-light to itop-knownerror-mgmt 2021-04-08 16:27:49 +02:00
acognet
521c493fd1 N°3868 - "Error: Invalid filter parameter" on mass update - fix datatable after configure this list 2021-04-08 10:06:55 +02:00
Pierre Goiffon
b68ee1136e 📦 💚 Update compiled CSS for test-red
Modification was done in 3262ad70
Didn't add this one in previous commit 0f43b0a6 but was necessary too :/
2021-04-07 18:39:41 +02:00
Pierre Goiffon
0f43b0a6de 📦 💚 Update compiled CSS
Modification was done in 3262ad70
2021-04-07 18:16:27 +02:00
Pierre Goiffon
58d1a1d311 🚚 collapsibleSection JQuery widget renamed to collapsible_section
to match other widget naming convention
2021-04-07 17:14:44 +02:00
Molkobain
5b3ab2965f Activity panel: Mark polish translation as potentially dirty 2021-04-07 16:57:35 +02:00
Stephen Abello
f97f55bcca N°3896 - CKeditor icon for enhance WikiText URLs syntax 2021-04-07 16:20:01 +02:00
acognet
3262ad7029 N°3868 - "Error: Invalid filter parameter" on mass update 2021-04-07 12:22:02 +02:00
acognet
a5bb6a0c55 N°3886 - Mass delete : toggle all checkbox not working anymore 2021-04-07 12:01:20 +02:00
acognet
f0d6b41cee N°2738 - Remove unused dict keys - undo for some entries 2021-04-07 11:55:54 +02:00
Pierre Goiffon
5c01d222c9 DictionariesConsistencyTest : remove debug var_dump
Many thanks @Hipska !
2021-04-07 11:27:33 +02:00
Pierre Goiffon
7e65541d3c DictionariesConsistencyTest : simplify & comment sample dict files 2021-04-07 11:09:51 +02:00
Molkobain
83b8fbb6b5 Remove unused DisplayDetails() function 2021-04-07 10:47:37 +02:00
Molkobain
5b9e5f8de9 Activity panel: Reword english translation for better clarity 2021-04-07 10:02:39 +02:00
Stephen Abello
ddceeafc52 Display ajax tab placeholder when loading regular displayed ajax tab 2021-04-07 09:56:35 +02:00
Stephen Abello
56087d9686 Fix tab container when there is only ajax tabs 2021-04-07 09:46:13 +02:00
Stephen Abello
5aef6f209b Remove debug line 2021-04-07 09:46:13 +02:00
Pierre Goiffon
1b6d69037e DictionariesConsistencyTest : fix inspections warnings 2021-04-07 09:26:34 +02:00
Pierre Goiffon
3941f323c0 Dict syntax samples : make them smaller to ease comparisons 2021-04-07 09:12:51 +02:00
Molkobain
b19f9d4875 N°2875 - Mentions: Continue work on implementation
- Add context attribute to details zlist
- Update french dictionary
2021-04-06 22:28:19 +02:00
Molkobain
057bb1a296 Remove some of the unrelevant tooltips from DM dictionaries 2021-04-06 22:28:19 +02:00
Molkobain
192cb2df73 N°3894 - Activity panel: Add conf. param. to prefilter only on current log or all 2021-04-06 19:45:12 +02:00
Pierre Goiffon
47c797daba 🔨 Fix extensions doc generation script
There were some path problems, this wasn't consistent with the procedure (run from the .doc dir) and with the other script
2021-04-06 18:25:26 +02:00
Pierre Goiffon
33dcb35344 📝 .doc/README : fix generation procedure 2021-04-06 18:25:26 +02:00
Molkobain
68ab84716b N°2224 - Update standard portal compiled stylesheet 2021-04-06 18:14:53 +02:00
2212 changed files with 66550 additions and 88704 deletions

View File

@@ -77,24 +77,20 @@ Then, **for a method** of an eligible class:
:notebook: as spaces are used to mark code, the templates (`.doc/phpdoc-templates/combodo-wiki/*`) have very few indentation, thus they are awful to read (sorry).
## Installation
```
cd .doc
composer require phpdocumentor/phpdocumentor:~2 --dev
```
## Generation
`./bin/build-doc-object-manipulation` and `./bin/build-doc-extensions` contains examples of doc. generation, beware: they have to be called from the .doc directory:
```shell
cd /path/to/itop/.doc
./bin/build-doc-object-manipulation
```
the resulting documentation is written into `data/phpdocumentor/output`
1. Switch to this directory : `cd /path/to/itop/.doc`
2. `composer install`
3. `./bin/build-doc-object-manipulation`
3. `./bin/build-doc-extensions`
4. Get the generated files from `/path/to/itop/data/phpdocumentor/output`
## Dokuwiki requirements
* the template uses the [wrap plugin](https://www.dokuwiki.org/plugin:wrap).

View File

@@ -1,6 +1,6 @@
#!/bin/sh -x
rm -rf /tmp/phpdoc-twig-cache/ && rm -rf data/phpdocumentor/output/extensions/ && rm -rf data/phpdocumentor/temp/extensions/ && .doc/vendor/bin/phpdoc -c .doc/phpdoc-extensions.dist.xml -vvv
rm -rf /tmp/phpdoc-twig-cache/ && rm -rf data/phpdocumentor/output/extensions/ && rm -rf data/phpdocumentor/temp/extensions/ && ./vendor/bin/phpdoc -c ./phpdoc-extensions.dist.xml -vvv
# now wee need to lowercase every generated file because dokuwiki can't handle uppercase
cd data/phpdocumentor/output/extensions/ && for i in $( ls | grep [A-Z] ); do mv -i $i `echo $i | tr 'A-Z' 'a-z'`; done
cd ../data/phpdocumentor/output/extensions/ && for i in $(ls | grep [A-Z]); do mv -i $i $(echo $i | tr 'A-Z' 'a-z'); done

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@@ -11,7 +11,7 @@ tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_visual_guides = 300
ij_wrap_on_typing = true
@@ -78,7 +78,7 @@ ij_editorconfig_space_before_colon = false
ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true
[{*.ant, *.fxml, *.jhm, *.jnlp, *.jrxml, *.rng, *.tld, *.wsdl, *.xml, *.xsd, *.xsl, *.xslt, *.xul, phpunit.xml.dist}]
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,phpunit.xml.dist}]
indent_size = 2
tab_width = 2
ij_smart_tabs = true
@@ -90,7 +90,7 @@ ij_xml_attribute_wrap = normal
ij_xml_block_comment_at_first_column = true
ij_xml_keep_blank_lines = 2
ij_xml_keep_indents_on_empty_lines = false
ij_xml_keep_line_breaks = false
ij_xml_keep_line_breaks = true
ij_xml_keep_line_breaks_in_text = true
ij_xml_keep_whitespaces = false
ij_xml_keep_whitespaces_around_cdata = preserve
@@ -110,6 +110,7 @@ ij_shell_keep_column_alignment_padding = false
ij_shell_minify_program = false
ij_shell_redirect_followed_by_space = false
ij_shell_switch_cases_indented = false
ij_shell_use_unix_line_separator = true
[{*.cjs,*.js}]
indent_style = tab
@@ -285,11 +286,12 @@ ij_continuation_indent_size = 4
ij_smart_tabs = true
ij_wrap_on_typing = false
ij_php_align_assignments = false
ij_php_align_class_constants = false
ij_php_align_class_constants = true
ij_php_align_group_field_declarations = false
ij_php_align_inline_comments = false
ij_php_align_key_value_pairs = false
ij_php_align_multiline_array_initializer_expression = false
ij_php_align_key_value_pairs = true
ij_php_align_match_arm_bodies = false
ij_php_align_multiline_array_initializer_expression = true
ij_php_align_multiline_binary_operation = false
ij_php_align_multiline_chained_methods = false
ij_php_align_multiline_extends_list = false
@@ -297,6 +299,7 @@ ij_php_align_multiline_for = true
ij_php_align_multiline_parameters = false
ij_php_align_multiline_parameters_in_calls = false
ij_php_align_multiline_ternary_operation = false
ij_php_align_named_arguments = false
ij_php_align_phpdoc_comments = false
ij_php_align_phpdoc_param_names = false
ij_php_anonymous_brace_style = end_of_line
@@ -416,6 +419,7 @@ ij_php_see_weight = 3
ij_php_since_weight = 28
ij_php_sort_phpdoc_elements = true
ij_php_space_after_colon = true
ij_php_space_after_colon_in_enum_backed_type = true
ij_php_space_after_colon_in_named_argument = true
ij_php_space_after_colon_in_return_type = true
ij_php_space_after_comma = true
@@ -430,6 +434,7 @@ ij_php_space_before_catch_parentheses = true
ij_php_space_before_class_left_brace = true
ij_php_space_before_closure_left_parenthesis = true
ij_php_space_before_colon = true
ij_php_space_before_colon_in_enum_backed_type = false
ij_php_space_before_colon_in_named_argument = false
ij_php_space_before_colon_in_return_type = false
ij_php_space_before_comma = false
@@ -465,6 +470,7 @@ ij_php_spaces_around_equality_operators = true
ij_php_spaces_around_logical_operators = true
ij_php_spaces_around_multiplicative_operators = true
ij_php_spaces_around_null_coalesce_operator = true
ij_php_spaces_around_pipe_in_union_type = false
ij_php_spaces_around_relational_operators = true
ij_php_spaces_around_shift_operators = true
ij_php_spaces_around_unary_operator = false
@@ -514,7 +520,7 @@ ij_json_wrap_long_lines = false
indent_style = tab
ij_smart_tabs = true
ij_visual_guides = none
ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3
ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
ij_html_align_attributes = true
ij_html_align_text = false
ij_html_attribute_wrap = normal
@@ -539,9 +545,22 @@ ij_html_space_after_tag_name = false
ij_html_space_around_equality_in_attribute = false
ij_html_space_inside_empty_tag = false
ij_html_text_wrap = normal
ij_html_uniform_ident = false
[{*.yaml, *.yml}]
[{*.markdown,*.md}]
ij_visual_guides = none
ij_markdown_force_one_space_after_blockquote_symbol = true
ij_markdown_force_one_space_after_header_symbol = true
ij_markdown_force_one_space_after_list_bullet = true
ij_markdown_force_one_space_between_words = true
ij_markdown_keep_indents_on_empty_lines = false
ij_markdown_max_lines_around_block_elements = 1
ij_markdown_max_lines_around_header = 1
ij_markdown_max_lines_between_paragraphs = 1
ij_markdown_min_lines_around_block_elements = 1
ij_markdown_min_lines_around_header = 1
ij_markdown_min_lines_between_paragraphs = 1
[{*.yaml,*.yml}]
indent_size = 2
ij_visual_guides = none
ij_yaml_align_values_properties = do_not_align

2
.gitignore vendored
View File

@@ -32,6 +32,8 @@ test/vendor/*
!/data/.htaccess
!/data/index.php
!/data/web.config
!/data/exclude.txt
!/data/.compilation-symlinks
# iTop extensions
/extensions/**

13
.make/git-hooks/README.md Normal file
View File

@@ -0,0 +1,13 @@
# Git hooks for iTop
## ❓ Goal
Those [git hooks](https://git-scm.com/docs/githooks) aims to ease developing on [iTop](https://github.com/Combodo/iTop).
## ☑ Available hooks
* pre-commit : rejects commit if you have at least one SCSS file staged, and no CSS file
## ⚙ Install
Just run install.php !

View File

@@ -0,0 +1,26 @@
<?php
$aHooks = [
'pre-commit.php',
];
$sAppRoot = dirname(__DIR__, 2);
foreach ($aHooks as $sSourceHookFileName) {
echo "Processing for `{$sSourceHookFileName}`...\n";
$sSourceHookPath = __DIR__.DIRECTORY_SEPARATOR.$sSourceHookFileName;
$aPathParts = pathinfo($sSourceHookFileName);
$sTargetHookPath = $sAppRoot.DIRECTORY_SEPARATOR.'.git'.DIRECTORY_SEPARATOR.'hooks'.DIRECTORY_SEPARATOR.$aPathParts['filename'];
if (file_exists($sTargetHookPath) || is_link($sTargetHookPath)) {
echo "Existing $sTargetHookPath ! Removing...";
unlink($sTargetHookPath);
echo "OK !\n";
}
echo "Creating symlink for hook in $sTargetHookPath...";
symlink($sSourceHookPath, $sTargetHookPath);
echo "OK !\n";
}

View File

@@ -0,0 +1,49 @@
#!/usr/bin/php
<?php
/**
* Reject any commit containing .scss files, but no .css file !
*/
echo "Checking files staged...\n";
$sFilesToCommit = shell_exec('git diff --cached --name-only --diff-filter=ACMRT');
$aFilesToCommit = explode("\n", $sFilesToCommit);
$aScssFiles = GetFilesWithExtension('scss', $aFilesToCommit);
if (count($aScssFiles) === 0) {
echo "No scss file : OK to go !\n";
exit(0);
}
$aCssFiles = GetFilesWithExtension('css', $aFilesToCommit);
if (count($aCssFiles) === 0) {
echo "There are SCSS files staged but no CSS file : REJECTING commit.\n";
echo "You must add the compiled SCSS files by running the setup !\n";
exit(1);
}
echo "We have SCSS but also CSS => OK to commit !\n";
exit(0);
function GetFilesWithExtension($sExtension, $aFiles) {
return array_filter(
$aFiles,
function($item) use ($sExtension) {
return (endsWith($item, '.'.$sExtension));
}
);
}
function endsWith( $haystack, $needle ) {
$length = strlen( $needle );
if( !$length ) {
return true;
}
return substr( $haystack, -$length ) === $needle;
}
function exitWithMessage($sMessage, $iCode) {
echo $sMessage;
exit($iCode);
}

View File

@@ -10,10 +10,6 @@
* `curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe`
* this is a Windows port : https://stedolan.github.io/jq/
*
* Known bug on Windows :
* Licenses added from Composer contains a path in the product node (N°3870)
* `<product scope="lib">C:\Dev\wamp64\www\itop-dev\.make\license/../..//lib/symfony/console</product>`
*
* Licenses sources :
* * `composer licenses --format json` (see https://getcomposer.org/doc/03-cli.md#licenses)
* * keep every existing nodes with `/licenses/license[11]/product/@scope` not in ['lib', 'datamodels']
@@ -70,39 +66,83 @@ function get_license_nodes($file_path)
$xp = new DOMXPath($dom);
$licenseList = $xp->query('/licenses/license');
$licenses = iterator_to_array($licenseList);
$licenses = iterator_to_array($licenseList);
usort($licenses, 'sort_by_product');
return $licenses;
}
/** @noinspection SuspiciousAssignmentsInspection */
function fix_product_name(DOMNode &$oProductNode)
{
$sProductNameOrig = $oProductNode->nodeValue;
// sample : `C:\Dev\wamp64\www\itop-27\.make\license/../..//lib/symfony/polyfill-ctype`
$sProductNameFixed = remove_dir_from_string($sProductNameOrig, 'lib/');
// sample : `C:\Dev\wamp64\www\itop-27\.make\license/../..//datamodels/2.x/authent-cas/vendor/apereo/phpcas`
$sProductNameFixed = remove_dir_from_string($sProductNameFixed, 'vendor/');
$oProductNode->nodeValue = $sProductNameFixed;
}
function remove_dir_from_string($sString, $sNeedle)
{
if (strpos($sString, $sNeedle) === false) {
return $sString;
}
$sStringTmp = strstr($sString, $sNeedle);
$sStringFixed = str_replace($sNeedle, '', $sStringTmp);
// DEBUG trace O:)
// echo "$sNeedle = $sString => $sStringFixed\n";
return $sStringFixed;
}
$old_licenses = get_license_nodes($xmlFilePath);
//generate file with updated licenses
$generated_license_file_path = __DIR__."/provfile.xml";
exec("bash " . __DIR__ . "/gen-community-license.sh $iTopFolder > ". $generated_license_file_path);
echo "- Generating licences...";
exec("bash ".__DIR__."/gen-community-license.sh $iTopFolder > ".$generated_license_file_path);
echo "OK!\n";
echo "- Get licenses nodes...";
$new_licenses = get_license_nodes($generated_license_file_path);
exec("rm -f ". $generated_license_file_path);
unlink($generated_license_file_path);
foreach ($old_licenses as $b) {
$aProductNode = get_product_node($b);
if (get_scope($aProductNode) !== "lib" && get_scope($aProductNode) !== "datamodels" )
{
if (get_scope($aProductNode) !== "lib" && get_scope($aProductNode) !== "datamodels") {
$new_licenses[] = $b;
}
}
usort($new_licenses, 'sort_by_product');
echo "OK!\n";
echo "- Overwritting Combodo license file...";
$new_dom = new DOMDocument("1.0");
$new_dom->formatOutput = true;
$root = $new_dom->createElement("licenses");
$new_dom->appendChild($root);
foreach ($new_licenses as $b) {
$node = $new_dom->importNode($b,true);
$root->appendChild($new_dom->importNode($b,true));
$node = $new_dom->importNode($b, true);
// N°3870 fix when running script in Windows
// fix should be in gen-community-license.sh but it is easier to do it here !
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
$oProductNodeOrig = get_product_node($node);
fix_product_name($oProductNodeOrig);
}
$root->appendChild($node);
}
$new_dom->save($xmlFilePath);
$new_dom->save($xmlFilePath);
echo "OK!\n";

View File

@@ -0,0 +1,77 @@
<?php
/**
* Usage :
* `php changelog.php 2.7.4`
*
* As argument is passed the git ref (tag name or sha1) we want to use as reference
*
* Outputs :
*
* 1. List of bugs as CSV :
* bug ref;link
* Example :
* <code>
* Bug_ref;Bug_URL;sha1
* 1234;https://support.combodo.com/pages/UI.php?operation=details&class=Bug&id=1234;949b213f9|b1ca1f263|a1271da74
* </code>
*
* 2. List of commits sha1/message without bug ref
* Example :
* <code>
* sha1;subject
* a6aa183e2;:bookmark: Prepare 2.7.5
* </code>
*/
if (count($argv) === 1) {
echo '⚠ You must pass the base tag/sha1 as parameter';
exit(1);
}
$sBaseReference = $argv[1];
//--- Get log
$sGitLogCommand = 'git log --decorate --pretty="%h;%s" --date-order --no-merges '.$sBaseReference.'..HEAD';
$sGitLogRaw = shell_exec($sGitLogCommand);
//--- Analyze log
$aGitLogLines = preg_split('/\n/', trim($sGitLogRaw));;
$aLogLinesWithBugRef = [];
$aLogLineNoBug = [];
foreach ($aGitLogLines as $sLogLine) {
$sBugRef = preg_match('/[nN]°(\d{3,4})/', $sLogLine, $aLineBugRef);
if (($sBugRef === false) || empty($aLineBugRef)) {
$aLogLineNoBug[] = $sLogLine;
continue;
}
$iBugId = $aLineBugRef[1];
$sSha = substr($sLogLine, 0, 9);
if (array_key_exists($iBugId, $aLogLinesWithBugRef)) {
$aBugShaRefs = $aLogLinesWithBugRef[$iBugId];
$aBugShaRefs[] = $sSha;
$aLogLinesWithBugRef[$iBugId] = $aBugShaRefs;
} else {
$aLogLinesWithBugRef[$iBugId] = [$sSha];
}
}
$aBugsList = array_keys($aLogLinesWithBugRef);
sort($aBugsList, SORT_NUMERIC);
//-- Output results
echo "# Bugs included\n";
echo "Bug_ref;Bug_URL;sha1\n";
foreach ($aBugsList as $sBugRef) {
$sShaRefs = implode('|', $aLogLinesWithBugRef[$sBugRef]);
echo "{$sBugRef};https://support.combodo.com/pages/UI.php?operation=details&class=Bug&id={$sBugRef};$sShaRefs\n";
}
echo "\n";
echo "# Logs line without bug referenced\n";
echo "sha1;subject\n";
foreach ($aLogLineNoBug as $sLogLine) {
echo "$sLogLine\n";
}

View File

@@ -125,8 +125,7 @@ Our tests are located in the `test/` directory, containing a PHPUnit config file
* ⬆️ `:arrow_up:` when upgrading dependencies
* ⬇️ `:arrow_down:` when downgrading dependencies
* ♻️ `:recycle:` code refactoring
* 💄 `:lipstick:` Updating the UI and style files.
* 💄 `:lipstick:` Updating the UI and style files.
## 👥 Pull request
@@ -137,3 +136,25 @@ When your code is working, please:
* create a pull request.
Detailed procedure to work on fork and create PR is available [in GitHub help pages](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
You might check the ["Allow edits from maintainers" PR checkbox][allow_edits_checkbox] to ease review.
[allow_edits_checkbox]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork#enabling-repository-maintainer-permissions-on-existing-pull-requests
### 🙏 We are thankful
We are thankful for all your contributions to the iTop universe! As a thank you gift, we will send stickers to every iTop (& extensions) contributors!
Stickers' design might change from one year to another. For the first year we wanted to try a "craft beer label" look, see examples below:
* Bug hunter: Fix a bug
* Translator: Add/update translations
* White hat: Find and/or fix a vulnerability
* Contributor: Contribute by finding a bug, making an extension or any other way
* Partner: For Combodo's official partners
* Graduated: Follow a Combodo's iTop training
* Ambassador: Outstanding community contributors
* Beta tester: Test and give feedback on beta releases
* Extension developer: Develop and publish an extension
![](.doc/contributing-guide/contributing-stickers-side-by-side.png)

View File

@@ -99,9 +99,11 @@ We would like to give a special thank you 🤗 to the people from the community
- Lucas, Jonathan
- Malik, Remie
- Mindêllo de Andrade, Lucas (a.k.a @rokam)
- Raenker, Martin
- Rosenke, Stephan
- Seki, Shoji
- Shilov, Vladimir
- Stukalov, Ilya (a.k.a @ilya-stukalov)
- Tulio, Marco
- Turrubiates, Miguel

View File

@@ -34,7 +34,7 @@ class URP_Profiles extends UserRightsBaseClassGUI
{
$aParams = array
(
"category" => "addon/userrights,grant_by_profile",
"category" => "addon/userrights,grant_by_profile,filter",
"key_type" => "autoincrement",
"name_attcode" => "name",
"state_attcode" => "",
@@ -219,9 +219,9 @@ class URP_UserProfile extends UserRightsBaseClassGUI
{
$aParams = array
(
"category" => "addon/userrights,grant_by_profile",
"category" => "addon/userrights,grant_by_profile,filter",
"key_type" => "autoincrement",
"name_attcode" => "userid",
"name_attcode" => array("userlogin", "profile"),
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_urp_userprofile",
@@ -246,11 +246,6 @@ class URP_UserProfile extends UserRightsBaseClassGUI
MetaModel::Init_SetZListItems('advanced_search', array('userid', 'profileid')); // Criteria of the advanced search form
}
public function GetName()
{
return Dict::Format('UI:UserManagement:LinkBetween_User_And_Profile', $this->Get('userlogin'), $this->Get('profile'));
}
public function CheckToDelete(&$oDeletionPlan)
{
if (MetaModel::GetConfig()->Get('demo_mode')) {
@@ -362,7 +357,7 @@ class URP_UserOrg extends UserRightsBaseClassGUI
(
"category" => "addon/userrights,grant_by_profile",
"key_type" => "autoincrement",
"name_attcode" => "userid",
"name_attcode" => array("userlogin", "allowed_org_name"),
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_urp_userorg",
@@ -387,12 +382,6 @@ class URP_UserOrg extends UserRightsBaseClassGUI
MetaModel::Init_SetZListItems('advanced_search', array('userid', 'allowed_org_id')); // Criteria of the advanced search form
}
public function GetName()
{
return Dict::Format('UI:UserManagement:LinkBetween_User_And_Org', $this->Get('userlogin'), $this->Get('allowed_org_name'));
}
protected function OnInsert()
{
$this->CheckIfOrgIsAllowed();
@@ -621,30 +610,115 @@ class UserRightsProfile extends UserRightsAddOnAPI
{
$this->LoadCache();
$aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, UR_ACTION_READ);
if ($aObjectPermissions['permission'] == UR_ALLOWED_NO)
// Let us pass an administrator for bypassing the grant matrix check in order to test this method without the need to set up a complex profile
// In the nominal case Administrators never end up here (since they completely bypass GetSelectFilter)
if (!static::IsAdministrator($oUser) && (MetaModel::HasCategory($sClass, 'silo') || MetaModel::HasCategory($sClass, 'bizmodel')))
{
return false;
// N°4354 - Categories 'silo' and 'bizmodel' do check the grant matrix. Whereas 'filter' always allows to read (but the result can be filtered)
$aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, UR_ACTION_READ);
if ($aObjectPermissions['permission'] == UR_ALLOWED_NO)
{
return false;
}
}
// Determine how to position the objects of this class
//
$oFilter = true;
$aConditions = array();
// Determine if this class is part of a silo and build the filter for it
$sAttCode = self::GetOwnerOrganizationAttCode($sClass);
if (is_null($sAttCode))
if (!is_null($sAttCode))
{
// No filtering for this object
return true;
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
if (count($aUserOrgs) > 0)
{
$oFilter = $this->MakeSelectFilter($sClass, $aUserOrgs, $aSettings, $sAttCode);
}
// else: No org means 'any org'
}
// Position the user
//
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
if (count($aUserOrgs) == 0)
// else: No silo for this class
// Specific conditions to hide, for non-administrators, the Administrator Users, the Administrator Profile and related links
// Note: when logged as an administrator, GetSelectFilter is completely bypassed.
if ($this->AdministratorsAreHidden())
{
// No org means 'any org'
return true;
if ($sClass == 'URP_Profiles')
{
$oExpression = new FieldExpression('id', $sClass);
$oScalarExpr = new ScalarExpression(1);
$aConditions[] = new BinaryExpression($oExpression, '!=', $oScalarExpr);
}
else if (($sClass == 'URP_UserProfile') || ($sClass == 'User') || (is_subclass_of($sClass, 'User')))
{
$aAdministrators = $this->GetAdministrators();
if (count($aAdministrators) > 0)
{
$sAttCode = ($sClass == 'URP_UserProfile') ? 'userid' : 'id';
$oExpression = new FieldExpression($sAttCode, $sClass);
$oListExpr = ListExpression::FromScalars($aAdministrators);
$aConditions[] = new BinaryExpression($oExpression, 'NOT IN', $oListExpr);
}
}
}
return $this->MakeSelectFilter($sClass, $aUserOrgs, $aSettings, $sAttCode);
// Handling of the added conditions
if (count($aConditions) > 0)
{
if($oFilter === true)
{
// No 'silo' filter, let's build a clean one
$oFilter = new DBObjectSearch($sClass);
}
// Add the conditions to the filter
foreach($aConditions as $oCondition)
{
$oFilter->AddConditionExpression($oCondition);
}
}
return $oFilter;
}
/**
* Retrieve (and memoize) the list of administrator accounts.
* Note that there should always be at least one administrator account
* @return number[]
*/
private function GetAdministrators()
{
static $aAdministrators = null;
if ($aAdministrators === null)
{
// Find all administrators
$aAdministrators = array();
$oAdministratorsFilter = new DBObjectSearch('User');
$oLnkFilter = new DBObjectSearch('URP_UserProfile');
$oExpression = new FieldExpression('profileid', 'URP_UserProfile');
$oScalarExpr = new ScalarExpression(1);
$oCondition = new BinaryExpression($oExpression, '=', $oScalarExpr);
$oLnkFilter->AddConditionExpression($oCondition);
$oAdministratorsFilter->AddCondition_ReferencedBy($oLnkFilter, 'userid');
$oAdministratorsFilter->AllowAllData(true); // Mandatory to prevent infinite recursion !!
$oSet = new DBObjectSet($oAdministratorsFilter);
$oSet->OptimizeColumnLoad(array('User' => array('login')));
while($oUser = $oSet->Fetch())
{
$aAdministrators[] = $oUser->GetKey();
}
}
return $aAdministrators;
}
/**
* Whether or not to hide the 'Administrator' profile and the administrator accounts
* @return boolean
*/
private function AdministratorsAreHidden()
{
return ((bool)MetaModel::GetConfig()->Get('security.hide_administrators'));
}

View File

@@ -327,7 +327,7 @@ class URP_UserProfile extends UserRightsBaseClassGUI
(
"category" => "addon/userrights",
"key_type" => "autoincrement",
"name_attcode" => "userid",
"name_attcode" => array("userlogin", "profile"),
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_urp_userprofile",
@@ -351,11 +351,6 @@ class URP_UserProfile extends UserRightsBaseClassGUI
MetaModel::Init_SetZListItems('standard_search', array('userid', 'profileid')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('userid', 'profileid')); // Criteria of the advanced search form
}
public function GetName()
{
return Dict::Format('UI:UserManagement:LinkBetween_User_And_Profile', $this->Get('userlogin'), $this->Get('profile'));
}
}
class URP_UserOrg extends UserRightsBaseClassGUI
@@ -366,7 +361,7 @@ class URP_UserOrg extends UserRightsBaseClassGUI
(
"category" => "addon/userrights",
"key_type" => "autoincrement",
"name_attcode" => "userid",
"name_attcode" => array("userlogin", "allowed_org_name"),
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_urp_userorg",
@@ -390,11 +385,6 @@ class URP_UserOrg extends UserRightsBaseClassGUI
MetaModel::Init_SetZListItems('standard_search', array('userid', 'allowed_org_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('userid', 'allowed_org_id')); // Criteria of the advanced search form
}
public function GetName()
{
return Dict::Format('UI:UserManagement:LinkBetween_User_And_Org', $this->Get('userlogin'), $this->Get('allowed_org_name'));
}
}

View File

@@ -270,7 +270,7 @@ class URP_UserProfile extends UserRightsBaseClass
(
"category" => "addon/userrights",
"key_type" => "autoincrement",
"name_attcode" => "userid",
"name_attcode" => array("userlogin", "profile"),
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_urp_userprofile",
@@ -294,11 +294,6 @@ class URP_UserProfile extends UserRightsBaseClass
MetaModel::Init_SetZListItems('standard_search', array('userid', 'profileid')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('userid', 'profileid')); // Criteria of the advanced search form
}
public function GetName()
{
return Dict::Format('UI:UserManagement:LinkBetween_User_And_Profile', $this->Get('userlogin'), $this->Get('profile'));
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
/**
* Class DBSearchHelper
*
* @since 3.0.0
*/
class DBSearchHelper
{
/**
* Add context filter to DBUnionSearch
*
* @param \DBSearch|null $oSearch
*
* @throws \Exception
* @since 3.0.0
*/
public static function AddContextFilter(?DBSearch $oSearch): void
{
$oAppContext = new ApplicationContext();
$sClass = $oSearch->GetClass();
foreach ($oAppContext->GetNames() as $key) {
// Find the value of the object corresponding to each 'context' parameter
$aCallSpec = [$sClass, 'MapContextParam'];
$sAttCode = '';
if (is_callable($aCallSpec)) {
$sAttCode = call_user_func($aCallSpec, $key); // Returns null when there is no mapping for this parameter
}
if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
// Add Hierarchical condition if hierarchical key
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (isset($oAttDef) && ($oAttDef->IsExternalKey())) {
$iDefaultValue = intval($oAppContext->GetCurrentValue($key));
if ($iDefaultValue != 0) {
try {
/** @var AttributeExternalKey $oAttDef */
$sTargetClass = $oAttDef->GetTargetClass();
$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sTargetClass);
if ($sHierarchicalKeyCode !== false) {
$oFilter = new DBObjectSearch($sTargetClass);
$oFilter->AddCondition('id', $iDefaultValue);
$oHKFilter = new DBObjectSearch($sTargetClass);
$oHKFilter->AddCondition_PointingTo($oFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
$oSearch->AddCondition_PointingTo($oHKFilter, $sAttCode);
}
}
catch (Exception $e) {
// If filtering fails just ignore it
}
}
}
}
}
}
}

View File

@@ -1,12 +1,16 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/AjaxPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/AjaxPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/AjaxPage.php, now loadable using autoloader');
/**
* Class ajax_page
*
* @deprecated will be removed in 3.1.0 - moved to AjaxPage
*/
class ajax_page extends AjaxPage

View File

@@ -24,6 +24,7 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\Helper\Session;
use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\UIBlock;
@@ -227,6 +228,20 @@ class ApplicationContext
}
return $sContext;
}
/**
* Returns the context an array of input blocks
*
* @return array The context as a sequence of <input type="hidden" /> tags
* @since 3.0.0
*/
public function GetForUIForm()
{
$aContextInputBlocks = [];
foreach ($this->aValues as $sName => $sValue) {
$aContextInputBlocks[] = InputUIBlockFactory::MakeForHidden("c[$sName]", htmlentities($sValue, ENT_QUOTES, 'UTF-8'));
}
return $aContextInputBlocks;
}
/**
* Returns the context as sequence of input tags to be inserted inside a <form> tag
@@ -321,7 +336,7 @@ class ApplicationContext
$sPrevious = self::GetUrlMakerClass();
self::$m_sUrlMakerClass = $sClass;
$_SESSION['UrlMakerClass'] = $sClass;
Session::Set('UrlMakerClass', $sClass);
return $sPrevious;
}
@@ -334,9 +349,9 @@ class ApplicationContext
{
if (is_null(self::$m_sUrlMakerClass))
{
if (isset($_SESSION['UrlMakerClass']))
if (Session::IsSet('UrlMakerClass'))
{
self::$m_sUrlMakerClass = $_SESSION['UrlMakerClass'];
self::$m_sUrlMakerClass = Session::Get('UrlMakerClass');
}
else
{
@@ -389,9 +404,9 @@ class ApplicationContext
*/
protected static function LoadPluginProperties()
{
if (isset($_SESSION['PluginProperties']))
if (Session::IsSet('PluginProperties'))
{
self::$m_aPluginProperties = $_SESSION['PluginProperties'];
self::$m_aPluginProperties = Session::Get('PluginProperties');
}
else
{
@@ -411,7 +426,7 @@ class ApplicationContext
if (is_null(self::$m_aPluginProperties)) self::LoadPluginProperties();
self::$m_aPluginProperties[$sPluginClass][$sProperty] = $value;
$_SESSION['PluginProperties'][$sPluginClass][$sProperty] = $value;
Session::Set(['PluginProperties', $sPluginClass, $sProperty], $value);
}
/**

View File

@@ -73,15 +73,14 @@ abstract class AbstractLoginFSMExtension implements iLoginFSMExtension
/**
* @inheritDoc
*/
public abstract function ListSupportedLoginModes();
abstract public function ListSupportedLoginModes();
/**
* @inheritDoc
*/
public function LoginAction($sLoginState, &$iErrorCode)
{
switch ($sLoginState)
{
switch ($sLoginState) {
case LoginWebPage::LOGIN_STATE_START:
return $this->OnStart($iErrorCode);
@@ -777,6 +776,10 @@ abstract class ApplicationPopupMenuItem
/** @ignore */
protected $sLabel;
/** @ignore */
protected $sTooltip;
/** @ignore */
protected $sIconClass;
/** @ignore */
protected $aCssClasses;
/**
@@ -791,6 +794,8 @@ abstract class ApplicationPopupMenuItem
{
$this->sUID = $sUID;
$this->sLabel = $sLabel;
$this->sTooltip = '';
$this->sIconClass = '';
$this->aCssClasses = array();
}
@@ -845,6 +850,47 @@ abstract class ApplicationPopupMenuItem
$this->aCssClasses[] = $sCssClass;
}
/**
* @param $sTooltip
*
* @since 3.0.0
*/
public function SetTooltip($sTooltip)
{
$this->sTooltip = $sTooltip;
}
/**
* @return string
*
* @since 3.0.0
*/
public function GetTooltip()
{
return $this->sTooltip;
}
/**
* @param $sIconClass
*
* @since 3.0.0
*/
public function SetIconClass($sIconClass)
{
$this->sIconClass = $sIconClass;
}
/**
* @return string
*
* @since 3.0.0
*/
public function GetIconClass()
{
return $this->sIconClass;
}
/**
* Returns the components to create a popup menu item in HTML
*
@@ -863,6 +909,8 @@ abstract class ApplicationPopupMenuItem
/**
* Class for adding an item into a popup menu that browses to the given URL
*
* Note: This works only in the backoffice, {@see \URLButtonItem} for the end-user portal
*
* @api
* @package Extensibility
* @since 2.0
@@ -892,7 +940,13 @@ class URLPopupMenuItem extends ApplicationPopupMenuItem
/** @ignore */
public function GetMenuItem()
{
return array('label' => $this->GetLabel(), 'url' => $this->GetUrl(), 'target' => $this-> GetTarget(), 'css_classes' => $this->aCssClasses);
return array('label' => $this->GetLabel(),
'url' => $this->GetUrl(),
'target' => $this-> GetTarget(),
'css_classes' => $this->aCssClasses,
'icon_class' => $this->sIconClass,
'tooltip' => $this->sTooltip
);
}
/** @ignore */
@@ -911,6 +965,8 @@ class URLPopupMenuItem extends ApplicationPopupMenuItem
/**
* Class for adding an item into a popup menu that triggers some Javascript code
*
* Note: This works only in the backoffice, {@see \JSButtonItem} for the end-user portal
*
* @api
* @package Extensibility
* @since 2.0
@@ -952,6 +1008,8 @@ class JSPopupMenuItem extends ApplicationPopupMenuItem
'onclick' => $this->GetJsCode().'; return false;',
'url' => $this->GetUrl(),
'css_classes' => $this->GetCssClasses(),
'icon_class' => $this->sIconClass,
'tooltip' => $this->sTooltip
);
}
@@ -1043,7 +1101,9 @@ class JSButtonItem extends JSPopupMenuItem
* @api
* @package Extensibility
* @since 2.0
* @deprecated since 3.0.0 use iPageUIBlockExtension instead
* @deprecated 3.0.0 If you need to include:
* * JS/CSS files/snippets, use {@see \iBackofficeLinkedScriptsExtension}, {@see \iBackofficeLinkedStylesheetsExtension}, etc instead
* * HTML (and optionally JS/CSS), use {@see \iPageUIBlockExtension} to manipulate {@see \Combodo\iTop\Application\UI\Base\UIBlock} instead
*/
interface iPageUIExtension
{
@@ -1133,6 +1193,8 @@ abstract class AbstractPageUIExtension implements iPageUIExtension
*/
public function GetNorthPaneHtml(iTopWebPage $oPage)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use iPageUIBlockExtension instead');
return '';
}
@@ -1141,6 +1203,8 @@ abstract class AbstractPageUIExtension implements iPageUIExtension
*/
public function GetSouthPaneHtml(iTopWebPage $oPage)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use iPageUIBlockExtension instead');
return '';
}
@@ -1149,6 +1213,8 @@ abstract class AbstractPageUIExtension implements iPageUIExtension
*/
public function GetBannerHtml(iTopWebPage $oPage)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use iPageUIBlockExtension instead');
return '';
}
@@ -1188,6 +1254,119 @@ abstract class AbstractPageUIBlockExtension implements iPageUIBlockExtension
}
}
/**
* Implement this interface to add script (JS) files to the backoffice pages
*
* @see \iTopWebPage::$a_linked_scripts
* @api
* @since 3.0.0
*/
interface iBackofficeLinkedScriptsExtension
{
/**
* @see \iTopWebPage::$a_linked_scripts Each script will be included using this property
* @return array An array of absolute URLs to the files to include
*/
public function GetLinkedScriptsAbsUrls(): array;
}
/**
* Implement this interface to add inline script (JS) to the backoffice pages' head.
* Will be executed first, BEFORE the DOM interpretation.
*
* @see \iTopWebPage::$a_early_scripts
* @api
* @since 3.0.0
*/
interface iBackofficeEarlyScriptExtension
{
/**
* @see \iTopWebPage::$a_early_scripts
* @return string
*/
public function GetEarlyScript(): string;
}
/**
* Implement this interface to add inline script (JS) to the backoffice pages that will be executed immediately, without waiting for the DOM to be ready.
*
* @see \iTopWebPage::$a_scripts
* @api
* @since 3.0.0
*/
interface iBackofficeScriptExtension
{
/**
* @see \iTopWebPage::$a_scripts
* @return string
*/
public function GetScript(): string;
}
/**
* Implement this interface to add inline script (JS) to the backoffice pages that will be executed right when the DOM is ready.
*
* @see \iTopWebPage::$a_init_scripts
* @api
* @since 3.0.0
*/
interface iBackofficeInitScriptExtension
{
/**
* @see \iTopWebPage::$a_init_scripts
* @return string
*/
public function GetInitScript(): string;
}
/**
* Implement this interface to add inline script (JS) to the backoffice pages that will be executed slightly AFTER the DOM is ready (just after the init. scripts).
*
* @see \iTopWebPage::$a_ready_scripts
* @api
* @since 3.0.0
*/
interface iBackofficeReadyScriptExtension
{
/**
* @see \iTopWebPage::$a_ready_scripts
* @return string
*/
public function GetReadyScript(): string;
}
/**
* Implement this interface to add stylesheets (CSS) to the backoffice pages
*
* @see \iTopWebPage::$a_linked_stylesheets
* @api
* @since 3.0.0
*/
interface iBackofficeLinkedStylesheetsExtension
{
/**
* @see \iTopWebPage::$a_linked_stylesheets
* @return array An array of absolute URLs to the files to include
*/
public function GetLinkedStylesheetsAbsUrls(): array;
}
/**
* Implement this interface to add inline style (CSS) to the backoffice pages' head.
*
* @see \iTopWebPage::$a_styles
* @api
* @since 3.0.0
*/
interface iBackofficeStyleExtension
{
/**
* @see \iTopWebPage::$a_styles
* @return string
*/
public function GetStyle(): string;
}
/**
* Implement this interface to add content to any enhanced portal page
*

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/CaptureWebPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/CaptureWebPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/CaptureWebPage.php, now loadable using autoloader');

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/CLIPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/CLIPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/CLIPage.php, now loadable using autoloader');

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/CSVPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/CSVPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/CSVPage.php, now loadable using autoloader');

View File

@@ -6,6 +6,7 @@
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableSettings;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\Dashboard\DashboardLayout as DashboardLayoutUIBlock;
@@ -542,7 +543,7 @@ EOF
if ($bFromDasboardPage) {
$sTitleForHTML = utils::HtmlEntities(Dict::S($this->sTitle));
$sHtml = "<div class=\"ibo-top-bar--toolbar-dashboard-title\">{$sTitleForHTML}</div>";
$sHtml = "<div class=\"ibo-top-bar--toolbar-dashboard-title\" title=\"{$sTitleForHTML}\">{$sTitleForHTML}</div>";
if ($oPage instanceof iTopWebPage) {
$oTopBar = $oPage->GetTopBarLayout();
$oToolbar = ToolbarUIBlockFactory::MakeStandard();
@@ -551,7 +552,7 @@ EOF
$oToolbar->AddHtml($sHtml);
} else {
$oPage->add_script(<<<JS
$(".ibo-top-bar--toolbar-dashboard-title").html("$sTitleForHTML");
$(".ibo-top-bar--toolbar-dashboard-title").html("$sTitleForHTML").attr("title", $('<div>').html("$sTitleForHTML").text());
JS
);
}
@@ -859,28 +860,29 @@ class RuntimeDashboard extends Dashboard
{
$bCustomized = false;
if (!appUserPreferences::GetPref('display_original_dashboard_'.$sDashBoardId, false))
{
$sDashboardFileSanitized = utils::RealPath($sDashboardFile, APPROOT);
if (false === $sDashboardFileSanitized) {
throw new SecurityException('Invalid dashboard file !');
}
if (!appUserPreferences::GetPref('display_original_dashboard_'.$sDashBoardId, false)) {
// Search for an eventual user defined dashboard
$oUDSearch = new DBObjectSearch('UserDashboard');
$oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$oUDSearch->AddCondition('menu_code', $sDashBoardId, '=');
$oUDSet = new DBObjectSet($oUDSearch);
if ($oUDSet->Count() > 0)
{
if ($oUDSet->Count() > 0) {
// Assuming there is at most one couple {user, menu}!
$oUserDashboard = $oUDSet->Fetch();
$sDashboardDefinition = $oUserDashboard->Get('contents');
$bCustomized = true;
}
else
{
$sDashboardDefinition = @file_get_contents($sDashboardFile);
} else {
$sDashboardDefinition = @file_get_contents($sDashboardFileSanitized);
}
}
else
{
$sDashboardDefinition = @file_get_contents($sDashboardFile);
$sDashboardDefinition = @file_get_contents($sDashboardFileSanitized);
}
if ($sDashboardDefinition !== false)
@@ -888,7 +890,7 @@ class RuntimeDashboard extends Dashboard
$oDashboard = new RuntimeDashboard($sDashBoardId);
$oDashboard->FromXml($sDashboardDefinition);
$oDashboard->SetCustomFlag($bCustomized);
$oDashboard->SetDefinitionFile($sDashboardFile);
$oDashboard->SetDefinitionFile($sDashboardFileSanitized);
} else {
$oDashboard = null;
}
@@ -1147,7 +1149,8 @@ JS
utils::GetPopupMenuItems($oPage, iPopupMenuExtension::MENU_DASHBOARD_ACTIONS, $this, $aActions);
$oActionsMenu = $oPage->GetPopoverMenu($sPopoverMenuId, $aActions)
->SetTogglerJSSelector("#$sMenuTogglerId");
->SetTogglerJSSelector("#$sMenuTogglerId")
->SetContainer(PopoverMenu::ENUM_CONTAINER_BODY);
$oToolbar->AddSubBlock($oActionButton)
->AddSubBlock($oActionsMenu);

View File

@@ -16,6 +16,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\Helper\WebResourcesHelper;
use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletContainer;
use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletFactory;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
@@ -202,6 +203,24 @@ abstract class Dashlet
$this->OnUpdate();
}
/**
* @return array Rel. path to the app. root of the JS files required by the dashlet
* @since 3.0.0
*/
public function GetJSFilesRelPaths(): array
{
return [];
}
/**
* @return array Rel. path to the app. root of the CSS files required by the dashlet
* @since 3.0.0
*/
public function GetCSSFilesRelPaths(): array
{
return [];
}
/**
* @param \WebPage $oPage
* @param bool $bEditMode
@@ -224,6 +243,9 @@ abstract class Dashlet
$oDashletContainer->AddCSSClasses($this->aCSSClasses);
}
$oDashletContainer->AddMultipleJsFilesRelPaths($this->GetJSFilesRelPaths());
$oDashletContainer->AddMultipleCssFilesRelPaths($this->GetCSSFilesRelPaths());
try {
if (get_class($this->oModelReflection) == 'ModelReflectionRuntime') {
$oBlock = $this->Render($oPage, $bEditMode, $aExtraParams);
@@ -604,8 +626,7 @@ class DashletUnknown extends Dashlet
$oDashletContainer = new DashletContainer(null, ['dashlet-content']);
$oDashletContainer->AddHtml('<div class="dashlet-ukn-image"><img src="'.$sIconUrl.'" /></div>');
$oDashletContainer->AddHtml('<div class="dashlet-ukn-text">'.$sExplainText.'</div>');
$oDashletContainer->AddHtml('<div class="dashlet-ukn-image"><img src="'.$sIconUrl.'" /></div><div class="dashlet-ukn-text">'.$sExplainText.'</div>');
return $oDashletContainer;
}
@@ -624,8 +645,7 @@ class DashletUnknown extends Dashlet
$oDashletContainer = new DashletContainer(null, ['dashlet-content']);
$oDashletContainer->AddHtml('<div class="dashlet-ukn-image"><img src="'.$sIconUrl.'" /></div>');
$oDashletContainer->AddHtml('<div class="dashlet-ukn-text">'.$sExplainText.'</div>');
$oDashletContainer->AddHtml('<div class="dashlet-ukn-image"><img src="'.$sIconUrl.'" /></div><div class="dashlet-ukn-text">'.$sExplainText.'</div>');
return $oDashletContainer;
}
@@ -906,17 +926,22 @@ class DashletObjectList extends Dashlet
$sShowMenu = $this->aProperties['menu'] ? '1' : '0';
$oFilter = $this->GetDBSearch($aExtraParams);
$sClass = $oFilter->GetClass();
$oPanel = PanelUIBlockFactory::MakeForClass($sClass, Dict::S($sTitle))
->AddCSSClass('ibo-datatable-panel');
//$oPanel = PanelUIBlockFactory::MakeForClass($sClass, Dict::S($sTitle))
// ->AddCSSClass('ibo-datatable-panel');
$oBlock = new DisplayBlock($oFilter, 'list');
$aParams = array(
'menu' => $sShowMenu,
'table_id' => self::APPUSERPREFERENCES_PREFIX.$this->sId,
'surround_with_panel' => false,
'surround_with_panel' => true,
'max_height' => '500px',
"panel_title" => Dict::S($sTitle),
"panel_class" => $sClass,
);
$sBlockId = 'block_'.$this->sId.($bEditMode ? '_edit' : ''); // make a unique id (edition occurring in the same DOM)
$oBlock->DisplayIntoContentBlock($oPanel, $oPage, $sBlockId, array_merge($aExtraParams, $aParams));
//$oBlock->DisplayIntoContentBlock($oPanel, $oPage, $sBlockId, array_merge($aExtraParams, $aParams));
$oPanel = $oBlock->GetDisplay($oPage, $sBlockId, array_merge($aExtraParams, $aParams));
return $oPanel;
}
@@ -926,24 +951,36 @@ class DashletObjectList extends Dashlet
*/
public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array())
{
$oDashletContainer = new DashletContainer($this->sId, ['dashlet-content']);
$sTitle = $this->aProperties['title'];
$sQuery = $this->aProperties['query'];
$bShowMenu = $this->aProperties['menu'];
$oPage->add('<div class="dashlet-content">');
$sHtmlTitle = utils::HtmlEntities($this->oModelReflection->DictString($sTitle)); // done in the itop block
$sHtmlTitle = utils::HtmlEntities($this->oModelReflection->DictString($sTitle));
if ($sHtmlTitle != '') {
$oPage->add('<h1>'.$sHtmlTitle.'</h1>');
$sHtmlTitle = '<h1>'.$sHtmlTitle.'</h1>';
}
$oQuery = $this->oModelReflection->GetQuery($sQuery);
$sClass = $oQuery->GetClass();
$oPage->add('<div id="block_fake_'.$this->sId.'" class="display_block">');
$oPage->p(Dict::S('UI:NoObjectToDisplay'));
$sId = $this->sId;
$sMessage = Dict::S('UI:NoObjectToDisplay');
$sMenu = '';
if ($bShowMenu) {
$oPage->p('<a>'.Dict::Format('UI:ClickToCreateNew', $this->oModelReflection->GetName($sClass)).'</a>');
$sMenu = '<p><a>'.Dict::Format('UI:ClickToCreateNew', $this->oModelReflection->GetName($sClass)).'</a></p>';
}
$oPage->add('</div>');
$oPage->add('</div>');
$sHtml = <<<HTML
<div class="dashlet-content">
<h1>$sHtmlTitle</h1>
<div id="block_fake_$sId" class="display_block">
<p>$sMessage</p>
$sMenu
</div>
</div>
HTML;
$oDashletContainer->AddHtml($sHtml);
return $oDashletContainer;
}
public function GetDBSearch($aExtraParams = array())
@@ -971,6 +1008,8 @@ class DashletObjectList extends Dashlet
$oField = new DesignerLongTextField('query', Dict::S('UI:DashletObjectList:Prop-Query'), $this->aProperties['query']);
$oField->SetMandatory();
$oField->AddCSSClass("ibo-query-oql");
$oField->AddCSSClass("ibo-is-code");
$oForm->AddField($oField);
$oField = new DesignerBooleanField('menu', Dict::S('UI:DashletObjectList:Prop-Menu'), $this->aProperties['menu']);
@@ -1007,6 +1046,8 @@ class DashletObjectList extends Dashlet
$oField = new DesignerHiddenField('query', Dict::S('UI:DashletObjectList:Prop-Query'), $sOQL);
$oField->SetMandatory();
$oField->AddCSSClass("ibo-query-oql");
$oField->AddCSSClass("ibo-is-code");
$oForm->AddField($oField);
$oField = new DesignerBooleanField('menu', Dict::S('UI:DashletObjectList:Prop-Menu'), $this->aProperties['menu']);
@@ -1243,15 +1284,21 @@ abstract class DashletGroupBy extends Dashlet
break;
}
$oPanel = PanelUIBlockFactory::MakeForClass($sClass, Dict::S($sTitle));
//$oPanel = \Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory::MakeStandard();
//PanelUIBlockFactory::MakeForClass($sClass, Dict::S($sTitle));
$sBlockId = 'block_'.$this->sId.($bEditMode ? '_edit' : ''); // make a unique id (edition occurring in the same DOM)
$oBlock = new DisplayBlock($oFilter, $sType);
$oBlock->DisplayIntoContentBlock($oPanel, $oPage, $sBlockId, array_merge($aExtraParams, $aParams));
//$oBlock->DisplayIntoContentBlock($oPanel, $oPage, $sBlockId, array_merge($aExtraParams, $aParams));
$aExtraParams["surround_with_panel"] = true;
$aExtraParams["panel_title"] = Dict::S($sTitle);
$aExtraParams["panel_class"] = $sClass;
$oPanel = $oBlock->GetDisplay($oPage, $sBlockId, array_merge($aExtraParams, $aParams));
if ($bEditMode) {
$oPanel->AddHtml('<div class="dashlet-blocker"></div>');
$oPanel->AddHtml('<div class="ibo-dashlet-blocker dashlet-blocker"></div>');
}
return $oPanel;
}
@@ -1350,10 +1397,11 @@ abstract class DashletGroupBy extends Dashlet
$oField = new DesignerLongTextField('query', Dict::S('UI:DashletGroupBy:Prop-Query'), $this->aProperties['query']);
$oField->SetMandatory();
$oField->AddCSSClass("ibo-query-oql");
$oField->AddCSSClass("ibo-is-code");
$oForm->AddField($oField);
try
{
try {
// Group by field: build the list of possible values (attribute codes + ...)
$aGroupBy = $this->GetGroupByOptions($this->aProperties['query']);
@@ -1607,16 +1655,15 @@ abstract class DashletGroupBy extends Dashlet
$oField = new DesignerHiddenField('query', Dict::S('UI:DashletGroupBy:Prop-Query'), $sOQL);
$oField->SetMandatory();
$oField->AddCSSClass("ibo-query-oql");
$oField->AddCSSClass("ibo-is-code");
$oForm->AddField($oField);
if (!is_null($sOQL))
{
if (!is_null($sOQL)) {
$oField = new DesignerComboField('group_by', Dict::S('UI:DashletGroupBy:Prop-GroupBy'), null);
$aGroupBy = $this->GetGroupByOptions($sOQL);
$oField->SetAllowedValues($aGroupBy);
}
else
{
} else {
// Creating a form for reading parameters!
$oField = new DesignerTextField('group_by', Dict::S('UI:DashletGroupBy:Prop-GroupBy'), null);
}
@@ -1653,6 +1700,28 @@ class DashletGroupByPie extends DashletGroupBy
);
}
/**
* @inheritDoc
*/
public function GetJSFilesRelPaths(): array
{
return array_merge(
parent::GetJSFilesRelPaths(),
WebResourcesHelper::GetJSFilesRelPathsForC3JS()
);
}
/**
* @inheritDoc
*/
public function GetCSSFilesRelPaths(): array
{
return array_merge(
parent::GetCSSFilesRelPaths(),
WebResourcesHelper::GetCSSFilesRelPathsForC3JS()
);
}
/**
* @inheritdoc
*/
@@ -2085,8 +2154,20 @@ class DashletHeaderDynamic extends Dashlet
$sQuery = $this->aProperties['query'];
$sGroupBy = $this->aProperties['group_by'];
$oQuery = $this->oModelReflection->GetQuery($sQuery);
$sClass = $oQuery->GetClass();
$aValueLabels = [];
$aValues = [];
try {
$oQuery = $this->oModelReflection->GetQuery($sQuery);
$sClass = $oQuery->GetClass();
$aValues = $this->GetValues();
foreach ($aValues as $sValue) {
$aValueLabels[] = $this->oModelReflection->GetValueLabel($sClass, $sGroupBy, $sValue);
}
}
catch (UnknownClassOqlException $e) {
$aValueLabels[] = $e->GetUserFriendlyDescription();
$aValues[] = 1;
}
$oIconSelect = $this->oModelReflection->GetIconSelectionField('icon');
$sIconPath = utils::HtmlEntities($oIconSelect->MakeFileUrl($sIcon));
@@ -2099,20 +2180,18 @@ class DashletHeaderDynamic extends Dashlet
$sBlockId = 'block_fake_'.$this->sId.($bEditMode ? '_edit' : ''); // make a unique id (edition occuring in the same DOM)
$iTotal = 0;
$aValues = $this->GetValues();
$sHtml .= '<div class="display_block" id="'.$sBlockId.'">';
$sHtml .= '<div class="summary-details">';
$sHtml .= '<table><tbody>';
$sHtml .= '<tr>';
foreach ($aValues as $sValue) {
$sValueLabel = $this->oModelReflection->GetValueLabel($sClass, $sGroupBy, $sValue);
foreach ($aValueLabels as $sValueLabel) {
$sHtml .= ' <th>'.$sValueLabel.'</th>';
}
$sHtml .= '</tr>';
$sHtml .= '<tr>';
foreach ($aValues as $sValue) {
$iCount = (int)rand(2, 100);
$iCount = rand(2, 100);
$iTotal += $iCount;
$sHtml .= ' <td>'.$iCount.'</td>';
}
@@ -2127,7 +2206,6 @@ class DashletHeaderDynamic extends Dashlet
$sHtml .= '<a class="summary">'.utils::HtmlEntities($sSubtitle).'</a>';
$sHtml .= '</div>';
$sHtml .= '</div>';
$oDashletContainer->AddHtml($sHtml);
@@ -2151,6 +2229,8 @@ class DashletHeaderDynamic extends Dashlet
$oField = new DesignerLongTextField('query', Dict::S('UI:DashletHeaderDynamic:Prop-Query'), $this->aProperties['query']);
$oField->SetMandatory();
$oField->AddCSSClass("ibo-query-oql");
$oField->AddCSSClass("ibo-is-code");
$oForm->AddField($oField);
try
@@ -2309,18 +2389,19 @@ class DashletBadge extends Dashlet
$oDashletContainer = new DashletContainer($this->sId, ['dashlet-content']);
$sClass = $this->aProperties['class'];
$sIconUrl = $this->oModelReflection->GetClassIcon($sClass, false);
$sIconUrl = utils::HtmlEntities($this->oModelReflection->GetClassIcon($sClass, false));
$sClassLabel = $this->oModelReflection->GetName($sClass);
$sId = $this->sId;
$sClassCreate = Dict::Format('UI:ClickToCreateNew', $sClassLabel);
$sHtml = '';
$sHtml .= '<div id="block_fake_'.$this->sId.'" class="display_block">';
$sHtml .= '<p>';
$sHtml .= ' <a class="actions"><img src="'.utils::HtmlEntities($sIconUrl).'" style="vertical-align:middle;float;left;margin-right:10px;border:0;">'.$sClassLabel.': 947</a>';
$sHtml .= '</p>';
$sHtml .= '<p>';
$sHtml .= ' <a>'.Dict::Format('UI:ClickToCreateNew', $sClassLabel).'</a>';
$sHtml .= '</p>';
$sHtml .= '</div>';
$sHtml = <<<HTML
<div id="block_fake_$sId" class="display_block">
<div class="ibo-dashlet-badge--body" data-role="ibo-dashlet-badge--body" title="$sClassLabel">
<div class="ibo-dashlet-badge--icon-container"><img class="ibo-dashlet-badge--icon" src="$sIconUrl"></div>
<div class="ibo-dashlet-badge--actions"><a class="ibo-dashlet-badge--action-list" href="#" data-role="ibo-dashlet-badge--action-list"><span class="ibo-dashlet-badge--action-list-count">4</span><span class="ibo-dashlet-badge--action-list-label">$sClassLabel</span></a><a class="ibo-dashlet-badge--action-create" href="#"><span class="ibo-dashlet-badge--action-create-icon fas fa-plus"></span><span class="ibo-dashlet-badge--action-create-label"> $sClassCreate </span></a></div>
</div>
</div>
HTML;
$oDashletContainer->AddHtml($sHtml);

View File

@@ -258,6 +258,66 @@
</argument>
</arguments>
</method>
<method id="SetComputedDate">
<arguments>
<argument id="1">
<type>attcode</type>
<mandatory>true</mandatory>
<type_restrictions>
<operation>allow</operation>
<types>
<type id="AttributeDate"/>
<type id="AttributeDateTime"/>
</types>
</type_restrictions>
</argument>
<argument id="2">
<type>string</type>
<mandatory>false</mandatory>
</argument>
<argument id="3">
<type>attcode</type>
<mandatory>false</mandatory>
<type_restrictions>
<operation>allow</operation>
<types>
<type id="AttributeDate"/>
<type id="AttributeDateTime"/>
</types>
</type_restrictions>
</argument>
</arguments>
</method>
<method id="SetComputedDateIfNull">
<arguments>
<argument id="1">
<type>attcode</type>
<mandatory>true</mandatory>
<type_restrictions>
<operation>allow</operation>
<types>
<type id="AttributeDate"/>
<type id="AttributeDateTime"/>
</types>
</type_restrictions>
</argument>
<argument id="2">
<type>string</type>
<mandatory>false</mandatory>
</argument>
<argument id="3">
<type>attcode</type>
<mandatory>false</mandatory>
<type_restrictions>
<operation>allow</operation>
<types>
<type id="AttributeDate"/>
<type id="AttributeDateTime"/>
</types>
</type_restrictions>
</argument>
</arguments>
</method>
<method id="SetCurrentDate">
<arguments>
<argument id="1">
@@ -409,30 +469,6 @@
</argument>
</arguments>
</method>
<method id="PrefillCreationForm">
<arguments>
<argument id="1">
<type>reference</type>
<mandatory>true</mandatory>
</argument>
</arguments>
</method>
<method id="PrefillTransitionForm">
<arguments>
<argument id="1">
<type>reference</type>
<mandatory>true</mandatory>
</argument>
</arguments>
</method>
<method id="PrefillSearchForm">
<arguments>
<argument id="1">
<type>reference</type>
<mandatory>true</mandatory>
</argument>
</arguments>
</method>
</methods>
</class>
</classes>

View File

@@ -48,6 +48,7 @@ class DataTable
*/
public function __construct($iListId, $oSet, $aClassAliases, $sTableId = null)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use Combodo\iTop\Application\UI\Base\Component\DataTable\Datatable');
$this->iListId = utils::GetSafeId($iListId); // Make a "safe" ID for jQuery
$this->sDatatableContainerId = 'datatable_'.utils::GetSafeId($iListId);
$this->oSet = $oSet;
@@ -115,8 +116,7 @@ class DataTable
// See if this column is a must to load
$sClass = $this->aClassAliases[$sAlias];
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->alwaysLoadInTables())
{
if ($oAttDef->AlwaysLoadInTables()) {
$aColumnsToLoad[$sAlias][] = $sAttCode;
}
}

View File

@@ -10,8 +10,10 @@ use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletFactory;
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Pill\PillFactory;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItemFactory;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\Separator\ToolbarSeparatorUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
use Combodo\iTop\Application\UI\Base\iUIBlock;
@@ -168,6 +170,10 @@ class DisplayBlock
/** bool add toolkit menu */
'selectionMode',
/**positive or negative*/
'max_height',
/** string Max. height of the list, if not specified will occupy all the available height no matter the pagination */
'localize_values',
/** param for export.php */
], DataTableUIBlockFactory::GetAllowedParams()),
'list_search' => array_merge([
'update_history',
@@ -186,6 +192,8 @@ class DisplayBlock
/** string */
'open',
/** bool open by default the search */
'submit_on_load',
/** bool submit the search on loading page */
'class', /** class name */
'search_header_force_dropdown', /** Html for <select> to choose the class to search */
'this',
@@ -195,6 +203,8 @@ class DisplayBlock
/** string search root class */
'open',
/** bool open the search panel by default */
'submit_on_load',
/** bool submit the search on loading page */
'result_list_outer_selector',
/** string js selector of the search result display */
'search_header_force_dropdown',
@@ -254,6 +264,16 @@ class DisplayBlock
'withJSRefreshCallBack',
/** true if dashboard page */
'from_dashboard_page',
/** bool true if list may be render in panel block */
'surround_with_panel',
/** string title of panel block */
'panel_title',
/** string true if panel title should be displayed as html */
'panel_title_is_html',
/** string class for panel block style */
'panel_class',
/** string class for panel block style */
'panel_icon',
];
if (isset($aAllowedParams[$sStyle])) {
@@ -449,10 +469,8 @@ class DisplayBlock
$oHtml->AddSubBlock($this->GetRenderContent($oPage, $aExtraParams, $sId));
} catch (Exception $e) {
if (UserRights::IsAdministrator()) {
$sExceptionContent = <<<HTML
Exception thrown:<br>
<code>{$e->getMessage()}</code>
HTML;
$sExceptionContent = 'Exception thrown:<br><code>'.utils::Sanitize($e->getMessage(), '', utils::ENUM_SANITIZATION_FILTER_STRING).'</code>';
$oExceptionAlert = AlertUIBlockFactory::MakeForFailure('Cannot display results', $sExceptionContent);
$oHtml->AddSubBlock($oExceptionAlert);
}
@@ -994,9 +1012,10 @@ JS
$aCountsQueryResults[$aCountGroupBySingleResult[0]] = $aCountGroupBySingleResult[1];
}
$oAttDef = MetaModel::GetAttributeDef($sClass, $sStateAttrCode);
$aValues = $oAttDef->GetAllowedValues();
foreach ($aStates as $sStateValue) {
$oAttDef = MetaModel::GetAttributeDef($sClass, $sStateAttrCode);
$aStateLabels[$sStateValue] = $oAttDef->GetAsPlainText($sStateValue);
$aStateLabels[$sStateValue] = $aValues[$sStateValue] ?? '';
$aCounts[$sStateValue] = (array_key_exists($sStateValue, $aCountsQueryResults))
? $aCountsQueryResults[$sStateValue]
: 0;
@@ -1023,10 +1042,11 @@ JS
$sHyperlink = $aCount['link'];
$sCountLabel = $aCount['label'];
$oPill = PillFactory::MakeForState($sClass, $sStateValue)
->SetUrl($sHyperlink)
->SetTooltip($sStateLabel)
->AddHtml("<span class=\"ibo-dashlet-header-dynamic--count\">$sCountLabel</span>")
->AddHtml("<span class=\"ibo-dashlet-header-dynamic--label ibo-text-truncated-with-ellipsis\">$sStateLabel</span>");
->AddHtml("<span class=\"ibo-dashlet-header-dynamic--count\">$sCountLabel</span><span class=\"ibo-dashlet-header-dynamic--label ibo-text-truncated-with-ellipsis\">".utils::HtmlEntities($sStateLabel)."</span>");
if ($sHyperlink != '-') {
$oPill->SetUrl($sHyperlink);
}
$oBlock->AddSubBlock($oPill);
}
$aExtraParams['query_params'] = $this->m_oFilter->GetInternalParams();
@@ -1138,7 +1158,7 @@ JS
$aValues[$iRow] = $sValue;
$sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
$aLabels[$iRow] = $sHtmlValue;
$aGroupBy[$iRow] = (int)$aRow[$sFctVar];
$aGroupBy[$iRow] = (float)$aRow[$sFctVar];
$iTotalCount += $aRow['_itop_count_'];
}
@@ -1170,11 +1190,23 @@ JS
),
);
$sFormat = isset($aExtraParams['format']) ? $aExtraParams['format'] : 'UI:Pagination:HeaderNoSelection';
$sTitle = Dict::Format($sFormat, $iTotalCount);
$aExtraParams['query_params'] = $this->m_oFilter->GetInternalParams();
$aOption['dom'] = 'pl';
$oBlock = DataTableUIBlockFactory::MakeForStaticData($sTitle, $aAttribs, $aData, null, $aExtraParams, $this->m_oFilter->ToOQL(), $aOption);
if (isset($aExtraParams["surround_with_panel"]) && $aExtraParams["surround_with_panel"]) {
$sTitle = Dict::Format($sFormat, $iTotalCount);
$oBlock = PanelUIBlockFactory::MakeForClass($aExtraParams["panel_class"], $aExtraParams["panel_title"]);
$oBlock->AddSubTitleBlock(new Html($sTitle));
if(isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0){
$oBlock->SetIcon($aExtraParams["panel_icon"]);
}
$oDataTable = DataTableUIBlockFactory::MakeForStaticData("", $aAttribs, $aData, null, $aExtraParams, $this->m_oFilter->ToOQL(), $aOption);
$oBlock->AddSubBlock($oDataTable);
} else {
$sTitle = Dict::Format($sFormat, $iTotalCount);
$oBlock = DataTableUIBlockFactory::MakeForStaticData($sTitle, $aAttribs, $aData, null, $aExtraParams, $this->m_oFilter->ToOQL(), $aOption);
}
} else {
// Simply count the number of elements in the set
@@ -1183,7 +1215,15 @@ JS
if (isset($aExtraParams['format'])) {
$sFormat = $aExtraParams['format'];
}
$oBlock = new Html('<p>'.Dict::Format($sFormat, $iCount).'</p>');
if (isset($aExtraParams["surround_with_panel"]) && $aExtraParams["surround_with_panel"]) {
$oBlock = PanelUIBlockFactory::MakeForClass($aExtraParams["panel_class"], $aExtraParams["panel_title"]);
if(isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0){
$oBlock->SetIcon($aExtraParams["panel_icon"]);
}
$oBlock->AddSubBlock(new Html('<p>'.Dict::Format($sFormat, $iCount).'</p>'));
} else {
$oBlock = new Html('<p>'.Dict::Format($sFormat, $iCount).'</p>');
}
}
return $oBlock;
@@ -1270,6 +1310,22 @@ JS
$oBlock->bNotAuthorized = true;
}
} else {
if (isset($aExtraParams['update_history']) && true == $aExtraParams['update_history']) {
$sSearchFilter = $this->m_oSet->GetFilter()->serialize();
// Limit the size of the URL (N°1585 - request uri too long)
if (strlen($sSearchFilter) < SERVER_MAX_URL_LENGTH) {
$oBlock->sEventAttachedData = json_encode(array(
'filter' => $sSearchFilter,
'breadcrumb_id' => "ui-search-".$this->m_oSet->GetClass(),
'breadcrumb_label' => MetaModel::GetName($this->m_oSet->GetClass()),
'breadcrumb_max_count' => utils::GetConfig()->Get('breadcrumb.max_count'),
'breadcrumb_instance_id' => MetaModel::GetConfig()->GetItopInstanceid(),
'breadcrumb_icon' => 'fas fa-search',
'breadcrumb_icon_type' => iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES,
));
}
}
// The list is made of only 1 class of objects, actions on the list are possible
if (($this->m_oSet->CountWithLimit(1) > 0) && (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES)) {
$oBlock->AddSubBlock(cmdbAbstractObject::GetDisplaySetBlock($oPage, $this->m_oSet, $aExtraParams));
@@ -1296,25 +1352,19 @@ JS
$oBlock->bCreateNew = true;
}
}
}
if (isset($aExtraParams['update_history']) && true == $aExtraParams['update_history']) {
$sSearchFilter = $this->m_oSet->GetFilter()->serialize();
// Limit the size of the URL (N°1585 - request uri too long)
if (strlen($sSearchFilter) < SERVER_MAX_URL_LENGTH) {
$oBlock->sEventAttachedData = json_encode(array(
'filter' => $sSearchFilter,
'breadcrumb_id' => "ui-search-".$this->m_oSet->GetClass(),
'breadcrumb_label' => MetaModel::GetName($this->m_oSet->GetClass()),
'breadcrumb_max_count' => utils::GetConfig()->Get('breadcrumb.max_count'),
'breadcrumb_instance_id' => MetaModel::GetConfig()->GetItopInstanceid(),
'breadcrumb_icon' => 'fas fa-search',
'breadcrumb_icon_type' => iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES,
));
if (isset($aExtraParams["surround_with_panel"]) && $aExtraParams["surround_with_panel"]) {
$oPanel = PanelUIBlockFactory::MakeForClass($aExtraParams["panel_class"], $aExtraParams["panel_title"]);
if(isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0){
$oPanel->SetIcon($aExtraParams["panel_icon"]);
}
$oPanel->AddSubBlock($oBlock);
return $oPanel;
}
}
}
}
return $oBlock;
}
@@ -1503,6 +1553,16 @@ JS
$oBlock->sUrl = $sUrl;
if (isset($aExtraParams["surround_with_panel"]) && $aExtraParams["surround_with_panel"]) {
$oPanel = PanelUIBlockFactory::MakeForClass($aExtraParams["panel_class"], $aExtraParams["panel_title"]);
if(isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0){
$oPanel->SetIcon($aExtraParams["panel_icon"]);
}
$oPanel->AddSubBlock($oBlock);
return $oPanel;
}
return $oBlock;
}
@@ -1538,7 +1598,7 @@ JS
$aValues[] = array(
'label' => html_entity_decode(strip_tags($sHtmlValue), ENT_QUOTES, 'UTF-8'),
'label_html' => $sHtmlValue,
'value' => (int)$aRow[$sFctVar],
'value' => (float)$aRow[$sFctVar],
);
// Build the search for this subset
@@ -1573,7 +1633,7 @@ JS
$aColumns = array();
$aNames = array();
foreach ($aValues as $idx => $aValue) {
$aColumns[] = array('series_'.$idx, (int)$aValue['value']);
$aColumns[] = array('series_'.$idx, (float)$aValue['value']);
$aNames['series_'.$idx] = $aValue['label'];
}
$oBlock = new BlockChartAjaxPie();
@@ -1584,6 +1644,16 @@ JS
$oBlock->sURLForRefresh = str_replace("'", "\'", $sUrl);
break;
}
if (isset($aExtraParams["surround_with_panel"]) && $aExtraParams["surround_with_panel"]) {
$oPanel = PanelUIBlockFactory::MakeForClass($aExtraParams["panel_class"], $aExtraParams["panel_title"]);
if(isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0){
$oPanel->SetIcon($aExtraParams["panel_icon"]);
}
$oPanel->AddSubBlock($oBlock);
return $oPanel;
}
return $oBlock;
}
@@ -1646,6 +1716,7 @@ class HistoryBlock extends DisplayBlock
public function __construct(DBSearch $oFilter, $sStyle = 'list', $bAsynchronous = false, $aParams = array(), $oSet = null)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
parent::__construct($oFilter, $sStyle, $bAsynchronous, $aParams, $oSet);
$this->iLimitStart = 0;
$this->iLimitCount = 0;
@@ -1771,6 +1842,13 @@ EOF
*/
class MenuBlock extends DisplayBlock
{
/**
* @var string Prefix to use for the ID of the actions toolbar
* @used-by static::GetRenderContent
* @since 3.0.0
*/
public const ACTIONS_TOOLBAR_ID_PREFIX = 'ibo-actions-toolbar-';
/**
* Renders the "Actions" popup menu for the given set of objects
*
@@ -1812,6 +1890,8 @@ class MenuBlock extends DisplayBlock
$aRegularActions = [];
/** @var array $aTransitionActions Only transitions */
$aTransitionActions = [];
/** @var array $aToolkitActions Any "legacy" toolkit menu item, which are now displayed in the same menu as the $aRegularActions, after them */
$aToolkitActions = [];
if ((!isset($aExtraParams['selection_mode']) || $aExtraParams['selection_mode'] == "") && $this->m_sStyle != 'listInObject') {
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
@@ -1981,13 +2061,9 @@ class MenuBlock extends DisplayBlock
$this->AddMenuSeparator($aRegularActions);
/** @var \iApplicationUIExtension $oExtensionInstance */
foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) {
$oSet->Rewind();
foreach ($oExtensionInstance->EnumAllowedActions($oSet) as $sLabel => $sUrl) {
$aRegularActions[$sLabel] = array('label' => $sLabel, 'url' => $sUrl) + $aActionParams;
}
}
$this->GetEnumAllowedActions($oSet, function ($sLabel, $data) use (&$aRegularActions, $aActionParams) {
$aRegularActions[$sLabel] = array('label' => $sLabel, 'url' => $data) + $aActionParams;
});
}
break;
@@ -2089,24 +2165,20 @@ class MenuBlock extends DisplayBlock
$this->AddMenuSeparator($aRegularActions);
/** @var \iApplicationUIExtension $oExtensionInstance */
foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) {
$oSet->Rewind();
foreach ($oExtensionInstance->EnumAllowedActions($oSet) as $sLabel => $data) {
if (is_array($data)) {
// New plugins can provide javascript handlers via the 'onclick' property
//TODO: enable extension of different menus by checking the 'target' property ??
$aRegularActions[$sLabel] = [
'label' => $sLabel,
'url' => isset($data['url']) ? $data['url'] : '#',
'onclick' => isset($data['onclick']) ? $data['onclick'] : '',
];
} else {
// Backward compatibility with old plugins
$aRegularActions[$sLabel] = ['label' => $sLabel, 'url' => $data] + $aActionParams;
}
$this->GetEnumAllowedActions($oSet, function ($sLabel, $data) use (&$aRegularActions, $aActionParams) {
if (is_array($data)) {
// New plugins can provide javascript handlers via the 'onclick' property
//TODO: enable extension of different menus by checking the 'target' property ??
$aRegularActions[$sLabel] = [
'label' => $sLabel,
'url' => isset($data['url']) ? $data['url'] : '#',
'onclick' => isset($data['onclick']) ? $data['onclick'] : '',
];
} else {
// Backward compatibility with old plugins
$aRegularActions[$sLabel] = ['label' => $sLabel, 'url' => $data] + $aActionParams;
}
}
});
if (empty($sRefreshAction) && $this->m_sStyle == 'list') {
//for the detail page this var is defined way beyond this line
@@ -2116,18 +2188,17 @@ class MenuBlock extends DisplayBlock
//it's easier just display configure this list and MENU_OBJLIST_TOOLKIT
}
$param = null;
$iMenuId = null;
if (is_null($sId)) {
$sId = uniqid();
}
// New extensions based on iPopupMenuItem interface
$oPopupMenuItemsBlock = new UIContentBlock();
switch ($this->m_sStyle) {
case 'list':
case 'listInObject':
$oSet->Rewind();
$param = $oSet;
$iMenuId = iPopupMenuExtension::MENU_OBJLIST_ACTIONS;
$bToolkitMenu = true;
if (isset($aExtraParams['toolkit_menu'])) {
$bToolkitMenu = (bool)$aExtraParams['toolkit_menu'];
@@ -2136,23 +2207,27 @@ class MenuBlock extends DisplayBlock
$sLabel = Dict::S('UI:ConfigureThisList');
$aRegularActions['iTop::ConfigureList'] = ['label' => $sLabel, 'url' => '#', 'onclick' => "$('#datatable_dlg_datatable_{$sId}').dialog('open'); return false;"];
}
utils::GetPopupMenuItemsBlock($oPopupMenuItemsBlock, iPopupMenuExtension::MENU_OBJLIST_ACTIONS, $param, $aRegularActions, $sId);
utils::GetPopupMenuItemsBlock($oPopupMenuItemsBlock, iPopupMenuExtension::MENU_OBJLIST_TOOLKIT, $param, $aToolkitActions, $sId);
break;
case 'details':
$oSet->Rewind();
$param = $oSet->Fetch();
$iMenuId = iPopupMenuExtension::MENU_OBJDETAILS_ACTIONS;
utils::GetPopupMenuItemsBlock($oPopupMenuItemsBlock, iPopupMenuExtension::MENU_OBJDETAILS_ACTIONS, $param, $aRegularActions, $sId);
break;
}
$oRenderBlock->AddSubBlock(utils::GetPopupMenuItemsBlock($iMenuId, $param, $aRegularActions, $sId));
if ($oPopupMenuItemsBlock->HasSubBlocks()) {
$oRenderBlock->AddSubBlock($oPopupMenuItemsBlock);
}
// Extract favorite actions from their menus
$aFavoriteRegularActions = [];
$aFavoriteTransitionActions = [];
$aCallSpec = [$sClass, 'GetShortcutActions'];
if (is_callable($aCallSpec)) {
$aShortcutActions = call_user_func($aCallSpec, $sClass);
if (is_callable([$sClass, 'GetShortcutActions'])) {
/** @var cmdbAbstractObject $sClass */
$aShortcutActions = $sClass::GetShortcutActions($sClass);
foreach ($aShortcutActions as $key) {
// Regular actions
if (isset($aRegularActions[$key])) {
@@ -2168,7 +2243,7 @@ class MenuBlock extends DisplayBlock
}
}
$oActionsToolbar = ToolbarUIBlockFactory::MakeForAction("ibo-actions-toolbar-{$sId}");
$oActionsToolbar = ToolbarUIBlockFactory::MakeForAction(static::ACTIONS_TOOLBAR_ID_PREFIX.$sId);
$oRenderBlock->AddSubBlock($oActionsToolbar);
$sRegularActionsMenuTogglerId = "ibo-regular-actions-menu-toggler-{$sId}";
$sRegularActionsPopoverMenuId = "ibo-regular-actions-popover-{$sId}";
@@ -2247,13 +2322,25 @@ class MenuBlock extends DisplayBlock
$sIconClass = 'fas fa-share-alt';
$sLabel = '';
break;
default:
if (isset($aAction['icon_class']) && (strlen($aAction['icon_class']) > 0)) {
$sIconClass = $aAction['icon_class'];
$sLabel = '';
}
}
$sTarget = isset($aAction['target']) ? $aAction['target'] : '';
$oActionButton = ButtonUIBlockFactory::MakeLinkNeutral($sUrl, $sLabel, $sIconClass, $sTarget, $sActionId);
$oActionButton = ButtonUIBlockFactory::MakeLinkNeutral($sUrl, $sLabel, $sIconClass, $sTarget, utils::Sanitize($sActionId, '', utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER));
// ResourceId should not be sanitized
$oActionButton->AddDataAttribute('resource-id', $sActionId);
$oActionButton->AddCSSClasses(['ibo-action-button', 'ibo-regular-action-button']);
if (empty($sLabel)) {
$oActionButton->SetTooltip(Dict::S($sActionId));
if (empty($aAction['tooltip'])) {
$oActionButton->SetTooltip(Dict::S($sActionId));
} else {
$oActionButton->SetTooltip($aAction['tooltip']);
}
}
$oActionsToolbar->AddSubBlock($oActionButton);
}
@@ -2261,7 +2348,7 @@ class MenuBlock extends DisplayBlock
// - Refresh
if ($sRefreshAction != '') {
$oActionButton = ButtonUIBlockFactory::MakeAlternativeNeutral('', 'UI:Button:Refresh');
$oActionButton->SetIconClass('fas fa-sync')
$oActionButton->SetIconClass('fas fa-sync-alt')
->SetOnClickJsCode($sRefreshAction)
->SetTooltip(Dict::S('UI:Button:Refresh'))
->AddCSSClasses(['ibo-action-button', 'ibo-regular-action-button']);
@@ -2276,7 +2363,7 @@ class MenuBlock extends DisplayBlock
}
// - Others
if (!empty($aRegularActions)) {
if (!empty($aRegularActions) || !empty($aToolkitActions)) {
if (count($aFavoriteRegularActions) > 0) {
$sName = 'UI:Menu:OtherActions';
} else {
@@ -2291,15 +2378,75 @@ class MenuBlock extends DisplayBlock
$oActionsToolbar->AddSubBlock($oActionButton)
->AddSubBlock($oRegularActionsMenu);
// Toolkit actions
if (!empty($aToolkitActions)) {
foreach ($aToolkitActions as $sActionId => $aActionData) {
$oRegularActionsMenu->AddItem('toolkit-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItemData($sActionId, $aActionData));
}
}
}
}
return $oRenderBlock;
}
/**
* If an extension doesn't return an array as expected :
* - calls IssueLog:Warning
* - if is dev env, then throw CoreUnexpectedValue exception
*
* @param \DBObjectSet $oSet
* @param callable $callback EnumAllowedActions returns an array, we will call this anonymous function on each of its value
* with two parameters : label (array index), data (array value)
*
* @throws \CoreUnexpectedValue
*
* @uses \MetaModel::EnumPlugins()
* @uses \iApplicationUIExtension::EnumAllowedActions()
* @uses \utils::IsDevelopmentEnvironment()
*
* @since 3.0.0
*/
private function GetEnumAllowedActions(DBObjectSet $oSet, callable $callback): void
{
$aInvalidExtensions = [];
/** @var \iApplicationUIExtension $oExtensionInstance */
foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) {
$oSet->Rewind();
$aExtEnumAllowedActions = $oExtensionInstance->EnumAllowedActions($oSet);
if (!is_array($aExtEnumAllowedActions)) {
$aInvalidExtensions[] = get_class($oExtensionInstance);
continue;
}
foreach ($aExtEnumAllowedActions as $sLabel => $data) {
$callback($sLabel, $data);
}
}
if (!empty($aInvalidExtensions)) {
$sMessage = 'Some extensions returned non array value for EnumAllowedActions() method impl';
IssueLog::Warning(
$sMessage,
null,
['extensions' => $aInvalidExtensions]
);
if (utils::IsDevelopmentEnvironment()) {
throw new CoreUnexpectedValue($sMessage, $aInvalidExtensions);
}
}
}
/**
* Appends a menu separator to the current list of actions
*
* @param array $aActions The current actions list
*
* @return void
*/
protected function AddMenuSeparator(&$aActions)

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/ErrorPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/ErrorPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/ErrorPage.php, now loadable using autoloader');

View File

@@ -28,14 +28,14 @@ class CoreCannotSaveObjectException extends CoreException
*
* @param array $aContextData containing at least those keys : issues, id, class
*/
public function __construct($aContextData)
public function __construct($aContextData, $oPrevious = null)
{
$this->aIssues = $aContextData['issues'];
$this->iObjectId = $aContextData['id'];
$this->sObjectClass = $aContextData['class'];
$sIssues = implode(', ', $this->aIssues);
parent::__construct($sIssues, $aContextData);
parent::__construct($sIssues, $aContextData, '', $oPrevious);
}
/**

View File

@@ -30,5 +30,10 @@ class MySQLException extends CoreException
$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);
}
}
}

View File

@@ -102,12 +102,20 @@ class DesignerForm
$sReturn .= '<fieldset>';
$sReturn .= '<legend>'.$sLabel.'</legend>';
}
/** @var \DesignerFormField $oField */
foreach($aFields as $oField) {
$aRow = $oField->Render($oP, $sFormId);
if ($oField->IsVisible()) {
$sValidation = '<span class="prop_apply ibo-prop--apply">'.$this->GetValidationArea($oField->GetFieldId()).'</span>';
$sValidation = '<span class="prop_apply ibo-prop--apply ibo-button ibo-is-alternative">'.$this->GetValidationArea($oField->GetFieldId()).'</span>';
$sField = $aRow['value'].$sValidation;
$aDetails[] = array('label' => $aRow['label'], 'value' => $sField);
$aDetails[] = array(
'label' => $aRow['label'],
'value' => $sField,
'attcode' => $oField->GetCode(),
'attlabel' => $aRow['label'],
'inputid' => $this->GetFieldId($oField->GetCode()),
'inputtype' => $oField->GetInputType(),
);
} else {
$sHiddenFields .= $aRow['value'];
}
@@ -203,51 +211,41 @@ class DesignerForm
$sActionUrl = addslashes($this->sSubmitTo);
$sJSSubmitParams = json_encode($this->aSubmitParams);
$sFormId = $this->GetFormId();
if ($this->oParentForm == null)
{
if ($this->oParentForm == null) {
$sReturn = '<form id="'.$sFormId.'" onsubmit="return false;">';
$sReturn .= '<table class="prop_table">';
$sReturn .= '<thead><tr><th class="prop_header">'.Dict::S('UI:Form:Property').'</th><th class="prop_header">'.Dict::S('UI:Form:Value').'</th><th colspan="2" class="prop_header">&nbsp;</th></tr></thead><tbody>';
$sReturn .= '<thead><tr><th class="ibo-prop-header">'.Dict::S('UI:Form:Property').'</th><th class="ibo-prop-header">'.Dict::S('UI:Form:Value').'</th><th colspan="2" class="ibo-prop-header">&nbsp;</th></tr></thead><tbody>';
}
$sHiddenFields = '';
foreach($this->aFieldSets as $sLabel => $aFields)
{
foreach ($this->aFieldSets as $sLabel => $aFields) {
$aDetails = array();
if ($sLabel != '')
{
if ($sLabel != '') {
$sReturn .= $this->StartRow().'<th colspan="4">'.$sLabel.'</th>'.$this->EndRow();
}
foreach($aFields as $oField)
{
foreach ($aFields as $oField) {
$aRow = $oField->Render($oP, $sFormId, 'property');
if ($oField->IsVisible())
{
if ($oField->IsVisible()) {
$sFieldId = $this->GetFieldId($oField->GetCode());
$sValidation = $this->GetValidationArea($sFieldId, '<span data-tooltip-content="Apply"><i class="fas fa-check"></i></span>');
$sValidationFields = '</td><td class="prop_icon prop_apply ibo-prop--apply">'.$sValidation.'</td><td class="prop_icon prop_cancel ibo-prop--cancel"><span data-tooltip-content="Revert"><i class="fas fa-times"></i></span></td>'.$this->EndRow();
$sPath = $this->GetHierarchyPath().'/'.$oField->GetCode();
if (is_null($aRow['label']))
{
$sReturn .= $this->StartRow($sFieldId).'<td class="prop_value ibo-field--value" colspan="2">'.$aRow['value'];
$sValidation = $this->GetValidationArea($sFieldId, '<div class="ibo-button ibo-is-alternative ibo-is-success" data-tooltip-content="'.Dict::Format('UI:DashboardEdit:Apply').'"><i class="fas fa-check"></i></div>');
$sValidationFields = '</td><td class="prop_icon prop_apply ibo-prop--apply" >'.$sValidation.'</td><td class="prop_icon prop_cancel ibo-prop--cancel"><span><div class="ibo-button ibo-is-alternative ibo-is-neutral" data-tooltip-content="'.Dict::Format('UI:DashboardEdit:Revert').'"><i class="fas fa-undo"></i></div></span></td>'
.$this->EndRow();
if (is_null($aRow['label'])) {
$sReturn .= $this->StartRow($sFieldId).'<td class="prop_value" colspan="2">'.$aRow['value'];
} else {
$sReturn .= $this->StartRow($sFieldId).'<td class="prop_label">'.$aRow['label'].'</td><td class="prop_value">'.$aRow['value'];
}
else
{
$sReturn .= $this->StartRow($sFieldId).'<td class="prop_label ibo-field--label">'.$aRow['label'].'</td><td class="prop_value ibo-field--value">'.$aRow['value'];
}
if (!($oField instanceof DesignerFormSelectorField) && !($oField instanceof DesignerMultipleSubFormField))
{
if (!($oField instanceof DesignerFormSelectorField) && !($oField instanceof DesignerMultipleSubFormField)) {
$sReturn .= $sValidationFields;
}
$sNotifyParentSelectorJS = is_null($sNotifyParentSelector) ? 'null' : "'".addslashes($sNotifyParentSelector)."'";
$sAutoApply = $oField->IsAutoApply() ? 'true' : 'false';
$sHandlerEquals = $oField->GetHandlerEquals();
$sHandlerGetValue = $oField->GetHandlerGetValue();
$sWidgetClass = $oField->GetWidgetClass();
$sJSExtraParams = '';
if (count($oField->GetWidgetExtraParams()) > 0)
@@ -356,7 +354,7 @@ EOF
<<<EOF
$('#$sDialogId').dialog({
height: 'auto',
maxHeight: $(window).height() - 8,
maxHeight: $(window).height() * 0.9,
width: $iDialogWidth,
modal: true,
autoOpen: $sAutoOpen,
@@ -712,11 +710,27 @@ class DesignerFormField
$this->bMandatory = false;
$this->bReadOnly = false;
$this->bAutoApply = false;
$this->aCSSClasses = array('ibo-input');
$this->aCSSClasses = [];
if (ContextTag::Check(ContextTag::TAG_CONSOLE)) {
$this->aCSSClasses[] = 'ibo-input';
}
$this->bDisplayed = true;
$this->aWidgetExtraParams = array();
}
/**
* Important, for now we use constants from the \cmdbAbstractObject class, introducing a coupling that should not exist.
* This has been traced under N°4241 and will be discussed during the next modernization batch.
*
* @return string|null Return the input type of the field
* @see \cmdbAbstractObject::ENUM_INPUT_TYPE_XXX
* @since 3.0.0
*/
public function GetInputType(): ?string
{
return cmdbAbstractObject::ENUM_INPUT_TYPE_SINGLE_INPUT;
}
/**
* @return string
*/
@@ -1054,7 +1068,18 @@ class DesignerLongTextField extends DesignerTextField
public function __construct($sCode, $sLabel = '', $defaultValue = '')
{
parent::__construct($sCode, $sLabel, $defaultValue);
$this->aCSSClasses[] = 'ibo-input-text';
if (ContextTag::Check(ContextTag::TAG_CONSOLE)) {
$this->aCSSClasses[] = 'ibo-input-text';
}
}
/**
* @inheritDoc
*/
public function GetInputType(): string
{
return cmdbAbstractObject::ENUM_INPUT_TYPE_TEXTAREA;
}
public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
@@ -1180,14 +1205,35 @@ class DesignerComboField extends DesignerFormField
$this->bMultipleSelection = false;
$this->bOtherChoices = false;
$this->sNullLabel = Dict::S('UI:SelectOne');
$this->aCSSClasses[] = 'ibo-input-select';
if (ContextTag::Check(ContextTag::TAG_CONSOLE)) {
$this->aCSSClasses[] = 'ibo-input-select';
}
$this->bAutoApply = true;
$this->bSorted = true; // Sorted by default
}
public function SetAllowedValues($aAllowedValues)
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
if ($this->bMultipleSelection) {
return cmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_MULTIPLE_CHOICES;
}
else {
return cmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_RAW;
}
}
public function SetAllowedValues(?array $aAllowedValues)
{
// Make sure to have an actual array for values
if (is_null($aAllowedValues)) {
$aAllowedValues = [];
}
$this->aAllowedValues = $aAllowedValues;
}
@@ -1264,11 +1310,11 @@ class DesignerComboField extends DesignerFormField
{
if ($this->bMultipleSelection)
{
$sHtml = "<select $sCSSClasses multiple size=\"8\"id=\"$sId\" name=\"$sName\">";
$sHtml = "<span><select $sCSSClasses multiple size=\"8\"id=\"$sId\" name=\"$sName\">";
}
else
{
$sHtml = "<select $sCSSClasses id=\"$sId\" name=\"$sName\">";
$sHtml = "<span class=\"ibo-input-select-wrapper\"><select $sCSSClasses id=\"$sId\" name=\"$sName\">";
if ($this->sNullLabel != '')
{
$sHtml .= "<option value=\"\">".$this->sNullLabel."</option>";
@@ -1288,7 +1334,7 @@ class DesignerComboField extends DesignerFormField
$sHtmlValue = str_replace(' ', '&nbsp;', htmlentities($sDisplayValue, ENT_QUOTES, 'UTF-8'));
$sHtml .= "<option value=\"".htmlentities($sKey, ENT_QUOTES, 'UTF-8')."\" $sSelected>$sHtmlValue</option>";
}
$sHtml .= "</select>";
$sHtml .= "</select></span>";
if ($this->bOtherChoices)
{
$sHtml .= '<br/><input type="checkbox" id="other_chk_'.$sId.'"><label for="other_chk_'.$sId.'">&nbsp;Other:</label>&nbsp;<input type="text" id="other_'.$sId.'" name="other_'.$sName.'" size="30"/>';
@@ -1319,7 +1365,17 @@ class DesignerBooleanField extends DesignerFormField
{
parent::__construct($sCode, $sLabel, $defaultValue);
$this->bAutoApply = true;
$this->aCSSClasses[] = 'ibo-input-checkbox';
if (ContextTag::Check(ContextTag::TAG_CONSOLE)) {
$this->aCSSClasses[] = 'ibo-input-checkbox';
}
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return cmdbAbstractObject::ENUM_INPUT_TYPE_CHECKBOX;
}
public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
@@ -1380,6 +1436,14 @@ class DesignerHiddenField extends DesignerFormField
{
parent::__construct($sCode, $sLabel, $defaultValue);
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return null;
}
public function IsVisible()
{
@@ -1407,6 +1471,14 @@ class DesignerIconSelectionField extends DesignerFormField
$this->bAutoApply = true;
$this->sUploadUrl = null;
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return cmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_DECORATED;
}
public function SetAllowedValues($aAllowedValues)
{
@@ -1423,28 +1495,33 @@ class DesignerIconSelectionField extends DesignerFormField
$sId = $this->oForm->GetFieldId($this->sCode);
$sName = $this->oForm->GetFieldName($this->sCode);
$idx = 0;
foreach($this->aAllowedValues as $index => $aValue)
{
if ($aValue['value'] == $this->defaultValue)
{
$idxFallback = 0;
foreach ($this->aAllowedValues as $index => $aValue) {
if ($aValue['value'] == $this->defaultValue) {
$idx = $index;
break;
}
//fallback if url of default value contains ../
//for contact, icon is http://localhost/env-production/itop-structure/../../images/icons/icons8-customer.svg => not found http://localhost/images/icons/icons8-customer.svg
if (basename($aValue['value']) == basename($this->defaultValue)) {
$idxFallback = $index;
}
}
if ($idx == 0) {
$idx = $idxFallback;
}
$sJSItems = json_encode($this->aAllowedValues);
$sPostUploadTo = ($this->sUploadUrl == null) ? 'null' : "'{$this->sUploadUrl}'";
if (!$this->IsReadOnly())
{
if (!$this->IsReadOnly()) {
$sDefaultValue = ($this->defaultValue !== '') ? $this->defaultValue : $this->aAllowedValues[$idx]['value'];
$sValue = "<input type=\"hidden\" id=\"$sId\" name=\"$sName\" value=\"{$sDefaultValue}\"/>";
$sCSSClasses = ContextTag::Check(ContextTag::TAG_CONSOLE) ? 'class="ibo-input-select-wrapper"' : '';
$sValue = "<span $sCSSClasses><input type=\"hidden\" id=\"$sId\" name=\"$sName\" value=\"{$sDefaultValue}\"/></span>";
$oP->add_ready_script(
<<<EOF
<<<EOF
$('#$sId').icon_select({current_idx: $idx, items: $sJSItems, post_upload_to: $sPostUploadTo});
EOF
);
}
else
{
} else {
$sValue = '<span style="display:inline-block;line-height:48px;height:48px;"><span><img style="vertical-align:middle" src="'.$this->aAllowedValues[$idx]['icon'].'" />&nbsp;'.htmlentities($this->aAllowedValues[$idx]['label'], ENT_QUOTES, 'UTF-8').'</span></span>';
}
$sReadOnly = $this->IsReadOnly() ? 'disabled' : '';
@@ -1459,18 +1536,21 @@ class RunTimeIconSelectionField extends DesignerIconSelectionField
public function __construct($sCode, $sLabel = '', $defaultValue = '')
{
parent::__construct($sCode, $sLabel, $defaultValue);
$aFolderList = [
APPROOT.'env-'.utils::GetCurrentEnvironment() => utils::GetAbsoluteUrlModulesRoot(),
APPROOT.'images/icons' => utils::GetAbsoluteUrlAppRoot().'images/icons',
];
if (count(self::$aAllIcons) == 0) {
foreach ($aFolderList as $sFolderPath => $sUrlPrefix) {
$aIcons = self::FindIconsOnDisk($sFolderPath);
ksort($aIcons);
if (count(self::$aAllIcons) == 0)
{
self::$aAllIcons = self::FindIconsOnDisk(APPROOT.'env-'.utils::GetCurrentEnvironment());
ksort(self::$aAllIcons);
foreach ($aIcons as $sFilePath) {
self::$aAllIcons[] = array('value' => $sFilePath, 'label' => basename($sFilePath), 'icon' => $sUrlPrefix.$sFilePath);
}
}
}
$aValues = array();
foreach(self::$aAllIcons as $sFilePath)
{
$aValues[] = array('value' => $sFilePath, 'label' => basename($sFilePath), 'icon' => utils::GetAbsoluteUrlModulesRoot().$sFilePath);
}
$this->SetAllowedValues($aValues);
$this->SetAllowedValues(self::$aAllIcons);
}
static protected function FindIconsOnDisk($sBaseDir, $sDir = '')
@@ -1501,26 +1581,29 @@ class RunTimeIconSelectionField extends DesignerIconSelectionField
SetupUtils::builddir(dirname($sCacheFile));
file_put_contents($sCacheFile, $sAvailableIcons, LOCK_EX);
}
return $aFiles;
}
static protected function _FindIconsOnDisk($sBaseDir, $sDir = '')
static protected function _FindIconsOnDisk($sBaseDir, $sDir = '', &$aFilesSpecs = [])
{
$aResult = array();
$aResult = [];
// Populate automatically the list of icon files
if ($hDir = @opendir($sBaseDir.'/'.$sDir))
{
while (($sFile = readdir($hDir)) !== false)
{
if ($hDir = @opendir($sBaseDir.'/'.$sDir)) {
while (($sFile = readdir($hDir)) !== false) {
$aMatches = array();
if (($sFile != '.') && ($sFile != '..') && ($sFile != 'lifecycle') && is_dir($sBaseDir.'/'.$sDir.'/'.$sFile))
{
if (($sFile != '.') && ($sFile != '..') && ($sFile != 'lifecycle') && is_dir($sBaseDir.'/'.$sDir.'/'.$sFile)) {
$sDirSubPath = ($sDir == '') ? $sFile : $sDir.'/'.$sFile;
$aResult = array_merge($aResult, self::_FindIconsOnDisk($sBaseDir, $sDirSubPath));
$aResult = array_merge($aResult, self::_FindIconsOnDisk($sBaseDir, $sDirSubPath, $aFilesSpecs));
}
if (preg_match("/\.(png|jpg|jpeg|gif)$/i", $sFile, $aMatches)) // png, jp(e)g and gif are considered valid
$sSize = filesize($sBaseDir.'/'.$sDir.'/'.$sFile);
if (isset($aFilesSpecs[$sFile]) && $aFilesSpecs[$sFile] == $sSize) {
continue;
}
if (preg_match("/\.(png|jpg|jpeg|gif|svg)$/i", $sFile, $aMatches)) // png, jp(e)g, gif and svg are considered valid
{
$aResult[$sFile.'_'.$sDir] = $sDir.'/'.$sFile;
$aFilesSpecs[$sFile] = $sSize;
}
}
closedir($hDir);
@@ -1566,6 +1649,14 @@ class DesignerSortableField extends DesignerFormField
parent::__construct($sCode, $sLabel, $defaultValue);
$this->aAllowedValues = array();
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return null;
}
public function SetAllowedValues($aAllowedValues)
{
@@ -1602,7 +1693,17 @@ class DesignerFormSelectorField extends DesignerFormField
$this->defaultRealValue = $defaultValue;
$this->aSubForms = array();
$this->bSorted = true;
$this->aCSSClasses[] = 'ibo-input-select';
if (ContextTag::Check(ContextTag::TAG_CONSOLE)) {
$this->aCSSClasses[] = 'ibo-input-select';
}
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return null;
}
public function IsSorted()
@@ -1645,27 +1746,23 @@ class DesignerFormSelectorField extends DesignerFormField
{
$sId = $this->oForm->GetFieldId($this->sCode);
$sName = $this->oForm->GetFieldName($this->sCode);
$sReadOnly = $this->IsReadOnly() ? 'disabled="disabled"' : '';
$sReadOnly = $this->IsReadOnly() ? 'disabled="disabled"' : '';
$this->aCSSClasses[] = 'formSelector';
$sCSSClasses = '';
if (count($this->aCSSClasses) > 0)
{
if (count($this->aCSSClasses) > 0) {
$sCSSClasses = 'class="'.implode(' ', $this->aCSSClasses).'"';
}
if ($this->IsSorted())
{
if ($this->IsSorted()) {
uasort($this->aSubForms, array(get_class($this), 'SortOnFormLabel'));
}
if ($this->IsReadOnly())
{
if ($this->IsReadOnly()) {
$sDisplayValue = '';
$sHiddenValue = '';
foreach($this->aSubForms as $iKey => $aFormData)
{
foreach ($this->aSubForms as $iKey => $aFormData) {
if ($iKey == $this->defaultValue) // Default value is actually the index
{
$sDisplayValue = htmlentities($aFormData['label'], ENT_QUOTES, 'UTF-8');
@@ -1674,35 +1771,29 @@ class DesignerFormSelectorField extends DesignerFormField
}
}
$sHtml = "<span $sCSSClasses>".$sDisplayValue.$sHiddenValue."</span>";
}
else
{
$sHtml = "<select $sCSSClasses id=\"$sId\" name=\"$sName\" $sReadOnly>";
foreach($this->aSubForms as $iKey => $aFormData)
{
} else {
$sHtml = "<span class=\"ibo-input-select-wrapper\"><select $sCSSClasses id=\"$sId\" name=\"$sName\" $sReadOnly>";
foreach ($this->aSubForms as $iKey => $aFormData) {
$sDisplayValue = htmlentities($aFormData['label'], ENT_QUOTES, 'UTF-8');
$sValue = htmlentities($aFormData['value'], ENT_QUOTES, 'UTF-8');
$sSelected = ($iKey == $this->defaultValue) ? 'selected' : '';
$sHtml .= "<option data-value=\"$sValue\" value=\"$iKey\" $sSelected>".$sDisplayValue."</option>";
}
$sHtml .= "</select>";
$sHtml .= "</select></span>";
}
if ($sRenderMode == 'property')
{
$sHtml .= '</td><td class="prop_icon prop_apply"><span title="Apply" class="ui-icon ui-icon-circle-check"/></td><td class="prop_icon prop_cancel"><span title="Revert" class="ui-icon ui-icon-circle-close"/></td></tr>';
if ($sRenderMode == 'property') {
$sHtml .= '</td><td class="prop_icon prop_apply ibo-prop--apply"><span><button class="ibo-button ibo-is-alternative ibo-is-success" data-tooltip-content="'.Dict::Format('UI:DashboardEdit:Apply').'"><i class="fas fa-check"></i></button></span></td><td class="prop_icon prop_cancel ibo-prop--cancel"><span><button class="ibo-button ibo-is-alternative ibo-is-neutral" data-tooltip-content="'.Dict::Format('UI:DashboardEdit:Revert').'"><i class="fas fa-times"></i></button></span></td></tr>';
}
foreach($this->aSubForms as $sKey => $aFormData)
{
foreach ($this->aSubForms as $sKey => $aFormData) {
$sId = $this->oForm->GetFieldId($this->sCode);
$sStyle = (($sKey == $this->defaultValue) && $this->oForm->IsDisplayed()) ? '' : 'style="display:none"';
$oSubForm = $aFormData['form'];
$oSubForm->SetParentForm($this->oForm);
$oSubForm->CopySubmitParams($this->oForm);
$oSubForm->SetPrefix($this->oForm->GetPrefix().$sKey.'_');
if ($sRenderMode == 'property')
{
if ($sRenderMode == 'property') {
// Note: Managing the visibility of nested subforms had several implications
// 1) Attributes are displayed in a table and we have to group them in as many tbodys as necessary to hide/show the various options depending on the current selection
// 2) It is not possible to nest tbody tags. Therefore, it is not possible to manage the visibility the same way as it is done for the dialog mode (using nested divs).
@@ -1800,6 +1891,14 @@ class DesignerSubFormField extends DesignerFormField
parent::__construct('', $sLabel, '');
$this->oSubForm = $oSubForm;
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return null;
}
public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
{
@@ -1844,6 +1943,14 @@ class DesignerStaticTextField extends DesignerFormField
parent::__construct($sCode, $sLabel, $defaultValue);
}
/**
* @inheritDoc
*/
public function GetInputType(): ?string
{
return null;
}
public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
{
return array('label' => $this->sLabel, 'value' => $this->defaultValue);

View File

@@ -1,7 +1,9 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/iTopWebPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/iTopWebPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/iTopWebPage.php, now loadable using autoloader');

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/iTopWizardWebPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/iTopWizardWebPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/iTopWizardWebPage.php, now loadable using autoloader');

View File

@@ -1,4 +1,7 @@
<?php
use Combodo\iTop\Application\Helper\Session;
/**
* Class LoginBasic
*
@@ -20,19 +23,19 @@ class LoginBasic extends AbstractLoginFSMExtension
protected function OnModeDetection(&$iErrorCode)
{
if (!isset($_SESSION['login_mode']))
if (!Session::IsSet('login_mode'))
{
if (isset($_SERVER['HTTP_AUTHORIZATION']) && !empty($_SERVER['HTTP_AUTHORIZATION']))
{
$_SESSION['login_mode'] = 'basic';
Session::Set('login_mode', 'basic');
}
elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']))
{
$_SESSION['login_mode'] = 'basic';
Session::Set('login_mode', 'basic');
}
elseif (isset($_SERVER['PHP_AUTH_USER']))
{
$_SESSION['login_mode'] = 'basic';
Session::Set('login_mode', 'basic');
}
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
@@ -40,10 +43,10 @@ class LoginBasic extends AbstractLoginFSMExtension
protected function OnReadCredentials(&$iErrorCode)
{
if (!isset($_SESSION['login_mode']) || $_SESSION['login_mode'] == 'basic')
if (!Session::IsSet('login_mode') || Session::Get('login_mode') == 'basic')
{
list($sAuthUser, $sAuthPwd) = $this->GetAuthUserAndPassword();
$_SESSION['login_temp_auth_user'] = $sAuthUser;
list($sAuthUser) = $this->GetAuthUserAndPassword();
Session::Set('login_temp_auth_user', $sAuthUser);
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
@@ -51,10 +54,10 @@ class LoginBasic extends AbstractLoginFSMExtension
protected function OnCheckCredentials(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'basic')
if (Session::Get('login_mode') == 'basic')
{
list($sAuthUser, $sAuthPwd) = $this->GetAuthUserAndPassword();
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $_SESSION['login_mode'], 'internal'))
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, Session::Get('login_mode'), 'internal'))
{
$iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS;
return LoginWebPage::LOGIN_FSM_ERROR;
@@ -65,17 +68,17 @@ class LoginBasic extends AbstractLoginFSMExtension
protected function OnCredentialsOK(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'basic')
if (Session::Get('login_mode') == 'basic')
{
list($sAuthUser) = $this->GetAuthUserAndPassword();
LoginWebPage::OnLoginSuccess($sAuthUser, 'internal', $_SESSION['login_mode']);
LoginWebPage::OnLoginSuccess($sAuthUser, 'internal', Session::Get('login_mode'));
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
protected function OnError(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'basic')
if (Session::Get('login_mode') == 'basic')
{
LoginWebPage::HTTP401Error();
}
@@ -84,9 +87,9 @@ class LoginBasic extends AbstractLoginFSMExtension
protected function OnConnected(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'basic')
if (Session::Get('login_mode') == 'basic')
{
$_SESSION['can_logoff'] = true;
Session::Set('can_logoff', true);
return LoginWebPage::CheckLoggedUser($iErrorCode);
}
return LoginWebPage::LOGIN_FSM_CONTINUE;

View File

@@ -4,6 +4,8 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\Helper\Session;
/**
* Class LoginDefaultBefore
*/
@@ -23,7 +25,7 @@ class LoginDefaultBefore extends AbstractLoginFSMExtension
{
$iErrorCode = LoginWebPage::EXIT_CODE_OK;
unset($_SESSION['login_temp_auth_user']);
Session::Unset('login_temp_auth_user');
// Check if proposed login mode is present and allowed
$aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
@@ -32,11 +34,11 @@ class LoginDefaultBefore extends AbstractLoginFSMExtension
if ($index !== false)
{
// Force login mode
$_SESSION['login_mode'] = $sProposedLoginMode;
Session::Set('login_mode', $sProposedLoginMode);
}
else
{
unset($_SESSION['login_mode']);
Session::Unset('login_mode');
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
@@ -91,7 +93,7 @@ class LoginDefaultAfter extends AbstractLoginFSMExtension implements iLogoutExte
protected function OnCredentialsOk(&$iErrorCode)
{
if (!isset($_SESSION['login_mode']))
if (!Session::IsSet('login_mode'))
{
// If no plugin validated the user, exit
self::ResetLoginSession();
@@ -110,7 +112,7 @@ class LoginDefaultAfter extends AbstractLoginFSMExtension implements iLogoutExte
protected function OnConnected(&$iErrorCode)
{
unset($_SESSION['login_temp_auth_user']);
Session::Unset('login_temp_auth_user');
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
@@ -118,11 +120,11 @@ class LoginDefaultAfter extends AbstractLoginFSMExtension implements iLogoutExte
private static function ResetLoginSession()
{
LoginWebPage::ResetSession();
foreach (array_keys($_SESSION) as $sKey)
foreach (Session::ListVariables() as $sKey)
{
if (utils::StartsWith($sKey, 'login_'))
{
unset($_SESSION[$sKey]);
Session::Unset($sKey);
}
}
}

View File

@@ -1,5 +1,7 @@
<?php
use Combodo\iTop\Application\Helper\Session;
/**
* Class LoginExternal
*
@@ -22,12 +24,12 @@ class LoginExternal extends AbstractLoginFSMExtension
protected function OnModeDetection(&$iErrorCode)
{
if (!isset($_SESSION['login_mode']))
if (!Session::IsSet('login_mode'))
{
$sAuthUser = $this->GetAuthUser();
if ($sAuthUser && (strlen($sAuthUser) > 0))
{
$_SESSION['login_mode'] = 'external';
Session::Set('login_mode', 'external');
}
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
@@ -35,10 +37,10 @@ class LoginExternal extends AbstractLoginFSMExtension
protected function OnCheckCredentials(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'external')
if (Session::Get('login_mode') == 'external')
{
$sAuthUser = $this->GetAuthUser();
if (!UserRights::CheckCredentials($sAuthUser, '', $_SESSION['login_mode'], 'external'))
if (!UserRights::CheckCredentials($sAuthUser, '', Session::Get('login_mode'), 'external'))
{
$iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS;
return LoginWebPage::LOGIN_FSM_ERROR;
@@ -49,19 +51,19 @@ class LoginExternal extends AbstractLoginFSMExtension
protected function OnCredentialsOK(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'external')
if (Session::Get('login_mode') == 'external')
{
$sAuthUser = $this->GetAuthUser();
LoginWebPage::OnLoginSuccess($sAuthUser, 'external', $_SESSION['login_mode']);
LoginWebPage::OnLoginSuccess($sAuthUser, 'external', Session::Get('login_mode'));
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
protected function OnConnected(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'external')
if (Session::Get('login_mode') == 'external')
{
$_SESSION['can_logoff'] = false;
Session::Set('can_logoff', false);
return LoginWebPage::CheckLoggedUser($iErrorCode);
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
@@ -69,7 +71,7 @@ class LoginExternal extends AbstractLoginFSMExtension
protected function OnError(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'external')
if (Session::Get('login_mode') == 'external')
{
LoginWebPage::HTTP401Error();
}

View File

@@ -5,6 +5,8 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\Helper\Session;
/**
* Class LoginForm
*
@@ -29,8 +31,7 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
*/
protected function OnReadCredentials(&$iErrorCode)
{
if (!isset($_SESSION['login_mode']) || ($_SESSION['login_mode'] == 'form'))
{
if (!Session::IsSet('login_mode') || Session::Get('login_mode') == 'form') {
$sAuthUser = utils::ReadPostedParam('auth_user', '', 'raw_data');
$sAuthPwd = utils::ReadPostedParam('auth_pwd', null, 'raw_data');
if ($this->bForceFormOnError || empty($sAuthUser) || empty($sAuthPwd))
@@ -50,9 +51,8 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
$this->bForceFormOnError = false;
exit;
}
$_SESSION['login_temp_auth_user'] = $sAuthUser;
$_SESSION['login_mode'] = 'form';
Session::Set('login_temp_auth_user', $sAuthUser);
Session::Set('login_mode', 'form');
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
@@ -62,11 +62,11 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
*/
protected function OnCheckCredentials(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'form')
if (Session::Get('login_mode') == 'form')
{
$sAuthUser = utils::ReadPostedParam('auth_user', '', 'raw_data');
$sAuthPwd = utils::ReadPostedParam('auth_pwd', null, 'raw_data');
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $_SESSION['login_mode'], 'internal'))
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, Session::Get('login_mode'), 'internal'))
{
$iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS;
return LoginWebPage::LOGIN_FSM_ERROR;
@@ -80,19 +80,19 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
*/
protected function OnCredentialsOK(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'form')
if (Session::Get('login_mode') == 'form')
{
if (isset($_SESSION['auth_user']))
if (Session::IsSet('auth_user'))
{
// If FSM reenter this state (example 2FA) then the auth_user is not resubmitted
$sAuthUser = $_SESSION['auth_user'];
$sAuthUser = Session::Get('auth_user');
}
else
{
$sAuthUser = utils::ReadPostedParam('auth_user', '', 'raw_data');
}
// Store 'auth_user' in session for further use
LoginWebPage::OnLoginSuccess($sAuthUser, 'internal', $_SESSION['login_mode']);
LoginWebPage::OnLoginSuccess($sAuthUser, 'internal', Session::Get('login_mode'));
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
@@ -102,7 +102,7 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
*/
protected function OnError(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'form')
if (Session::Get('login_mode') == 'form')
{
$this->bForceFormOnError = true;
}
@@ -114,9 +114,9 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
*/
protected function OnConnected(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'form')
if (Session::Get('login_mode') == 'form')
{
$_SESSION['can_logoff'] = true;
Session::Set('can_logoff', true);
return LoginWebPage::CheckLoggedUser($iErrorCode);
}
return LoginWebPage::LOGIN_FSM_CONTINUE;

View File

@@ -7,6 +7,7 @@
*/
use Combodo\iTop\Application\Branding;
use Combodo\iTop\TwigExtension;
/**
@@ -238,16 +239,9 @@ class LoginTwigRenderer
public function GetDefaultVars()
{
$sLogo = 'itop-logo-external.png';
$sBrandingLogo = 'login-logo.png';
$sVersionShort = Dict::Format('UI:iTopVersion:Short', ITOP_APPLICATION, ITOP_VERSION);
$sIconUrl = Utils::GetConfig()->Get('app_icon_url');
$sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/'.$sLogo.'?t='.utils::GetCacheBusterTimestamp();
if (file_exists(MODULESROOT.'branding/'.$sBrandingLogo))
{
$sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/'.$sBrandingLogo.'?t='.utils::GetCacheBusterTimestamp();
}
$sDisplayIcon = Branding::GetLoginLogoAbsoluteUrl();
$aVars = array(
'sAppRootUrl' => utils::GetAbsoluteUrlAppRoot(),

View File

@@ -1,5 +1,7 @@
<?php
use Combodo\iTop\Application\Helper\Session;
/**
* Class LoginURL
*
@@ -26,13 +28,13 @@ class LoginURL extends AbstractLoginFSMExtension
protected function OnModeDetection(&$iErrorCode)
{
if (!isset($_SESSION['login_mode']) && !$this->bErrorOccurred)
if (!Session::IsSet('login_mode') && !$this->bErrorOccurred)
{
$sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
$sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data');
if (!empty($sAuthUser) && !empty($sAuthPwd))
{
$_SESSION['login_mode'] = 'url';
Session::Set('login_mode', 'url');
}
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
@@ -40,20 +42,20 @@ class LoginURL extends AbstractLoginFSMExtension
protected function OnReadCredentials(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'url')
if (Session::Get('login_mode') == 'url')
{
$_SESSION['login_temp_auth_user'] = utils::ReadParam('auth_user', '', false, 'raw_data');
Session::Set('login_temp_auth_user', utils::ReadParam('auth_user', '', false, 'raw_data'));
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
protected function OnCheckCredentials(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'url')
if (Session::Get('login_mode') == 'url')
{
$sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
$sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data');
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $_SESSION['login_mode'], 'internal'))
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, Session::Get('login_mode'), 'internal'))
{
$iErrorCode = LoginWebPage::EXIT_CODE_WRONGCREDENTIALS;
return LoginWebPage::LOGIN_FSM_ERROR;
@@ -64,17 +66,17 @@ class LoginURL extends AbstractLoginFSMExtension
protected function OnCredentialsOK(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'url')
if (Session::Get('login_mode') == 'url')
{
$sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
LoginWebPage::OnLoginSuccess($sAuthUser, 'internal', $_SESSION['login_mode']);
LoginWebPage::OnLoginSuccess($sAuthUser, 'internal', Session::Get('login_mode'));
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}
protected function OnError(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'url')
if (Session::Get('login_mode') == 'url')
{
$this->bErrorOccurred = true;
}
@@ -83,9 +85,9 @@ class LoginURL extends AbstractLoginFSMExtension
protected function OnConnected(&$iErrorCode)
{
if ($_SESSION['login_mode'] == 'url')
if (Session::Get('login_mode') == 'url')
{
$_SESSION['can_logoff'] = true;
Session::Set('can_logoff', true);
return LoginWebPage::CheckLoggedUser($iErrorCode);
}
return LoginWebPage::LOGIN_FSM_CONTINUE;

View File

@@ -24,6 +24,9 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\Branding;
use Combodo\iTop\Application\Helper\Session;
/**
* Web page used for displaying the login form
*/
@@ -139,16 +142,9 @@ class LoginWebPage extends NiceWebPage
public function DisplayLoginHeader($bMainAppLogo = false)
{
$sLogo = 'itop-logo-external.png';
$sBrandingLogo = 'login-logo.png';
$sVersionShort = Dict::Format('UI:iTopVersion:Short', ITOP_APPLICATION, ITOP_VERSION);
$sIconUrl = Utils::GetConfig()->Get('app_icon_url');
$sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/'.$sLogo.'?t='.utils::GetCacheBusterTimestamp();
if (file_exists(MODULESROOT.'branding/'.$sBrandingLogo))
{
$sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/'.$sBrandingLogo.'?t='.utils::GetCacheBusterTimestamp();
}
$sDisplayIcon = Branding::GetLoginLogoAbsoluteUrl();
$this->add("<div id=\"login-logo\"><a href=\"".htmlentities($sIconUrl, ENT_QUOTES,
self::PAGES_CHARSET)."\"><img title=\"$sVersionShort\" src=\"$sDisplayIcon\"></a></div>\n");
}
@@ -392,11 +388,11 @@ class LoginWebPage extends NiceWebPage
public static function ResetSession()
{
// Unset all of the session variables.
unset($_SESSION['auth_user']);
unset($_SESSION['login_state']);
unset($_SESSION['can_logoff']);
unset($_SESSION['archive_mode']);
unset($_SESSION['impersonate_user']);
Session::Unset('auth_user');
Session::Unset('login_state');
Session::Unset('can_logoff');
Session::Unset('archive_mode');
Session::Unset('impersonate_user');
UserRights::_ResetSessionCache();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
@@ -442,11 +438,11 @@ class LoginWebPage extends NiceWebPage
}
$bLoginDebug = MetaModel::GetConfig()->Get('login_debug');
if (!isset($_SESSION['login_state']) || ($_SESSION['login_state'] == self::LOGIN_STATE_ERROR))
if (Session::Get('login_state') == self::LOGIN_STATE_ERROR)
{
$_SESSION['login_state'] = self::LOGIN_STATE_START;
Session::Set('login_state', self::LOGIN_STATE_START);
}
$sLoginState = $_SESSION['login_state'];
$sLoginState = Session::Get('login_state');
$sSessionLog = '';
if ($bLoginDebug)
@@ -500,7 +496,7 @@ class LoginWebPage extends NiceWebPage
// Every plugin has nothing else to do in this state, go forward
$sLoginState = self::AdvanceLoginFSMState($sLoginState);
$_SESSION['login_state'] = $sLoginState;
Session::Set('login_state', $sLoginState);
}
catch (Exception $e)
{
@@ -526,7 +522,7 @@ class LoginWebPage extends NiceWebPage
if ($bFilterWithMode)
{
$sCurrentLoginMode = isset($_SESSION['login_mode']) ? $_SESSION['login_mode'] : '';
$sCurrentLoginMode = Session::Get('login_mode', '');
}
else
{
@@ -665,8 +661,8 @@ class LoginWebPage extends NiceWebPage
$oLog->DBInsertNoReload();
}
$_SESSION['auth_user'] = $sAuthUser;
$_SESSION['login_mode'] = $sLoginMode;
Session::Set('auth_user', $sAuthUser);
Session::Set('login_mode', $sLoginMode);
UserRights::_InitSessionCache();
}
@@ -681,10 +677,10 @@ class LoginWebPage extends NiceWebPage
*/
public static function CheckLoggedUser(&$iErrorCode)
{
if (isset($_SESSION['auth_user']))
if (Session::IsSet('auth_user'))
{
// Already authenticated
$bRet = UserRights::Login($_SESSION['auth_user']); // Login & set the user's language
$bRet = UserRights::Login(Session::Get('auth_user')); // Login & set the user's language
if ($bRet)
{
$iErrorCode = self::EXIT_CODE_OK;
@@ -712,11 +708,11 @@ class LoginWebPage extends NiceWebPage
public static function SetLoginModeAndReload($sNewLoginMode)
{
if (isset($_SESSION['login_mode']) && ($_SESSION['login_mode'] == $sNewLoginMode))
if (Session::Get('login_mode') == $sNewLoginMode)
{
return;
}
$_SESSION['login_mode'] = $sNewLoginMode;
Session::Set('login_mode', $sNewLoginMode);
self::HTTPReload();
}
@@ -829,9 +825,9 @@ class LoginWebPage extends NiceWebPage
{
CMDBObject::SetTrackOrigin('custom-extension');
$sInfo = 'External User provisioning';
if (isset($_SESSION['login_mode']))
if (Session::IsSet('login_mode'))
{
$sInfo .= " ({$_SESSION['login_mode']})";
$sInfo .= " (".Session::Get('login_mode').")";
}
CMDBObject::SetTrackInfo($sInfo);
@@ -883,9 +879,9 @@ class LoginWebPage extends NiceWebPage
{
CMDBObject::SetTrackOrigin('custom-extension');
$sInfo = 'External User provisioning';
if (isset($_SESSION['login_mode']))
if (Session::IsSet('login_mode'))
{
$sInfo .= " ({$_SESSION['login_mode']})";
$sInfo .= " (".Session::Get('login_mode').")";
}
CMDBObject::SetTrackInfo($sInfo);
@@ -924,9 +920,9 @@ class LoginWebPage extends NiceWebPage
// Now synchronize the profiles
$sOrigin = 'External User provisioning';
if (isset($_SESSION['login_mode']))
if (Session::IsSet('login_mode'))
{
$sOrigin .= " ({$_SESSION['login_mode']})";
$sOrigin .= " (".Session::Get('login_mode').")";
}
$aExistingProfiles = self::SynchronizeProfiles($oUser, $aProfiles, $sOrigin);
if ($oUser->IsModified())
@@ -1011,7 +1007,6 @@ class LoginWebPage extends NiceWebPage
$sMessage = self::HandleOperations($operation); // May exit directly
$iRet = self::Login($iOnExit);
if ($iRet == self::EXIT_CODE_OK)
{
if ($bMustBeAdmin && !UserRights::IsAdministrator())
@@ -1091,19 +1086,23 @@ class LoginWebPage extends NiceWebPage
}
else if ($operation == 'change_pwd')
{
if (isset($_SESSION['auth_user']))
if (Session::IsSet('auth_user'))
{
$sAuthUser = $_SESSION['auth_user'];
$sAuthUser = Session::Get('auth_user');
$sIssue = Session::Get('pwd_issue');
Session::Unset('pwd_issue');
$bFailedLogin = ($sIssue != null); // Force the "failed login" flag to display the "issue" message
UserRights::Login($sAuthUser); // Set the user's language
$oPage = self::NewLoginWebPage();
$oPage->DisplayChangePwdForm();
$oPage->DisplayChangePwdForm($bFailedLogin, $sIssue);
$oPage->output();
exit;
}
}
else if ($operation == 'check_pwd_policy')
{
$sAuthUser = $_SESSION['auth_user'];
$sAuthUser = Session::Get('auth_user');
UserRights::Login($sAuthUser); // Set the user's language
$aPwdMap = array();
@@ -1121,9 +1120,9 @@ class LoginWebPage extends NiceWebPage
}
if ($operation == 'do_change_pwd')
{
if (isset($_SESSION['auth_user']))
if (Session::IsSet('auth_user'))
{
$sAuthUser = $_SESSION['auth_user'];
$sAuthUser = Session::Get('auth_user');
UserRights::Login($sAuthUser); // Set the user's language
$sOldPwd = utils::ReadPostedParam('old_pwd', '', 'raw_data');
$sNewPwd = utils::ReadPostedParam('new_pwd', '', 'raw_data');

View File

@@ -1,22 +1,10 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\Helper\WebResourcesHelper;
use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory;
require_once(APPROOT.'/application/utils.inc.php');
@@ -71,6 +59,10 @@ class ApplicationMenu
* @var array
*/
static $aMenusIndex = array();
/**
* @var array
*/
static $aMenusById = [];
/**
* @var string
*/
@@ -179,6 +171,7 @@ class ApplicationMenu
$aBacktrace = debug_backtrace();
$sFile = isset($aBacktrace[2]["file"]) ? $aBacktrace[2]["file"] : $aBacktrace[1]["file"];
self::$aMenusIndex[$index] = array('node' => $oMenuNode, 'children' => array(), 'parent' => $sParentId, 'rank' => $fRank, 'source_file' => $sFile);
self::$aMenusById[$oMenuNode->GetMenuId()] = $index;
}
else
{
@@ -342,15 +335,17 @@ class ApplicationMenu
*/
public static function DisplayMenu($oPage, $aExtraParams)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use static::GetMenuGroups() instead');
self::LoadAdditionalMenus();
// Sort the root menu based on the rank
usort(self::$aRootMenus, array('ApplicationMenu', 'CompareOnRank'));
$iAccordion = 0;
$iActiveAccordion = $iAccordion;
$iActiveMenu = self::GetMenuIndexById(self::GetActiveNodeId());
foreach(self::$aRootMenus as $aMenu)
{
if (!self::CanDisplayMenu($aMenu)) { continue; }
foreach (self::$aRootMenus as $aMenu) {
if (!self::CanDisplayMenu($aMenu)) {
continue;
}
$oMenuNode = self::GetMenuNode($aMenu['index']);
$oPage->AddToMenu('<h3 id="'.utils::GetSafeId('AccordionMenu_'.$oMenuNode->GetMenuID()).'" class="navigation-menu-group" data-menu-id="'.$oMenuNode->GetMenuId().'">'.$oMenuNode->GetTitle().'</h3>');
$oPage->AddToMenu('<div>');
@@ -418,13 +413,12 @@ EOF
*/
protected static function DisplaySubMenu($oPage, $aMenus, $aExtraParams, $iActiveMenu = -1)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use static::GetSubMenuNodes() instead');
// Sort the menu based on the rank
$bActive = false;
usort($aMenus, array('ApplicationMenu', 'CompareOnRank'));
foreach($aMenus as $aMenu)
{
if (!self::CanDisplayMenu($aMenu))
{
foreach ($aMenus as $aMenu) {
if (!self::CanDisplayMenu($aMenu)) {
continue;
}
$index = $aMenu['index'];
@@ -518,17 +512,11 @@ EOF
*/
public static function GetMenuIndexById($sTitle)
{
$index = -1;
/** @var MenuNode[] $aMenu */
foreach(self::$aMenusIndex as $aMenu)
{
if ($aMenu['node']->GetMenuId() == $sTitle)
{
$index = $aMenu['node']->GetIndex();
break;
}
if (isset(self::$aMenusById[$sTitle])) {
return self::$aMenusById[$sTitle];
}
return $index;
return -1;
}
/**
@@ -727,42 +715,9 @@ abstract class MenuNode
{
// Count the entries up to 99
$oSearch = DBSearch::FromOQL($sOQL);
$oSearch->SetShowObsoleteData(utils::ShowObsoleteData());
DBSearchHelper::AddContextFilter($oSearch);
$oAppContext = new ApplicationContext();
$sClass = $oSearch->GetClass();
foreach ($oAppContext->GetNames() as $key) {
// Find the value of the object corresponding to each 'context' parameter
$aCallSpec = [$sClass, 'MapContextParam'];
$sAttCode = '';
if (is_callable($aCallSpec)) {
$sAttCode = call_user_func($aCallSpec, $key); // Returns null when there is no mapping for this parameter
}
if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
// Add Hierarchical condition if hierarchical key
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (isset($oAttDef) && ($oAttDef->IsExternalKey())) {
$iDefaultValue = intval($oAppContext->GetCurrentValue($key));
if ($iDefaultValue != 0) {
try {
/** @var AttributeExternalKey $oAttDef */
$sTargetClass = $oAttDef->GetTargetClass();
$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sTargetClass);
if ($sHierarchicalKeyCode !== false) {
$oFilter = new DBObjectSearch($sTargetClass);
$oFilter->AddCondition('id', $iDefaultValue);
$oHKFilter = new DBObjectSearch($sTargetClass);
$oHKFilter->AddCondition_PointingTo($oFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
$oSearch->AddCondition_PointingTo($oHKFilter, $sAttCode);
}
}
catch (Exception $e) {
// If filtering fails just ignore it
}
}
}
}
}
$oSet = new DBObjectSet($oSearch);
$iCount = $oSet->CountWithLimit(99);
@@ -1171,15 +1126,13 @@ class OQLMenuNode extends MenuNode
{
$sUsageId = utils::GetSafeId($sUsageId);
$oSearch = DBObjectSearch::FromOQL($sOql);
//$sIcon = MetaModel::GetClassIcon($oSearch->GetClass(), false);
if ($bSearchPane) {
$aParams = array_merge(array('open' => $bSearchOpen, 'table_id' => $sUsageId), $aExtraParams);
$aParams = array_merge(['open' => $bSearchOpen, 'table_id' => $sUsageId, 'submit_on_load' => false], $aExtraParams);
$oBlock = new DisplayBlock($oSearch, 'search', false /* Asynchronous */, $aParams);
$oBlock->Display($oPage, 0);
}
//$oPage->add("<p class=\"page-header\">$sIcon ".utils::HtmlEntities(Dict::S($sTitle))."</p>");
$oPage->add("<div class='sf_results_area' data-target='search_results'>");
$oTitle = TitleUIBlockFactory::MakeForPage($sTitle);
$oPage->AddUiBlock($oTitle);
@@ -1255,7 +1208,8 @@ class SearchMenuNode extends MenuNode
$oPage->SetBreadCrumbEntry("menu-".$this->sMenuId, $this->GetTitle(), '', '', 'fas fa-search', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES);
$oSearch = new DBObjectSearch($this->sClass);
$aParams = array_merge(array('table_id' => 'Menu_'.utils::GetSafeId($this->GetMenuId())), $aExtraParams);
$sUsageId = 'Menu_'.utils::GetSafeId($this->GetMenuId());
$aParams = array_merge(array('table_id' =>$sUsageId), $aExtraParams);
$oBlock = new DisplayBlock($oSearch, 'search', false /* Asynchronous */, $aParams);
$oBlock->Display($oPage, 0);
}
@@ -1461,6 +1415,8 @@ class DashboardMenuNode extends MenuNode
$oDashboard = $this->GetDashboard();
if ($oDashboard != null)
{
WebResourcesHelper::EnableC3JSToWebPage($oPage);
$sDivId = utils::Sanitize($this->sMenuId, '', 'element_identifier');
$oPage->add('<div id="'.$sDivId.'" class="ibo-dashboard" data-role="ibo-dashboard">');
$aExtraParams['dashboard_div_id'] = $sDivId;

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/NiceWebPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/NiceWebPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/NiceWebPage.php, now loadable using autoloader');

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/PDFPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/PDFPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/PDFPage.php, now loadable using autoloader');

View File

@@ -17,6 +17,12 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Field\Field;
use Combodo\iTop\Application\UI\Base\Component\Field\FieldUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\Component\Input\TextArea;
abstract class Query extends cmdbAbstractObject
{
/**
@@ -120,36 +126,37 @@ class QueryOQL extends Query
function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
{
$aFieldsMap = parent::DisplayBareProperties($oPage, $bEditMode, $sPrefix, $aExtraParams);
if (!$bEditMode)
{
$oPage->add_script("$('[name=\"attr_oql\"]').addClass('ibo-query-oql ibo-is-code'); $('[data-attribute-code=\"oql\"]').addClass('ibo-query-oql ibo-is-code');");
if (!$bEditMode) {
$sFields = trim($this->Get('fields'));
$bExportV1Recommended = ($sFields == '');
if ($bExportV1Recommended)
{
if ($bExportV1Recommended) {
$oFieldAttDef = MetaModel::GetAttributeDef('QueryOQL', 'fields');
$oPage->add('<div class="message message_error" style="padding-left: 30px;"><div style="padding: 10px;">'.Dict::Format('UI:Query:UrlV1', $oFieldAttDef->GetLabel()).'</div></div>');
$oAlert = AlertUIBlockFactory::MakeForFailure()
->SetIsClosable(false)
->SetIsCollapsible(false);
$oAlert->AddCSSClass('mb-5');
$oAlert->AddSubBlock(new Html(Dict::Format('UI:Query:UrlV1', '')));
$oPage->AddSubBlock($oAlert);
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export.php?format=spreadsheet&login_mode=basic&query='.$this->GetKey();
}
else
{
} else {
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export-v2.php?format=spreadsheet&login_mode=basic&date_format='.urlencode((string)AttributeDateTime::GetFormat()).'&query='.$this->GetKey();
}
$sOql = $this->Get('oql');
$sMessage = null;
try
{
try {
$oSearch = DBObjectSearch::FromOQL($sOql);
$aParameters = $oSearch->GetQueryParams();
foreach($aParameters as $sParam => $val)
{
foreach ($aParameters as $sParam => $val) {
$sUrl .= '&arg_'.$sParam.'=["'.$sParam.'"]';
}
$oPage->p(Dict::S('UI:Query:UrlForExcel').':<br/><textarea cols="80" rows="3" READONLY>'.$sUrl.'</textarea>');
$oTextArea = new TextArea("", $sUrl, null, 80, 3);
$oFieldUrl = FieldUIBlockFactory::MakeFromObject(Dict::S('UI:Query:UrlForExcel'), $oTextArea, Field::ENUM_FIELD_LAYOUT_LARGE);
$oPage->AddSubBlock($oFieldUrl);
if (count($aParameters) == 0)
{
if (count($aParameters) == 0) {
$oBlock = new DisplayBlock($oSearch, 'list');
$aExtraParams = array(
//'menu' => $sShowMenu,
@@ -159,10 +166,13 @@ class QueryOQL extends Query
$oBlock->Display($oPage, $sBlockId, $aExtraParams);
}
}
catch (OQLException $e)
{
$sMessage = '<div class="message message_error" style="padding-left: 30px;"><div style="padding: 10px;">'.Dict::Format('UI:RunQuery:Error', $e->getHtmlDesc()).'</div></div>';
$oPage->p($sMessage);
catch
(OQLException $e) {
$oAlert = AlertUIBlockFactory::MakeForFailure(Dict::Format('UI:RunQuery:Error'), $e->getHtmlDesc())
->SetIsClosable(false)
->SetIsCollapsible(false);
$oAlert->AddCSSClass('mb-5');
$oPage->AddSubBlock($oAlert);
}
}
return $aFieldsMap;

View File

@@ -15,9 +15,12 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\Helper\Session;
require_once(APPROOT.'/core/cmdbobject.class.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/core/contexttag.class.inc.php');
require_once(APPROOT.'/core/kpi.class.inc.php');
/**
@@ -27,6 +30,9 @@ require_once(APPROOT.'/core/contexttag.class.inc.php');
* @license http://opensource.org/licenses/AGPL-3.0
*/
ExecutionKPI::EnableDuration(1);
ExecutionKPI::EnableMemory(1);
// This storage is freed on error (case of allowed memory exhausted)
$sReservedMemory = str_repeat('*', 1024 * 1024);
register_shutdown_function(function()
@@ -35,41 +41,39 @@ register_shutdown_function(function()
$sReservedMemory = null;
if (!is_null($err = error_get_last()) && ($err['type'] == E_ERROR))
{
// Remove stack trace from MySQLException
// Remove stack trace from MySQLException (since 2.7.2 see N°3174)
$sMessage = $err['message'];
if (strpos($sMessage, 'MySQLException') !== false)
{
if (strpos($sMessage, 'MySQLException') !== false) {
$iStackTracePos = strpos($sMessage, 'Stack trace:');
if ($iStackTracePos !== false)
{
if ($iStackTracePos !== false) {
$sMessage = substr($sMessage, 0, $iStackTracePos);
}
}
IssueLog::error($sMessage);
if (strpos($err['message'], 'Allowed memory size of') !== false)
{
// Log additional info but message from $err (since 2.7.6 N°4174)
$aErrToLog = $err;
unset($aErrToLog['message']);
IssueLog::error($sMessage, null, $aErrToLog);
if (strpos($err['message'], 'Allowed memory size of') !== false) {
$sLimit = ini_get('memory_limit');
echo "<p>iTop: Allowed memory size of $sLimit exhausted, contact your administrator to increase 'memory_limit' in php.ini</p>\n";
}
elseif (strpos($err['message'], 'Maximum execution time') !== false)
{
} elseif (strpos($err['message'], 'Maximum execution time') !== false) {
$sLimit = ini_get('max_execution_time');
echo "<p>iTop: Maximum execution time of $sLimit exceeded, contact your administrator to increase 'max_execution_time' in php.ini</p>\n";
}
else
{
} else {
echo "<p>iTop: An error occurred, check server error log for more information.</p>\n";
}
}
});
$oKPI = new ExecutionKPI();
Session::Start();
Session::WriteClose();
$oKPI->ComputeAndReport("Session Start");
session_name('itop-'.md5(APPROOT));
session_start();
$sSwitchEnv = utils::ReadParam('switch_env', null);
$bAllowCache = true;
if (($sSwitchEnv != null) && (file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FILE)) && isset($_SESSION['itop_env']) && ($_SESSION['itop_env'] !== $sSwitchEnv))
if (($sSwitchEnv != null) && file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FILE) &&( Session::Get('itop_env') !== $sSwitchEnv))
{
$_SESSION['itop_env'] = $sSwitchEnv;
Session::Set('itop_env', $sSwitchEnv);
$sEnv = $sSwitchEnv;
$bAllowCache = false;
// Reset the opcache since otherwise the PHP "model" files may still be cached !!
@@ -85,14 +89,14 @@ if (($sSwitchEnv != null) && (file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FI
}
// TODO: reset the credentials as well ??
}
else if (isset($_SESSION['itop_env']))
else if (Session::IsSet('itop_env'))
{
$sEnv = $_SESSION['itop_env'];
$sEnv = Session::Get('itop_env');
}
else
{
$sEnv = ITOP_DEFAULT_ENV;
$_SESSION['itop_env'] = ITOP_DEFAULT_ENV;
Session::Set('itop_env', ITOP_DEFAULT_ENV);
}
$sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE;
MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv);

View File

@@ -31,14 +31,15 @@ class DisplayTemplate
public function __construct($sTemplate)
{
$this->m_aTags = array (
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
$this->m_aTags = array(
'itopblock',
'itopcheck',
'itoptabs',
'itoptab',
'itoptoggle',
'itopstring',
'sqlblock'
'sqlblock',
);
$this->m_sTemplate = $sTemplate;
}

View File

@@ -27,6 +27,7 @@ class ThemeHandler
{
const IMAGE_EXTENSIONS = ['png', 'gif', 'jpg', 'jpeg'];
/** @var \CompileCSSService */
private static $oCompileCSSService;
public static function GetAppRootWithSlashes()
@@ -46,11 +47,10 @@ class ThemeHandler
'name' => 'fullmoon',
'parameters' => [
'variables' => [],
'imports' => [
],
'imports' => [],
'stylesheets' => [
'main' => '../css/backoffice/main.scss',
],
]
],
];
}
@@ -58,22 +58,27 @@ class ThemeHandler
/**
* Return the ID of the theme currently defined in the config. file
*
* @deprecated 3.0.0, will be removed in 3.1, see N°3898
* @return string
*/
public static function GetCurrentThemeId()
{
try
{
if (is_null(MetaModel::GetConfig()))
{
throw new CoreException('no config');
}
$sThemeId = MetaModel::GetConfig()->Get('backoffice_default_theme');
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
static::GetCurrentUserThemeId();
}
/**
* @return string ID of the theme currently defined in the config. file, which applies to all users by default. If non defined, fallback on the default one.
* @since 3.0.0
*/
public static function GetApplicationThemeId(): string
{
try {
$sThemeId = utils::GetConfig()->Get('backoffice_default_theme');
}
catch(CoreException $oCompileException)
{
catch (CoreException $oCompileException) {
// Fallback on our default theme in case the config. is not available yet
$aDefaultTheme = ThemeHandler::GetDefaultThemeInformation();
$aDefaultTheme = ThemeHandler::GetDefaultThemeInformation();
$sThemeId = $aDefaultTheme['name'];
}
@@ -81,49 +86,173 @@ class ThemeHandler
}
/**
* Return the absolute path of the compiled theme folder.
*
* @return string ID of the theme to use for the current user as per they preferences. If non defined, fallback on the app. theme ID.
* @since 3.0.0
*/
public static function GetCurrentUserThemeId(): string
{
$sThemeId = null;
try {
if (true === utils::GetConfig()->Get('user_preferences.allow_backoffice_theme_override')) {
$sThemeId = appUserPreferences::GetPref('backoffice_theme', null);
}
}
catch (Exception $oException) {
// Do nothing, already handled by $sThemeId null by default
}
// Fallback on the app. theme
if (is_null($sThemeId)) {
$sThemeId = static::GetApplicationThemeId();
}
return $sThemeId;
}
/**
* @param string $sThemeId
*
* @return string
* @return string Label of the theme which is either a dict entry ('theme:<THEME_ID>') or the ID if no localized dict. entry found.
* @since 3.0.0
*/
public static function GetCompiledThemeFolderAbsolutePath($sThemeId)
public static function GetThemeLabel(string $sThemeId): string
{
return APPROOT.'env-'.utils::GetCurrentEnvironment().'/branding/themes/'.$sThemeId.'/';
$sDictEntryCode = 'theme:'.$sThemeId;
$sDictEntryValue = Dict::S('theme:'.$sThemeId);
return ($sDictEntryCode === $sDictEntryValue) ? $sThemeId : $sDictEntryValue;
}
/**
* @return array Associative array of <THEME_ID> => <THEME_LABEL>, ordered by labels
* @since 3.0.0
*/
public static function GetAvailableThemes(): array
{
$aThemes = [];
foreach (glob(static::GetCompiledThemesFolderAbsolutePath().'/*') as $sPath) {
if (is_dir($sPath)) {
$sThemeId = basename($sPath);
$sThemeLabel = static::GetThemeLabel($sThemeId);
$aThemes[$sThemeId] = $sThemeLabel;
}
}
asort($aThemes);
return $aThemes;
}
/**
* @param string $sThemeId
*
* @return bool True if $sThemeId is a valid theme that can be used.
* @since 3.0.0
*/
public static function IsValidTheme(string $sThemeId): bool
{
return array_key_exists($sThemeId, static::GetAvailableThemes());
}
/**
* @return string Absolute path to the folder containing all the compiled themes
* @since 3.0.0
*/
public static function GetCompiledThemesFolderAbsolutePath(): string
{
return APPROOT.'env-'.utils::GetCurrentEnvironment().'/branding/themes/';
}
/**
* @param string $sThemeId
*
* @return string Absolute path to the folder containing the $sThemeId theme
*/
public static function GetCompiledThemeFolderAbsolutePath(string $sThemeId): string
{
return static::GetCompiledThemesFolderAbsolutePath().$sThemeId.'/';
}
/**
* @param string $sThemeId
*
* @return string Absolute path of the compiled file for the $sThemeId theme (Note: It doesn't mean that the theme is actually compiled)
* @since 3.0.0
*/
public static function GetCompiledThemeFileAbsolutePath(string $sThemeId): string
{
return static::GetCompiledThemeFolderAbsolutePath($sThemeId).'main.css';
}
/**
* @param string $sThemeId
*
* @return string Absolute URL of the compiled file for the $sThemeId theme (Note: It doesn't mean that the theme is actually compiled)
* @throws \Exception
* @since 3.0.0
*/
public static function GetCompiledThemeFileAbsoluteUrl(string $sThemeId): string
{
return utils::GetAbsoluteUrlModulesRoot().'branding/themes/'.$sThemeId.'/main.css';
}
/**
* Return the absolute URL for the current theme CSS file
*
* @return string
* @throws \Exception
*/
public static function GetCurrentThemeUrl()
public static function GetCurrentThemeUrl(): string
{
try
{
try {
// Try to compile theme defined in the configuration
$sThemeId = static::GetCurrentThemeId();
static::CompileTheme($sThemeId);
// Note: In maintenance mode we should stick to the app theme (also we don't have access to many PHP classes, including the user preferences)
$sThemeId = SetupUtils::IsInMaintenanceMode() ? static::GetApplicationThemeId() : static::GetCurrentUserThemeId();
if (static::ShouldThemeSignatureCheckBeForced($sThemeId)) {
static::CompileTheme($sThemeId);
}
}
catch(CoreException $oCompileException)
{
catch (CoreException $oCompileException) {
// Fallback on our default theme (should always be compilable) in case the previous theme doesn't exists
$aDefaultTheme = ThemeHandler::GetDefaultThemeInformation();
$aDefaultTheme = ThemeHandler::GetDefaultThemeInformation();
$sThemeId = $aDefaultTheme['name'];
$sDefaultThemeDirPath = static::GetCompiledThemeFolderAbsolutePath($sThemeId);
// Create our theme dir if it doesn't exist (XML theme node removed, renamed etc..)
if(!is_dir($sDefaultThemeDirPath))
{
if (!is_dir($sDefaultThemeDirPath)) {
SetupUtils::builddir($sDefaultThemeDirPath);
}
static::CompileTheme($sThemeId, false, "", $aDefaultTheme['parameters']);
if (static::ShouldThemeSignatureCheckBeForced($sThemeId)) {
static::CompileTheme($sThemeId, false, "", $aDefaultTheme['parameters']);
}
}
// Return absolute url to theme compiled css
return utils::GetAbsoluteUrlModulesRoot().'branding/themes/'.$sThemeId.'/main.css';
return static::GetCompiledThemeFileAbsoluteUrl($sThemeId);
}
/**
* @param string $sThemeId
*
* @return bool True if the $sThemeId signature check -and possibly the compilation- should be forced (dev. environment, missing compiled file, ...)
*/
protected static function ShouldThemeSignatureCheckBeForced(string $sThemeId): bool
{
if (utils::IsDevelopmentEnvironment()) {
return true;
}
if (false === file_exists(static::GetCompiledThemeFileAbsolutePath($sThemeId))) {
return true;
}
if (true === utils::GetConfig()->Get('theme.force_signature_check_at_runtime')) {
return true;
}
return false;
}
/**
@@ -135,7 +264,7 @@ class ThemeHandler
* @param boolean $bSetup
* @param string $sSetupCompilationTimestamp : setup compilation timestamp in micro secunds
* @param array|null $aThemeParameters Parameters (variables, imports, stylesheets) for the theme, if not passed, will be retrieved from compiled DM
* @param array|null $aImportsPaths Paths where imports can be found. Must end with '/'
* @param array|null $aImportsPaths Folder paths where imports can be found. Must end with '/'
* @param string|null $sWorkingPath Path of the folder used during compilation. Must end with a '/'
*
* @throws \CoreException
@@ -180,15 +309,16 @@ class ThemeHandler
}
}
$aThemeParametersWithVersion = self::CloneThemeParameterAndIncludeVersion($aThemeParameters, $sSetupCompilationTimestampInSecunds);
$aThemeParametersWithVersion = self::CloneThemeParameterAndIncludeVersion($aThemeParameters, $sSetupCompilationTimestampInSecunds, $aImportsPaths);
clearstatcache();
// Loading files to import and stylesheet to compile, also getting most recent modification time on overall files
$sTmpThemeScssContent = '';
$oFindStylesheetObject = new FindStylesheetObject();
if (isset($aThemeParameters['imports_utility'])) {
foreach ($aThemeParameters['imports_utility'] as $sImport) {
if (isset($aThemeParameters['utility_imports'])) {
foreach ($aThemeParameters['utility_imports'] as $sImport) {
static::FindStylesheetFile($sImport, $aImportsPaths, $oFindStylesheetObject);
}
}
@@ -203,6 +333,12 @@ class ThemeHandler
$sTmpThemeScssContent .= '@import "'.$sStylesheet.'";'."\n";
}
if (isset($aThemeParameters['variable_imports'])) {
foreach ($aThemeParameters['variable_imports'] as $sImport) {
static::FindStylesheetFile($sImport, $aImportsPaths, $oFindStylesheetObject);
}
}
$iStyleLastModified = $oFindStylesheetObject->GetLastModified();
$aIncludedImages=static::GetIncludedImages($aThemeParametersWithVersion, $oFindStylesheetObject->GetAllStylesheetPaths(), $sThemeId);
@@ -262,11 +398,12 @@ CSS;
static::$oCompileCSSService = new CompileCSSService();
}
//store it again to change $version with latest compiled time
SetupLog::Info("Compiling theme $sThemeId...");
$sTmpThemeCssContent = static::$oCompileCSSService->CompileCSSFromSASS($sTmpThemeScssContent, $aImportsPaths,
$aThemeParametersWithVersion);
SetupLog::Info("$sThemeId theme compilation done.");
file_put_contents($sThemeFolderPath.'/theme-parameters.json', json_encode($aThemeParameters));
file_put_contents($sThemeCssPath, $sSignatureComment.$sTmpThemeCssContent);
SetupLog::Info("Theme $sThemeId file compiled.");
return true;
}
}
@@ -292,27 +429,29 @@ CSS;
$aSignature = [
'variables' => md5(json_encode($aThemeParameters['variables'])),
'stylesheets' => [],
'imports' => [],
'images' => []
'variable_imports' => [],
'images' => [],
'utility_imports' => []
];
$oFindStylesheetObject = new FindStylesheetObject();
if (isset($aThemeParameters['imports_variable'])) {
foreach ($aThemeParameters['imports_variable'] as $key => $sImport) {
if (isset($aThemeParameters['variable_imports'])) {
foreach ($aThemeParameters['variable_imports'] as $key => $sImport) {
static::FindStylesheetFile($sImport, $aImportsPaths, $oFindStylesheetObject);
$sFile = $oFindStylesheetObject->GetLastStylesheetFile();
if (!empty($sFile)) {
$aSignature['stylesheets'][$key] = md5_file($sFile);
$aSignature['variable_imports'][$key] = md5_file($sFile);
}
}
}
if (isset($aThemeParameters['imports_utility'])) {
foreach ($aThemeParameters['imports_utility'] as $key => $sImport) {
if (isset($aThemeParameters['utility_imports'])) {
foreach ($aThemeParameters['utility_imports'] as $key => $sImport) {
static::FindStylesheetFile($sImport, $aImportsPaths, $oFindStylesheetObject);
$sFile = $oFindStylesheetObject->GetLastStylesheetFile();
if (!empty($sFile)) {
$aSignature['stylesheets'][$key] = md5_file($sFile);
$aSignature['utility_imports'][$key] = md5_file($sFile);
}
}
}
@@ -330,7 +469,7 @@ CSS;
$aFiles = $oFindStylesheetObject->GetImportPaths();
if (count($aFiles) !== 0) {
foreach ($aFiles as $sFileURI => $sFilePath) {
$aSignature['imports_utility'][$sFileURI] = md5_file($sFilePath);
$aSignature['utility_imports'][$sFileURI] = md5_file($sFilePath);
}
}
@@ -767,7 +906,8 @@ CSS;
foreach($aImportsPaths as $sPath)
{
$sFilePath = $sPath.'/'.$sFileURI;
$sAlterableFileURI = $sFileURI;
$sFilePath = $sPath.'/'.$sAlterableFileURI;
$sImportedFile = realpath($sFilePath);
if ($sImportedFile === false){
// Handle shortcut syntax : @import "typo" ;
@@ -775,7 +915,7 @@ CSS;
$sFilePath2 = "$sFilePath.scss";
$sImportedFile = realpath($sFilePath2);
if ($sImportedFile){
self::FindStylesheetFile("$sFileURI.scss", [ $sPath ], $oFindStylesheetObject, $bImports);
self::FindStylesheetFile("$sAlterableFileURI.scss", [ $sPath ], $oFindStylesheetObject, $bImports);
$sImportedFile = false;
}
}
@@ -785,7 +925,7 @@ CSS;
// file matched: _typo.scss
$sShortCut = substr($sFilePath, strrpos($sFilePath, '/') + 1);
$sFilePath = static::ReplaceLastOccurrence($sShortCut, "_$sShortCut.scss", $sFilePath);
$sFileURI = static::ReplaceLastOccurrence($sShortCut, "_$sShortCut.scss", $sFileURI);
$sAlterableFileURI = static::ReplaceLastOccurrence($sShortCut, "_$sShortCut.scss", $sAlterableFileURI);
$sImportedFile = realpath($sFilePath);
}
@@ -793,14 +933,14 @@ CSS;
&& (!$oFindStylesheetObject->AlreadyFetched($sImportedFile)))
{
if ($bImports){
$oFindStylesheetObject->AddImport($sFileURI, $sImportedFile);
$oFindStylesheetObject->AddImport($sAlterableFileURI, $sImportedFile);
}else{
$oFindStylesheetObject->AddStylesheet($sFileURI, $sImportedFile);
$oFindStylesheetObject->AddStylesheet($sAlterableFileURI, $sImportedFile);
}
$oFindStylesheetObject->UpdateLastModified($sImportedFile);
//Regexp matching on all included scss files : @import 'XXX.scss';
$sDirUri = dirname($sFileURI);
$sDirUri = dirname($sAlterableFileURI);
preg_match_all('/@import \s*[\"\']([^\"\']*)\s*[\"\']\s*;/', file_get_contents($sImportedFile), $aMatches);
if ( (is_array($aMatches)) && (count($aMatches)!==0) ){
foreach ($aMatches[1] as $sImportedFile){
@@ -847,10 +987,11 @@ CSS;
* Clone variable array and include $version with bSetupCompilationTimestamp value
* @param $aThemeParameters
* @param $bSetupCompilationTimestamp
* @param $aImportsPaths
*
* @return array
*/
public static function CloneThemeParameterAndIncludeVersion($aThemeParameters, $bSetupCompilationTimestamp)
public static function CloneThemeParameterAndIncludeVersion($aThemeParameters, $bSetupCompilationTimestamp, $aImportsPaths)
{
$aThemeParametersVariable = [];
if (array_key_exists('variables', $aThemeParameters))
@@ -859,12 +1000,13 @@ CSS;
{
$aThemeParametersVariable = array_merge([], $aThemeParameters['variables']);
}
}
if (array_key_exists('imports_variable', $aThemeParameters))
}
if (array_key_exists('variable_imports', $aThemeParameters))
{
if (is_array($aThemeParameters['imports_variable']))
if (is_array($aThemeParameters['variable_imports']))
{
$aThemeParametersVariable = array_merge($aThemeParametersVariable, static::GetVariablesFromFile($aThemeParameters['imports_variable']));
$aThemeParametersVariable = array_merge($aThemeParametersVariable, static::GetVariablesFromFile($aThemeParameters['variable_imports'], $aImportsPaths));
}
}
@@ -874,20 +1016,30 @@ CSS;
/**
* @param $aVariableFiles
* @param $aImportsPaths
*
* @return array
* @since 3.0.0 N°3593
*/
public static function GetVariablesFromFile($aVariableFiles){
public static function GetVariablesFromFile($aVariableFiles, $aImportsPaths){
$aVariablesResults = [];
foreach ($aVariableFiles as $sVariableFile)
{
$sFileContent = file_get_contents(APPROOT.'env-'.utils::GetCurrentEnvironment().'/'.$sVariableFile);
$aVariableMatches = [];
preg_match_all( '/\$(.*?):(.*?);/', $sFileContent,$aVariableMatches);
$aVariableMatches = array_combine( $aVariableMatches[1], array_map( function($sVariableValue) { return ltrim($sVariableValue); }, $aVariableMatches[2] ) );
$aVariablesResults = array_merge($aVariablesResults, $aVariableMatches);
foreach($aImportsPaths as $sPath) {
$sFilePath = $sPath.'/'.$sVariableFile;
$sImportedFile = realpath($sFilePath);
if ($sImportedFile !== false) {
$sFileContent = file_get_contents($sImportedFile);
$aVariableMatches = [];
preg_match_all('/\s*\$(.*?)\s*:\s*[\"\']{0,1}(.*?)[\"\']{0,1}\s*[;!]/', $sFileContent, $aVariableMatches);
$aVariableMatches = array_combine($aVariableMatches[1], array_map(function ($sVariableValue) {
return $sVariableValue;
}, $aVariableMatches[2]));
$aVariablesResults = array_merge($aVariablesResults, $aVariableMatches);
break;
}
}
}
array_map( function($sVariableValue) { return ltrim($sVariableValue); }, $aVariablesResults );
return $aVariablesResults;

View File

@@ -0,0 +1,35 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
/**
* Class ThemeHandlerService : used to ease testing MFCompiler::CompileThemes class via mocks
*
* @author Olivier DAIN <olivier.dain@combodo.com>
* @since 3.0.0 N°2982
*/
class ThemeHandlerService
{
public function __construct()
{
}
public function CompileTheme($sThemeId, $bSetup = false, $sSetupCompilationTimestamp="", $aThemeParameters = null, $aImportsPaths = null, $sWorkingPath = null){
return ThemeHandler::CompileTheme($sThemeId, $bSetup, $sSetupCompilationTimestamp="", $aThemeParameters, $aImportsPaths, $sWorkingPath);
}
}

View File

@@ -15,6 +15,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\Helper\Session;
/**
* This class records the pending "transactions" corresponding to forms that have not been
@@ -26,8 +27,6 @@
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
class privUITransaction
{
/**
@@ -99,9 +98,12 @@ class privUITransaction
}
/**
* The original (and by default) mechanism for storing transaction information
* as an array in the $_SESSION variable
* The original mechanism for storing transaction information as an array in the $_SESSION variable
*
* Warning, since 2.6.0 the session is regenerated on each login (see PR #20) !
* Also, we saw some problems when using memcached as the PHP session implementation (see N°1835)
*
* @see \Combodo\iTop\Application\Helper\Session
*/
class privUITransactionSession
{
@@ -112,15 +114,15 @@ class privUITransactionSession
*/
public static function GetNewTransactionId()
{
if (!isset($_SESSION['transactions']))
if (!Session::IsSet('transactions'))
{
$_SESSION['transactions'] = array();
Session::Set('transactions', []);
}
// Strictly speaking, the two lines below should be grouped together
// by a critical section
// sem_acquire($rSemIdentified);
$id = static::GetUserPrefix() . str_replace(array('.', ' '), '', microtime()); //1 + count($_SESSION['transactions']);
$_SESSION['transactions'][$id] = true;
$id = static::GetUserPrefix() . str_replace(array('.', ' '), '', microtime());
Session::Set(['transactions', $id], true);
// sem_release($rSemIdentified);
return (string)$id;
@@ -137,17 +139,17 @@ class privUITransactionSession
public static function IsTransactionValid($id, $bRemoveTransaction = true)
{
$bResult = false;
if (isset($_SESSION['transactions']))
if (Session::IsSet('transactions'))
{
// Strictly speaking, the eight lines below should be grouped together
// inside the same critical section as above
// sem_acquire($rSemIdentified);
if (isset($_SESSION['transactions'][$id]))
if (Session::IsSet(['transactions', $id]))
{
$bResult = true;
if ($bRemoveTransaction)
{
unset($_SESSION['transactions'][$id]);
Session::Unset(['transactions', $id]);
}
}
// sem_release($rSemIdentified);
@@ -162,14 +164,14 @@ class privUITransactionSession
*/
public static function RemoveTransaction($id)
{
if (isset($_SESSION['transactions']))
if (Session::IsSet('transactions'))
{
// Strictly speaking, the three lines below should be grouped together
// inside the same critical section as above
// sem_acquire($rSemIdentified);
if (isset($_SESSION['transactions'][$id]))
if (Session::IsSet(['transactions', $id]))
{
unset($_SESSION['transactions'][$id]);
Session::Unset(['transactions', $id]);
}
// sem_release($rSemIdentified);
}
@@ -195,8 +197,31 @@ class privUITransactionSession
class privUITransactionFile
{
/**
* @return int
* @throws \SecurityException if no connected user
*
* @since 2.6.5 2.7.6 3.0.0 N°4289 method creation
*/
private static function GetCurrentUserId() {
$iCurrentUserId = UserRights::GetConnectedUserId();
if ('' === $iCurrentUserId) {
throw new SecurityException('Cannot creation transaction_id when no user logged');
}
return $iCurrentUserId;
}
/**
* Create a new transaction id, store it in the session and return its id
*
* @param void
*
* @return int The new transaction identifier
*
* @throws \SecurityException
* @throws \Exception
*
* @since 2.6.5 2.7.6 3.0.0 security hardening + throws SecurityException if no user logged
*/
public static function GetNewTransactionId()
{
@@ -213,24 +238,36 @@ class privUITransactionFile
throw new Exception('Failed to create the directory "'.APPROOT.'data/transactions". Ajust the rights on the parent directory or let an administrator create the transactions directory and give the web sever enough rights to write into it.');
}
}
if (!is_writable(APPROOT.'data/transactions'))
{
throw new Exception('The directory "'.APPROOT.'data/transactions" must be writable to the application.');
}
self::CleanupOldTransactions();
$id = basename(tempnam(APPROOT.'data/transactions', static::GetUserPrefix()));
self::Info('GetNewTransactionId: Created transaction: '.$id);
return (string)$id;
$iCurrentUserId = static::GetCurrentUserId();
self::CleanupOldTransactions();
$sTransactionIdFullPath = tempnam(APPROOT.'data/transactions', static::GetUserPrefix());
file_put_contents($sTransactionIdFullPath, $iCurrentUserId, LOCK_EX);
$sTransactionIdFileName = basename($sTransactionIdFullPath);
self::Info('GetNewTransactionId: Created transaction: '.$sTransactionIdFileName);
return $sTransactionIdFileName;
}
/**
* Check whether a transaction is valid or not and (optionally) remove the valid transaction from
* the session so that another call to IsTransactionValid for the same transaction id
* will return false
*
* @param int $id Identifier of the transaction, as returned by GetNewTransactionId
* @param bool $bRemoveTransaction True if the transaction must be removed
*
* @return bool True if the transaction is valid, false otherwise
*
* @since 2.6.5 2.7.6 3.0.0 N°4289 security hardening
*/
public static function IsTransactionValid($id, $bRemoveTransaction = true)
{
@@ -244,53 +281,53 @@ class privUITransactionFile
clearstatcache(true, $sFilepath);
$bResult = file_exists($sFilepath);
if ($bResult)
if (false === $bResult) {
self::Info("IsTransactionValid: Transaction '$id' not found. Pending transactions:\n".implode("\n", self::GetPendingTransactions()));
return false;
}
$iCurrentUserId = static::GetCurrentUserId();
$sTransactionIdUserId = file_get_contents($sFilepath);
if ($iCurrentUserId != $sTransactionIdUserId) {
self::Info("IsTransactionValid: Transaction '$id' not existing for current user. Pending transactions:\n".implode("\n", self::GetPendingTransactions()));
return false;
}
if ($bRemoveTransaction)
{
if ($bRemoveTransaction)
$bResult = @unlink($sFilepath);
if (!$bResult)
{
$bResult = @unlink($sFilepath);
if (!$bResult)
{
self::Error('IsTransactionValid: FAILED to remove transaction '.$id);
}
else
{
self::Info('IsTransactionValid: OK. Removed transaction: '.$id);
}
self::Error('IsTransactionValid: FAILED to remove transaction '.$id);
}
else
{
self::Info('IsTransactionValid: OK. Removed transaction: '.$id);
}
}
else
{
self::Info("IsTransactionValid: Transaction '$id' not found. Pending transactions for this user:\n".implode("\n", self::GetPendingTransactions()));
}
return $bResult;
}
/**
* Removes the transaction specified by its id
* @param int $id The Identifier (as returned by GetNewTransactionId) of the transaction to be removed.
* @return void
* @return bool true if the token can be removed
*
* @since 2.6.5 2.7.6 3.0.0 N°4289 security hardening
*/
public static function RemoveTransaction($id)
{
$bSuccess = true;
$sFilepath = APPROOT.'data/transactions/'.$id;
clearstatcache(true, $sFilepath);
if(!file_exists($sFilepath))
{
$bSuccess = false;
self::Error("RemoveTransaction: Transaction '$id' not found. Pending transactions for this user:\n".implode("\n", self::GetPendingTransactions()));
/** @noinspection PhpRedundantOptionalArgumentInspection */
$bResult = static::IsTransactionValid($id, true);
if (false === $bResult) {
self::Error("RemoveTransaction: Transaction '$id' is invalid. Pending transactions:\n"
.implode("\n", self::GetPendingTransactions()));
return false;
}
$bSuccess = @unlink($sFilepath);
if (!$bSuccess)
{
self::Error('RemoveTransaction: FAILED to remove transaction '.$id);
}
else
{
self::Info('RemoveTransaction: OK '.$id);
}
return $bSuccess;
return true;
}
/**
@@ -363,22 +400,35 @@ class privUITransactionFile
{
self::Write('Error | '.$sText);
}
protected static function IsLogEnabled() {
$oConfig = MetaModel::GetConfig();
if (is_null($oConfig)) {
return false;
}
$bLogTransactions = $oConfig->Get('log_transactions');
if (true === $bLogTransactions) {
return true;
}
return false;
}
protected static function Write($sText)
{
$bLogEnabled = MetaModel::GetConfig()->Get('log_transactions');
if ($bLogEnabled)
{
if (false === static::IsLogEnabled()) {
return;
}
$hLogFile = @fopen(APPROOT.'log/transactions.log', 'a');
if ($hLogFile !== false)
{
if ($hLogFile !== false) {
flock($hLogFile, LOCK_EX);
$sDate = date('Y-m-d H:i:s');
fwrite($hLogFile, "$sDate | $sText\n");
fflush($hLogFile);
flock($hLogFile, LOCK_UN);
fclose($hLogFile);
}
}
}
}

View File

@@ -11,6 +11,13 @@ use Twig_SimpleFilter;
use Twig_SimpleFunction;
use utils;
/**
* Class TwigExtension
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop
* @deprecated 3.1.0 N°4034
*/
class TwigExtension
{
/**
@@ -80,30 +87,14 @@ class TwigExtension
// Filter to add itopversion to an url
$oTwigEnv->addFilter(new Twig_SimpleFilter('add_itop_version', function ($sUrl) {
if (strpos($sUrl, '?') === false)
{
$sUrl = $sUrl."?itopversion=".ITOP_VERSION;
}
else
{
$sUrl = $sUrl."&itopversion=".ITOP_VERSION;
}
$sUrl = utils::AddParameterToUrl($sUrl, 'itopversion', ITOP_VERSION);
return $sUrl;
}));
// Filter to add a module's version to an url
$oTwigEnv->addFilter(new Twig_SimpleFilter('add_module_version', function ($sUrl, $sModuleName) {
$sModuleVersion = utils::GetCompiledModuleVersion($sModuleName);
if (strpos($sUrl, '?') === false)
{
$sUrl = $sUrl."?moduleversion=".$sModuleVersion;
}
else
{
$sUrl = $sUrl."&moduleversion=".$sModuleVersion;
}
$sUrl = utils::AddParameterToUrl($sUrl, 'moduleversion', $sModuleVersion);
return $sUrl;
}));
@@ -123,6 +114,14 @@ class TwigExtension
return $oConfig->Get($sParamName);
}));
// Function to get a module setting
// Usage in twig: {{ get_module_setting(<MODULE_CODE>, <PROPERTY_CODE> [, <DEFAULT_VALUE>]) }}
// since 3.0.0, but see N°4034 for upcoming evolutions in the 3.1
$oTwigEnv->addFunction(new Twig_SimpleFunction('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 Twig_SimpleFunction('get_static_page_module_url', function($sModuleName, $sPage)
@@ -137,4 +136,5 @@ class TwigExtension
return utils::GetAbsoluteUrlModulePage($sModuleName, $sPage);
}));
}
}

View File

@@ -4,6 +4,10 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\UI\Base\Component\Form\FormUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
require_once(APPROOT.'/application/displayblock.class.inc.php');
/**
@@ -82,6 +86,12 @@ class UIExtKeyWidget
$aArgs = [], $bSearchMode = false, &$sInputType = ''
)
{
// we will only use key & name, so let's reduce fields loaded !
$aAttToLoad = [
$sClass => [], // nothing, id and friendlyname are automatically added by the API
];
$oAllowedValues->OptimizeColumnLoad($aAttToLoad);
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$sTargetClass = $oAttDef->GetTargetClass();
$iMaxComboLength = $oAttDef->GetMaximumComboLength();
@@ -160,7 +170,8 @@ class UIExtKeyWidget
$sMessage = Dict::S('UI:Message:EmptyList:UseSearchForm');
$sAttrFieldPrefix = ($this->bSearchMode) ? '' : 'attr_';
$sHTMLValue = "<div class=\"field_input_zone field_input_extkey ibo-input-wrapper ibo-input-select-wrapper--with-buttons\" data-attcode=\"".$this->sAttCode."\" data-validation=\"untouched\">";
$sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL());
if ($this->bSearchMode) {
$sWizHelper = 'null';
@@ -183,48 +194,46 @@ class UIExtKeyWidget
$bDoSearch = !utils::IsHighCardinality($this->sTargetClass);
$sJSDoSearch = $bDoSearch ? 'true' : 'false';
$bIsAutocomplete = $oAllowedValues->CountExceeds($iMaxComboLength);
$sWrapperCssClass = $bIsAutocomplete ? 'ibo-input-select-autocomplete-wrapper' : 'ibo-input-select-wrapper';
$sHTMLValue = "<div class=\"field_input_zone field_input_extkey ibo-input-wrapper ibo-input-select-wrapper--with-buttons $sWrapperCssClass\" data-attcode=\"".$this->sAttCode."\" data-validation=\"untouched\" data-accessibility-selectize-label=\"$sTitle\">";
// We just need to compare the number of entries with MaxComboLength, so no need to get the real count.
if (!$oAllowedValues->CountExceeds($iMaxComboLength)) {
if (!$bIsAutocomplete) {
// Discrete list of values, use a SELECT or RADIO buttons depending on the config
$sHelpText = ''; //$this->oAttDef->GetHelpOnEdition();
//$sHTMLValue .= "<div class=\"field_select_wrapper\">\n";
$aOptions = [];
$sDisplayValue = "";
$aOption = [];
$aOption['value'] = "";
$aOption['label'] = Dict::S('UI:SelectOne');
array_push($aOptions,$aOption);
array_push($aOptions, $aOption);
$oAllowedValues->Rewind();
$bAddingValue=false;
$sClassAllowed = $oAllowedValues->GetClass();
$bAddingValue = false;
$aComplementAttributeSpec = MetaModel::GetComplementAttributeSpec($oAllowedValues->GetClass());
$aComplementAttributeSpec = MetaModel::GetNameSpec($oAllowedValues->GetClass(), FriendlyNameType::COMPLEMENTARY);
$sFormatAdditionalField = $aComplementAttributeSpec[0];
$aAdditionalField = $aComplementAttributeSpec[1];
if (count($aAdditionalField)>0)
{
$bAddingValue=true;
if (count($aAdditionalField) > 0) {
$bAddingValue = true;
}
while($oObj = $oAllowedValues->Fetch())
{
$aOption=[];
$sObjectImageAttCode = MetaModel::GetImageAttributeCode($sClassAllowed);
$bInitValue = false;
while ($oObj = $oAllowedValues->Fetch()) {
$aOption = [];
$aOption['value'] = $oObj->GetKey();
$aOption['label'] = $oObj->GetName();//.'<span class=\"object-ref-icon fas fa-eye-slash object-obsolete fa-1x fa-fw\"></span>';
$aOption['label'] = $oObj->GetName();
$aOption['search_label'] = utils::HtmlEntityDecode($oObj->GetName());
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true') )
{
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true')) {
// When there is only once choice, select it by default
$sDisplayValue=$oObj->GetName();
if($value != $oObj->GetKey())
{
$value=$oObj->GetKey();
}
}
else {
if ((is_array($value) && in_array($oObj->GetKey(), $value)) || ($value == $oObj->GetKey())) {
$sDisplayValue = $oObj->GetName();
if ($value != $oObj->GetKey()) {
$value = $oObj->GetKey();
$bInitValue = true;
}
}
if ($oObj->IsObsolete()) {
@@ -235,23 +244,36 @@ class UIExtKeyWidget
foreach ($aAdditionalField as $sAdditionalField) {
array_push($aArguments, $oObj->Get($sAdditionalField));
}
$aOption['additional_field'] = vsprintf($sFormatAdditionalField, $aArguments);
$aOption['additional_field'] = utils::HtmlEntities(vsprintf($sFormatAdditionalField, $aArguments));
}
if (!empty($sObjectImageAttCode)) {
// Try to retrieve image for contact
/** @var \ormDocument $oImage */
$oImage = $oObj->Get($sObjectImageAttCode);
if (!$oImage->IsEmpty()) {
$aOption['picture_url'] = $oImage->GetDisplayURL($sClassAllowed, $oObj->GetKey(), $sObjectImageAttCode);
$aOption['initials'] = '';
} else {
$aOption['initials'] = utils::ToAcronym($oObj->Get('friendlyname'));
}
}
array_push($aOptions, $aOption);
}
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_DECORATED;
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\" tabindex=\"0\"></select>";
$sJsonOptions = json_encode($aOptions);
$sHTMLValue .= "<select class=\"ibo-input-select-placeholder\" title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\" tabindex=\"0\"></select>";
$sJsonOptions = str_replace("'", "\'", str_replace('\\', '\\\\', json_encode($aOptions)));
$oPage->add_ready_script(
<<<EOF
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch);
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
oACWidget_{$this->iId}.AddSelectize('$sJsonOptions','$value');
$('#$this->iId').on('update', function() { oACWidget_{$this->iId}.Update(); } );
$('#$this->iId').on('change', function() { $(this).trigger('extkeychange') } );
$('#$this->iId').on('change', function() { $(this).trigger('extkeychange'); } );
EOF
);
if ($bInitValue) {
$oPage->add_ready_script("$('#$this->iId').one('validate', function() { $(this).trigger('change'); } );");
}
$sHTMLValue .= "<div class=\"ibo-input-select--action-buttons\">";
}
else
@@ -295,12 +317,12 @@ EOF
EOF
);
$sHTMLValue .= "<div class=\"ibo-input-select--action-buttons\">";
$sHTMLValue .= " <div class=\"ibo-input-select--action-button ibo-input-select--action-button--clear ibo-is-hidden\" id=\"mini_clear_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.Clear();\" data-tooltip-content='".Dict::S('UI:Button:Clear')."''><i class=\"fas fa-times\"></i></div>";
$sHTMLValue .= " <div class=\"ibo-input-select--action-button ibo-input-select--action-button--clear ibo-is-hidden\" id=\"mini_clear_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.Clear();\" data-tooltip-content='".Dict::S('UI:Button:Clear')."'><i class=\"fas fa-times\"></i></div>";
}
if ($bCreate && $bExtensions) {
$sCallbackName = (MetaModel::IsAbstract($this->sTargetClass)) ? 'SelectObjectClass' : 'CreateObject';
$sHTMLValue .= "<div class=\"ibo-input-select--action-button ibo-input-select--action-button--create\" id=\"mini_add_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.{$sCallbackName}();\" data-tooltip-content='".Dict::S('UI:Button:Create')."''><i class=\"fas fa-plus\"></i></div>";
$sHTMLValue .= "<div class=\"ibo-input-select--action-button ibo-input-select--action-button--create\" id=\"mini_add_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.{$sCallbackName}();\" data-tooltip-content='".Dict::S('UI:Button:Create')."'><i class=\"fas fa-plus\"></i></div>";
$oPage->add_ready_script(
<<<JS
if ($('#ajax_{$this->iId}').length == 0)
@@ -311,7 +333,7 @@ JS
);
}
if ($bExtensions && MetaModel::IsHierarchicalClass($this->sTargetClass) !== false) {
$sHTMLValue .= "<div class=\"ibo-input-select--action-button ibo-input-select--action-button--hierarchy\" id=\"mini_tree_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.HKDisplay();\" data-tooltip-content='".Dict::S('UI:Button:SearchInHierarchy')."''><i class=\"fas fa-sitemap\"></i></div>";
$sHTMLValue .= "<div class=\"ibo-input-select--action-button ibo-input-select--action-button--hierarchy\" id=\"mini_tree_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.HKDisplay();\" data-tooltip-content='".Dict::S('UI:Button:SearchInHierarchy')."'><i class=\"fas fa-sitemap\"></i></div>";
$oPage->add_ready_script(
<<<JS
if ($('#ac_tree_{$this->iId}').length == 0)
@@ -322,7 +344,7 @@ JS
);
}
if ($oAllowedValues->CountExceeds($iMaxComboLength)) {
$sHTMLValue .= " <div class=\"ibo-input-select--action-button ibo-input-select--action-button--search\" id=\"mini_search_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.Search();\" data-tooltip-content='".Dict::S('UI:Button:Search')."''><i class=\"fas fa-search\"></i></div>";
$sHTMLValue .= " <div class=\"ibo-input-select--action-button ibo-input-select--action-button--search\" id=\"mini_search_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.Search();\" data-tooltip-content='".Dict::S('UI:Button:Search')."'><i class=\"fas fa-search\"></i></div>";
}
$sHTMLValue .= "</div>";
$sHTMLValue .= "</div>";
@@ -516,7 +538,7 @@ JS
$sHTMLValue .= "<option value=\"\">$sDisplayValue</option>\n";
}
} else {
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
$sHTMLValue .= "<select class=\"ibo-input-select-placeholder\" title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
}
@@ -588,7 +610,7 @@ EOF
// the input for the auto-complete
$sHTMLValue .= "<input class=\"field_autocomplete ibo-input-select\" type=\"text\" id=\"label_$this->iId\" value=\"$sDisplayValue\"/>";
$sHTMLValue .= "<span class=\"field_input_btn\"><div class=\"mini_button\" id=\"mini_search_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.Search();\"><i class=\"fas fa-search\"></i></div></span>";
$sHTMLValue .= "<div class=\"ibo-input-select--action-buttons\"><span class=\"field_input_btn\"><div class=\"mini_button ibo-input-select--action-button\" id=\"mini_search_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.Search();\"><i class=\"fas fa-search\"></i></div></span></div>";
// another hidden input to store & pass the object's Id
$sHTMLValue .= "<input type=\"hidden\" id=\"$this->iId\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" value=\"".htmlentities($value, ENT_QUOTES, 'UTF-8')."\" />\n";
@@ -673,20 +695,38 @@ JS
$sEmptyList = Dict::S('UI:Message:EmptyList:UseSearchForm');
$oPage->add(<<<HTML
<form id="fr_{$this->iId}" OnSubmit="return oACWidget_{$this->iId}.DoOk();">
<div id="dr_{$this->iId}" style="vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;">
<div style="background: #fff; border:0; text-align:center; vertical-align:middle;"><p>{$sEmptyList}</p></div>
<div id="dr_{$this->iId}">
<div><p>{$sEmptyList}</p></div>
</div>
<input type="button" id="btn_cancel_{$this->iId}" value="{$sCancel}" onClick="$('#ac_dlg_{$this->iId}').dialog('close');">&nbsp;&nbsp;
<input type="button" id="btn_ok_{$this->iId}_results" value="{$sOK}" onClick="oACWidget_{$this->iId}.DoOk();">
<input type="hidden" id="count_{$this->iId}_results" value="0">
</form>
</div></div>
HTML
);
$sDialogTitle = addslashes($sTitle);
$sDialogTitleSanitized = utils::HtmlToText($sTitle);
$oPage->add_ready_script(<<<JS
$('#ac_dlg_{$this->iId}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, title: '$sDialogTitle', resizeStop: oACWidget_{$this->iId}.UpdateSizes, close: oACWidget_{$this->iId}.OnClose });
$('#ac_dlg_{$this->iId}').dialog({
width: $(window).width()*0.8,
height: $(window).height()*0.8,
autoOpen: false,
modal: true,
title: '$sDialogTitleSanitized',
resizeStop: oACWidget_{$this->iId}.UpdateSizes,
close: oACWidget_{$this->iId}.OnClose,
buttons: [
{ text: "$sCancel",
class: "ibo-is-alternative ibo-is-neutral",
click: function() {
$(this).dialog('close');
} },
{ text: "$sOK",
class: "ibo-is-regular ibo-is-primary",
click: function() {
oACWidget_{$this->iId}.DoOk();
} },
],
});
$('#fs_{$this->iId}').on('submit.uiAutocomplete', oACWidget_{$this->iId}.DoSearchObjects);
$('#dc_{$this->iId}').resize(oACWidget_{$this->iId}.UpdateSizes);
JS
@@ -782,21 +822,24 @@ JS
{
case static::ENUM_OUTPUT_FORMAT_JSON:
$aJsonMap = array();
foreach ($aValues as $sKey => $aValue)
{
if ($aValue['additional_field'] != '')
{
$aJsonMap[] = array('value' => $sKey, 'label' => $aValue['label'], 'obsolescence_flag' => $aValue['obsolescence_flag'], 'additional_field' => $aValue['additional_field']);
}
else
{
$aJsonMap[] = array('value' => $sKey, 'label' => $aValue['label'], 'obsolescence_flag' => $aValue['obsolescence_flag']);
}
}
$aJsonMap = array();
foreach ($aValues as $sKey => $aValue) {
$aElt = ['value' => $sKey, 'label' => utils::EscapeHtml($aValue['label']), 'obsolescence_flag' => $aValue['obsolescence_flag']];
if ($aValue['additional_field'] != '') {
$aElt['additional_field'] = utils::EscapeHtml($aValue['additional_field']);
}
$oP->SetContentType('application/json');
$oP->add(json_encode($aJsonMap));
if (array_key_exists('initials', $aValue)) {
$aElt['initials'] = $aValue['initials'];
if (array_key_exists('picture_url', $aValue)) {
$aElt['picture_url'] = $aValue['picture_url'];
}
}
$aJsonMap[] = $aElt;
}
$oP->SetContentType('application/json');
$oP->add(json_encode($aJsonMap));
break;
case static::ENUM_OUTPUT_FORMAT_CSV:
@@ -863,26 +906,17 @@ JS
}
}
$sDialogTitle = '';
$oPage->add('<div id="ac_create_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_'.$this->iId.'">');
$oPage->add('<form>');
$sClassLabel = MetaModel::GetName($this->sTargetClass);
$oPage->add('<p>'.Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel));
$oPage->add('<nobr><select name="class">');
asort($aPossibleClasses);
foreach($aPossibleClasses as $sClassName => $sClassLabel)
{
$oPage->add("<option value=\"$sClassName\">$sClassLabel</option>");
}
$oPage->add('</select>');
$oPage->add('&nbsp; <button type="submit" class="action" style="margin-top:15px;"><span>' . Dict::S('UI:Button:Ok') . '</span></button></nobr></p>');
$sDialogTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel);;
$oBlock = UIContentBlockUIBlockFactory::MakeStandard('ac_create_'.$this->iId,['ibo-is-visible']);
$oPage->AddSubBlock($oBlock);
$oClassForm = FormUIBlockFactory::MakeStandard();
$oBlock->AddSubBlock($oClassForm);
$oClassForm->AddSubBlock(cmdbAbstractObject::DisplayBlockSelectClassToCreate( $sClassLabel, $this->sTargetClass, $aPossibleClasses));
$oPage->add('</form>');
$oPage->add('</div></div></div>');
$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: 'auto', height: 'auto', maxHeight: $(window).height() - 50, autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').removeAttr('onsubmit');");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').on('submit.uilinksWizard', oACWidget_{$this->iId}.DoSelectObjectClass);");
$oPage->add_ready_script("$('#ac_create_$this->iId').dialog({ width: 'auto', height: 'auto', maxHeight: $(window).height() - 50, autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
$oPage->add_ready_script("$('#ac_create_{$this->iId} form').removeAttr('onsubmit');");
$oPage->add_ready_script("$('#ac_create_{$this->iId} form').on('submit.uilinksWizard', oACWidget_{$this->iId}.DoSelectObjectClass);");
}
/**
@@ -953,7 +987,7 @@ JS
public function DisplayHierarchy(WebPage $oPage, $sFilter, $currValue, $oObj)
{
$sDialogTitle = addslashes(Dict::Format('UI:HierarchyOf_Class', MetaModel::GetName($this->sTargetClass)));
$oPage->add('<div id="dlg_tree_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div style="overflow:auto;background:#fff;margin-bottom:5px;" id="tree_'.$this->iId.'">');
$oPage->add('<div id="dlg_tree_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div style="margin-bottom:5px;" id="tree_'.$this->iId.'">');
$oPage->add('<table style="width:100%"><tr><td>');
if (is_null($sFilter))
{
@@ -977,8 +1011,8 @@ JS
$oPage->add('<div class="treecontrol" id="treecontrolid"><a href="?#">'.Dict::S("UI:Treeview:CollapseAll").'</a> | <a href="?#">'.Dict::S("UI:Treeview:ExpandAll").'</a></div>');
}
$oPage->add("<input type=\"button\" id=\"btn_cancel_{$this->iId}\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_tree_{$this->iId}').dialog('close');\">&nbsp;&nbsp;");
$oPage->add("<input type=\"button\" id=\"btn_ok_{$this->iId}\" value=\"".Dict::S('UI:Button:Ok')."\" onClick=\"oACWidget_{$this->iId}.DoHKOk();\">");
$oPage->add("<input type=\"button\" class=\"ibo-button ibo-is-regular ibo-is-neutral\" id=\"btn_cancel_{$this->iId}\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_tree_{$this->iId}').dialog('close');\">&nbsp;&nbsp;");
$oPage->add("<input type=\"button\" class=\"ibo-button ibo-is-regular ibo-is-primary\" id=\"btn_ok_{$this->iId}\" value=\"".Dict::S('UI:Button:Ok')."\" onClick=\"oACWidget_{$this->iId}.DoHKOk();\">");
$oPage->add('</div></div>');

View File

@@ -15,6 +15,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\Helper\WebResourcesHelper;
/**
* Class UIHTMLEditorWidget
@@ -64,7 +65,7 @@ class UIHTMLEditorWidget
$sHelpText = $this->m_sHelpText;
$sValidationField = $this->m_sValidationField;
$sHtmlValue = "<div class=\"field_input_zone field_input_html\"><textarea class=\"htmlEditor\" title=\"$sHelpText\" name=\"attr_{$this->m_sFieldPrefix}{$sCode}\" rows=\"10\" cols=\"10\" id=\"$iId\">$sValue</textarea></div>$sValidationField";
$sHtmlValue = "<div class=\"field_input_zone field_input_html ibo-input-wrapper\"><textarea class=\"htmlEditor ibo-input-richtext-placeholder\" title=\"$sHelpText\" name=\"attr_{$this->m_sFieldPrefix}{$sCode}\" id=\"$iId\">$sValue</textarea></div>$sValidationField";
// Replace the text area with CKEditor
// To change the default settings of the editor,
@@ -83,6 +84,7 @@ class UIHTMLEditorWidget
}
$sConfigJS = json_encode($aConfig);
WebResourcesHelper::EnableCKEditorToWebPage($oPage);
$oPage->add_ready_script("$('#$iId').ckeditor(function() { /* callback code */ }, $sConfigJS);"); // Transform $iId into a CKEdit
// Please read...

View File

@@ -337,11 +337,10 @@ class UILinksWidgetDirect
$oPage->add(<<<HTML
<form id="ObjectsAddForm_{$this->sInputid}">
<div id="SearchResultsToAdd_{$this->sInputid}" style="vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;">
<div id="SearchResultsToAdd_{$this->sInputid}">
<div style="background: #fff; border:0; text-align:center; vertical-align:middle;"><p>{$sEmptyList}</p></div>
</div>
<input type="hidden" id="count_{$this->sInputid}" value="0"/>
<button type="button" class="cancel">{$sCancel}</button>&nbsp;&nbsp;<button type="button" class="ok" disabled="disabled">{$sAdd}</button>
</form>
HTML
);

View File

@@ -49,6 +49,8 @@ class UIPasswordWidget
*/
public function Display(WebPage $oPage, $aArgs = array())
{
$oPage->add_dict_entry('UI:Component:Input:Password:DoesNotMatch');
$sCode = $this->sAttCode.$this->sNameSuffix;
$iWidgetIndex = self::$iWidgetIndex;
@@ -57,11 +59,12 @@ class UIPasswordWidget
$sConfirmPasswordValue = $aPasswordValues ? $aPasswordValues['confirm'] : '*****';
$sChangedValue = (($sPasswordValue != '*****') || ($sConfirmPasswordValue != '*****')) ? 1 : 0;
$sHtmlValue = '';
$sHtmlValue .= '<div class="field_input_zone field_input_onewaypassword">';
$sHtmlValue .= '<input type="password" maxlength="255" name="attr_'.$sCode.'[value]" id="'.$this->iId.'" value="'.htmlentities($sPasswordValue, ENT_QUOTES, 'UTF-8').'"/>';
$sHtmlValue .= '<input type="password" maxlength="255" id="'.$this->iId.'_confirm" value="'.htmlentities($sConfirmPasswordValue, ENT_QUOTES, 'UTF-8').'" name="attr_'.$sCode.'[confirm]"/>';
$sHtmlValue .= '<span>'.Dict::S('UI:PasswordConfirm').'</span>';
$sHtmlValue .= '<input id="'.$this->iId.'_reset" type="button" value="'.Dict::S('UI:Button:ResetPassword').'" onClick="ResetPwd(\''.$this->iId.'\');">';
$sHtmlValue .= '<div class="field_input_zone field_input_onewaypassword ibo-input-wrapper ibo-input-one-way-password-wrapper">';
$sHtmlValue .= '<input class="ibo-input" type="password" maxlength="255" name="attr_'.$sCode.'[value]" id="'.$this->iId.'" value="'.htmlentities($sPasswordValue, ENT_QUOTES, 'UTF-8').'"/>';
$sHtmlValue .= '<div class="ibo-input-wrapper ibo-input-wrapper--with-buttons"><input class="ibo-input" type="password" maxlength="255" id="'.$this->iId.'_confirm" value="'.htmlentities($sConfirmPasswordValue, ENT_QUOTES, 'UTF-8').'" name="attr_'.$sCode.'[confirm]"/>';
$sHtmlValue .= '<div class="ibo-input-select--action-buttons"><div class="ibo-input-select--action-button ibo-input-select--action-button--create" data-tooltip-content="'.Dict::S('UI:PasswordConfirm').'"><i class="fas fa-question-circle"></i></div></div></div>';
$sHtmlValue .= '<button id="'.$this->iId.'_reset" class="ibo-button ibo-is-regular ibo-is-neutral" onClick="ResetPwd(\''.$this->iId.'\');">';
$sHtmlValue .= '<span class="ibo-button--icon fas fa-undo"></span><span class="ibo-button--label">'.Dict::S('UI:Button:ResetPassword').'</span></button>';
$sHtmlValue .= '<input type="hidden" id="'.$this->iId.'_changed" name="attr_'.$sCode.'[changed]" value="'.$sChangedValue.'"/>';
$sHtmlValue .= '</div>';

View File

@@ -64,16 +64,42 @@ class UISearchFormForeignKeys
<div style="background: #fff; border:0; text-align:center; vertical-align:middle;"><p>{$sEmptyList}</p></div>
</div>
<input type="hidden" id="count_{$this->m_iInputId}" value="0"/>
<input type="button" value="{$sCancel}" onClick="$('#dlg_{$this->m_iInputId}').dialog('close');">&nbsp;&nbsp;
<input id="btn_ok_add_{$this->m_iInputId}" disabled="disabled" type="button" onclick="return oForeignKeysWidget{$this->m_iInputId}.DoAddObjects(this.id);" value="{$sAdd}">
</form>
HTML
);
$oPage->add_ready_script("$('#dlg_{$this->m_iInputId}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, resizeStop: oForeignKeysWidget{$this->m_iInputId}.UpdateSizes });");
$oPage->add_ready_script("$('#dlg_{$this->m_iInputId}').dialog('option', {title:'$sTitle'});");
$oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_iInputId} form').on('submit.uilinksWizard', oForeignKeysWidget{$this->m_iInputId}.SearchObjectsToAdd);");
$oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_iInputId}').resize(oForeignKeysWidget{$this->m_iInputId}.UpdateSizes);");
$oPage->add_ready_script(
<<<JS
$('#dlg_{$this->m_iInputId}').dialog({
width: $(window).width()*0.8,
height: $(window).height()*0.8,
autoOpen: false,
modal: true,
resizeStop: oForeignKeysWidget{$this->m_iInputId}.UpdateSizes,
buttons: [
{
text: Dict.S('UI:Button:Cancel'),
class: "cancel ibo-is-alternative ibo-is-neutral",
click: function() {
$('#dlg_{$this->m_iInputId}').dialog('close');
}
},
{
text: Dict.S('UI:Button:Add'),
id: 'btn_ok_{$this->m_iInputId}',
class: "ok ibo-is-regular ibo-is-primary",
click: function() {
oForeignKeysWidget{$this->m_iInputId}.DoAddObjects(this.id);
}
},
],
});
$('#dlg_{$this->m_iInputId}').dialog('option', {title:'$sTitle'});
$('#SearchFormToAdd_{$this->m_iInputId} form').on('submit.uilinksWizard', oForeignKeysWidget{$this->m_iInputId}.SearchObjectsToAdd);
$('#SearchFormToAdd_{$this->m_iInputId}').resize(oForeignKeysWidget{$this->m_iInputId}.UpdateSizes);
JS
);
}
public function GetFullListForeignKeysFromSelection($oPage, $oFullSetFilter)

View File

@@ -270,23 +270,20 @@ $sJSHandlerCode
$aFields = array(); // reset
foreach(MetaModel::ListAttributeDefs($this->m_sClass) as $sAttCode=>$oAttDef)
{
$iOptions = (isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode])) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
if ( ($sStateAttCode != $sAttCode) &&
(!$oAttDef->IsExternalField()) &&
(($iOptions & (OPT_ATT_HIDDEN | OPT_ATT_READONLY)) == 0) &&
(!isset($aFieldsDone[$sAttCode])) )
{
// 'State', external fields, read-only and hidden fields
$iOptions = (isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode])) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
if (($sStateAttCode != $sAttCode) &&
(!$oAttDef->IsExternalField()) &&
($oAttDef->IsWritable()) &&
(($iOptions & (OPT_ATT_HIDDEN | OPT_ATT_READONLY)) == 0) &&
(!isset($aFieldsDone[$sAttCode]))) {
// 'State', external fields, read-only (both because of the flags or the attribute type) and hidden fields
// and fields that are already listed in the wizard
// are removed from the 'optional' part of the wizard
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
$aFields[$sAttCode] = array();
foreach($aPrerequisites as $sCode)
{
if (!isset($aFieldsDone[$sCode]))
{
foreach ($aPrerequisites as $sCode) {
if (!isset($aFieldsDone[$sCode])) {
// retain only the dependencies that were not covered
// in the 'mandatory' part of the wizard
$aFields[$sAttCode][$sCode] = '';

View File

@@ -17,6 +17,8 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\Helper\Session;
use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use ScssPhp\ScssPhp\Compiler;
@@ -90,12 +92,31 @@ class utils
* @since 3.0.0
*/
public const ENUM_SANITIZATION_FILTER_VARIABLE_NAME = 'variable_name';
/**
* @var string
* @since 3.0.0
*/
public const ENUM_SANITIZATION_FILTER_RAW_DATA = 'raw_data';
/**
* @var string
* @since 3.0.0
* @used-by static::GetMentionedObjectsFromText
*/
public const ENUM_TEXT_FORMAT_PLAIN = 'text';
/**
* @var string
* @since 3.0.0
* @used-by static::GetMentionedObjectsFromText
*/
public const ENUM_TEXT_FORMAT_HTML = 'html';
/**
* @var string
* @since 3.0.0
* @used-by static::GetMentionedObjectsFromText
*/
public const ENUM_TEXT_FORMAT_MARKDOWN = 'markdown';
/**
* @var string
* @since 3.0.0
@@ -219,9 +240,9 @@ class utils
public static function InitArchiveMode()
{
if (isset($_SESSION['archive_mode']))
if (Session::IsSet('archive_mode'))
{
$iDefault = $_SESSION['archive_mode'];
$iDefault = Session::Get('archive_mode');
}
else
{
@@ -229,9 +250,9 @@ class utils
}
// Read and record the value for switching the archive mode
$iCurrent = self::ReadParam('with-archive', $iDefault);
if (isset($_SESSION))
if (Session::IsInitialized())
{
$_SESSION['archive_mode'] = $iCurrent;
Session::Set('archive_mode', $iCurrent);
}
// Read and use the value for the current page (web services)
$iCurrent = self::ReadParam('with_archive', $iCurrent, true);
@@ -520,12 +541,10 @@ class utils
{
$aSelectedObj = utils::ReadParam('selectObject', array());
$sSelectionMode = utils::ReadParam('selectionMode', '');
if ($sSelectionMode != '')
{
if ($sSelectionMode != '') {
// Paginated selection
$aExceptions = utils::ReadParam('storedSelection', array());
if ($sSelectionMode == 'positive')
{
if ($sSelectionMode == 'positive') {
// Only the explicitely listed items are selected
$aSelectedObj = $aExceptions;
}
@@ -638,48 +657,93 @@ class utils
public static function ReadFromFile($sFileName)
{
if (!file_exists($sFileName)) return false;
if (!file_exists($sFileName)) {
return false;
}
return file_get_contents($sFileName);
}
/**
* Helper function to convert a value expressed in a 'user friendly format'
* as in php.ini, e.g. 256k, 2M, 1G etc. Into a number of bytes
* @param mixed $value The value as read from php.ini
* @return number
* @param mixed $value The value as read from php.ini (eg 256k, 2M, 1G etc.)
*
* @return int conversion to number of bytes
*
* @since 2.7.5 3.0.0 convert to int numeric values
*
* @link https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes Shorthand bytes value reference in PHP.net FAQ
*/
public static function ConvertToBytes( $value )
public static function ConvertToBytes($value)
{
$iReturn = $value;
if ( !is_numeric( $value ) )
{
$iLength = strlen( $value );
$iReturn = substr( $value, 0, $iLength - 1 );
$sUnit = strtoupper( substr( $value, $iLength - 1 ) );
switch ( $sUnit )
{
case 'G':
$iReturn *= 1024;
case 'M':
$iReturn *= 1024;
case 'K':
$iReturn *= 1024;
}
}
return $iReturn;
}
/**
* Checks if the memory limit is at least what is required
*
* @param int $memoryLimit set limit in bytes
* @param int $requiredLimit required limit in bytes
* @return bool
*/
public static function IsMemoryLimitOk($memoryLimit, $requiredLimit)
{
return ($memoryLimit >= $requiredLimit) || ($memoryLimit == -1);
}
if (!is_numeric($value)) {
$iLength = strlen($value);
$iReturn = substr($value, 0, $iLength - 1);
$sUnit = strtoupper(substr($value, $iLength - 1));
switch ($sUnit) {
case 'G':
$iReturn *= 1024;
case 'M':
$iReturn *= 1024;
case 'K':
$iReturn *= 1024;
}
} else {
$iReturn = (int)$value;
}
return $iReturn;
}
/**
* Checks if the memory limit is at least what is required
*
* @param int $iMemoryLimit set limit in bytes, use {@link utils::ConvertToBytes()} to convert current php.ini value
* @param int $iRequiredLimit required limit in bytes
*
* @return bool
*/
public static function IsMemoryLimitOk($iMemoryLimit, $iRequiredLimit)
{
if ($iMemoryLimit === -1) {
// -1 means : no limit (see https://www.php.net/manual/fr/ini.core.php#ini.memory-limit)
return true;
}
return ($iMemoryLimit >= $iRequiredLimit);
}
/**
* Set memory_limit to required value
*
* @param string $sRequiredLimit required limit, for example '512M'
*
* @return bool|null null if nothing was done, true if modifying memory_limit was successful, false otherwise
*
* @uses utils::ConvertToBytes()
* @uses \ini_get('memory_limit')
* @uses \ini_set()
* @uses utils::ConvertToBytes()
*
* @since 2.7.5 N°3806
*/
public static function SetMinMemoryLimit($sRequiredLimit)
{
$iRequiredLimit = static::ConvertToBytes($sRequiredLimit);
$sMemoryLimit = trim(ini_get('memory_limit'));
if (empty($sMemoryLimit)) {
// On some PHP installations, memory_limit does not exist as a PHP setting!
// (encountered on a 5.2.0 under Windows)
// In that case, ini_set will not work
return false;
}
$iMemoryLimit = static::ConvertToBytes($sMemoryLimit);
if (static::IsMemoryLimitOk($iMemoryLimit, $iRequiredLimit)) {
return null;
}
return ini_set('memory_limit', $iRequiredLimit);
}
/**
* Format a value into a more friendly format (KB, MB, GB, TB) instead a juste a Bytes amount.
@@ -797,6 +861,8 @@ class utils
}
/**
* @param boolean $bForceGetFromDisk if true then will always read from disk without using instances in memory
*
* @return \Config Get object in the following order :
* <ol>
* <li>from {@link MetaModel::GetConfig} if loaded
@@ -808,26 +874,27 @@ class utils
* @throws \ConfigException
* @throws \CoreException
*
* @since 2.7.0 N°2478 always call {@link MetaModel::GetConfig} first, cache is only set when loading from disk
* @since 2.7.0 N°2478 this method will now always call {@link MetaModel::GetConfig} first, and cache in this class is only set when loading from disk
* @since 3.0.0 N°4158 new $bReadFromDisk parameter
*/
public static function GetConfig()
public static function GetConfig($bForceGetFromDisk = false)
{
$oMetaModelConfig = MetaModel::GetConfig();
if ($oMetaModelConfig !== null)
{
return $oMetaModelConfig;
}
if (!$bForceGetFromDisk) {
$oMetaModelConfig = MetaModel::GetConfig();
if ($oMetaModelConfig !== null) {
return $oMetaModelConfig;
}
if (self::$oConfig !== null)
{
return self::$oConfig;
if (self::$oConfig !== null) {
return self::$oConfig;
}
}
$sCurrentEnvConfigPath = self::GetConfigFilePath();
if (file_exists($sCurrentEnvConfigPath))
{
if (file_exists($sCurrentEnvConfigPath)) {
$oCurrentEnvDiskConfig = new Config($sCurrentEnvConfigPath);
self::SetConfig($oCurrentEnvDiskConfig);
return self::$oConfig;
}
@@ -1147,7 +1214,7 @@ class utils
*/
static function CanLogOff()
{
return (isset($_SESSION['can_logoff']) ? $_SESSION['can_logoff'] : false);
return Session::Get('can_logoff', false);
}
/**
@@ -1156,7 +1223,7 @@ class utils
*/
public static function GetSessionLog()
{
return print_r($_SESSION, true);
return Session::GetLog();
}
static function DebugBacktrace($iLimit = 5)
@@ -1249,14 +1316,17 @@ class utils
*/
public static function GetCurrentEnvironment()
{
if (isset($_SESSION['itop_env']))
{
return $_SESSION['itop_env'];
}
else
{
return ITOP_DEFAULT_ENV;
}
return Session::Get('itop_env', ITOP_DEFAULT_ENV);
}
/**
* @return string Absolute path to the folder into which the current environment has been compiled.
* The corresponding folder is created or cleaned upon code compilation
* @since 3.0.0
*/
public static function GetCompiledEnvironmentPath(): string
{
return APPROOT . 'env-' . MetaModel::GetEnvironment() . '/';
}
/**
@@ -1267,6 +1337,7 @@ class utils
{
return APPROOT.'data/cache-'.MetaModel::GetEnvironment().'/';
}
/**
* @return string A path to a folder into which any module can store log
* @since 2.7.0
@@ -1291,12 +1362,15 @@ class utils
*/
public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null)
{
$oPage->AddUiBlock(static::GetPopupMenuItemsBlock($iMenuId, $param, $aActions, $sDataTableId));
$oBlock = new UIContentBlock();
static::GetPopupMenuItemsBlock($oBlock, $iMenuId, $param, $aActions, $sDataTableId);
$oPage->AddUiBlock($oBlock);
}
/**
* Merge standard menu items with plugin provided menus items
*
* @param \Combodo\iTop\Application\UI\Base\iUIBlock $oContainerBlock The UIBlock containing the menu
* @param int $iMenuId
* @param \DBObjectSet $param
* @param array $aActions
@@ -1306,9 +1380,8 @@ class utils
* @throws \ArchivedObjectException
* @throws \CoreException
*/
public static function GetPopupMenuItemsBlock($iMenuId, $param, &$aActions, $sDataTableId = null)
public static function GetPopupMenuItemsBlock(iUIBlock &$oContainerBlock, $iMenuId, $param, &$aActions, $sDataTableId = null)
{
$oBlock = new UIContentBlock();
// 1st - add standard built-in menu items
//
switch($iMenuId)
@@ -1322,9 +1395,9 @@ class utils
$sOQL = addslashes($param->GetFilter()->ToOQL(true));
$sFilter = urlencode($param->GetFilter()->serialize());
$sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}";
$oBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oBlock->AddCssFileRelPath('css/dragtable.css');
$oContainerBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oContainerBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oContainerBlock->AddCssFileRelPath('css/dragtable.css');
$aResult = array();
if (strlen($sUrl) < SERVER_MAX_URL_LENGTH)
@@ -1357,12 +1430,12 @@ class utils
$oObj = $param;
$sOQL = "SELECT ".get_class($oObj)." WHERE id=".$oObj->GetKey();
$sUrl = ApplicationContext::MakeObjectUrl(get_class($oObj), $oObj->GetKey());
$oBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oBlock->AddCssFileRelPath('css/dragtable.css');
$oBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oBlock->AddCssFileRelPath('css/dragtable.css');
$oContainerBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oContainerBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oContainerBlock->AddCssFileRelPath('css/dragtable.css');
$oContainerBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oContainerBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oContainerBlock->AddCssFileRelPath('css/dragtable.css');
$aResult = array(
new SeparatorPopupMenuItem(),
@@ -1430,13 +1503,11 @@ class utils
foreach($oMenuItem->GetLinkedScripts() as $sLinkedScript)
{
$oBlock->AddJsFileRelPath($sLinkedScript);
$oContainerBlock->AddJsFileRelPath($sLinkedScript);
}
}
}
}
return $oBlock;
}
/**
@@ -1859,7 +1930,7 @@ class utils
public static function CompileCSSFromSASS($sSassContent, $aImportPaths = array(), $aVariables = array())
{
$oSass = new Compiler();
$oSass->setFormatter('ScssPhp\\ScssPhp\\Formatter\\Expanded');
$oSass->setFormatter('ScssPhp\\ScssPhp\\Formatter\\Compressed');
// Setting our variables
$oSass->setVariables($aVariables);
// Setting our imports paths
@@ -2567,7 +2638,9 @@ class utils
$aDefaultConf = array(
'language'=> $sLanguage,
'contentsLanguage' => $sLanguage,
'extraPlugins' => 'disabler,codesnippet,mentions',
'extraPlugins' => 'disabler,codesnippet,mentions,objectshortcut,font,uploadimage',
'uploadUrl' => utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php',
'contentsCss' => array(utils::GetAbsoluteUrlAppRoot().'js/ckeditor/contents.css', utils::GetAbsoluteUrlAppRoot().'css/ckeditor/contents.css'),
);
// Mentions
@@ -2575,24 +2648,36 @@ class utils
if(!empty($aMentionsAllowedClasses)) {
$aDefaultConf['mentions'] = [];
foreach($aMentionsAllowedClasses as $sMentionChar => $sMentionClass) {
foreach($aMentionsAllowedClasses as $sMentionMarker => $sMentionScope) {
// Retrieve mention class
// - First test if the conf is a simple Datamodel class
if (MetaModel::IsValidClass($sMentionScope)) {
$sMentionClass = $sMentionScope;
}
// - Otherwise it must be a valid OQL
else {
$oTmpSearch = DBSearch::FromOQL($sMentionScope);
$sMentionClass = $oTmpSearch->GetClass();
unset($oTmpSearch);
}
// Note: Endpoints are defaults only and should be overloaded by other GUIs such as the end-users portal
$sMentionEndpoint = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=cke_mentions&target_class='.$sMentionClass.'&needle={encodedQuery}';
$sMentionEndpoint = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=cke_mentions&marker='.urlencode($sMentionMarker).'&needle={encodedQuery}';
$sMentionItemUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class='.$sMentionClass.'&id={id}';
$sMentionItemPictureTemplate = (empty(MetaModel::GetImageAttributeCode($sMentionClass))) ? '' : <<<HTML
<span class="ibo-vendors-ckeditor--autocomplete-item-image" style="background-image: url('{picture_url}');">{initials}</span>
<span class="ibo-vendors-ckeditor--autocomplete-item-image" style="{picture_style}">{initials}</span>
HTML;
$sMentionItemTemplate = <<<HTML
<li class="ibo-vendors-ckeditor--autocomplete-item" data-id="{id}">{$sMentionItemPictureTemplate}<span class="ibo-vendors-ckeditor--autocomplete-item-title">{friendlyname}</span></li>
HTML;
$sMentionOutputTemplate = <<<HTML
<a href="$sMentionItemUrl" data-role="object-mention" data-object-class="{class}" data-object-id="{id}">{$sMentionChar}{friendlyname}</a>
<a href="$sMentionItemUrl" data-role="object-mention" data-object-class="{class}" data-object-id="{id}">{$sMentionMarker}{friendlyname}</a>
HTML;
$aDefaultConf['mentions'][] = [
'feed' => $sMentionEndpoint,
'marker' => $sMentionChar,
'marker' => $sMentionMarker,
'minChars' => MetaModel::GetConfig()->Get('min_autocomplete_chars'),
'itemTemplate' => $sMentionItemTemplate,
'outputTemplate' => $sMentionOutputTemplate,
@@ -2684,15 +2769,13 @@ HTML;
}
/**
* Return keyboard shortcuts config as an array
*
* @return array
* @return array All keyboard shortcuts config as an array
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @since 3.0.0
*/
public static function GetKeyboardShortcutPref(): array
public static function GetAllKeyboardShortcutsPrefs(): array
{
$aResultPref = [];
$aShortcutPrefs = appUserPreferences::GetPref('keyboard_shortcuts', []);
@@ -2703,29 +2786,113 @@ HTML;
$sTriggeredElement = $cShortcutPlugin::GetShortcutTriggeredElementSelector();
foreach ($cShortcutPlugin::GetShortcutKeys() as $aShortcutKey) {
$sKey = isset($aShortcutPrefs[$aShortcutKey['id']]) ? $aShortcutPrefs[$aShortcutKey['id']] : $aShortcutKey['key'];
$aResultPref[$aShortcutKey['id']] = ['key' => $sKey, 'label' => $aShortcutKey['label'], 'event' => $aShortcutKey['event'], 'triggered_element_selector' => $sTriggeredElement];
// Format key for display
$aKeyParts = explode('+', $sKey);
$aFormattedKeyParts = [];
foreach ($aKeyParts as $sKeyPart) {
$aFormattedKeyParts[] = ucfirst(trim($sKeyPart));
}
$sFormattedKey = implode(' + ', $aFormattedKeyParts);
$aResultPref[$aShortcutKey['id']] = [
'key' => $sKey,
'key_for_display' => $sFormattedKey,
'label' => $aShortcutKey['label'],
'event' => $aShortcutKey['event'],
'triggered_element_selector' => $sTriggeredElement,
];
}
}
return $aResultPref;
}
/**
* @param string $sShortcutId
*
* @return array The properties of the $sShortcutId shorcut
* @throws \Exception
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @since 3.0.0
*/
public static function GetKeyboardShortcutPref(string $sShortcutId): array
{
$aPrefs = static::GetAllKeyboardShortcutsPrefs();
if (false === array_key_exists($sShortcutId, $aPrefs)) {
throw new Exception('No shortcut identified as "'.$sShortcutId.'" is currently handled by the application.');
}
return $aPrefs[$sShortcutId];
}
//----------------------------------------------
// Environment helpers
//----------------------------------------------
/**
* Check if iTop is in a development environment (VCS vs build number)
* Check if iTop is in a development environment
*
* @return bool
* @return bool true if development environment
*
* @since 2.6.0 method creation
* @since 3.0.0 add the `developer_mode.enabled` config parameter
*
* @uses GetDeveloperModeParam
* @uses ITOP_REVISION constant (check 'svn' value)
*/
public static function IsDevelopmentEnvironment()
{
$bIsDevEnvInConfig = static::GetDeveloperModeParam();
if ($bIsDevEnvInConfig === true) {
return true;
}
if ($bIsDevEnvInConfig === false) {
return false;
}
if (!defined('ITOP_REVISION')) {
//defensive behaviour: by default we are not in dev environment
//can happen even in production (unattended install for example) or with exotic use of iTop
return false;
}
return ITOP_REVISION === 'svn';
}
/**
* @return bool : indicate whether we run under a windows environnement or not
* In the setup there are times when the MetaModel config attribute is loaded but partially (only setup parameters are set, others have the default value)
* So we need to load from disk then !
*
* But in other scenario we want to read from memory : for example when changing the option in a PHPUnit setUp method
*
* This method will first try to get the `developer_mode.enabled` config parameter the standard way (call to GetConfig without modification).
* If we are getting null (not defined parameter), then we will load config from disk only (GetConfig(true))
*
* @return bool|null
* @throws \ConfigException
* @throws \CoreException
*
* @uses developer_mode.enabled config parameter
*/
private static function GetDeveloperModeParam(): ?bool
{
$oConfig = static::GetConfig(false);
$bIsDevEnvInConfig = $oConfig->Get('developer_mode.enabled');
if (!is_null($bIsDevEnvInConfig)) {
return $bIsDevEnvInConfig;
}
$oConfigFromDisk = static::GetConfig(true);
return $oConfigFromDisk->Get('developer_mode.enabled');
}
/**
* @return bool true if we are running under a Windows environment
* @since 2.7.4 : N°3412
*/
public static function IsWindowsEnvironment()
@@ -2830,4 +2997,87 @@ HTML;
return $sAcronym;
}
//----------------------------------------------
// Text manipulation
//----------------------------------------------
/**
* Note: Only works for backoffice URLs for now
*
* @param string $sText Text containing the mentioned objects to be found
* @param string $sFormat {@uses static::ENUM_TEXT_FORMAT_HTML, ...}
*
* @return array Array of object classes / IDs for the ones found in $sText
*
* [
* 'ClassA' => ['ID1', 'ID2', ...],
* 'ClassB' => ['ID3'],
* ]
*
* @throws \Exception
* @since 3.0.0
*/
public static function GetMentionedObjectsFromText(string $sText, string $sFormat = self::ENUM_TEXT_FORMAT_HTML): array
{
// First transform text so it can be parsed
switch ($sFormat) {
case static::ENUM_TEXT_FORMAT_HTML:
$sText = static::HtmlToText($sText);
break;
default:
// Don't transform it
break;
}
// Then parse text to find objects
$aMentionedObjects = array();
$aMentionMatches = array();
// Note: As the sanitizer (or CKEditor autocomplete plugin? 🤔) removes data-* attributes from the hyperlink,
// - we can't use the following (simpler) regexp that only checks data attributes on hyperlinks, which would have worked for hyperlinks pointing to any GUIs: '/<a\s*([^>]*)data-object-class="([^"]*)"\s*data-object-id="([^"]*)">/i'
// - instead we use a regexp to match the following pattern '[Some object label](<APP_ROOT_URL>...&class=<OBJECT_CLASS>&id=<OBJECT_ID>...)' which only works for the backoffice
// If we change the sanitizer, we might want to switch to the other regexp as it's universal and easier to read
$sAppRootUrlForRegExp = addcslashes(utils::GetAbsoluteUrlAppRoot(), '/&');
preg_match_all("/\[([^\]]*)\]\({$sAppRootUrlForRegExp}[^\)]*\&class=([^\)\&]*)\&id=([\d]*)[^\)]*\)/i", $sText, $aMentionMatches);
foreach ($aMentionMatches[0] as $iMatchIdx => $sCompleteMatch) {
$sMatchedClass = $aMentionMatches[2][$iMatchIdx];
$sMatchedId = $aMentionMatches[3][$iMatchIdx];
// Prepare array for matched class if not already present
if (!array_key_exists($sMatchedClass, $aMentionedObjects)) {
$aMentionedObjects[$sMatchedClass] = array();
}
// Add matched ID if not already there
if (!in_array($sMatchedId, $aMentionedObjects[$sMatchedClass])) {
$aMentionedObjects[$sMatchedClass][] = $sMatchedId;
}
}
return $aMentionedObjects;
}
/**
* @param $sUrl
* @param string $sParamName
* @param string $sParamValue
*
* @return string
* @since 3.0.0
*/
public static function AddParameterToUrl(string $sUrl, string $sParamName, string $sParamValue): string
{
if (strpos($sUrl, '?') === false)
{
$sUrl = $sUrl.'?'.urlencode($sParamName).'='.urlencode($sParamValue);
}
else
{
$sUrl = $sUrl.'&'.urlencode($sParamName).'='.urlencode($sParamValue);
}
return $sUrl;
}
}

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/WebPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/WebPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/WebPage.php, now loadable using autoloader');

View File

@@ -350,7 +350,7 @@ class WizardHelper
*/
public function GetJsForUpdateFields()
{
$sWizardHelperJsVar = ($this->m_aData['m_sWizHelperJsVarName']) ?? 'oWizardHelper'.$this->GetFormPrefix();
$sWizardHelperJsVar = (!is_null($this->m_aData['m_sWizHelperJsVarName'])) ? utils::Sanitize($this->m_aData['m_sWizHelperJsVarName'], '', utils::ENUM_SANITIZATION_FILTER_PARAMETER) : 'oWizardHelper'.$this->GetFormPrefix();
$sWizardHelperJson = $this->ToJSON();
return <<<JS

View File

@@ -1,7 +1,8 @@
<?php
/**
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/XMLPage.php
* @deprecated will be removed in 3.1.0 - moved to sources/application/WebPage/XMLPage.php, now loadable using autoloader
* @license http://opensource.org/licenses/AGPL-3.0
* @copyright Copyright (C) 2010-2021 Combodo SARL
*/
DeprecatedCallsLog::NotifyDeprecatedFile('moved to sources/application/WebPage/XMLPage.php, now loadable using autoloader');

View File

@@ -3,4 +3,9 @@
define('APPROOT', dirname(__FILE__).'/');
define('APPCONF', APPROOT.'conf/');
/**
* iTop framework Version
*/
define('ITOP_DESIGN_LATEST_VERSION', '3.0');
require_once APPROOT.'bootstrap.inc.php';

View File

@@ -44,14 +44,9 @@ define('ITOP_DEFAULT_ENV', 'production');
define('MAINTENANCE_MODE_FILE', APPROOT.'data/.maintenance');
define('READONLY_MODE_FILE', APPROOT.'data/.readonly');
if (function_exists('microtime')) {
$fItopStarted = microtime(true);
} else {
$fItopStarted = 1000 * time();
}
$fItopStarted = microtime(true);
if (! isset($GLOBALS['bBypassAutoload']) || $GLOBALS['bBypassAutoload'] == false)
{
if (!isset($GLOBALS['bBypassAutoload']) || $GLOBALS['bBypassAutoload'] == false) {
require_once APPROOT.'/lib/autoload.php';
}
@@ -60,8 +55,7 @@ if (! isset($GLOBALS['bBypassAutoload']) || $GLOBALS['bBypassAutoload'] == false
//
// Use 'maintenance' parameter to bypass maintenance mode
if (!isset($bBypassMaintenance))
{
if (!isset($bBypassMaintenance)) {
$bBypassMaintenance = isset($_REQUEST['maintenance']) ? boolval($_REQUEST['maintenance']) : false;
}

View File

@@ -2,7 +2,7 @@
"type": "project",
"license": "AGPLv3",
"require": {
"php": ">=7.1.3",
"php": ">=7.1.3 <8.0.0",
"ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*",
@@ -11,9 +11,9 @@
"ext-mysqli": "*",
"ext-soap": "*",
"combodo/tcpdf": "6.3.5",
"nikic/php-parser": "^3.1",
"pear/archive_tar": "1.4.10",
"pelago/emogrifier": "2.1.0",
"nikic/php-parser": "^4.12.0",
"pear/archive_tar": "1.4.14",
"pelago/emogrifier": "3.1.0",
"scssphp/scssphp": "1.0.6",
"swiftmailer/swiftmailer": "5.4.12",
"symfony/console": "3.4.*",
@@ -37,24 +37,21 @@
},
"config": {
"platform": {
"php": "7.2.0"
"php": "7.1.3"
},
"vendor-dir": "lib",
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"classmap-authoritative": true
"classmap-authoritative": true,
"platform-check": true
},
"autoload": {
"classmap": [
"core",
"application",
"sources/application",
"sources/Composer",
"sources/Controller",
"sources/Form",
"sources/Renderer"
"sources"
],
"exclude-from-classmap": [
"core/dbobjectsearch.class.php",

128
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "27af144ea2acf2c138f587052a4ceddc",
"content-hash": "4c5cdd1e0feb4abaab8f86959ffc7a64",
"packages": [
{
"name": "combodo/tcpdf",
@@ -68,24 +68,25 @@
},
{
"name": "nikic/php-parser",
"version": "v3.1.5",
"version": "v4.12.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce"
"reference": "6608f01670c3cc5079e18c1dab1104e002579143"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce",
"reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143",
"reference": "6608f01670c3cc5079e18c1dab1104e002579143",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.5"
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
"ircmaxell/php-yacc": "^0.0.7",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
@@ -93,7 +94,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "4.9-dev"
}
},
"autoload": {
@@ -115,7 +116,11 @@
"parser",
"php"
],
"time": "2018-02-28T20:30:58+00:00"
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0"
},
"time": "2021-07-21T10:44:31+00:00"
},
{
"name": "paragonie/random_compat",
@@ -168,16 +173,16 @@
},
{
"name": "pear/archive_tar",
"version": "1.4.10",
"version": "1.4.14",
"source": {
"type": "git",
"url": "https://github.com/pear/Archive_Tar.git",
"reference": "bbb4f10f71a1da2715ec6d9a683f4f23c507a49b"
"reference": "4d761c5334c790e45ef3245f0864b8955c562caa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Archive_Tar/zipball/bbb4f10f71a1da2715ec6d9a683f4f23c507a49b",
"reference": "bbb4f10f71a1da2715ec6d9a683f4f23c507a49b",
"url": "https://api.github.com/repos/pear/Archive_Tar/zipball/4d761c5334c790e45ef3245f0864b8955c562caa",
"reference": "4d761c5334c790e45ef3245f0864b8955c562caa",
"shasum": ""
},
"require": {
@@ -230,7 +235,21 @@
"archive",
"tar"
],
"time": "2020-09-15T14:13:23+00:00"
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Archive_Tar",
"source": "https://github.com/pear/Archive_Tar"
},
"funding": [
{
"url": "https://github.com/mrook",
"type": "github"
},
{
"url": "https://www.patreon.com/michielrook",
"type": "patreon"
}
],
"time": "2021-07-20T13:53:39+00:00"
},
{
"name": "pear/console_getopt",
@@ -277,6 +296,10 @@
}
],
"description": "More info available on: http://pear.php.net/package/Console_Getopt",
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_Getopt",
"source": "https://github.com/pear/Console_Getopt"
},
"time": "2019-11-20T18:27:48+00:00"
},
{
@@ -321,27 +344,31 @@
}
],
"description": "Minimal set of PEAR core files to be used as composer dependency",
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR",
"source": "https://github.com/pear/pear-core-minimal"
},
"time": "2019-11-19T19:00:24+00:00"
},
{
"name": "pear/pear_exception",
"version": "v1.0.1",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/pear/PEAR_Exception.git",
"reference": "dbb42a5a0e45f3adcf99babfb2a1ba77b8ac36a7"
"reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/dbb42a5a0e45f3adcf99babfb2a1ba77b8ac36a7",
"reference": "dbb42a5a0e45f3adcf99babfb2a1ba77b8ac36a7",
"url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/b14fbe2ddb0b9f94f5b24cf08783d599f776fff0",
"reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0",
"shasum": ""
},
"require": {
"php": ">=4.4.0"
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "*"
"phpunit/phpunit": "<9"
},
"type": "class",
"extra": {
@@ -376,38 +403,42 @@
"keywords": [
"exception"
],
"time": "2019-12-10T10:24:42+00:00"
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception",
"source": "https://github.com/pear/PEAR_Exception"
},
"time": "2021-03-21T15:43:46+00:00"
},
{
"name": "pelago/emogrifier",
"version": "v2.1.0",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/MyIntervals/emogrifier.git",
"reference": "40c3d4f475d44ffc7265a760d1dd0e81f579f96f"
"reference": "f6a5c7d44612d86c3901c93f1592f5440e6b2cd8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/40c3d4f475d44ffc7265a760d1dd0e81f579f96f",
"reference": "40c3d4f475d44ffc7265a760d1dd0e81f579f96f",
"url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/f6a5c7d44612d86c3901c93f1592f5440e6b2cd8",
"reference": "f6a5c7d44612d86c3901c93f1592f5440e6b2cd8",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"php": "^5.5.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0",
"symfony/css-selector": "^3.4.0 || ^4.0.0"
"php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4",
"symfony/css-selector": "^2.8 || ^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2.0",
"phpmd/phpmd": "^2.6.0",
"phpunit/phpunit": "^4.8.0",
"squizlabs/php_codesniffer": "^3.3.2"
"friendsofphp/php-cs-fixer": "^2.15.3",
"phpmd/phpmd": "^2.7.0",
"phpunit/phpunit": "^5.7.27",
"squizlabs/php_codesniffer": "^3.5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
"dev-master": "4.0.x-dev"
}
},
"autoload": {
@@ -420,16 +451,6 @@
"MIT"
],
"authors": [
{
"name": "John Reeve",
"email": "jreeve@pelagodesign.com"
},
{
"name": "Cameron Brooks"
},
{
"name": "Jaime Prado"
},
{
"name": "Oliver Klee",
"email": "github@oliverklee.de"
@@ -438,9 +459,19 @@
"name": "Zoli Szabó",
"email": "zoli.szabo+github@gmail.com"
},
{
"name": "John Reeve",
"email": "jreeve@pelagodesign.com"
},
{
"name": "Jake Hotson",
"email": "jake@qzdesign.co.uk"
},
{
"name": "Cameron Brooks"
},
{
"name": "Jaime Prado"
}
],
"description": "Converts CSS styles into inline style attributes in your HTML code",
@@ -450,7 +481,11 @@
"email",
"pre-processing"
],
"time": "2018-12-08T13:55:46+00:00"
"support": {
"issues": "https://github.com/MyIntervals/emogrifier/issues",
"source": "https://github.com/MyIntervals/emogrifier"
},
"time": "2019-12-26T19:37:31+00:00"
},
{
"name": "psr/cache",
@@ -2578,7 +2613,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.6.0",
"php": ">=7.1.3 <8.0.0",
"ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*",
@@ -2589,6 +2624,7 @@
},
"platform-dev": [],
"platform-overrides": {
"php": "5.6.0"
}
"php": "7.1.3"
},
"plugin-api-version": "2.1.0"
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Core;
use mysqli;
/**
* mysqli object is really hard to mock as it contains lots of attributes & methods ! Thought we need to mock it to test transactions !
*
* To solve this, a new attribute exists and is only used in specific use cases, so there are just few things to mock.
*
* This object adds more readability than previous model with 2 attributes in {@see CMDBSource}.
*
* @used-by \CMDBSource
*
* @since 3.0.0 N°4325 Object creation
* This wrapper handles the 2 {@mysqli myqsli} attributes that were previously in {@see CMDBSource}
* To allow testing we added a second mysqli object (N°3513 in 2.7.5) and code became a bit confusing :/
* With this wrapper everything is in the same place, and we can express the intention more clearly !
*/
class DbConnectionWrapper
{
/** @var mysqli */
protected static $oDbCnxStandard;
/**
* Can contain a genuine mysqli object, or a mock that would emulate {@see mysqli::query()}
*
* @var mysqli
* @used-by \Combodo\iTop\Test\UnitTest\Core\TransactionsTest
*/
protected static $oDbCnxMockableForQuery;
/**
* @param bool $bIsForQuery set to true if using {@see mysqli::query()}
*
* @return \mysqli|null
*/
public static function GetDbConnection(bool $bIsForQuery = false): ?mysqli
{
if ($bIsForQuery) {
return static::$oDbCnxMockableForQuery;
}
return static::$oDbCnxStandard;
}
public static function SetDbConnection(?mysqli $oMysqli): void
{
static::$oDbCnxStandard = $oMysqli;
static::SetDbConnectionMockForQuery($oMysqli);
}
/**
* Use this to register a mock that will handle {@see mysqli::query()}
*
* @param \mysqli|null $oMysqli
*/
public static function SetDbConnectionMockForQuery(?mysqli $oMysqli): void
{
static::$oDbCnxMockableForQuery = $oMysqli;
}
}

View File

@@ -66,9 +66,8 @@ class MyHelpers
// getmicrotime()
// format sss.mmmuuupppnnn
public static function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
{
return microtime(true);
}
/*

View File

@@ -51,6 +51,7 @@ abstract class Action extends cmdbAbstractObject
"db_table" => "priv_action",
"db_key_field" => "id",
"db_finalclass_field" => "realclass",
'style' => new ormStyle(null, null, null, null, null, '../images/icons/icons8-in-transit.svg'),
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
@@ -366,8 +367,7 @@ class ActionEmail extends ActionNotification
{
$this->m_iRecipients = 0;
$this->m_aMailErrors = array();
$bRes = false; // until we do succeed in sending the email
// Determine recipients
//
$sTo = $this->FindRecipients('to', $aContextArgs);
@@ -381,29 +381,42 @@ class ActionEmail extends ActionNotification
$sSubject = MetaModel::ApplyParams($this->Get('subject'), $aContextArgs);
$sBody = MetaModel::ApplyParams($this->Get('body'), $aContextArgs);
$oObj = $aContextArgs['this->object()'];
$sMessageId = sprintf('iTop_%s_%d_%f@%s.openitop.org', get_class($oObj), $oObj->GetKey(), microtime(true /* get as float*/), MetaModel::GetEnvironmentId());
$sMessageId = sprintf('iTop_%s_%d_%f@%s.openitop.org', get_class($oObj), $oObj->GetKey(), microtime(true /* get as float*/),
MetaModel::GetEnvironmentId());
$sReference = '<'.$sMessageId.'>';
}
catch(Exception $e)
{
ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
throw $e;
}
ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
if (!is_null($oLog))
{
catch (Exception $e) {
/** @noinspection PhpUnhandledExceptionInspection */
throw $e;
}
finally {
ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
}
if (!is_null($oLog)) {
// Note: we have to secure this because those values are calculated
// inside the try statement, and we would like to keep track of as
// many data as we could while some variables may still be undefined
if (isset($sTo)) $oLog->Set('to', $sTo);
if (isset($sCC)) $oLog->Set('cc', $sCC);
if (isset($sBCC)) $oLog->Set('bcc', $sBCC);
if (isset($sFrom)) $oLog->Set('from', empty($sFromLabel) ? $sFrom : "$sFromLabel <$sFrom>");
if (isset($sSubject)) $oLog->Set('subject', $sSubject);
if (isset($sBody)) $oLog->Set('body', $sBody);
if (isset($sTo)) {
$oLog->Set('to', $sTo);
}
if (isset($sCC)) {
$oLog->Set('cc', $sCC);
}
if (isset($sBCC)) {
$oLog->Set('bcc', $sBCC);
}
if (isset($sFrom)) {
$oLog->Set('from', $sFrom);
}
if (isset($sSubject)) {
$oLog->Set('subject', $sSubject);
}
if (isset($sBody)) {
$oLog->Set('body', $sBody);
}
}
$sStyles = file_get_contents(APPROOT.'css/email.css');
$sStyles .= MetaModel::GetConfig()->Get('email_css');

View File

@@ -157,7 +157,7 @@ abstract class AsyncTask extends DBObject
if (is_array($aRetries) && array_key_exists(get_class($this), $aRetries))
{
$aConfig = $aRetries[get_class($this)];
$iRetryDelay = $aConfig['retry_delay'];
$iRetryDelay = $aConfig['retry_delay'] ?? $iRetryDelay;
}
return $iRetryDelay;
}
@@ -169,11 +169,71 @@ abstract class AsyncTask extends DBObject
if (is_array($aRetries) && array_key_exists(get_class($this), $aRetries))
{
$aConfig = $aRetries[get_class($this)];
$iMaxRetries = $aConfig['max_retries'];
$iMaxRetries = $aConfig['max_retries'] ?? $iMaxRetries;
}
return $iMaxRetries;
}
public function IsRetryDelayExponential()
{
$bExponential = false;
$aRetries = MetaModel::GetConfig()->Get('async_task_retries');
if (is_array($aRetries) && array_key_exists(get_class($this), $aRetries))
{
$aConfig = $aRetries[get_class($this)];
$bExponential = (bool)$aConfig['exponential_delay'] ?? $bExponential;
}
return $bExponential;
}
public static function CheckRetryConfig(Config $oConfig, $sAsyncTaskClass)
{
$aMessages = [];
$aRetries = $oConfig->Get('async_task_retries');
if (is_array($aRetries) && array_key_exists($sAsyncTaskClass, $aRetries))
{
$aValidKeys = array("retry_delay", "max_retries", "exponential_delay");
$aConfig = $aRetries[$sAsyncTaskClass];
if (!is_array($aConfig))
{
$aMessages[] = Dict::Format('Class:AsyncTask:InvalidConfig_Class_Keys', $sAsyncTaskClass, implode(', ', $aValidKeys));
}
else
{
foreach($aConfig as $key => $value)
{
if (!in_array($key, $aValidKeys))
{
$aMessages[] = Dict::Format('Class:AsyncTask:InvalidConfig_Class_InvalidKey_Keys', $sAsyncTaskClass, $key, implode(', ', $aValidKeys));
}
}
}
}
return $aMessages;
}
/**
* Compute the delay to wait for the "next retry", based on the given parameters
* @param bool $bIsExponential
* @param int $iRetryDelay
* @param int $iMaxRetries
* @param int $iRemainingRetries
* @return int
*/
public static function GetNextRetryDelay($bIsExponential, $iRetryDelay, $iMaxRetries, $iRemainingRetries)
{
if ($bIsExponential)
{
$iExponent = $iMaxRetries - $iRemainingRetries;
if ($iExponent < 0) $iExponent = 0; // Safety net in case on configuration change in the middle of retries
return $iRetryDelay * (2 ** $iExponent);
}
else
{
return $iRetryDelay;
}
}
/**
* Override to notify people that a task cannot be performed
*/
@@ -241,25 +301,26 @@ abstract class AsyncTask extends DBObject
if ($iRemaining > 0)
{
$iRetryDelay = $this->GetRetryDelay($iErrorCode);
IssueLog::Info('Failed to process async task #'.$this->GetKey().' - reason: '.$sErrorMessage.' - remaining retries: '.$iRemaining.' - next retry in '.$iRetryDelay.'s');
$iNextRetryDelay = static::GetNextRetryDelay($this->IsRetryDelayExponential(), $iRetryDelay, $this->GetMaxRetries($iErrorCode), $iRemaining);
IssueLog::Info('Failed to process async task #'.$this->GetKey().' - reason: '.$sErrorMessage.' - remaining retries: '.$iRemaining.' - next retry in '.$iNextRetryDelay.'s');
if ($this->Get('event_id') != 0)
{
$oEventLog = MetaModel::GetObject('Event', $this->Get('event_id'));
$oEventLog->Set('message', "$sErrorMessage\nFailed to process async task. Remaining retries: '.$iRemaining.'. Next retry in '.$iRetryDelay.'s'");
$oEventLog->Set('message', "$sErrorMessage\nFailed to process async task. Remaining retries: $iRemaining. Next retry in {$iNextRetryDelay}s");
try
{
$oEventLog->DBUpdate();
}
catch (Exception $e)
{
$oEventLog->Set('message', "Failed to process async task. Remaining retries: '.$iRemaining.'. Next retry in '.$iRetryDelay.'s', more details in the log");
$oEventLog->Set('message', "Failed to process async task. Remaining retries: $iRemaining. Next retry in {$iNextRetryDelay}s, more details in the log");
$oEventLog->DBUpdate();
}
}
$this->Set('remaining_retries', $iRemaining - 1);
$this->Set('status', 'planned');
$this->Set('started', null);
$this->Set('planned', time() + $iRetryDelay);
$this->Set('planned', time() + $iNextRetryDelay);
}
else
{
@@ -388,7 +449,12 @@ class AsyncSendEmail extends AsyncTask
return "Bug - the email should be sent in synchronous mode";
case EMAIL_SEND_ERROR:
return "Failed: ".implode(', ', $aIssues);
if (is_array($aIssues)) {
$sMessage = "Sending eMail failed: ".implode(', ', $aIssues);
} else {
$sMessage = "Sending eMail failed.";
}
throw new Exception($sMessage);
}
return '';
}

View File

@@ -1,25 +1,13 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\UI\Base\Component\FieldBadge\FieldBadgeUIBlockFactory;
use Combodo\iTop\Form\Field\LabelField;
use Combodo\iTop\Form\Field\TextAreaField;
use Combodo\iTop\Form\Form;
use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
use Combodo\iTop\Form\Validator\Validator;
use Combodo\iTop\Renderer\BlockRenderer;
@@ -317,6 +305,8 @@ abstract class AttributeDefinition
*/
public function ListDBJoins()
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
return "";
// e.g: return array("Site", "infrid", "name");
}
@@ -842,9 +832,9 @@ abstract class AttributeDefinition
*/
public function MakeValue()
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
$sComputeFunc = $this->Get("compute_func");
if (empty($sComputeFunc))
{
if (empty($sComputeFunc)) {
return null;
}
@@ -1803,7 +1793,7 @@ class AttributeLinkedSet extends AttributeDefinition
public function GetImportColumns()
{
$aColumns = array();
$aColumns[$this->GetCode()] = 'TEXT';
$aColumns[$this->GetCode()] = 'TEXT'.CMDBSource::GetSqlStringColumnDefinition();
return $aColumns;
}
@@ -4133,7 +4123,8 @@ class AttributeText extends AttributeString
{
// Propose a std link to the object
$sClassLabel = MetaModel::GetName($sClass);
$sReplacement = "<span class=\"wiki_broken_link\">$sClassLabel:$sName" . (!empty($sLabel) ? " ($sLabel)" : "") . "</span>";
$sToolTipForHtml = utils::EscapeHtml(Dict::Format('Core:UnknownObjectLabel', $sClass, $sName));
$sReplacement = "<span class=\"wiki_broken_link ibo-is-broken-hyperlink\" data-tooltip-content=\"$sToolTipForHtml\">$sClassLabel:$sName" . (!empty($sLabel) ? " ($sLabel)" : "") . "</span>";
$sText = str_replace($aMatches[0], $sReplacement, $sText);
// Later: propose a link to create a new object
// Anyhow... there is no easy way to suggest default values based on the given FRIENDLY name
@@ -4168,14 +4159,15 @@ class AttributeText extends AttributeString
{
$sValue = parent::GetAsHTML($sValue, $oHostObject, $bLocalize);
$sValue = self::RenderWikiHtml($sValue);
$sValue = nl2br($sValue);
return "<div $sStyle>".str_replace("\n", "<br>\n", $sValue).'</div>';
return "<div $sStyle>$sValue</div>";
}
else
{
$sValue = self::RenderWikiHtml($sValue, true /* wiki only */);
return "<div class=\"HTML\" $sStyle>".InlineImage::FixUrls($sValue).'</div>';
return "<div class=\"HTML ibo-is-html-content\" $sStyle>".InlineImage::FixUrls($sValue).'</div>';
}
}
@@ -6003,7 +5995,7 @@ class AttributeDateTime extends AttributeDBField
{
// Allow an empty string to be a valid value (synonym for "reset")
$aColumns = array();
$aColumns[$this->GetCode()] = 'VARCHAR(19)';
$aColumns[$this->GetCode()] = 'VARCHAR(19)'.CMDBSource::GetSqlStringColumnDefinition();
return $aColumns;
}
@@ -6491,7 +6483,7 @@ class AttributeDate extends AttributeDateTime
{
// Allow an empty string to be a valid value (synonym for "reset")
$aColumns = array();
$aColumns[$this->GetCode()] = 'VARCHAR(10)';
$aColumns[$this->GetCode()] = 'VARCHAR(10)'.CMDBSource::GetSqlStringColumnDefinition();
return $aColumns;
}
@@ -6818,23 +6810,6 @@ class AttributeExternalKey extends AttributeDBFieldVoid
return (int)$proposedValue;
}
public function GetPrerequisiteAttributes($sClass = null)
{
$aAttributes = parent::GetPrerequisiteAttributes($sClass);
$oExpression = DBSearch::FromOQL($this->GetValuesDef()->GetFilterExpression())->GetCriteria();
foreach ($oExpression->GetParameters('this') as $sAttCode)
{
// Skip the id as it cannot change anyway
if ($sAttCode =='id') continue;
if (!in_array($sAttCode, $aAttributes))
{
$aAttributes[] = $sAttCode;
}
}
return $aAttributes;
}
public function GetMaximumComboLength()
{
return $this->GetOptional('max_combo_length', MetaModel::GetConfig()->Get('max_combo_length'));
@@ -8155,6 +8130,25 @@ class AttributeImage extends AttributeBlob
return "Image";
}
/**
* {@inheritDoc}
* @see AttributeBlob::MakeRealValue()
*/
public function MakeRealValue($proposedValue, $oHostObj)
{
$oDoc = parent::MakeRealValue($proposedValue, $oHostObj);
if (($oDoc instanceof ormDocument)
&& (false === $oDoc->IsEmpty())
&& ($oDoc->GetMimeType() === 'image/svg+xml')) {
$sCleanSvg = HTMLSanitizer::Sanitize($oDoc->GetData(), 'svg_sanitizer');
$oDoc = new ormDocument($sCleanSvg, $oDoc->GetMimeType(), $oDoc->GetFileName());
}
// The validation of the MIME Type is done by CheckFormat below
return $oDoc;
}
/**
* Check that the supplied ormDocument actually contains an image
* {@inheritDoc}
@@ -8185,24 +8179,27 @@ class AttributeImage extends AttributeBlob
$sRet = '';
$bIsCustomImage = false;
$iMaxWidthPx = $this->Get('display_max_width').'px';
$iMaxHeightPx = $this->Get('display_max_height').'px';
$iMaxWidth = $this->Get('display_max_width');
$sMaxWidthPx = $iMaxWidth.'px';
$iMaxHeight = $this->Get('display_max_height');
$sMaxHeightPx = $iMaxHeight.'px';
$sDefaultImageUrl = $this->Get('default_image');
if ($sDefaultImageUrl !== null) {
$sRet = $this->GetHtmlForImageUrl($sDefaultImageUrl, $iMaxWidthPx, $iMaxHeightPx);
$sRet = $this->GetHtmlForImageUrl($sDefaultImageUrl, $sMaxWidthPx, $sMaxHeightPx);
}
$sCustomImageUrl = $this->GetAttributeImageFileUrl($value, $oHostObject);
if ($sCustomImageUrl !== null) {
$bIsCustomImage = true;
$sRet = $this->GetHtmlForImageUrl($sCustomImageUrl, $iMaxWidthPx, $iMaxHeightPx);
$sRet = $this->GetHtmlForImageUrl($sCustomImageUrl, $sMaxWidthPx, $sMaxHeightPx);
}
$sCssClasses = 'ibo-input-image--image-view attribute-image';
$sCssClasses .= ' '.(($bIsCustomImage) ? 'attribute-image-custom' : 'attribute-image-default');
return '<div class="'.$sCssClasses.'" style="width: '.$iMaxWidthPx.'; height: '.$iMaxHeightPx.';">'.$sRet.'</div>';
// Important: If you change this, mind updating edit_image.js as well
return '<div class="'.$sCssClasses.'" style="max-width: '.$sMaxWidthPx.'; max-height: '.$sMaxHeightPx.'; aspect-ratio: '.$iMaxWidth.' / '.$iMaxHeight.'">'.$sRet.'</div>';
}
/**
@@ -10309,7 +10306,6 @@ abstract class AttributeSet extends AttributeDBFieldVoid
} else {
$sTooltipContent = <<<HTML
<h4>$sLabel</h4>
<br>
<div>$sDescription</div>
HTML;
$sTooltipHtmlEnabled = 'true';
@@ -10856,7 +10852,7 @@ class AttributeClassAttCodeSet extends AttributeSet
}
}
$sLabelForHtmlAttribute = MetaModel::GetLabel($sAttClass, $sAttCode)." ($sAttCode)";
$sLabelForHtmlAttribute = utils::HtmlEntities(MetaModel::GetLabel($sAttClass, $sAttCode)." ($sAttCode)");
$aLocalizedValues[] = '<span class="attribute-set-item" data-code="'.$sAttCode.'" data-label="'.$sLabelForHtmlAttribute.'" data-description="" data-tooltip-content="'.$sLabelForHtmlAttribute.'">'.$sAttCode.'</span>';
} catch (Exception $e)
{
@@ -11049,7 +11045,7 @@ class AttributeQueryAttCodeSet extends AttributeSet
$aLocalizedValues = array();
foreach ($value as $sAttCode) {
if (isset($aAllowedAttributes[$sAttCode])) {
$sLabelForHtmlAttribute = $aAllowedAttributes[$sAttCode];
$sLabelForHtmlAttribute = utils::HtmlEntities($aAllowedAttributes[$sAttCode]);
$aLocalizedValues[] = '<span class="attribute-set-item" data-code="'.$sAttCode.'" data-label="'.$sLabelForHtmlAttribute.'" data-description="" data-tooltip-content="'.$sLabelForHtmlAttribute.'">'.$sAttCode.'</span>';
}
}
@@ -11598,20 +11594,20 @@ class AttributeTagSet extends AttributeSet
$sTooltipContent = $sTagLabel;
$sTooltipHtmlEnabled = 'false';
} else {
$sTagLabelEscaped = utils::EscapeHtml($sTagLabel);
$sTooltipContent = <<<HTML
<h4>$sTagLabel</h4>
<br>
<h4>$sTagLabelEscaped</h4>
<div>$sTagDescription</div>
HTML;
$sTooltipHtmlEnabled = 'true';
}
$sTooltipContent = utils::EscapeHtml($sTooltipContent);
$sTooltipContent = utils::HtmlEntities($sTooltipContent);
$sHtml .= '<a'.$sLink.' class="attribute-set-item attribute-set-item-'.$sTagCode.'" data-code="'.$sTagCode.'" data-label="'.$sLabelForHtml.'" data-description="'.$sDescriptionForHtml.'" data-tooltip-content="'.$sTooltipContent.'" data-tooltip-html-enabled="'.$sTooltipHtmlEnabled.'">'.$sLabelForHtml.'</a>';
}
else
{
$sHtml .= '<span class="attribute-set-item">'.$oTag.'</span>';
$sHtml .= '<span class="attribute-set-item">'.utils::EscapeHtml($oTag).'</span>';
}
}
$sHtml .= '</span>';
@@ -11804,13 +11800,12 @@ class AttributeFriendlyName extends AttributeDefinition
// Code duplicated with AttributeObsolescenceFlag
$aAttributes = $this->GetOptional("depends_on", array());
$oExpression = $this->GetOQLExpression();
foreach ($oExpression->ListRequiredFields() as $sClass => $sAttCode)
{
if (!in_array($sAttCode, $aAttributes))
{
foreach ($oExpression->ListRequiredFields() as $sAttCode) {
if (!in_array($sAttCode, $aAttributes)) {
$aAttributes[] = $sAttCode;
}
}
return $aAttributes;
}
@@ -12572,10 +12567,12 @@ class AttributeCustomFields extends AttributeDefinition
*/
public function ReadValueFromPostedForm($oHostObject, $sFormPrefix)
{
$aRawData = json_decode(utils::ReadPostedParam("attr_{$sFormPrefix}{$this->GetCode()}", '{}', 'raw_data'),
true);
return new ormCustomFieldsValue($oHostObject, $this->GetCode(), $aRawData);
$aRawData = json_decode(utils::ReadPostedParam("attr_{$sFormPrefix}{$this->GetCode()}", '{}', 'raw_data'), true);
if ($aRawData != null) {
return new ormCustomFieldsValue($oHostObject, $this->GetCode(), $aRawData);
} else{
return null;
}
}
public function MakeRealValue($proposedValue, $oHostObject)
@@ -12634,16 +12631,15 @@ class AttributeCustomFields extends AttributeDefinition
*/
public function GetForm(DBObject $oHostObject, $sFormPrefix = null)
{
try
{
try {
$oValue = $oHostObject->Get($this->GetCode());
$oHandler = $this->GetHandler($oValue->GetValues());
$sFormId = is_null($sFormPrefix) ? 'cf_'.$this->GetCode() : $sFormPrefix.'_cf_'.$this->GetCode();
$oHandler->BuildForm($oHostObject, $sFormId);
$oForm = $oHandler->GetForm();
} catch (Exception $e)
{
$oForm = new \Combodo\iTop\Form\Form('');
}
catch (Exception $e) {
$oForm = new Form('');
$oField = new LabelField('');
$oField->SetLabel('Custom field error: '.$e->getMessage());
$oForm->AddField($oField);

View File

@@ -452,20 +452,23 @@ class BulkChange
foreach ($this->m_aAttList as $sAttCode => $iCol)
{
// skip the private key, if any
if ($sAttCode == 'id') continue;
if (($sAttCode == 'id') || ($sAttCode == 'friendlyname')) {
continue;
}
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
// skip reconciliation keys
if (!$oAttDef->IsWritable() && in_array($sAttCode, $this->m_aReconcilKeys)){ continue; }
if (!$oAttDef->IsWritable() && in_array($sAttCode, $this->m_aReconcilKeys)) {
continue;
}
$aReasons = array();
$iFlags = ($oTargetObj->IsNew())
? $oTargetObj->GetInitialStateAttributeFlags($sAttCode, $aReasons)
: $oTargetObj->GetAttributeFlags($sAttCode, $aReasons);
if ( (($iFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY) && ( $oTargetObj->Get($sAttCode) != $aRowData[$iCol]) )
{
$aErrors[$sAttCode] = Dict::Format('UI:CSVReport-Value-Issue-Readonly', $sAttCode, $oTargetObj->Get($sAttCode), $aRowData[$iCol]);
if ( (($iFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY) && ( $oTargetObj->Get($sAttCode) != $aRowData[$iCol]) ) {
$aErrors[$sAttCode] = Dict::Format('UI:CSVReport-Value-Issue-Readonly', $sAttCode, $oTargetObj->Get($sAttCode), $aRowData[$iCol]);
}
else if ($oAttDef->IsLinkSet() && $oAttDef->IsIndirect())
{
@@ -1180,25 +1183,22 @@ class BulkChange
$oPage->add('<p>'.$sCollapsedLabel.'&nbsp;&nbsp;<a class="truncated" onclick="OnTruncatedHistoryToggle(true);">'.$sLinkLabel.'</p>');
$oPage->add_ready_script(
<<<EOF
<<<EOF
$('#$sAjaxDivId table.listResults').addClass('truncated');
$('#$sAjaxDivId table.listResults tr:last td').addClass('truncated');
EOF
);
$sAppContext = $oAppContext->GetForLink();
$oPage->add_script(
<<<EOF
<<<EOF
function OnTruncatedHistoryToggle(bShowAll)
{
$('#csv_history_reload').html('<img src="../images/indicator.gif"/>');
$.get(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?{$sAppContext}', {operation: 'displayCSVHistory', showall: bShowAll}, function(data)
{
$('#$sAjaxDivId').html(data);
var table = $('#$sAjaxDivId .listResults');
table.tableHover(); // hover tables
table.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
}
);
}

View File

@@ -376,10 +376,11 @@ abstract class BulkExport
}
/**
* @deprecated since 3.0 replaced by GetFormPart
* @deprecated 3.0.0 use GetFormPart instead
*/
public function DisplayFormPart(WebPage $oP, $sPartId)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use GetFormPart instead');
$oP->AddSubBlock($this->GetFormPart($oP, $sPartId));
}

View File

@@ -1,22 +1,4 @@
<?php
// Copyright (C) 2010-2021 Combodo SARL
//
// This file is part of iTop.
//
// iTop is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// iTop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
/**
* Persistent class (internal) cmdbChange
*
@@ -24,6 +6,7 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
/**
* A change as requested/validated at once by user, may groups many atomic changes
@@ -53,7 +36,7 @@ class CMDBChange extends DBObject
MetaModel::Init_AddAttribute(new AttributeDateTime("date", array("allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("user_id", array("allowed_values"=>null, "sql"=>"user_id", "targetclass"=>"User", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("origin", array("allowed_values"=>new ValueSetEnum('interactive,csv-interactive,csv-import.php,webservice-soap,webservice-rest,synchro-data-source,email-processing,custom-extension'), "sql"=>"origin", "default_value"=>"interactive", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("origin", array("allowed_values"=>new ValueSetEnum(implode(',', [CMDBChangeOrigin::INTERACTIVE, CMDBChangeOrigin::CSV_INTERACTIVE, CMDBChangeOrigin::CSV_IMPORT, CMDBChangeOrigin::WEBSERVICE_SOAP, CMDBChangeOrigin::WEBSERVICE_REST, CMDBChangeOrigin::SYNCHRO_DATA_SOURCE, CMDBChangeOrigin::EMAIL_PROCESSING, CMDBChangeOrigin::CUSTOM_EXTENSION])), "sql"=>"origin", "default_value"=>CMDBChangeOrigin::INTERACTIVE, "is_null_allowed"=>true, "depends_on"=>array())));
}
/**

View File

@@ -436,28 +436,31 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
{
if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode')))
{
if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) {
$oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode'));
$sAttName = $oAttDef->GetLabel();
}
else
{
} else {
// The attribute was renamed or removed from the object ?
$sAttName = $this->Get('attcode');
}
/** @var \ormDocument $oPrevDoc */
$oPrevDoc = $this->Get('prevdata');
if ($oPrevDoc->IsEmpty())
{
if ($oPrevDoc->IsEmpty()) {
$sPrevious = '';
$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sPrevious);
}
else
{
$sDocView = $oPrevDoc->GetAsHtml();
$sDocView .= "<br/>".Dict::Format('UI:OpenDocumentInNewWindow_', $oPrevDoc->GetDisplayLink(get_class($this), $this->GetKey(), 'prevdata')).", \n";
$sDocView .= Dict::Format('UI:DownloadDocument_', $oPrevDoc->GetDownloadLink(get_class($this), $this->GetKey(), 'prevdata'))."\n";
//$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata');
} else {
$sFieldAsHtml = $oPrevDoc->GetAsHTML();
$sDisplayLabel = Dict::S('UI:OpenDocumentInNewWindow_');
$sDisplayUrl = $oPrevDoc->GetDisplayURL(get_class($this), $this->GetKey(), 'prevdata');
$sDownloadLabel = Dict::Format('UI:DownloadDocument_');
$sDownloadUrl = $oPrevDoc->GetDownloadURL(get_class($this), $this->GetKey(), 'prevdata');
$sDocView = <<<HTML
{$sFieldAsHtml}
<a href="{$sDisplayUrl}" target="_blank">{$sDisplayLabel}</a> / <a href="{$sDownloadUrl}">{$sDownloadLabel}</a>
HTML;
$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sDocView);
}
}
@@ -770,18 +773,15 @@ class CMDBChangeOpSetAttributeHTML extends CMDBChangeOpSetAttributeLongText
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
{
if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode')))
{
if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) {
$oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode'));
$sAttName = $oAttDef->GetLabel();
}
else
{
} else {
// The attribute was renamed or removed from the object ?
$sAttName = $this->Get('attcode');
}
$sTextView = '<div class="history_entry history_entry_truncated"><div class="history_html_content">'.$this->Get('prevdata').'</div></div>';
$sTextView = $this->Get('prevdata');
//$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata');
$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sTextView);
}

View File

@@ -566,8 +566,8 @@ abstract class CMDBObject extends DBObject
*/
protected function CheckUserRights($bSkipStrongSecurity, $iActionCode)
{
if (is_null($bSkipStrongSecurity))
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
if (is_null($bSkipStrongSecurity)) {
// This is temporary
// We have implemented this safety net right before releasing iTop 1.0
// and we decided that it was too risky to activate it

View File

@@ -24,13 +24,15 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Core\DbConnectionWrapper;
require_once('MyHelpers.class.inc.php');
require_once(APPROOT.'core/kpi.class.inc.php');
/**
* CMDBSource
* database access wrapper
* database access wrapper
*
* @package iTopORM
*/
@@ -66,9 +68,6 @@ class CMDBSource
*/
protected static $m_sDBTlsCA;
/** @var mysqli $m_oMysqli */
protected static $m_oMysqli;
/**
* @var int number of level for nested transactions : 0 if no transaction was ever opened, +1 for each 'START TRANSACTION' sent
* @since 2.7.0 N°679
@@ -133,7 +132,8 @@ class CMDBSource
self::$m_bDBTlsEnabled = empty($bTlsEnabled) ? false : $bTlsEnabled;
self::$m_sDBTlsCA = empty($sTlsCA) ? null : $sTlsCA;
self::$m_oMysqli = self::GetMysqliInstance($sServer, $sUser, $sPwd, $sSource, $bTlsEnabled, $sTlsCA, true);
$oMysqli = self::GetMysqliInstance($sServer, $sUser, $sPwd, $sSource, $bTlsEnabled, $sTlsCA, true);
DbConnectionWrapper::SetDbConnection($oMysqli);
}
/**
@@ -147,12 +147,12 @@ class CMDBSource
*
* @return \mysqli
* @throws \MySQLException
*
* @uses IsOpenedDbConnectionUsingTls when asking for a TLS connection, to check if it was really opened using TLS
*/
public static function GetMysqliInstance(
$sDbHost, $sUser, $sPwd, $sSource = '', $bTlsEnabled = false, $sTlsCa = null, $bCheckTlsAfterConnection = false
) {
$oMysqli = null;
$sServer = null;
$iPort = null;
self::InitServerAndPort($sDbHost, $sServer, $iPort);
@@ -182,7 +182,7 @@ class CMDBSource
}
catch(mysqli_sql_exception $e)
{
throw new MySQLException('Could not connect to the DB server', array('host' => $sServer, 'user' => $sUser), $e);
throw new MySQLException('Could not connect to the DB server', array('host' => $sServer, 'user' => $sUser),$e);
}
if ($bTlsEnabled
@@ -251,41 +251,41 @@ class CMDBSource
* parameters were used.<br>
* This method can be called to ensure that the DB connection really uses TLS.
*
* <p>We're using this object connection : {@link self::$m_oMysqli}
* <p>We're using our own mysqli instance to do the check as this check is done when creating the mysqli instance : the consumer
* might want a dedicated object, and if so we don't want to overwrite the one saved in CMDBSource !<br>
* This is the case for example with {@see \iTopMutex} !
*
* @param \mysqli $oMysqli
*
* @return boolean true if the connection was really established using TLS
* @return boolean true if the connection was really established using TLS, false otherwise
* @throws \MySQLException
*
* @used-by GetMysqliInstance
* @uses IsMySqlVarNonEmpty
* @uses 'ssl_version' MySQL var
* @uses 'ssl_cipher' MySQL var
*/
private static function IsOpenedDbConnectionUsingTls($oMysqli)
{
if (self::$m_oMysqli == null)
{
self::$m_oMysqli = $oMysqli;
}
$bNonEmptySslVersionVar = self::IsMySqlVarNonEmpty('ssl_version');
$bNonEmptySslCipherVar = self::IsMySqlVarNonEmpty('ssl_cipher');
$bNonEmptySslVersionVar = self::IsMySqlVarNonEmpty('ssl_version', $oMysqli);
$bNonEmptySslCipherVar = self::IsMySqlVarNonEmpty('ssl_cipher', $oMysqli);
return ($bNonEmptySslVersionVar && $bNonEmptySslCipherVar);
}
/**
* @param string $sVarName
* @param mysqli $oMysqli connection to use for the query
*
* @return bool
* @throws \MySQLException
*
* @uses SHOW STATUS queries
* @uses 'SHOW SESSION STATUS' queries
*/
private static function IsMySqlVarNonEmpty($sVarName)
private static function IsMySqlVarNonEmpty($sVarName, $oMysqli)
{
try
{
$sResult = self::QueryToScalar("SHOW SESSION STATUS LIKE '$sVarName'", 1);
$sResult = self::QueryToScalar("SHOW SESSION STATUS LIKE '$sVarName'", 1, $oMysqli);
}
catch (MySQLQueryHasNoResultException $e)
{
@@ -344,7 +344,8 @@ class CMDBSource
{
// In case we don't have rights to enumerate the databases
// Let's try to connect directly
return @((bool)self::$m_oMysqli->query("USE `$sSource`"));
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
return @((bool)DbConnectionWrapper::GetDbConnection(true)->query("USE `$sSource`"));
}
}
@@ -360,7 +361,7 @@ class CMDBSource
*/
public static function GetServerInfo()
{
return mysqli_get_server_info ( self::$m_oMysqli );
return mysqli_get_server_info(DbConnectionWrapper::GetDbConnection());
}
/**
@@ -391,9 +392,9 @@ class CMDBSource
*/
public static function SelectDB($sSource)
{
if (!((bool)self::$m_oMysqli->query("USE `$sSource`")))
{
throw new MySQLException('Could not select DB', array('db_name'=>$sSource));
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
if (!((bool)DbConnectionWrapper::GetDbConnection(true)->query("USE `$sSource`"))) {
throw new MySQLException('Could not select DB', array('db_name' => $sSource));
}
self::$m_sDBName = $sSource;
}
@@ -444,33 +445,29 @@ class CMDBSource
/**
* @return \mysqli
*
* @since 2.5.0 N°1260
*/
public static function GetMysqli()
{
return self::$m_oMysqli;
return DbConnectionWrapper::GetDbConnection(false);
}
public static function GetErrNo()
{
if (self::$m_oMysqli->errno != 0)
{
return self::$m_oMysqli->errno;
}
else
{
return self::$m_oMysqli->connect_errno;
if (DbConnectionWrapper::GetDbConnection()->errno != 0) {
return DbConnectionWrapper::GetDbConnection()->errno;
} else {
return DbConnectionWrapper::GetDbConnection()->connect_errno;
}
}
public static function GetError()
{
if (self::$m_oMysqli->error != '')
{
return self::$m_oMysqli->error;
}
else
{
return self::$m_oMysqli->connect_error;
if (DbConnectionWrapper::GetDbConnection()->error != '') {
return DbConnectionWrapper::GetDbConnection()->error;
} else {
return DbConnectionWrapper::GetDbConnection()->connect_error;
}
}
@@ -510,7 +507,8 @@ class CMDBSource
// Quote if not a number or a numeric string
if ($bAlways || is_string($value))
{
$value = $cQuoteStyle . self::$m_oMysqli->real_escape_string($value) . $cQuoteStyle;
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$value = $cQuoteStyle.DbConnectionWrapper::GetDbConnection()->real_escape_string($value).$cQuoteStyle;
}
return $value;
}
@@ -571,7 +569,7 @@ class CMDBSource
/**
* Send the query directly to the DB. **Be extra cautious with this !**
*
* Use {@link Query} if you're not sure.
* Use {@see Query} if you're not sure.
*
* @internal
*
@@ -585,29 +583,33 @@ class CMDBSource
*/
private static function DBQuery($sSql)
{
$sShortSQL = substr(preg_replace("/\s+/", " ", substr($sSql, 0, 180)), 0, 150);
if (substr_compare($sShortSQL, "SELECT", 0, strlen("SELECT")) !== 0) {
IssueLog::Trace("$sShortSQL", LogChannels::CMDB_SOURCE);
}
$oKPI = new ExecutionKPI();
try
{
$oResult = self::$m_oMysqli->query($sSql);
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oResult = DbConnectionWrapper::GetDbConnection(true)->query($sSql);
}
catch (mysqli_sql_exception $e)
{
self::LogDeadLock($e);
self::LogDeadLock($e, true);
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql, $e));
}
$oKPI->ComputeStats('Query exec (mySQL)', $sSql);
if ($oResult === false)
{
if ($oResult === false) {
$aContext = array('query' => $sSql);
$iMySqlErrorNo = self::$m_oMysqli->errno;
$iMySqlErrorNo = DbConnectionWrapper::GetDbConnection(true)->errno;
$aMySqlHasGoneAwayErrorCodes = MySQLHasGoneAwayException::getErrorCodes();
if (in_array($iMySqlErrorNo, $aMySqlHasGoneAwayErrorCodes))
{
if (in_array($iMySqlErrorNo, $aMySqlHasGoneAwayErrorCodes)) {
throw new MySQLHasGoneAwayException(self::GetError(), $aContext);
}
$e = new MySQLException('Failed to issue SQL query', $aContext);
self::LogDeadLock($e);
self::LogDeadLock($e, true);
throw $e;
}
@@ -616,23 +618,24 @@ class CMDBSource
/**
* @param \Exception $e
* @param bool $bForQuery to get the proper DB connection
*
* @since 2.7.1
* @since 3.0.0 N°4325 add new optional parameter to use the correct DB connection
*/
private static function LogDeadLock(Exception $e)
private static function LogDeadLock(Exception $e, $bForQuery = false)
{
// checks MySQL error code
$iMySqlErrorNo = self::$m_oMysqli->errno;
if (!in_array($iMySqlErrorNo, array(self::MYSQL_ERRNO_WAIT_TIMEOUT, self::MYSQL_ERRNO_DEADLOCK)))
{
$iMySqlErrorNo = DbConnectionWrapper::GetDbConnection($bForQuery)->errno;
if (!in_array($iMySqlErrorNo, array(self::MYSQL_ERRNO_WAIT_TIMEOUT, self::MYSQL_ERRNO_DEADLOCK))) {
return;
}
// Get error info
$sUser = UserRights::GetUser();
$oError = self::$m_oMysqli->query('SHOW ENGINE INNODB STATUS');
if ($oError !== false)
{
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oError = DbConnectionWrapper::GetDbConnection(true)->query('SHOW ENGINE INNODB STATUS');
if ($oError !== false) {
$aData = $oError->fetch_all(MYSQLI_ASSOC);
$sInnodbStatus = $aData[0];
}
@@ -652,7 +655,7 @@ class CMDBSource
);
DeadLockLog::Info($sMessage, $iMySqlErrorNo, $aLogContext);
IssueLog::Error($sMessage, 'DeadLock', $e->getMessage());
IssueLog::Error($sMessage, LogChannels::DEADLOCK, $e->getMessage());
}
/**
@@ -668,10 +671,14 @@ class CMDBSource
*/
private static function StartTransaction()
{
$aStackTrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT , 3);
$sCaller = 'From '.$aStackTrace[1]['file'].'('.$aStackTrace[1]['line'].'): '.$aStackTrace[2]['class'].'->'.$aStackTrace[2]['function'].'()';
$bHasExistingTransactions = self::IsInsideTransaction();
if (!$bHasExistingTransactions)
{
if (!$bHasExistingTransactions) {
IssueLog::Trace("START TRANSACTION $sCaller", LogChannels::CMDB_SOURCE);
self::DBQuery('START TRANSACTION');
} else {
IssueLog::Trace("Ignore nested (".self::$m_iTransactionLevel.") START TRANSACTION $sCaller", LogChannels::CMDB_SOURCE);
}
self::AddTransactionLevel();
@@ -689,18 +696,22 @@ class CMDBSource
*/
private static function Commit()
{
if (!self::IsInsideTransaction())
{
$aStackTrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT , 3);
$sCaller = 'From '.$aStackTrace[1]['file'].'('.$aStackTrace[1]['line'].'): '.$aStackTrace[2]['class'].'->'.$aStackTrace[2]['function'].'()';
if (!self::IsInsideTransaction()) {
// should not happen !
IssueLog::Error("No Transaction COMMIT $sCaller", LogChannels::CMDB_SOURCE);
throw new MySQLNoTransactionException('Trying to commit transaction whereas none have been started !', null);
}
self::RemoveLastTransactionLevel();
if (self::IsInsideTransaction())
{
if (self::IsInsideTransaction()) {
IssueLog::Trace("Ignore nested (".self::$m_iTransactionLevel.") COMMIT $sCaller", LogChannels::CMDB_SOURCE);
return;
}
IssueLog::Trace("COMMIT $sCaller", LogChannels::CMDB_SOURCE);
self::DBQuery('COMMIT');
}
@@ -719,17 +730,21 @@ class CMDBSource
*/
private static function Rollback()
{
if (!self::IsInsideTransaction())
{
$aStackTrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT , 3);
$sCaller = 'From '.$aStackTrace[1]['file'].'('.$aStackTrace[1]['line'].'): '.$aStackTrace[2]['class'].'->'.$aStackTrace[2]['function'].'()';
if (!self::IsInsideTransaction()) {
// should not happen !
IssueLog::Error("No Transaction ROLLBACK $sCaller", LogChannels::CMDB_SOURCE);
throw new MySQLNoTransactionException('Trying to commit transaction whereas none have been started !', null);
}
self::RemoveLastTransactionLevel();
if (self::IsInsideTransaction())
{
if (self::IsInsideTransaction()) {
IssueLog::Trace("Ignore nested (".self::$m_iTransactionLevel.") ROLLBACK $sCaller", LogChannels::CMDB_SOURCE);
return;
}
IssueLog::Trace("ROLLBACK $sCaller", LogChannels::CMDB_SOURCE);
self::DBQuery('ROLLBACK');
}
@@ -779,9 +794,21 @@ class CMDBSource
self::$m_iTransactionLevel = 0;
}
public static function IsDeadlockException(Exception $e)
{
while ($e instanceof Exception) {
if (($e instanceof MySQLException) && ($e->getCode() == 1213)) {
return true;
}
$e = $e->getPrevious();
}
return false;
}
public static function GetInsertId()
{
$iRes = self::$m_oMysqli->insert_id;
$iRes = DbConnectionWrapper::GetDbConnection()->insert_id;
if (is_null($iRes))
{
return 0;
@@ -813,26 +840,28 @@ class CMDBSource
/**
* @param string $sSql
* @param int $iCol beginning at 0
* @param mysqli $oMysqli if not null will query using this connection, otherwise will use {@see GetMySQLiForQuery}
*
* @return string corresponding cell content on the first line
* @throws \MySQLException
* @throws \MySQLQueryHasNoResultException
* @since 2.7.5-2 2.7.6 3.0.0 N°4215 new optional mysqli param
*/
public static function QueryToScalar($sSql, $iCol = 0)
public static function QueryToScalar($sSql, $iCol = 0, $oMysqli = null)
{
$oMysqliForQuery = $oMysqli ?: DbConnectionWrapper::GetDbConnection(true);
$oKPI = new ExecutionKPI();
try
{
$oResult = self::$m_oMysqli->query($sSql);
try {
/** @noinspection NullPointerExceptionInspection this shouldn't happen : either cnx is passed or the DB was init */
$oResult = $oMysqliForQuery->query($sSql);
}
catch(mysqli_sql_exception $e)
{
catch (mysqli_sql_exception $e) {
$oKPI->ComputeStats('Query exec (mySQL)', $sSql);
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql, $e));
}
$oKPI->ComputeStats('Query exec (mySQL)', $sSql);
if ($oResult === false)
{
if ($oResult === false) {
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql));
}
@@ -853,17 +882,19 @@ class CMDBSource
/**
* @param string $sSql
* @param int $iMode
*
* @return array
* @throws \MySQLException if query cannot be processed
*/
public static function QueryToArray($sSql)
public static function QueryToArray($sSql, $iMode = MYSQLI_BOTH)
{
$aData = array();
$oKPI = new ExecutionKPI();
try
{
$oResult = self::$m_oMysqli->query($sSql);
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oResult = DbConnectionWrapper::GetDbConnection(true)->query($sSql);
}
catch(mysqli_sql_exception $e)
{
@@ -876,7 +907,7 @@ class CMDBSource
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql));
}
while ($aRow = $oResult->fetch_array(MYSQLI_BOTH))
while ($aRow = $oResult->fetch_array($iMode))
{
$aData[] = $aRow;
}
@@ -913,7 +944,8 @@ class CMDBSource
$aData = array();
try
{
$oResult = self::$m_oMysqli->query($sSql);
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oResult = DbConnectionWrapper::GetDbConnection(true)->query($sSql);
}
catch(mysqli_sql_exception $e)
{
@@ -945,7 +977,8 @@ class CMDBSource
{
try
{
$oResult = self::$m_oMysqli->query($sSql);
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oResult = DbConnectionWrapper::GetDbConnection(true)->query($sSql);
}
catch(mysqli_sql_exception $e)
{
@@ -970,7 +1003,7 @@ class CMDBSource
public static function AffectedRows()
{
return self::$m_oMysqli->affected_rows;
return DbConnectionWrapper::GetDbConnection()->affected_rows;
}
public static function FetchArray($oResult)
@@ -1088,7 +1121,7 @@ class CMDBSource
*
* We still need to do a case sensitive comparison for enum values !
*
* A better solution would be to generate SQL field definitions ({@link GetFieldSpec} method) based on the DB used... But for
* A better solution would be to generate SQL field definitions ({@see GetFieldSpec} method) based on the DB used... But for
* now (N°2490 / SF #1756 / PR #91) we did implement this simpler solution
*
* @see GetFieldDataTypeAndOptions extracts all info from the SQL field definition
@@ -1433,7 +1466,8 @@ class CMDBSource
$sSql = "SELECT * FROM `$sTable`";
try
{
$oResult = self::$m_oMysqli->query($sSql);
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oResult = DbConnectionWrapper::GetDbConnection(true)->query($sSql);
}
catch(mysqli_sql_exception $e)
{

View File

@@ -107,7 +107,15 @@ class Config
protected $m_aSettings = [
'log_level_min' => [
'type' => 'array',
'description' => 'Optional min log level per channel',
'description' => 'Optional min log level, per channel.',
'default' => '',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'log_level_min.write_in_db' => [
'type' => 'array',
'description' => 'Optional min log level IN DB, per channel.',
'default' => '',
'value' => '',
'source_of_value' => '',
@@ -1062,72 +1070,88 @@ class Config
'show_in_conf_sample' => false,
],
'transactions_gc_threshold' => [
'type' => 'integer',
'description' => 'probability in percent for the garbage collector to be triggered (100 mean always)',
'default' => 10, // added in itop 2.7.4, before the GC was always called
'value' => '',
'source_of_value' => '',
'type' => 'integer',
'description' => 'probability in percent for the garbage collector to be triggered (100 mean always)',
'default' => 10, // added in itop 2.7.4, before the GC was always called
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'log_transactions' => [
'type' => 'bool',
'description' => 'Whether or not to enable the debug log for the transactions.',
'default' => false,
'value' => '',
'source_of_value' => '',
'type' => 'bool',
'description' => 'Whether or not to enable the debug log for the transactions.',
'default' => false,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'concurrent_lock_enabled' => [
'type' => 'bool',
'description' => 'Whether or not to activate the locking mechanism in order to prevent concurrent edition of the same object.',
'default' => false,
'value' => '',
'source_of_value' => '',
'type' => 'bool',
'description' => 'Whether or not to activate the locking mechanism in order to prevent concurrent edition of the same object.',
'default' => false,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'concurrent_lock_expiration_delay' => [
'type' => 'integer',
'description' => 'Delay (in seconds) for a concurrent lock to expire',
'default' => 120,
'value' => '',
'source_of_value' => '',
'type' => 'integer',
'description' => 'Delay (in seconds) for a concurrent lock to expire',
'default' => 120,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'concurrent_lock_override_profiles' => [
'type' => 'array',
'description' => 'The list of profiles allowed to "kill" a lock',
'default' => ['Administrator'],
'value' => '',
'source_of_value' => '',
'type' => 'array',
'description' => 'The list of profiles allowed to "kill" a lock',
'default' => ['Administrator'],
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'force_transition_confirmation' => [
'type' => 'bool',
'description' => 'If set to true force confirmation in all transition even if there is no field to complete',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'html_sanitizer' => [
'type' => 'string',
'description' => 'The class to use for HTML sanitization: HTMLDOMSanitizer, HTMLPurifierSanitizer or HTMLNullSanitizer',
'default' => 'HTMLDOMSanitizer',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'svg_sanitizer' => [
'type' => 'string',
'description' => 'The class to use for HTML sanitization: HTMLDOMSanitizer, HTMLPurifierSanitizer or HTMLNullSanitizer',
'default' => 'HTMLDOMSanitizer',
'description' => 'The class to use for SVG sanitization : allow to provide a custom made sanitizer',
'default' => 'SVGDOMSanitizer',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'inline_image_max_display_width' => [
'type' => 'integer',
'description' => 'The maximum width (in pixels) when displaying images inside an HTML formatted attribute. Images will be displayed using this this maximum width.',
'default' => '250',
'value' => '',
'source_of_value' => '',
'type' => 'integer',
'description' => 'The maximum width (in pixels) when displaying images inside an HTML formatted attribute. Images will be displayed using this this maximum width.',
'default' => '250',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'inline_image_max_storage_width' => [
'type' => 'integer',
'description' => 'The maximum width (in pixels) when uploading images to be used inside an HTML formatted attribute. Images larger than the given size will be downsampled before storing them in the database.',
'default' => '1600',
'value' => '',
'source_of_value' => '',
'type' => 'integer',
'description' => 'The maximum width (in pixels) when uploading images to be used inside an HTML formatted attribute. Images larger than the given size will be downsampled before storing them in the database.',
'default' => '1600',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'draft_attachments_lifetime' => [
'type' => 'integer',
'description' => 'Lifetime (in seconds) of drafts\' attachments and inline images: after this duration, the garbage collector will delete them.',
'type' => 'integer',
'description' => 'Lifetime (in seconds) of drafts\' attachments and inline images: after this duration, the garbage collector will delete them.',
'default' => 86400,
'value' => '',
'source_of_value' => '',
@@ -1141,6 +1165,38 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'compatibility.include_moved_js_files' => [
'type' => 'bool',
'description' => 'Include back JS files which are now only included when necessary to ease usage of not migrated extensions',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'compatibility.include_deprecated_js_files' => [
'type' => 'bool',
'description' => 'Include the deprecated JS files to ease usage of not migrated extensions',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'compatibility.include_moved_css_files' => [
'type' => 'bool',
'description' => 'Include back CSS files which are now only included when necessary to ease usage of not migrated extensions',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'compatibility.include_deprecated_css_files' => [
'type' => 'bool',
'description' => 'Include the deprecated CSS files to ease usage of not migrated extensions',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'navigation_menu.show_menus_count' => [
'type' => 'bool',
'description' => 'Display count badges for OQL menu entries',
@@ -1229,6 +1285,38 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'activity_panel.prefilter_only_current_log' => [
'type' => 'bool',
'description' => 'Whether the "Logs" filter should only be set to the log from the current tab or to all of them.',
'default' => true,
'value' => true,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'activity_panel.prefilter_state_changes_on_logs' => [
'type' => 'bool',
'description' => 'Whether the "State changes" filter should be set by default on all log tabs.',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'activity_panel.prefilter_edits_on_logs' => [
'type' => 'bool',
'description' => 'Whether the "Edits" filter should be set by default on all log tabs.',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'activity_panel.hide_avatars' => [
'type' => 'array',
'description' => 'GUIs IDs ("backoffice", "itop-portal" for the standard end-users portal, ...) in which the user avatars should be hidden and replaced if possible by their initials (eg. array("backoffice", "itop-portal", "another-portal-id"))',
'default' => [],
'value' => [],
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'activity_panel.show_author_name_below_entries' => [
'type' => 'bool',
'description' => 'Whether or not to show the author friendlyname next to the date on the last entry.',
@@ -1255,7 +1343,7 @@ class Config
],
'mentions.allowed_classes' => [
'type' => 'array',
'description' => 'Classes which can be mentioned through the autocomplete in the caselogs. Key of the array must be a single character that will trigger the autocomplete (eg. "@" => "Person")',
'description' => 'Classes which can be mentioned through the autocomplete in the caselogs. Key of the array must be a single character that will trigger the autocomplete, value must be a DM class (eg. "@" => "Person", "?" => "FAQ")',
'default' => [
'@' => 'Person',
],
@@ -1279,6 +1367,14 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'user_preferences.allow_backoffice_theme_override' => [
'type' => 'bool',
'description' => 'Whether the user can choose which theme to use in the backoffice. If set to false, all users will have the theme defined in "backoffice_default_theme"',
'default' => true,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'secure_rest_services' => [
'type' => 'bool',
'description' => 'When set to true, only the users with the profile "REST Services User" are allowed to use the REST web services.',
@@ -1375,6 +1471,22 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'security.disable_inline_documents_sandbox' => [
'type' => 'bool',
'description' => 'If true then the sandbox for documents displayed in a browser tab will be disabled; enabling scripts and other interactive content. Note that setting this to true will open the application to potential XSS attacks!',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'security.hide_administrators' => [
'type' => 'bool',
'description' => 'If true, non-administrator users will not be able to see the administrator accounts, the Administrator profile and the links between the administrator accounts and their profiles.',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'behind_reverse_proxy' => [
'type' => 'bool',
'description' => 'If true, then proxies custom header (X-Forwarded-*) are taken into account. Use only if the webserver is not publicly accessible (reachable only by the reverse proxy)',
@@ -1383,6 +1495,30 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'developer_mode.enabled' => [
'type' => 'bool',
'description' => 'If true then unlocks dev env functionalities, see \utils::IsDevelopmentEnvironment',
'default' => null,
'value' => null,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'theme.enable_precompilation' => [
'type' => 'bool',
'description' => 'If false, theme compilation will not use any precompiled file setup optimization.)',
'default' => true,
'value' => true,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'theme.force_signature_check_at_runtime' => [
'type' => 'bool',
'description' => 'If true, checking that the current theme signature matches the compiled file -to recompile it if necessary- will be done for each page. This can slow the application, only use it if you are experiencing issues while customizing a theme.)',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
];
public function IsProperty($sPropCode)

View File

@@ -3,4 +3,6 @@
* This file is only here for compatibility issues. Will be removed in iTop 3.1.0 (N°3664)
*
* @deprecated 3.0.0 N°3663 Exception classes were moved to `/application/exceptions`, use autoloader instead of require !
*/
*/
require_once '../approot.inc.php';
DeprecatedCallsLog::NotifyDeprecatedFile('Classes were moved to /application/exceptions');

View File

@@ -185,13 +185,13 @@ class CSVBulkExport extends TabularBulkExport
$oFieldSetLocalization->AddSubBlock(new Html('</br>'));
$oSelect = SelectUIBlockFactory::MakeForSelectWithLabel("charset", Dict::S('UI:CSVImport:Encoding'));
$oSelect->SetBeforeInput(true);
$oSelect->SetIsLabelBefore(true);
$oFieldSetLocalization->AddSubBlock($oSelect);
$aPossibleEncodings = utils::GetPossibleEncodings(MetaModel::GetConfig()->GetCSVImportCharsets());
$sDefaultEncoding = MetaModel::GetConfig()->Get('csv_file_default_charset');
foreach ($aPossibleEncodings as $sIconvCode => $sDisplayName) {
$oSelect->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sIconvCode, $sDisplayName, ($sIconvCode == $sDefaultEncoding)));
$oSelect->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sIconvCode, $sDisplayName, ($sIconvCode == $sDefaultEncoding)));
}
//markup
$oFieldSetMarkup = FieldSetUIBlockFactory::MakeStandard(Dict::S('Core:BulkExport:TextFormat'));
@@ -211,15 +211,15 @@ class CSVBulkExport extends TabularBulkExport
$sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8');
$sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8');
$oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "csv_custom_date_time_format", "default", "csv_date_time_format_default", "radio");
$oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "csv_date_format_radio", "default", "csv_date_time_format_default", "radio");
$oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat()));
$oRadioDefault->SetBeforeInput(false);
$oRadioDefault->GetInput()->AddCSSClass('ibo-input-checkbox');
$oFieldSetDate->AddSubBlock($oRadioDefault);
$oFieldSetDate->AddSubBlock(new Html('</br>'));
$sFormatInput = '<input type="text" size="15" name="date_format" id="excel_custom_date_time_format" title="" value="'.htmlentities($sDateTimeFormat, ENT_QUOTES, 'UTF-8').'"/>';
$oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "csv_custom_date_time_format", "custom", "csv_date_time_format_custom", "radio");
$sFormatInput = '<input type="text" size="15" name="date_format" id="csv_custom_date_time_format" title="" value="'.htmlentities($sDateTimeFormat, ENT_QUOTES, 'UTF-8').'"/>';
$oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "csv_date_format_radio", "custom", "csv_date_time_format_custom", "radio");
$oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat());
$oRadioCustom->SetBeforeInput(false);
$oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox');

View File

@@ -1,22 +1,11 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
/**
* All objects to be displayed in the application (either as a list or as details)
* must implement this interface.
@@ -803,7 +792,7 @@ abstract class DBObject implements iDisplay
//
/** @var \AttributeExternalField $oAttDef */
$sExtKeyAttCode = $oAttDef->GetKeyAttCode();
if (($iRemote = $this->Get($sExtKeyAttCode)) && ($iRemote > 0)) // Objects in memory have negative IDs
{
$oExtKeyAttDef = MetaModel::GetAttributeDef(get_class($this), $sExtKeyAttCode);
@@ -959,10 +948,9 @@ abstract class DBObject implements iDisplay
*/
protected function ComputeHighlightCode()
{
// First if the state defines a HiglightCode, apply it
$sState = $this->GetState();
if ($sState != '')
if (MetaModel::HasLifecycle(get_class($this)))
{
$sState = $this->GetState();
$sCode = MetaModel::GetHighlightCode(get_class($this), $sState);
$this->SetHighlightCode($sCode);
}
@@ -1290,13 +1278,20 @@ abstract class DBObject implements iDisplay
{
// If the object if not issued from a query but constructed programmatically
// the label may be empty. In this case run a query to get the object's friendly name
$oTmpObj = MetaModel::GetObject($sObjClass, $sObjKey, false);
if (is_object($oTmpObj))
{
$sObjOql = 'SELECT '.$sObjClass.' WHERE id='.$sObjKey;
$oObjFilter = DBSearch::FromOQL($sObjOql);
$oSet = new DBObjectSet($oObjFilter);
// we will only use id and friendlyname, so let's remove other fields !
$aAttToLoad = [
$sObjClass => [],
];
$oSet->OptimizeColumnLoad($aAttToLoad);
$oTmpObj = $oSet->Fetch();
if (is_object($oTmpObj)) {
$sHtmlLabel = $oTmpObj->GetName();
}
else
{
} else {
// May happen in case the target object is not in the list of allowed values for this attribute
$sHtmlLabel = "<em>$sObjClass::$sObjKey</em>";
}
@@ -1475,24 +1470,78 @@ abstract class DBObject implements iDisplay
*/
public function GetIcon($bImgTag = true)
{
$sClass = get_class($this);
if($this->HasHighlightIcon()) {
$sIconUrl = MetaModel::GetHighlightScale($sClass)[$this->ComputeHighlightCode()]['icon'];
if($bImgTag) {
return "<img src=\"$sIconUrl\" style=\"vertical-align:middle\"/>";
}
else {
return $sIconUrl;
}
}
// Get object instance own image if it exists
$sImageAttCode = MetaModel::GetImageAttributeCode($sClass);
$sIconUrl = $this->HasInstanceIcon() ? $this->Get($sImageAttCode)->GetDisplayURL($sClass, $this->GetKey(), $sImageAttCode) : '';
if (strlen($sIconUrl) > 0) {
if($bImgTag) {
return "<img src=\"$sIconUrl\"/>";
}
else {
return $sIconUrl;
}
}
return MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
/**
* @return bool True if the object has an image attribute as semantic attribute and its value is not empty
* @throws \ArchivedObjectException
* @throws \CoreException
* @since 3.0.0
*/
public function HasInstanceIcon(): bool
{
$bHasInstanceIcon = false;
$sClass = get_class($this);
if (!$this->IsNew() && MetaModel::HasImageAttributeCode($sClass)) {
$sImageAttCode = MetaModel::GetImageAttributeCode($sClass);
if (!empty($sImageAttCode)) {
/** @var \ormDocument $oImage */
$oImage = $this->Get($sImageAttCode);
$bHasInstanceIcon = !$oImage->IsEmpty();
}
}
return $bHasInstanceIcon;
}
/**
* @return bool True if the class has an highlight icon declared for the current object state
* @throws \ArchivedObjectException
* @throws \CoreException
* @since 3.0.0
*/
public function HasHighlightIcon(): bool
{
$bHasHighlightIcon = false;
$sCode = $this->ComputeHighlightCode();
$sClass = get_class($this);
if($sCode != '')
{
$aHighlightScale = MetaModel::GetHighlightScale(get_class($this));
$aHighlightScale = MetaModel::GetHighlightScale($sClass);
if (array_key_exists($sCode, $aHighlightScale))
{
$sIconUrl = $aHighlightScale[$sCode]['icon'];
if($bImgTag)
{
return "<img src=\"$sIconUrl\" style=\"vertical-align:middle\"/>";
}
else
{
return $sIconUrl;
}
$bHasHighlightIcon = true;
}
}
return MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
return $bHasHighlightIcon;
}
/**
@@ -1530,31 +1579,40 @@ abstract class DBObject implements iDisplay
/**
* Helper to get the friendly name in a safe manner for displaying inside a web page
*
* @api
*
* @internal
* @return string
* @throws \CoreException
* @since 3.0.0 N°4106 This method is now internal. It will be set final in 3.1.0 (N°4107)
* @since 3.0.0 N°580 New $sType parameter
*
*/
public function GetName()
public function GetName($sType = FriendlyNameType::SHORT)
{
return htmlentities($this->GetRawName(), ENT_QUOTES, 'UTF-8');
return htmlentities($this->GetRawName($sType), ENT_QUOTES, 'UTF-8');
}
/**
* Helper to get the friendly name
*
* This is not safe for displaying inside a web page since the " < > characters are not escaped.
* In example, the name may contain some XSS script instructions.
* Helper to get the friendly name
*
* This is not safe for displaying inside a web page since the " < > characters are not escaped.
* In example, the name may contain some XSS script instructions.
* Use this function only for internal computations or for an output to a non-HTML destination
*
* @api
*
* @internal
* @return string
* @throws \CoreException
* @since 3.0.0 N°4106 This method is now internal. It will be set final in 3.1.0 (N°4107)
* @since 3.0.0 N°580 New $sType parameter
*
*/
public function GetRawName()
public function GetRawName($sType = FriendlyNameType::SHORT)
{
return $this->Get('friendlyname');
if ($sType == FriendlyNameType::SHORT) {
return $this->Get('friendlyname');
} else {
$oExpression = MetaModel::GetNameExpression(get_class($this), $sType);
$this->EvaluateExpression($oExpression);
}
}
/**
@@ -1870,9 +1928,7 @@ abstract class DBObject implements iDisplay
{
/** @var \AttributeExternalKey $oAtt */
$sTargetClass = $oAtt->GetTargetClass();
$oTargetObj = MetaModel::GetObject($sTargetClass, $toCheck, false /*must be found*/, true /*allow all data*/);
if (is_null($oTargetObj))
{
if (false === MetaModel::IsObjectInDB($sTargetClass, $toCheck)) {
return "Target object not found ($sTargetClass::$toCheck)";
}
}
@@ -2140,28 +2196,23 @@ abstract class DBObject implements iDisplay
}
if ($oAttDef->DuplicatesAllowed()) {
return true;
return;
}
// To control duplicates go through all the entries and check if the remote has been seen
/** @var \ormLinkSet $value */
$aModifiedLnk = $value->ListModifiedLinks();
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
$aExistingRemotesId = $value->GetColumnAsArray($sExtKeyToRemote, true);
$aExistingRemotesFriendlyName = $value->GetColumnAsArray($sExtKeyToRemote.'_friendlyname', true);
$aCurrentRemoteIds = [];
$aDuplicatesFields = [];
foreach ($aModifiedLnk as $oModifiedLnk) {
$iModifiedLnkId = $oModifiedLnk->GetKey();
$iModifiedLnkRemoteId = $oModifiedLnk->Get($sExtKeyToRemote);
$aExistingRemotesIdToCheck = array_filter($aExistingRemotesId, function ($iLnkKey) use ($iModifiedLnkId) {
return ($iLnkKey != $iModifiedLnkId);
}, ARRAY_FILTER_USE_KEY);
if (!in_array($iModifiedLnkRemoteId, $aExistingRemotesIdToCheck, true)) {
continue;
$value->rewind();
while ($oCurrentLnk = $value->current()) {
$iExtKeyToRemote = $oCurrentLnk->Get($sExtKeyToRemote);
if (isset($aCurrentRemoteIds[$iExtKeyToRemote])) {
$aDuplicatesFields[] = $oCurrentLnk->Get($sExtKeyToRemote.'_friendlyname');
} else {
$aCurrentRemoteIds[$iExtKeyToRemote] = true;
}
$iLnkId = $oModifiedLnk->GetKey();
$aDuplicatesFields[] = $aExistingRemotesFriendlyName[$iLnkId];
$value->next();
}
if (!empty($aDuplicatesFields)) {
@@ -2434,11 +2485,10 @@ abstract class DBObject implements iDisplay
* Reset during {@see DBObject::DBUpdate()}
* @throws Exception
* @uses m_aCurrValues
*/
*/
public function ListChanges()
{
if ($this->m_bIsInDB)
{
if ($this->m_bIsInDB) {
return $this->ListChangedValues($this->m_aCurrValues);
}
@@ -2784,50 +2834,75 @@ abstract class DBObject implements iDisplay
}
}
$iTransactionRetry = 1;
$bIsTransactionEnabled = MetaModel::GetConfig()->Get('db_core_transactions_enabled');
try
if ($bIsTransactionEnabled)
{
if ($bIsTransactionEnabled)
{
CMDBSource::Query('START TRANSACTION');
}
// First query built upon on the root class, because the ID must be created first
$this->m_iKey = $this->DBInsertSingleTable($sRootClass);
// Then do the leaf class, if different from the root class
if ($sClass != $sRootClass)
{
$this->DBInsertSingleTable($sClass);
}
// Then do the other classes
foreach (MetaModel::EnumParentClasses($sClass) as $sParentClass)
{
if ($sParentClass == $sRootClass)
{
continue;
}
$this->DBInsertSingleTable($sParentClass);
}
$this->OnObjectKeyReady();
$this->DBWriteLinks();
$this->WriteExternalAttributes();
if ($bIsTransactionEnabled)
{
CMDBSource::Query('COMMIT');
}
// TODO Deep clone this object before the transaction (to use it in case of rollback)
// $iTransactionRetryCount = MetaModel::GetConfig()->Get('db_core_transactions_retry_count');
$iTransactionRetryCount = 1;
$iTransactionRetryDelay = MetaModel::GetConfig()->Get('db_core_transactions_retry_delay_ms');
$iTransactionRetry = $iTransactionRetryCount;
}
catch (Exception $e)
{
if ($bIsTransactionEnabled)
{
CMDBSource::Query('ROLLBACK');
while ($iTransactionRetry > 0) {
try {
$iTransactionRetry--;
if ($bIsTransactionEnabled) {
CMDBSource::Query('START TRANSACTION');
}
// First query built upon on the root class, because the ID must be created first
$this->m_iKey = $this->DBInsertSingleTable($sRootClass);
// Then do the leaf class, if different from the root class
if ($sClass != $sRootClass) {
$this->DBInsertSingleTable($sClass);
}
// Then do the other classes
foreach (MetaModel::EnumParentClasses($sClass) as $sParentClass) {
if ($sParentClass == $sRootClass) {
continue;
}
$this->DBInsertSingleTable($sParentClass);
}
$this->OnObjectKeyReady();
$this->DBWriteLinks();
$this->WriteExternalAttributes();
// Write object creation history within the transaction
$this->RecordObjCreation();
if ($bIsTransactionEnabled) {
CMDBSource::Query('COMMIT');
}
break;
}
catch (Exception $e) {
IssueLog::Error($e->getMessage());
if ($bIsTransactionEnabled)
{
CMDBSource::Query('ROLLBACK');
if (!CMDBSource::IsInsideTransaction() && CMDBSource::IsDeadlockException($e))
{
// Deadlock found when trying to get lock; try restarting transaction (only in main transaction)
if ($iTransactionRetry > 0)
{
// wait and retry
IssueLog::Error("Insert TRANSACTION Retrying...");
usleep(random_int(1, 5) * 1000 * $iTransactionRetryDelay * ($iTransactionRetryCount - $iTransactionRetry));
continue;
}
else
{
IssueLog::Error("Insert Deadlock TRANSACTION prevention failed.");
}
}
}
throw $e;
}
throw $e;
}
$this->m_bIsInDB = true;
@@ -2860,8 +2935,6 @@ abstract class DBObject implements iDisplay
}
}
$this->RecordObjCreation();
return $this->m_iKey;
}
@@ -3136,52 +3209,35 @@ abstract class DBObject implements iDisplay
}
// 2 - Find mentioned objects
$aMentionedObjects = array();
foreach($aUpdatedLogAttCodes as $sAttCode)
{
foreach ($aUpdatedLogAttCodes as $sAttCode) {
/** @var \ormCaseLog $oUpdatedCaseLog */
$oUpdatedCaseLog = $this->Get($sAttCode);
$aMentionMatches = array();
// Note: As the sanitizer (or CKEditor autocomplete plugin? 🤔) removes data-* attributes from the hyperlink, we can't use the following (simpler) regexp: '/<a\s*([^>]*)data-object-class="([^"]*)"\s*data-object-id="([^"]*)">/i'
// If we change the sanitizer, we might want to use this regexp as it's easier to read
// Note 2: This is only working for backoffice URLs...
$sAppRootUrlForRegExp = addcslashes(utils::GetAbsoluteUrlAppRoot(), '/&');
preg_match_all("/\[([^\]]*)\]\({$sAppRootUrlForRegExp}[^\)]*\&class=([^\)\&]*)\&id=([\d]*)[^\)]*\)/i", $oUpdatedCaseLog->GetModifiedEntry(), $aMentionMatches);
foreach($aMentionMatches[0] as $iMatchIdx => $sCompleteMatch)
{
$sMatchedClass = $aMentionMatches[2][$iMatchIdx];
$sMatchedId = $aMentionMatches[3][$iMatchIdx];
// Prepare array for matched class if not already present
if(!array_key_exists($sMatchedClass, $aMentionedObjects))
{
$aMentionedObjects[$sMatchedClass] = array();
}
// Add matched ID if not already there
if(!in_array($sMatchedId, $aMentionedObjects[$sMatchedClass]))
{
$aMentionedObjects[$sMatchedClass][] = $sMatchedId;
}
}
$aMentionedObjects = array_merge_recursive($aMentionedObjects, utils::GetMentionedObjectsFromText($oUpdatedCaseLog->GetModifiedEntry()));
}
// 3 - Trigger for those objects
foreach($aMentionedObjects as $sMentionedClass => $aMentionedIds)
{
foreach($aMentionedIds as $sMentionedId)
{
// TODO: This should be refactored and moved into the caselogs loop, otherwise, we won't be able to know which case log triggered the action.
foreach ($aMentionedObjects as $sMentionedClass => $aMentionedIds) {
foreach ($aMentionedIds as $sMentionedId) {
/** @var \DBObject $oMentionedObject */
$oMentionedObject = MetaModel::GetObject($sMentionedClass, $sMentionedId);
// Important: Here the "$this->object()$" placeholder is actually the mentioned object and not the current object. The current object can be used through the $source->object()$ placeholder.
// This is due to the current implementation of triggers, the events will only be visible on the object the trigger's OQL is based on... 😕
$aTriggerArgs = $this->ToArgs('source') + array('this->object()' => $oMentionedObject);
$aTriggerArgs = $this->ToArgs('this') + array('mentioned->object()' => $oMentionedObject);
$aParams = array('class_list' => MetaModel::EnumParentClasses($sMentionedClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectMention AS t WHERE t.target_class IN (:class_list)"),
array(), $aParams);
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectMention AS t WHERE t.target_class IN (:class_list)"), array(), $aParams);
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
$oTrigger->DoActivate($aTriggerArgs);
/** @var \TriggerOnObjectMention $oTrigger */
try {
// Ensure to handle only mentioned object in the trigger's scope
if ($oTrigger->IsMentionedObjectInScope($oMentionedObject) === false) {
continue;
}
$oTrigger->DoActivate($aTriggerArgs);
}
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
}
}
}
}
@@ -3210,9 +3266,11 @@ abstract class DBObject implements iDisplay
$bIsTransactionEnabled = MetaModel::GetConfig()->Get('db_core_transactions_enabled');
if ($bIsTransactionEnabled)
{
$iIsTransactionRetryCount = MetaModel::GetConfig()->Get('db_core_transactions_retry_count');
// TODO Deep clone this object before the transaction (to use it in case of rollback)
// $iTransactionRetryCount = MetaModel::GetConfig()->Get('db_core_transactions_retry_count');
$iTransactionRetryCount = 1;
$iIsTransactionRetryDelay = MetaModel::GetConfig()->Get('db_core_transactions_retry_delay_ms');
$iTransactionRetry = $iIsTransactionRetryCount;
$iTransactionRetry = $iTransactionRetryCount;
}
while ($iTransactionRetry > 0)
{
@@ -3228,7 +3286,7 @@ abstract class DBObject implements iDisplay
// Update the left & right indexes for each hierarchical key
foreach ($aHierarchicalKeys as $sAttCode => $oAttDef)
{
$sTable = $sTable = MetaModel::DBGetTable(get_class($this), $sAttCode);
$sTable = MetaModel::DBGetTable(get_class($this), $sAttCode);
$sSQL = "SELECT `".$oAttDef->GetSQLRight()."` AS `right`, `".$oAttDef->GetSQLLeft()."` AS `left` FROM `$sTable` WHERE id=".$this->GetKey();
$aRes = CMDBSource::QueryToArray($sSQL);
$iMyLeft = $aRes[0]['left'];
@@ -3236,8 +3294,7 @@ abstract class DBObject implements iDisplay
$iDelta = $iMyRight - $iMyLeft + 1;
MetaModel::HKTemporaryCutBranch($iMyLeft, $iMyRight, $oAttDef, $sTable);
if ($aDBChanges[$sAttCode] == 0)
{
if ($aDBChanges[$sAttCode] == 0) {
// No new parent, insert completely at the right of the tree
$sSQL = "SELECT max(`".$oAttDef->GetSQLRight()."`) AS max FROM `$sTable`";
$aRes = CMDBSource::QueryToArray($sSQL);
@@ -3280,38 +3337,29 @@ abstract class DBObject implements iDisplay
$this->DBWriteLinks();
$this->WriteExternalAttributes();
// following lines are resetting changes (so after this {@see DBObject::ListChanges()} won't return changes anymore)
// new values are already in the object (call {@see DBObject::Get()} to get them)
// call {@see DBObject::ListPreviousValuesForUpdatedAttributes()} to get changed fields and previous values
$this->m_bDirty = false;
$this->m_aTouchedAtt = array();
$this->m_aModifiedAtt = array();
if (count($aChanges) != 0)
{
if (count($aChanges) != 0) {
$this->RecordAttChanges($aChanges, $aOriginalValues);
}
if ($bIsTransactionEnabled)
{
if ($bIsTransactionEnabled) {
CMDBSource::Query('COMMIT');
}
break;
}
catch (MySQLException $e)
{
IssueLog::Error($e->getMessage());
if ($bIsTransactionEnabled)
{
CMDBSource::Query('ROLLBACK');
if ($e->getCode() == 1213)
if (!CMDBSource::IsInsideTransaction() && CMDBSource::IsDeadlockException($e))
{
// Deadlock found when trying to get lock; try restarting transaction
IssueLog::Error($e->getMessage());
// Deadlock found when trying to get lock; try restarting transaction (only in main transaction)
if ($iTransactionRetry > 0)
{
// wait and retry
IssueLog::Error("Update TRANSACTION Retrying...");
usleep(random_int(1, 5) * 1000 * $iIsTransactionRetryDelay * ($iIsTransactionRetryCount - $iTransactionRetry));
usleep(random_int(1, 5) * 1000 * $iIsTransactionRetryDelay * ($iTransactionRetryCount - $iTransactionRetry));
continue;
}
else
@@ -3325,10 +3373,11 @@ abstract class DBObject implements iDisplay
'id' => $this->GetKey(),
'class' => get_class($this),
'issues' => $aErrors
));
), $e);
}
catch (CoreCannotSaveObjectException $e)
{
IssueLog::Error($e->getMessage());
if ($bIsTransactionEnabled)
{
CMDBSource::Query('ROLLBACK');
@@ -3337,6 +3386,7 @@ abstract class DBObject implements iDisplay
}
catch (Exception $e)
{
IssueLog::Error($e->getMessage());
if ($bIsTransactionEnabled)
{
CMDBSource::Query('ROLLBACK');
@@ -3350,13 +3400,20 @@ abstract class DBObject implements iDisplay
}
}
// following lines are resetting changes (so after this {@see DBObject::ListChanges()} won't return changes anymore)
// new values are already in the object (call {@see DBObject::Get()} to get them)
// call {@see DBObject::ListPreviousValuesForUpdatedAttributes()} to get changed fields and previous values
$this->m_bDirty = false;
$this->m_aTouchedAtt = array();
$this->m_aModifiedAtt = array();
try {
// - TriggerOnObjectUpdate
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectUpdate AS t WHERE t.target_class IN (:class_list)"),
array(), $aParams);
while ($oTrigger = $oSet->Fetch()) {
/** @var \Trigger $oTrigger */
/** @var \TriggerOnObjectUpdate $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
@@ -3539,9 +3596,11 @@ abstract class DBObject implements iDisplay
$bIsTransactionEnabled = MetaModel::GetConfig()->Get('db_core_transactions_enabled');
if ($bIsTransactionEnabled)
{
$iIsTransactionRetryCount = MetaModel::GetConfig()->Get('db_core_transactions_retry_count');
$iIsTransactionRetryDelay = MetaModel::GetConfig()->Get('db_core_transactions_retry_delay_ms');
$iTransactionRetry = $iIsTransactionRetryCount;
// TODO Deep clone this object before the transaction (to use it in case of rollback)
// $iTransactionRetryCount = MetaModel::GetConfig()->Get('db_core_transactions_retry_count');
$iTransactionRetryCount = 1;
$iTransactionRetryDelay = MetaModel::GetConfig()->Get('db_core_transactions_retry_delay_ms');
$iTransactionRetry = $iTransactionRetryCount;
}
while ($iTransactionRetry > 0)
{
@@ -3564,18 +3623,18 @@ abstract class DBObject implements iDisplay
}
catch (MySQLException $e)
{
IssueLog::Error($e->getMessage());
if ($bIsTransactionEnabled)
{
CMDBSource::Query('ROLLBACK');
if ($e->getCode() == 1213)
if (!CMDBSource::IsInsideTransaction() && CMDBSource::IsDeadlockException($e))
{
// Deadlock found when trying to get lock; try restarting transaction
IssueLog::Error($e->getMessage());
if ($iTransactionRetry > 0)
{
// wait and retry
IssueLog::Error("Delete TRANSACTION Retrying...");
usleep(random_int(1, 5) * 1000 * $iIsTransactionRetryDelay * ($iIsTransactionRetryCount - $iTransactionRetry));
usleep(random_int(1, 5) * 1000 * $iTransactionRetryDelay * ($iTransactionRetryCount - $iTransactionRetry));
continue;
}
else
@@ -3728,16 +3787,22 @@ abstract class DBObject implements iDisplay
/**
* Apply a stimulus (workflow)
*
* @api
*
* @param string $sStimulusCode
* @param bool $bDoNotWrite
*
*
* @api
*
* @param string $sStimulusCode
* @param bool $bDoNotWrite if true we won't save the object !
*
* @return bool
*
*
* @throws CoreException
* @throws CoreUnexpectedValue
*
* @uses \AttributeStopWatch::Start
* @uses \AttributeStopWatch::Stop
* @uses \DBObject::DBWrite
* @uses \TriggerOnStateLeave::DoActivate
* @uses \TriggerOnStateEnter::DoActivate
*/
public function ApplyStimulus($sStimulusCode, $bDoNotWrite = false)
{
@@ -3852,17 +3917,14 @@ abstract class DBObject implements iDisplay
if (in_array($sNewState, $oAttDef->GetStates()))
{
$oSW->Start($this, $oAttDef);
}
else
{
} else {
$oSW->Stop($this, $oAttDef);
}
$this->Set($sAttCode, $oSW);
}
}
if (!$bDoNotWrite)
{
if (!$bDoNotWrite) {
$this->DBWrite();
}
@@ -3870,30 +3932,26 @@ abstract class DBObject implements iDisplay
$aParams = array(
'class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL),
'previous_state' => $sPreviousState,
'new_state' => $sNewState);
'new_state' => $sNewState,
);
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateLeave AS t WHERE t.target_class IN (:class_list) AND t.state=:previous_state"), array(), $aParams);
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
try
{
while ($oTrigger = $oSet->Fetch()) {
/** @var \TriggerOnStateLeave $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
catch(Exception $e)
{
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
}
}
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateEnter AS t WHERE t.target_class IN (:class_list) AND t.state=:new_state"), array(), $aParams);
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
try{
while ($oTrigger = $oSet->Fetch()) {
/** @var \TriggerOnStateEnter $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
catch(Exception $e)
{
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
}
}
@@ -4003,6 +4061,58 @@ abstract class DBObject implements iDisplay
return true;
}
/**
* Helper to set a date computed from another date with extra logic
*
* @api
*
* @param string $sAttCode attribute code of a date or date-time which will be set
* @param string $sModifier string specifying how to modify the date time
* @param string $sAttCodeSource attribute code of a date or date-time used as source
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @since 3.0.0
*/
public function SetComputedDate($sAttCode, $sModifier = '', $sAttCodeSource = '')
{
$oDate = new DateTime(); // Use now if no Source provided
if ($sAttCodeSource != "") {
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCodeSource);
$oSourceValue = $this->Get($sAttCodeSource);
if (!$oAttDef->IsNull($oSourceValue)) {
// Use the existing value as the Source date
$oDate = new DateTime($oSourceValue);
}
}
$oDate->modify($sModifier);
$this->Set($sAttCode, $oDate->format('Y-m-d H:i:s'));
}
/**
* Helper to set a date computed from another date with extra logic
* Call SetComputedDate() only of the internal representation of the attribute is null.
*
* @api
* @see SetComputedDate()
*
* @param string $sAttCode attribute code which will be set
* @param string $sModifier string specifying how to modify the date time
* @param string $sAttCodeSource attribute code used as source
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @since 3.0.0
*/
public function SetComputedDateIfNull($sAttCode, $sModifier = '', $sAttCodeSource = '')
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$oCurrentValue = $this->Get($sAttCode);
if ($oAttDef->IsNull($oCurrentValue)) {
$this->SetComputedDate($sAttCode, $sModifier, $sAttCodeSource);
}
}
/**
* Helper to set a value only if it is currently undefined
*
@@ -4021,40 +4131,35 @@ abstract class DBObject implements iDisplay
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$oCurrentValue = $this->Get($sAttCode);
if ($oAttDef->IsNull($oCurrentValue))
{
if ($oAttDef->IsNull($oCurrentValue)) {
$this->SetCurrentDate($sAttCode);
}
}
/**
* Helper to set the current logged in user for the given attribute
* Suitable for use as a lifecycle action
*
* @api
*
* @param string $sAttCode
*
* @return bool
*
* @throws CoreException
* @throws CoreUnexpectedValue
*/
/**
* Helper to set the current logged in user for the given attribute
* Suitable for use as a lifecycle action
*
* @api
*
* @param string $sAttCode
*
* @return bool
*
* @throws CoreException
* @throws CoreUnexpectedValue
*/
public function SetCurrentUser($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef instanceof AttributeString)
{
if ($oAttDef instanceof AttributeString) {
// Note: the user friendly name is the contact friendly name if a contact is attached to the logged in user
$this->Set($sAttCode, UserRights::GetUserFriendlyName());
}
else
{
if ($oAttDef->IsExternalKey())
{
} else {
if ($oAttDef->IsExternalKey()) {
/** @var \AttributeExternalKey $oAttDef */
if ($oAttDef->GetTargetClass() != 'User')
{
if ($oAttDef->GetTargetClass() != 'User') {
throw new Exception("SetCurrentUser: the attribute $sAttCode must be an external key to 'User', found '".$oAttDef->GetTargetClass()."'");
}
}
@@ -4573,8 +4678,9 @@ abstract class DBObject implements iDisplay
public function GetRelatedObjectsUp($sRelCode, $iMaxDepth = 99, $bEnableRedundancy = true)
{
$oGraph = new RelationGraph();
$oGraph->AddSourceObject($this);
$oGraph->AddSinkObject($this);
$oGraph->ComputeRelatedObjectsUp($sRelCode, $iMaxDepth, $bEnableRedundancy);
return $oGraph;
}
@@ -4718,8 +4824,10 @@ abstract class DBObject implements iDisplay
*/
public function GetMasterReplica()
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
$sOQL = "SELECT replica,datasource FROM SynchroReplica AS replica JOIN SynchroDataSource AS datasource ON replica.sync_source_id=datasource.id WHERE replica.dest_class = :dest_class AND replica.dest_id = :dest_id";
$oReplicaSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array() /* order by*/, array('dest_class' => get_class($this), 'dest_id' => $this->GetKey()));
return $oReplicaSet;
}
@@ -5552,27 +5660,31 @@ abstract class DBObject implements iDisplay
{
$aFields = $oExpression->ListRequiredFields();
$aArgs = array();
foreach ($aFields as $sFieldDesc)
{
foreach ($aFields as $sFieldDesc) {
$aFieldParts = explode('.', $sFieldDesc);
if (count($aFieldParts) == 2)
{
if (count($aFieldParts) == 2) {
$sClass = $aFieldParts[0];
$sAttCode = $aFieldParts[1];
}
else
{
} else {
$sClass = get_class($this);
$sAttCode = $aFieldParts[0];
}
if (get_class($this) != $sClass) continue;
if (!MetaModel::IsValidAttCode(get_class($this), $sAttCode)) continue;
if (get_class($this) != $sClass) {
continue;
}
if (!MetaModel::IsValidAttCode(get_class($this), $sAttCode)) {
continue;
}
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$aSQLValues = $oAttDef->GetSQLValues($this->m_aCurrValues[$sAttCode]);
$value = reset($aSQLValues);
if ($oAttDef->IsNull($value)) {
return '';
}
$aArgs[$sFieldDesc] = $value;
}
return $oExpression->Evaluate($aArgs);
}
}

View File

@@ -63,22 +63,23 @@ else
abstract class DBSearch
{
/** @internal */
/** @internal */
const JOIN_POINTING_TO = 0;
/** @internal */
/** @internal */
const JOIN_REFERENCED_BY = 1;
protected $m_bNoContextParameters = false;
/** @var array For {@see iQueryModifier} impl */
protected $m_aModifierProperties = array();
protected $m_bArchiveMode = false;
protected $m_bShowObsoleteData = true;
/**
* DBSearch constructor.
*
* @api
* @see DBSearch::FromOQL()
*/
/**
* DBSearch constructor.
*
* @api
* @see DBSearch::FromOQL()
*/
public function __construct()
{
$this->Init();
@@ -280,62 +281,97 @@ abstract class DBSearch
abstract public function TranslateConditions($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true);
/**
* @internal
* @return mixed
*/
/**
* @internal
* @return mixed
*/
abstract public function IsAny();
/**
* @deprecated use ToOQL() instead
* @internal
* @return string
*/
public function Describe(){return 'deprecated - use ToOQL() instead';}
/**
* @deprecated use ToOQL() instead
* @internal
* @return string
*/
public function DescribeConditionPointTo($sExtKeyAttCode, $aPointingTo){return 'deprecated - use ToOQL() instead';}
/**
* @deprecated use ToOQL() instead
* @internal
* @return string
*/
public function DescribeConditionRefBy($sForeignClass, $sForeignExtKeyAttCode){return 'deprecated - use ToOQL() instead';}
/**
* @deprecated use ToOQL() instead
* @internal
* @return string
*/
public function DescribeConditionRelTo($aRelInfo){return 'deprecated - use ToOQL() instead';}
/**
* @deprecated use ToOQL() instead
* @internal
* @return string
*/
public function DescribeConditions(){return 'deprecated - use ToOQL() instead';}
/**
* @deprecated use ToOQL() instead
* @internal
* @return string
*/
public function __DescribeHTML(){return 'deprecated - use ToOQL() instead';}
/**
* @internal
* @deprecated use ToOQL() instead
* @return string
*/
public function Describe()
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use ToOQL() instead');
/**
* @internal
* @return mixed
*/
return 'deprecated - use ToOQL() instead';
}
/**
* @internal
* @deprecated use ToOQL() instead
* @return string
*/
public function DescribeConditionPointTo($sExtKeyAttCode, $aPointingTo)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use ToOQL() instead');
return 'deprecated - use ToOQL() instead';
}
/**
* @internal
* @deprecated use ToOQL() instead
* @return string
*/
public function DescribeConditionRefBy($sForeignClass, $sForeignExtKeyAttCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use ToOQL() instead');
return 'deprecated - use ToOQL() instead';
}
/**
* @internal
* @deprecated use ToOQL() instead
* @return string
*/
public function DescribeConditionRelTo($aRelInfo)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use ToOQL() instead');
return 'deprecated - use ToOQL() instead';
}
/**
* @internal
* @deprecated use ToOQL() instead
* @return string
*/
public function DescribeConditions()
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use ToOQL() instead');
return 'deprecated - use ToOQL() instead';
}
/**
* @internal
* @deprecated use ToOQL() instead
* @return string
*/
public function __DescribeHTML()
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use ToOQL() instead');
return 'deprecated - use ToOQL() instead';
}
/**
* @internal
* @return mixed
*/
abstract public function ResetCondition();
/**
* add $oExpression as a OR
*
* @api
* @see DBSearch::AddConditionExpression()
*
* @param Expression $oExpression
/**
* add $oExpression as a OR
*
* @api
* @see DBSearch::AddConditionExpression()
*
* @param Expression $oExpression
*
* @return mixed
*/
@@ -1004,10 +1040,8 @@ abstract class DBSearch
}
/**
* Generate a SQL query from the current search
*
* @internal
*
* Generate a SQL query from the current search
*
* @param array $aOrderBy Array of '[<classalias>.]attcode' => bAscending
* @param array $aArgs
* @param null $aAttToLoad
@@ -1015,12 +1049,16 @@ abstract class DBSearch
* @param int $iLimitCount
* @param int $iLimitStart
* @param bool $bGetCount
* @param bool $bBeautifulSQL
*
* @return string
* @throws CoreException
* @throws Exception
* @throws MissingQueryArgument
* @throws \ConfigException
* @throws \CoreException
* @throws \MissingQueryArgument
* @internal
*
*/
public function MakeSelectQuery($aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0, $bGetCount = false)
public function MakeSelectQuery($aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0, $bGetCount = false, $bBeautifulSQL = true)
{
// Check the order by specification, and prefix with the class alias
// and make sure that the ordering columns are going to be selected
@@ -1085,8 +1123,7 @@ abstract class DBSearch
}
try
{
// $bBeautifulSQL = self::$m_bTraceQueries || self::$m_bDebugQuery || self::$m_bIndentQueries;
$sRes = $oSQLQuery->RenderSelect($aOrderSpec, $aScalarArgs, $iLimitCount, $iLimitStart, $bGetCount, true);
$sRes = $oSQLQuery->RenderSelect($aOrderSpec, $aScalarArgs, $iLimitCount, $iLimitStart, $bGetCount, $bBeautifulSQL);
if ($sClassAlias == '_itop_')
{
IssueLog::Info('SQL Query (_itop_): '.$sRes);

View File

@@ -242,7 +242,7 @@ class DeletionPlan
public function SetDeletionIssues($oObject, $aIssues, $bSecurityIssue)
{
if (count($aIssues) > 0)
if (count($aIssues ?? []) > 0)
{
$sClass = get_class($oObject);
$iId = $oObject->GetKey();

View File

@@ -15,6 +15,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\Helper\WebResourcesHelper;
use Combodo\iTop\Application\UI\Base\Component\MedallionIcon\MedallionIcon;
use Combodo\iTop\Application\UI\Base\Component\Panel\Panel;
use Combodo\iTop\Renderer\BlockRenderer;
@@ -119,48 +120,41 @@ class DisplayableNode extends GraphNode
$Alpha = 1.0;
$oPdf->SetFillColor(200, 200, 200);
$oPdf->setAlpha(1);
$sIconUrl = $this->GetProperty('icon_url');
$sIconPath = str_replace(utils::GetAbsoluteUrlModulesRoot(), APPROOT.'env-'.utils::GetCurrentEnvironment().'/', $sIconUrl);
if ($this->GetProperty('source'))
{
$oPdf->SetLineStyle(array('width' => 2*$fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(204, 51, 51)));
if ($this->GetProperty('source')) {
$oPdf->SetLineStyle(array('width' => 2 * $fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(204, 51, 51)));
$oPdf->Circle($this->x * $fScale, $this->y * $fScale, 16 * 1.25 * $fScale, 0, 360, 'D');
} else if ($this->GetProperty('sink')) {
$oPdf->SetLineStyle(array('width' => 2 * $fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(51, 51, 204)));
$oPdf->Circle($this->x * $fScale, $this->y * $fScale, 16 * 1.25 * $fScale, 0, 360, 'D');
}
else if ($this->GetProperty('sink'))
{
$oPdf->SetLineStyle(array('width' => 2*$fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(51, 51, 204)));
$oPdf->Circle($this->x * $fScale, $this->y * $fScale, 16 * 1.25 * $fScale, 0, 360, 'D');
}
if (!$this->GetProperty('is_reached'))
{
if (!$this->GetProperty('is_reached')) {
$sTempImageName = $this->CreateWhiteIcon($oGraph, $sIconPath);
if ($sTempImageName != null)
{
$oPdf->Image($sTempImageName, ($this->x - 16)*$fScale, ($this->y - 16)*$fScale, 32*$fScale, 32*$fScale, 'PNG');
if ($sTempImageName != null) {
$oPdf->AddImage($sTempImageName, ($this->x - 16) * $fScale, ($this->y - 16) * $fScale, 32 * $fScale, 32 * $fScale, 'PNG');
}
$Alpha = 0.4;
$oPdf->setAlpha($Alpha);
}
$oPdf->Image($sIconPath, ($this->x - 16)*$fScale, ($this->y - 16)*$fScale, 32*$fScale, 32*$fScale);
$oPdf->AddImage($sIconPath, ($this->x - 16) * $fScale, ($this->y - 16) * $fScale, 32 * $fScale, 32 * $fScale);
$aContextRootCauses = $this->GetProperty('context_root_causes');
if (!is_null($aContextRootCauses))
{
if (!is_null($aContextRootCauses)) {
$idx = 0;
foreach($aContextRootCauses as $key => $aObjects)
{
$sgn = 2*($idx %2) -1;
$coef = floor((1+$idx)/2) * $sgn;
$alpha = $coef*pi()/4 - pi()/2;
$x = $this->x * $fScale + cos($alpha) * 16*1.25 * $fScale;
$y = $this->y * $fScale + sin($alpha) * 16*1.25 * $fScale;
foreach ($aContextRootCauses as $key => $aObjects) {
$sgn = 2 * ($idx % 2) - 1;
$coef = floor((1 + $idx) / 2) * $sgn;
$alpha = $coef * pi() / 4 - pi() / 2;
$x = $this->x * $fScale + cos($alpha) * 16 * 1.25 * $fScale;
$y = $this->y * $fScale + sin($alpha) * 16 * 1.25 * $fScale;
$l = 32 * $fScale / 3;
$sIconPath = APPROOT.'env-'.utils::GetCurrentEnvironment().'/'.$aContextDefs[$key]['icon'];
$oPdf->Image($sIconPath, $x - $l/2, $y - $l/2, $l, $l);
$oPdf->AddImage($sIconPath, $x - $l / 2, $y - $l / 2, $l, $l);
$idx++;
}
}
@@ -413,7 +407,7 @@ class DisplayableNode extends GraphNode
{
$oNewNode = new DisplayableGroupNode($oGraph, $sNewId);
$oNewNode->SetProperty('label', 'x'.$aGroupProps['count']);
$oNewNode->SetProperty('icon_url', $aGroupProps['icon_url']);
$oNewNode->SetProperty('icon_url', MetaModel::GetClassIcon($sClass, false));
$oNewNode->SetProperty('class', $sClass);
$oNewNode->SetProperty('is_reached', ($sStatus == 'reached'));
$oNewNode->SetProperty('count', $aGroupProps['count']);
@@ -469,7 +463,7 @@ class DisplayableNode extends GraphNode
{
$aRootCauses[] = $oRootCause->GetHyperlink();
}
$sHtml .= '<p><img style="max-height: 24px; vertical-align:bottom;" src="'.utils::GetAbsoluteUrlModulesRoot().$aContext['icon'].'" title="'.htmlentities(Dict::S($aContext['dict'])).'">&nbsp;'.implode(', ', $aRootCauses).'</p>';
$sHtml .= '<p><img style="max-height: 24px; vertical-align:bottom;" class="ibo-class-icon ibo-is-small" src="'.utils::GetAbsoluteUrlModulesRoot().$aContext['icon'].'" title="'.htmlentities(Dict::S($aContext['dict'])).'">&nbsp;'.implode(', ', $aRootCauses).'</p>';
}
$sHtml .= '<hr/>';
}
@@ -593,7 +587,7 @@ class DisplayableRedundancyNode extends DisplayableNode
{
$oNewNode = new DisplayableGroupNode($oGraph, '-'.$this->GetId().'::'.$sClass.'/'.$sStatus);
$oNewNode->SetProperty('label', 'x'.count($aGroupProps['nodes']));
$oNewNode->SetProperty('icon_url', $aGroupProps['icon_url']);
$oNewNode->SetProperty('icon_url', MetaModel::GetClassIcon($sClass, false));
$oNewNode->SetProperty('is_reached', ($sStatus == 'is_reached'));
$oNewNode->SetProperty('class', $sClass);
$oNewNode->SetProperty('count', count($aGroupProps['nodes']));
@@ -771,46 +765,39 @@ class DisplayableGroupNode extends DisplayableNode
{
$bReached = $this->GetProperty('is_reached');
$oPdf->SetFillColor(255, 255, 255);
if ($bReached)
{
if ($bReached) {
$aBorderColor = array(100, 100, 100);
}
else
{
} else {
$aBorderColor = array(200, 200, 200);
}
$oPdf->SetLineStyle(array('width' => 2*$fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => $aBorderColor));
$oPdf->SetLineStyle(array('width' => 2 * $fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => $aBorderColor));
$sIconUrl = $this->GetProperty('icon_url');
$sIconPath = str_replace(utils::GetAbsoluteUrlModulesRoot(), APPROOT.'env-'.utils::GetCurrentEnvironment().'/', $sIconUrl);
$oPdf->SetAlpha(1);
$oPdf->Circle($this->x*$fScale, $this->y*$fScale, $this->GetWidth() / 2 * $fScale, 0, 360, 'DF');
if ($bReached)
{
$oPdf->Circle($this->x * $fScale, $this->y * $fScale, $this->GetWidth() / 2 * $fScale, 0, 360, 'DF');
if ($bReached) {
$oPdf->SetAlpha(1);
}
else
{
} else {
$oPdf->SetAlpha(0.4);
}
$oPdf->Image($sIconPath, ($this->x - 17)*$fScale, ($this->y - 17)*$fScale, 16*$fScale, 16*$fScale);
$oPdf->Image($sIconPath, ($this->x + 1)*$fScale, ($this->y - 17)*$fScale, 16*$fScale, 16*$fScale);
$oPdf->Image($sIconPath, ($this->x -8)*$fScale, ($this->y +1)*$fScale, 16*$fScale, 16*$fScale);
$oPdf->AddImage($sIconPath, ($this->x - 17) * $fScale, ($this->y - 17) * $fScale, 16 * $fScale, 16 * $fScale);
$oPdf->AddImage($sIconPath, ($this->x + 1) * $fScale, ($this->y - 17) * $fScale, 16 * $fScale, 16 * $fScale);
$oPdf->AddImage($sIconPath, ($this->x - 8) * $fScale, ($this->y + 1) * $fScale, 16 * $fScale, 16 * $fScale);
$oPdf->SetFontParams('', 24 * $fScale, '', true);
$width = $oPdf->GetStringWidth($this->GetProperty('label'));
$oPdf->SetTextColor(0, 0, 0);
$oPdf->Text($this->x*$fScale - $width/2, ($this->y + 25)*$fScale, $this->GetProperty('label'));
$oPdf->Text($this->x * $fScale - $width / 2, ($this->y + 25) * $fScale, $this->GetProperty('label'));
}
public function GetTooltip($aContextDefs)
{
$sHtml = '';
$iGroupIdx = $this->GetProperty('group_index');
$sHtml .= '<a href="#" onclick="$(\'.itop-simple-graph\').simple_graph(\'show_group\', \'relation_group_'.$iGroupIdx.'\');">'.Dict::Format('UI:RelationGroupNumber_N', (1+$iGroupIdx))."</a>";
$sHtml = '<a href="#" id="a_'.$iGroupIdx.'" onclick="$(this).closest(\'.tippy-box\').parent().hide();$(\'.itop-simple-graph\').simple_graph(\'show_group\', \'relation_group_'.$iGroupIdx.'\');return false;">'.Dict::Format('UI:RelationGroupNumber_N', (1+$iGroupIdx))."</a>";
$sHtml .= '<hr/>';
$sHtml .= '<table><tbody><tr>';
$sHtml .= '<td style="vertical-align:top;padding-right: 0.5em;"><img src="'.$this->GetProperty('icon_url').'"></td><td style="vertical-align:top">'.MetaModel::GetName($this->GetObjectClass()).'<br/>';
$sHtml .= '<td style="vertical-align:top;padding-right: 0.5em;"><img class="ibo-class-icon ibo-is-small" src="'.$this->GetProperty('icon_url').'"></td><td style="vertical-align:top">'.MetaModel::GetName($this->GetObjectClass()).'<br/>';
$sHtml .= Dict::Format('UI_CountOfObjectsShort', $this->GetObjectCount()).'</td>';
$sHtml .= '</tr></tbody></table>';
return $sHtml;
@@ -859,66 +846,68 @@ class DisplayableGraph extends SimpleGraph
@unlink($sTempFile);
}
}
/**
* Build a DisplayableGraph from a RelationGraph
*
* @param RelationGraph $oGraph
* @param number $iGroupingThreshold
* @param string $bDirectionDown
*
* @return DisplayableGraph
*/
public static function FromRelationGraph(RelationGraph $oGraph, $iGroupingThreshold = 20, $bDirectionDown = true)
public static function FromRelationGraph(RelationGraph $oGraph, $iGroupingThreshold = 20, $bDirectionDown = true, $bForPdf = false)
{
$oNewGraph = new DisplayableGraph();
$oNewGraph->bDirectionDown = $bDirectionDown;
$iPreviousTimeLimit = ini_get('max_execution_time');
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
$oNodesIter = new RelationTypeIterator($oGraph, 'Node');
foreach($oNodesIter as $oNode)
{
foreach ($oNodesIter as $oNode) {
set_time_limit(intval($iLoopTimeLimit));
switch(get_class($oNode))
{
case 'RelationObjectNode':
$oNewNode = new DisplayableNode($oNewGraph, $oNode->GetId(), 0, 0);
$oObj = $oNode->GetProperty('object');
$sClass = get_class($oObj);
if ($oNode->GetProperty('source'))
{
if (!array_key_exists($sClass, $oNewGraph->aSourceObjects))
{
$oNewGraph->aSourceObjects[$sClass] = array();
switch (get_class($oNode)) {
case 'RelationObjectNode':
$oNewNode = new DisplayableNode($oNewGraph, $oNode->GetId(), 0, 0);
$oObj = $oNode->GetProperty('object');
$sClass = get_class($oObj);
if ($oNode->GetProperty('source')) {
if (!array_key_exists($sClass, $oNewGraph->aSourceObjects)) {
$oNewGraph->aSourceObjects[$sClass] = array();
}
$oNewGraph->aSourceObjects[$sClass][] = $oObj->GetKey();
$oNewNode->SetProperty('source', true);
}
$oNewGraph->aSourceObjects[$sClass][] = $oObj->GetKey();
$oNewNode->SetProperty('source', true);
}
if ($oNode->GetProperty('sink'))
{
if (!array_key_exists($sClass, $oNewGraph->aSinkObjects))
{
$oNewGraph->aSinkObjects[$sClass] = array();
if ($oNode->GetProperty('sink')) {
if (!array_key_exists($sClass, $oNewGraph->aSinkObjects)) {
$oNewGraph->aSinkObjects[$sClass] = array();
}
$oNewGraph->aSinkObjects[$sClass][] = $oObj->GetKey();
$oNewNode->SetProperty('sink', true);
}
$oNewGraph->aSinkObjects[$sClass][] = $oObj->GetKey();
$oNewNode->SetProperty('sink', true);
}
$oNewNode->SetProperty('object', $oObj);
$oNewNode->SetProperty('icon_url', $oObj->GetIcon(false));
$oNewNode->SetProperty('label', $oObj->GetRawName());
$oNewNode->SetProperty('is_reached', $bDirectionDown ? $oNode->GetProperty('is_reached') : true); // When going "up" is_reached does not matter
$oNewNode->SetProperty('is_reached_allowed', $oNode->GetProperty('is_reached_allowed'));
$oNewNode->SetProperty('context_root_causes', $oNode->GetProperty('context_root_causes'));
break;
$oNewNode->SetProperty('object', $oObj);
$sIconUrl = $oObj->GetIcon(false);
//when icons are displayed in a PDF file, puts the image data in place of the url
if ($bForPdf && strpos($sIconUrl, 'display_document') > 0) {
$sImageAttCode = MetaModel::GetImageAttributeCode($sClass);
$sIconUrl = '@'.$oObj->Get($sImageAttCode)->GetData();
}
$oNewNode->SetProperty('icon_url', $sIconUrl);
$oNewNode->SetProperty('label', $oObj->GetRawName());
$oNewNode->SetProperty('is_reached', $bDirectionDown ? $oNode->GetProperty('is_reached') : true); // When going "up" is_reached does not matter
$oNewNode->SetProperty('is_reached_allowed', $oNode->GetProperty('is_reached_allowed'));
$oNewNode->SetProperty('context_root_causes', $oNode->GetProperty('context_root_causes'));
break;
default:
$oNewNode = new DisplayableRedundancyNode($oNewGraph, $oNode->GetId(), 0, 0);
$iNbReached = (is_null($oNode->GetProperty('is_reached_count'))) ? 0 : $oNode->GetProperty('is_reached_count');
$oNewNode->SetProperty('label', $iNbReached."/".($oNode->GetProperty('min_up') + $oNode->GetProperty('threshold')));
$oNewNode->SetProperty('min_up', $oNode->GetProperty('min_up'));
$oNewNode->SetProperty('threshold', $oNode->GetProperty('threshold'));
$oNewNode->SetProperty('is_reached_count', $iNbReached);
$oNewNode->SetProperty('is_reached', true);
$oNewNode = new DisplayableRedundancyNode($oNewGraph, $oNode->GetId(), 0, 0);
$iNbReached = (is_null($oNode->GetProperty('is_reached_count'))) ? 0 : $oNode->GetProperty('is_reached_count');
$oNewNode->SetProperty('label', $iNbReached."/".($oNode->GetProperty('min_up') + $oNode->GetProperty('threshold')));
$oNewNode->SetProperty('min_up', $oNode->GetProperty('min_up'));
$oNewNode->SetProperty('threshold', $oNode->GetProperty('threshold'));
$oNewNode->SetProperty('is_reached_count', $iNbReached);
$oNewNode->SetProperty('is_reached', true);
}
}
$oEdgesIter = new RelationTypeIterator($oGraph, 'Edge');
@@ -1185,7 +1174,7 @@ class DisplayableGraph extends SimpleGraph
return json_encode($aData);
}
/**
* Sort class "codes" based on their localized name
* @param string $sClass1
@@ -1196,12 +1185,12 @@ class DisplayableGraph extends SimpleGraph
{
return strcasecmp(MetaModel::GetName($sClass1), MetaModel::GetName($sClass2));
}
/**
* Renders the graph in a PDF document: centered in the current page
* @param PDFPage $oPage The PDFPage representing the PDF document to draw into
* @param string $sComments An optional comment to display next to the graph (HTML entities will be escaped, \n replaced by <br/>)
* @param string $sContextKey The key to fetch the queries in the configuration. Example: itop-tickets/relation_context/UserRequest/impacts/down
* @param string $sContextKey The key to fetch the queries in the configuration. Example: itop-tickets/relation_context/UserRequest/impacts/down
* @param float $xMin Left coordinate of the bounding box to display the graph
* @param float $xMax Right coordinate of the bounding box to display the graph
* @param float $yMin Top coordinate of the bounding box to display the graph
@@ -1329,20 +1318,18 @@ class DisplayableGraph extends SimpleGraph
$yPos = $yMin + $fPadding;
$oPdf->SetFillColor(225, 225, 225);
$oPdf->Cell($fIconSize + $fPadding + $fMaxWidth, $fIconSize + $fPadding, Dict::S('UI:Relation:Key'), 0 /* border */, 1 /* ln */, 'C', true /* fill */);
$yPos += $fIconSize + 2*$fPadding;
foreach($aClasses as $sClass => $sLabel)
{
$yPos += $fIconSize + 2 * $fPadding;
foreach ($aClasses as $sClass => $sLabel) {
$oPdf->SetX($xMin + $fIconSize + $fPadding);
$oPdf->Cell(0, $fIconSize + 2*$fPadding, $sLabel, 0 /* border */, 1 /* ln */);
$oPdf->Image($aIcons[$sClass], $xMin+1, $yPos, $fIconSize, $fIconSize);
$yPos += $fIconSize + 2*$fPadding;
$oPdf->Cell(0, $fIconSize + 2 * $fPadding, $sLabel, 0 /* border */, 1 /* ln */);
$oPdf->AddImage($aIcons[$sClass], $xMin + 1, $yPos, $fIconSize, $fIconSize);
$yPos += $fIconSize + 2 * $fPadding;
}
foreach($aContexts as $key => $sLabel)
{
foreach ($aContexts as $key => $sLabel) {
$oPdf->SetX($xMin + $fIconSize + $fPadding);
$oPdf->Cell(0, $fIconSize + 2*$fPadding, $sLabel, 0 /* border */, 1 /* ln */);
$oPdf->Image($aContextIcons[$key], $xMin+1+$fIconSize*0.125, $yPos+$fIconSize*0.125, $fIconSize*0.75, $fIconSize*0.75);
$yPos += $fIconSize + 2*$fPadding;
$oPdf->Cell(0, $fIconSize + 2 * $fPadding, $sLabel, 0 /* border */, 1 /* ln */);
$oPdf->AddImage($aContextIcons[$key], $xMin + 1 + $fIconSize * 0.125, $yPos + $fIconSize * 0.125, $fIconSize * 0.75, $fIconSize * 0.75);
$yPos += $fIconSize + 2 * $fPadding;
}
$oPdf->Rect($xMin, $yMin, $fMaxWidth + $fIconSize + 3*$fPadding, $yMax - $yMin, 'D');
@@ -1453,9 +1440,9 @@ class DisplayableGraph extends SimpleGraph
$sSftShort = Dict::S('UI:ElementsDisplayed');
$sSearchToggle = Dict::S('UI:Search:Toggle');
$oP->add("<div class=\"not-printable\">\n");
$oUiSearchBlock = new Panel($sSftShort, [],Panel::ENUM_COLOR_CYAN, 'ds_flash');
$oUiSearchBlock = new Panel($sSftShort, [],Panel::ENUM_COLOR_SCHEME_CYAN, 'ds_flash');
$oUiSearchBlock->SetCSSClasses(["ibo-search-form-panel", "display_block"]);
$oUiSearchBlock->SetIsCollapsible(true);
$oUiHtmlBlock = new Combodo\iTop\Application\UI\Base\Component\Html\Html(
<<<EOF
<div id="ds_flash" class="search_box ibo-display-graph--search-box">
@@ -1506,11 +1493,8 @@ EOF
$sDirection = utils::ReadParam('d', 'horizontal');
$iGroupingThreshold = utils::ReadParam('g', 5);
$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/fraphael.js');
$oP->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/jquery.contextMenu.css');
$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.contextMenu.js');
$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/simple_graph.js');
WebResourcesHelper::EnableSimpleGraphInWebPage($oP);
try
{
$this->InitFromGraphviz();

View File

@@ -24,6 +24,10 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Pelago\Emogrifier\CssInliner;
use Pelago\Emogrifier\HtmlProcessor\CssToAttributeConverter;
use Pelago\Emogrifier\HtmlProcessor\HtmlPruner;
Swift_Preferences::getInstance()->setCharset('UTF-8');
@@ -335,8 +339,9 @@ class EMail
{
if (($sMimeType === 'text/html') && ($sCustomStyles !== null))
{
$emogrifier = new \Pelago\Emogrifier($sBody, $sCustomStyles);
$sBody = $emogrifier->emogrify(); // Adds html/body tags if not already present
$oDomDocument = CssInliner::fromHtml($sBody)->inlineCss($sCustomStyles)->getDomDocument();
HtmlPruner::fromDomDocument($oDomDocument)->removeElementsWithDisplayNone();
$sBody = CssToAttributeConverter::fromDomDocument($oDomDocument)->convertCssToVisualAttributes()->render(); // Adds html/body tags if not already present
}
$this->m_aData['body'] = array('body' => $sBody, 'mimeType' => $sMimeType);
$this->m_oMessage->setBody($sBody, $sMimeType);

View File

@@ -222,6 +222,10 @@ class EventIssue extends Event
//
$this->Set('page', @$GLOBALS['_SERVER']['SCRIPT_NAME']);
if (strlen($this->Get('userinfo')) == 0) {
$this->Set('userinfo', UserRights::GetUserId());
}
if (array_key_exists('_GET', $GLOBALS) && is_array($GLOBALS['_GET']))
{
$this->Set('arguments_get', $GLOBALS['_GET']);

View File

@@ -97,64 +97,163 @@ class HTMLNullSanitizer extends HTMLSanitizer
{
return $sHTML;
}
}
/**
* A standard-compliant HTMLSanitizer based on the HTMLPurifier library by Edward Z. Yang
* Complete but quite slow
* http://htmlpurifier.org
* Common implementation for sanitizer using DOM parsing
*/
/*
class HTMLPurifierSanitizer extends HTMLSanitizer
abstract class DOMSanitizer extends HTMLSanitizer
{
protected static $oPurifier = null;
/** @var DOMDocument */
protected $oDoc;
public function __construct()
{
if (self::$oPurifier == null)
{
$sLibPath = APPROOT.'lib/htmlpurifier/HTMLPurifier.auto.php';
if (!file_exists($sLibPath))
{
throw new Exception("Missing library '$sLibPath', cannot use HTMLPurifierSanitizer.");
}
require_once($sLibPath);
abstract public function GetTagsWhiteList();
$oPurifierConfig = HTMLPurifier_Config::createDefault();
$oPurifierConfig->set('Core.Encoding', 'UTF-8'); // defaults to 'UTF-8'
$oPurifierConfig->set('HTML.Doctype', 'XHTML 1.0 Strict'); // defaults to 'XHTML 1.0 Transitional'
$oPurifierConfig->set('URI.AllowedSchemes', array (
'http' => true,
'https' => true,
'data' => true, // This one is not present by default
));
$sPurifierCache = APPROOT.'data/HTMLPurifier';
if (!is_dir($sPurifierCache))
{
mkdir($sPurifierCache);
}
if (!is_dir($sPurifierCache))
{
throw new Exception("Could not create the cache directory '$sPurifierCache'");
}
$oPurifierConfig->set('Cache.SerializerPath', $sPurifierCache); // no trailing slash
self::$oPurifier = new HTMLPurifier($oPurifierConfig);
}
}
abstract public function GetTagsBlackList();
abstract public function GetAttrsWhiteList();
abstract public function GetAttrsBlackList();
abstract public function GetStylesWhiteList();
public function DoSanitize($sHTML)
{
$sCleanHtml = self::$oPurifier->purify($sHTML);
$this->oDoc = new DOMDocument();
$this->oDoc->preserveWhitespace = true;
// MS outlook implements empty lines by the mean of <p><o:p></o:p></p>
// We have to transform that into <p><br></p> (which is how Thunderbird implements empty lines)
// Unfortunately, DOMDocument::loadHTML does not take the tag namespaces into account (once loaded there is no way to know if the tag did have a namespace)
// therefore we have to do the transformation upfront
$sHTML = preg_replace('@<o:p>(\s|&nbsp;)*</o:p>@', '<br>', $sHTML);
$this->LoadDoc($sHTML);
$this->CleanNode($this->oDoc);
$sCleanHtml = $this->PrintDoc();
return $sCleanHtml;
}
abstract public function LoadDoc($sHTML);
/**
* @return string cleaned source
* @uses \DOMSanitizer::oDoc
*/
abstract public function PrintDoc();
protected function CleanNode(DOMNode $oElement)
{
$aAttrToRemove = array();
// Gather the attributes to remove
if ($oElement->hasAttributes()) {
foreach ($oElement->attributes as $oAttr) {
$sAttr = strtolower($oAttr->name);
if ((false === empty($this->GetAttrsBlackList()))
&& (in_array($sAttr, $this->GetAttrsBlackList(), true))) {
$aAttrToRemove[] = $oAttr->name;
} else if ((false === empty($this->GetTagsWhiteList()))
&& (false === in_array($sAttr, $this->GetTagsWhiteList()[strtolower($oElement->tagName)]))) {
$aAttrToRemove[] = $oAttr->name;
} else if (!$this->IsValidAttributeContent($sAttr, $oAttr->value)) {
// Invalid content
$aAttrToRemove[] = $oAttr->name;
} else if ($sAttr == 'style') {
// Special processing for style tags
$sCleanStyle = $this->CleanStyle($oAttr->value);
if ($sCleanStyle == '') {
// Invalid content
$aAttrToRemove[] = $oAttr->name;
} else {
$oElement->setAttribute($oAttr->name, $sCleanStyle);
}
}
}
// Now remove them
foreach($aAttrToRemove as $sName)
{
$oElement->removeAttribute($sName);
}
}
if ($oElement->hasChildNodes())
{
$aChildElementsToRemove = array();
// Gather the child noes to remove
foreach($oElement->childNodes as $oNode) {
if ($oNode instanceof DOMElement) {
$sNodeTagName = strtolower($oNode->tagName);
}
if (($oNode instanceof DOMElement)
&& (false === empty($this->GetTagsBlackList()))
&& (in_array($sNodeTagName, $this->GetTagsBlackList(), true))) {
$aChildElementsToRemove[] = $oNode;
} else if (($oNode instanceof DOMElement)
&& (false === empty($this->GetTagsWhiteList()))
&& (false === array_key_exists($sNodeTagName, $this->GetTagsWhiteList()))) {
$aChildElementsToRemove[] = $oNode;
} else if ($oNode instanceof DOMComment) {
$aChildElementsToRemove[] = $oNode;
} else {
// Recurse
$this->CleanNode($oNode);
if (($oNode instanceof DOMElement) && (strtolower($oNode->tagName) == 'img')) {
InlineImage::ProcessImageTag($oNode);
}
}
}
// Now remove them
foreach($aChildElementsToRemove as $oDomElement)
{
$oElement->removeChild($oDomElement);
}
}
}
protected function IsValidAttributeContent($sAttributeName, $sValue)
{
if ((false === empty($this->GetAttrsBlackList()))
&& (in_array($sAttributeName, $this->GetAttrsBlackList(), true))) {
return true;
}
if (array_key_exists($sAttributeName, $this->GetAttrsWhiteList())) {
return preg_match($this->GetAttrsWhiteList()[$sAttributeName], $sValue);
}
return true;
}
protected function CleanStyle($sStyle)
{
if (empty($this->GetStylesWhiteList())) {
return $sStyle;
}
$aAllowedStyles = array();
$aItems = explode(';', $sStyle);
{
foreach ($aItems as $sItem) {
$aElements = explode(':', trim($sItem));
if (in_array(trim(strtolower($aElements[0])), $this->GetStylesWhiteList())) {
$aAllowedStyles[] = trim($sItem);
}
}
}
return implode(';', $aAllowedStyles);
}
}
*/
class HTMLDOMSanitizer extends HTMLSanitizer
class HTMLDOMSanitizer extends DOMSanitizer
{
protected $oDoc;
/**
* @var array
* @see https://www.itophub.io/wiki/page?id=2_6_0%3Aadmin%3Arich_text_limitations
@@ -239,6 +338,31 @@ class HTMLDOMSanitizer extends HTMLSanitizer
'white-space',
);
public function GetTagsWhiteList()
{
return static::$aTagsWhiteList;
}
public function GetTagsBlackList()
{
return [];
}
public function GetAttrsWhiteList()
{
return static::$aAttrsWhiteList;
}
public function GetAttrsBlackList()
{
return [];
}
public function GetStylesWhiteList()
{
return static::$aStylesWhiteList;
}
public function __construct()
{
parent::__construct();
@@ -264,139 +388,152 @@ class HTMLDOMSanitizer extends HTMLSanitizer
}
}
public function DoSanitize($sHTML)
public function LoadDoc($sHTML)
{
$this->oDoc = new DOMDocument();
$this->oDoc->preserveWhitespace = true;
// MS outlook implements empty lines by the mean of <p><o:p></o:p></p>
// We have to transform that into <p><br></p> (which is how Thunderbird implements empty lines)
// Unfortunately, DOMDocument::loadHTML does not take the tag namespaces into account (once loaded there is no way to know if the tag did have a namespace)
// therefore we have to do the transformation upfront
$sHTML = preg_replace('@<o:p>(\s|&nbsp;)*</o:p>@', '<br>', $sHTML);
// Replace badly encoded non breaking space
$sHTML = preg_replace('~\xc2\xa0~', ' ', $sHTML);
@$this->oDoc->loadHTML('<?xml encoding="UTF-8"?>'.$sHTML); // For loading HTML chunks where the character set is not specified
$this->oDoc->preserveWhitespace = true;
}
$this->CleanNode($this->oDoc);
public function PrintDoc()
{
$oXPath = new DOMXPath($this->oDoc);
$sXPath = "//body";
$oNodesList = $oXPath->query($sXPath);
if ($oNodesList->length == 0)
{
if ($oNodesList->length == 0) {
// No body, save the whole document
$sCleanHtml = $this->oDoc->saveHTML();
}
else
{
} else {
// Export only the content of the body tag
$sCleanHtml = $this->oDoc->saveHTML($oNodesList->item(0));
// remove the body tag itself
$sCleanHtml = str_replace( array('<body>', '</body>'), '', $sCleanHtml);
$sCleanHtml = str_replace(array('<body>', '</body>'), '', $sCleanHtml);
}
return $sCleanHtml;
}
}
protected function CleanNode(DOMNode $oElement)
/**
* @since 2.6.5 2.7.6 3.0.0 N°4360
*/
class SVGDOMSanitizer extends DOMSanitizer
{
public function GetTagsWhiteList()
{
$aAttrToRemove = array();
// Gather the attributes to remove
if ($oElement->hasAttributes())
{
foreach($oElement->attributes as $oAttr)
{
$sAttr = strtolower($oAttr->name);
if (!in_array($sAttr, self::$aTagsWhiteList[strtolower($oElement->tagName)]))
{
// Forbidden (or unknown) attribute
$aAttrToRemove[] = $oAttr->name;
}
else if (!$this->IsValidAttributeContent($sAttr, $oAttr->value))
{
// Invalid content
$aAttrToRemove[] = $oAttr->name;
}
else if ($sAttr == 'style')
{
// Special processing for style tags
$sCleanStyle = $this->CleanStyle($oAttr->value);
if ($sCleanStyle == '')
{
// Invalid content
$aAttrToRemove[] = $oAttr->name;
}
else
{
$oElement->setAttribute($oAttr->name, $sCleanStyle);
}
}
}
// Now remove them
foreach($aAttrToRemove as $sName)
{
$oElement->removeAttribute($sName);
}
}
if ($oElement->hasChildNodes())
{
$aChildElementsToRemove = array();
// Gather the child noes to remove
foreach($oElement->childNodes as $oNode)
{
if (($oNode instanceof DOMElement) && (!array_key_exists(strtolower($oNode->tagName), self::$aTagsWhiteList)))
{
$aChildElementsToRemove[] = $oNode;
}
else if ($oNode instanceof DOMComment)
{
$aChildElementsToRemove[] = $oNode;
}
else
{
// Recurse
$this->CleanNode($oNode);
if (($oNode instanceof DOMElement) && (strtolower($oNode->tagName) == 'img'))
{
InlineImage::ProcessImageTag($oNode);
}
}
}
// Now remove them
foreach($aChildElementsToRemove as $oDomElement)
{
$oElement->removeChild($oDomElement);
}
}
return [];
}
protected function CleanStyle($sStyle)
/**
* @return string[]
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script
*/
public function GetTagsBlackList()
{
$aAllowedStyles = array();
$aItems = explode(';', $sStyle);
{
foreach($aItems as $sItem)
{
$aElements = explode(':', trim($sItem));
if (in_array(trim(strtolower($aElements[0])), static::$aStylesWhiteList))
{
$aAllowedStyles[] = trim($sItem);
}
}
}
return implode(';', $aAllowedStyles);
return [
'script',
];
}
protected function IsValidAttributeContent($sAttributeName, $sValue)
public function GetAttrsWhiteList()
{
if (array_key_exists($sAttributeName, self::$aAttrsWhiteList))
{
return preg_match(self::$aAttrsWhiteList[$sAttributeName], $sValue);
}
return true;
return [];
}
/**
* @return string[]
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events#document_event_attributes
*/
public function GetAttrsBlackList()
{
return [
'onbegin',
'onbegin',
'onrepeat',
'onabort',
'onerror',
'onerror',
'onscroll',
'onunload',
'oncopy',
'oncut',
'onpaste',
'oncancel',
'oncanplay',
'oncanplaythrough',
'onchange',
'onclick',
'onclose',
'oncuechange',
'ondblclick',
'ondrag',
'ondragend',
'ondragenter',
'ondragleave',
'ondragover',
'ondragstart',
'ondrop',
'ondurationchange',
'onemptied',
'onended',
'onerror',
'onfocus',
'oninput',
'oninvalid',
'onkeydown',
'onkeypress',
'onkeyup',
'onload',
'onloadeddata',
'onloadedmetadata',
'onloadstart',
'onmousedown',
'onmouseenter',
'onmouseleave',
'onmousemove',
'onmouseout',
'onmouseover',
'onmouseup',
'onmousewheel',
'onpause',
'onplay',
'onplaying',
'onprogress',
'onratechange',
'onreset',
'onresize',
'onscroll',
'onseeked',
'onseeking',
'onselect',
'onshow',
'onstalled',
'onsubmit',
'onsuspend',
'ontimeupdate',
'ontoggle',
'onvolumechange',
'onwaiting',
'onactivate',
'onfocusin',
'onfocusout',
];
}
public function GetStylesWhiteList()
{
return [];
}
public function LoadDoc($sHTML)
{
@$this->oDoc->loadXml($sHTML, LIBXML_NOBLANKS);
}
public function PrintDoc()
{
return $this->oDoc->saveXML();
}
}

View File

@@ -6,6 +6,8 @@
*/
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Parser;
use PhpParser\ParserFactory;
use PhpParser\PrettyPrinter\Standard;
@@ -80,38 +82,49 @@ class iTopConfigParser
* @param \PhpParser\Parser $oParser
* @param $sConfig
*
* @return \Combodo\iTop\Config\Validator\ConfigNodesVisitor
* @return void
*/
private function BrowseFile(\PhpParser\Parser $oParser, $sConfig)
private function BrowseFile(Parser $oParser, $sConfig)
{
$prettyPrinter = new Standard();
try
{
try {
$aNodes = $oParser->parse($sConfig);
}
catch (\Error $e)
{
catch (\Error $e) {
$sMessage = Dict::Format('config-parse-error', $e->getMessage(), $e->getLine());
$this->oException = new \Exception($sMessage, 0, $e);
}
foreach ($aNodes as $oAssignation)
{
if (! $oAssignation instanceof Assign)
{
foreach ($aNodes as $sKey => $oNode) {
// With PhpParser 3 we had an Assign node at root
// In PhpParser 4 the root node is now an Expression
if (false === ($oNode instanceof \PhpParser\Node\Stmt\Expression)) {
continue;
}
/** @var \PhpParser\Node\Stmt\Expression $oNode */
if (false === ($oNode->expr instanceof Assign)) {
continue;
}
/** @var Assign $oAssignation */
$oAssignation = $oNode->expr;
if (false === ($oAssignation->var instanceof Variable)) {
continue;
}
if (false === ($oAssignation->expr instanceof PhpParser\Node\Expr\Array_)) {
continue;
}
$sCurrentRootVar = $oAssignation->var->name;
if (!array_key_exists($sCurrentRootVar, $this->aVarsMap))
{
if (!array_key_exists($sCurrentRootVar, $this->aVarsMap)) {
continue;
}
$aCurrentRootVarMap =& $this->aVarsMap[$sCurrentRootVar];
foreach ($oAssignation->expr->items as $oItem)
{
foreach ($oAssignation->expr->items as $oItem) {
$sValue = $prettyPrinter->prettyPrintExpr($oItem->value);
$aCurrentRootVarMap[$oItem->key->value] = $sValue;
}

View File

@@ -198,31 +198,29 @@ class InlineImage extends DBObject
$sOQL = 'SELECT InlineImage WHERE temp_id = :temp_id';
$oSearch = DBObjectSearch::FromOQL($sOQL);
$oSet = new DBObjectSet($oSearch, array(), array('temp_id' => $sTempId));
$aInlineImagesId = array();
while($oInlineImage = $oSet->Fetch())
{
$aInlineImagesId[] = $oInlineImage->GetKey();
$aInlineImagesId = array();
while ($oInlineImage = $oSet->Fetch()) {
$aInlineImagesId[] = $oInlineImage->GetKey();
$oInlineImage->SetItem($oObject);
$oInlineImage->Set('temp_id', '');
$oInlineImage->DBUpdate();
}
IssueLog::Trace('FinalizeInlineImages (see $aInlineImagesId for the id list)', 'InlineImage', array(
'$sObjectClass' => get_class($oObject),
'$sTransactionId' => $iTransactionId,
'$sTempId' => $sTempId,
'$aInlineImagesId' => $aInlineImagesId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
IssueLog::Trace('FinalizeInlineImages (see $aInlineImagesId for the id list)', LogChannels::INLINE_IMAGE, array(
'$sObjectClass' => get_class($oObject),
'$sTransactionId' => $iTransactionId,
'$sTempId' => $sTempId,
'$aInlineImagesId' => $aInlineImagesId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
}
else
{
IssueLog::Trace('FinalizeInlineImages "error" $iTransactionId is null', 'InlineImage', array(
'$sObjectClass' => get_class($oObject),
'$sTransactionId' => $iTransactionId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
else {
IssueLog::Trace('FinalizeInlineImages "error" $iTransactionId is null', LogChannels::INLINE_IMAGE, array(
'$sObjectClass' => get_class($oObject),
'$sTransactionId' => $iTransactionId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
}
}
@@ -231,7 +229,7 @@ class InlineImage extends DBObject
*
* @param string $sTempId
*
* @return void
* @return bool True if cleaning was successful, false if anything aborted it
* @throws \ArchivedObjectException
* @throws \CoreCannotSaveObjectException
* @throws \CoreException
@@ -241,8 +239,19 @@ class InlineImage extends DBObject
* @throws \MySQLHasGoneAwayException
* @throws \OQLException
*/
public static function OnFormCancel($sTempId)
public static function OnFormCancel($sTempId): bool
{
// Protection against unfortunate massive delete of inline images when a null temp ID is passed
if (strlen($sTempId) === 0) {
IssueLog::Trace('OnFormCancel "error" $sTempId is null or empty', LogChannels::INLINE_IMAGE, array(
'$sTempId' => $sTempId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
return false;
}
// Delete all "pending" InlineImages for this form
$sOQL = 'SELECT InlineImage WHERE temp_id = :temp_id';
$oSearch = DBObjectSearch::FromOQL($sOQL);
@@ -253,12 +262,14 @@ class InlineImage extends DBObject
$aInlineImagesId[] = $oInlineImage->GetKey();
$oInlineImage->DBDelete();
}
IssueLog::Trace('OnFormCancel', 'InlineImage', array(
'$sTempId' => $sTempId,
'$aInlineImagesId' => $aInlineImagesId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
IssueLog::Trace('OnFormCancel', LogChannels::INLINE_IMAGE, array(
'$sTempId' => $sTempId,
'$aInlineImagesId' => $aInlineImagesId,
'$sUser' => UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
));
return true;
}
/**
@@ -537,8 +548,6 @@ JS
// Hook the file upload of all CKEditor instances
$('.htmlEditor').each(function() {
var oEditor = $(this).ckeditorGet();
oEditor.config.extraPlugins = 'font,uploadimage';
oEditor.config.uploadUrl = '$sAbsoluteUrlAppRoot'+'pages/ajax.render.php';
oEditor.config.filebrowserBrowseUrl = '$sAbsoluteUrlAppRoot'+'pages/ajax.render.php?operation=cke_browse&temp_id=$sTempId&obj_class=$sObjClass&obj_key=$iObjKey';
oEditor.on( 'fileUploadResponse', function( evt ) {
var fileLoader = evt.data.fileLoader;
@@ -579,7 +588,7 @@ JS
oEditor.on( 'instanceReady', function() {
if(!CKEDITOR.env.iOS && $('#'+oEditor.id+'_toolbox .ibo-vendors-ckeditor--toolbar-fullscreen-button').length == 0)
{
$('#'+oEditor.id+'_toolbox').append('<span class="ibo-vendors-ckeditor--toolbar-fullscreen-button" data-role="ibo-vendors-ckeditor--toolbar-fullscreen-button" title="$sToggleFullScreen" style="background-image:url(\\'$sAbsoluteUrlAppRoot/images/full-screen.png\\')">&nbsp;</span>');
$('#'+oEditor.id+'_toolbox').append('<span class="ibo-vendors-ckeditor--toolbar-fullscreen-button editor-fullscreen-button" data-role="ibo-vendors-ckeditor--toolbar-fullscreen-button" title="$sToggleFullScreen">&nbsp;</span>');
$('#'+oEditor.id+'_toolbox .ibo-vendors-ckeditor--toolbar-fullscreen-button').on('click', function() {
oEditor.execCommand('maximize');
if ($(this).closest('.cke_maximized').length != 0)
@@ -608,17 +617,17 @@ JS
*/
protected function AfterInsert()
{
IssueLog::Trace(__METHOD__, 'InlineImage', array(
'id' => $this->GetKey(),
'expire' => $this->Get('expire'),
'temp_id' => $this->Get('temp_id'),
'item_class' => $this->Get('item_class'),
'item_id' => $this->Get('item_id'),
'item_org_id' => $this->Get('item_org_id'),
'secret' => $this->Get('secret'),
'user' => $sUser = UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
IssueLog::Trace(__METHOD__, LogChannels::INLINE_IMAGE, array(
'id' => $this->GetKey(),
'expire' => $this->Get('expire'),
'temp_id' => $this->Get('temp_id'),
'item_class' => $this->Get('item_class'),
'item_id' => $this->Get('item_id'),
'item_org_id' => $this->Get('item_org_id'),
'secret' => $this->Get('secret'),
'user' => $sUser = UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
));
parent::AfterInsert();
@@ -629,17 +638,17 @@ JS
*/
protected function AfterUpdate()
{
IssueLog::Trace(__METHOD__, 'InlineImage', array(
'id' => $this->GetKey(),
'expire' => $this->Get('expire'),
'temp_id' => $this->Get('temp_id'),
'item_class' => $this->Get('item_class'),
'item_id' => $this->Get('item_id'),
'item_org_id' => $this->Get('item_org_id'),
'secret' => $this->Get('secret'),
'user' => $sUser = UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
IssueLog::Trace(__METHOD__, LogChannels::INLINE_IMAGE, array(
'id' => $this->GetKey(),
'expire' => $this->Get('expire'),
'temp_id' => $this->Get('temp_id'),
'item_class' => $this->Get('item_class'),
'item_id' => $this->Get('item_id'),
'item_org_id' => $this->Get('item_org_id'),
'secret' => $this->Get('secret'),
'user' => $sUser = UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
));
parent::AfterUpdate();
@@ -650,17 +659,17 @@ JS
*/
protected function AfterDelete()
{
IssueLog::Trace(__METHOD__, 'InlineImage', array(
'id' => $this->GetKey(),
'expire' => $this->Get('expire'),
'temp_id' => $this->Get('temp_id'),
'item_class' => $this->Get('item_class'),
'item_id' => $this->Get('item_id'),
'item_org_id' => $this->Get('item_org_id'),
'secret' => $this->Get('secret'),
'user' => $sUser = UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
IssueLog::Trace(__METHOD__, LogChannels::INLINE_IMAGE, array(
'id' => $this->GetKey(),
'expire' => $this->Get('expire'),
'temp_id' => $this->Get('temp_id'),
'item_class' => $this->Get('item_class'),
'item_id' => $this->Get('item_id'),
'item_org_id' => $this->Get('item_org_id'),
'secret' => $this->Get('secret'),
'user' => $sUser = UserRights::GetUser(),
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
));
parent::AfterDelete();

View File

@@ -31,29 +31,38 @@ class ExecutionKPI
static protected $m_bBlameCaller = false;
static protected $m_sAllowedUser = '*';
static protected $m_aStats = array(); // Recurrent operations
static protected $m_aExecData = array(); // One shot operations
static protected $m_aStats = []; // Recurrent operations
static protected $m_aExecData = []; // One shot operations
/**
* @var array[ExecutionKPI]
*/
static protected $m_aExecutionStack = []; // embedded execution stats
protected $m_fStarted = null;
protected $m_fChildrenDuration = 0; // Count embedded
protected $m_iInitialMemory = null;
static public function EnableDuration($iLevel)
{
if ($iLevel > 0)
{
if ($iLevel > 0) {
self::$m_bEnabled_Duration = true;
if ($iLevel > 1)
{
if ($iLevel > 1) {
self::$m_bBlameCaller = true;
} else {
self::$m_bBlameCaller = false;
}
} else {
self::$m_bEnabled_Duration = false;
self::$m_bBlameCaller = false;
}
}
static public function EnableMemory($iLevel)
{
if ($iLevel > 0)
{
if ($iLevel > 0) {
self::$m_bEnabled_Memory = true;
} else {
self::$m_bEnabled_Memory = false;
}
}
@@ -103,16 +112,17 @@ class ExecutionKPI
$sTableStyle = 'background-color: #ccc; margin: 10px;';
self::Report("<hr/>");
self::Report("<div style=\"background-color: grey; padding: 10px;\">");
self::Report("<h3><a name=\"".md5($sExecId)."\">KPIs</a> - ".$_SERVER['REQUEST_URI']." (".$_SERVER['REQUEST_METHOD'].")</h3>");
self::Report("<p>".date('Y-m-d H:i:s', $fItopStarted)."</p>");
self::Report("<p>log_kpi_user_id: ".UserRights::GetUserId()."</p>");
self::Report("<div>");
self::Report("<table border=\"1\" style=\"$sTableStyle\">");
self::Report("<thead>");
self::Report(" <th>Operation</th><th>Begin</th><th>End</th><th>Duration</th><th>Memory start</th><th>Memory end</th><th>Memory peak</th>");
self::Report("</thead>");
$sHtml = "<hr/>";
$sHtml .= "<div style=\"background-color: grey; padding: 10px;\">";
$sHtml .= "<h3><a name=\"".md5($sExecId)."\">KPIs</a> - ".$_SERVER['REQUEST_URI']." (".$_SERVER['REQUEST_METHOD'].")</h3>";
$oStarted = DateTime::createFromFormat('U.u', $fItopStarted);
$sHtml .= "<p>".$oStarted->format('Y-m-d H:i:s.u')."</p>";
$sHtml .= "<p>log_kpi_user_id: ".UserRights::GetUserId()."</p>";
$sHtml .= "<div>";
$sHtml .= "<table border=\"1\" style=\"$sTableStyle\">";
$sHtml .= "<thead>";
$sHtml .= " <th>Operation</th><th>Begin</th><th>End</th><th>Duration</th><th>Memory start</th><th>Memory end</th><th>Memory peak</th>";
$sHtml .= "</thead>";
foreach (self::$m_aExecData as $aOpStats)
{
$sOperation = $aOpStats['op'];
@@ -134,12 +144,12 @@ class ExecutionKPI
}
}
self::Report("<tr>");
self::Report(" <td>$sOperation</td><td>$sBegin</td><td>$sEnd</td><td>$sDuration</td><td>$sMemBegin</td><td>$sMemEnd</td><td>$sMemPeak</td>");
self::Report("</tr>");
$sHtml .= "<tr>";
$sHtml .= " <td>$sOperation</td><td>$sBegin</td><td>$sEnd</td><td>$sDuration</td><td>$sMemBegin</td><td>$sMemEnd</td><td>$sMemPeak</td>";
$sHtml .= "</tr>";
}
self::Report("</table>");
self::Report("</div>");
$sHtml .= "</table>";
$sHtml .= "</div>";
$aConsolidatedStats = array();
foreach (self::$m_aStats as $sOperation => $aOpStats)
@@ -175,11 +185,11 @@ class ExecutionKPI
);
}
self::Report("<div>");
self::Report("<table border=\"1\" style=\"$sTableStyle\">");
self::Report("<thead>");
self::Report(" <th>Operation</th><th>Count</th><th>Duration</th><th>Min</th><th>Max</th><th>Avg</th>");
self::Report("</thead>");
$sHtml .= "<div>";
$sHtml .= "<table border=\"1\" style=\"$sTableStyle\">";
$sHtml .= "<thead>";
$sHtml .= " <th>Operation</th><th>Count</th><th>Duration</th><th>Min</th><th>Max</th><th>Avg</th>";
$sHtml .= "</thead>";
foreach ($aConsolidatedStats as $sOperation => $aOpStats)
{
$sOperation = '<a href="#'.md5($sExecId.$sOperation).'">'.$sOperation.'</a>';
@@ -189,22 +199,24 @@ class ExecutionKPI
$sMax = '<a href="#'.md5($sExecId.$aOpStats['max_args']).'">'.round($aOpStats['max'], 3).'</a>';
$sAvg = round($aOpStats['avg'], 3);
self::Report("<tr>");
self::Report(" <td>$sOperation</td><td>$sCount</td><td>$sDuration</td><td>$sMin</td><td>$sMax</td><td>$sAvg</td>");
self::Report("</tr>");
$sHtml .= "<tr>";
$sHtml .= " <td>$sOperation</td><td>$sCount</td><td>$sDuration</td><td>$sMin</td><td>$sMax</td><td>$sAvg</td>";
$sHtml .= "</tr>";
}
self::Report("</table>");
self::Report("</div>");
$sHtml .= "</table>";
$sHtml .= "</div>";
self::Report("</div>");
$sHtml .= "</div>";
self::Report("<p><a href=\"#end-".md5($sExecId)."\">Next page stats</a></p>");
$sHtml .= "<p><a href=\"#end-".md5($sExecId)."\">Next page stats</a></p>";
$fSlowQueries = MetaModel::GetConfig()->Get('log_kpi_slow_queries');
self::Report($sHtml);
// Report operation details
foreach (self::$m_aStats as $sOperation => $aOpStats)
{
$sHtml = '';
$bDisplayHeader = true;
foreach ($aOpStats as $sArguments => $aEvents)
{
@@ -250,31 +262,59 @@ class ExecutionKPI
if ($bDisplayHeader)
{
$sOperationHtml = '<a name="'.md5($sExecId.$sOperation).'">'.$sOperation.'</a>';
self::Report("<h4>$sOperationHtml</h4>");
self::Report("<table border=\"1\" style=\"$sTableStyle\">");
self::Report("<thead>");
self::Report(" <th>Operation details (+ blame caller if log_kpi_duration = 2)</th><th>Count</th><th>Duration</th><th>Min</th><th>Max</th>");
self::Report("</thead>");
$sHtml .= "<h4>$sOperationHtml</h4>";
$sHtml .= "<table border=\"1\" style=\"$sTableStyle\">";
$sHtml .= "<thead>";
$sHtml .= " <th>Operation details (+ blame caller if log_kpi_duration = 2)</th><th>Count</th><th>Duration</th><th>Min</th><th>Max</th>";
$sHtml .= "</thead>";
$bDisplayHeader = false;
}
self::Report("<tr>");
self::Report(" <td>$sHtmlArguments</td><td>$iCountInter</td><td>$sTotalInter</td><td>$sMinInter</td><td>$sMaxInter</td>");
self::Report("</tr>");
$sHtml .= "<tr>";
$sHtml .= " <td>$sHtmlArguments</td><td>$iCountInter</td><td>$sTotalInter</td><td>$sMinInter</td><td>$sMaxInter</td>";
$sHtml .= "</tr>";
}
}
if (!$bDisplayHeader)
{
self::Report("</table>");
self::Report("<p><a href=\"#".md5($sExecId)."\">Back to page stats</a></p>");
$sHtml .= "</table>";
$sHtml .= "<p><a href=\"#".md5($sExecId)."\">Back to page stats</a></p>";
}
self::Report($sHtml);
}
self::Report('<a name="end-'.md5($sExecId).'">&nbsp;</a>');
$sHtml = '<a name="end-'.md5($sExecId).'">&nbsp;</a>';
self::Report($sHtml);
}
public function __construct()
{
$this->ResetCounters();
self::Push($this);
}
/**
* Stack executions to remove children duration from stats
*
* @param \ExecutionKPI $oExecutionKPI
*/
private static function Push(ExecutionKPI $oExecutionKPI)
{
array_push(self::$m_aExecutionStack, $oExecutionKPI);
}
/**
* Pop current child and count its duration in its parent
*
* @param float|int $fChildDuration
*/
private static function Pop(float $fChildDuration = 0)
{
array_pop(self::$m_aExecutionStack);
// Update the parent's children duration
$oPrevExecutionKPI = end(self::$m_aExecutionStack);
if ($oPrevExecutionKPI) {
$oPrevExecutionKPI->m_fChildrenDuration += $fChildDuration;
}
}
// Get the duration since startup, and reset the counter for the next measure
@@ -285,13 +325,12 @@ class ExecutionKPI
$aNewEntry = null;
if (self::$m_bEnabled_Duration)
{
if (self::$m_bEnabled_Duration) {
$fStopped = MyHelpers::getmicrotime();
$aNewEntry = array(
'op' => $sOperationDesc,
'op' => $sOperationDesc,
'time_begin' => $this->m_fStarted - $fItopStarted,
'time_end' => $fStopped - $fItopStarted,
'time_end' => $fStopped - $fItopStarted,
);
// Reset for the next operation (if the object is recycled)
$this->m_fStarted = $fStopped;
@@ -323,31 +362,30 @@ class ExecutionKPI
public function ComputeStats($sOperation, $sArguments)
{
if (self::$m_bEnabled_Duration)
{
$fDuration = 0;
if (self::$m_bEnabled_Duration) {
$fStopped = MyHelpers::getmicrotime();
$fDuration = $fStopped - $this->m_fStarted;
if (self::$m_bBlameCaller)
{
$fSelfDuration = $fDuration - $this->m_fChildrenDuration;
if (self::$m_bBlameCaller) {
self::$m_aStats[$sOperation][$sArguments][] = array(
'time' => $fDuration,
'time' => $fSelfDuration,
'callers' => MyHelpers::get_callstack(1),
);
}
else
{
} else {
self::$m_aStats[$sOperation][$sArguments][] = array(
'time' => $fDuration
'time' => $fSelfDuration,
);
}
}
self::Pop($fDuration);
}
protected function ResetCounters()
{
if (self::$m_bEnabled_Duration)
{
$this->m_fStarted = MyHelpers::getmicrotime();
$this->m_fStarted = microtime(true);
}
if (self::$m_bEnabled_Memory)

View File

@@ -399,10 +399,10 @@ class MonthlyRotatingLogFileNameBuilder extends RotatingLogFileNameBuilder
*/
protected function GetFileSuffix($oDate)
{
$sWeekYear = $oDate->format('o');
$sWeekNumber = $oDate->format('m');
$sMonthYear = $oDate->format('o');
$sMonthNumber = $oDate->format('m');
return $sWeekYear.'-month'.$sWeekNumber;
return $sMonthYear.'-month'.$sMonthNumber;
}
/**
@@ -502,27 +502,27 @@ class FileLog
protected function Write($sText, $sLevel = '', $sChannel = '', $aContext = array())
{
$sTextPrefix = empty($sLevel) ? '' : (str_pad($sLevel, 7).' | ');
$sTextSuffix = empty($sChannel) ? '' : " | $sChannel";
$sText = "{$sTextPrefix}{$sText}{$sTextSuffix}";
$sLogFilePath = $this->oFileNameBuilder->GetLogFilePath();
$sTextPrefix = empty($sLevel) ? '' : (str_pad($sLevel, 7));
$sTextPrefix .= ' | ';
$sTextPrefix .= str_pad(LogAPI::GetUserInfo(), 5)." | ";
if (empty($sLogFilePath))
{
$sTextSuffix = ' | '.(empty($sChannel) ? '' : $sChannel);
$sTextSuffix .= ' |||';
$sText = "{$sTextPrefix}{$sText}{$sTextSuffix}";
$sLogFilePath = $this->oFileNameBuilder->GetLogFilePath();
if (empty($sLogFilePath)) {
return;
}
$hLogFile = @fopen($sLogFilePath, 'a');
if ($hLogFile !== false)
{
if ($hLogFile !== false) {
flock($hLogFile, LOCK_EX);
$sDate = date('Y-m-d H:i:s');
if (empty($aContext))
{
if (empty($aContext)) {
fwrite($hLogFile, "$sDate | $sText\n");
}
else
{
} else {
$sContext = var_export($aContext, true);
fwrite($hLogFile, "$sDate | $sText\n$sContext\n");
}
@@ -533,22 +533,51 @@ class FileLog
}
}
/**
* Simple enum like class to factorize channels values as constants
* Channels are used especially as parameters in {@see \LogAPI} methods
*
* @since 2.7.5 3.0.0 N°4012
*/
class LogChannels
{
public const CLI = 'CLI';
public const CONSOLE = 'console';
public const DEADLOCK = 'DeadLock';
public const INLINE_IMAGE = 'InlineImage';
public const PORTAL = 'portal';
public const CMDB_SOURCE = 'cmdbsource';
public const CORE = 'core';
}
abstract class LogAPI
{
const CHANNEL_DEFAULT = '';
public const CHANNEL_DEFAULT = '';
public const LEVEL_ERROR = 'Error';
public const LEVEL_WARNING = 'Warning';
public const LEVEL_INFO = 'Info';
public const LEVEL_OK = 'Ok';
public const LEVEL_DEBUG = 'Debug';
public const LEVEL_TRACE = 'Trace';
const LEVEL_ERROR = 'Error';
const LEVEL_WARNING = 'Warning';
const LEVEL_INFO = 'Info';
const LEVEL_OK = 'Ok';
const LEVEL_DEBUG = 'Debug';
const LEVEL_TRACE = 'Trace';
/**
* @var string default log level, can be overrided
* @see GetMinLogLevel
* @see GetMinLogLevel
* @used-by GetLevelDefault
* @var string default log level.
* @since 2.7.1 N°2977
*/
const LEVEL_DEFAULT = self::LEVEL_OK;
public const LEVEL_DEFAULT = self::LEVEL_OK;
/**
* @see GetMinLogLevel
* @used-by GetLevelDefault
* @var string|bool default log level when writing to DB: false by default in order to disable EventIssue creation, and so on, do not change the behavior.
* @since 3.0.0 N°4261
*/
public const LEVEL_DEFAULT_DB = false;
protected static $aLevelsPriority = array(
self::LEVEL_ERROR => 400,
@@ -556,18 +585,29 @@ abstract class LogAPI
self::LEVEL_INFO => 200,
self::LEVEL_OK => 200,
self::LEVEL_DEBUG => 100,
self::LEVEL_TRACE => 50,
self::LEVEL_TRACE => 50,
);
public const ENUM_CONFIG_PARAM_FILE = 'log_level_min';
public const ENUM_CONFIG_PARAM_DB = 'log_level_min.write_in_db';
/**
* @var \Config attribute allowing to mock config in the tests
*/
protected static $m_oMockMetaModelConfig = null;
protected static $oLastEventIssue = null;
public static function Enable($sTargetFile)
{
// m_oFileLog is not defined as a class attribute so that each impl will have its own
static::$m_oFileLog = new FileLog($sTargetFile);
}
public static function MockStaticObjects($oFileLog, $oMetaModelConfig=null)
/**
* @internal uses only for testing purpose.
*/
public static function MockStaticObjects($oFileLog, $oMetaModelConfig = null)
{
static::$m_oFileLog = $oFileLog;
static::$m_oMockMetaModelConfig = $oMetaModelConfig;
@@ -603,85 +643,250 @@ abstract class LogAPI
static::Log(self::LEVEL_TRACE, $sMessage, $sChannel, $aContext);
}
/**
* @throws \ConfigException if log wrongly configured
*/
public static function Log($sLevel, $sMessage, $sChannel = null, $aContext = array())
{
if (! static::$m_oFileLog)
{
return;
}
if (! isset(self::$aLevelsPriority[$sLevel]))
{
if (!isset(self::$aLevelsPriority[$sLevel])) {
IssueLog::Error("invalid log level '{$sLevel}'");
return;
}
if (is_null($sChannel))
{
if (is_null($sChannel)) {
$sChannel = static::CHANNEL_DEFAULT;
}
$sMinLogLevel = self::GetMinLogLevel($sChannel);
if ($sMinLogLevel === false || $sMinLogLevel === 'false')
{
return;
}
if (is_string($sMinLogLevel))
{
if (! isset(self::$aLevelsPriority[$sMinLogLevel]))
{
throw new Exception("invalid configuration for log_level '{$sMinLogLevel}' is not within the list: ".implode(',', array_keys(self::$aLevelsPriority)));
}
elseif (self::$aLevelsPriority[$sLevel] < self::$aLevelsPriority[$sMinLogLevel])
{
//priority too low regarding the conf, do not log this
return;
}
}
static::$m_oFileLog->$sLevel($sMessage, $sChannel, $aContext);
static::WriteLog($sLevel, $sMessage, $sChannel, $aContext);
}
/**
* @param $sChannel
*
* @return string one of the LEVEL_* const value
* @uses \LogAPI::LEVEL_DEFAULT
* @throws \ConfigException
*/
private static function GetMinLogLevel($sChannel)
protected static function WriteLog(string $sLevel, string $sMessage, ?string $sChannel = null, ?array $aContext = array()): void
{
$oConfig = (static::$m_oMockMetaModelConfig !== null) ? static::$m_oMockMetaModelConfig : \MetaModel::GetConfig();
if (!$oConfig instanceof Config)
{
return static::LEVEL_DEFAULT;
if (
(null !== static::$m_oFileLog)
&& static::IsLogLevelEnabled($sLevel, $sChannel, static::ENUM_CONFIG_PARAM_FILE)
) {
static::$m_oFileLog->$sLevel($sMessage, $sChannel, $aContext);
}
$sLogLevelMin = $oConfig->Get('log_level_min');
if (static::IsLogLevelEnabled($sLevel, $sChannel, static::ENUM_CONFIG_PARAM_DB)) {
self::WriteToDb($sMessage, $sChannel, $aContext);
}
}
if (empty($sLogLevelMin))
{
return static::LEVEL_DEFAULT;
public static function GetUserInfo(): ?string
{
$oConnectedUser = UserRights::GetUserObject();
if (is_null($oConnectedUser)) {
return '';
}
if (!is_array($sLogLevelMin))
{
return $oConnectedUser->GetKey();
}
/**
* @throws \ConfigException if log wrongly configured
* @uses GetMinLogLevel
*/
final public static function IsLogLevelEnabled(string $sLevel, string $sChannel, string $sConfigKey = self::ENUM_CONFIG_PARAM_FILE): bool
{
$sMinLogLevel = self::GetMinLogLevel($sChannel, $sConfigKey);
// the is_bool call is to remove a IDE O:) warning as $sMinLogLevel is typed as string
if ((is_bool($sMinLogLevel) && ($sMinLogLevel === false)) || $sMinLogLevel === 'false') {
return false;
}
if (!is_string($sMinLogLevel)) {
return false;
}
if (!isset(self::$aLevelsPriority[$sMinLogLevel])) {
throw new ConfigException("invalid configuration for log_level '{$sMinLogLevel}' is not within the list: ".implode(',', array_keys(self::$aLevelsPriority)));
} elseif (self::$aLevelsPriority[$sLevel] < self::$aLevelsPriority[$sMinLogLevel]) {
return false;
}
return true;
}
/**
* @param string $sChannel
* @param string $sConfigKey
*
* @return string one of the LEVEL_* const value : the one configured it if exists, otherwise default log level for this channel
* Config can be set :
* * globally : `'log_level_min' => LogAPI::LEVEL_TRACE,`
* * per channel :
* ```
* 'log_level_min' => [
* '' => LogAPI::LEVEL_ERROR, // default log level for channels not listed below
* 'InlineImage' => LogAPI::LEVEL_TRACE,
* 'UserRequest' => LogAPI::LEVEL_TRACE
* ],
* ```
*
* @uses \LogAPI::GetConfig()
* @uses `log_level_min` config parameter
* @uses `log_level_min.write_to_db` config parameter
* @uses \LogAPI::GetLevelDefault
*
* @link https://www.itophub.io/wiki/page?id=3_0_0%3Aadmin%3Alog iTop log reference
*/
protected static function GetMinLogLevel($sChannel, $sConfigKey = self::ENUM_CONFIG_PARAM_FILE)
{
$sLogLevelMin = static::GetLogConfig($sConfigKey);
$sConfiguredLevelForChannel = static::GetMinLogLevelFromChannel($sLogLevelMin, $sChannel, $sConfigKey);
if (!is_null($sConfiguredLevelForChannel)) {
return $sConfiguredLevelForChannel;
}
return static::GetMinLogLevelFromDefault($sLogLevelMin, $sChannel, $sConfigKey);
}
final protected static function GetLogConfig($sConfigKey)
{
$oConfig = static::GetConfig();
if (!$oConfig instanceof Config) {
return static::GetLevelDefault($sConfigKey);
}
return $oConfig->Get($sConfigKey);
}
/**
* @param string|array $sLogLevelMin log config parameter value
* @param string $sChannel
* @param string $sConfigKey config option key
*
* @return string|null null if not defined
*/
protected static function GetMinLogLevelFromChannel($sLogLevelMin, $sChannel, $sConfigKey)
{
if (empty($sLogLevelMin)) {
return static::GetLevelDefault($sConfigKey);
}
if (!is_array($sLogLevelMin)) {
return $sLogLevelMin;
}
if (isset($sLogLevelMin[$sChannel]))
{
if (isset($sLogLevelMin[$sChannel])) {
return $sLogLevelMin[$sChannel];
}
if (isset($sLogLevelMin[static::CHANNEL_DEFAULT]))
{
return $sLogLevelMin[$sChannel];
}
return static::LEVEL_DEFAULT;
return null;
}
protected static function GetMinLogLevelFromDefault($sLogLevelMin, $sChannel, $sConfigKey)
{
if (isset($sLogLevelMin[static::CHANNEL_DEFAULT])) {
return $sLogLevelMin[static::CHANNEL_DEFAULT];
}
// Even though the *self*::CHANNEL_DEFAULT is set to '' in the current class (LogAPI), the test below is necessary as the CHANNEL_DEFAULT constant can be (and is!) overloaded in children classes, don't remove this test to factorize it with the previous one.
if (isset($sLogLevelMin[''])) {
return $sLogLevelMin[''];
}
return static::GetLevelDefault($sConfigKey);
}
protected static function WriteToDb(string $sMessage, string $sChannel, array $aContext): void
{
if (false === MetaModel::IsLogEnabledIssue()) {
return;
}
if (false === MetaModel::IsValidClass('EventIssue')) {
return;
}
// Protect against reentrance
static $bWriteToDbReentrance;
if ($bWriteToDbReentrance === true) {
return;
}
$bWriteToDbReentrance = true;
try {
self::$oLastEventIssue = static::GetEventIssue($sMessage, $sChannel, $aContext);
self::$oLastEventIssue->DBInsertNoReload();
}
catch (Exception $e) {
// calling low level methods : if we would call Error() for example we would try to write to DB again...
static::$m_oFileLog->Error('Failed to log issue into the DB', LogChannels::CORE, [
'exception message' => $e->getMessage(),
'exception stack' => $e->getTraceAsString(),
]);
}
finally {
$bWriteToDbReentrance = false;
}
}
/**
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \OQLException
*/
protected static function GetEventIssue(string $sMessage, string $sChannel, array $aContext): EventIssue
{
$sDate = date('Y-m-d H:i:s');
$aStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
$sCurrentCallStack = var_export($aStack, true);
$oEventIssue = new EventIssue();
$oEventIssue->Set('issue', $sMessage);
$oEventIssue->Set('message', $sMessage);
$oEventIssue->Set('date', $sDate);
$oEventIssue->Set('userinfo', static::GetUserInfo());
$oEventIssue->Set('callstack', $sCurrentCallStack);
$oEventIssue->Set('data', $aContext);
return $oEventIssue;
}
/**
* **Warning** : during \MFCompiler::Compile the config will be partial, so when logging in this method you won't get the proper log config !
* See N°4345
*
* @uses m_oMockMetaModelConfig if defined
* @uses \MetaModel::GetConfig()
*/
protected static function GetConfig(): ?Config
{
return static::$m_oMockMetaModelConfig ?? \utils::GetConfig();
}
/**
* A method to override if default log level needs to be computed. Otherwise, simply override the corresponding constants
*
* @used-by GetMinLogLevel
*
* @param string $sConfigKey config key used for log
*
* @return string|bool if false, then disable log for any level
*
* @uses \LogAPI::LEVEL_DEFAULT
* @uses \LogAPI::LEVEL_DEFAULT_DB
*
* @since 3.0.0 N°3731 Method creation
* @since 3.0.0 N°4261 add specific default level for DB write
*/
protected static function GetLevelDefault(string $sConfigKey)
{
switch ($sConfigKey) {
case static::ENUM_CONFIG_PARAM_DB:
return static::LEVEL_DEFAULT_DB;
case static::ENUM_CONFIG_PARAM_FILE:
default:
return static::LEVEL_DEFAULT;
}
}
}
class SetupLog extends LogAPI
@@ -695,6 +900,16 @@ class SetupLog extends LogAPI
const LEVEL_DEFAULT = self::LEVEL_INFO;
protected static $m_oFileLog = null;
/**
* In the setup there is no user logged...
*
* @return string|null
*/
public static function GetUserInfo(): ?string
{
return 'SETUP';
}
}
class IssueLog extends LogAPI
@@ -733,6 +948,7 @@ class DeadLockLog extends LogAPI
parent::Enable($sTargetFile);
}
/** @noinspection PhpUnreachableStatementInspection we want to keep the break statements to keep clarity and avoid errors */
private static function GetChannelFromMysqlErrorNo($iMysqlErrorNo)
{
switch ($iMysqlErrorNo)
@@ -741,7 +957,7 @@ class DeadLockLog extends LogAPI
return self::CHANNEL_WAIT_TIMEOUT;
break;
case 1213:
return self::CHANNEL_DEADLOCK_FOUND;
return self::CHANNEL_DEADLOCK_FOUND;
break;
default:
return self::CHANNEL_DEFAULT;
@@ -750,17 +966,250 @@ class DeadLockLog extends LogAPI
}
/**
* @param int $iMySQLErrNo will be converted to channel using {@link GetChannelFromMysqlErrorNo}
* @param string $sLevel
* @param string $sMessage
* @param null $iMysqlErroNo
* @param int $iMysqlErrorNumber will be converted to channel using {@link GetChannelFromMysqlErrorNo}
* @param array $aContext
*
* @throws \Exception
* @noinspection PhpParameterNameChangedDuringInheritanceInspection
*
* @since 2.7.1 method creation
* @since 2.7.5 3.0.0 rename param names and fix phpdoc (thanks Hipska !)
*/
public static function Log($iMySQLErrNo, $sMessage, $iMysqlErroNo = null, $aContext = array())
public static function Log($sLevel, $sMessage, $iMysqlErrorNumber = null, $aContext = array())
{
$sChannel = self::GetChannelFromMysqlErrorNo($iMysqlErroNo);
parent::Log($iMySQLErrNo, $sMessage, $sChannel, $aContext);
$sChannel = self::GetChannelFromMysqlErrorNo($iMysqlErrorNumber);
parent::Log($sLevel, $sMessage, $sChannel, $aContext);
}
}
/**
* @since 3.0.0 N°3731
*/
class DeprecatedCallsLog extends LogAPI
{
public const ENUM_CHANNEL_PHP_METHOD = 'deprecated-php-method';
public const ENUM_CHANNEL_PHP_LIBMETHOD = 'deprecated-php-libmethod';
public const ENUM_CHANNEL_FILE = 'deprecated-file';
public const CHANNEL_DEFAULT = self::ENUM_CHANNEL_PHP_METHOD;
public const LEVEL_DEFAULT = self::LEVEL_ERROR;
/** @var \FileLog we want our own instance ! */
protected static $m_oFileLog = null;
/**
* Indirection to {@see \LogAPI::IsLogLevelEnabled()} that is handling possible {@see ConfigException}
*
* @param string $sLevel
* @param string $sChannel
*
* @return bool if exception occurs, then returns false
*
* @uses \LogAPI::IsLogLevelEnabled()
*/
protected static function IsLogLevelEnabledSafe($sLevel, $sChannel): bool
{
try {
$bIsLogLevelEnabled = static::IsLogLevelEnabled(self::LEVEL_WARNING, self::ENUM_CHANNEL_PHP_LIBMETHOD);
}
catch (ConfigException $e) {
$bIsLogLevelEnabled = false;
}
return $bIsLogLevelEnabled;
}
/**
* @param string|null $sTargetFile
*
* @uses \set_error_handler() to catch deprecated notices
*
* @since 3.0.0 N°3002 logs deprecated notices in called code
*/
public static function Enable($sTargetFile = null): void
{
if (empty($sTargetFile)) {
$sTargetFile = APPROOT.'log/deprecated-calls.log';
}
parent::Enable($sTargetFile);
if (static::IsLogLevelEnabledSafe(self::LEVEL_WARNING, self::ENUM_CHANNEL_PHP_LIBMETHOD)) {
set_error_handler([static::class, 'DeprecatedNoticesErrorHandler']);
}
}
/**
* This will catch a message for all E_DEPRECATED and E_USER_DEPRECATED errors.
* This handler is set in DeprecatedCallsLog::Enable
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
*
* @return bool
* @since 3.0.0 N°3002
* @noinspection SpellCheckingInspection
*/
public static function DeprecatedNoticesErrorHandler(int $errno, string $errstr, string $errfile, int $errline): bool
{
if (
(\E_USER_DEPRECATED !== $errno)
&& (\E_DEPRECATED !== $errno)
) {
return false;
}
if (false === static::IsLogLevelEnabledSafe(self::LEVEL_WARNING, self::ENUM_CHANNEL_PHP_LIBMETHOD)) {
// returns true so that nothing is throwned !
return true;
}
$aStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
$iStackDeprecatedMethodLevel = 2; // level 0 = current method, level 1 = @trigger_error, level 2 = method containing the `trigger_error` call
$sDeprecatedObject = $aStack[$iStackDeprecatedMethodLevel]['class'];
$sDeprecatedMethod = $aStack[$iStackDeprecatedMethodLevel]['function'];
if (($sDeprecatedObject === __CLASS__) && ($sDeprecatedMethod === 'Log')) {
// We are generating a trigger_error ourselves, we don't want to trace them !
return false;
}
$sCallerFile = $aStack[$iStackDeprecatedMethodLevel]['file'];
$sCallerLine = $aStack[$iStackDeprecatedMethodLevel]['line'];
$sMessage = "Call to {$sDeprecatedObject}::{$sDeprecatedMethod} in {$sCallerFile}#L{$sCallerLine}";
$iStackCallerMethodLevel = $iStackDeprecatedMethodLevel + 1; // level 3 = caller of the deprecated method
if (array_key_exists($iStackCallerMethodLevel, $aStack)) {
$sCallerObject = $aStack[$iStackCallerMethodLevel]['class'] ?? null;
$sCallerMethod = $aStack[$iStackCallerMethodLevel]['function'] ?? null;
$sMessage .= ' (';
if (!is_null($sCallerObject)) {
$sMessage .= "{$sCallerObject}::{$sCallerMethod}";
} else {
$sCallerMethodFile = $aStack[$iStackCallerMethodLevel]['file'];
$sCallerMethodLine = $aStack[$iStackCallerMethodLevel]['line'];
if (!is_null($sCallerMethod)) {
$sMessage .= "call to {$sCallerMethod}() in {$sCallerMethodFile}#L{$sCallerMethodLine}";
} else {
$sMessage .= "{$sCallerMethodFile}#L{$sCallerMethodLine}";
}
}
$sMessage .= ')';
}
if (!empty($errstr)) {
$sMessage .= ' : '.$errstr;
}
static::Warning($sMessage, self::ENUM_CHANNEL_PHP_LIBMETHOD);
return true;
}
/**
* Override so that :
* - if we are in dev mode ({@see \utils::IsDevelopmentEnvironment()}), the level for file will be DEBUG
* - else call parent method
*
* In other words, when in dev mode all deprecated calls will be logged to file
*
*/
protected static function GetLevelDefault(string $sConfigKey)
{
if ($sConfigKey === self::ENUM_CONFIG_PARAM_DB) {
return parent::GetLevelDefault($sConfigKey);
}
if (utils::IsDevelopmentEnvironment()) {
return static::LEVEL_DEBUG;
}
return parent::GetLevelDefault($sConfigKey);
}
/**
* @throws \ConfigException
* @link https://www.php.net/debug_backtrace
* @uses \debug_backtrace()
*/
public static function NotifyDeprecatedFile(?string $sAdditionalMessage = null): void
{
if (!static::IsLogLevelEnabled(self::LEVEL_WARNING, self::ENUM_CHANNEL_FILE)) {
return;
}
$aStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$sDeprecatedFile = $aStack[0]['file'];
if (array_key_exists(1, $aStack)) {
$sCallerFile = $aStack[1]['file'];
$sCallerLine = $aStack[1]['line'];
} else {
$sCallerFile = 'N/A';
$sCallerLine = 'N/A';
}
$sMessage = "{$sCallerFile} L{$sCallerLine} including/requiring {$sDeprecatedFile}";
if (!is_null($sAdditionalMessage)) {
$sMessage .= ' : '.$sAdditionalMessage;
}
static::Warning($sMessage, static::ENUM_CHANNEL_FILE);
}
/**
* @param string|null $sAdditionalMessage
*
* @link https://www.php.net/debug_backtrace
* @uses \debug_backtrace()
*/
public static function NotifyDeprecatedPhpMethod(?string $sAdditionalMessage = null): void
{
try {
if (!static::IsLogLevelEnabled(self::LEVEL_WARNING, self::ENUM_CHANNEL_PHP_METHOD)) {
return;
}
}
catch (ConfigException $e) {
return;
}
$aStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
$iStackDeprecatedMethodLevel = 1; // level 0 = current method, level 1 = method containing the `NotifyDeprecatedPhpMethod` call
$sDeprecatedObject = $aStack[$iStackDeprecatedMethodLevel]['class'];
$sDeprecatedMethod = $aStack[$iStackDeprecatedMethodLevel]['function'];
$sCallerFile = $aStack[$iStackDeprecatedMethodLevel]['file'];
$sCallerLine = $aStack[$iStackDeprecatedMethodLevel]['line'];
$sMessage = "Call to {$sDeprecatedObject}::{$sDeprecatedMethod} in {$sCallerFile}#L{$sCallerLine}";
$iStackCallerMethodLevel = $iStackDeprecatedMethodLevel + 1; // level 2 = caller of the deprecated method
if (array_key_exists($iStackCallerMethodLevel, $aStack)) {
$sCallerObject = $aStack[$iStackCallerMethodLevel]['class'];
$sCallerMethod = $aStack[$iStackCallerMethodLevel]['function'];
$sMessage .= " ({$sCallerObject}::{$sCallerMethod})";
}
if (!is_null($sAdditionalMessage)) {
$sMessage .= ' : '.$sAdditionalMessage;
}
static::Warning($sMessage, self::ENUM_CHANNEL_PHP_METHOD);
}
public static function Log($sLevel, $sMessage, $sChannel = null, $aContext = array()): void
{
if (true === utils::IsDevelopmentEnvironment()) {
trigger_error($sMessage, E_USER_DEPRECATED);
}
try {
parent::Log($sLevel, $sMessage, $sChannel, $aContext);
}
catch (ConfigException $e) {
// nothing much we can do... and we don't want to crash the caller !
}
}
}
@@ -769,6 +1218,7 @@ class LogFileRotationProcess implements iScheduledProcess
{
/**
* Cannot get this list from anywhere as log file name is provided by the caller using LogAPI::Enable
*
* @var string[]
*/
const LOGFILES_TO_ROTATE = array(
@@ -832,3 +1282,178 @@ class LogFileRotationProcess implements iScheduledProcess
throw new ProcessException(self::class.' : The configured filename builder is invalid (log_filename_builder_impl="'.$sLogFileNameBuilder.'")');
}
}
/**
* Log exceptions using dedicated API and logic.
*
* Please use {@see ExceptionLog::LogException()} to log exceptions
*
* @since 3.0.0 N°4261 class creation to ease logging when an exception occurs
*/
class ExceptionLog extends LogAPI
{
public const CHANNEL_DEFAULT = 'Exception';
public const CONTEXT_EXCEPTION = '__exception';
protected static $m_oFileLog = null;
/**
* This method should be used to write logs.
*
* As it encapsulate the operations performed using the Exception, you should prefer it to the standard API inherited from LogApi `ExceptionLog::Error($oException->getMessage(), get_class($oException), ['__exception' => $oException]);`
* The parameter order is not standard, but in our use case, the resulting API is way more convenient this way !
*/
public static function LogException(Throwable $oException, $aContext = array(), $sLevel = self::LEVEL_ERROR): void
{
if (!isset(self::$aLevelsPriority[$sLevel])) {
IssueLog::Error("invalid log level '{$sLevel}'");
return;
}
$sExceptionClass = get_class($oException);
$aDefaultValues = [
self::CONTEXT_EXCEPTION => $oException,
'exception class' => $sExceptionClass,
'file' => $oException->getFile(),
'line' => $oException->getLine(),
];
$aContext = array_merge($aDefaultValues, $aContext);
parent::Log($sLevel, $oException->getMessage(), $sExceptionClass, $aContext);
}
/** @noinspection PhpUnhandledExceptionInspection */
public static function Log($sLevel, $sMessage, $sChannel = null, $aContext = array())
{
throw new ApplicationException('Do not call this directly, prefer using ExceptionLog::LogException() instead');
}
/** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
protected static function WriteLog(string $sLevel, string $sMessage, ?string $sExceptionClass = null, ?array $aContext = array()): void
{
if (
(null !== static::$m_oFileLog)
&& static::IsLogLevelEnabled($sLevel, $sExceptionClass, static::ENUM_CONFIG_PARAM_FILE)
) {
$sExceptionClassConfiguredForFile = static::ExceptionClassFromHierarchy($sExceptionClass, static::ENUM_CONFIG_PARAM_FILE);
if (null === $sExceptionClassConfiguredForFile) {
$sExceptionClassConfiguredForFile = $sExceptionClass;
}
// clearing the Exception object as it is too verbose to write to a file !
$aContextForFile = array_diff_key($aContext, [self::CONTEXT_EXCEPTION => null]);
static::$m_oFileLog->$sLevel($sMessage, $sExceptionClassConfiguredForFile, $aContextForFile);
}
if (static::IsLogLevelEnabled($sLevel, $sExceptionClass, static::ENUM_CONFIG_PARAM_DB)) {
$sExceptionClassConfiguredForDb = static::ExceptionClassFromHierarchy($sExceptionClass, static::ENUM_CONFIG_PARAM_DB);
if (null === $sExceptionClassConfiguredForDb) {
$sExceptionClassConfiguredForDb = $sExceptionClass;
}
self::WriteToDb($sMessage, $sExceptionClassConfiguredForDb, $aContext);
}
}
/**
* Will seek for the configuration based on the exception class, using {@see \ExceptionLog::ExceptionClassFromHierarchy()}
*
* @param string $sExceptionClass
* @param string $sConfigKey
*
* @return string
* @noinspection PhpParameterNameChangedDuringInheritanceInspection
*/
protected static function GetMinLogLevel($sExceptionClass, $sConfigKey = self::ENUM_CONFIG_PARAM_FILE)
{
$sLogLevelMin = static::GetLogConfig($sConfigKey);
$sExceptionClassInConfig = static::ExceptionClassFromHierarchy($sExceptionClass, $sConfigKey);
if (null !== $sExceptionClassInConfig) {
return $sConfigKey[$sExceptionClassInConfig];
}
return static::GetMinLogLevelFromDefault($sLogLevelMin, $sExceptionClass, $sConfigKey);
}
/**
* Searching config first for the current exception class
* If not found we are seeking for config for all the parent classes
*
* That means if we are logging a UnknownClassOqlException, we will seek log config all the way the class hierarchy :
* 1. UnknownClassOqlException
* 2. OqlNormalizeException
* 3. OQLException
* 4. CoreException
* 5. Exception
*
* @param string $sExceptionClass
* @param string $sConfigKey
*
* @return string|null the current or parent class name defined in the config, otherwise null if no class of the hierarchy found in the config
*/
protected static function ExceptionClassFromHierarchy($sExceptionClass, $sConfigKey = self::ENUM_CONFIG_PARAM_FILE)
{
$sLogLevelMin = static::GetLogConfig($sConfigKey);
if (false === is_array($sLogLevelMin)) {
return null;
}
$sExceptionClassInHierarchy = $sExceptionClass;
while ($sExceptionClassInHierarchy !== false) {
$sConfiguredLevelForExceptionClass = static::GetMinLogLevelFromChannel($sLogLevelMin, $sExceptionClassInHierarchy, $sConfigKey);
if (!is_null($sConfiguredLevelForExceptionClass)) {
break;
}
$sExceptionClassInHierarchy = get_parent_class($sExceptionClassInHierarchy);
}
if ($sExceptionClassInHierarchy === false) {
return null;
}
return $sExceptionClassInHierarchy;
}
protected static function GetEventIssue(string $sMessage, string $sChannel, array $aContext): EventIssue
{
$oEventIssue = parent::GetEventIssue($sMessage, $sChannel, $aContext);
$oContextException = $aContext[self::CONTEXT_EXCEPTION];
unset($aContext[self::CONTEXT_EXCEPTION]);
$sIssue = ($oContextException instanceof CoreException) ? $oContextException->GetIssue() : 'PHP Exception';
$sErrorStackTrace = ($oContextException instanceof CoreException) ? $oContextException->getFullStackTraceAsString() : $oContextException->getTraceAsString();
$aContextData = ($oContextException instanceof CoreException) ? $oContextException->getContextData() : [];
$oEventIssue->Set('issue', $sIssue);
$oEventIssue->Set('message', $oContextException->getMessage());
$oEventIssue->Set('callstack', $sErrorStackTrace);
$oEventIssue->Set('data', array_merge($aContextData, $aContext));
return $oEventIssue;
}
/**
* @inheritDoc
*/
public static function Enable($sTargetFile = null)
{
if (empty($sTargetFile)) {
$sTargetFile = APPROOT.'log/error.log';
}
parent::Enable($sTargetFile);
}
/**
* @internal Used by the tests
*/
private static function GetLastEventIssue()
{
return self::$oLastEventIssue;
}
}

View File

@@ -17,6 +17,8 @@
// along with iTop. If not, see <http://www.gnu.org/licenses/>
//
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
require_once APPROOT.'core/modulehandler.class.inc.php';
require_once APPROOT.'core/querymodifier.class.inc.php';
require_once APPROOT.'core/metamodelmodifier.inc.php';
@@ -443,10 +445,10 @@ abstract class MetaModel
/**
* @param string $sClass
* @param bool $bImgTag
* @param string $sMoreStyles
* @param bool $bImgTag Whether to surround the icon URL with an HTML IMG tag or not
* @param string $sMoreStyles Additional inline CSS style to add to the IMG tag. Only used if $bImgTag is set to true
*
* @return string
* @return string Absolute URL the class icon
* @throws \CoreException
*/
final public static function GetClassIcon($sClass, $bImgTag = true, $sMoreStyles = '')
@@ -457,7 +459,7 @@ abstract class MetaModel
if (array_key_exists('style', self::$m_aClassParams[$sClass])) {
/** @var ormStyle $oStyle */
$oStyle = self::$m_aClassParams[$sClass]['style'];
$sIcon = $oStyle->GetIcon();
$sIcon = $oStyle->GetIconAsAbsUrl();
}
if (strlen($sIcon) == 0) {
$sParentClass = self::GetParentPersistentClass($sClass);
@@ -492,7 +494,7 @@ abstract class MetaModel
$oStyle = new ormStyle("ibo-class-style--$sClass", "ibo-class-style-alt--$sClass");
}
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIcon()) > 0)) {
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIconAsRelPath()) > 0)) {
// all the parameters are set, no need to search in the parent classes
return $oStyle;
}
@@ -510,10 +512,10 @@ abstract class MetaModel
$oStyle->SetComplementaryColor($oParentStyle->GetComplementaryColor());
$oStyle->SetAltStyleClass($oParentStyle->GetAltStyleClass());
}
if (strlen($oStyle->GetIcon()) == 0) {
$oStyle->SetIcon($oParentStyle->GetIcon());
if (strlen($oStyle->GetIconAsRelPath()) == 0) {
$oStyle->SetIcon($oParentStyle->GetIconAsRelPath());
}
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIcon()) > 0)) {
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIconAsRelPath()) > 0)) {
// all the parameters are set, no need to search in the parent classes
return $oStyle;
}
@@ -521,7 +523,7 @@ abstract class MetaModel
$sParentClass = self::GetParentPersistentClass($sParentClass);
}
if ((strlen($oStyle->GetMainColor()) == 0) && (strlen($oStyle->GetComplementaryColor()) == 0) && (strlen($oStyle->GetIcon()) == 0)) {
if ((strlen($oStyle->GetMainColor()) == 0) && (strlen($oStyle->GetComplementaryColor()) == 0) && (strlen($oStyle->GetIconAsRelPath()) == 0)) {
return null;
}
@@ -752,17 +754,56 @@ abstract class MetaModel
/**
* @param string $sClass
* @param string $sType {@see \Combodo\iTop\Core\MetaModel\FriendlyNameType}
*
* @return array
* @throws \CoreException
* @throws \DictExceptionMissingString
*
* @since 3.0.0 N°580 New $sType parameter
*/
final public static function GetNameSpec($sClass)
final public static function GetNameSpec($sClass, $sType = FriendlyNameType::SHORT)
{
self::_check_subclass($sClass);
$nameRawSpec = self::$m_aClassParams[$sClass]["name_attcode"];
switch ($sType) {
case FriendlyNameType::COMPLEMENTARY:
if (!isset(self::$m_aClassParams[$sClass]["complementary_name_attcode"])) {
return [$sClass, []];
}
$nameRawSpec = self::$m_aClassParams[$sClass]["complementary_name_attcode"];
$sDictName = 'ComplementaryName';
break;
case FriendlyNameType::LONG:
$nameRawSpec = self::$m_aClassParams[$sClass]["name_attcode"];
if (!isset(self::$m_aClassParams[$sClass]["complementary_name_attcode"])) {
return self::GetNameSpec($sClass, FriendlyNameType::SHORT);
}
$complementaryNameRawSpec = self::$m_aClassParams[$sClass]["complementary_name_attcode"];
if (is_array($nameRawSpec)) {
if (is_array($complementaryNameRawSpec)) {
$nameRawSpec = merge($nameRawSpec, $complementaryNameRawSpec);
} elseif (!empty($nameRawSpec)) {
$nameRawSpec = merge($nameRawSpec, [$complementaryNameRawSpec]);
}
} elseif (empty($nameRawSpec)) {
$nameRawSpec = $complementaryNameRawSpec;
} else {
if (is_array($complementaryNameRawSpec)) {
$nameRawSpec = merge([$nameRawSpec], $complementaryNameRawSpec);
} elseif (!empty($nameRawSpec)) {
$nameRawSpec = [$nameRawSpec, $complementaryNameRawSpec];
}
}
$sDictName = 'LongName';
break;
default:
$nameRawSpec = self::$m_aClassParams[$sClass]["name_attcode"];
$sDictName = 'Name';
}
if (is_array($nameRawSpec)) {
$sFormat = Dict::S("Class:$sClass/Name", '');
$sFormat = Dict::S("Class:$sClass/$sDictName", '');
if (strlen($sFormat) == 0) {
// Default to "%1$s %2$s..."
for ($i = 1; $i <= count($nameRawSpec); $i++) {
@@ -774,80 +815,103 @@ abstract class MetaModel
}
}
return array($sFormat, $nameRawSpec);
}
elseif (empty($nameRawSpec))
{
return array($sClass, array());
}
else
{
return [$sFormat, $nameRawSpec];
} elseif (empty($nameRawSpec)) {
return [$sClass, []];
} else {
// string -> attcode
return array('%1$s', array($nameRawSpec));
return ['%1$s', [$nameRawSpec]];
}
}
/**
* @param string $sClass
*
* @return array
* @param string $sClass
* @param bool $bWithAttributeDefinition
* @param string $sType {@see \Combodo\iTop\Core\MetaModel\FriendlyNameType}
*
* @return array of attribute codes used by friendlyname
* @throws \CoreException
* @throws \DictExceptionMissingString
* @since 3.0.0
*/
final static public function GetComplementAttributeSpec($sClass)
final public static function GetNameAttributes(string $sClass, $bWithAttributeDefinition = false, $sType = FriendlyNameType::SHORT): array
{
self::_check_subclass($sClass);
if (!isset(self::$m_aClassParams[$sClass]["name_complement_for_select"]))
{
$sParentClass = static::GetParentClass($sClass);
if (is_null($sParentClass)) {
return array($sClass, array());
$aNameAttCodes = [];
if ($sType == FriendlyNameType::SHORT || FriendlyNameType::LONG) {
$rawNameAttCodes = self::$m_aClassParams[$sClass]["name_attcode"];
if (!is_array($rawNameAttCodes)) {
if (self::IsValidAttCode($sClass, $rawNameAttCodes)) {
$aNameAttCodes[] = $rawNameAttCodes;
}
} else {
return static::GetComplementAttributeSpec($sParentClass);
$aNameAttCodes = $rawNameAttCodes;
}
}
$nameRawSpec = self::$m_aClassParams[$sClass]["name_complement_for_select"];
if (is_array($nameRawSpec))
{
$sFormat = Dict::S("Class:$sClass/ComplementForSelect", '');
if (strlen($sFormat) == 0)
{
// Default to "%1$s %2$s..."
for($i = 1; $i <= count($nameRawSpec); $i++)
{
if (empty($sFormat))
{
$sFormat .= '%'.$i.'$s';
}
else
{
$sFormat .= ' %'.$i.'$s';
if ($sType == FriendlyNameType::COMPLEMENTARY || FriendlyNameType::LONG) {
$rawNameAttCodes = self::$m_aClassParams[$sClass]["complementary_name_attcode"];
if (!isEmpty($rawNameAttCodes)) {
if (!is_array($rawNameAttCodes)) {
if (self::IsValidAttCode($sClass, $rawNameAttCodes)) {
$aNameAttCodes[] = array_merge($aNameAttCodes, [$rawNameAttCodes]);
}
} else {
$aNameAttCodes = array_merge($rawNameAttCodes, $rawNameAttCodes);
}
}
return array($sFormat, $nameRawSpec);
}
elseif (empty($nameRawSpec))
{
return array($sClass, array());
}
else
{
// string -> attcode
return array('%1$s', array($nameRawSpec));
if ($bWithAttributeDefinition) {
$aResults = [];
foreach ($aNameAttCodes as $sAttCode) {
$aResults[$sAttCode] = self::GetAttributeDef($sClass, $sAttCode);
}
return $aResults;
}
return $aNameAttCodes;
}
/**
* @param string $sClass
* @param false $bWithAttributeDefinition
*
* @return array of attributes to always reload in tables
* @throws \CoreException
* @since 3.0.0
*/
final public static function GetAttributesToAlwaysLoadInTables(string $sClass, $bWithAttributeDefinition = false): array
{
$aResults = [];
foreach (self::GetAttributesList($sClass) as $sAttCode) {
$oAttDef = self::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->AlwaysLoadInTables()) {
if ($bWithAttributeDefinition) {
$aResults[$sAttCode] = $oAttDef;
} else {
$aResults[] = $sAttCode;
}
}
}
return $aResults;
}
/**
* Get the friendly name expression for a given class
*
* @param string $sClass
* @param string $sType {@see \Combodo\iTop\Core\MetaModel\FriendlyNameType}
*
* @return Expression
* @throws \CoreException
* @throws \DictExceptionMissingString
*
* @since 3.0.0 N°580 New $sType parameter
*/
final public static function GetNameExpression($sClass)
final public static function GetNameExpression($sClass, $sType = FriendlyNameType::SHORT)
{
$aNameSpec = self::GetNameSpec($sClass);
$aNameSpec = self::GetNameSpec($sClass, $sType);
$sFormat = $aNameSpec[0];
$aAttributes = $aNameSpec[1];
@@ -879,14 +943,17 @@ abstract class MetaModel
/**
* @param string $sClass
* @param string $sType {@see \Combodo\iTop\Core\MetaModel\FriendlyNameType}
*
* @return string The friendly name IIF it is equivalent to a single attribute
* @throws \CoreException
* @throws \DictExceptionMissingString
*
* @since 3.0.0 N°580 New $sType parameter
*/
final public static function GetFriendlyNameAttributeCode($sClass)
final public static function GetFriendlyNameAttributeCode($sClass, $sType = FriendlyNameType::SHORT)
{
$aNameSpec = self::GetNameSpec($sClass);
$aNameSpec = self::GetNameSpec($sClass, $sType);
$sFormat = trim($aNameSpec[0]);
$aAttributes = $aNameSpec[1];
if (($sFormat != '') && ($sFormat != '%1$s')) {
@@ -902,13 +969,16 @@ abstract class MetaModel
/**
* Returns the list of attributes composing the friendlyname
*
* @param $sClass
* @param string $sClass
* @param string $sType {@see \Combodo\iTop\Core\MetaModel\FriendlyNameType}
*
* @return array
*
* @since 3.0.0 N°580 New $sType parameter
*/
final public static function GetFriendlyNameAttributeCodeList($sClass)
final public static function GetFriendlyNameAttributeCodeList($sClass, $sType = FriendlyNameType::SHORT)
{
$aNameSpec = self::GetNameSpec($sClass);
$aNameSpec = self::GetNameSpec($sClass, $sType);
$aAttributes = $aNameSpec[1];
return $aAttributes;
@@ -1077,7 +1147,8 @@ abstract class MetaModel
{
self::_check_subclass($sClass);
$oAtt = self::GetAttributeDef($sClass, $sAttCode);
return $oAtt->GetPrerequisiteAttributes();
return $oAtt->GetPrerequisiteAttributes($sClass);
}
/**
@@ -1419,7 +1490,10 @@ abstract class MetaModel
*/
final public static function GetFiltersList($sClass)
{
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
self::_check_subclass($sClass);
return array_keys(self::$m_aFilterDefs[$sClass]);
}
@@ -1526,6 +1600,8 @@ abstract class MetaModel
*/
final public static function IsValidFilterCode($sClass, $sFilterCode)
{
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
if (!array_key_exists($sClass, self::$m_aFilterDefs)) {
return false;
}
@@ -1837,7 +1913,10 @@ abstract class MetaModel
*/
public static function GetClassFilterDefs($sClass)
{
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
self::_check_subclass($sClass);
return self::$m_aFilterDefs[$sClass];
}
@@ -1852,6 +1931,7 @@ abstract class MetaModel
*/
final public static function GetClassFilterDef($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
self::_check_subclass($sClass);
if (!array_key_exists($sFilterCode, self::$m_aFilterDefs[$sClass])) {
throw new CoreException("Unknown filter code '$sFilterCode' for class '$sClass'");
@@ -1871,9 +1951,9 @@ abstract class MetaModel
*/
public static function GetFilterLabel($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter)
{
if ($oFilter) {
return $oFilter->GetLabel();
}
@@ -1890,11 +1970,12 @@ abstract class MetaModel
*/
public static function GetFilterDescription($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter)
{
if ($oFilter) {
return $oFilter->GetDescription();
}
return "";
}
@@ -1908,11 +1989,12 @@ abstract class MetaModel
*/
public static function GetFilterOperators($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter)
{
if ($oFilter) {
return $oFilter->GetOperators();
}
return array();
}
@@ -1926,9 +2008,9 @@ abstract class MetaModel
*/
public static function GetFilterLooseOperator($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter)
{
if ($oFilter) {
return $oFilter->GetLooseOperator();
}
@@ -1946,9 +2028,9 @@ abstract class MetaModel
*/
public static function GetFilterOpDescription($sClass, $sFilterCode, $sOpCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter)
{
if ($oFilter) {
return $oFilter->GetOpDescription($sOpCode);
}
@@ -1963,6 +2045,8 @@ abstract class MetaModel
*/
public static function GetFilterHTMLInput($sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
return "<INPUT name=\"$sFilterCode\">";
}
@@ -2137,24 +2221,21 @@ abstract class MetaModel
*/
public static function EnumRelations($sClass = '')
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('Use EnumRelationsEx instead');
$aResult = array_keys(self::$m_aRelationInfos);
if (!empty($sClass))
{
if (!empty($sClass)) {
// Return only the relations that have a meaning (i.e. for which at least one query is defined)
// for the specified class
$aClassRelations = array();
foreach($aResult as $sRelCode)
{
foreach ($aResult as $sRelCode) {
$aQueriesDown = self::EnumRelationQueries($sClass, $sRelCode);
if (count($aQueriesDown) > 0)
{
if (count($aQueriesDown) > 0) {
$aClassRelations[] = $sRelCode;
}
// Temporary patch: until the impact analysis GUI gets rewritten,
// let's consider that "depends on" is equivalent to "impacts/up"
// The current patch has been implemented in DBObject and MetaModel
if ($sRelCode == 'impacts')
{
if ($sRelCode == 'impacts') {
$aQueriesUp = self::EnumRelationQueries($sClass, 'impacts', false);
if (count($aQueriesUp) > 0)
{
@@ -3002,8 +3083,7 @@ abstract class MetaModel
// Set attribute code
self::$m_aClassParams[$sPHPClass]['state_attcode'] = self::$m_aClassParams[$sParent]['state_attcode'];
// Set states
self::$m_aStates[$sPHPClass] = self::$m_aStates[$sParent];
// Note: Don't set self::$m_aStates[$sPHPClass], it has already been done by self::Init_DefineState()
}
// - Image attribute
$bParentHasImageAttribute = (isset(self::$m_aClassParams[$sParent]['image_attcode']) && !empty(self::$m_aClassParams[$sParent]['image_attcode']));
@@ -4051,19 +4131,26 @@ abstract class MetaModel
/**
* @param string $sClass
* @param int $iOption one of ENUM_CHILD_CLASSES_EXCLUDETOP, ENUM_CHILD_CLASSES_ALL
* @param bool $bRootFirst Only when $iOption NOT set to ENUM_CHILD_CLASSES_EXCLUDETOP. If true, the $sClass will be the first element of the returned array, otherwise it will be the last (legacy behavior)
*
* @return array
* @throws \CoreException
* @since 3.0.0 Added $bRootFirst param.
*/
public static function EnumChildClasses($sClass, $iOption = ENUM_CHILD_CLASSES_EXCLUDETOP)
public static function EnumChildClasses($sClass, $iOption = ENUM_CHILD_CLASSES_EXCLUDETOP, $bRootFirst = false)
{
self::_check_subclass($sClass);
$aRes = self::$m_aChildClasses[$sClass];
if ($iOption != ENUM_CHILD_CLASSES_EXCLUDETOP)
{
// Add it to the list
$aRes[] = $sClass;
if ($bRootFirst) {
// Root class on top
array_unshift($aRes, $sClass);
} else {
// Root class at the end, legacy behavior
$aRes[] = $sClass;
}
}
return $aRes;
@@ -4450,15 +4537,15 @@ abstract class MetaModel
/**
* Check (and updates if needed) the hierarchical keys
*
* @param boolean $bDiagnosticsOnly If true only a diagnostic pass will be run, returning true or false
* @param boolean $bVerbose Displays some information about what is done/what needs to be done
* @param boolean $bForceComputation If true, the _left and _right parameters will be recomputed even if some
* @param bool $bDiagnosticsOnly If true only a diagnostic pass will be run, returning true or false
* @param bool $bVerbose Displays some information about what is done/what needs to be done
* @param bool $bForceComputation If true, the _left and _right parameters will be recomputed even if some
* values already exist in the DB
*
* @return bool
* @throws \CoreException
* @throws \Exception
*/
public static function CheckHKeys($bDiagnosticsOnly = false, $bVerbose = false, $bForceComputation = false)
public static function CheckHKeys(bool $bDiagnosticsOnly = false, bool $bVerbose = false, bool $bForceComputation = false)
{
$bChangeNeeded = false;
foreach(self::GetClasses() as $sClass)
@@ -5048,7 +5135,7 @@ abstract class MetaModel
foreach($aErrors as $sClass => $aMessages)
{
echo "<p>Wrong declaration for class <b>$sClass</b></p>\n";
echo "<ul class=\"treeview\">\n";
echo "<ul >\n";
$i = 0;
foreach($aMessages as $sMsg)
{
@@ -5512,7 +5599,7 @@ abstract class MetaModel
$aSugFix[$sClass]['id'][] = "ALTER TABLE `$sTable` ADD $sKeyFieldDefinition";
if (!$bTableToCreate)
{
$aAlterTableItems[$sTable][$sKeyField] = "ADD $sKeyFieldDefinition";
$aAlterTableItems[$sTable]['field'][$sKeyField] = "ADD $sKeyFieldDefinition";
}
}
else
@@ -5525,7 +5612,7 @@ abstract class MetaModel
$aSugFix[$sClass]['id'][] = "ALTER TABLE `$sTable`, DROP PRIMARY KEY, ADD PRIMARY key(`$sKeyField`)";
if (!$bTableToCreate)
{
$aAlterTableItems[$sTable][$sKeyField] = "CHANGE `$sKeyField` $sKeyFieldDefinition";
$aAlterTableItems[$sTable]['field'][$sKeyField] = "CHANGE `$sKeyField` $sKeyFieldDefinition";
}
}
if (self::IsAutoIncrementKey($sClass) && !CMDBSource::IsAutoIncrement($sTable, $sKeyField))
@@ -5534,7 +5621,7 @@ abstract class MetaModel
$aSugFix[$sClass]['id'][] = "ALTER TABLE `$sTable` CHANGE `$sKeyField` $sKeyFieldDefinition";
if (!$bTableToCreate)
{
$aAlterTableItems[$sTable][$sKeyField] = "CHANGE `$sKeyField` $sKeyFieldDefinition";
$aAlterTableItems[$sTable]['field'][$sKeyField] = "CHANGE `$sKeyField` $sKeyFieldDefinition";
}
}
}
@@ -5597,7 +5684,7 @@ abstract class MetaModel
}
else
{
$aAlterTableItems[$sTable][$sField] = "ADD $sFieldDefinition";
$aAlterTableItems[$sTable]['field'][$sField] = "ADD $sFieldDefinition";
$aAdditionalRequests = self::GetAdditionalRequestAfterAlter($sClass, $sTable, $sField);
if (!empty($aAdditionalRequests))
{
@@ -5641,7 +5728,7 @@ abstract class MetaModel
}
else
{
$aAlterTableItems[$sTable][] = "ADD $sIndexType `$sIndexName` ($sColumns)";
$aAlterTableItems[$sTable]['index'][] = "ADD $sIndexType `$sIndexName` ($sColumns)";
}
}
@@ -5682,7 +5769,7 @@ abstract class MetaModel
if (CMDBSource::HasIndex($sTable, $sField))
{
$aSugFix[$sClass][$sAttCode][] = "ALTER TABLE `$sTable` DROP INDEX `$sIndexName`";
$aAlterTableItems[$sTable][] = "DROP INDEX `$sIndexName`";
$aAlterTableItems[$sTable]['index'][] = "DROP INDEX `$sIndexName`";
}
$sSugFixAfterChange = "ALTER TABLE `$sTable` ADD $sIndexType `$sIndexName` ($sColumns)";
$sAlterTableItemsAfterChange = "ADD $sIndexType `$sIndexName` ($sColumns)";
@@ -5696,7 +5783,7 @@ abstract class MetaModel
{
$aErrors[$sClass][$sAttCode][] = "field '$sField' in table '$sTable' has a wrong type: found <code>$sActualFieldSpec</code> while expecting <code>$sDBFieldSpec</code>";
$aSugFix[$sClass][$sAttCode][] = "ALTER TABLE `$sTable` CHANGE `$sField` $sFieldDefinition";
$aAlterTableItems[$sTable][$sField] = "CHANGE `$sField` $sFieldDefinition";
$aAlterTableItems[$sTable]['field'][$sField] = "CHANGE `$sField` $sFieldDefinition";
}
// Create indexes (external keys only... so far)
@@ -5711,7 +5798,7 @@ abstract class MetaModel
}
else
{
$aAlterTableItems[$sTable][] = $sAlterTableItemsAfterChange;
$aAlterTableItems[$sTable]['index'][] = $sAlterTableItemsAfterChange;
}
}
}
@@ -5771,9 +5858,12 @@ abstract class MetaModel
{
$aAlterTableItems[$sTable] = array();
}
array_unshift($aAlterTableItems[$sTable], "DROP INDEX `$sIndexId`");
if (isset($aAlterTableItems[$sTable]['index']))
{
array_unshift($aAlterTableItems[$sTable]['index'], "DROP INDEX `$sIndexId`");
}
}
$aAlterTableItems[$sTable][] = "ADD INDEX `$sIndexId` ($sColumns)";
$aAlterTableItems[$sTable]['index'][] = "ADD INDEX `$sIndexId` ($sColumns)";
}
}
}
@@ -5791,7 +5881,7 @@ abstract class MetaModel
// without specifying the value of this unknown column
$sFieldDefinition = "`$sField` ".CMDBSource::GetFieldType($sTable, $sField).' NULL';
$aSugFix[$sClass][$sAttCode][] = "ALTER TABLE `$sTable` CHANGE `$sField` $sFieldDefinition";
$aAlterTableItems[$sTable][$sField] = "CHANGE `$sField` $sFieldDefinition";
$aAlterTableItems[$sTable]['field'][$sField] = "CHANGE `$sField` $sFieldDefinition";
}
$aSugFix[$sClass][$sAttCode][] = "-- Recommended action: ALTER TABLE `$sTable` DROP `$sField`";
}
@@ -5810,7 +5900,10 @@ abstract class MetaModel
{
$aAlterTableItems[$sTable] = array();
}
array_unshift($aAlterTableItems[$sTable], "DROP INDEX `$sIndexId`");
if (isset($aAlterTableItems[$sTable]['index']))
{
array_unshift($aAlterTableItems[$sTable]['index'], "DROP INDEX `$sIndexId`");
}
}
}
@@ -5842,8 +5935,16 @@ abstract class MetaModel
}
foreach ($aAlterTableItems as $sTable => $aChangeList)
{
$sChangeList = implode(', ', $aChangeList);
$aCondensedQueries[] = "ALTER TABLE `$sTable` $sChangeList";
if (isset($aAlterTableItems[$sTable]['field']))
{
$sChangeList = implode(', ', $aChangeList['field']);
$aCondensedQueries[] = "ALTER TABLE `$sTable` $sChangeList";
}
if (isset($aAlterTableItems[$sTable]['index']))
{
$sChangeList = implode(', ', $aChangeList['index']);
$aCondensedQueries[] = "ALTER TABLE `$sTable` $sChangeList";
}
// Add request right after the ALTER TABLE
if (isset($aPostTableAlteration[$sTable]))
{
@@ -5869,7 +5970,8 @@ abstract class MetaModel
/**
* @deprecated 2.7.0 N°2369 will be removed in 2.8
* @deprecated 2.7.0 N°2369 Method will not be removed any time soon as we still need to drop view if the instance is migrating from an iTop 2.x to an iTop 3.0 or newer, even if they skip iTop 3.0.
* @since 3.0.0 Does not recreate SQL views, only drops them. Method has not been renamed to avoid regressions
*
* @return array
* @throws \CoreException
@@ -5893,6 +5995,7 @@ abstract class MetaModel
$aSugFix[$sClass]['*'][] = "DROP VIEW `$sView`";
}
}
return array($aErrors, $aSugFix);
}
@@ -6428,6 +6531,7 @@ abstract class MetaModel
*/
public static function LoadConfig($oConfiguration, $bAllowCache = false)
{
$oKPI = new ExecutionKPI();
self::$m_oConfig = $oConfiguration;
// N°2478 utils has his own private attribute
@@ -6438,8 +6542,7 @@ abstract class MetaModel
// Set log ASAP
if (self::$m_oConfig->GetLogGlobal())
{
if (self::$m_oConfig->GetLogIssue())
{
if (self::$m_oConfig->GetLogIssue()) {
self::$m_bLogIssue = true;
IssueLog::Enable(APPROOT.'log/error.log');
}
@@ -6448,6 +6551,8 @@ abstract class MetaModel
ToolsLog::Enable(APPROOT.'log/tools.log');
DeadLockLog::Enable();
DeprecatedCallsLog::Enable();
ExceptionLog::Enable();
}
else
{
@@ -6504,6 +6609,7 @@ abstract class MetaModel
$sSource = self::$m_oConfig->Get('db_name');
$sTablePrefix = self::$m_oConfig->Get('db_subname');
$oKPI->ComputeAndReport('Load config');
if (self::$m_bUseAPCCache)
{
@@ -6875,7 +6981,7 @@ abstract class MetaModel
* @param int $iKey id value of the object to retrieve
* @param bool $bMustBeFound see throws ArchivedObjectException
* @param bool $bAllowAllData if true then user rights will be bypassed - use with care!
* @param null $aModifierProperties
* @param array $aModifierProperties properties for {@see iQueryModifier} impl
*
* @return \DBObject null if : (the object is not found) or (archive mode disabled and object is archived and
* $bMustBeFound=false)
@@ -6895,12 +7001,9 @@ abstract class MetaModel
if (!utils::IsArchiveMode() && $oObject->IsArchived())
{
if ($bMustBeFound)
{
if ($bMustBeFound) {
throw new ArchivedObjectException("The object $sClass::$iKey is archived");
}
else
{
} else {
return null;
}
}
@@ -6908,6 +7011,35 @@ abstract class MetaModel
return $oObject;
}
/**
* @param string $sClass
* @param int $iKey
*
* @return bool True if the object of $sClass and $iKey exists in the DB -no matter the current user restrictions-, false otherwise meaning:
* - It could be in memory for now and is not persisted yet
* - It is neither in memory nor DB
*
* @throws \CoreException
* @throws \MySQLException
* @throws \MySQLQueryHasNoResultException
* @since 3.0.0 N°4173
*/
public static function IsObjectInDB(string $sClass, int $iKey): bool
{
// Note: We take the root class to ensure that there is a corresponding table in the DB
// as some intermediate classes can have no table in the DB.
$sRootClass = MetaModel::GetRootClass($sClass);
$sTable = MetaModel::DBGetTable($sRootClass);
$sKeyCol = MetaModel::DBGetKey($sRootClass);
$sEscapedKey = CMDBSource::Quote($iKey);
$sQuery = "SELECT count(*) FROM `{$sTable}` WHERE `{$sKeyCol}` = {$sEscapedKey}";
$iCount = (int) CMDBSource::QueryToScalar($sQuery);
return $iCount === 1;
}
/**
* Search for the specified class and id. If the object is archived it will be returned anyway (this is for pre-2.4
* module compatibility, see N.1108)
@@ -7108,19 +7240,6 @@ abstract class MetaModel
return $oRet;
}
/**
* @deprecated 2.7.0 N°1627, use ItopCounter::incRootClass($sClass) instead
*
* @param string $sClass
*
* @return int
* @throws \CoreException
*/
public static function GetNextKey($sClass)
{
return ItopCounter::IncClass($sClass);
}
/**
* Deletion of records, bypassing {@link DBObject::DBDelete} !!!
* It is NOT recommended to use this shortcut
@@ -7141,9 +7260,9 @@ abstract class MetaModel
*/
public static function BulkDelete(DBObjectSearch $oFilter)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$sSQL = $oFilter->MakeDeleteQuery();
if (!self::DBIsReadOnly())
{
if (!self::DBIsReadOnly()) {
CMDBSource::Query($sSQL);
}
}
@@ -7162,10 +7281,10 @@ abstract class MetaModel
{
// $aValues is an array of $sAttCode => $value
$sSQL = $oFilter->MakeUpdateQuery($aValues);
if (!self::DBIsReadOnly())
{
if (!self::DBIsReadOnly()) {
CMDBSource::Query($sSQL);
}
return CMDBSource::AffectedRows();
}
@@ -7345,9 +7464,11 @@ abstract class MetaModel
* @param string $sInput
* @param array $aParams
*
* @return mixed
* @return string
*
* @throws \Exception
*/
static public function ApplyParams($sInput, $aParams)
public static function ApplyParams($sInput, $aParams)
{
$aParams = static::AddMagicPlaceholders($aParams);
@@ -7357,7 +7478,7 @@ abstract class MetaModel
$aSearches = array();
$aReplacements = array();
foreach($aParams as $sSearch => $replace)
foreach ($aParams as $sSearch => $replace)
{
// Some environment parameters are objects, we just need scalars
if (is_object($replace))
@@ -7606,14 +7727,18 @@ abstract class MetaModel
/**
* @param string $sClass
* @param string $sAttCode
* @param string $sValue
* @param string|null $sValue Code of the state value, can be null if allowed by the attribute definition
*
* @return \ormStyle|null
* @throws \Exception
* @throws \CoreException
*/
public static function GetEnumStyle(string $sClass, string $sAttCode, string $sValue = ''): ?ormStyle
public static function GetEnumStyle(string $sClass, string $sAttCode, ?string $sValue = ''): ?ormStyle
{
if (strlen($sAttCode) === 0) {
return null;
}
$oAttDef = self::GetAttributeDef($sClass, $sAttCode);
if (!$oAttDef instanceof AttributeEnum) {
throw new CoreException("MetaModel::GetEnumStyle() Attribute $sAttCode of class $sClass is not an AttributeEnum\n");

View File

@@ -242,6 +242,8 @@ class iTopMutex
*
* @throws \Exception
* @throws \MySQLException
*
* @since 2.7.5 3.0.0 N°3968 specify `wait_timeout` for the mutex dedicated connection
*/
public function InitMySQLSession()
{
@@ -254,10 +256,36 @@ class iTopMutex
$this->hDBLink = CMDBSource::GetMysqliInstance($sServer, $sUser, $sPwd, $sSource, $bTlsEnabled, $sTlsCA, false);
if (!$this->hDBLink)
{
if (!$this->hDBLink) {
throw new Exception("Could not connect to the DB server (host=$sServer, user=$sUser): ".mysqli_connect_error().' (mysql errno: '.mysqli_connect_errno().')');
}
// Make sure that the server variable `wait_timeout` is at least 86400 seconds for this connection,
// since the lock will be released if/when the connection times out.
// Source https://dev.mysql.com/doc/refman/5.7/en/locking-functions.html :
// > A lock obtained with GET_LOCK() is released explicitly by executing RELEASE_LOCK() or implicitly when your session terminates
//
// BEWARE: If you want to check the value of this variable, when run from an interactive console `SHOW VARIABLES LIKE 'wait_timeout'`
// will actually returns the value of the variable `interactive_timeout` which may be quite different.
$sSql = "SHOW VARIABLES LIKE 'wait_timeout'";
$result = mysqli_query($this->hDBLink, $sSql);
if (!$result) {
throw new Exception("Failed to issue MySQL query '".$sSql."': ".mysqli_error($this->hDBLink).' (mysql errno: '.mysqli_errno($this->hDBLink).')');
}
if ($aRow = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$iTimeout = (int)$aRow[1];
} else {
mysqli_free_result($result);
throw new Exception("No result for query '".$sSql."'");
}
mysqli_free_result($result);
if ($iTimeout < 86400) {
$result = mysqli_query($this->hDBLink, 'SET SESSION wait_timeout=86400');
if ($result === false) {
throw new Exception("Failed to issue MySQL query '".$sSql."': ".mysqli_error($this->hDBLink).' (mysql errno: '.mysqli_errno($this->hDBLink).')');
}
}
}

View File

@@ -117,6 +117,9 @@ abstract class Expression {
*/
public function Render(&$aArgs = null, $bRetrofitParams = false)
{
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use RenderExpression');
return $this->RenderExpression(false, $aArgs, $bRetrofitParams);
}

View File

@@ -597,7 +597,7 @@ static public $yy_action = array(
** defined, then do no error processing.
*/
const YYNOCODE = 119;
const YYSTACKDEPTH = 100;
const YYSTACKDEPTH = 1000;
const YYNSTATE = 175;
const YYNRULE = 125;
const YYERRORSYMBOL = 76;
@@ -1175,6 +1175,10 @@ static public $yy_action = array(
}
/* Here code is inserted which will execute if the parser
** stack ever overflows */
#line 30 "..\oql-parser.y"
throw new OQLParserStackOverFlowException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol);
#line 1186 "..\oql-parser.php"
return;
}
$yytos = new OQLParser_yyStackEntry;
@@ -1474,116 +1478,116 @@ static public $yy_action = array(
** function yy_r0($yymsp){ ... } // User supplied code
** #line <lineno> <thisfile>
*/
#line 29 "..\oql-parser.y"
#line 37 "..\oql-parser.y"
function yy_r0(){ $this->my_result = $this->yystack[$this->yyidx + 0]->minor; }
#line 1483 "..\oql-parser.php"
#line 33 "..\oql-parser.y"
#line 1488 "..\oql-parser.php"
#line 41 "..\oql-parser.y"
function yy_r3(){
$this->_retvalue = new OqlUnionQuery($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
}
#line 1488 "..\oql-parser.php"
#line 40 "..\oql-parser.y"
#line 1493 "..\oql-parser.php"
#line 48 "..\oql-parser.y"
function yy_r5(){
$this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, array($this->yystack[$this->yyidx + -2]->minor));
}
#line 1493 "..\oql-parser.php"
#line 43 "..\oql-parser.y"
#line 1498 "..\oql-parser.php"
#line 51 "..\oql-parser.y"
function yy_r6(){
$this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, array($this->yystack[$this->yyidx + -2]->minor));
}
#line 1498 "..\oql-parser.php"
#line 47 "..\oql-parser.y"
#line 1503 "..\oql-parser.php"
#line 55 "..\oql-parser.y"
function yy_r7(){
$this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + -4]->minor);
}
#line 1503 "..\oql-parser.php"
#line 50 "..\oql-parser.y"
#line 1508 "..\oql-parser.php"
#line 58 "..\oql-parser.y"
function yy_r8(){
$this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + -6]->minor);
}
#line 1508 "..\oql-parser.php"
#line 55 "..\oql-parser.y"
#line 1513 "..\oql-parser.php"
#line 63 "..\oql-parser.y"
function yy_r9(){
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor);
}
#line 1513 "..\oql-parser.php"
#line 58 "..\oql-parser.y"
#line 1518 "..\oql-parser.php"
#line 66 "..\oql-parser.y"
function yy_r10(){
array_push($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor;
}
#line 1519 "..\oql-parser.php"
#line 63 "..\oql-parser.y"
#line 1524 "..\oql-parser.php"
#line 71 "..\oql-parser.y"
function yy_r11(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 1522 "..\oql-parser.php"
#line 64 "..\oql-parser.y"
#line 1527 "..\oql-parser.php"
#line 72 "..\oql-parser.y"
function yy_r12(){ $this->_retvalue = null; }
#line 1525 "..\oql-parser.php"
#line 66 "..\oql-parser.y"
#line 1530 "..\oql-parser.php"
#line 74 "..\oql-parser.y"
function yy_r13(){
// insert the join statement on top of the existing list
array_unshift($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor);
// and return the updated array
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
}
#line 1533 "..\oql-parser.php"
#line 72 "..\oql-parser.y"
#line 1538 "..\oql-parser.php"
#line 80 "..\oql-parser.y"
function yy_r14(){
$this->_retvalue = Array($this->yystack[$this->yyidx + 0]->minor);
}
#line 1538 "..\oql-parser.php"
#line 78 "..\oql-parser.y"
#line 1543 "..\oql-parser.php"
#line 86 "..\oql-parser.y"
function yy_r16(){
// create an array with one single item
$this->_retvalue = new OqlJoinSpec($this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
}
#line 1544 "..\oql-parser.php"
#line 83 "..\oql-parser.y"
#line 1549 "..\oql-parser.php"
#line 91 "..\oql-parser.y"
function yy_r17(){
// create an array with one single item
$this->_retvalue = new OqlJoinSpec($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
}
#line 1550 "..\oql-parser.php"
#line 88 "..\oql-parser.y"
function yy_r18(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, '=', $this->yystack[$this->yyidx + 0]->minor); }
#line 1553 "..\oql-parser.php"
#line 89 "..\oql-parser.y"
function yy_r19(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'BELOW', $this->yystack[$this->yyidx + 0]->minor); }
#line 1556 "..\oql-parser.php"
#line 90 "..\oql-parser.y"
function yy_r20(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'BELOW_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1559 "..\oql-parser.php"
#line 91 "..\oql-parser.y"
function yy_r21(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_BELOW', $this->yystack[$this->yyidx + 0]->minor); }
#line 1562 "..\oql-parser.php"
#line 92 "..\oql-parser.y"
function yy_r22(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_BELOW_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1565 "..\oql-parser.php"
#line 93 "..\oql-parser.y"
function yy_r23(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'ABOVE', $this->yystack[$this->yyidx + 0]->minor); }
#line 1568 "..\oql-parser.php"
#line 94 "..\oql-parser.y"
function yy_r24(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'ABOVE_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1571 "..\oql-parser.php"
#line 95 "..\oql-parser.y"
function yy_r25(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_ABOVE', $this->yystack[$this->yyidx + 0]->minor); }
#line 1574 "..\oql-parser.php"
#line 1555 "..\oql-parser.php"
#line 96 "..\oql-parser.y"
function yy_r26(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_ABOVE_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1577 "..\oql-parser.php"
function yy_r18(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, '=', $this->yystack[$this->yyidx + 0]->minor); }
#line 1558 "..\oql-parser.php"
#line 97 "..\oql-parser.y"
function yy_r19(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'BELOW', $this->yystack[$this->yyidx + 0]->minor); }
#line 1561 "..\oql-parser.php"
#line 98 "..\oql-parser.y"
function yy_r27(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 1580 "..\oql-parser.php"
function yy_r20(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'BELOW_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1564 "..\oql-parser.php"
#line 99 "..\oql-parser.y"
function yy_r21(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_BELOW', $this->yystack[$this->yyidx + 0]->minor); }
#line 1567 "..\oql-parser.php"
#line 100 "..\oql-parser.y"
function yy_r22(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_BELOW_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1570 "..\oql-parser.php"
#line 101 "..\oql-parser.y"
function yy_r23(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'ABOVE', $this->yystack[$this->yyidx + 0]->minor); }
#line 1573 "..\oql-parser.php"
#line 102 "..\oql-parser.y"
function yy_r24(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'ABOVE_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1576 "..\oql-parser.php"
#line 103 "..\oql-parser.y"
function yy_r31(){ $this->_retvalue = new FunctionOqlExpression($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor); }
#line 1583 "..\oql-parser.php"
function yy_r25(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_ABOVE', $this->yystack[$this->yyidx + 0]->minor); }
#line 1579 "..\oql-parser.php"
#line 104 "..\oql-parser.y"
function yy_r32(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; }
#line 1586 "..\oql-parser.php"
#line 105 "..\oql-parser.y"
function yy_r33(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
#line 1589 "..\oql-parser.php"
function yy_r26(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_ABOVE_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
#line 1582 "..\oql-parser.php"
#line 106 "..\oql-parser.y"
function yy_r27(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 1585 "..\oql-parser.php"
#line 111 "..\oql-parser.y"
function yy_r31(){ $this->_retvalue = new FunctionOqlExpression($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor); }
#line 1588 "..\oql-parser.php"
#line 112 "..\oql-parser.y"
function yy_r32(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; }
#line 1591 "..\oql-parser.php"
#line 113 "..\oql-parser.y"
function yy_r33(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
#line 1594 "..\oql-parser.php"
#line 119 "..\oql-parser.y"
function yy_r37(){
if ($this->yystack[$this->yyidx + -1]->minor == 'MATCHES')
{
@@ -1594,44 +1598,44 @@ static public $yy_action = array(
$this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor);
}
}
#line 1601 "..\oql-parser.php"
#line 128 "..\oql-parser.y"
#line 1606 "..\oql-parser.php"
#line 136 "..\oql-parser.y"
function yy_r42(){
$this->_retvalue = new ListOqlExpression($this->yystack[$this->yyidx + -1]->minor);
}
#line 1606 "..\oql-parser.php"
#line 131 "..\oql-parser.y"
#line 1611 "..\oql-parser.php"
#line 139 "..\oql-parser.y"
function yy_r43(){
$this->_retvalue = new NestedQueryOqlExpression($this->yystack[$this->yyidx + -1]->minor);
}
#line 1611 "..\oql-parser.php"
#line 146 "..\oql-parser.y"
#line 1616 "..\oql-parser.php"
#line 154 "..\oql-parser.y"
function yy_r47(){
$this->_retvalue = array();
}
#line 1616 "..\oql-parser.php"
#line 157 "..\oql-parser.y"
#line 1621 "..\oql-parser.php"
#line 165 "..\oql-parser.y"
function yy_r51(){ $this->_retvalue = new IntervalOqlExpression($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
#line 1619 "..\oql-parser.php"
#line 170 "..\oql-parser.y"
#line 1624 "..\oql-parser.php"
#line 178 "..\oql-parser.y"
function yy_r61(){ $this->_retvalue = new ScalarOqlExpression($this->yystack[$this->yyidx + 0]->minor); }
#line 1622 "..\oql-parser.php"
#line 172 "..\oql-parser.y"
#line 1627 "..\oql-parser.php"
#line 180 "..\oql-parser.y"
function yy_r63(){ $this->_retvalue = new ScalarOqlExpression(null); }
#line 1625 "..\oql-parser.php"
#line 174 "..\oql-parser.y"
#line 1630 "..\oql-parser.php"
#line 182 "..\oql-parser.y"
function yy_r64(){ $this->_retvalue = new FieldOqlExpression($this->yystack[$this->yyidx + 0]->minor); }
#line 1628 "..\oql-parser.php"
#line 175 "..\oql-parser.y"
#line 1633 "..\oql-parser.php"
#line 183 "..\oql-parser.y"
function yy_r65(){ $this->_retvalue = new FieldOqlExpression($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -2]->minor); }
#line 1631 "..\oql-parser.php"
#line 176 "..\oql-parser.y"
#line 1636 "..\oql-parser.php"
#line 184 "..\oql-parser.y"
function yy_r66(){ $this->_retvalue=$this->yystack[$this->yyidx + 0]->minor; }
#line 1634 "..\oql-parser.php"
#line 179 "..\oql-parser.y"
#line 1639 "..\oql-parser.php"
#line 187 "..\oql-parser.y"
function yy_r67(){ $this->_retvalue = new VariableOqlExpression(substr($this->yystack[$this->yyidx + 0]->minor, 1)); }
#line 1637 "..\oql-parser.php"
#line 181 "..\oql-parser.y"
#line 1642 "..\oql-parser.php"
#line 189 "..\oql-parser.y"
function yy_r68(){
if ($this->yystack[$this->yyidx + 0]->minor[0] == '`')
{
@@ -1643,22 +1647,22 @@ static public $yy_action = array(
}
$this->_retvalue = new OqlName($name, $this->m_iColPrev);
}
#line 1650 "..\oql-parser.php"
#line 192 "..\oql-parser.y"
#line 1655 "..\oql-parser.php"
#line 200 "..\oql-parser.y"
function yy_r69(){$this->_retvalue=(int)$this->yystack[$this->yyidx + 0]->minor; }
#line 1653 "..\oql-parser.php"
#line 193 "..\oql-parser.y"
#line 1658 "..\oql-parser.php"
#line 201 "..\oql-parser.y"
function yy_r70(){$this->_retvalue=(int)-$this->yystack[$this->yyidx + 0]->minor; }
#line 1656 "..\oql-parser.php"
#line 194 "..\oql-parser.y"
#line 1661 "..\oql-parser.php"
#line 202 "..\oql-parser.y"
function yy_r71(){$this->_retvalue=new OqlHexValue($this->yystack[$this->yyidx + 0]->minor); }
#line 1659 "..\oql-parser.php"
#line 195 "..\oql-parser.y"
#line 1664 "..\oql-parser.php"
#line 203 "..\oql-parser.y"
function yy_r72(){$this->_retvalue=stripslashes(substr($this->yystack[$this->yyidx + 0]->minor, 1, strlen($this->yystack[$this->yyidx + 0]->minor) - 2)); }
#line 1662 "..\oql-parser.php"
#line 198 "..\oql-parser.y"
#line 1667 "..\oql-parser.php"
#line 206 "..\oql-parser.y"
function yy_r73(){$this->_retvalue=$this->yystack[$this->yyidx + 0]->minor; }
#line 1665 "..\oql-parser.php"
#line 1670 "..\oql-parser.php"
/**
* placeholder for the left hand side in a reduce operation.
@@ -1759,6 +1763,10 @@ static public $yy_action = array(
}
/* Here code is inserted which will be executed whenever the
** parser fails */
#line 33 "..\oql-parser.y"
throw new OQLParserParseFailureException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol);
#line 1775 "..\oql-parser.php"
}
/**
@@ -1772,8 +1780,8 @@ static public $yy_action = array(
{
#line 25 "..\oql-parser.y"
throw new OQLParserException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol, $this->tokenName($yymajor), $TOKEN);
#line 1781 "..\oql-parser.php"
throw new OQLParserSyntaxErrorException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol, $this->tokenName($yymajor), $TOKEN);
#line 1791 "..\oql-parser.php"
}
/**
@@ -1940,19 +1948,47 @@ throw new OQLParserException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCo
} while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
}
}
#line 263 "..\oql-parser.y"
#line 271 "..\oql-parser.y"
class OQLParserException extends OQLException
{
public function __construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue)
{
parent::__construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue);
}
}
class OQLParserSyntaxErrorException extends OQLParserException
{
public function __construct($sInput, $iLine, $iCol, $sTokenName, $sTokenValue)
{
$sIssue = "Unexpected token $sTokenName";
parent::__construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue);
}
}
class OQLParserStackOverFlowException extends OQLParserException
{
public function __construct($sInput, $iLine, $iCol)
{
$sIssue = "Stack overflow";
parent::__construct($sIssue, $sInput, $iLine, $iCol, '');
}
}
class OQLParserParseFailureException extends OQLParserException
{
public function __construct($sInput, $iLine, $iCol)
{
$sIssue = "Unexpected token $sTokenName";
parent::__construct($sIssue, $sInput, $iLine, $iCol, '');
}
}
class OQLParser extends OQLParserRaw
{
// dirty, but working for us (no other mean to get the final result :-(
@@ -2005,4 +2041,4 @@ class OQLParser extends OQLParserRaw
}
}
#line 2014 "..\oql-parser.php"
#line 2052 "..\oql-parser.php"

View File

@@ -23,7 +23,15 @@ later : solve the 2 remaining shift-reduce conflicts (JOIN)
%name OQLParser_
%declare_class {class OQLParserRaw}
%syntax_error {
throw new OQLParserException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol, $this->tokenName($yymajor), $TOKEN);
throw new OQLParserSyntaxErrorException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol, $this->tokenName($yymajor), $TOKEN);
}
/* Bug N°4052 Parser stack size too small for huge OQL requests */
%stack_size 1000
%stack_overflow {
throw new OQLParserStackOverFlowException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol);
}
%parse_failure {
throw new OQLParserParseFailureException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol);
}
result ::= union(X). { $this->my_result = X; }
@@ -263,15 +271,43 @@ func_name(A) ::= F_INET_NTOA(X). { A=X; }
%code {
class OQLParserException extends OQLException
{
public function __construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue)
{
parent::__construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue);
}
}
class OQLParserSyntaxErrorException extends OQLParserException
{
public function __construct($sInput, $iLine, $iCol, $sTokenName, $sTokenValue)
{
$sIssue = "Unexpected token $sTokenName";
parent::__construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue);
}
}
class OQLParserStackOverFlowException extends OQLParserException
{
public function __construct($sInput, $iLine, $iCol)
{
$sIssue = "Stack overflow";
parent::__construct($sIssue, $sInput, $iLine, $iCol, '');
}
}
class OQLParserParseFailureException extends OQLParserException
{
public function __construct($sInput, $iLine, $iCol)
{
$sIssue = "Unexpected token $sTokenName";
parent::__construct($sIssue, $sInput, $iLine, $iCol, '');
}
}
class OQLParser extends OQLParserRaw
{
// dirty, but working for us (no other mean to get the final result :-(

View File

@@ -1 +1 @@
2020-09-29
2021-06-03

View File

@@ -55,7 +55,7 @@ class OQLClassTreeOptimizer
$sJoinedClass = $oJoin->GetOOQLClassNode()->GetNodeClass();
$sExtKeyAttCode = $oJoin->GetLeftField();
$oExtKeyAttDef = MetaModel::GetAttributeDef($oCurrentClassNode->GetNodeClass(), $sExtKeyAttCode);
if ($sJoinedClass == $oExtKeyAttDef->GetTargetClass()) {
if (($oExtKeyAttDef instanceof AttributeExternalKey) && ($sJoinedClass == $oExtKeyAttDef->GetTargetClass())) {
// The join is not used, remove from tree
$oCurrentClassNode->RemoveJoin($sLeftKey, $index);
}

View File

@@ -7,41 +7,50 @@
/**
* Class ormStyle
*
* @since 3.0
* @since 3.0.0
*/
class ormStyle
{
/** @var string */
/** @var string|null */
protected $sMainColor;
/** @var string */
/** @var string|null */
protected $sComplementaryColor;
/** @var string CSS class with color and background-color */
/** @var string|null CSS class with color and background-color */
protected $sStyleClass;
/** @var string CSS class with only color */
/** @var string|null CSS class with only color */
protected $sAltStyleClass;
/** @var string */
/** @var string|null */
protected $sDecorationClasses;
/** @var string */
/** @var string|null Relative path (from current environment) to the icon */
protected $sIcon;
/**
* ormStyle constructor.
*
* @param string $sStyleClass
* @param string $sAltStyleClass
* @param string|null $sStyleClass
* @param string|null $sAltStyleClass
* @param string|null $sMainColor
* @param string|null $sComplementaryColor
* @param string|null $sDecorationClasses
* @param string|null $sIcon
*/
public function __construct(string $sStyleClass, string $sAltStyleClass, string $sMainColor = null, string $sComplementaryColor = null, string $sDecorationClasses = null, string $sIcon = null)
public function __construct(?string $sStyleClass = null, ?string $sAltStyleClass = null, ?string $sMainColor = null, ?string $sComplementaryColor = null, ?string $sDecorationClasses = null, ?string $sIcon = null)
{
$this->sMainColor = $sMainColor;
$this->sComplementaryColor = $sComplementaryColor;
$this->sStyleClass = $sStyleClass;
$this->sAltStyleClass = $sAltStyleClass;
$this->sDecorationClasses = $sDecorationClasses;
$this->sIcon = $sIcon;
$this->SetMainColor($sMainColor);
$this->SetComplementaryColor($sComplementaryColor);
$this->SetStyleClass($sStyleClass);
$this->SetAltStyleClass($sAltStyleClass);
$this->SetDecorationClasses($sDecorationClasses);
$this->SetIcon($sIcon);
}
/**
* @see static::$sMainColor
* @return bool
*/
public function HasMainColor(): bool
{
return strlen($this->sMainColor) > 0;
}
/**
@@ -59,10 +68,19 @@ class ormStyle
*/
public function SetMainColor(?string $sMainColor)
{
$this->sMainColor = $sMainColor;
$this->sMainColor = (strlen($sMainColor) === 0) ? null : $sMainColor;
return $this;
}
/**
* @see static::$sComplementaryColor
* @return bool
*/
public function HasComplementaryColor(): bool
{
return strlen($this->sComplementaryColor) > 0;
}
/**
* @return string
*/
@@ -78,14 +96,33 @@ class ormStyle
*/
public function SetComplementaryColor(?string $sComplementaryColor)
{
$this->sComplementaryColor = $sComplementaryColor;
$this->sComplementaryColor = (strlen($sComplementaryColor) === 0) ? null : $sComplementaryColor;
return $this;
}
/**
* @see static::$sMainColor
* @see static::$sComplementaryColor
* @return bool
*/
public function HasAtLeastOneColor(): bool
{
return $this->HasMainColor() || $this->HasComplementaryColor();
}
/**
* @see static::$sStyleClass
* @return bool
*/
public function HasStyleClass(): bool
{
return strlen($this->sStyleClass) > 0;
}
/**
* @return string
*/
public function GetStyleClass(): string
public function GetStyleClass(): ?string
{
return $this->sStyleClass;
}
@@ -95,16 +132,25 @@ class ormStyle
*
* @return $this
*/
public function SetStyleClass(string $sStyleClass)
public function SetStyleClass(?string $sStyleClass)
{
$this->sStyleClass = $sStyleClass;
$this->sStyleClass = (strlen($sStyleClass) === 0) ? null : $sStyleClass;
return $this;
}
/**
* @see static::$sAltStyleClass
* @return bool
*/
public function HasAltStyleClass(): bool
{
return strlen($this->sAltStyleClass) > 0;
}
/**
* @return string
*/
public function GetAltStyleClass(): string
public function GetAltStyleClass(): ?string
{
return $this->sAltStyleClass;
}
@@ -114,12 +160,21 @@ class ormStyle
*
* @return $this
*/
public function SetAltStyleClass(string $sAltStyleClass)
public function SetAltStyleClass(?string $sAltStyleClass)
{
$this->sAltStyleClass = $sAltStyleClass;
$this->sAltStyleClass = (strlen($sAltStyleClass) === 0) ? null : $sAltStyleClass;
return $this;
}
/**
* @see static::$sDecorationClasses
* @return bool
*/
public function HasDecorationClasses(): bool
{
return strlen($this->sDecorationClasses) > 0;
}
/**
* @return string
*/
@@ -135,16 +190,17 @@ class ormStyle
*/
public function SetDecorationClasses(?string $sDecorationClasses)
{
$this->sDecorationClasses = $sDecorationClasses;
$this->sDecorationClasses = (strlen($sDecorationClasses) === 0) ? null : $sDecorationClasses;
return $this;
}
/**
* @return string
* @see static::$sIcon
* @return bool
*/
public function GetIcon(): ?string
public function HasIcon(): bool
{
return $this->sIcon;
return strlen($this->sIcon) > 0;
}
/**
@@ -154,8 +210,30 @@ class ormStyle
*/
public function SetIcon(?string $sIcon)
{
$this->sIcon = $sIcon;
$this->sIcon = (strlen($sIcon) === 0) ? null : $sIcon;
return $this;
}
/**
* @see static::$sIcon
* @return string|null Relative path (from the current environment) of the icon
*/
public function GetIconAsRelPath(): ?string
{
return $this->sIcon;
}
/**
* @see static::$sIcon
* @return string|null Absolute URL of the icon
* @throws \Exception
*/
public function GetIconAsAbsUrl(): ?string
{
if (is_null($this->sIcon)) {
return null;
}
return utils::GetAbsoluteUrlModulesRoot().$this->sIcon;
}
}

View File

@@ -16,6 +16,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSectionUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
use Combodo\iTop\Renderer\BlockRenderer;
define('CASELOG_VISIBLE_ITEMS', 2);
define('CASELOG_SEPARATOR', "\n".'========== %1$s : %2$s (%3$d) ============'."\n\n");
@@ -168,7 +174,6 @@ class ormCaseLog {
return $aEntries;
}
/**
* Returns a "plain text" version of the log (equivalent to $this->m_sLog) where all the HTML markup from the 'html' entries have been removed
* @return string
@@ -201,6 +206,15 @@ class ormCaseLog {
{
return ($this->m_sLog === null);
}
/**
* @return int The number of entries in this log
* @since 3.0.0
*/
public function GetEntryCount(): int
{
return count($this->m_aIndex);
}
public function ClearModifiedFlag()
{
@@ -389,7 +403,7 @@ class ormCaseLog {
{
$bPrintableVersion = (utils::ReadParam('printable', '0') == '1');
$sHtml = '<table style="width:100%;table-layout:fixed"><tr><td>'; // Use table-layout:fixed to force the with to be independent from the actual content
$oBlock = UIContentBlockUIBlockFactory::MakeStandard(null, ['ibo-caselog-list']);
$iPos = 0;
$aIndex = $this->m_aIndex;
if (($bEditMode) && (count($aIndex) > 0) && $this->m_bModified)
@@ -403,20 +417,16 @@ class ormCaseLog {
{
if (!$bPrintableVersion && ($index < count($aIndex) - CASELOG_VISIBLE_ITEMS))
{
$sOpen = '';
$sDisplay = 'style="display:none;"';
$bIsOpen = false;
}
else
{
$sOpen = ' open';
$sDisplay = '';
$bIsOpen = true;
}
$iPos += $aIndex[$index]['separator_length'];
$sTextEntry = substr($this->m_sLog, $iPos, $aIndex[$index]['text_length']);
$sCSSClass= 'caselog_entry_html';
if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == 'text'))
{
$sCSSClass= 'caselog_entry';
$sTextEntry = str_replace(array("\r\n", "\n", "\r"), "<br/>", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8'));
if (!is_null($aTransfoHandler))
{
@@ -433,7 +443,6 @@ class ormCaseLog {
}
$iPos += $aIndex[$index]['text_length'];
$sEntry = '<div class="caselog_header'.$sOpen.'">';
// Workaround: PHP < 5.3 cannot unserialize correctly DateTime objects,
// therefore we have changed the format. To preserve the compatibility with existing
// installations of iTop, both format are allowed:
@@ -456,14 +465,11 @@ class ormCaseLog {
$sDate = '';
}
}
$sEntry .= sprintf(Dict::S('UI:CaseLog:Header_Date_UserName'), $sDate, $aIndex[$index]['user_name']);
$sEntry .= '</div>';
$sEntry .= '<div class="'.$sCSSClass.'"'.$sDisplay.'>';
$sEntry .= $sTextEntry;
$sEntry .= '</div>';
$sHtml = $sHtml.$sEntry;
$oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( sprintf(Dict::S('UI:CaseLog:Header_Date_UserName'), $sDate, $aIndex[$index]['user_name']));
$oCollapsibleBlock->AddSubBlock(new Html($sTextEntry));
$oCollapsibleBlock->SetOpenedByDefault($bIsOpen);
$oBlock->AddSubBlock($oCollapsibleBlock);
}
// Process the case of an eventual remainder (quick migration of AttributeText fields)
if ($iPos < (strlen($this->m_sLog) - 1))
{
@@ -477,48 +483,84 @@ class ormCaseLog {
if (count($this->m_aIndex) == 0)
{
$sHtml .= '<div class="caselog_entry open">';
$sHtml .= $sTextEntry;
$sHtml .= '</div>';
$oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( '');
$oCollapsibleBlock->AddSubBlock(new Html($sTextEntry));
$oCollapsibleBlock->SetOpenedByDefault(true);
$oBlock->AddSubBlock($oCollapsibleBlock);
}
else
{
if (!$bPrintableVersion && (count($this->m_aIndex) - CASELOG_VISIBLE_ITEMS > 0))
{
$sOpen = '';
$sDisplay = 'style="display:none;"';
$bIsOpen = false;
}
else
{
$sOpen = ' open';
$sDisplay = '';
$bIsOpen = true;
}
$sHtml .= '<div class="caselog_header'.$sOpen.'">';
$sHtml .= Dict::S('UI:CaseLog:InitialValue');
$sHtml .= '</div>';
$sHtml .= '<div class="caselog_entry"'.$sDisplay.'>';
$sHtml .= $sTextEntry;
$sHtml .= '</div>';
$oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( Dict::S('UI:CaseLog:InitialValue'));
$oCollapsibleBlock->AddSubBlock(new Html($sTextEntry));
$oCollapsibleBlock->SetOpenedByDefault($bIsOpen);
}
}
$sHtml .= '</td></tr></table>';
return $sHtml;
$oBlockRenderer = new BlockRenderer($oBlock);
$sHtml = $oBlockRenderer->RenderHtml();
$sScript = $oBlockRenderer->RenderJsInlineRecursively($oBlock,iUIBlock::ENUM_JS_TYPE_ON_READY);
$aJsFiles = $oBlockRenderer->GetJsFiles();
if ($sScript!=''){
if ($oP == null) {
$sScript = '<script>'.$sScript.'</script>';
$sHtml .= $sScript;
} else {
$oP->add_ready_script($sScript);
}
}
// Ugly hack as we use a block and strip its content above, we'll also need JS files it depends on
if(count($aJsFiles) > 0){
foreach ($aJsFiles as $sFileAbsUrl) {
if ($oP === null) {
$sScript = '<script src="'.$sFileAbsUrl.'"></></script>';
$sHtml .= $sScript;
} else {
$oP->add_linked_script($sFileAbsUrl);
}
}
}
return $sHtml;
}
/**
* Add a new entry to the log or merge the given text into the currently modified entry
* Add a new entry to the log or merge the given text into the currently modified entry
* and updates the internal index
* @param $sText string The text of the new entry
*
* @param string $sText The text of the new entry
* @param string $sOnBehalfOf Display this name instead of current user name
* @param null|int $iOnBehalfOfId Use this UserId to author this Entry. If $sOnBehalfOf equals '', it'll be replaced by this User friendlyname
*
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
*
* @since 3.0.0 New $iOnBehalfOfId parameter
* @since 3.0.0 May throw \ArchivedObjectException exception
*/
public function AddLogEntry($sText, $sOnBehalfOf = '')
public function AddLogEntry(string $sText, $sOnBehalfOf = '', $iOnBehalfOfId = null)
{
$sText = HTMLSanitizer::Sanitize($sText);
$sDate = date(AttributeDateTime::GetInternalFormat());
if ($sOnBehalfOf == '')
{
if ($sOnBehalfOf == '' && $iOnBehalfOfId === null) {
$sOnBehalfOf = UserRights::GetUserFriendlyName();
$iUserId = UserRights::GetUserId();
}
elseif ($iOnBehalfOfId !== null) {
$iUserId = $iOnBehalfOfId;
/* @var User $oUser */
$oUser = MetaModel::GetObject('User', $iUserId, false, true);
if ($oUser !== null && $sOnBehalfOf === '') {
$sOnBehalfOf = $oUser->GetFriendlyName();
}
}
else
{
$iUserId = null;
@@ -553,7 +595,6 @@ class ormCaseLog {
$this->m_bModified = true;
}
public function AddLogEntryFromJSON($oJson, $bCheckUserId = true)
{
if (isset($oJson->user_id))
@@ -630,7 +671,6 @@ class ormCaseLog {
$this->m_bModified = true;
}
public function GetModifiedEntry($sFormat = 'text')
{
$sModifiedEntry = '';
@@ -709,4 +749,3 @@ class ormCaseLog {
return $sText;
}
}
?>

View File

@@ -118,7 +118,8 @@ class ormDocument
else
{
$data = $this->GetData();
$sResult = htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8').' [ '.$this->GetMimeType().', size: '.strlen($data).' byte(s) ]<br/>';
$sSize = utils::BytesToFriendlyFormat(strlen($data));
$sResult = htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8').' ('.$sSize.')<br/>';
}
return $sResult;
}

Some files were not shown because too many files have changed in this diff Show More