Skip to content

Commit 823532b

Browse files
authored
Merge pull request #710 from dpalou/MOBILE-1806
Mobile 1806
2 parents 816266e + d6ab4a0 commit 823532b

File tree

23 files changed

+260
-89
lines changed

23 files changed

+260
-89
lines changed

upgrade.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
This files describes API changes in the Moodle Mobile app,
22
information provided here is intended especially for developers.
33

4+
=== 3.2 ===
5+
6+
* Now the app supports auto-login with the site if it's a Moodle 3.2 or higher. The mm-link directive already handles it automatically, but it also includes a new attribute to force or disable auto-login in links. To manually open a link with auto-login you can use any of the new functions in $mmSite: openInBrowserWithAutoLogin, openInAppWithAutoLogin, ...
7+
48
=== 3.1.3 ===
59

610
* The module object received by addons in course contents no longer has the "contents" array in Moodle 2.9 or higher. Please use the new function $mmCourse#loadModuleContents to load the contents.

www/addons/grades/controllers/grade.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ angular.module('mm.addons.grades')
2121
* @ngdoc controller
2222
* @name mmaGradesGradeCtrl
2323
*/
24-
.controller('mmaGradesGradeCtrl', function($scope, $stateParams, $mmUtil, $mmaGrades, $mmSite, $mmaGradesHelper, $log,
25-
$mmContentLinksHelper) {
24+
.controller('mmaGradesGradeCtrl', function($scope, $stateParams, $mmUtil, $mmaGrades, $mmSite, $mmaGradesHelper, $log) {
2625

2726
$log = $log.getInstance('mmaGradesGradeCtrl');
2827

@@ -49,17 +48,6 @@ angular.module('mm.addons.grades')
4948
});
5049
};
5150

52-
$scope.gotoActivity = function() {
53-
if ($scope.grade.link) {
54-
$mmContentLinksHelper.handleLink($scope.grade.link).then(function(treated) {
55-
if (!treated) {
56-
$log.debug('Link not being handled ' + $scope.grade.link + ' opening in browser...');
57-
$mmUtil.openInBrowser($scope.grade.link);
58-
}
59-
});
60-
}
61-
};
62-
6351
$scope.refreshGrade = function() {
6452
$mmaGrades.invalidateGradesTableData(courseId, userId).finally(function() {
6553
fetchGrade().finally(function() {

www/addons/grades/templates/grade.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</ion-refresher>
66
<mm-loading hide-until="gradeLoaded">
77
<div ng-if="grade" class="card">
8-
<div ng-if="grade.itemname" class="item item-divider" ng-click="gotoActivity()">
8+
<a ng-if="grade.itemname" mm-link capture-link="true" class="item item-divider" href="{{ grade.link }}" title="{{ grade.itemname }}">
99
<h2><mm-format-text watch="true" class="mm-content-with-float">{{ grade.itemname }}</mm-format-text></h2>
10-
</div>
10+
</a>
1111

1212
<div ng-if="grade.weight" class="item item-text-wrap">
1313
<h2>{{ 'mma.grades.weight' | translate}}</h2>

www/addons/messages/services/handlers.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ angular.module('mm.addons.messages')
2323
* @ngdoc service
2424
* @name $mmaMessagesHandlers
2525
*/
26-
.factory('$mmaMessagesHandlers', function($log, $mmaMessages, $mmSite, $state, $mmUtil, $mmContentLinksHelper, $mmaMessagesSync) {
26+
.factory('$mmaMessagesHandlers', function($log, $mmaMessages, $mmSite, $state, $mmUtil, $mmContentLinksHelper, $mmaMessagesSync,
27+
$mmSitesManager) {
2728
$log = $log.getInstance('$mmaMessagesHandlers');
2829

2930
var self = {};
@@ -343,7 +344,12 @@ angular.module('mm.addons.messages')
343344
stateParams = {userId: parseInt(params.user1, 10)};
344345
} else {
345346
// He isn't, open in browser.
346-
$mmUtil.openInBrowser(url);
347+
var modal = $mmUtil.showModalLoading();
348+
$mmSitesManager.getSite(siteId).then(function(site) {
349+
return site.openInBrowserWithAutoLogin(url);
350+
}).finally(function() {
351+
modal.dismiss();
352+
});
347353
return;
348354
}
349355
} else if (typeof params.id != 'undefined') {

www/addons/mod/assign/templates/edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ion-view can-swipe-back="false">
22
<ion-nav-title><mm-format-text watch="true">{{ title }}</mm-format-text></ion-nav-title>
33
<ion-nav-buttons side="secondary">
4-
<a class="button button-clear" ng-click="save()" mm-link aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
4+
<a class="button button-clear" ng-click="save()" aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
55
</ion-nav-buttons>
66
<ion-content mm-state-class delegate-handle="mmaModAssignEditScroll">
77
<mm-loading hide-until="assignmentLoaded">

www/addons/mod/url/services/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ angular.module('mm.addons.mod_url')
5555
var modal = $mmUtil.showModalLoading();
5656
$mmContentLinksHelper.handleLink(url).then(function(treated) {
5757
if (!treated) {
58-
$mmUtil.openInBrowser(url);
58+
return $mmSite.openInBrowserWithAutoLoginIfSameSite(url);
5959
}
6060
}).finally(function() {
6161
modal.dismiss();

www/addons/mod/wiki/templates/edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ion-view can-swipe-back="false">
22
<ion-nav-title><mm-format-text watch="true">{{ title }}</mm-format-text></ion-nav-title>
33
<ion-nav-buttons side="secondary">
4-
<a class="button button-clear" ng-click="save()" mm-link aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
4+
<a class="button button-clear" ng-click="save()" aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
55
</ion-nav-buttons>
66
<ion-content padding="true" mm-state-class delegate-handle="mmaModWikiEditPage">
77
<mm-loading hide-until="wikiLoaded">

www/addons/mod/wiki/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ion-nav-title><mm-format-text watch="true">{{ title }}</mm-format-text></ion-nav-title>
33
<ion-nav-buttons side="secondary">
44
<button ng-if="subwikiData.count > 1" class="button button-icon ion-person-stalker" ng-click="showSubwikiPicker($event)" aria-label="{{ 'mma.mod_wiki.subwiki' | translate }}"></button>
5-
<a class="button button-icon ion-home" ng-if="showHomeButton" ng-click="goHomeWiki()" mm-link aria-label="{{ 'mma.mod_wiki.gowikihome' | translate }}"></a>
5+
<a class="button button-icon ion-home" ng-if="showHomeButton" ng-click="goHomeWiki()" aria-label="{{ 'mma.mod_wiki.gowikihome' | translate }}"></a>
66
<mm-context-menu>
77
<mm-context-menu-item priority="900" ng-if="moduleUrl" href="moduleUrl" content="'mm.core.openinbrowser' | translate" icon-action="'ion-share'"></mm-context-menu-item>
88
<mm-context-menu-item priority="800" ng-if="description" content="'mm.core.moduleintro' | translate" action="expandDescription()" icon-action="'ion-arrow-right-c'"></mm-context-menu-item>

www/core/components/contentlinks/services/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ angular.module('mm.core.contentlinks')
309309
gotoReview(url, params, courseId, siteId);
310310
} else {
311311
// Not current user and no gotoReview function specified, open it in browser.
312-
$mmUtil.openInBrowser(url);
312+
return site.openInBrowserWithAutoLogin(url);
313313
}
314314
}).finally(function() {
315315
modal.dismiss();

www/core/components/course/services/content_handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mm.core.course')
2121
* @ngdoc service
2222
* @name $mmCourseContentHandler
2323
*/
24-
.factory('$mmCourseContentHandler', function($mmCourse, $mmUtil) {
24+
.factory('$mmCourseContentHandler', function($mmCourse, $mmSite) {
2525
return {
2626
getController: function(module) {
2727
return function($scope, $state) {
@@ -40,9 +40,9 @@ angular.module('mm.core.course')
4040
icon: 'ion-share',
4141
label: 'mm.core.openinbrowser',
4242
action: function(e) {
43-
$mmUtil.openInBrowser(module.url);
4443
e.preventDefault();
4544
e.stopPropagation();
45+
$mmSite.openInBrowserWithAutoLoginIfSameSite(module.url);
4646
}
4747
}];
4848
}

0 commit comments

Comments
 (0)