238 Commits

Author SHA1 Message Date
Vladimir Zhirov
ff2dab4566 MDL-59005 resource: fixed zip extraction for filenames in CP-1251/CP-866 2017-06-19 08:50:23 +08:00
Jake Dallimore
e927581a50 MDL-58684 files: Ensure stored_file never serializes the file_storage
Magic methods __sleep and __wakeup used to properly store only the
file_record property and to reinit using get_file_storage().
2017-05-08 11:12:39 +08:00
Andrew Nicols
9020212522 MDL-58718 filestorage: Normalise file paths for Windows 2017-04-26 09:36:10 +08:00
Jake Dallimore
84fb93a77e Merge branch 'MDL-58297-master' of git://github.com/andrewnicols/moodle 2017-04-11 10:49:07 +08:00
Andrew Nicols
a30a04fa01 MDL-58297 filestorage: New functions for hash calculation 2017-04-07 10:40:23 +08:00
Andrew Nicols
941cb7ce3c Merge branch 'MDL-58399-master' of git://github.com/jleyva/moodle 2017-04-05 14:22:39 +08:00
Damyon Wiese
13b449f4a5 MDL-58220 oauth2: cibot cleanups 2017-04-03 13:43:25 +08:00
Damyon Wiese
141ee541ca MDL-58219 repository: Change how controlled links work
Files are copied to the system user as soon as they are uploaded. Write access is then controlled when
serving links to the file.

Part of MDL-58220
2017-04-03 13:41:19 +08:00
Damyon Wiese
151b0f9409 MDL-58132 repositories: Controlled link file type
This introduces a new "controlled link" file type where the file is not
stored in Moodle - but Moodle will control the access permissions on the file.

Plugins can "freeze" a filearea which means Moodle will take ownership of all the remote
files of this type.

When accessing a file, if the "filebrowser" infomation indicates the current user can write to the file, they
will be granted temporary write access.

Part of MDL-58220
2017-04-03 13:40:13 +08:00
Juan Leyva
1104a9fa44 MDL-58399 webservice: Return additional file fields for repositories
We should be detecting when we are treating files that are linked to
external repositories.
For doing that we'd need to return some additional fields via Web
Services:
- isexternalfile
- mimetype (google docs files use an special one)
- repositorytype (the repository plugin name)
2017-03-28 20:23:16 +02:00
Andrew Nicols
1568168717 MDL-55528 fileconverter_unoconv: Add new unoconv plugin
AMOS BEGIN
 MOV [pathtounoconv,admin],[pathtounoconv,fileconverter_unoconv]
 MOV [pathtounoconv_help,admin],[pathtounoconv_help,fileconv_helperter_unoconv_help]
 MOV [unoconvwarning,admin],[unoconvwarning,fileconverter_unoconv]
 MOV [test_unoconv,assignfeedback_editpdf],[test_unoconv,fileconverter_unoconv]
 MOV [test_unoconvempty,assignfeedback_editpdf],[test_unoconvempty,fileconverter_unoconv]
 MOV [test_unoconvdoesnotexist,assignfeedback_editpdf],[test_unoconvdoesnotexist,fileconverter_unoconv]
 MOV [test_unoconvdownload,assignfeedback_editpdf],[test_unoconvdownload,fileconverter_unoconv]
 MOV [test_unoconvisdir,assignfeedback_editpdf],[test_unoconvisdir,fileconverter_unoconv]
 MOV [test_unoconvnotestfile,assignfeedback_editpdf],[test_unoconvnotestfile,fileconverter_unoconv]
 MOV [test_unoconvnotexecutable,assignfeedback_editpdf],[test_unoconvnotexecutable,fileconverter_unoconv]
 MOV [test_unoconvok,assignfeedback_editpdf],[test_unoconvok,fileconverter_unoconv]
 MOV [test_unoconvversionnotsupported,assignfeedback_editpdf],[test_unoconvversionnotsupported,fileconverter_unoconv]
