317 Commits

Author SHA1 Message Date
Mark Nelson
6a1ad7c677 MDL-65794 core: allow ajax calls to specify a cache key
This allows for better caching capabilities on servers. If a
cache key is passed and the web service call does not require
the user to be logged in we will attempt to use GET for the
request. This allows for things like proxy caching on URLs.
The cache key must be changed if we do not want to retrieve
what has been cached and want to perform the request again.
2019-07-16 14:23:34 +08:00
Damyon Wiese
7aeeb44463 MDL-34498 session: Add a checker to warn before session expiry
Replaces old yui module checknet.
2019-06-06 09:31:01 +08:00
Damyon Wiese
946281d282 MDL-56958 ajax: Prefer the general renderer 2016-11-15 12:44:59 +08:00
Russell Smith
1fcf0ca8a5 MDL-35628 performance: Remove dirname() where possible.
dirname() is a slow function compared with __DIR__ and using
'/../'.  Moodle has a large number of legacy files that are included
each time a page loads and is not able to use an autoloader as it is
functional code.  This allows those required includes to perform as
best as possible in this situation.
2016-06-10 08:06:49 +10:00
Frederic Massart
1d0140757a MDL-54034 ajax: Apply filters in ajax requests
This also clarified that developers can decide to force filters
to be ignored when using external_format_text, though they cannot
force filters to be turned on as the clients should be able to
opt-out from filtering should they want to.
2016-05-06 17:59:41 +08:00
Damyon Wiese
56fa860ead MDL-53772 externallib: Fix busted webservices context handling
Fix:
$PAGE->context must be reset when calling validate_context

Improve:
Provide wrapper for calling an external function

The wrapper correctly checks the function parameters and return type against
the description of the external function, and stores the PAGE and COURSE global
state variables, restoring them before the function returns.

Fix: buggy unit tests.

These tests are expecting debugging from a bug that was fixed, and calling web
service functions with no user or session.
2016-04-14 13:58:23 +08:00
Krista Koivisto
7b9fbb1cf4 MDL-52774 ajax: Require authentication when getting nav branch
When getting the navigation branch data through AJAX, require
login if forcelogin is set.
2016-03-08 00:39:45 +01:00
Frederic Massart
4879477632 MDL-51700 ajax: Clean the external function return values 2015-12-02 10:30:01 +08:00
Damyon Wiese
ad348cbdf9 MDL-50783 ajax: Add specific check for NO_MOODLE_COOKIES
If loginrequired is set for a webservice - NO_MOODLE_COOKIES cannot
be true - or it is a coding error.
2015-09-14 15:10:39 +08:00
Damyon Wiese
ba224fb42c MDL-50783 Ajax: Configure how to call a webservice through db/service.php
Now the db/service.php array can contain these extra keys to provide information
on how a webservice may be called:

    'ajax' => true (Default is false)

Replaces the xx_is_allowed_from_ajax callback.

    'loginrequired' => false (Default is true)

Means that this webservice can be called through lib/ajax/service-nosession.php
which sets NO_MOODLE_COOKIES to true (faster). This is only safe for webservices returning
static public data (e.g. get_string).
2015-09-14 15:10:21 +08:00
Damyon Wiese
5d8c198711 MDL-50782 Ajax: No require_login for all ajax webservice calls
Some webservice functions need to be available without a login, e.g.
fetching strings and templates.

External functions must call validate_context if they require a valid login etc.

Added a new parameter to services.php: "loginrequired". Default is true.
2015-09-08 09:16:58 +08:00
Frederic Massart
ad606e6514 MDL-47450 blocks: Blocks can be moved on the site profile 2015-08-07 15:08:47 +08:00
Andrew Nicols
2ed6be873b MDL-43785 lib: Improve session timeout warnings 2015-07-27 14:29:47 +08:00
Damyon Wiese
b0a583932a MDL-50784 ajax: Require a sesskey for all ajax requests.
This needs to be done before we can expose any webservices that
change state, or return private info to ajax (to prevent CSRF).

Currently there are no webservices exposed to ajax that meet these
criteria - so this issue is to prevent future security issues.
2015-07-13 16:49:06 +02:00
Mark Nelson
b3cb726431 MDL-49985 core_course: revert commit belonging to MDL-18309
This reverts commit 6601690202764d786a5ee4b7bbd9afb5b91dd0ec.

