File tree Expand file tree Collapse file tree 3 files changed +72
-2
lines changed Expand file tree Collapse file tree 3 files changed +72
-2
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Icinga \Module \Director \Web \Form ;
4
+
5
+ use ipl \Html \Form ;
6
+ use ipl \Html \ValidHtml ;
7
+
8
+ class PropertyTableSortForm extends Form
9
+ {
10
+ /** @var string Name of the table using the form */
11
+ private $ name ;
12
+
13
+ /** @var string Table to sort */
14
+ private $ table ;
15
+
16
+ public function __construct (string $ name , ValidHtml $ table )
17
+ {
18
+ $ this ->name = $ name ;
19
+ $ this ->table = $ table ;
20
+ }
21
+
22
+ protected function assemble ()
23
+ {
24
+ $ this ->addElement ('hidden ' , '__FORM_NAME ' , ['value ' => $ this ->name ]);
25
+ $ this ->addElement ('hidden ' , '__FORM_CSRF ' , ['value ' => CsrfToken::generate ()]);
26
+ $ this ->addHtml ($ this ->table );
27
+ }
28
+ }
Original file line number Diff line number Diff line change 10
10
use gipfl \IcingaWeb2 \Table \Extension \ZfSortablePriority ;
11
11
use gipfl \IcingaWeb2 \Table \ZfQueryBasedTable ;
12
12
use gipfl \IcingaWeb2 \Url ;
13
+ use Icinga \Module \Director \Web \Form \CsrfToken ;
14
+ use Icinga \Module \Director \Web \Form \PropertyTableSortForm ;
15
+ use Icinga \Module \Director \Web \Form \QuickForm ;
16
+ use ipl \Html \HtmlString ;
13
17
14
18
class PropertymodifierTable extends ZfQueryBasedTable
15
19
{
@@ -51,7 +55,24 @@ public function render()
51
55
if ($ this ->readOnly ) {
52
56
return parent ::render ();
53
57
}
54
- return $ this ->renderWithSortableForm ();
58
+
59
+ if ($ this ->request === null ) {
60
+ return parent ::render ();
61
+ }
62
+
63
+ if ($ this ->request ->isPost () && $ this ->hasBeenSent ($ this ->request )) {
64
+ if (! CsrfToken::isValid ($ this ->request ->get (QuickForm::CSRF ))) {
65
+ die ('Invalid CSRF token provided ' );
66
+ }
67
+
68
+ $ this ->reallyHandleSortPriorityActions ();
69
+ }
70
+
71
+ $ url = $ this ->request ->getUrl ();
72
+ $ form = (new PropertyTableSortForm ($ this ->getUniqueFormName (), new HtmlString (parent ::render ())))
73
+ ->setAction ($ url ->getAbsoluteUrl ());
74
+
75
+ return $ form ->render ();
55
76
}
56
77
57
78
protected function assemble ()
Original file line number Diff line number Diff line change 6
6
use gipfl \IcingaWeb2 \Link ;
7
7
use gipfl \IcingaWeb2 \Table \Extension \ZfSortablePriority ;
8
8
use gipfl \IcingaWeb2 \Table \ZfQueryBasedTable ;
9
+ use Icinga \Module \Director \Web \Form \CsrfToken ;
10
+ use Icinga \Module \Director \Web \Form \PropertyTableSortForm ;
11
+ use Icinga \Module \Director \Web \Form \QuickForm ;
12
+ use ipl \Html \Form ;
13
+ use ipl \Html \HtmlString ;
9
14
10
15
class SyncpropertyTable extends ZfQueryBasedTable
11
16
{
@@ -33,7 +38,23 @@ public static function create(SyncRule $rule)
33
38
34
39
public function render ()
35
40
{
36
- return $ this ->renderWithSortableForm ();
41
+ if ($ this ->request === null ) {
42
+ return parent ::render ();
43
+ }
44
+
45
+ if ($ this ->request ->isPost () && $ this ->hasBeenSent ($ this ->request )) {
46
+ if (! CsrfToken::isValid ($ this ->request ->get (QuickForm::CSRF ))) {
47
+ die ('Invalid CSRF token provided ' );
48
+ }
49
+
50
+ $ this ->reallyHandleSortPriorityActions ();
51
+ }
52
+
53
+ $ url = $ this ->request ->getUrl ();
54
+ $ form = (new PropertyTableSortForm ($ this ->getUniqueFormName (), new HtmlString (parent ::render ())))
55
+ ->setAction ($ url ->getAbsoluteUrl ());
56
+
57
+ return $ form ->render ();
37
58
}
38
59
39
60
public function renderRow ($ row )
You can’t perform that action at this time.
0 commit comments