summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-01-19 00:31:09 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-01-19 00:31:09 +0100
commitcdd07b33392897b1b6c7f5707b83874ba06ec363 (patch)
tree1bad04263312d7e799bb8eeb8c59afe90f2733fb /apps/files/lib
parentafb5de955e00490be5762247e817b20722091f37 (diff)
downloadnextcloud-server-cdd07b33392897b1b6c7f5707b83874ba06ec363.tar.gz
nextcloud-server-cdd07b33392897b1b6c7f5707b83874ba06ec363.zip
introducing class OCA/files/lib/Helper with new function to build an array with storage stats
DRYing the code by using \OCA\files\lib\Helper::buildFileStorageStatistics() now returning used space percent on each ajax call
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/helper.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
new file mode 100644
index 00000000000..f2b1f142e9b
--- /dev/null
+++ b/apps/files/lib/helper.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace OCA\files\lib;
+
+class Helper
+{
+ public static function buildFileStorageStatistics($dir) {
+ $l = new \OC_L10N('files');
+ $maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir);
+ $maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
+ $maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
+
+ // information about storage capacities
+ $storageInfo = \OC_Helper::getStorageInfo();
+
+ return array('uploadMaxFilesize' => $maxUploadFilesize,
+ 'maxHumanFilesize' => $maxHumanFilesize,
+ 'usedSpacePercent' => (int)$storageInfo['relative']);
+ }
+}