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
4 changes: 4 additions & 0 deletions upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
This files describes API changes in the Moodle Mobile app,
information provided here is intended especially for developers.

=== 3.2 ===

* 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, ...

=== 3.1.3 ===

* 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.
Expand Down
14 changes: 1 addition & 13 deletions www/addons/grades/controllers/grade.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ angular.module('mm.addons.grades')
* @ngdoc controller
* @name mmaGradesGradeCtrl
*/
.controller('mmaGradesGradeCtrl', function($scope, $stateParams, $mmUtil, $mmaGrades, $mmSite, $mmaGradesHelper, $log,
$mmContentLinksHelper) {
.controller('mmaGradesGradeCtrl', function($scope, $stateParams, $mmUtil, $mmaGrades, $mmSite, $mmaGradesHelper, $log) {

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

Expand All @@ -49,17 +48,6 @@ angular.module('mm.addons.grades')
});
};

$scope.gotoActivity = function() {
if ($scope.grade.link) {
$mmContentLinksHelper.handleLink($scope.grade.link).then(function(treated) {
if (!treated) {
$log.debug('Link not being handled ' + $scope.grade.link + ' opening in browser...');
$mmUtil.openInBrowser($scope.grade.link);
}
});
}
};

$scope.refreshGrade = function() {
$mmaGrades.invalidateGradesTableData(courseId, userId).finally(function() {
fetchGrade().finally(function() {
Expand Down
4 changes: 2 additions & 2 deletions www/addons/grades/templates/grade.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</ion-refresher>
<mm-loading hide-until="gradeLoaded">
<div ng-if="grade" class="card">
<div ng-if="grade.itemname" class="item item-divider" ng-click="gotoActivity()">
<a ng-if="grade.itemname" mm-link capture-link="true" class="item item-divider" href="{{ grade.link }}" title="{{ grade.itemname }}">
<h2><mm-format-text watch="true" class="mm-content-with-float">{{ grade.itemname }}</mm-format-text></h2>
</div>
</a>

<div ng-if="grade.weight" class="item item-text-wrap">
<h2>{{ 'mma.grades.weight' | translate}}</h2>
Expand Down
10 changes: 8 additions & 2 deletions www/addons/messages/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ angular.module('mm.addons.messages')
* @ngdoc service
* @name $mmaMessagesHandlers
*/
.factory('$mmaMessagesHandlers', function($log, $mmaMessages, $mmSite, $state, $mmUtil, $mmContentLinksHelper, $mmaMessagesSync) {
.factory('$mmaMessagesHandlers', function($log, $mmaMessages, $mmSite, $state, $mmUtil, $mmContentLinksHelper, $mmaMessagesSync,
$mmSitesManager) {
$log = $log.getInstance('$mmaMessagesHandlers');

var self = {};
Expand Down Expand Up @@ -343,7 +344,12 @@ angular.module('mm.addons.messages')
stateParams = {userId: parseInt(params.user1, 10)};
} else {
// He isn't, open in browser.
$mmUtil.openInBrowser(url);
var modal = $mmUtil.showModalLoading();
$mmSitesManager.getSite(siteId).then(function(site) {
return site.openInBrowserWithAutoLogin(url);
}).finally(function() {
modal.dismiss();
});
return;
}
} else if (typeof params.id != 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/assign/templates/edit.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-view can-swipe-back="false">
<ion-nav-title><mm-format-text watch="true">{{ title }}</mm-format-text></ion-nav-title>
<ion-nav-buttons side="secondary">
<a class="button button-clear" ng-click="save()" mm-link aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
<a class="button button-clear" ng-click="save()" aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
</ion-nav-buttons>
<ion-content mm-state-class delegate-handle="mmaModAssignEditScroll">
<mm-loading hide-until="assignmentLoaded">
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/url/services/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ angular.module('mm.addons.mod_url')
var modal = $mmUtil.showModalLoading();
$mmContentLinksHelper.handleLink(url).then(function(treated) {
if (!treated) {
$mmUtil.openInBrowser(url);
return $mmSite.openInBrowserWithAutoLoginIfSameSite(url);
}
}).finally(function() {
modal.dismiss();
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/wiki/templates/edit.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-view can-swipe-back="false">
<ion-nav-title><mm-format-text watch="true">{{ title }}</mm-format-text></ion-nav-title>
<ion-nav-buttons side="secondary">
<a class="button button-clear" ng-click="save()" mm-link aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
<a class="button button-clear" ng-click="save()" aria-label="{{ 'mm.core.save' | translate }}"> {{ 'mm.core.save' | translate }}</a>
</ion-nav-buttons>
<ion-content padding="true" mm-state-class delegate-handle="mmaModWikiEditPage">
<mm-loading hide-until="wikiLoaded">
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/wiki/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ion-nav-title><mm-format-text watch="true">{{ title }}</mm-format-text></ion-nav-title>
<ion-nav-buttons side="secondary">
<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>
<a class="button button-icon ion-home" ng-if="showHomeButton" ng-click="goHomeWiki()" mm-link aria-label="{{ 'mma.mod_wiki.gowikihome' | translate }}"></a>
<a class="button button-icon ion-home" ng-if="showHomeButton" ng-click="goHomeWiki()" aria-label="{{ 'mma.mod_wiki.gowikihome' | translate }}"></a>
<mm-context-menu>
<mm-context-menu-item priority="900" ng-if="moduleUrl" href="moduleUrl" content="'mm.core.openinbrowser' | translate" icon-action="'ion-share'"></mm-context-menu-item>
<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>
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/contentlinks/services/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ angular.module('mm.core.contentlinks')
gotoReview(url, params, courseId, siteId);
} else {
// Not current user and no gotoReview function specified, open it in browser.
$mmUtil.openInBrowser(url);
return site.openInBrowserWithAutoLogin(url);
}
}).finally(function() {
modal.dismiss();
Expand Down
4 changes: 2 additions & 2 deletions www/core/components/course/services/content_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module('mm.core.course')
* @ngdoc service
* @name $mmCourseContentHandler
*/
.factory('$mmCourseContentHandler', function($mmCourse, $mmUtil) {
.factory('$mmCourseContentHandler', function($mmCourse, $mmSite) {
return {
getController: function(module) {
return function($scope, $state) {
Expand All @@ -40,9 +40,9 @@ angular.module('mm.core.course')
icon: 'ion-share',
label: 'mm.core.openinbrowser',
action: function(e) {
$mmUtil.openInBrowser(module.url);
e.preventDefault();
e.stopPropagation();
$mmSite.openInBrowserWithAutoLoginIfSameSite(module.url);
}
}];
}
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/courses/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ angular.module('mm.core.courses')
var body = $translate('mm.core.twoparagraphs',
{p1: error, p2: $translate.instant('mm.core.confirmopeninbrowser')});
$mmUtil.showConfirm(body).then(function() {
$mmUtil.openInBrowser(url);
$mmSite.openInBrowserWithAutoLogin(url);
});
return $q.reject();
});
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/login/controllers/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ angular.module('mm.core.login')

// Start the authentication process.
return $mmSitesManager.getUserToken(siteurl, username, password).then(function(data) {
return $mmSitesManager.newSite(data.siteurl, data.token).then(function() {
return $mmSitesManager.newSite(data.siteurl, data.token, data.privatetoken).then(function() {
delete $scope.credentials; // Delete username and password from the scope.
$ionicHistory.nextViewOptions({disableBack: true});

Expand Down
2 changes: 1 addition & 1 deletion www/core/components/login/controllers/reconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ angular.module('mm.core.login')

// Start the authentication process.
$mmSitesManager.getUserToken(siteurl, username, password).then(function(data) {
$mmSitesManager.updateSiteToken(infositeurl, username, data.token).then(function() {
$mmSitesManager.updateSiteToken(infositeurl, username, data.token, data.privatetoken).then(function() {
// Update site info too because functions might have changed (e.g. unisntall local_mobile).
$mmSitesManager.updateSiteInfoByUrl(infositeurl, username).finally(function() {
delete $scope.credentials; // Delete password from the scope.
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/login/controllers/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ angular.module('mm.core.login')
if (sitedata) {
// It's a demo site.
$mmSitesManager.getUserToken(sitedata.url, sitedata.username, sitedata.password).then(function(data) {
$mmSitesManager.newSite(data.siteurl, data.token).then(function() {
$mmSitesManager.newSite(data.siteurl, data.token, data.privatetoken).then(function() {
$ionicHistory.nextViewOptions({disableBack: true});
return $mmLoginHelper.goToSiteInitialPage();
}, function(error) {
Expand Down
4 changes: 2 additions & 2 deletions www/core/components/settings/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h2>{{appname}} {{versionname}}</h2>
</li>
<li class="item item-text-wrap">
<h2>Apache 2.0</h2>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0" mm-link>http://www.apache.org/licenses/LICENSE-2.0</a></p>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0" mm-link auto-login="no">http://www.apache.org/licenses/LICENSE-2.0</a></p>
</li>
<li class="item item-divider">
<p>{{ 'mm.settings.deviceinfo' | translate }}</p>
Expand All @@ -24,7 +24,7 @@ <h2>Apache 2.0</h2>
</li>
<li class="item item-text-wrap" ng-if="filesystemroot">
<p class="item-heading">{{ 'mm.settings.filesystemroot' | translate}}</p>
<a ng-if="fsclickable" ng-href="{{filesystemroot}}" mm-link>{{ filesystemroot }}</a>
<a ng-if="fsclickable" ng-href="{{filesystemroot}}" mm-link auto-login="no">{{ filesystemroot }}</a>
<p ng-if="!fsclickable">{{ filesystemroot }}</p>
</li>
<li class="item item-text-wrap" ng-if="navigator && navigator.userAgent">
Expand Down
4 changes: 2 additions & 2 deletions www/core/components/sidemenu/templates/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ <h2>{{siteinfo.fullname}}</h2>
</a>
</li>
<li>
<a menu-close class="item item-icon-left" ng-href="{{siteinfo.siteurl}}" mm-link title="{{ 'mm.sidemenu.website' | translate}}">
<a menu-close class="item item-icon-left" ng-href="{{siteinfo.siteurl}}" mm-link auto-login="yes" title="{{ 'mm.sidemenu.website' | translate}}">
<i class="icon ion-earth"></i>{{ 'mm.sidemenu.website' | translate}}
</a>
</li>
<li>
<a menu-close class="item item-icon-left" ng-href="{{docsurl}}" mm-link title="{{ 'mm.sidemenu.help' | translate}}">
<a menu-close class="item item-icon-left" ng-href="{{docsurl}}" mm-link auto-login="no" title="{{ 'mm.sidemenu.help' | translate}}">
<i class="icon ion-help-buoy"></i>{{ 'mm.sidemenu.help' | translate}}
</a>
</li>
Expand Down
10 changes: 5 additions & 5 deletions www/core/components/user/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ <h2>{{ 'mm.user.contact' | translate}}</h2>
<div class="item" ng-if="user.email">
<p class="item-heading">{{ 'mm.user.email' | translate}}</p>
<p>
<a href="mailto:{{user.email}}" mm-link>
<a href="mailto:{{user.email}}" mm-link auto-login="no">
<mm-format-text watch="true" clean="true">{{user.email}}</mm-format-text>
</a>
</p>
</div>
<div class="item" ng-if="user.phone1">
<p class="item-heading">{{ 'mm.user.phone1' | translate}}</p>
<p>
<a href="tel:{{user.phone1}}" mm-link>
<a href="tel:{{user.phone1}}" mm-link auto-login="no">
<mm-format-text watch="true" clean="true">{{user.phone1}}</mm-format-text>
</a>
</p>
</div>
<div class="item" ng-if="user.phone2">
<p class="item-heading">{{ 'mm.user.phone2' | translate}}</p>
<p>
<a href="tel:{{user.phone2}}" mm-link>
<a href="tel:{{user.phone2}}" mm-link auto-login="no">
<mm-format-text watch="true" clean="true">{{user.phone2}}</mm-format-text>
</a>
</p>
</div>
<div class="item" ng-if="user.address">
<p class="item-heading">{{ 'mm.user.address' | translate}}</p>
<p>
<a ng-if="isAndroid" href="geo:0,0?q={{user.encodedAddress}}" mm-link>
<a ng-if="isAndroid" href="geo:0,0?q={{user.encodedAddress}}" mm-link auto-login="no">
<mm-format-text watch="true" clean="true">{{user.address}}</mm-format-text>
</a>
<a ng-if="!isAndroid" href="http://maps.google.com?q={{user.encodedAddress}}" mm-link>
<a ng-if="!isAndroid" href="http://maps.google.com?q={{user.encodedAddress}}" mm-link auto-login="no">
<mm-format-text watch="true" clean="true">{{user.address}}</mm-format-text>
</a>
</p>
Expand Down
3 changes: 3 additions & 0 deletions www/core/directives/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ angular.module('mm.core')
* @param {Function} [action] Javascript action to be taken on click. Only works if iconAction is set and is not an spinner.
* @param {String} [href] Link to go if no action provided.
* @param {Boolean} [captureLink=false] If the link needs to be captured by the app.
* @param {Boolean} [autoLogin=check] If the link needs to be opened using auto-login. See mmLink.
* @param {Boolean} [closeOnClick=true] If close the popover when clicked. Only works if action or href is provided.
* @param {Boolean} [closeWhenDone=false] Close popover when action is done. Only if action is supplied and closeOnClick=false.
* @param {Number} [priority] Used to sort items. The highest priority, the highest position.
Expand Down Expand Up @@ -226,6 +227,7 @@ angular.module('mm.core')
action: '&?',
href: '=?',
captureLink: '=?',
autoLogin: '=?',
closeOnClick: '=?',
closeWhenDone: '=?',
priority: '=?',
Expand All @@ -248,6 +250,7 @@ angular.module('mm.core')

// Navigation help if href provided.
scope.captureLink = scope.href && scope.captureLink ? scope.captureLink : "false";
scope.autoLogin = scope.autoLogin || 'check';

if (CtxtMenuCtrl.shouldMerge() && $ionicPlatform.isTablet()) {
// Item should be merged with an outer context-menu in tablet view.
Expand Down
14 changes: 11 additions & 3 deletions www/core/directives/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ angular.module('mm.core')
* @param {Mixed} [width=100%] Width of the iframe. If not defined, use 100%.
* @param {Mixed} [height=100%] Height of the iframe. If not defined, use 100%.
*/
.directive('mmIframe', function($mmUtil, $mmText) {
.directive('mmIframe', function($mmUtil, $mmText, $mmSite) {

var errorShownTime = 0,
tags = ['iframe', 'frame', 'object', 'embed'];
Expand Down Expand Up @@ -130,7 +130,11 @@ angular.module('mm.core')
// If the link's already prevented by SCORM JS then we won't open it in browser.
if (!e.defaultPrevented) {
e.preventDefault();
$mmUtil.openInBrowser(href);
if (!$mmSite.isLoggedIn()) {
$mmUtil.openInBrowser(href);
} else {
$mmSite.openInBrowserWithAutoLoginIfSameSite(href);
}
}
});
} else if (el.target == '_parent' || el.target == '_top' || el.target == '_blank') {
Expand All @@ -139,7 +143,11 @@ angular.module('mm.core')
// If the link's already prevented by SCORM JS then we won't open it in InAppBrowser.
if (!e.defaultPrevented) {
e.preventDefault();
$mmUtil.openInApp(href);
if (!$mmSite.isLoggedIn()) {
$mmUtil.openInApp(href);
} else {
$mmSite.openInAppWithAutoLoginIfSameSite(href);
}
}
});
} else if (ionic.Platform.isIOS() && (!el.target || el.target == '_self')) {
Expand Down
Loading