Skip to content

Commit

Permalink
improv. fix ordered navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcoo authored Dec 5, 2021
1 parent 0a7a41d commit 7c87e07
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/Controller/NavbarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function admin_index()
public function admin_save_ajax()
{
$this->autoRender = false;
$this->response->type('json');
if ($this->isConnected and $this->Permissions->can('MANAGE_NAV')) {

if ($this->request->is('post')) {
if (!empty($this->request->data)) {
$data = $this->request->data['xss']['nav'];
Expand All @@ -68,7 +68,7 @@ public function admin_save_ajax()
$data = $data1;
$this->loadModel('Navbar');
foreach ($data as $key => $value) {
$find = $this->Navbar->find('first', ['conditions' => ['name' => $key]]);
$find = $this->Navbar->find('first', ['conditions' => ['id' => $key]]);
if (!empty($find)) {
$id = $find['Navbar']['id'];
$this->Navbar->read(null, $id);
Expand All @@ -82,16 +82,15 @@ public function admin_save_ajax()
}
}
if (empty($error)) {
$this->History->set('EDIT_NAVBAR', 'navbar');
echo $this->Lang->get('NAVBAR__SAVE_SUCCESS') . '|true';
return $this->response->body(json_encode(['statut' => true, 'msg' => $this->Lang->get('NAVBAR__SAVE_SUCCESS')]));
} else {
echo $this->Lang->get('ERROR__INTERNAL_ERROR') . '|false';
return $this->response->body(json_encode(['statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')]));
}
} else {
echo $this->Lang->get('ERROR__FILL_ALL_FIELDS') . '|false';
return $this->response->body(json_encode(['statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')]));
}
} else {
echo $this->Lang->get('ERROR__BAD_REQUEST') . '|false';
return $this->response->body(json_encode(['statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST')]));
}
} else {
$this->redirect('/');
Expand Down

0 comments on commit 7c87e07

Please sign in to comment.