Merge branch 'MDL-63210_34' of git://github.com/markn86/moodle into MOODLE_34_STABLE

This commit is contained in:
David Monllao
2018-08-27 11:47:07 +02:00
4 changed files with 12 additions and 7 deletions
+1
View File
@@ -186,6 +186,7 @@ $string['service'] = 'Service';
$string['servicehelpexplanation'] = 'A service is a set of functions. A service can be accessed by all users or just specified users.';
$string['servicename'] = 'Service name';
$string['servicenotavailable'] = 'Web service is not available (it doesn\'t exist or might be disabled)';
$string['servicerequireslogin'] = 'Web service is not available (the session has been logged out or has expired)';
$string['servicesbuiltin'] = 'Built-in services';
$string['servicescustom'] = 'Custom services';
$string['serviceusers'] = 'Authorised users';
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/config","core/log"],function(a,b,c){var d=!1,e=function(a){var b,c,d=this,e=null,f=0;if(a.error)for(;f<d.length;f++)b=d[f],b.deferred.reject(a);else{for(f=0;f<d.length;f++){if(b=d[f],c=a[f],"undefined"==typeof c){e=new Error("missing response");break}if(c.error!==!1){e=c.exception;break}b.deferred.resolve(c.data)}if(null!==e)for(;f<d.length;f++)b=d[f],b.deferred.reject(e)}},f=function(a,b,e){var f=this,g=0;for(g=0;g<f.length;g++){var h=f[g];d?(c.error("Page unloaded."),c.error(e)):h.deferred.reject(e)}};return{call:function(c,g,h){a(window).bind("beforeunload",function(){d=!0});var i,j=[],k=[],l=[],m="";for("undefined"==typeof h&&(h=!0),"undefined"==typeof g&&(g=!0),i=0;i<c.length;i++){var n=c[i];j.push({index:i,methodname:n.methodname,args:n.args}),n.deferred=a.Deferred(),k.push(n.deferred.promise()),"undefined"!=typeof n.done&&n.deferred.done(n.done),"undefined"!=typeof n.fail&&n.deferred.fail(n.fail),n.index=i,l.push(n.methodname)}m=l.length<=5?l.sort().join():l.length+"-method-calls",j=JSON.stringify(j);var o={type:"POST",data:j,context:c,dataType:"json",processData:!1,async:g,contentType:"application/json"},p="service.php";h||(p="service-nologin.php");var q=b.wwwroot+"/lib/ajax/"+p+"?sesskey="+b.sesskey+"&info="+m;return g?a.ajax(q,o).done(e).fail(f):(o.success=e,o.error=f,a.ajax(q,o)),k}}});
define(["jquery","core/config","core/log","core/url"],function(a,b,c,d){var e=!1,f=function(a){var b,c,e=this,f=null,g=0;if(a.error)for(;g<e.length;g++)b=e[g],b.deferred.reject(a);else{for(g=0;g<e.length;g++){if(b=e[g],c=a[g],"undefined"==typeof c){f=new Error("missing response");break}if(c.error!==!1){f=c.exception;break}b.deferred.resolve(c.data)}null!==f&&("servicerequireslogin"===f.errorcode?window.location=d.relativeUrl("/login/index.php"):e.forEach(function(a){a.deferred.reject(f)}))}},g=function(a,b,d){var f=this,g=0;for(g=0;g<f.length;g++){var h=f[g];e?(c.error("Page unloaded."),c.error(d)):h.deferred.reject(d)}};return{call:function(c,d,h){a(window).bind("beforeunload",function(){e=!0});var i,j=[],k=[],l=[],m="";for("undefined"==typeof h&&(h=!0),"undefined"==typeof d&&(d=!0),i=0;i<c.length;i++){var n=c[i];j.push({index:i,methodname:n.methodname,args:n.args}),n.deferred=a.Deferred(),k.push(n.deferred.promise()),"undefined"!=typeof n.done&&n.deferred.done(n.done),"undefined"!=typeof n.fail&&n.deferred.fail(n.fail),n.index=i,l.push(n.methodname)}m=l.length<=5?l.sort().join():l.length+"-method-calls",j=JSON.stringify(j);var o={type:"POST",data:j,context:c,dataType:"json",processData:!1,async:d,contentType:"application/json"},p="service.php";h||(p="service-nologin.php");var q=b.wwwroot+"/lib/ajax/"+p+"?sesskey="+b.sesskey+"&info="+m;return d?a.ajax(q,o).done(f).fail(g):(o.success=f,o.error=g,a.ajax(q,o)),k}}});
+8 -4
View File
@@ -25,7 +25,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/
define(['jquery', 'core/config', 'core/log'], function($, config, Log) {
define(['jquery', 'core/config', 'core/log', 'core/url'], function($, config, Log, URL) {
// Keeps track of when the user leaves the page so we know not to show an error.
var unloading = false;
@@ -79,9 +79,13 @@ define(['jquery', 'core/config', 'core/log'], function($, config, Log) {
}
// Something failed, reject the remaining promises.
if (exception !== null) {
for (; i < requests.length; i++) {
request = requests[i];
request.deferred.reject(exception);
// Redirect to the login page.
if (exception.errorcode === "servicerequireslogin") {
window.location = URL.relativeUrl("/login/index.php");
} else {
requests.forEach(function(request) {
request.deferred.reject(exception);
});
}
}
};
+2 -2
View File
@@ -208,10 +208,10 @@ class external_api {
// Do not allow access to write or delete webservices as a public user.
if ($externalfunctioninfo->loginrequired) {
if (defined('NO_MOODLE_COOKIES') && NO_MOODLE_COOKIES && !PHPUNIT_TEST) {
throw new moodle_exception('servicenotavailable', 'webservice');
throw new moodle_exception('servicerequireslogin', 'webservice');
}
if (!isloggedin()) {
throw new moodle_exception('servicenotavailable', 'webservice');
throw new moodle_exception('servicerequireslogin', 'webservice');
} else {
require_sesskey();
}