This commit was adding the 'returnurl' param unnecessarily to the
course links in the navigation block, causing a lot of long URLs
to be created.
2015-05-05 01:09:20 -07:00
Gregory Zbitnev
6601690202 MDL-18309 Course: enrol/index.php returnurl improvement
This patch improves usability of enrolment page in case of course is not
enrollable. 'Continue' button now returns student to referring page instead of
main moodle page (as it used to be). To make this improvement, passing correct
returnurl parameter to enrol/index.php page was implemented for links that may
be accessible for not-enrolled students.
2015-04-10 09:32:31 +08:00
Damyon Wiese
72f8324ec5 MDL-49163 Webservices, AJAX: Add support for a new ajax webservice handler.
This is a new script that can call any function in the built-in AJAX webservice. This is
a new system service that is added at install time (like the mobile webservice). It has no
protocols added to it, but it accessible by a new ajax script /lib/ajax/service.php.

Requests and responses to the script are required to be in json format, and multiple functions can
be called in a single request.
2015-03-12 15:07:08 +08:00
Valerii Kuznetsov
13b5a4942f MDL-48968 blocks: fixed bug with pagetype handling 2015-01-26 09:28:42 +13:00
Tim Hunt
5bcfd504df MDL-45618 Fix @since PHPdoc tags. 2014-05-19 17:03:04 +01:00
Sam Hemelryk
292dcf047f MDL-41551 blocks: added tracking and recognition of custom block regions 2014-04-06 15:17:47 +12:00
Andrew Nicols
1fa31fb376 MDL-44061 Ajax: Log whitespace issues to the server error log 2014-03-05 16:34:35 +08:00
Sam Hemelryk
2ef8ff9e05 MDL-44315 phpdoc: fixed up typos and made up tags 2014-02-24 09:13:31 +13:00
Andrew Nicols
af64bc6179 MDL-33099 Javascript: Deprecate the ajaxenabled function 2014-02-17 14:11:21 +08:00
Dan Poltawski
0eea6f5d99 Merge branch '43714-27' of git://github.com/samhemelryk/moodle 2014-01-21 14:49:26 +08:00
Sam Hemelryk
8496ddd7c6 MDL-43714 blocks: fixed coding style of ajax/blocks.php 2014-01-17 10:50:18 +13:00
Sam Hemelryk
efd556f77b MDL-43714 blocks: fixed notice when moving to an empty region 2014-01-17 10:45:23 +13:00
Sam Hemelryk
956e2e8a8c MDL-43675 navigation: courses branch is now recognised as expandable 2014-01-17 10:27:10 +13:00
Andrew Nicols
f2c780d525 MDL-34182 AJAX: Change to use shared method when checking the siteadminbranch for invalid output 2013-12-13 14:10:04 +08:00
Andrew Nicols
af736f903d MDL-34182: Add functions to warn of output in AJAX scripts
We need to be able to capture output when including contributed code as it
may add additional content which makes makes the json we output invalid.

We only warn of these errors if the site is in debugdeveloper, otherwise
we silently drop them.
2013-12-13 14:10:04 +08:00
Andrew Nicols
0bb56f2e31 MDL-42989 Admin: Clean output when building site administration tree for JS
Previously, any inappropriate whitespace found whilst building the admin
tree caused a JSON error and for the site administration tree retrieval to
fail.

This change ensures that access to the site administration tree is unbroken
for non-developers, whilst still alerting developers that there is an
issue.
2013-12-02 14:28:37 +08:00
Petr Škoda
d5814f4e22 MDL-41811 simplify the admin tree detection logic and fix navigation in multiple areas 2013-10-21 14:17:55 +08:00
Rajesh Taneja
5ab32c11b7 MDL-41811 navigation: Site admin will be loaded by ajax on non admin pages 2013-10-21 14:17:52 +08:00
Dan Poltawski
378b3eac83 MDL-36316 useragent: Reduce user agent sniffing
* core_useragent: Introduce is_vendor methods to improve readability
  when we are just detecting if a browser is from a vendor, rather than
  the exact version

* Remove uncessary browser version checks when we are just detecting
  vendors - this makes the intention of our sniffing clearer.

* Remove sniffing for browsers which we do not support, grades/ajax/tinymce
  all support modern browsers so there is no need to sniff for them.
