Get user quota information on main page | patching the code?




I want to tweak , the front page by adding Quota information. I did my best to get the information from the hidden fields such as "usedSpacePercent" and "free_space" displayed on the main-page. For this , I learned a little from /apps/files/js/files.js with the relevant section looks like:-

if ( !== undefined && !== undefined) {

The problem is that there is no 'quota' information present in the files.js, getJSON call to "getstoragestats.php" which lands to "/apps/files/lib/Helper.php" contains

public static function buildFileStorageStatistics($dir) {
	// information about storage capacities
	$storageInfo = \OC_Helper::getStorageInfo($dir);
	$l = new \OC_L10N('files');
	$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
	$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
	$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
	return [
		'uploadMaxFilesize' => $maxUploadFileSize,
		'maxHumanFilesize'  => $maxHumanFileSize,
		'freeSpace' => $storageInfo['free'],
		'usedSpacePercent'  => (int)$storageInfo['relative'],
		'owner' => $storageInfo['owner'],
		'ownerDisplayName' => $storageInfo['ownerDisplayName'],

no return of 'Quota' value from "getStorageInfo()" defined here "lib/private/legacy/helper.php' as

$ownerId = $storage->getOwner($path);
$ownerDisplayName = '';
$owner = \OC::$server->getUserManager()->get($ownerId);
if($owner) {
$ownerDisplayName = $owner->getDisplayName();
return [
'free' => $free,
'used' => $used,
'quota' => $quota,
'total' => $total,
'relative' => $relative,
'owner' => $ownerId,
'ownerDisplayName' => $ownerDisplayName,

I'm thinking of thus patching the files.js as


and files/lib/Helper.php as

'quota' => $storageInfo['quota'],

After, that I can use JS, to call the id against whatever HTML element i.e span or div on the main-page. Please suggest?


using firebug in files.js = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) {

I get response as

{"data":{"uploadMaxFilesize":537919488,"maxHumanFilesize":"Upload (max. 513 MB)","freeSpace":1069113360

No quota is returned?



any assistance.....?


To be honest - I don't really understand what you are trying to do :frowning:


I'm trying to display quote information on the mainpage,by adding code to files.js and files/lib/Helper.php.


What do you mean by mainpage? the login page?

Quota information is user specific - there is little to display without being logged in


yes quote for specific user, the page I want it to be displayed is /index.php/apps/files/


Hello assistance required?


Generally speaking your approach looks valid.
If it doesn't work outyou need to dive into debugging the situation.

If you don't want to setup an ide and xdebug you can add logging statements to see whats going on in the server.