@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use Symfony\Component\Dotenv\Dotenv; |
| 6 | 6 | use Symfony\Component\HttpFoundation\Request; |
| 7 | 7 | |
| 8 | -require __DIR__.'/../vendor/autoload.php'; |
|
| 8 | +require __DIR__ . '/../vendor/autoload.php'; |
|
| 9 | 9 | |
| 10 | 10 | session_start(); |
| 11 | 11 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | if (!class_exists(Dotenv::class)) { |
| 15 | 15 | throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); |
| 16 | 16 | } |
| 17 | - (new Dotenv())->load(__DIR__.'/../.env'); |
|
| 17 | + (new Dotenv())->load(__DIR__ . '/../.env'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) { |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function getCacheDir() |
| 18 | 18 | { |
| 19 | - return $this->getProjectDir().'/var/cache/'.$this->environment; |
|
| 19 | + return $this->getProjectDir() . '/var/cache/' . $this->environment; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function getLogDir() |
| 23 | 23 | { |
| 24 | - return $this->getProjectDir().'/var/log'; |
|
| 24 | + return $this->getProjectDir() . '/var/log'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function registerBundles() |
| 28 | 28 | { |
| 29 | - $contents = require $this->getProjectDir().'/config/bundles.php'; |
|
| 29 | + $contents = require $this->getProjectDir() . '/config/bundles.php'; |
|
| 30 | 30 | foreach ($contents as $class => $envs) { |
| 31 | 31 | if (isset($envs['all']) || isset($envs[$this->environment])) { |
| 32 | 32 | yield new $class(); |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $container->setParameter('container.autowiring.strict_mode', true); |
| 40 | 40 | $container->setParameter('container.dumper.inline_class_loader', true); |
| 41 | - $confDir = $this->getProjectDir().'/config'; |
|
| 42 | - $loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob'); |
|
| 43 | - if (is_dir($confDir.'/packages/'.$this->environment)) { |
|
| 44 | - $loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); |
|
| 41 | + $confDir = $this->getProjectDir() . '/config'; |
|
| 42 | + $loader->load($confDir . '/packages/*' . self::CONFIG_EXTS, 'glob'); |
|
| 43 | + if (is_dir($confDir . '/packages/' . $this->environment)) { |
|
| 44 | + $loader->load($confDir . '/packages/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); |
|
| 45 | 45 | } |
| 46 | - $loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob'); |
|
| 47 | - $loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS, 'glob'); |
|
| 46 | + $loader->load($confDir . '/services' . self::CONFIG_EXTS, 'glob'); |
|
| 47 | + $loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | protected function configureRoutes(RouteCollectionBuilder $routes) |
| 51 | 51 | { |
| 52 | - $confDir = $this->getProjectDir().'/config'; |
|
| 53 | - if (is_dir($confDir.'/routes/')) { |
|
| 54 | - $routes->import($confDir.'/routes/*'.self::CONFIG_EXTS, '/', 'glob'); |
|
| 52 | + $confDir = $this->getProjectDir() . '/config'; |
|
| 53 | + if (is_dir($confDir . '/routes/')) { |
|
| 54 | + $routes->import($confDir . '/routes/*' . self::CONFIG_EXTS, '/', 'glob'); |
|
| 55 | 55 | } |
| 56 | - if (is_dir($confDir.'/routes/'.$this->environment)) { |
|
| 57 | - $routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); |
|
| 56 | + if (is_dir($confDir . '/routes/' . $this->environment)) { |
|
| 57 | + $routes->import($confDir . '/routes/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); |
|
| 58 | 58 | } |
| 59 | - $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); |
|
| 59 | + $routes->import($confDir . '/routes' . self::CONFIG_EXTS, '/', 'glob'); |
|
| 60 | 60 | } |
| 61 | 61 | } |
@@ -83,10 +83,10 @@ |
||
| 83 | 83 | */ |
| 84 | 84 | public function languagesAvailable() |
| 85 | 85 | { |
| 86 | - $languages = []; |
|
| 87 | - foreach ($this->container->getParameter('dictionaries') as $languageId => $dictionary) { |
|
| 88 | - $languages += [ $dictionary['self_name'] => $languageId ]; |
|
| 89 | - } |
|
| 86 | + $languages = []; |
|
| 87 | + foreach ($this->container->getParameter('dictionaries') as $languageId => $dictionary) { |
|
| 88 | + $languages += [ $dictionary['self_name'] => $languageId ]; |
|
| 89 | + } |
|
| 90 | 90 | return $languages; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | { |
| 86 | 86 | $languages = []; |
| 87 | 87 | foreach ($this->container->getParameter('dictionaries') as $languageId => $dictionary) { |
| 88 | - $languages += [ $dictionary['self_name'] => $languageId ]; |
|
| 88 | + $languages += [$dictionary['self_name'] => $languageId]; |
|
| 89 | 89 | } |
| 90 | 90 | return $languages; |
| 91 | 91 | } |
@@ -43,6 +43,6 @@ |
||
| 43 | 43 | |
| 44 | 44 | public static function getSubscribedEvents() |
| 45 | 45 | { |
| 46 | - return [ KernelEvents::CONTROLLER => 'onKernelController' ]; |
|
| 46 | + return [KernelEvents::CONTROLLER => 'onKernelController']; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -36,17 +36,21 @@ |
||
| 36 | 36 | if ($controller[0] instanceof AdminAuthenticatedController) { |
| 37 | 37 | $isAdmin = false; |
| 38 | 38 | if (isset($_SESSION['phpCAS']['user'])) { |
| 39 | - if (in_array($_SESSION['phpCAS']['user'], $this->administrators)) |
|
| 40 | - $isAdmin = true; |
|
| 39 | + if (in_array($_SESSION['phpCAS']['user'], $this->administrators)) { |
|
| 40 | + $isAdmin = true; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + if (!$isAdmin) { |
|
| 44 | + throw new AccessDeniedHttpException('Access forbidden.'); |
|
| 41 | 45 | } |
| 42 | - if (!$isAdmin) throw new AccessDeniedHttpException('Access forbidden.'); |
|
| 43 | 46 | } |
| 44 | 47 | } |
| 45 | 48 | |
| 46 | 49 | public function onKernelRequest(GetResponseEvent $event) |
| 47 | 50 | { |
| 48 | - if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) |
|
| 49 | - return; |
|
| 51 | + if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 50 | 54 | } |
| 51 | 55 | |
| 52 | 56 | |
@@ -58,6 +58,6 @@ |
||
| 58 | 58 | |
| 59 | 59 | public static function getSubscribedEvents() |
| 60 | 60 | { |
| 61 | - return [ KernelEvents::REQUEST => [['onKernelRequest', 200]] ]; |
|
| 61 | + return [KernelEvents::REQUEST => [['onKernelRequest', 200]]]; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | \ No newline at end of file |
@@ -33,8 +33,9 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function onKernelRequest(GetResponseEvent $event) |
| 35 | 35 | { |
| 36 | - if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) |
|
| 37 | - return; |
|
| 36 | + if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 38 | 39 | |
| 39 | 40 | $this->registerLDAP(); |
| 40 | 41 | $this->registerCapsule(); |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | $students = $this->ldap($filter, ['displayname', 'uid']); |
| 38 | 38 | $res = []; |
| 39 | 39 | |
| 40 | - foreach($students as $student) { |
|
| 40 | + foreach ($students as $student) { |
|
| 41 | 41 | if ($student['uid'][0] != null) |
| 42 | - $res += [ $student['uid'][0] => $student['displayname'][0] ]; |
|
| 42 | + $res += [$student['uid'][0] => $student['displayname'][0]]; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | return $this->json($res); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | array_push($classes, $enrollment->class); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - return $this->render('admin/user.twig',[ |
|
| 80 | + return $this->render('admin/user.twig', [ |
|
| 81 | 81 | 'classes' => $classes, |
| 82 | 82 | 'student_name' => $this->ldapFirst("uid=$id")['displayname'][0] |
| 83 | 83 | ]); |
@@ -38,8 +38,9 @@ discard block |
||
| 38 | 38 | $res = []; |
| 39 | 39 | |
| 40 | 40 | foreach($students as $student) { |
| 41 | - if ($student['uid'][0] != null) |
|
| 42 | - $res += [ $student['uid'][0] => $student['displayname'][0] ]; |
|
| 41 | + if ($student['uid'][0] != null) { |
|
| 42 | + $res += [ $student['uid'][0] => $student['displayname'][0] ]; |
|
| 43 | + } |
|
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | return $this->json($res); |
@@ -73,8 +74,9 @@ discard block |
||
| 73 | 74 | ]); |
| 74 | 75 | |
| 75 | 76 | foreach (json_decode($enrollments->getBody()->getContents()) as $enrollment) { |
| 76 | - if ($enrollment->class->title != null) |
|
| 77 | - array_push($classes, $enrollment->class); |
|
| 77 | + if ($enrollment->class->title != null) { |
|
| 78 | + array_push($classes, $enrollment->class); |
|
| 79 | + } |
|
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | return $this->render('admin/user.twig',[ |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 7 | 7 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 8 | 8 | |
| 9 | - abstract class AbstractController extends Controller |
|
| 9 | + abstract class AbstractController extends Controller |
|
| 10 | 10 | { |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'password' => env('API_PASSWORD') |
| 40 | 40 | ] |
| 41 | 41 | ])->getBody() |
| 42 | - ->getContents()); |
|
| 42 | + ->getContents()); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -32,8 +32,8 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | protected function createJWT() |
| 34 | 34 | { |
| 35 | - return json_decode( $this->http->request('POST', 'auth/login', [ |
|
| 36 | - 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' ], |
|
| 35 | + return json_decode($this->http->request('POST', 'auth/login', [ |
|
| 36 | + 'headers' => ['X-Requested-With' => 'XMLHttpRequest'], |
|
| 37 | 37 | 'json' => [ |
| 38 | 38 | 'username' => env('API_USERNAME'), |
| 39 | 39 | 'password' => env('API_PASSWORD') |