2013-09-13 14:25:37 +08:00
Sam Hemelryk
c3d2fbf9cd MDL-40931 useragent: separated user agent functionality into a lib
This commit moves user agent related functionality out of several
core libraries and combines it into a more manageable class.
All core uses are converted and functions deprecated in favor
of the new class.
2013-08-26 13:59:19 +12:00
Damyon Wiese
9ead041cdb Revert "MDL-40931 useragent: separated user agent functionality into a lib"
This reverts commit af62237d0e6e27df868d50848f7098f57c103f86.
This reverts commit 87a4194fdcd322d4aee5a6207b55a8da0864da94.
This reverts commit b2c66eb60c01805f26cc791966f05be52af7b406.

Conflicts:

	version.php
2013-08-22 13:31:25 +08:00
Sam Hemelryk
87a4194fdc MDL-40931 useragent: converted useragent calls in ajaxenabled 2013-08-21 09:48:31 +10:00
Sam Hemelryk
af62237d0e MDL-40931 useragent: separated user agent functionality into a lib
This commit moves user agent related functionality out of several
core libraries and combines it into a more manageable class.
All core uses are converted and functions deprecated in favor
of the new class.
2013-08-16 09:02:01 +12:00
Petr Škoda
8252b7c291 MDL-40901 standardise core test case class and file names
This finally allows us to type only the class name when executing individual core test cases.
2013-08-04 22:10:31 +02:00
Marina Glancy
3b42c973d7 MDL-38631 link categories in My courses only when needed 2013-06-22 16:27:28 +10:00
Paul Nicholls
606554d5b0 MDL-32652 - Make block drag-drop work throughout Moodle
The central "content" region on My Home / user profile pages also needs to
be initialised in lib/ajax/blocks.php in order to allow blocks to be
dropped into that region successfully.  Some tweaks were also necessary in
order to correct the "content" region's structure in order for drag-drop
to function on this region on these pages.

Non-standard block regions (including the central "content" region
used by My Home and user profile pages) were causing the temporary empty
block region used as a drop target to sometimes appear in the wrong place.

The call to init_requirements_data (which includes the block drag-drop JS)
happens at a late enough stage in page generation that we can simply
pass the context ID through to the JS, so that it can be sent as part of
the AJAX request.  This prevents lib/ajax/blocks.php from having to try
to guess the context from the other bits of information it receives, so
block drag-drop should now work everywhere without issues.
2013-01-29 14:57:28 +13:00
Dan Poltawski
dec70f2599 Revert "MDL-32652 - Make block drag-drop work throughout Moodle"
This reverts commit d7c29c22572314680350ccdcf801f188aca541e4.
2013-01-25 11:52:15 +08:00
Paul Nicholls
d7c29c2257 MDL-32652 - Make block drag-drop work throughout Moodle
Other than shifting the initialisation from course/lib.php to
lib/outputrequirementslib.php, some workarounds/tweaks were required
in order to make it work correctly on admin pages and My Home.
2013-01-15 14:55:31 +13:00
Mark Nielsen
e893c6d442 MDL-36607: Improve block drag and drop
* Adding support for subpage
* Adding support for regions that do not start with "side-"
2012-12-10 14:12:57 +13:00
Sam Hemelryk
b9c87ef86a MDL-33017 navigation: Tidied up after peer-review 2012-11-07 09:52:47 +13:00
Sam Hemelryk
58b602da8e MDL-33017 navigation: added current course and simplified loading 2012-11-04 11:06:49 +13:00
Adrian Greeve
b0c6dc1cac MDL-34465 - lib - Replacing get_context_instance with context_XXXX::instance (group 8) 2012-07-27 10:10:46 +08:00
Dan Poltawski
cfed1268ef MDL-33990 - yui2: remove 2 uncessary requirements
We no longer use yui2 logger and connection in set_user_prefs
2012-06-25 14:42:00 +08:00
Dan Poltawski
a80b5a0cf0 MDL-32908 - drop $USER->ajax
Its not been respected for some time and is just confusing
2012-06-19 15:07:18 +08:00
Dan Poltawski
70b36b488b MDL-31263 lib/ajax/blocks.php fix nonsensical url 2012-04-26 11:03:05 +08:00
Eloy Lafuente (stronk7)
ee5855687e Merge branch 'MDL-31052-js-rewrite' of git://github.com/danpoltawski/moodle 2012-04-26 03:32:08 +02:00