[Pkg-owncloud-commits] [owncloud] 320/457: Add owner to the storage stats to enable better notifications

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:06:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 62ae39208a0deed71d4cd373c6822946fd489586
Author: Morris Jobke <hey at morrisjobke.de>
Date:   Fri Jun 5 18:21:41 2015 +0200

    Add owner to the storage stats to enable better notifications
    
    * getstoragestats.php returns now the owner and it's display name
    * show proper storage stats notifications for shared folders
---
 apps/files/index.php           |  2 ++
 apps/files/js/files.js         | 16 +++++++++++++++-
 apps/files/lib/helper.php      |  4 +++-
 apps/files/templates/index.php |  2 ++
 lib/private/helper.php         | 16 +++++++++++++++-
 5 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/apps/files/index.php b/apps/files/index.php
index c7a45e5..ee12df5 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -138,6 +138,8 @@ OCP\Util::addscript('files', 'navigation');
 OCP\Util::addscript('files', 'keyboardshortcuts');
 $tmpl = new OCP\Template('files', 'index', 'user');
 $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
+$tmpl->assign('owner', $storageInfo['owner']);
+$tmpl->assign('ownerDisplayName', $storageInfo['ownerDisplayName']);
 $tmpl->assign('isPublic', false);
 $tmpl->assign("mailNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_mail_notification', 'no'));
 $tmpl->assign("mailPublicNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_public_notification', 'no'));
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 68e9315..44868e7 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -63,6 +63,8 @@
 				$('#free_space').val(response.data.freeSpace);
 				$('#upload.button').attr('original-title', response.data.maxHumanFilesize);
 				$('#usedSpacePercent').val(response.data.usedSpacePercent);
+				$('#owner').val(response.data.owner);
+				$('#ownerDisplayName').val(response.data.ownerDisplayName);
 				Files.displayStorageWarnings();
 			}
 			if (response[0] === undefined) {
@@ -109,12 +111,24 @@
 				return;
 			}
 
-			var usedSpacePercent = $('#usedSpacePercent').val();
+			var usedSpacePercent = $('#usedSpacePercent').val(),
+				owner = $('#owner').val(),
+				ownerDisplayName = $('#ownerDisplayName').val();
 			if (usedSpacePercent > 98) {
+				if (owner !== oc_current_user) {
+					OC.Notification.show(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!',
+						{ owner: ownerDisplayName }));
+					return;
+				}
 				OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!'));
 				return;
 			}
 			if (usedSpacePercent > 90) {
+				if (owner !== oc_current_user) {
+					OC.Notification.show(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)',
+						{ usedSpacePercent: usedSpacePercent,  owner: ownerDisplayName }));
+					return;
+				}
 				OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)',
 					{usedSpacePercent: usedSpacePercent}));
 			}
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index e966e60..6bfdc0a 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -52,7 +52,9 @@ class Helper {
 			'uploadMaxFilesize' => $maxUploadFileSize,
 			'maxHumanFilesize'  => $maxHumanFileSize,
 			'freeSpace' => $storageInfo['free'],
-			'usedSpacePercent'  => (int)$storageInfo['relative']
+			'usedSpacePercent'  => (int)$storageInfo['relative'],
+			'owner' => $storageInfo['owner'],
+			'ownerDisplayName' => $storageInfo['ownerDisplayName'],
 		];
 	}
 
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 77f80bc..a068f30 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -11,6 +11,8 @@
 <!-- config hints for javascript -->
 <input type="hidden" name="filesApp" id="filesApp" value="1" />
 <input type="hidden" name="usedSpacePercent" id="usedSpacePercent" value="<?php p($_['usedSpacePercent']); ?>" />
+<input type="hidden" name="owner" id="owner" value="<?php p($_['owner']); ?>" />
+<input type="hidden" name="ownerDisplayName" id="ownerDisplayName" value="<?php p($_['ownerDisplayName']); ?>" />
 <?php if (!$_['isPublic']) :?>
 <input type="hidden" name="mailNotificationEnabled" id="mailNotificationEnabled" value="<?php p($_['mailNotificationEnabled']) ?>" />
 <input type="hidden" name="mailPublicNotificationEnabled" id="mailPublicNotificationEnabled" value="<?php p($_['mailPublicNotificationEnabled']) ?>" />
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 981447c..f4de5b0 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -1008,7 +1008,21 @@ class OC_Helper {
 			$relative = 0;
 		}
 
-		return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative);
+		$ownerId = $storage->getOwner($path);
+		$ownerDisplayName = '';
+		$owner = \OC::$server->getUserManager()->get($ownerId);
+		if($owner) {
+			$ownerDisplayName = $owner->getDisplayName();
+		}
+
+		return [
+			'free' => $free,
+			'used' => $used,
+			'total' => $total,
+			'relative' => $relative,
+			'owner' => $ownerId,
+			'ownerDisplayName' => $ownerDisplayName,
+		];
 	}
 
 	/**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list