File tree Expand file tree Collapse file tree 4 files changed +39
-10
lines changed Expand file tree Collapse file tree 4 files changed +39
-10
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,15 @@ angular.module('mm.addons.files')
2727 $scope . canDownload = $mmSite . canDownloadFiles ;
2828
2929 $scope . add = function ( ) {
30- if ( ! $mmApp . isOnline ( ) ) {
31- $mmUtil . showErrorModal ( 'mma.files.errormustbeonlinetoupload' , true ) ;
32- } else {
33- $state . go ( 'site.files-upload' ) ;
34- }
30+ $mmaFiles . versionCanUploadFiles ( ) . then ( function ( canUpload ) {
31+ if ( ! canUpload ) {
32+ $mmUtil . showErrorModal ( 'mma.files.erroruploadnotworking' , true ) ;
33+ } else if ( ! $mmApp . isOnline ( ) ) {
34+ $mmUtil . showErrorModal ( 'mma.files.errormustbeonlinetoupload' , true ) ;
35+ } else {
36+ $state . go ( 'site.files-upload' ) ;
37+ }
38+ } ) ;
3539 } ;
3640
3741} ) ;
Original file line number Diff line number Diff line change @@ -84,10 +84,14 @@ angular.module('mm.addons.files')
8484
8585 // When we are in the root of the private files we can add more files.
8686 $scope . add = function ( ) {
87- if ( ! $mmApp . isOnline ( ) ) {
88- $mmUtil . showErrorModal ( 'mma.files.errormustbeonlinetoupload' , true ) ;
89- } else {
90- $state . go ( 'site.files-upload' , { root : root , path : path } ) ;
91- }
87+ $mmaFiles . versionCanUploadFiles ( ) . then ( function ( canUpload ) {
88+ if ( ! canUpload ) {
89+ $mmUtil . showErrorModal ( 'mma.files.erroruploadnotworking' , true ) ;
90+ } else if ( ! $mmApp . isOnline ( ) ) {
91+ $mmUtil . showErrorModal ( 'mma.files.errormustbeonlinetoupload' , true ) ;
92+ } else {
93+ $state . go ( 'site.files-upload' , { root : root , path : path } ) ;
94+ }
95+ } ) ;
9296 } ;
9397} ) ;
Original file line number Diff line number Diff line change 1616 "errornoapp" : " You don't have an app installed to perform this action." ,
1717 "errorreadingfile" : " Error reading file." ,
1818 "errorreceivefilenosites" : " There are no sites stored. Please add a site before trying to upload a file." ,
19+ "erroruploadnotworking" : " Unfortunately it is currently not possible to upload files to your site." ,
1920 "errorwhiledownloading" : " An error occured while trying to download the file." ,
2021 "errorwhileuploading" : " An error occured during the file upload." ,
2122 "errorwhilerecordingaudio" : " An error occured while trying to record audio." ,
Original file line number Diff line number Diff line change @@ -51,6 +51,26 @@ angular.module('mm.addons.files')
5151 return $mmSite . wsAvailable ( 'core_files_get_files' ) ;
5252 } ;
5353
54+ /**
55+ * Check the Moodle version in order to check if upload files is working.
56+ *
57+ * @module mm.addons.files
58+ * @ngdoc method
59+ * @name $mmaFiles#versionCanUploadFiles
60+ * @param {String } [siteId] Id of the site to check. If not defined, use current site.
61+ * @return {Promise } Resolved with true if WS is working, false otherwise.
62+ */
63+ self . versionCanUploadFiles = function ( siteId ) {
64+ siteId = siteId || $mmSite . getId ( ) ;
65+
66+ return $mmSitesManager . getSite ( siteId ) . then ( function ( site ) {
67+ var version = site . getInfo ( ) . version ;
68+
69+ // Uploading is not working right now for Moodle 3.1.0 (2016052300).
70+ return version && ( parseInt ( version ) != 2016052300 ) ;
71+ } ) ;
72+ } ;
73+
5474 /**
5575 * Checks if there is a new file received in iOS. If more than one file is found, treat only the first one.
5676 * The file returned is marked as "treated" and will be deleted in the next execution.
You can’t perform that action at this time.
0 commit comments