Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- #
- # ManageController.php
- #
- # This file handle the backoffice management of the site.
- #
- #
- */
- namespace App\Controller;
- use App\Controller\AppController;
- use Authorization\Policy\MapResolver;
- class ManageController extends AppController{
- public function initialize(): void
- {
- parent::initialize();
- $this->loadModel('Users');
- $this->Authentication->allowUnauthenticated(['index', 'users']);
- $this->Authorization->authorize($this);
- }
- public function index()
- {
- //$this->Authorization->authorize($this, 'index');
- $this->viewBuilder()->setLayout('adminlayout');
- //$this->layout='adminlayout';
- }
- public function users()
- {
- //$session = $this->request->getSession();
- $resultset = $this->Users->find()->all();
- $this->set('userlist', $resultset);
- }
- public function updateuser(){
- if ($this->request->is('post')) {
- $user = $this->Users->get($this->request->getData('id'));
- $user->username = $this->request->getData('username');
- $user->firstname = $this->request->getData('firstname');
- $user->surname = $this->request->getData('surname');
- $user->email = $this->request->getData('email');
- $user->editedon = date("Y-m-d H:i:s");
- $this->Users->save($user);
- $this->Flash->success('User has been successfully updated.');
- return $this->redirect(
- ['controller' => 'manage', 'action' => 'users']
- );
- }else{
- $this->Flash->error('No POST data received.');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement