563 Commits

Author SHA1 Message Date
Andrew Nicols
3d51aed3e2
MDL-81521 core: Update all possibly data providers to be static
Note: Some data providers could not be automatically be converted to
being static. These will be handled in a separate issue.
2024-11-19 09:30:51 +08:00
Andrew Nicols
b4eb274d7a
Merge branch 'MDL-77799-m401' of https://github.com/sammarshallou/moodle into MOODLE_401_STABLE 2023-06-08 11:21:35 +08:00
sam marshall
0c3b3c9b92 MDL-77799 webservice_rest: unhandled exception should go in server log 2023-06-07 10:04:07 +01:00
Paul Holden
a22aabb29f
MDL-78352 webservice: use default user context page heading. 2023-05-26 12:27:46 +01:00
Ilya Tregubov
5c96f74a06 Merge branch 'MDL-74853-401' of https://github.com/marinaglancy/moodle into MOODLE_401_STABLE 2022-12-01 08:59:06 +03:00
Marina Glancy
a5f92c041e MDL-74853 various: add second parameter to htmlentities functions
Default value of the $flag argument changed in PHP 8.1 from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE
To ensure consistent behavior across different PHP version the second parameter is now required for the functions:
htmlspecialchars(), htmlentities(), htmlspecialchars_decode(), html_entity_decode() and get_html_translation_table()
2022-11-28 16:12:32 +01:00
Paul Holden
fac0c27efb MDL-76284 webservice: early exit if no users for missing capabilities. 2022-11-28 11:53:23 +00:00
Jun Pataleta
00bae8b8a4 MDL-76403 versions: bump all versions and requires near release 2022-11-23 09:45:23 +08:00
Eloy Lafuente (stronk7)
e7d3e042fc MDL-76052 webservice_xmlrpc: Annotate some wrong plugin uses
It has been detected that there are various uses of the plugins
breaking the inter-communication principles, with core_webservice
implementing functionality plugin-dependent that should belong
to the plugins.

Because of that, https://tracker.moodle.org/browse/MDL-76078 has
been created and we have added some TODO/@todo comments in core
pointing to that issue, for further analysis and fixes there.
2022-11-04 16:49:57 +01:00
Eloy Lafuente (stronk7)
df227f3819 MDL-76052 webservice_xmlrpc: Remove it completely from core
Normal removal procedure:
  - Remove the plugin completely from core.
  - Document it in the webservices upgrade.txt file.
  - Add a core upgrade step to proceed to remove any configuration
    if the plugin has not been re-installed manually.

Plus:
  - Remove a few remaining uses in the hub/sites registration scripts,
    that were moved from xmlrpc to hand.made rest calls by MDL-31436
    (Moodle 3.4.1 and up) and never removed then.
  - Remove the php-xmlrpc extension as a recommendation in composer.
  - Remove "xmlrpc" from various comments, trivial cleanup.

Note:
  - While working on this MDL-76078 has been created about to
    fix a serious design problem detected (it does not affect
    functionality). That's out from this issue scope.
2022-11-04 16:49:52 +01:00
Víctor Déniz
ad3ba9d0b7 Merge branch 'MDL-74827-master' of https://github.com/rmady/moodle 2022-07-21 00:12:23 +01:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
Rodrigo Mady da Silva
892047d3c8 MDL-74827 core_webservice: Add enablecustomreports in WS get_site_info 2022-06-23 12:00:43 -03:00
Marina Glancy
e3bd0f7348 MDL-29717 core_webservice: Display deprecated badge in API docs 2022-06-03 16:17:47 +02:00
Dmitrii Metelkin
a6cad23b1a MDL-73431 enrol: Introduce a sync interval 2022-05-30 15:58:22 +10:00
Eloy Lafuente (stronk7)
caf55abf17 MDL-74413 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- Moved to the level2 "privacy" namespace:
  - \mod_assign\privacy\feedback_legacy_polyfill_test
  - \mod_assign\privacy\submission_legacy_polyfill_test

- Moved to the level2 "task" namespace:
  - \core_message\task\migrate_message_data_test
  - \ltiservice_gradebookservices\task\cleanup_test
  - \message_email\task\send_email_test
  - \mod_lti\task\clean_access_tokens_test
  - \mod_workshop\task\cron_task_test

- Moved to the level2 "event" namespace:
  - \core_h5p\event\deleted_test
  - \core_h5p\event\viewed_test

- Renamed to a better name:
  - backup_forum_activity_task_test.php (missing "task")
2022-05-07 20:32:30 +02:00
Jun Pataleta
70f6b1605b MDL-74471 versions: bump all versions and requires near release 2022-04-13 10:37:36 +08:00
Paul Holden
17dd5bbae0 MDL-74202 webservice: fix protocol type in exception message. 2022-03-25 09:53:23 +00:00
Eloy Lafuente (stronk7)
100bc51f1d MDL-73485 phpunit: externallib, generator and filter tescase names
All externallib_test, generator_test and filter_test classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to tests under testing/tests:

