diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-07-13 17:38:13 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-11-22 16:05:50 +0100 |
commit | fa2be0750c50de45a2fd101eb23fa858c0e0771b (patch) | |
tree | 977892b4eeaf9c26e7157575d5c1909e6aa5febd /apps/files/ajax | |
parent | f120846e291bf83244831770c5f25b730fa8ba90 (diff) | |
download | nextcloud-server-fa2be0750c50de45a2fd101eb23fa858c0e0771b.tar.gz nextcloud-server-fa2be0750c50de45a2fd101eb23fa858c0e0771b.zip |
Make files app use Webdav for most operations
Diffstat (limited to 'apps/files/ajax')
-rw-r--r-- | apps/files/ajax/delete.php | 81 | ||||
-rw-r--r-- | apps/files/ajax/move.php | 59 | ||||
-rw-r--r-- | apps/files/ajax/newfile.php | 103 | ||||
-rw-r--r-- | apps/files/ajax/newfolder.php | 99 | ||||
-rw-r--r-- | apps/files/ajax/rename.php | 58 |
5 files changed, 0 insertions, 400 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php deleted file mode 100644 index 2d02869df14..00000000000 --- a/apps/files/ajax/delete.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -/** - * @author Arthur Schiwon <blizzz@owncloud.com> - * @author Frank Karlitschek <frank@owncloud.org> - * @author Jakob Sack <mail@jakobsack.de> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Robin Appelman <icewind@owncloud.com> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Vincent Petry <pvince81@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); -\OC::$server->getSession()->close(); - - -// Get data -$dir = isset($_POST['dir']) ? (string)$_POST['dir'] : ''; -$allFiles = isset($_POST["allfiles"]) ? (string)$_POST["allfiles"] : false; - -// delete all files in dir ? -if ($allFiles === 'true') { - $files = array(); - $fileList = \OC\Files\Filesystem::getDirectoryContent($dir); - foreach ($fileList as $fileInfo) { - $files[] = $fileInfo['name']; - } -} else { - $files = isset($_POST["file"]) ? (string)$_POST["file"] : (string)$_POST["files"]; - $files = json_decode($files); -} -$filesWithError = ''; - -$success = true; - -//Now delete -foreach ($files as $file) { - try { - if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) && - !(\OC\Files\Filesystem::isDeletable($dir . '/' . $file) && - \OC\Files\Filesystem::unlink($dir . '/' . $file)) - ) { - $filesWithError .= $file . "\n"; - $success = false; - } - } catch (\Exception $e) { - $filesWithError .= $file . "\n"; - $success = false; - } -} - -// get array with updated storage stats (e.g. max file size) after upload -try { - $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); -} catch(\OCP\Files\NotFoundException $e) { - OCP\JSON::error(['data' => ['message' => 'File not found']]); - return; -} - -if ($success) { - OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats))); -} else { - OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:\n" . $filesWithError), $storageStats))); -} diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php deleted file mode 100644 index 0961636a116..00000000000 --- a/apps/files/ajax/move.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * @author Björn Schießle <schiessle@owncloud.com> - * @author Frank Karlitschek <frank@owncloud.org> - * @author Georg Ehrke <georg@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Robin Appelman <icewind@owncloud.com> - * @author Vincent Petry <pvince81@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); -\OC::$server->getSession()->close(); - -// Get data -$dir = isset($_POST['dir']) ? (string)$_POST['dir'] : ''; -$file = isset($_POST['file']) ? (string)$_POST['file'] : ''; -$target = isset($_POST['target']) ? rawurldecode((string)$_POST['target']) : ''; - -$l = \OC::$server->getL10N('files'); - -if(\OC\Files\Filesystem::file_exists($target . '/' . $file)) { - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not move %s - File with this name already exists", array($file)) ))); - exit; -} - -if ($target != '' || strtolower($file) != 'shared') { - $targetFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file); - $sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file); - try { - if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) { - OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file ))); - } else { - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not move %s", array($file)) ))); - } - } catch (\OCP\Files\NotPermittedException $e) { - OCP\JSON::error(array("data" => array( "message" => $l->t("Permission denied") ))); - } catch (\Exception $e) { - OCP\JSON::error(array("data" => array( "message" => $e->getMessage()))); - } -}else{ - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not move %s", array($file)) ))); -} diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php deleted file mode 100644 index be09b288d4b..00000000000 --- a/apps/files/ajax/newfile.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/** - * @author Andreas Fischer <bantu@owncloud.com> - * @author Georg Ehrke <georg@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Robin Appelman <icewind@owncloud.com> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Vincent Petry <pvince81@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -// Init owncloud -global $eventSource; - -\OCP\JSON::checkLoggedIn(); -\OCP\JSON::callCheck(); - -\OC::$server->getSession()->close(); - -// Get the params -$dir = isset( $_REQUEST['dir'] ) ? '/'.trim((string)$_REQUEST['dir'], '/\\') : ''; -$fileName = isset( $_REQUEST['filename'] ) ? trim((string)$_REQUEST['filename'], '/\\') : ''; - -$l10n = \OC::$server->getL10N('files'); - -$result = array( - 'success' => false, - 'data' => NULL -); - -try { - \OC\Files\Filesystem::getView()->verifyPath($dir, $fileName); -} catch (\OCP\Files\InvalidPathException $ex) { - $result['data'] = [ - 'message' => $ex->getMessage()]; - OCP\JSON::error($result); - return; -} - -if (!\OC\Files\Filesystem::file_exists($dir . '/')) { - $result['data'] = array('message' => (string)$l10n->t( - 'The target folder has been moved or deleted.'), - 'code' => 'targetnotfound' - ); - OCP\JSON::error($result); - exit(); -} - -$target = $dir.'/'.$fileName; - -if (\OC\Files\Filesystem::file_exists($target)) { - $result['data'] = array('message' => (string)$l10n->t( - 'The name %s is already used in the folder %s. Please choose a different name.', - array($fileName, $dir)) - ); - OCP\JSON::error($result); - exit(); -} - -$success = false; -$templateManager = OC_Helper::getFileTemplateManager(); -$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target); -$content = $templateManager->getTemplate($mimeType); - -try { - if($content) { - $success = \OC\Files\Filesystem::file_put_contents($target, $content); - } else { - $success = \OC\Files\Filesystem::touch($target); - } -} catch (\Exception $e) { - $result = [ - 'success' => false, - 'data' => [ - 'message' => $e->getMessage() - ] - ]; - OCP\JSON::error($result); - exit(); -} - -if($success) { - $meta = \OC\Files\Filesystem::getFileInfo($target); - OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta))); - return; -} - -OCP\JSON::error(array('data' => array( 'message' => $l10n->t('Error when creating the file') ))); diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php deleted file mode 100644 index a2897dd437a..00000000000 --- a/apps/files/ajax/newfolder.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * @author Arthur Schiwon <blizzz@owncloud.com> - * @author Björn Schießle <schiessle@owncloud.com> - * @author Frank Karlitschek <frank@owncloud.org> - * @author Georg Ehrke <georg@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Robin Appelman <icewind@owncloud.com> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Vincent Petry <pvince81@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -// Init owncloud - - -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); -\OC::$server->getSession()->close(); - -// Get the params -$dir = isset($_POST['dir']) ? (string)$_POST['dir'] : ''; -$folderName = isset($_POST['foldername']) ?(string) $_POST['foldername'] : ''; - -$l10n = \OC::$server->getL10N('files'); - -$result = array( - 'success' => false, - 'data' => NULL - ); - -try { - \OC\Files\Filesystem::getView()->verifyPath($dir, $folderName); -} catch (\OCP\Files\InvalidPathException $ex) { - $result['data'] = [ - 'message' => $ex->getMessage()]; - OCP\JSON::error($result); - return; -} - -if (!\OC\Files\Filesystem::file_exists($dir . '/')) { - $result['data'] = array('message' => (string)$l10n->t( - 'The target folder has been moved or deleted.'), - 'code' => 'targetnotfound' - ); - OCP\JSON::error($result); - exit(); -} - -$target = $dir . '/' . $folderName; - -if (\OC\Files\Filesystem::file_exists($target)) { - $result['data'] = array('message' => $l10n->t( - 'The name %s is already used in the folder %s. Please choose a different name.', - array($folderName, $dir)) - ); - OCP\JSON::error($result); - exit(); -} - -try { - if(\OC\Files\Filesystem::mkdir($target)) { - if ( $dir !== '/') { - $path = $dir.'/'.$folderName; - } else { - $path = '/'.$folderName; - } - $meta = \OC\Files\Filesystem::getFileInfo($path); - $meta['type'] = 'dir'; // missing ?! - OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta))); - exit(); - } -} catch (\Exception $e) { - $result = [ - 'success' => false, - 'data' => [ - 'message' => $e->getMessage() - ] - ]; - OCP\JSON::error($result); - exit(); -} - -OCP\JSON::error(array('data' => array( 'message' => $l10n->t('Error when creating the folder') ))); diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php deleted file mode 100644 index a24a57b1046..00000000000 --- a/apps/files/ajax/rename.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * @author Christopher Schäpers <kondou@ts.unde.re> - * @author Frank Karlitschek <frank@owncloud.org> - * @author Jakob Sack <mail@jakobsack.de> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <icewind@owncloud.com> - * @author Vincent Petry <pvince81@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); -\OC::$server->getSession()->close(); - -$l10n = \OC::$server->getL10N('files'); - -$files = new \OCA\Files\App( - \OC\Files\Filesystem::getView(), - \OC::$server->getL10N('files') -); -try { - $result = $files->rename( - isset($_GET['dir']) ? (string)$_GET['dir'] : '', - isset($_GET['file']) ? (string)$_GET['file'] : '', - isset($_GET['newname']) ? (string)$_GET['newname'] : '' - ); -} catch (\Exception $e) { - $result = [ - 'success' => false, - 'data' => [ - 'message' => $e->getMessage() - ] - ]; -} - -if($result['success'] === true){ - OCP\JSON::success(['data' => $result['data']]); -} else { - OCP\JSON::error(['data' => $result['data']]); -} |