diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-06-05 13:01:01 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-06-06 12:00:25 +0200 |
commit | a59b5249d39e4b04da318c3f1ec43132988933cc (patch) | |
tree | 8702a2e9365cb1bd11b9b72173be6c3ba1c33d18 /apps/files/appinfo/update.php | |
parent | c47d4ebbac7885ad91cf56355bd6aa09318ff8e8 (diff) | |
download | nextcloud-server-a59b5249d39e4b04da318c3f1ec43132988933cc.tar.gz nextcloud-server-a59b5249d39e4b04da318c3f1ec43132988933cc.zip |
add more and fix office mimetypes, migrate wrong mimetypes
Diffstat (limited to 'apps/files/appinfo/update.php')
-rw-r--r-- | apps/files/appinfo/update.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php index de635e5ce6b..a993979414e 100644 --- a/apps/files/appinfo/update.php +++ b/apps/files/appinfo/update.php @@ -6,3 +6,60 @@ if (version_compare(\OCP\Config::getSystemValue('version', '0.0.0'), '7.0.0', '< \OCP\Config::deleteSystemValue('allowZipDownload'); \OCP\Config::deleteSystemValue('maxZipInputSize'); } + +if (version_compare(\OCP\Config::getAppValue('files', 'installed_version'), '1.1.8', '<')) { + + // update wrong mimetypes + $wrongMimetypes = array( + 'application/mspowerpoint' => 'application/vnd.ms-powerpoint', + 'application/msexcel' => 'application/vnd.ms-excel', + ); + + $stmt = OC_DB::prepare(' + UPDATE `*PREFIX*mimetypes` + SET `mimetype` = ? + WHERE `mimetype` = ? + '); + + foreach ($wrongMimetypes as $wrong => $correct) { + OC_DB::executeAudited($stmt, array($wrong, $correct)); + } + + $updatedMimetypes = array( + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'xlsx' => 'application/vnd.ms-excel', + 'pptx' => 'application/vnd.ms-powerpoint', + ); + + // separate doc from docx etc + foreach ($updatedMimetypes as $extension => $mimetype ) { + $result = OC_DB::executeAudited(' + SELECT count(`mimetype`) + FROM `*PREFIX*mimetypes` + WHERE `mimetype` = ? + ', array($mimetype) + ); + + $exists = $result->fetchOne(); + + if ( ! $exists ) { + // insert mimetype + OC_DB::executeAudited(' + INSERT INTO `*PREFIX*mimetypes` ( `mimetype` ) + VALUES ( ? ) + ', array($mimetype) + ); + } + + // change mimetype for files with x extension + OC_DB::executeAudited(' + UPDATE `*PREFIX*filecache` + SET `mimetype` = ( + SELECT `id` + FROM `*PREFIX*mimetypes` + WHERE `mimetype` = ? + ) WHERE `name` LIKE ? + ', array($mimetype, '%.'.$extension) + ); + } +}
\ No newline at end of file |