1) The core_testing component doesn't exist.
2) But testing/tests are allowed because there is a suite pointing to it (phpunit.xml).
3) So, the only possible namespace for them is "core".
4) And to avoid problems with other core testcases (under lib/tests)
   they have been renamed to have testing_xxxx as prefix.

Finally, also modified calendar/tests/events/events_test.php because it uses
some renamed (core_calendar_externallib_testcase => \core_calendar\externallib_test)
classes.
2022-01-21 19:48:23 +01:00
Sara Arjona
6ed6520d86 Merge branch 'MDL-73603' of https://github.com/paulholden/moodle 2022-01-20 17:23:42 +01:00
Paul Holden
b385e0da5e MDL-73603 webservice: fix user retrieval in token form callback. 2022-01-17 21:51:39 +00:00
Eloy Lafuente (stronk7)
0c53a3dec8 MDL-73476 phpunit: events, external and search tescase names
All events_test, external_test and search_test classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to lib/external/tests/external_test.php:
- external is not a valid component
- hence, its only valid namespace is "core"
- also, it's testing lib/external/externallib.php
- hence, the file (and class) have been renamed to external_externallib_test.php
  (to avoid conflicts with other external_test that may exist in core)
2022-01-14 16:18:39 +01:00
Andrew Nicols
6c2a64dca1 Merge branch 'MDL-73575' of https://github.com/paulholden/moodle 2022-01-14 09:36:04 +08:00
Paul Holden
ef871e28b5 MDL-73575 webservice: ensure configured protocols are non-empty. 2022-01-13 12:21:29 +00:00
Marina Glancy
6f6586b164 MDL-73564 webservice: make sure to require webservice lib once 2022-01-12 13:19:58 +01:00
Eloy Lafuente (stronk7)
511801cb46 MDL-73352 phpunit: lib_test and locallib_test testcase names
All lib_test and locallib_test classes:

- Namespaced with component (and API whenever makes sense).
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed or add new uses.
- All them passing individually.
- Complete runs passing too.

Special mention to tests under login/tests:

1) The core_login component doesn't exist.
2) But login/tests are allowed because there is a suite pointing to it (phpunit.xml).
3) So, the only possible namespace for them is "core".
4) And to avoid problems with other core testcases (under lib/tests)
   they have been renamed to have login_xxxx as prefix.
2021-12-30 16:21:42 +01:00
Paul Holden
d4bd398ad7 MDL-73295 webservice: only pass around sesskey for tokens as needed. 2021-12-29 09:54:23 +00:00
Eloy Lafuente (stronk7)
e4a2d9c1d4 MDL-73348 phpunit: normalize all privacy provider tests
As far as now all them have correct privacy level2 namespace:
- Move them to "privacy" subdir.
- Rename the files to "provider_test.php", this includes old
  privacy_test.php and privacy_provider_test.php files
- Rename the testcase to provider_test too (to match file name)

Also, change some relative paths and comments to point to new
locations.
2021-12-17 14:21:02 +01:00
Eloy Lafuente (stronk7)
57e6fb7ad9 MDL-73348 phpunit: privacy and privacy_provider testcase names
All privacy_test and privacy_provider_test classes:

- Namespaced with component\privacy.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Renamed a few files to make all be privacy_test or privacy_provider_test.php
- All them passing individually.
- Complete runs passing too.
2021-12-17 14:21:02 +01:00
Jun Pataleta
019df14c00 Merge branch 'MDL-67807-master' of git://github.com/jleyva/moodle 2021-12-03 12:24:42 +08:00
Juan Leyva
a5c48fe780 MDL-67804 webservice: Fix exception class to allow clients treat errors 2021-11-23 16:59:21 +01:00
Juan Leyva
c7e7229ccd MDL-67807 webservice: Return concurrent sessions information 2021-11-19 14:03:37 +01:00
Eloy Lafuente (stronk7)
fdc2dcf264 MDL-72871 cleanup: Remove incorrect whitespace from codebase
Differences can be checked with git diff --ignore-all-space and
that will show that the only non-whitespace change is in a test
in the git lib/tests/html2text_test.php file. In that case the
whitespace has been replaced by a quoted string (of whitespaces)
keeping the test 100% equivalent and workarrounding the whitespace.
2021-10-26 17:19:11 +02:00
Paul Holden
797cff78d5 MDL-72464 webservice: fix detection of non-expiring external tokens. 2021-10-10 20:40:14 +01:00
Paul Holden
7d177640b0 MDL-71760 admin: escape identity fields in token management table. 2021-07-08 23:30:33 +02:00
Eloy Lafuente (stronk7)
9d6aa39985 MDL-71583 versions: Add all the missing full-stops to version/requires
It seems that the new phpcs3 checker is now controlling those
line comments that previously were ignored.

This commit just looks for all the cases and bulk-add
them when needed. The bash script (mac) used to add all them is:

