-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathmybookings.php
More file actions
92 lines (75 loc) · 3.06 KB
/
mybookings.php
File metadata and controls
92 lines (75 loc) · 3.06 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Handling my bookings page
*
* @package mod_booking
* @copyright 2023 Wunderbyte GmbH <info@wunderbyte.at>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/mod/booking/locallib.php');
// No guest autologin.
require_login(0, false);
use mod_booking\shortcodes;
use mod_booking\singleton_service;
$url = new moodle_url('/mod/booking/mybookings.php');
$userid = optional_param('userid', 0, PARAM_INT);
$completed = optional_param('completed', 0, PARAM_INT);
$search = optional_param('search', 0, PARAM_INT);
$filter = optional_param('filter', 0, PARAM_INT);
$typefilter = optional_param('typefilter', 0, PARAM_INT);
$shoppingcartexists = core_component::get_plugin_directory('local', 'shopping_cart');
$hascapability = false;
if (has_capability('mod/booking:bookforothers', context_system::instance())) {
$hascapability = true;
}
if ($shoppingcartexists) {
$hascapability = has_capability('local/shopping_cart:cashier', context_system::instance());
}
if (!empty($userid) && $hascapability) {
$user = singleton_service::get_instance_of_user($userid);
} else {
$user = $USER;
$userid = $USER->id;
}
$PAGE->set_context(context_user::instance($user->id));
$PAGE->navigation->extend_for_user($user);
$mybookingsurl = new moodle_url('/mod/booking/mybookings.php', ['userid' => $userid]);
$PAGE->set_url($mybookingsurl);
$PAGE->set_pagelayout('base');
if ($userid != $USER->id) {
$arguments = ['userid' => $userid, 'completed' => $completed];
$heading = get_string('bookings', 'mod_booking');
} else {
$arguments = ['userid' => $userid, 'completed' => $completed];
$heading = get_string('mybookingoptions', 'mod_booking');
}
$PAGE->navbar->add($heading);
echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
$arguments['sort'] = 1;
$arguments['sortby'] = 'coursestarttime';
$arguments['sortorder'] = 'desc';
$arguments['foruserid'] = $userid;
$arguments['search'] = $search;
$arguments['filter'] = $filter;
$arguments['typefilter'] = $typefilter;
echo shortcodes::mycourselist('', $arguments, '', (object)[], fn($a) => $a);
if (class_exists('local_shopping_cart\shopping_cart') && get_config('booking', 'displayshoppingcarthistory')) {
echo local_shopping_cart\shortcodes::shoppingcarthistory('', ['foruserid' => $userid], '', (object)[], fn($a) => $a);
}
echo $OUTPUT->footer();