-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpage.php
68 lines (57 loc) · 2.08 KB
/
page.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
<?php
require("../../global/library.php");
use FormTools\General;
use FormTools\Modules;
use FormTools\Sessions;
use FormTools\Pages;
// this just checks that SOMEONE's logged in - even someone via the Submission Accounts module
$module = Modules::initModulePage("client");
$page_id = $request["id"];
$page_info = $module->getPage($page_id);
// check permissions! The above code handles booting a user out if they're not logged in,
// so the only case we're worried about
$account_type = Sessions::get("account.account_type");
$account_id = Sessions::get("account.account_id");
$has_permission = true;
if ($account_type == "client") {
if ($page_info["access_type"] == "admin") {
$has_permission = false;
}
if ($page_info["access_type"] == "private") {
if (!in_array($account_id, $page_info["clients"])) {
$has_permission = false;
}
}
}
$L = $module->getLangStrings();
// pretty crumby. We need a consistent way to handle in-page errors
if (!$has_permission) {
$head_title = "";
$content = "<div class=\"error\"><div style=\"padding: 8px\">" . $L["notify_no_permissions"] . "</div></div>";
$page_info["heading"] = "Error";
} else {
$head_title = "{$L["word_page"]} - {$page_info["heading"]}";
$content = $page_info["content"];
switch ($page_info["content_type"]) {
case "php":
ob_start();
eval($page_info["content"]);
$content = ob_get_contents();
ob_end_clean();
break;
case "smarty":
$content = General::evalSmartyString($page_info["content"]);
break;
}
}
$page_vars = array(
"page" => "custom_page",
"page_id" => $page_id,
"phrase_edit_page" => $L["phrase_edit_page"],
"account_type" => $account_type,
"page_url" => Pages::getPageUrl("custom_page"),
"head_title" => $head_title,
"page_info" => $page_info,
"content" => $content
);
$module->displayPage("../../modules/pages/templates/page.tpl", $page_vars);