summaryrefslogtreecommitdiff
path: root/src/controller/post.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/post.php')
-rw-r--r--src/controller/post.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/controller/post.php b/src/controller/post.php
index 3ba0656..7e6ed53 100644
--- a/src/controller/post.php
+++ b/src/controller/post.php
@@ -132,8 +132,32 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
132 $main = $director->getNode(); 132 $main = $director->getNode();
133 $position = count($main->getChildren()) + 1; // position dans la fraterie 133 $position = count($main->getChildren()) + 1; // position dans la fraterie
134 134
135 $blocs_true_names = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php
136 if(!in_array($_POST["bloc_select"], $blocs_true_names, true)) // 3è param: contrôle du type
137 {
138 header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type']));
139 die;
140 }
141
142 if($_POST["bloc_select"] === 'calendar'){
143 $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page
144 $bulk_data = $entityManager
145 ->createQuery($dql)
146 ->setParameter('page', $page)
147 ->setParameter('name', 'head')
148 ->getResult();
149
150 if(count($bulk_data) != 1){ // 1 head par page
151 header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found']));
152 die;
153 }
154
155 $bulk_data[0]->addAttribute('css_array', 'calendar');
156 $entityManager->persist($bulk_data[0]);
157 }
158
135 $bloc = new Node( 159 $bloc = new Node(
136 trim(htmlspecialchars($_POST["bloc_select"])), 160 $_POST["bloc_select"],
137 null, [], 161 null, [],
138 $position, 162 $position,
139 $main, 163 $main,