|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* @author Xavier Chopin <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace App\Controller; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
14
|
|
|
|
|
15
|
|
|
class HomeController extends AbstractController |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Render the home page. |
|
20
|
|
|
* |
|
21
|
|
|
* @Route("/", name="home") |
|
22
|
|
|
* @param Request $request |
|
23
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
24
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
25
|
|
|
*/ |
|
26
|
|
|
public function index(Request $request) |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
if (self::isUp()) |
|
29
|
|
|
return $this->render('home.twig'); |
|
30
|
|
|
else |
|
31
|
|
|
return $this->render('Error/unavailable.twig'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Leave the "View as" mode. |
|
36
|
|
|
* |
|
37
|
|
|
* @Route("/view/actions/leave", name="leave-view-as") |
|
38
|
|
|
* @param Request $request |
|
39
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse |
|
40
|
|
|
*/ |
|
41
|
|
|
public function leaveViewAs(Request $request) |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
$_SESSION['phpCAS']['user'] = $_SESSION['username']; |
|
44
|
|
|
unset($_SESSION['username']); |
|
45
|
|
|
return $this->redirectToRoute('home'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Redirect to "View as" form page by giving back admin rights. |
|
50
|
|
|
* |
|
51
|
|
|
* @Route("/view/actions/new", name="new-view-as") |
|
52
|
|
|
* @param Request $request |
|
53
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse |
|
54
|
|
|
*/ |
|
55
|
|
|
public function changeViewAsTarget(Request $request) |
|
|
|
|
|
|
56
|
|
|
{ |
|
57
|
|
|
$_SESSION['phpCAS']['user'] = $_SESSION['username']; |
|
58
|
|
|
unset($_SESSION['username']); |
|
59
|
|
|
return $this->redirectToRoute('view-as'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.