AMOS END
2017-03-10 10:45:46 +08:00
Tony Butler
efa7d24168 MDL-57801 core_filestorage: Delete temp file if disk space runs out 2017-02-16 12:41:06 +00:00
Tony Butler
961323a05f MDL-57801 core_filestorage: Verify hash of temp file before committing
This addresses an edge scenario on NFS filesystems with no space
remaining, where subsequent uploads fail silently while zero byte files
are saved to the pool (and for some reason the filesize check passes).
2017-02-16 12:38:58 +00:00
Andrew Nicols
0c03db6a32 MDL-46375 core_files: Correct filename in mbz test
I noticed during the file system abstraction that this test was
incorrect.

Since both $storagefalse, and $storagetrue are in the same context,
component, area, itemid, and folder, the fact that they had the same
filename meant that they constantly overwrote one another.

As part of archive_to_storage, existing files in the same location are
found, the files themselves deleted, and the existing file record in the
files table is deleted.

The tests continued to pass because:
* the existing variables were not affected by the deletion of the file
  record and file so the comparisons were successful; and
* subsequent calls to fetch the content of the file meant that the
  files themselves were restored from the trash directory.
2017-02-14 08:42:28 +08:00
Andrew Nicols
16a34ae189 MDL-46375 core_files: Split parts of file_storage into new file system
This change moves all operations which deal with the fetching/updating, or
setting of files from the file_storage class into a new file_system class.

A new file_system can be specified in the config.php and used to replace
all relevant methods in order to move the file system component to an
alternative solution.
2017-02-14 08:42:28 +08:00
sam marshall
66234de24c MDL-57515 Resource: 'not very efficient' with a large number of files
Fixes bug where the resource module loads metadata for all files while
building course modinfo, even though it only needs the first file.
(This causes problems if you have ~10k files.)
2017-01-10 17:43:46 +00:00
Eloy Lafuente (stronk7)
a584a403cd Merge branch 'MDL-54916' of https://github.com/mr-russ/moodle 2016-11-07 16:19:06 +01:00
David Monllao
c9af13123d MDL-54751 course_modules: New major upgrade point
Also trailing whitespace cleaned.
2016-11-07 08:59:04 +08:00
Jake Dallimore
3869d77411 MDL-54751 core_course: Edit course libs to support deletion flag
Changed the course libs such that module and section deletion is now
handed off to relevant functions in the util class and exempted
modules scheduled for deletion from the course backups.
2016-11-07 07:41:59 +08:00
Russell Smith
cebce76f61 MDL-56307 course: Refactor file_storage 2016-10-25 10:10:53 +01:00
Juan Leyva
1896b8009a MDL-56307 course: API changes to support retrieve by time 2016-10-25 10:10:52 +01:00
Russell Smith
261bfabc6f MDL-54916 filestorage: Only write empty zip on change.
In some cases we may inspect an empty zip file. If we do open
an empty zip file, check that it changed before we attempt to write
it to disk.  It may be the case that we were reading the file from
a location that we don't have write access to.
2016-10-25 14:10:36 +11:00
Andrew Nicols
b4bb1e65dc Merge branch 'MDL-55445-master-2nd' of git://github.com/FMCorz/moodle 2016-08-17 11:25:24 +08:00
Andrew Nicols
0a0eaa7dfc Merge branch 'MDL-54647-master' of git://github.com/damyon/moodle 2016-08-16 08:01:47 +08:00
Damyon Wiese
300852ee30 MDL-54647 file_storage: Redo the test pdf every time it's viewed 2016-08-15 16:32:21 +08:00
Andrew Nicols
40cc0ba04e Merge branch 'MDL-55513-master' of https://github.com/lucisgit/moodle 2016-08-15 14:07:41 +08:00
Frederic Massart
92b9ef9917
MDL-55445 gdlib: Support for resizing an image 2016-08-15 10:54:28 +08:00
Tony Butler
2ee668ec56 MDL-55513 core_filestorage: Touch and test size instead of file_exists()
file_exists() can return false when file exists (in certain scenarios)
2016-08-10 09:35:23 +01:00
Tony Butler
e98483d748 MDL-55513 core_filestorage: Pass full path of temp dir to remove_dir() 2016-08-10 09:35:23 +01:00
Matt Davidson
826bb3547b MDL-55246 assign: convert files with spaces
If a file is sent to unoconv with a filename that contains spaces,
unoconv will fail to produce the intended results.
2016-08-05 08:14:20 -04:00
Andrew Nicols
2c2f4f17c3 MDL-24343 core: Deprecate unzip_file 2016-08-03 09:05:55 +08:00
Rajesh Taneja
52f3e060e4
MDL-55091 phpunit: Following has been deprecated.
1. getMock()
2. setExpectedException()
3. checkForUnintentionallyCoveredCode renamed to beStrictAboutCoversAnnotation
4. beStrictAboutTestSize renamed to enforceTimeLimit
5. UnitTestCase class is now fully removed.
2016-07-26 10:11:30 +08:00
Simey Lameze
37eafbb6dc MDL-54948 core_files: return false if theres no output from unoconv 2016-06-23 08:37:23 +08:00
Simey Lameze
9254ba09e8 MDL-54948 core_files: make the check consistent on unoconv test page 2016-06-21 09:36:44 +08:00
David Monllao
50c338b84b Merge branch 'MDL-54544-master' of git://github.com/damyon/moodle 2016-05-18 13:55:05 +08:00
Damyon Wiese
4f54bdc733 MDL-54544 files: Better error handling in $fs->create_converted_document() 2016-05-18 13:44:13 +08:00
Damyon Wiese
5620177efd MDL-54544 file: Use shared tmp storage for unoconv document conversions 2016-05-17 10:58:25 +08:00
Adrian Greeve
0eecf87687 MDL-53923 mod_assign: Movement of functions to file_storage. 2016-05-16 14:32:54 +08:00
Matteo Scaramuccia
bc219382b7 MDL-53837 assign: Fix executable check for 'unoconv.py' on Windows. 2016-04-17 22:35:13 +02:00
Damyon Wiese
6853cd5ed4 MDL-52954 assign: Fix the reasonable cibot warnings. 2016-03-30 14:07:28 +08:00
Damyon Wiese
bb690849c9 MDL-52954 assign: Rebuild the assignment single grade page. 2016-03-30 13:47:21 +08:00
Damyon Wiese
1356d85151 MDL-52954 core: Change from pandoc to unoconv - it gives better results
Most importantly it retains formatting better, and supports different charsets far better than pandoc.
2016-03-30 11:48:39 +08:00
Damyon Wiese
2e76c14e11 MDL-52954 core: Add a document converter to file_storage
This lets us convert between common office formats. E.g. docx -> pdf
html -> pdf, html -> ods.

