Admin - show personal filesystem usage
authorPaul Mehrer <p.mehrer@metaways.de>
Wed, 12 Jul 2017 10:47:39 +0000 (12:47 +0200)
committerPaul Mehrer <p.mehrer@metaways.de>
Thu, 13 Jul 2017 09:20:23 +0000 (11:20 +0200)
Change-Id: Ib136d6a10077987c639e090918ea3f6a03731b8d
Reviewed-on: http://gerrit.tine20.com/customers/5117
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
Tested-by: Paul Mehrer <p.mehrer@metaways.de>
tine20/Admin/Frontend/Json.php

index 3c7edee..f9a0499 100644 (file)
@@ -262,6 +262,9 @@ class Admin_Frontend_Json extends Tinebase_Frontend_Json_Abstract
     /**
      * get list of accounts
      *
+     * adds filesystemSize and filesystemRevisionSize columns to result, these columns currently contain the value
+     * of the filemanager personal folder ONLY.
+     *
      * @param string $_filter
      * @param string $_sort
      * @param string $_dir
@@ -274,9 +277,29 @@ class Admin_Frontend_Json extends Tinebase_Frontend_Json_Abstract
     public function getUsers($filter, $sort, $dir, $start, $limit)
     {
         $accounts = Admin_Controller_User::getInstance()->searchFullUsers($filter, $sort, $dir, $start, $limit);
+        $results = array();
+        foreach ($this->_multipleRecordsToJson($accounts) as $val) {
+            $val['filesystemSize'] = null;
+            $val['filesystemRevisionSize'] = null;
+            $results[$val['accountId']] = $val;
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Filemanager')) {
+            $accountIds = $accounts->getId();
+            /** @var Tinebase_Model_Tree_Node $node */
+            foreach (Tinebase_FileSystem::getInstance()->searchNodes(new Tinebase_Model_Tree_Node_Filter(array(
+                        array('field' => 'path', 'operator' => 'equals', 'value' => '/Filemanager/folders/personal'),
+                        array('field' => 'name', 'operator' => 'in', 'value' => $accountIds)
+                    ), '', array('ignoreAcl' => true))) as $node) {
+                if (isset($results[$node->name])) {
+                    $results[$node->name]['filesystemSize'] = $node->size;
+                    $results[$node->name]['filesystemRevisionSize'] = $node->revision_size;
+                }
+            }
+        }
 
         $result = array(
-            'results'     => $this->_multipleRecordsToJson($accounts),
+            'results'     => $results,
             'totalcount'  => Admin_Controller_User::getInstance()->searchCount($filter)
         );