diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-01-20 03:11:04 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-01-20 03:11:04 +0100 |
commit | 83d622132224fa61b1518e6bca430518cf138401 (patch) | |
tree | 53f79474af81e07f1304a1cf10e866b2d8af652b /apps/files/ajax | |
parent | 8ca30d244c19b33e7e3b0da247b70160a3acc44f (diff) | |
parent | ebc0c4b85bc382efcf64ad0b2613d70a193b18f2 (diff) | |
download | nextcloud-server-83d622132224fa61b1518e6bca430518cf138401.tar.gz nextcloud-server-83d622132224fa61b1518e6bca430518cf138401.zip |
merge master into filesytem
Diffstat (limited to 'apps/files/ajax')
-rw-r--r-- | apps/files/ajax/autocomplete.php | 54 | ||||
-rw-r--r-- | apps/files/ajax/delete.php | 18 | ||||
-rw-r--r-- | apps/files/ajax/getstoragestats.php | 16 | ||||
-rw-r--r-- | apps/files/ajax/upload.php | 35 |
4 files changed, 61 insertions, 62 deletions
diff --git a/apps/files/ajax/autocomplete.php b/apps/files/ajax/autocomplete.php deleted file mode 100644 index 7613a1cb77a..00000000000 --- a/apps/files/ajax/autocomplete.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -//provide auto completion of paths for use with jquer ui autocomplete - - -// Init owncloud - - -OCP\JSON::checkLoggedIn(); - -// Get data -$query = $_GET['term']; -$dirOnly=(isset($_GET['dironly']))?($_GET['dironly']=='true'):false; - -if($query[0]!='/') { - $query='/'.$query; -} - -if(substr($query, -1, 1)=='/') { - $base=$query; -} else { - $base=dirname($query); -} - -$query=substr($query, strlen($base)); - -if($base!='/') { - $query=substr($query, 1); -} -$queryLen=strlen($query); -$query=strtolower($query); - -// echo "$base - $query"; - -$files=array(); - -if(\OC\Files\Filesystem::file_exists($base) and \OC\Files\Filesystem::is_dir($base)) { - $dh = \OC\Files\Filesystem::opendir($base); - if($dh) { - if(substr($base, -1, 1)!='/') { - $base=$base.'/'; - } - while (($file = readdir($dh)) !== false) { - if ($file != "." && $file != "..") { - if(substr(strtolower($file), 0, $queryLen)==$query) { - $item=$base.$file; - if((!$dirOnly or \OC\Files\Filesystem::is_dir($item))) { - $files[]=(object)array('id'=>$item, 'label'=>$item, 'name'=>$item); - } - } - } - } - } -} -OCP\JSON::encodedPrint($files); diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php index 8f05eaaa1b8..196d6982782 100644 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -23,8 +23,20 @@ foreach ($files as $file) { } } -if ($success) { - OCP\JSON::success(array("data" => array("dir" => $dir, "files" => $files))); +// updated max file size after upload +$l=new OC_L10N('files'); +$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); +$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); +$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + +if($success) { + OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files, + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } else { - OCP\JSON::error(array("data" => array("message" => "Could not delete:\n" . $filesWithError))); + OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError, + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php new file mode 100644 index 00000000000..e55e346ed67 --- /dev/null +++ b/apps/files/ajax/getstoragestats.php @@ -0,0 +1,16 @@ +<?php + +// only need filesystem apps +$RUNTIME_APPTYPES = array('filesystem'); + +OCP\JSON::checkLoggedIn(); + +$l=new OC_L10N('files'); +$maxUploadFilesize = OCP\Util::maxUploadFilesize($dir); +$maxHumanFilesize = OCP\Util::humanFileSize($maxUploadFilesize); +$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize; + +// send back json +OCP\JSON::success(array('data' => array('uploadMaxFilesize' => $maxUploadFilesize, + 'maxHumanFilesize' => $maxHumanFilesize +))); diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index eea66d6b269..b4a2035301e 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -10,8 +10,17 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); $l=OC_L10N::get('files'); +// current max upload size +$l=new OC_L10N('files'); +$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); +$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); +$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + if (!isset($_FILES['files'])) { - OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' )))); + OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ), + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } @@ -28,7 +37,10 @@ foreach ($_FILES['files']['error'] as $error) { UPLOAD_ERR_NO_TMP_DIR=>$l->t('Missing a temporary folder'), UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'), ); - OCP\JSON::error(array('data' => array( 'message' => $errors[$error] ))); + OCP\JSON::error(array('data' => array( 'message' => $errors[$error], + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } } @@ -42,7 +54,9 @@ foreach($files['size'] as $size) { $totalSize+=$size; } if($totalSize>\OC\Files\Filesystem::free_space($dir)) { - OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available' ))); + OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ), + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize))); exit(); } @@ -55,11 +69,19 @@ if(strpos($dir, '..') === false) { $target = \OC\Files\Filesystem::normalizePath($target); if(is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = \OC\Files\Filesystem::getFileInfo($target); + // updated max file size after upload + $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); + $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); + $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + $result[]=array( 'status' => 'success', 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$meta['fileid'], - 'name'=>basename($target)); + 'name'=>basename($target), + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ); } } OCP\JSON::encodedPrint($result); @@ -68,4 +90,7 @@ if(strpos($dir, '..') === false) { $error=$l->t( 'Invalid directory.' ); } -OCP\JSON::error(array('data' => array('message' => $error ))); +OCP\JSON::error(array('data' => array('message' => $error, + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize +))); |