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