diff options
Diffstat (limited to 'src/controller/post.php')
-rw-r--r-- | src/controller/post.php | 463 |
1 files changed, 237 insertions, 226 deletions
diff --git a/src/controller/post.php b/src/controller/post.php index acad1ce..bcafe6f 100644 --- a/src/controller/post.php +++ b/src/controller/post.php | |||
@@ -9,261 +9,272 @@ use App\Entity\Page; | |||
9 | use App\Entity\Image; | 9 | use App\Entity\Image; |
10 | use Doctrine\Common\Collections\ArrayCollection; | 10 | use Doctrine\Common\Collections\ArrayCollection; |
11 | 11 | ||
12 | if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) | 12 | if($_SERVER['REQUEST_METHOD'] === 'POST'){ |
13 | { | 13 | // POST ordinaires non admin |
14 | /* -- formulaires HTML classiques -- */ | 14 | |
15 | if($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') | 15 | // POST ajax non admin |
16 | require '../src/controller/ajax.php'; | ||
17 | |||
18 | if($_SESSION['admin'] === true) | ||
16 | { | 19 | { |
17 | /* -- nouvelle page -- */ | 20 | /* -- formulaires HTML classiques -- */ |
18 | if(isset($_POST['page_name']) && $_POST['page_name'] !== null | 21 | if($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') |
19 | && isset($_POST['page_name_path']) && $_POST['page_name_path'] !== null | ||
20 | && isset($_POST['page_location']) && $_POST['page_location'] !== null | ||
21 | && isset($_POST['page_description']) && $_POST['page_description'] !== null | ||
22 | && isset($_POST['new_page_hidden']) && $_POST['new_page_hidden'] === '') | ||
23 | { | ||
24 | // titre et chemin | ||
25 | $director = new Director($entityManager, true); | ||
26 | //Director::$menu_data = new Menu($entityManager); | ||
27 | $previous_page = Director::$menu_data->findPageById((int)$_POST["page_location"]); // (int) à cause de declare(strict_types=1); | ||
28 | $parent = $previous_page->getParent(); | ||
29 | |||
30 | $page = new Page( | ||
31 | trim(htmlspecialchars($_POST["page_name"])), | ||
32 | trim(htmlspecialchars($_POST["page_name_path"])), | ||
33 | true, true, false, | ||
34 | $previous_page->getPosition(), | ||
35 | $parent); // peut et DOIT être null si on est au 1er niveau | ||
36 | |||
37 | // on a donné à la nouvelle entrée la même position qu'à la précédente, | ||
38 | // addChild l'ajoute à la fin du tableau "children" puis on trie | ||
39 | // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position | ||
40 | if($parent == null){ | ||
41 | $parent = Director::$menu_data; | ||
42 | } | ||
43 | $parent->addChild($page); | ||
44 | $parent->reindexPositions(); | ||
45 | |||
46 | $page->setPagePath(ltrim($parent->getPagePath() . '/' . $page->getEndOfPath(), '/')); | ||
47 | |||
48 | // noeud "head" | ||
49 | $node = new Node( | ||
50 | 'head', | ||
51 | null, [], | ||
52 | 1, // position d'un head = 1 | ||
53 | null, // pas de parent | ||
54 | $page); | ||
55 | $node->useDefaultAttributes(); // fichiers CSS et JS | ||
56 | |||
57 | $data = new NodeData([ | ||
58 | // pas de titre, il est dans $page | ||
59 | 'description' => trim(htmlspecialchars($_POST["page_description"]))], | ||
60 | $node); | ||
61 | |||
62 | $bulk_data = $entityManager | ||
63 | ->createQuery('SELECT n FROM App\Entity\Image n WHERE n.file_name LIKE :name') | ||
64 | ->setParameter('name', '%favicon%') | ||
65 | ->getResult(); | ||
66 | $data->setImages(new ArrayCollection($bulk_data)); | ||
67 | |||
68 | $entityManager->persist($page); | ||
69 | $entityManager->persist($node); | ||
70 | $entityManager->persist($data); | ||
71 | $entityManager->flush(); | ||
72 | |||
73 | // page créée, direction la page en mode modification pour ajouter des blocs | ||
74 | header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page'])); | ||
75 | die; | ||
76 | } | ||
77 | |||
78 | /* -- suppression d'une page -- */ | ||
79 | elseif(isset($_POST['page_id']) && $_POST['page_id'] !== null | ||
80 | && isset($_POST['submit_hidden']) && $_POST['submit_hidden'] === '') | ||
81 | { | 22 | { |
82 | $page = $entityManager->find('App\Entity\Page', (int)$_POST['page_id']); | 23 | /* -- nouvelle page -- */ |
83 | $nodes = $entityManager->getRepository('App\Entity\Node')->findBy(['page' => $page]); | 24 | if(isset($_POST['page_name']) && $_POST['page_name'] !== null |
84 | $data = []; | 25 | && isset($_POST['page_name_path']) && $_POST['page_name_path'] !== null |
85 | foreach($nodes as $node){ | 26 | && isset($_POST['page_location']) && $_POST['page_location'] !== null |
86 | $data[] = $entityManager->getRepository('App\Entity\NodeData')->findOneBy(['node' => $node]); | 27 | && isset($_POST['page_description']) && $_POST['page_description'] !== null |
87 | $entityManager->remove($node); | 28 | && isset($_POST['new_page_hidden']) && $_POST['new_page_hidden'] === '') |
88 | } | 29 | { |
89 | foreach($data as $one_data){ | 30 | // titre et chemin |
90 | $entityManager->remove($one_data); | 31 | $director = new Director($entityManager, true); |
91 | } | 32 | //Director::$menu_data = new Menu($entityManager); |
92 | $entityManager->remove($page); // suppression en BDD | 33 | $previous_page = Director::$menu_data->findPageById((int)$_POST["page_location"]); // (int) à cause de declare(strict_types=1); |
93 | 34 | $parent = $previous_page->getParent(); | |
94 | $entityManager->flush(); | 35 | |
95 | header("Location: " . new URL); | 36 | $page = new Page( |
96 | die; | 37 | trim(htmlspecialchars($_POST["page_name"])), |
97 | } | 38 | trim(htmlspecialchars($_POST["page_name_path"])), |
39 | true, true, false, | ||
40 | $previous_page->getPosition(), | ||
41 | $parent); // peut et DOIT être null si on est au 1er niveau | ||
42 | |||
43 | // on a donné à la nouvelle entrée la même position qu'à la précédente, | ||
44 | // addChild l'ajoute à la fin du tableau "children" puis on trie | ||
45 | // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position | ||
46 | if($parent == null){ | ||
47 | $parent = Director::$menu_data; | ||
48 | } | ||
49 | $parent->addChild($page); | ||
50 | $parent->reindexPositions(); | ||
98 | 51 | ||
52 | $page->setPagePath(ltrim($parent->getPagePath() . '/' . $page->getEndOfPath(), '/')); | ||
99 | 53 | ||
100 | /* -- mode Modification d'une page -- */ | 54 | // noeud "head" |
55 | $node = new Node( | ||
56 | 'head', | ||
57 | null, [], | ||
58 | 1, // position d'un head = 1 | ||
59 | null, // pas de parent | ||
60 | $page); | ||
61 | $node->useDefaultAttributes(); // fichiers CSS et JS | ||
101 | 62 | ||
102 | // modification des titres, chemins et descriptions | 63 | $data = new NodeData([ |
103 | elseif(isset($_POST['page_menu_path']) && $_POST['page_menu_path'] !== null | 64 | // pas de titre, il est dans $page |
104 | && isset($_POST['page_id']) && $_POST['page_id'] !== null | 65 | 'description' => trim(htmlspecialchars($_POST["page_description"]))], |
105 | && isset($_POST['page_name_path_hidden']) && $_POST['page_name_path_hidden'] === '') | 66 | $node); |
106 | { | 67 | |
107 | $director = new Director($entityManager, true); | 68 | $bulk_data = $entityManager |
108 | $page = Director::$page_path->getLast(); | 69 | ->createQuery('SELECT n FROM App\Entity\Image n WHERE n.file_name LIKE :name') |
109 | $path = htmlspecialchars($_POST['page_menu_path']); | 70 | ->setParameter('name', '%favicon%') |
110 | 71 | ->getResult(); | |
111 | // mise en snake_case: filtre caractères non-alphanumériques, minuscule, doublons d'underscore, trim des underscores | 72 | $data->setImages(new ArrayCollection($bulk_data)); |
112 | $path = trim(preg_replace('/_+/', '_', strtolower(preg_replace('/[^a-zA-Z0-9]/', '_', $path))), '_'); | 73 | |
113 | $page->setEndOfPath($path); | 74 | $entityManager->persist($page); |
114 | foreach(Director::$menu_data->getChildren() as $child){ | 75 | $entityManager->persist($node); |
115 | if($child->getEndOfPath() === Director::$page_path->getArray()[0]->getEndOfPath()){ | 76 | $entityManager->persist($data); |
116 | $child->fillChildrenPagePath(); // MAJ de $page_path | 77 | $entityManager->flush(); |
117 | } | 78 | |
79 | // page créée, direction la page en mode modification pour ajouter des blocs | ||
80 | header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page'])); | ||
81 | die; | ||
118 | } | 82 | } |
119 | $entityManager->flush(); | 83 | |
120 | header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page'])); | 84 | /* -- suppression d'une page -- */ |
121 | die; | 85 | elseif(isset($_POST['page_id']) && $_POST['page_id'] !== null |
122 | } | 86 | && isset($_POST['submit_hidden']) && $_POST['submit_hidden'] === '') |
123 | // ajout d'un bloc dans une page | ||
124 | elseif(isset($_POST['bloc_title']) && $_POST['bloc_title'] !== null | ||
125 | && isset($_POST['bloc_select']) && $_POST['bloc_select'] !== null | ||
126 | && isset($_POST['bloc_title_hidden']) && $_POST['bloc_title_hidden'] === '') // contrôle anti-robot avec input hidden | ||
127 | { | ||
128 | $director = new Director($entityManager, true); // on a besoin de page_path qui dépend de menu_data | ||
129 | $page = Director::$page_path->getLast(); | ||
130 | $director->findUniqueNodeByName('main'); | ||
131 | $director->findItsChildren(); | ||
132 | $main = $director->getNode(); | ||
133 | $position = count($main->getChildren()) + 1; // position dans la fraterie | ||
134 | |||
135 | $blocks = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php | ||
136 | if(!in_array($_POST["bloc_select"], $blocks, true)) // 3è param: contrôle du type | ||
137 | { | 87 | { |
138 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); | 88 | $page = $entityManager->find('App\Entity\Page', (int)$_POST['page_id']); |
89 | $nodes = $entityManager->getRepository('App\Entity\Node')->findBy(['page' => $page]); | ||
90 | $data = []; | ||
91 | foreach($nodes as $node){ | ||
92 | $data[] = $entityManager->getRepository('App\Entity\NodeData')->findOneBy(['node' => $node]); | ||
93 | $entityManager->remove($node); | ||
94 | } | ||
95 | foreach($data as $one_data){ | ||
96 | $entityManager->remove($one_data); | ||
97 | } | ||
98 | $entityManager->remove($page); // suppression en BDD | ||
99 | |||
100 | $entityManager->flush(); | ||
101 | header("Location: " . new URL); | ||
139 | die; | 102 | die; |
140 | } | 103 | } |
141 | 104 | ||
142 | if($_POST["bloc_select"] === 'calendar' || $_POST["bloc_select"] === 'form'){ | ||
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 | 105 | ||
150 | if(count($bulk_data) != 1){ // 1 head par page | 106 | /* -- mode Modification d'une page -- */ |
151 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found'])); | ||
152 | die; | ||
153 | } | ||
154 | 107 | ||
155 | $bulk_data[0]->addAttribute('css_array', $_POST["bloc_select"]); | 108 | // modification des titres, chemins et descriptions |
156 | $entityManager->persist($bulk_data[0]); | 109 | elseif(isset($_POST['page_menu_path']) && $_POST['page_menu_path'] !== null |
110 | && isset($_POST['page_id']) && $_POST['page_id'] !== null | ||
111 | && isset($_POST['page_name_path_hidden']) && $_POST['page_name_path_hidden'] === '') | ||
112 | { | ||
113 | $director = new Director($entityManager, true); | ||
114 | $page = Director::$page_path->getLast(); | ||
115 | $path = htmlspecialchars($_POST['page_menu_path']); | ||
116 | |||
117 | // mise en snake_case: filtre caractères non-alphanumériques, minuscule, doublons d'underscore, trim des underscores | ||
118 | $path = trim(preg_replace('/_+/', '_', strtolower(preg_replace('/[^a-zA-Z0-9]/', '_', $path))), '_'); | ||
119 | $page->setEndOfPath($path); | ||
120 | foreach(Director::$menu_data->getChildren() as $child){ | ||
121 | if($child->getEndOfPath() === Director::$page_path->getArray()[0]->getEndOfPath()){ | ||
122 | $child->fillChildrenPagePath(); // MAJ de $page_path | ||
123 | } | ||
124 | } | ||
125 | $entityManager->flush(); | ||
126 | header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page'])); | ||
127 | die; | ||
157 | } | 128 | } |
129 | // ajout d'un bloc dans une page | ||
130 | elseif(isset($_POST['bloc_title']) && $_POST['bloc_title'] !== null | ||
131 | && isset($_POST['bloc_select']) && $_POST['bloc_select'] !== null | ||
132 | && isset($_POST['bloc_title_hidden']) && $_POST['bloc_title_hidden'] === '') // contrôle anti-robot avec input hidden | ||
133 | { | ||
134 | $director = new Director($entityManager, true); // on a besoin de page_path qui dépend de menu_data | ||
135 | $page = Director::$page_path->getLast(); | ||
136 | $director->findUniqueNodeByName('main'); | ||
137 | $director->findItsChildren(); | ||
138 | $main = $director->getNode(); | ||
139 | $position = count($main->getChildren()) + 1; // position dans la fraterie | ||
140 | |||
141 | $blocks = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php | ||
142 | if(!in_array($_POST["bloc_select"], $blocks, true)) // 3è param: contrôle du type | ||
143 | { | ||
144 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); | ||
145 | die; | ||
146 | } | ||
158 | 147 | ||
159 | $bloc = new Node( | 148 | if($_POST["bloc_select"] === 'calendar' || $_POST["bloc_select"] === 'form'){ |
160 | $_POST["bloc_select"], | 149 | $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page |
161 | null, [], | 150 | $bulk_data = $entityManager |
162 | $position, | 151 | ->createQuery($dql) |
163 | $main, | 152 | ->setParameter('page', $page) |
164 | $page); | 153 | ->setParameter('name', 'head') |
165 | $data = new NodeData( | 154 | ->getResult(); |
166 | ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], | 155 | |
167 | $bloc); | 156 | if(count($bulk_data) != 1){ // 1 head par page |
168 | 157 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found'])); | |
169 | $entityManager->persist($bloc); | 158 | die; |
170 | $entityManager->persist($data); | 159 | } |
171 | $entityManager->flush(); | 160 | |
172 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | 161 | $bulk_data[0]->addAttribute('css_array', $_POST["bloc_select"]); |
173 | die; | 162 | if($_POST["bloc_select"] === 'form'){ |
174 | } | 163 | $bulk_data[0]->addAttribute('js_array', $_POST["bloc_select"]); |
175 | // suppression d'un bloc de page | 164 | } |
176 | elseif(isset($_POST['delete_bloc_id']) && $_POST['delete_bloc_id'] !== null | 165 | $entityManager->persist($bulk_data[0]); |
177 | && isset($_POST['delete_bloc_hidden']) && $_POST['delete_bloc_hidden'] === '') // contrôle anti-robot avec input hidden | ||
178 | { | ||
179 | $director = new Director($entityManager, true); | ||
180 | $director->findUniqueNodeByName('main'); | ||
181 | $director->findItsChildren(); | ||
182 | //$director->findNodeById((int)$_POST['delete_bloc_id']); | ||
183 | $main = $director->getNode(); | ||
184 | $bloc; | ||
185 | foreach($main->getChildren() as $child){ | ||
186 | if($child->getId() === (int)$_POST['delete_bloc_id']){ | ||
187 | $bloc = $child; | ||
188 | break; | ||
189 | } | 166 | } |
167 | |||
168 | $bloc = new Node( | ||
169 | $_POST["bloc_select"], | ||
170 | null, [], | ||
171 | $position, | ||
172 | $main, | ||
173 | $page); | ||
174 | $data = new NodeData( | ||
175 | ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], | ||
176 | $bloc); | ||
177 | |||
178 | $entityManager->persist($bloc); | ||
179 | $entityManager->persist($data); | ||
180 | $entityManager->flush(); | ||
181 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | ||
182 | die; | ||
190 | } | 183 | } |
191 | $main->removeChild($bloc); // réindex le tableau $children au passage | 184 | // suppression d'un bloc de page |
192 | $main->reindexPositions(); | 185 | elseif(isset($_POST['delete_bloc_id']) && $_POST['delete_bloc_id'] !== null |
186 | && isset($_POST['delete_bloc_hidden']) && $_POST['delete_bloc_hidden'] === '') // contrôle anti-robot avec input hidden | ||
187 | { | ||
188 | $director = new Director($entityManager, true); | ||
189 | $director->findUniqueNodeByName('main'); | ||
190 | $director->findItsChildren(); | ||
191 | //$director->findNodeById((int)$_POST['delete_bloc_id']); | ||
192 | $main = $director->getNode(); | ||
193 | $bloc; | ||
194 | foreach($main->getChildren() as $child){ | ||
195 | if($child->getId() === (int)$_POST['delete_bloc_id']){ | ||
196 | $bloc = $child; | ||
197 | break; | ||
198 | } | ||
199 | } | ||
200 | $main->removeChild($bloc); // réindex le tableau $children au passage | ||
201 | $main->reindexPositions(); | ||
193 | 202 | ||
194 | $entityManager->remove($bloc); // suppression en BDD | 203 | $entityManager->remove($bloc); // suppression en BDD |
195 | $entityManager->flush(); | 204 | $entityManager->flush(); |
196 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | 205 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); |
197 | die; | 206 | die; |
198 | } | 207 | } |
199 | 208 | ||
200 | 209 | ||
201 | /* -- page Menu et chemins -- */ | 210 | /* -- page Menu et chemins -- */ |
202 | 211 | ||
203 | // création d'une entrée de menu avec une URL | 212 | // création d'une entrée de menu avec une URL |
204 | elseif(isset($_POST["label_input"]) && isset($_POST["url_input"]) && isset($_POST["location"])){ | 213 | elseif(isset($_POST["label_input"]) && isset($_POST["url_input"]) && isset($_POST["location"])){ |
205 | Director::$menu_data = new Menu($entityManager); | 214 | Director::$menu_data = new Menu($entityManager); |
206 | $previous_page = Director::$menu_data->findPageById((int)$_POST["location"]); // (int) à cause de declare(strict_types=1); | 215 | $previous_page = Director::$menu_data->findPageById((int)$_POST["location"]); // (int) à cause de declare(strict_types=1); |
207 | $parent = $previous_page->getParent(); | 216 | $parent = $previous_page->getParent(); |
208 | 217 | ||
209 | $page = new Page( | 218 | $page = new Page( |
210 | trim(htmlspecialchars($_POST["label_input"])), | 219 | trim(htmlspecialchars($_POST["label_input"])), |
211 | filter_var($_POST["url_input"], FILTER_VALIDATE_URL), | 220 | filter_var($_POST["url_input"], FILTER_VALIDATE_URL), |
212 | true, true, false, | 221 | true, true, false, |
213 | $previous_page->getPosition(), | 222 | $previous_page->getPosition(), |
214 | $parent); // peut et DOIT être null si on est au 1er niveau | 223 | $parent); // peut et DOIT être null si on est au 1er niveau |
215 | 224 | ||
216 | // on a donné à la nouvelle entrée la même position qu'à la précédente, | 225 | // on a donné à la nouvelle entrée la même position qu'à la précédente, |
217 | // addChild l'ajoute à la fin du tableau "children" puis on trie | 226 | // addChild l'ajoute à la fin du tableau "children" puis on trie |
218 | // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position | 227 | // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position |
219 | if($parent == null){ | 228 | if($parent == null){ |
220 | $parent = Director::$menu_data; | 229 | $parent = Director::$menu_data; |
221 | } | 230 | } |
222 | $parent->addChild($page); // true pour réindexer les positions en BDD | 231 | $parent->addChild($page); // true pour réindexer les positions en BDD |
223 | $parent->reindexPositions(); | 232 | $parent->reindexPositions(); |
224 | 233 | ||
225 | $entityManager->persist($page); | 234 | $entityManager->persist($page); |
226 | $entityManager->flush(); | 235 | $entityManager->flush(); |
227 | header("Location: " . new URL(['page' => $_GET['from']])); | 236 | header("Location: " . new URL(['page' => $_GET['from']])); |
228 | die; | 237 | die; |
229 | } | ||
230 | // suppression d'une entrée de menu avec une URL | ||
231 | elseif(isset($_POST['delete']) && isset($_POST['x']) && isset($_POST['y'])){ // 2 params x et y sont là parce qu'on a cliqué sur une image | ||
232 | Director::$menu_data = new Menu($entityManager); | ||
233 | $page = Director::$menu_data->findPageById((int)$_POST["delete"]); | ||
234 | $parent = $page->getParent(); | ||
235 | if($parent == null){ | ||
236 | $parent = Director::$menu_data; | ||
237 | } | 238 | } |
239 | // suppression d'une entrée de menu avec une URL | ||
240 | elseif(isset($_POST['delete']) && isset($_POST['x']) && isset($_POST['y'])){ // 2 params x et y sont là parce qu'on a cliqué sur une image | ||
241 | Director::$menu_data = new Menu($entityManager); | ||
242 | $page = Director::$menu_data->findPageById((int)$_POST["delete"]); | ||
243 | $parent = $page->getParent(); | ||
244 | if($parent == null){ | ||
245 | $parent = Director::$menu_data; | ||
246 | } | ||
238 | 247 | ||
239 | $parent->removeChild($page); // suppression de $children avant de trier | 248 | $parent->removeChild($page); // suppression de $children avant de trier |
240 | $parent->reindexPositions(); | 249 | $parent->reindexPositions(); |
241 | 250 | ||
242 | $entityManager->remove($page); // suppression en BDD | 251 | $entityManager->remove($page); // suppression en BDD |
243 | $entityManager->flush(); | 252 | $entityManager->flush(); |
244 | header("Location: " . new URL(['page' => $_GET['from']])); | 253 | header("Location: " . new URL(['page' => $_GET['from']])); |
245 | die; | 254 | die; |
246 | } | 255 | } |
247 | elseif(isset($_GET['action']) && $_GET['action'] === 'modif_mdp' | 256 | elseif(isset($_GET['action']) && $_GET['action'] === 'modif_mdp' |
248 | && isset($_POST['login']) && isset($_POST['old_password']) && isset($_POST['new_password']) | 257 | && isset($_POST['login']) && isset($_POST['old_password']) && isset($_POST['new_password']) |
249 | && isset($_POST['modify_password_hidden']) && empty($_POST['modify_password_hidden'])) | 258 | && isset($_POST['modify_password_hidden']) && empty($_POST['modify_password_hidden'])) |
250 | { | 259 | { |
251 | changePassword($entityManager); | 260 | changePassword($entityManager); |
252 | header("Location: " . new URL(['page' => $_GET['from']])); | 261 | header("Location: " . new URL(['page' => $_GET['from']])); |
253 | die; | 262 | die; |
263 | } | ||
264 | else{ | ||
265 | header("Location: " . new URL(['error' => 'paramètres inconnus'])); | ||
266 | die; | ||
267 | } | ||
254 | } | 268 | } |
269 | |||
270 | /* -- requêtes AJAX -- */ | ||
255 | else{ | 271 | else{ |
256 | header("Location: " . new URL(['error' => 'paramètres inconnus'])); | 272 | require '../src/controller/ajax_admin.php'; |
257 | die; | ||
258 | } | 273 | } |
259 | } | ||
260 | 274 | ||
261 | /* -- requêtes AJAX -- */ | 275 | require '../src/controller/ajax_calendar_admin.php'; |
262 | else{ | ||
263 | require '../src/controller/ajax.php'; | ||
264 | } | 276 | } |
265 | |||
266 | require '../src/controller/ajax_calendar_admin.php'; | ||
267 | } | 277 | } |
268 | 278 | elseif($_SERVER['REQUEST_METHOD'] === 'GET'){ | |
269 | require '../src/controller/ajax_calendar_visitor.php'; | 279 | require '../src/controller/ajax_calendar_visitor.php'; // fullcalendar utilise un GET pour récupérer les données |
280 | } \ No newline at end of file | ||