-
Notifications
You must be signed in to change notification settings - Fork 38
/
lib.php
70 lines (51 loc) · 1.77 KB
/
lib.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
function block_sharing_cart_after_file_deleted(object $file): void
{
$base_factory = \block_sharing_cart\app\factory::make();
if ($item = $base_factory->item()->repository()->get_by_file_id($file->id)) {
$base_factory->item()->repository()->delete_by_id($item->get_id());
}
}
function block_sharing_cart_output_fragment_item($args)
{
global $OUTPUT, $USER;
$item_id = clean_param($args['item_id'], PARAM_INT);
$base_factory = \block_sharing_cart\app\factory::make();
$item = $base_factory->item()->repository()->get_by_id($item_id);
if (!$item) {
return '';
}
if ($item->get_user_id() !== (int)$USER->id) {
return '';
}
$template = new \block_sharing_cart\output\block\item($base_factory, $item);
return fix_utf8($OUTPUT->render($template));
}
function block_sharing_cart_output_fragment_item_restore_form($args)
{
global $OUTPUT, $USER;
$item_id = clean_param($args['item_id'], PARAM_INT);
$base_factory = \block_sharing_cart\app\factory::make();
$item = $base_factory->item()->repository()->get_by_id($item_id);
if (!$item) {
return '';
}
if ($item->get_user_id() !== (int)$USER->id) {
return '';
}
if ($item->is_module()) {
return get_string(
'confirm_copy_item',
'block_sharing_cart'
);
}
$template = new \block_sharing_cart\output\modal\import_item_modal_body($base_factory, $item);
return fix_utf8($OUTPUT->render($template));
}
function block_sharing_cart_output_fragment_item_queue($args)
{
global $OUTPUT;
$base_factory = \block_sharing_cart\app\factory::make();
$template = new \block_sharing_cart\output\block\queue\items($base_factory);
return fix_utf8($OUTPUT->render($template));
}