forked from jgmac1106/Known-Listen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.php
46 lines (36 loc) · 1.52 KB
/
Main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace IdnoPlugins\Listen {
class Main extends \Idno\Common\Plugin {
function registerPages() {
\Idno\Core\site()->addPageHandler('/listen/edit/?', '\IdnoPlugins\Listen\Pages\Edit');
\Idno\Core\site()->addPageHandler('/listen/edit/([A-Za-z0-9]+)/?', '\IdnoPlugins\Listen\Pages\Edit');
\Idno\Core\site()->addPageHandler('/listen/delete/([A-Za-z0-9]+)/?', '\IdnoPlugins\Listen\Pages\Delete');
\Idno\Core\site()->addPageHandler('/listen/([A-Za-z0-9]+)/.*', '\Idno\Pages\Entity\View');
}
/**
* Get the total file usage
* @param bool $user
* @return int
*/
function getFileUsage($user = false) {
$total = 0;
if (!empty($user)) {
$search = ['user' => $user];
} else {
$search = [];
}
if ($listens = listen::get($search,[],9999,0)) {
foreach($listens as $listen) {
if ($listen instanceof listen) {
if ($attachments = $listen->getAttachments()) {
foreach($attachments as $attachment) {
$total += $attachment['length'];
}
}
}
}
}
return $total;
}
}
}