@@ -103,7 +103,7 @@ function policyCheck($folderDao, $userDao = null, $policy = 0)
103
103
return true ;
104
104
}//end policyCheck
105
105
106
- /** get the size and the number of item in a folder*/
106
+ /** get the size and the number of item in a folder*/
107
107
public function getSizeFiltered ($ folders , $ userDao = null , $ policy = 0 )
108
108
{
109
109
$ isAdmin = false ;
@@ -214,6 +214,37 @@ public function getSizeFiltered($folders, $userDao = null, $policy = 0)
214
214
return $ folders ;
215
215
}
216
216
217
+ /** get the total size for a folder (with no filtered results) */
218
+ public function getSize ($ folder )
219
+ {
220
+ if (!$ folder instanceof FolderDao)
221
+ {
222
+ throw new Zend_Exception ("Should be a folder " );
223
+ }
224
+ $ folders = $ this ->database ->select ()
225
+ ->setIntegrityCheck (false )
226
+ ->from (array ('f ' => 'folder ' ), array ('folder_id ' ))
227
+ ->where ('left_indice > ? ' , $ folder ->getLeftIndice ())
228
+ ->where ('right_indice < ? ' , $ folder ->getRightIndice ());
229
+
230
+ $ sql = $ this ->database ->select ()
231
+ ->distinct ()
232
+ ->setIntegrityCheck (false )
233
+ ->from (array ('i ' => 'item ' ))
234
+ ->join (array ('i2f ' => 'item2folder ' ),
235
+ '( ' .$ this ->database ->getDB ()->quoteInto ('i2f.folder_id IN (?) ' , $ folders ).'
236
+ OR i2f.folder_id = ' .$ folder ->getKey ().'
237
+ )
238
+ AND i2f.item_id = i.item_id ' , array ());
239
+
240
+ $ sql = $ this ->database ->select ()
241
+ ->setIntegrityCheck (false )
242
+ ->from (array ('i ' => $ sql ), array ('sum ' => 'sum(i.sizebytes) ' ));
243
+
244
+ $ row = $ this ->database ->fetchRow ($ sql );
245
+ return $ row ['sum ' ];
246
+ }
247
+
217
248
/** Get the root folder */
218
249
function getRoot ($ folder )
219
250
{
0 commit comments