27 lines
954 B
PHP
27 lines
954 B
PHP
<?php
|
|
require_once $GLOBALS['app_path'].'Framework/Controller.php';
|
|
|
|
abstract class ControllerSecureUserCam extends Controller
|
|
{
|
|
public function executeAction($action)
|
|
{
|
|
if ($this->request->getSession()->existAttribute("user_id"))
|
|
{
|
|
$user_id = $this->request->getSession()->getAttribute("user_id");
|
|
if($this->request->existParameter('id'))
|
|
{
|
|
$camera_id = $this->request->getParameter('id');
|
|
$modelCamera = new ModelCamera();
|
|
if($modelCamera->userCanAccessCam($user_id,$camera_id))
|
|
parent::executeAction($action);
|
|
else
|
|
throw new Exception('Vous n\'avez pas accès à cette caméra');
|
|
}
|
|
else
|
|
throw new Exception('Id caméra non spécifié');
|
|
}
|
|
else {
|
|
$this->redirect("connexion");
|
|
}
|
|
}
|
|
} |