-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.php
executable file
·47 lines (37 loc) · 1.54 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
47
<?php
namespace IdnoPlugins\Read {
class Main extends \Idno\Common\Plugin {
function registerPages() {
\Idno\Core\site()->addPageHandler('/read/edit/?', '\IdnoPlugins\Read\Pages\Edit');
\Idno\Core\site()->addPageHandler('/read/edit/([A-Za-z0-9]+)/?', '\IdnoPlugins\Read\Pages\Edit');
\Idno\Core\site()->addPageHandler('/read/delete/([A-Za-z0-9]+)/?', '\IdnoPlugins\Read\Pages\Delete');
\Idno\Core\site()->addPageHandler('/read/([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 ($reads = read::get($search,[],9999,0)) {
foreach($reads as $read) {
/* @var read $read */
if ($read instanceof read) {
if ($attachments = $read->getAttachments()) {
foreach($attachments as $attachment) {
$total += $attachment['length'];
}
}
}
}
}
return $total;
}
}
}