This commit also updates assignment editpdf plugin to use this converter
on all compatible submission files.
2016-03-30 11:48:39 +08:00
Eugene Venter
8ef4fbc64f MDL-52530 unittest: more robust capability assignments for guest
for core_files_file_storage_testcase and core_repositorylib_testcase
2015-12-23 09:24:53 +13:00
Eloy Lafuente (stronk7)
b4153ff09d Merge branch 'wip-MDL-51985-master' of https://github.com/marinaglancy/moodle 2015-12-03 11:16:34 +01:00
Jun Pataleta
a33e5debe9 MDL-37308 files: Additional fixes for transparency
Fixed transparency support when resizing and when not resizing.
2015-11-29 20:28:19 -06:00
Jetha Chan
623c947f2b MDL-37308 files: support transparency when not resizing; new unit test 2015-11-29 20:28:19 -06:00
Adrian Greeve
e245843193 MDL-37308 files: convert_image() now supports transparency. 2015-11-29 20:28:18 -06:00
Marina Glancy
58e5ab1bac MDL-51985 files: sync timemodified when possible 2015-10-30 14:46:09 +08:00
Eloy Lafuente (stronk7)
70ae75674d MDL-51863 packer: ensure empty zip files behavior remains consistent
With PHP bug #70322 fixed, ZipArchive::close() did start returning false
and throwing PHP Warnings with recent PHP versions (5.6.14 and up).
Previously (5.6.13 verified) it was returning true, and false in older
versions (5.4.x verified).

This change does silent the 2 "hacky" calls to close() that we perform
in core leaving the 3rd one (used for files having files) unmodified.

A new unit test has been created to cover the close() behavior, ideally
supporting both old and new PHP versions without harcoding any PHP
version.

Note that we don't use to rely much on results coming from close(), and
that's a good thing given the buggy behavior commented above. This just
keeps empty zips working like they were before.
2015-10-26 21:16:54 +01:00