This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
forked from projectsend/projectsend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublic.php
64 lines (50 loc) · 1.78 KB
/
public.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
<?php
/**
* Shows the list of public groups and files
*/
define('IS_PUBLIC_VIEW', true);
$allowed_levels = array(9, 8, 7, 0);
require_once 'bootstrap.php';
// If the option to show this page is not enabled, redirect
if (get_option('public_listing_page_enable') != 1) {
ps_redirect(BASE_URI . "index.php");
}
// Check the option to show the page to logged in users only
if (get_option('public_listing_logged_only') == 1) {
redirect_if_not_logged_in();
}
$current_url = get_form_action_with_existing_parameters(basename(__FILE__));
$mode = 'files';
// If viewing a particular group, make sure it's public
if (!empty($_GET['group'])) {
if (empty($_GET['token'])) {
ps_redirect(BASE_URI . "index.php");
}
if (!can_view_public_group($_GET['group'], $_GET['token'])) {
ps_redirect(BASE_URI . "index.php");
}
$mode = 'group';
$current_group = new \ProjectSend\Classes\Groups($_GET['group']);
$group_props = $current_group->getProperties();
}
$page_id = 'public_files_list';
$show_page_title = true;
$page_title = ($mode == 'files') ? __('Public files (not assigned to any group)', 'cftp_admin') : sprintf(__('Files in group: %s', 'cftp_admin'), $group_props['name']);
$dont_redirect_if_logged = 1;
// Pagination
$per_page = get_option('pagination_results_per_page');
$pagination_page = (isset($_GET["page"])) ? $_GET["page"] : 1;
$pagination_start = ($pagination_page - 1) * $per_page;
$args = [
'group' => null,
'pagination' => [
'page' => $pagination_page,
'start' => $pagination_start,
'per_page' => $per_page, //get_option('pagination_results_per_page')
]
];
if (!empty($_GET['group'])) {
$args['group_id'] = $_GET['group'];
}
$files = get_public_files($args);
require get_template_file_location('public-list.php');