forked from textpattern/textpattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtxp_pane.php
More file actions
113 lines (90 loc) · 2.5 KB
/
Copy pathtxp_pane.php
File metadata and controls
113 lines (90 loc) · 2.5 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
* Textpattern Content Management System
* https://textpattern.com/
*
* Copyright (C) 2019 The Textpattern Development Team
*
* This file is part of Textpattern.
*
* Textpattern 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, version 2.
*
* Textpattern 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 Textpattern. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined('txpinterface')) {
die('txpinterface is undefined.');
}
/**
* Handles pane states.
*
* @package Admin\Pane
*/
class Textpattern_Admin_Pane
{
/**
* Constructor.
*/
public function __construct()
{
global $step;
$steps = array(
'visible' => true,
'tabVisible' => true,
);
if ($step && bouncer($step, $steps) && has_privs(ps('origin'))) {
$this->$step();
}
}
/**
* Validates a token.
*
* @return bool
*/
protected function valid_token()
{
$args = func_get_args();
return ps('token') === md5(join('', $args).ps('origin').form_token().get_pref('blog_uid'));
}
/**
* Saves pane visibility.
*/
public function visible()
{
extract(psa(array(
'pane',
'visible',
'origin',
)));
send_xml_response();
if ($this->valid_token($pane) && preg_match('/^[a-z0-9_-]+$/i', $pane)) {
set_pref("pane_{$pane}_visible", (int) ($visible === 'true'), $origin, PREF_HIDDEN, 'yesnoradio', 0, PREF_PRIVATE);
return;
}
trigger_error(gTxt('invalid_pane'), E_USER_WARNING);
}
/**
* Saves tab visibility.
*/
public function tabVisible()
{
extract(psa(array(
'pane',
'origin',
)));
send_xml_response();
if ($this->valid_token($pane) && preg_match('/^[a-z0-9_-]+$/i', $pane)) {
set_pref("pane_{$origin}_visible", ($pane), $origin, PREF_HIDDEN, 'text_input', 0, PREF_PRIVATE);
return;
}
trigger_error(gTxt('invalid_pane'), E_USER_WARNING);
}
}
new Textpattern_Admin_Pane();