Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion www/addons/grades/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ angular.module('mm.addons.grades')
*/
self.getActions = function(siteIds, url) {
// Check it's a grade URL.
if (url.indexOf('/grade/report/user/index.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
var params = $mmUtil.extractUrlParams(url);
if (typeof params.id != 'undefined') {
var courseId = parseInt(params.id, 10);
Expand Down Expand Up @@ -220,6 +220,19 @@ angular.module('mm.addons.grades')
return [];
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/grade/report/user/index.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/messages/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ angular.module('mm.addons.messages')
*/
self.getActions = function(siteIds, url) {
// Check it's a messages URL.
if (url.indexOf('/message/index.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
// Pass false because all sites should have the same siteurl.
return $mmContentLinksHelper.filterSupportedSites(siteIds, isEnabledForSite, false).then(function(ids) {
if (!ids.length) {
Expand Down Expand Up @@ -364,6 +364,19 @@ angular.module('mm.addons.messages')
return [];
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/message/index.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_assign/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,25 @@ angular.module('mm.addons.mod_assign')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's an assign URL.
if (url.indexOf('/mod/assign/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/assign/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_book/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,25 @@ angular.module('mm.addons.mod_book')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a book URL.
if (url.indexOf('/mod/book/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/book/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_chat/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,25 @@ angular.module('mm.addons.mod_chat')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a chat URL.
if (url.indexOf('/mod/chat/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/chat/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_choice/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,25 @@ angular.module('mm.addons.mod_choice')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a choice URL.
if (url.indexOf('/mod/choice/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/choice/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_folder/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,25 @@ angular.module('mm.addons.mod_folder')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a folder URL.
if (url.indexOf('/mod/folder/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/folder/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
25 changes: 22 additions & 3 deletions www/addons/mod_forum/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ angular.module('mm.addons.mod_forum')
*/
self.linksHandler = function() {

var self = {};
var self = {},
patterns = ['/mod/forum/view.php', '/mod/forum/discuss.php'];

/**
* Whether or not the handler is enabled for a certain site.
Expand Down Expand Up @@ -122,13 +123,16 @@ angular.module('mm.addons.mod_forum')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a forum URL.
if (url.indexOf('/mod/forum/view.php') > -1) {
if (url.indexOf(patterns[0]) > -1) {
// Forum index.
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isIndexEnabled, courseId);
} else if (url.indexOf('/mod/forum/discuss.php') > -1) {
} else if (url.indexOf(patterns[1]) > -1) {
// Forum discussion.
var params = $mmUtil.extractUrlParams(url);
if (params.d != 'undefined') {
// If courseId is not set we check if it's set in the URL as a param.
courseId = courseId || params.courseid || params.cid;

// Pass false because all sites should have the same siteurl.
return $mmContentLinksHelper.filterSupportedSites(siteIds, isDiscEnabled, false, courseId).then(function(ids) {
if (!ids.length) {
Expand All @@ -154,6 +158,21 @@ angular.module('mm.addons.mod_forum')
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
for (var i = 0; i < patterns.length; i++) {
var position = url.indexOf(patterns[i]);
if (position > -1) {
return url.substr(0, position);
}
}
};

return self;
};

Expand Down
25 changes: 22 additions & 3 deletions www/addons/mod_glossary/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ angular.module('mm.addons.mod_glossary')
*/
self.linksHandler = function() {

var self = {};
var self = {},
patterns = ['/mod/glossary/view.php', '/mod/glossary/showentry.php'];

/**
* Whether or not the handler is enabled to see glossary index for a certain site.
Expand Down Expand Up @@ -136,6 +137,9 @@ angular.module('mm.addons.mod_glossary')
function treatEntryLink(siteIds, url, courseId) {
var params = $mmUtil.extractUrlParams(url);
if (params.eid != 'undefined') {
// If courseId is not set we check if it's set in the URL as a param.
courseId = courseId || params.courseid || params.cid;

// Pass false because all sites should have the same siteurl.
return $mmContentLinksHelper.filterSupportedSites(siteIds, isEntryEnabled, false, courseId).then(function(ids) {
if (!ids.length) {
Expand Down Expand Up @@ -183,16 +187,31 @@ angular.module('mm.addons.mod_glossary')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a glossary URL.
if (url.indexOf('/mod/glossary/view.php') > -1) {
if (url.indexOf(patterns[0]) > -1) {
// Glossary index.
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isIndexEnabled, courseId);
} else if (url.indexOf('/mod/glossary/showentry.php') > -1) {
} else if (url.indexOf(patterns[1]) > -1) {
// Glossary entry.
return treatEntryLink(siteIds, url, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
for (var i = 0; i < patterns.length; i++) {
var position = url.indexOf(patterns[i]);
if (position > -1) {
return url.substr(0, position);
}
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_imscp/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,25 @@ angular.module('mm.addons.mod_imscp')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's an IMSCP URL.
if (url.indexOf('/mod/imscp/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/imscp/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_label/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,25 @@ angular.module('mm.addons.mod_label')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a label URL.
if (url.indexOf('/mod/label/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/label/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
15 changes: 14 additions & 1 deletion www/addons/mod_lti/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,25 @@ angular.module('mm.addons.mod_lti')
*/
self.getActions = function(siteIds, url, courseId) {
// Check it's a LTI URL.
if (url.indexOf('/mod/lti/view.php') > -1) {
if (typeof self.handles(url) != 'undefined') {
return $mmContentLinksHelper.treatModuleIndexUrl(siteIds, url, isEnabled, courseId);
}
return $q.when([]);
};

/**
* Check if the URL is handled by this handler. If so, returns the URL of the site.
*
* @param {String} url URL to check.
* @return {String} Site URL. Undefined if the URL doesn't belong to this handler.
*/
self.handles = function(url) {
var position = url.indexOf('/mod/lti/view.php');
if (position > -1) {
return url.substr(0, position);
}
};

return self;
};

Expand Down
Loading