1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the vseth-semesterly-reports project. |
5
|
|
|
* |
6
|
|
|
* (c) Florian Moser <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace App\Controller; |
13
|
|
|
|
14
|
|
|
use App\Controller\Administration\Base\BaseController; |
15
|
|
|
use App\Entity\Organisation; |
16
|
|
|
use App\Form\Type\SemesterType; |
17
|
|
|
use App\Service\Interfaces\CsvServiceInterface; |
18
|
|
|
use App\Service\Interfaces\EvaluationServiceInterface; |
19
|
|
|
use Symfony\Component\HttpFoundation\Response; |
20
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
21
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @Route("/administration") |
25
|
|
|
*/ |
26
|
|
|
class AdministrationController extends BaseController |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @Route("", name="administration") |
30
|
|
|
* |
31
|
|
|
* @return Response |
32
|
|
|
*/ |
33
|
|
|
public function indexAction(EvaluationServiceInterface $evaluationService) |
34
|
|
|
{ |
35
|
|
|
$semesterEvaluation = $evaluationService->getActiveSemesterEvaluation(); |
36
|
|
|
$currentSemester = SemesterType::getCurrentSemester(); |
37
|
|
|
|
38
|
|
|
return $this->render('administration.html.twig', ['semesterEvaluation' => $semesterEvaluation, 'currentSemester' => $currentSemester]); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @Route("/export_authentication_links", name="administration_export_authentication_links") |
43
|
|
|
* |
44
|
|
|
* @return Response |
45
|
|
|
*/ |
46
|
|
|
public function exportAuthenticationLinksAction(CsvServiceInterface $csvService) |
47
|
|
|
{ |
48
|
|
|
//get all existing semesters |
49
|
|
|
/** @var Organisation[] $organisations */ |
50
|
|
|
$organisations = $this->getDoctrine()->getRepository(Organisation::class)->findActive(); |
51
|
|
|
|
52
|
|
|
$organisationArray = []; |
53
|
|
|
foreach ($organisations as $organisation) { |
54
|
|
|
$entry = []; |
55
|
|
|
$entry[] = $organisation->getName(); |
56
|
|
|
$entry[] = $organisation->getEmail(); |
57
|
|
|
$entry[] = $this->generateUrl('login_code', ['code' => $organisation->getAuthenticationCode()], UrlGeneratorInterface::ABSOLUTE_URL); |
58
|
|
|
|
59
|
|
|
$organisationArray[] = $entry; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $csvService->streamCsv('authentication_links.csv', $organisationArray); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|