GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0c8258...8d1f3d )
by Luis Ramón
24:24 queued 21:31
created

GroupController::studentReportAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
/*
3
  ÁTICA - Aplicación web para la gestión documental de centros educativos
4
5
  Copyright (C) 2015-2016: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Controller;
22
23
use AppBundle\Entity\Agreement;
24
use AppBundle\Entity\Group;
25
use AppBundle\Entity\User;
26
use Doctrine\ORM\EntityManager;
27
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
28
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
29
use Symfony\Component\HttpFoundation\Request;
30
31
/**
32
 * @Route("/alumnado")
33
 * @Security("is_granted('ROLE_GROUP_TUTOR')")
34
 */
35
class GroupController extends BaseController
36
{
37
    /**
38
     * @Route("", name="admin_tutor_group", methods={"GET"})
39
     */
40
    public function groupIndexAction(Request $request)
41
    {
42
        /** @var EntityManager $em */
43
        $em = $this->getDoctrine()->getManager();
44
45
        /** @var User $user */
46
        $user = $this->getUser();
47
48
        $qb = $em->getRepository('AppBundle:Group')
49
            ->createQueryBuilder('g')
50
            ->innerJoin('g.training', 't')
51
            ->innerJoin('t.department', 'd')
52
            ->orderBy('d.name')
53
            ->addOrderBy('t.name')
54
            ->addOrderBy('g.name');
55
56
        if (!$user->isGlobalAdministrator()) {
57
            $qb = $qb
58
                ->where('g.id IN (:groups)')
59
                ->orWhere('d.head = :user')
60
                ->setParameter('groups', $user->getTutorizedGroups()->toArray())
61
                ->setParameter('user', $user);
62
        }
63
64
        $items = $qb->getQuery()->getResult();
65
66
        if (count($items) == 1) {
67
            return $this->groupDetailIndexAction($items[0], $request);
68
        }
69
70
        return $this->render('group/group_index.html.twig',
71
            [
72
                'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('admin_tutor_group'),
73
                'title' => null,
74
                'elements' => $items
75
            ]);
76
    }
77
78
    /**
79
     * @Route("/grupo/{id}", name="admin_group_students", methods={"GET"})
80
     * @Security("is_granted('GROUP_MANAGE', group)")
81
     */
82 View Code Duplication
    public function groupDetailIndexAction(Group $group, Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
    {
84
        /** @var EntityManager $em */
85
        $em = $this->getDoctrine()->getManager();
86
87
        $usersQuery = $em->createQuery('SELECT u FROM AppBundle:User u WHERE u.studentGroup = :group')
88
            ->setParameter('group', $group);
89
90
        $paginator = $this->get('knp_paginator');
91
        $pagination = $paginator->paginate(
92
            $usersQuery,
93
            $request->query->getInt('page', 1),
94
            $this->getParameter('page.size'),
95
            [
96
                'defaultSortFieldName' => 'u.lastName',
97
                'defaultSortDirection' => 'asc'
98
            ]
99
        );
100
101
        return $this->render('group/manage_students.html.twig', [
102
            'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('admin_tutor_group'),
103
            'breadcrumb' => [
104
                ['fixed' => (string) $group],
105
            ],
106
            'title' => $group->getName(),
107
            'pagination' => $pagination
108
        ]);
109
110
    }
111
112
    /**
113
     * @Route("/alumnado/estudiante/{id}", name="student_detail", methods={"GET", "POST"})
114
     * @Security("is_granted('GROUP_MANAGE', student.getStudentGroup())")
115
     */
116
    public function studentIndexAction(User $student, Request $request)
117
    {
118
        $form = $this->createForm('AppBundle\Form\Type\StudentUserType', $student, [
119
            'admin' => $this->isGranted('ROLE_ADMIN')
120
        ]);
121
122
        $form->handleRequest($request);
123
124 View Code Duplication
        if ($form->isSubmitted() && $form->isValid()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
125
126
            // Guardar el usuario en la base de datos
127
128
            // Probar a guardar los cambios
129
            try {
130
                $this->getDoctrine()->getManager()->flush();
131
                $this->addFlash('success', $this->get('translator')->trans('alert.saved', [], 'student'));
132
                return $this->redirectToRoute('admin_group_students', ['id' => $student->getStudentGroup()->getId()]);
133
            } catch (\Exception $e) {
134
                $this->addFlash('error', $this->get('translator')->trans('alert.not_saved', [], 'student'));
135
            }
136
        }
137
        return $this->render('group/form_student.html.twig',
138
            [
139
                'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('admin_tutor_group'),
140
                'breadcrumb' => [
141
                    ['fixed' => $student->getStudentGroup()->getName(), 'path' => 'admin_group_students', 'options' => ['id' => $student->getStudentGroup()->getId()]],
142
                    ['fixed' => (string) $student],
143
                ],
144
                'title' => (string) $student,
145
                'user' => $student,
146
                'form' => $form->createView()
147
            ]);
148
    }
149
    /**
150
     * @Route("/seguimiento/informe/{id}", name="admin_group_agreement_report_form", methods={"GET", "POST"})
151
     * @Security("is_granted('AGREEMENT_REPORT', agreement)")
152
     */
153 View Code Duplication
    public function studentReportAction(Agreement $agreement, Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
154
    {
155
        $breadcrumb = [
156
            ['fixed' => $agreement->getStudent()->getStudentGroup()->getName(), 'path' => 'admin_group_students', 'options' => ['id' => $agreement->getStudent()->getStudentGroup()->getId()]],
157
            ['fixed' => (string) $agreement->getStudent(), 'path' => 'admin_group_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]],
158
            ['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'admin_group_student_calendar', 'options' => ['id' => $agreement->getId()]],
159
            ['fixed' => $this->get('translator')->trans('form.report', [], 'student')]
160
        ];
161
162
        $routes = ['admin_group_student_calendar', 'admin_group_agreement_report_download'];
163
164
        return $this->workTutorReportAction($agreement, $request, $breadcrumb, $routes, 'group/report_form.html.twig');
165
    }
166
}
167