while read -r line; do
    arr=(${line//:/ })
    if [[ -n ${arr[0]} ]] && [[ -n ${arr[1]} ]]; then
        echo "  file ${arr[0]}, line ${arr[1]}"
        sed -i "${arr[1]}s/\$/\./" ${arr[0]}
    fi
done < <(find . -name version.php | xargs ag --nomultiline '>(version|requires) *=.*//.*[^;\.]$')
2021-05-11 20:11:07 +02:00
sam marshall
611e2569aa MDL-71215 core_user: User fields - remaining deprecated functions
This change removes references in code and comments to a few
deprecated functions that were accidentally missed in the larger
change.

The code changes only affect service_users.php. I made it support
custom user profile fields in this query, because it was easy
enough, rather than adding another TODO to fix later.
2021-03-31 11:12:16 +01:00
sam marshall
5e72715e4f MDL-71099 Lib: Move new user_fields class from core to core_user
This class would belong more appropriately within the 'user' API
(core_user) instead of within the 'core' API, since it is
directly related to user data.

Since the class has only just been added to Moodle, now is a good
time to move it.
2021-03-25 13:47:23 +00:00
Jun Pataleta
ebf078458d Merge branch 'MDL-71036' of https://github.com/stronk7/moodle 2021-03-17 20:05:25 +08:00
David Mudrák
4a9f864969 MDL-67748 admin: Add Behat tests for tokens filtering features
Credit goes to Andrew for Behat data generators for webservices.

Co-authored-by: Andrew Nicols <andrew@nicols.co.uk>
2021-03-16 10:51:39 +01:00
David Mudrák
b0fd376db3 MDL-67748 admin: Do not show missing capabilities for mobile app service
We used to display capabilities like "Manage any calendar entries",
"Delete evidence", "Manage competency frameworks", "View hidden courses"
and others as "Missing capabilities" for the mobile app service tokens.

This gave dangerous impression that the app will not work for students
without these capabilities granted. There are known cases of admins who
started to grant all these caps to the Authenticated user role because
they were afraid the app would not work for them.

The problem here is that the official mobile app service includes some
functions that have these capabilities declared as required. But they
are not really required to use the app. Either the app makes its own
clever checks of capabilities before calling the functions, or sometimes
the capabilities are not even correctly declared.

It is safer for everybody to display this information for custom
services only where the risk of the falsely missing caps is lower and
the information is more accurate.

Also, the help text has been improved so it does not suggest that these
capabilities must be always added. We do not know why the service has
them declared. In some cases, a service has capabilities declared just
because it makes use of them in the if-then fashion.

Additionally, the patch also displays the service short name because it
is actually needed to know.
2021-03-15 21:24:06 +01:00
David Mudrák
6ea3588d82 MDL-67748 admin: Show user identity fields on the manage tokens page
On sites with many users, the fullname itself may not be unique
identifier of users. Display the user identity fields below the token
owner's name.
2021-03-15 21:24:06 +01:00
David Mudrák
c4ad1bf2f6 MDL-67748 admin: Add filter to the WS tokens management page
The patch adds ability to filter the list of token by the token value,
the user and the service. Also the button to create a new token is made
more prominent and easier to spot.
2021-03-15 21:24:06 +01:00
David Mudrák
bcd8692fef MDL-67748 admin: Improve the display of tokens the user cannot see 2021-03-15 21:24:06 +01:00
David Mudrák
2c177ae4c1 MDL-67748 admin: Refactor tokens management as an external page
No need to have a dedicated admin_setting_managewebservicetokens admin
setting subclass, and yet do not use almost any of its features. So the
patch merges the list and the forms handling into a single external
page.

Similarly, it feels like overkill to have a renderer method for a
simple confirmation widget - especially given that the URLs were
hard-coded in it. So that one was dropped.
2021-03-15 21:24:06 +01:00
David Mudrák
596b0bb23e MDL-67748 admin: Improve the display of missing capabilities
The patch improves the display of the missing capabilities on the Manage
tokens page and the Select authorised users page. The list of
capabilities is rendered in a collapsible area and does not occupy too
much space by default.

Additionally on the later page, the patch improves the display of the
list of existing authorised users so that it respects the configured
identity fields.
2021-03-15 21:24:06 +01:00
David Mudrák
c07f15d791 MDL-67748 admin: Improve get_missing_capabilities_by_users()
The previous implementation falsely reported all implicit capabilities
inherited from the authenticated user archetype. That caused a lot of
capabilities reported as missing, even if they were correctly granted.

This new implementation uses a different logic. Instead of seeking for
explicitly assigned capabilities, it searches for capabilities that are
not assigned to any of the user's role across the system.

Please refer to the inline documentation. This should be still used for
informative reports only, not for actual permissions evaluation. The
context has been ignored here, as well as all the overrides etc. This
patch just makes it a lesser evil.
2021-03-15 21:24:06 +01:00
David Mudrák
0bcaab32ad MDL-67748 admin: Simplify the webservice token form
We can now use the autocomplete element to select the user. No need to
for the legacy behaviour.
2021-03-15 21:24:05 +01:00
David Mudrák
a7f6934297 MDL-67748 admin: Respect the viewfullnames cap at manage tokens table 2021-03-15 21:24:05 +01:00
David Mudrák
db723ad066 MDL-67748 admin: Move the web service token form to its own file 2021-03-15 21:21:43 +01:00