Commit 673e2eae113f5fe46c250add6e63901b8a8ba2a8

Authored by Eduardo Santos
2 parents 4fe6eb59 a78b0577
Exists in master and in 1 other branch 3.1

Versão com upload automático do módulo agente.

app/Resources/views/base.html.twig
@@ -27,6 +27,13 @@ @@ -27,6 +27,13 @@
27 {% endstylesheets %} 27 {% endstylesheets %}
28 28
29 <link href="{{ asset('bundles/caciccommon/libs/googleapis.fonts.css') }}" rel="stylesheet"> 29 <link href="{{ asset('bundles/caciccommon/libs/googleapis.fonts.css') }}" rel="stylesheet">
  30 +
  31 + <!-- javascript
  32 + ================================================== -->
  33 + <!-- Placed at the top of the document so thinks work -->
  34 + <!-- jQuery (UI) -->
  35 + <script type="text/javascript" src="{{ asset('bundles/caciccommon/libs/jquery.1.7.1.min.js') }}"></script>
  36 + <script type="text/javascript" src="{{ asset('bundles/caciccommon/libs/jquery-ui-1.8.17.min.js') }}"></script>
30 37
31 {% endblock %} 38 {% endblock %}
32 39
@@ -164,13 +171,6 @@ @@ -164,13 +171,6 @@
164 </div><!--/.fluid-container--> 171 </div><!--/.fluid-container-->
165 172
166 {% block javascripts %} 173 {% block javascripts %}
167 -  
168 - <!-- javascript  
169 - ================================================== -->  
170 - <!-- Placed at the end of the document so the pages load faster -->  
171 - <!-- jQuery (UI) -->  
172 - <script type="text/javascript" src="{{ asset('bundles/caciccommon/libs/jquery.1.7.1.min.js') }}"></script>  
173 - <script type="text/javascript" src="{{ asset('bundles/caciccommon/libs/jquery-ui-1.8.17.min.js') }}"></script>  
174 174
175 175
176 {% javascripts output='assets/base.js' combine=true 176 {% javascripts output='assets/base.js' combine=true
app/config/config.yml
@@ -153,14 +153,35 @@ knp_paginator: @@ -153,14 +153,35 @@ knp_paginator:
153 153
154 # Configuration for FMElFinderBundle 154 # Configuration for FMElFinderBundle
155 fm_elfinder: 155 fm_elfinder:
156 - locale: %locale%  
157 - editor: simple  
158 - compression: false  
159 - connector:  
160 - roots:  
161 - downloads:  
162 - driver: elfinder.driver.filesystem  
163 - path: downloads 156 + instances:
  157 + default:
  158 + locale: %locale% # defaults to current request locale
  159 + editor: simple # other choices are tinymce or simple, and form
  160 + compression: false # enable if you configured the uglifycss and uglifyjs2 assetic filters and want compression
  161 + connector:
  162 + roots: # at least one root must be defined
  163 + uploads:
  164 + showhidden: false # defaults to false
  165 + driver: LocalFileSystem
  166 + path: downloads
  167 + upload_max_size: 2M
  168 + upload_deny: ['all']
  169 + form:
  170 + locale: %locale% # defaults to current request locale
  171 + editor: form # other choices are tinymce or simple, and form
  172 + compression: false # enable if you configured the uglifycss and uglifyjs2 assetic filters and want compression
  173 + connector:
  174 + roots: # at least one root must be defined
  175 + cacic:
  176 + showhidden: false # defaults to false
  177 + driver: LocalFileSystem
  178 + path: downloads/cacic
  179 + upload_deny: ['all']
  180 + outros:
  181 + showhidden: false # defaults to false
  182 + driver: LocalFileSystem
  183 + path: downloads/outros
  184 + upload_deny: ['all']
164 185
165 jms_translation: 186 jms_translation:
166 configs: 187 configs:
@@ -215,5 +236,4 @@ services: @@ -215,5 +236,4 @@ services:
215 236
216 apikey_authenticator: 237 apikey_authenticator:
217 class: Cacic\WSBundle\Security\ApiKeyAuthenticator 238 class: Cacic\WSBundle\Security\ApiKeyAuthenticator
218 - arguments: ["@webservice_user_provider"]  
219 - 239 + arguments: ["@webservice_user_provider"]
220 \ No newline at end of file 240 \ No newline at end of file
app/config/config_test.yml
@@ -23,4 +23,10 @@ web_profiler: @@ -23,4 +23,10 @@ web_profiler:
23 intercept_redirects: false 23 intercept_redirects: false
24 24
25 swiftmailer: 25 swiftmailer:
26 - disable_delivery: true  
27 \ No newline at end of file 26 \ No newline at end of file
  27 + disable_delivery: true
  28 +
  29 +# Adiciona autenticação HTTP para as requisições de teste
  30 +security:
  31 + firewalls:
  32 + main:
  33 + http_basic: ~
28 \ No newline at end of file 34 \ No newline at end of file
app/config/security.yml
@@ -59,6 +59,8 @@ security: @@ -59,6 +59,8 @@ security:
59 access_control: 59 access_control:
60 - { path: ^/ws, roles: IS_AUTHENTICATED_ANONYMOUSLY } 60 - { path: ^/ws, roles: IS_AUTHENTICATED_ANONYMOUSLY }
61 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 61 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
62 - - { path: ^/, roles: ROLE_ADMIN }  
63 - - { path: ^/efconnect, role: ROLE_USER }  
64 - - { path: ^/elfinder, role: ROLE_USER } 62 + - { path: ^/admin, roles: ROLE_ADMIN }
  63 + - { path: ^/manutencao, roles: [ ROLE_ADMIN, ROLE_GESTAO ] }
  64 + - { path: ^/, role: [ROLE_USER, ROLE_ADMIN, ROLE_GESTAO, ROLE_SUPERVISAO, ROLE_TECNICO ] }
  65 + - { path: ^/efconnect, role: [ ROLE_USER, ROLE_ADMIN, ROLE_GESTAO, ROLE_SUPERVISAO, ROLE_TECNICO ] }
  66 + - { path: ^/elfinder, role: [ ROLE_USER, ROLE_ADMIN, ROLE_GESTAO, ROLE_SUPERVISAO, ROLE_TECNICO ] }
@@ -47,7 +47,8 @@ @@ -47,7 +47,8 @@
47 "doctrine/doctrine-fixtures-bundle": "dev-master", 47 "doctrine/doctrine-fixtures-bundle": "dev-master",
48 "ijanki/ftp-bundle": "*", 48 "ijanki/ftp-bundle": "*",
49 "jms/translation-bundle": "1.1.*@dev", 49 "jms/translation-bundle": "1.1.*@dev",
50 - "helios-ag/fm-elfinder-bundle": "1.x", 50 + "helios-ag/fm-elfinder-bundle": "~2.5",
  51 + "helios-ag/fm-elfinder-php-connector": "~2.0",
51 "knplabs/knp-menu": "~2.0", 52 "knplabs/knp-menu": "~2.0",
52 "knplabs/knp-menu-bundle": "~2.0", 53 "knplabs/knp-menu-bundle": "~2.0",
53 "jpgraph/jpgraph": "dev-master", 54 "jpgraph/jpgraph": "dev-master",
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 4 "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 "This file is @generated automatically" 5 "This file is @generated automatically"
6 ], 6 ],
7 - "hash": "2bfd0da0469386a6510b8353b8fd1ce5", 7 + "hash": "26259b90c15f97d94c17de0e76b7fb8f",
8 "packages": [ 8 "packages": [
9 { 9 {
10 "name": "braincrafted/bootstrap-bundle", 10 "name": "braincrafted/bootstrap-bundle",
@@ -1104,34 +1104,39 @@ @@ -1104,34 +1104,39 @@
1104 }, 1104 },
1105 { 1105 {
1106 "name": "helios-ag/fm-elfinder-bundle", 1106 "name": "helios-ag/fm-elfinder-bundle",
1107 - "version": "1.5",  
1108 - "target-dir": "FM/ElfinderBundle", 1107 + "version": "2.5",
1109 "source": { 1108 "source": {
1110 "type": "git", 1109 "type": "git",
1111 "url": "https://github.com/helios-ag/FMElfinderBundle.git", 1110 "url": "https://github.com/helios-ag/FMElfinderBundle.git",
1112 - "reference": "57de87e1bf72f9a87fa1d7cd508e7857a3d03860" 1111 + "reference": "955e8ec9ed63605f0aeedd2db99dc33818e0ddc8"
1113 }, 1112 },
1114 "dist": { 1113 "dist": {
1115 "type": "zip", 1114 "type": "zip",
1116 - "url": "https://api.github.com/repos/helios-ag/FMElfinderBundle/zipball/57de87e1bf72f9a87fa1d7cd508e7857a3d03860",  
1117 - "reference": "57de87e1bf72f9a87fa1d7cd508e7857a3d03860", 1115 + "url": "https://api.github.com/repos/helios-ag/FMElfinderBundle/zipball/955e8ec9ed63605f0aeedd2db99dc33818e0ddc8",
  1116 + "reference": "955e8ec9ed63605f0aeedd2db99dc33818e0ddc8",
1118 "shasum": "" 1117 "shasum": ""
1119 }, 1118 },
1120 "require": { 1119 "require": {
1121 - "helios-ag/fm-elfinder-php-connector": "1.1.1", 1120 + "helios-ag/fm-elfinder-php-connector": "~2.0",
1122 "php": ">=5.3.3", 1121 "php": ">=5.3.3",
1123 - "sensio/framework-extra-bundle": "*@dev",  
1124 - "symfony/symfony": "*@stable",  
1125 - "symfony/twig-bundle": "~2.0" 1122 + "symfony/framework-bundle": "~2.4",
  1123 + "symfony/twig-bundle": "~2.4"
  1124 + },
  1125 + "require-dev": {
  1126 + "doctrine/doctrine-bundle": "~1.0",
  1127 + "matthiasnoback/symfony-config-test": "0.*",
  1128 + "matthiasnoback/symfony-dependency-injection-test": "0.*",
  1129 + "symfony/form": "~2.1"
1126 }, 1130 },
1127 "suggest": { 1131 "suggest": {
1128 - "Trsteel/ckeditor-bundle": "CKEditor WYSIWYG Editor Bundlefor Symfony2 Project by Trsteel",  
1129 - "stfalcon/tinymce-bundle": "TinyMCE WYSIWYG Editor Bundle by Stfalcon" 1132 + "egeloen/ckeditor-bundle": "CKEditor Bundle by Egeloen",
  1133 + "stfalcon/tinymce-bundle": "TinyMCE Bundle by Stfalcon",
  1134 + "trsteel/ckeditor-bundle": "CKEditor Bundle by trsteel"
1130 }, 1135 },
1131 "type": "symfony-bundle", 1136 "type": "symfony-bundle",
1132 "autoload": { 1137 "autoload": {
1133 - "psr-0": {  
1134 - "FM\\ElfinderBundle": "" 1138 + "psr-4": {
  1139 + "FM\\ElfinderBundle\\": ""
1135 } 1140 }
1136 }, 1141 },
1137 "notification-url": "https://packagist.org/downloads/", 1142 "notification-url": "https://packagist.org/downloads/",
@@ -1148,35 +1153,39 @@ @@ -1148,35 +1153,39 @@
1148 "homepage": "https://github.com/helios-ag/FMElfinderBundle/contributors" 1153 "homepage": "https://github.com/helios-ag/FMElfinderBundle/contributors"
1149 } 1154 }
1150 ], 1155 ],
1151 - "description": "ElFinder bundle, add ElFinder file manager to your Symfony2 project", 1156 + "description": "ElFinder bundle, adds ElFinder file manager to your Symfony2 project",
1152 "homepage": "https://github.com/helios-ag/FMElfinderBundle", 1157 "homepage": "https://github.com/helios-ag/FMElfinderBundle",
1153 "keywords": [ 1158 "keywords": [
1154 "elfinder", 1159 "elfinder",
1155 "file manager" 1160 "file manager"
1156 ], 1161 ],
1157 - "time": "2014-05-09 12:02:28" 1162 + "time": "2014-10-11 09:18:19"
1158 }, 1163 },
1159 { 1164 {
1160 "name": "helios-ag/fm-elfinder-php-connector", 1165 "name": "helios-ag/fm-elfinder-php-connector",
1161 - "version": "1.1.1", 1166 + "version": "2.1",
1162 "source": { 1167 "source": {
1163 "type": "git", 1168 "type": "git",
1164 "url": "https://github.com/helios-ag/ElFinderPHP.git", 1169 "url": "https://github.com/helios-ag/ElFinderPHP.git",
1165 - "reference": "fa24c5ce710ec2c9eab899786c93dfac1a232386" 1170 + "reference": "928d58b4a76d08c3c52b5a911500b0311b518802"
1166 }, 1171 },
1167 "dist": { 1172 "dist": {
1168 "type": "zip", 1173 "type": "zip",
1169 - "url": "https://api.github.com/repos/helios-ag/ElFinderPHP/zipball/fa24c5ce710ec2c9eab899786c93dfac1a232386",  
1170 - "reference": "fa24c5ce710ec2c9eab899786c93dfac1a232386", 1174 + "url": "https://api.github.com/repos/helios-ag/ElFinderPHP/zipball/928d58b4a76d08c3c52b5a911500b0311b518802",
  1175 + "reference": "928d58b4a76d08c3c52b5a911500b0311b518802",
1171 "shasum": "" 1176 "shasum": ""
1172 }, 1177 },
1173 "require": { 1178 "require": {
1174 - "php": ">=5.3.0" 1179 + "php": ">=5.3.3"
  1180 + },
  1181 + "suggest": {
  1182 + "aws/aws-sdk-php": "Allows you to use AWS S3 storage",
  1183 + "dropbox-php/dropbox-php": "Allows you to use Dropbox storage"
1175 }, 1184 },
1176 "type": "library", 1185 "type": "library",
1177 "autoload": { 1186 "autoload": {
1178 - "psr-0": {  
1179 - "FM\\ElFinderPHP": "src/" 1187 + "psr-4": {
  1188 + "FM\\ElFinderPHP\\": "src/"
1180 } 1189 }
1181 }, 1190 },
1182 "notification-url": "https://packagist.org/downloads/", 1191 "notification-url": "https://packagist.org/downloads/",
@@ -1185,7 +1194,7 @@ @@ -1185,7 +1194,7 @@
1185 ], 1194 ],
1186 "authors": [ 1195 "authors": [
1187 { 1196 {
1188 - "name": "Albert Ganiev", 1197 + "name": "Al Ganiev",
1189 "email": "helios.ag@gmail.com" 1198 "email": "helios.ag@gmail.com"
1190 }, 1199 },
1191 { 1200 {
@@ -1203,7 +1212,7 @@ @@ -1203,7 +1212,7 @@
1203 "elfinder", 1212 "elfinder",
1204 "filemanager" 1213 "filemanager"
1205 ], 1214 ],
1206 - "time": "2013-08-06 17:02:04" 1215 + "time": "2014-10-17 10:43:45"
1207 }, 1216 },
1208 { 1217 {
1209 "name": "ijanki/ftp-bundle", 1218 "name": "ijanki/ftp-bundle",
@@ -2283,12 +2292,12 @@ @@ -2283,12 +2292,12 @@
2283 "source": { 2292 "source": {
2284 "type": "git", 2293 "type": "git",
2285 "url": "https://github.com/lightbase/cocar.git", 2294 "url": "https://github.com/lightbase/cocar.git",
2286 - "reference": "877b9496c3eb1682040298a7a3bb584aba5c5034" 2295 + "reference": "3a80e6a980a19c6d75c1dd672ffce8d68a54c9f0"
2287 }, 2296 },
2288 "dist": { 2297 "dist": {
2289 "type": "zip", 2298 "type": "zip",
2290 - "url": "https://api.github.com/repos/lightbase/cocar/zipball/877b9496c3eb1682040298a7a3bb584aba5c5034",  
2291 - "reference": "877b9496c3eb1682040298a7a3bb584aba5c5034", 2299 + "url": "https://api.github.com/repos/lightbase/cocar/zipball/3a80e6a980a19c6d75c1dd672ffce8d68a54c9f0",
  2300 + "reference": "3a80e6a980a19c6d75c1dd672ffce8d68a54c9f0",
2292 "shasum": "" 2301 "shasum": ""
2293 }, 2302 },
2294 "require": { 2303 "require": {
@@ -2319,7 +2328,7 @@ @@ -2319,7 +2328,7 @@
2319 "support": { 2328 "support": {
2320 "source": "https://github.com/lightbase/cocar/tree/master" 2329 "source": "https://github.com/lightbase/cocar/tree/master"
2321 }, 2330 },
2322 - "time": "2014-09-22 12:29:23" 2331 + "time": "2014-10-15 20:35:53"
2323 }, 2332 },
2324 { 2333 {
2325 "name": "liip/functional-test-bundle", 2334 "name": "liip/functional-test-bundle",
src/Cacic/CommonBundle/Controller/AgenteController.php 0 → 100644
@@ -0,0 +1,256 @@ @@ -0,0 +1,256 @@
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: eduardo
  5 + * Date: 18/10/14
  6 + * Time: 23:49
  7 + */
  8 +
  9 +namespace Cacic\CommonBundle\Controller;
  10 +
  11 +use Cacic\CommonBundle\Form\Type\AgenteType;
  12 +use Symfony\Component\HttpFoundation\Request;
  13 +use Symfony\Component\HttpFoundation\Response;
  14 +use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  15 +use Symfony\Component\Finder\Finder;
  16 +use PharData;
  17 +use Symfony\Component\Security\Acl\Exception\Exception;
  18 +use ZipArchive;
  19 +
  20 +
  21 +class AgenteController extends Controller {
  22 +
  23 + public function indexAction(Request $request) {
  24 + $logger = $this->get('logger');
  25 + // Cria diretório dos agentes se não existir
  26 + $rootDir = $this->container->get('kernel')->getRootDir();
  27 + $webDir = $rootDir . "/../web/";
  28 + $downloadsDir = $webDir . "downloads/";
  29 + if (!is_dir($downloadsDir)) {
  30 + mkdir($downloadsDir);
  31 + }
  32 +
  33 + $cacicDir = $downloadsDir . "cacic/";
  34 + if (!is_dir($cacicDir)) {
  35 + mkdir($cacicDir);
  36 + }
  37 +
  38 + $linuxDir = $cacicDir . "linux/";
  39 + if (!is_dir($linuxDir)) {
  40 + mkdir($linuxDir);
  41 + }
  42 +
  43 + $windowsDir = $cacicDir . "windows/";
  44 + if (!is_dir($windowsDir)) {
  45 + mkdir($windowsDir);
  46 + }
  47 +
  48 +
  49 + $outrosDir = $downloadsDir . "outros/";
  50 + if (!is_dir($outrosDir)) {
  51 + mkdir($outrosDir);
  52 + }
  53 +
  54 +
  55 + $form = $this->createForm( new AgenteType() );
  56 + $locale = $request->getLocale();
  57 +
  58 + // Constrói array de arquivos e hashes
  59 + $finder = new Finder();
  60 + $agentes = new Finder();
  61 + $saida = array();
  62 +
  63 + // Primeiro tratamos agentes Linux
  64 + // A regra é que o agente mais atual estará na pasta current
  65 + $finder->directories()->in($linuxDir);
  66 + $saida['linux']['versions'] = array();
  67 + foreach($finder as $version) {
  68 + if ($version->getFileName() == 'current') {
  69 + continue;
  70 + }
  71 + $saida['linux']['versions'][$version->getFileName()] = array();
  72 + $agentes->files()->in($version->getRealPath());
  73 + foreach ($agentes as $file) {
  74 + array_push($saida['linux']['versions'][$version->getFileName()], array(
  75 + 'name' => $file->getFileName(),
  76 + 'download_url' => 'downloads/linux/windows/' . $version->getFileName() . '/' . $file->getFileName(),
  77 + 'hash' => md5_file($file->getRealPath()),
  78 + 'size' => $file->getSize(),
  79 + 'filename' => $windowsDir . $version->getFileName() . '/' . $file->getFileName()
  80 + ));
  81 +
  82 + }
  83 + }
  84 + // Get latest version
  85 + $current = basename(readlink($cacicDir."current"));
  86 + $saida['linux']['live_version'] = $current;
  87 +
  88 + // Aí tratamos Windows
  89 + $finder->directories()->in($windowsDir);
  90 + $saida['windows']['versions'] = array();
  91 + foreach($finder as $version) {
  92 + if ($version->getFileName() == 'current') {
  93 + continue;
  94 + }
  95 + $saida['windows']['versions'][$version->getFileName()] = array();
  96 + $agentes->files()->in($version->getRealPath());
  97 + foreach ($agentes as $file) {
  98 + array_push($saida['windows']['versions'][$version->getFileName()], array(
  99 + 'name' => $file->getFileName(),
  100 + 'download_url' => 'downloads/cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(),
  101 + 'hash' => md5_file($file->getRealPath()),
  102 + 'size' => $file->getSize(),
  103 + 'filename' => 'windows/' . $version->getFileName() . '/' . $file->getFileName()
  104 + ));
  105 +
  106 + }
  107 + }
  108 + // Get latest version
  109 + $current = basename(readlink($windowsDir."current"));
  110 + $saida['windows']['live_version'] = $current;
  111 +
  112 + //$logger->debug("4444444444444444444444444444444444 ".print_r($saida, true));
  113 +
  114 + if ( $request->isMethod('POST') )
  115 + {
  116 + // Aqui vamos fazer o tratamento dos agentes
  117 + $data = $form->getData();
  118 + $data['windows_version'] = $request->get('agentes')['windows_version'];
  119 + $data['linux_version'] = $request->get('agentes')['linux_version'];
  120 + $files = $request->files->get('agentes');
  121 +
  122 + //$logger->debug("99999999999999999999999999999999999 ".print_r($data, true));
  123 + if (!empty($files['windows'])) {
  124 + //$logger->debug("88888888888888888888888888888888888888 ".print_r($files['windows'], true));
  125 + if (empty($data['windows_version'])) {
  126 + $logger->error("O parâmetro versão é obrigatório");
  127 + $this->get('session')->getFlashBag()->add('error', 'O parâmetro versão é obrigatório');
  128 + } else {
  129 + $versionDir = $windowsDir . $data['windows_version'];
  130 + $result = $this->uploadPackage($files['windows'], $versionDir);
  131 + if (!$result) {
  132 + $logger->error("Erro na atualização dos Agentes Windows");
  133 + $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes Windows');
  134 + } else {
  135 + // Make this version current
  136 + $logger->debug("Agentes atualizados com sucesso");
  137 + symlink($versionDir, "$windowsDir"."current");
  138 + $this->get('session')->getFlashBag()->add('success', 'Agentes atualizados com sucesso!');
  139 + }
  140 + }
  141 + }
  142 +
  143 + if (!empty($files['linux'])) {
  144 + if (empty($data['linux_version'])) {
  145 + $logger->error("O parâmetro versão é obrigatório");
  146 + $this->get('session')->getFlashBag()->add('error', 'O parâmetro versão é obrigatório');
  147 + } else {
  148 + $versionDir = $linuxDir . $data['linux_version'];
  149 + $result = $this->uploadPackage($files['linux'], $versionDir);
  150 + if (!$result) {
  151 + $logger->error("Erro na atualização dos Agentes Linux");
  152 + $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes Linux');
  153 + } else {
  154 + // Make this version current
  155 + symlink($versionDir, $linuxDir."current");
  156 + $this->get('session')->getFlashBag()->add('success', 'Agentes atualizados com sucesso!');
  157 + }
  158 + }
  159 + }
  160 +
  161 + }
  162 +
  163 + return $this->render( 'CacicCommonBundle:Agente:index.html.twig',
  164 + array(
  165 + 'local'=>$locale,
  166 + 'saida' => $saida,
  167 + 'form' => $form->createView()
  168 + )
  169 + );
  170 + }
  171 +
  172 + public function uploadPackage($file, $version) {
  173 + $logger = $this->get('logger');
  174 + if (!$file->isValid()) {
  175 + $logger->error("Erro no upload do arquivo. Arquivo inválido\n".$file->getErrorMessage());
  176 + $this->get('session')->getFlashBag()->add('error', "Erro no upload do arquivo. Arquivo inválido\n".$file->getErrorMessage());
  177 + return false;
  178 + }
  179 + $result = false;
  180 + mkdir($version);
  181 + //$logger->debug("66666666666666666666666666666666666 ".print_r($file, true));
  182 +
  183 + $extension = $file->getClientOriginalExtension();
  184 + //$logger->debug("00000000000000000000000000000000000000000 $extension | $version");
  185 +
  186 + if ($extension == 'zip') {
  187 + $zip = new ZipArchive;
  188 + if ($zip->open($file) === TRUE) {
  189 + $zip->extractTo($version);
  190 + $zip->close();
  191 + $logger->debug("Arquivo .zip descompactado com sucesso ". $file->getClientOriginalName());
  192 + $result = true;
  193 + } else {
  194 + $logger->error("Erro na descompactação do arquivo .zip ". $file->getClientOriginalName());
  195 + $this->get('session')->getFlashBag()->add('error', "Erro na descompatcação do arquivo .zip\n".$file->getErrorMessage());
  196 + $result = false;
  197 + }
  198 +
  199 + } elseif ($extension == 'gz') {
  200 + try {
  201 + // decompress from gz
  202 + $tar = $version.$file->getClientOriginalName();
  203 + $p = new PharData($tar, 0, $file);
  204 + $p->decompress();
  205 +
  206 + // Now unarchive from tar
  207 + $phar = new PharData($tar);
  208 + $phar->extractTo($version);
  209 +
  210 + // Remove file
  211 + unlink($tar);
  212 +
  213 + $result = true;
  214 + } catch (Exception $e) {
  215 + $logger->error("Erro na extração do arquivo .gz \n".$e->getMessage());
  216 + $this->get('session')->getFlashBag()->add('error', "Erro na extração do arquivo .gz\n".$file->getErrorMessage());
  217 + $result = false;
  218 + }
  219 +
  220 + } else {
  221 + $logger->error("Extensão inválida para upload dos agentes ".$extension);
  222 + $this->get('session')->getFlashBag()->add('error', "Extensão inválida para upload dos agentes ".$extension);
  223 + $result = false;
  224 + }
  225 +
  226 + return $result;
  227 + }
  228 +
  229 + public function excluirAction(Request $request) {
  230 + if ( ! $request->isXmlHttpRequest() )
  231 + throw $this->createNotFoundException( 'Página não encontrada' );
  232 +
  233 +
  234 +
  235 + $rootDir = $this->container->get('kernel')->getRootDir();
  236 + $webDir = $rootDir . "/../web/";
  237 + $downloadsDir = $webDir . "downloads/";
  238 + $cacicDir = $downloadsDir . "cacic/";
  239 + $filepath = $cacicDir . $request->get('id');
  240 +
  241 + $this->get('logger')->debug("Excluindo arquivo de agente ".$filepath);
  242 +
  243 + $result = unlink($filepath);
  244 +
  245 + if ($result) {
  246 + $response = new Response( json_encode( array('status' => 'ok') ) );
  247 + $response->headers->set('Content-Type', 'application/json');
  248 + } else {
  249 + $response = new Response( json_encode( array('status' => 'error') ) );
  250 + $response->headers->set('Content-Type', 'application/json');
  251 + }
  252 +
  253 + return $response;
  254 + }
  255 +
  256 +}
0 \ No newline at end of file 257 \ No newline at end of file
src/Cacic/CommonBundle/DataFixtures/ORM/LoadGrupoUsuarioData.php
@@ -36,11 +36,56 @@ class LoadGrupoUsuarioData extends AbstractFixture implements FixtureInterface, @@ -36,11 +36,56 @@ class LoadGrupoUsuarioData extends AbstractFixture implements FixtureInterface,
36 $grupoAdmin->setTeMenuGrupo('menu_adm.txt'); 36 $grupoAdmin->setTeMenuGrupo('menu_adm.txt');
37 $grupoAdmin->setTeDescricaoGrupo('Acesso irrestrito'); 37 $grupoAdmin->setTeDescricaoGrupo('Acesso irrestrito');
38 $grupoAdmin->setCsNivelAdministracao(true); 38 $grupoAdmin->setCsNivelAdministracao(true);
  39 + $grupoAdmin->setRole('ROLE_ADMIN');
39 40
40 // Adiciona referência ao Grupo que será usada depois 41 // Adiciona referência ao Grupo que será usada depois
41 $this->addReference('grupo-admin', $grupoAdmin); 42 $this->addReference('grupo-admin', $grupoAdmin);
42 43
43 $manager->persist($grupoAdmin); 44 $manager->persist($grupoAdmin);
  45 +
  46 + // Cria os outros grupos padrão do Cacic
  47 + $grupo = new GrupoUsuario();
  48 + $grupo->setNmGrupoUsuarios('comum');
  49 + $grupo->setTeGrupoUsuarios('Comum');
  50 + $grupo->setTeMenuGrupo('menu_adm.txt');
  51 + $grupo->setTeDescricaoGrupo('Usuário limitado, sem acesso a informações confidenciais como Softwares Inventariados e Opções Administrativas como Forçar Coletas e Excluir Computadores. Poderá alterar sua própria senha.');
  52 + $grupo->setCsNivelAdministracao(2);
  53 + $grupo->setRole('ROLE_USER');
  54 +
  55 + $manager->persist($grupo);
  56 +
  57 + // Cria os outros grupos padrão do Cacic
  58 + $grupo = new GrupoUsuario();
  59 + $grupo->setNmGrupoUsuarios('gestao');
  60 + $grupo->setTeGrupoUsuarios('Gestão Central');
  61 + $grupo->setTeMenuGrupo('menu_adm.txt');
  62 + $grupo->setTeDescricaoGrupo('Acesso de leitura em todas as opções.');
  63 + $grupo->setCsNivelAdministracao(3);
  64 + $grupo->setRole('ROLE_GESTAO');
  65 +
  66 + $manager->persist($grupo);
  67 +
  68 + // Cria os outros grupos padrão do Cacic
  69 + $grupo = new GrupoUsuario();
  70 + $grupo->setNmGrupoUsuarios('supervisao');
  71 + $grupo->setTeGrupoUsuarios('Supervisão');
  72 + $grupo->setTeMenuGrupo('menu_adm.txt');
  73 + $grupo->setTeDescricaoGrupo('Manutenção de tabelas e acesso a todas as informações referentes à Localização.');
  74 + $grupo->setCsNivelAdministracao(4);
  75 + $grupo->setRole('ROLE_SUPERVISAO');
  76 +
  77 + $manager->persist($grupo);
  78 +
  79 +
  80 + // Cria os outros grupos padrão do Cacic
  81 + $grupo = new GrupoUsuario();
  82 + $grupo->setNmGrupoUsuarios('tecnico');
  83 + $grupo->setTeGrupoUsuarios('Técnico');
  84 + $grupo->setTeMenuGrupo('menu_adm.txt');
  85 + $grupo->setTeDescricaoGrupo('Acesso técnico. Será permitido acessar configurações de rede e relatórios de Patrimônio e Hardware.');
  86 + $grupo->setCsNivelAdministracao(5);
  87 + $grupo->setRole('ROLE_TECNICO');
  88 +
44 $manager->flush(); 89 $manager->flush();
45 90
46 } 91 }
src/Cacic/CommonBundle/DoctrineMigrations/Version20141018220727.php 0 → 100644
@@ -0,0 +1,109 @@ @@ -0,0 +1,109 @@
  1 +<?php
  2 +
  3 +namespace Cacic\CommonBundle\Migrations;
  4 +
  5 +use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  6 +use Symfony\Component\DependencyInjection\ContainerInterface;
  7 +use Doctrine\DBAL\Migrations\AbstractMigration;
  8 +use Doctrine\DBAL\Schema\Schema;
  9 +use Cacic\CommonBundle\Entity\GrupoUsuario;
  10 +
  11 +/**
  12 + * Auto-generated Migration: Please modify to your needs!
  13 + */
  14 +class Version20141018220727 extends AbstractMigration implements ContainerAwareInterface
  15 +{
  16 + private $container;
  17 +
  18 + public function setContainer(ContainerInterface $container = null)
  19 + {
  20 + $this->container = $container;
  21 + }
  22 +
  23 + public function up(Schema $schema)
  24 + {
  25 + // this up() migration is auto-generated, please modify it to your needs
  26 + $logger = $this->container->get('logger');
  27 + $em = $this->container->get('doctrine.orm.entity_manager');
  28 +
  29 + $grupoAdmin = $em->getRepository('CacicCommonBundle:GrupoUsuario')->findOneBy(array(
  30 + 'nmGrupoUsuarios' => 'Admin'
  31 + ));
  32 +
  33 + if (empty($grupoAdmin)) {
  34 + // Cria pelo menos um grupo de administradores
  35 + $grupoAdmin = new GrupoUsuario();
  36 + $grupoAdmin->setNmGrupoUsuarios('Admin');
  37 + $grupoAdmin->setTeGrupoUsuarios('Administradores');
  38 + $grupoAdmin->setTeMenuGrupo('menu_adm.txt');
  39 + $grupoAdmin->setTeDescricaoGrupo('Acesso irrestrito');
  40 + $grupoAdmin->setRole('ROLE_ADMIN');
  41 + $grupoAdmin->setCsNivelAdministracao(true);
  42 +
  43 + $em->persist($grupoAdmin);
  44 + }
  45 +
  46 + // A melhor solução é adicionar todos os usuários no Grupo de Administradores
  47 + $usuario_list = $em->getRepository('CacicCommonBundle:Usuario')->findAll();
  48 + foreach ($usuario_list as $usuario) {
  49 + $usuario->setIdGrupoUsuario($grupoAdmin);
  50 +
  51 + $em->persist($usuario);
  52 + }
  53 +
  54 + // Cria os outros grupos padrão do Cacic
  55 + $grupo = new GrupoUsuario();
  56 + $grupo->setNmGrupoUsuarios('comum');
  57 + $grupo->setTeGrupoUsuarios('Comum');
  58 + $grupo->setTeMenuGrupo('menu_adm.txt');
  59 + $grupo->setTeDescricaoGrupo('Usuário limitado, sem acesso a informações confidenciais como Softwares Inventariados e Opções Administrativas como Forçar Coletas e Excluir Computadores. Poderá alterar sua própria senha.');
  60 + $grupo->setCsNivelAdministracao(2);
  61 + $grupo->setRole('ROLE_USER');
  62 +
  63 + $em->persist($grupo);
  64 +
  65 + // Cria os outros grupos padrão do Cacic
  66 + $grupo = new GrupoUsuario();
  67 + $grupo->setNmGrupoUsuarios('gestao');
  68 + $grupo->setTeGrupoUsuarios('Gestão Central');
  69 + $grupo->setTeMenuGrupo('menu_adm.txt');
  70 + $grupo->setTeDescricaoGrupo('Acesso de leitura em todas as opções.');
  71 + $grupo->setCsNivelAdministracao(3);
  72 + $grupo->setRole('ROLE_GESTAO');
  73 +
  74 + $em->persist($grupo);
  75 +
  76 + // Cria os outros grupos padrão do Cacic
  77 + $grupo = new GrupoUsuario();
  78 + $grupo->setNmGrupoUsuarios('supervisao');
  79 + $grupo->setTeGrupoUsuarios('Supervisão');
  80 + $grupo->setTeMenuGrupo('menu_adm.txt');
  81 + $grupo->setTeDescricaoGrupo('Manutenção de tabelas e acesso a todas as informações referentes à Localização.');
  82 + $grupo->setCsNivelAdministracao(4);
  83 + $grupo->setRole('ROLE_SUPERVISAO');
  84 +
  85 + $em->persist($grupo);
  86 +
  87 +
  88 + // Cria os outros grupos padrão do Cacic
  89 + $grupo = new GrupoUsuario();
  90 + $grupo->setNmGrupoUsuarios('tecnico');
  91 + $grupo->setTeGrupoUsuarios('Técnico');
  92 + $grupo->setTeMenuGrupo('menu_adm.txt');
  93 + $grupo->setTeDescricaoGrupo('Acesso técnico. Será permitido acessar configurações de rede e relatórios de Patrimônio e Hardware.');
  94 + $grupo->setCsNivelAdministracao(5);
  95 + $grupo->setRole('ROLE_TECNICO');
  96 +
  97 + $em->persist($grupo);
  98 +
  99 + // Grava tudo
  100 + $em->flush();
  101 +
  102 + }
  103 +
  104 + public function down(Schema $schema)
  105 + {
  106 + // this down() migration is auto-generated, please modify it to your needs
  107 +
  108 + }
  109 +}
src/Cacic/CommonBundle/Entity/GrupoUsuario.php
@@ -164,4 +164,32 @@ class GrupoUsuario @@ -164,4 +164,32 @@ class GrupoUsuario
164 { 164 {
165 return $this->csNivelAdministracao; 165 return $this->csNivelAdministracao;
166 } 166 }
167 -}  
168 \ No newline at end of file 167 \ No newline at end of file
  168 + /**
  169 + * @var string
  170 + */
  171 + private $role;
  172 +
  173 +
  174 + /**
  175 + * Set role
  176 + *
  177 + * @param string $role
  178 + * @return GrupoUsuario
  179 + */
  180 + public function setRole($role)
  181 + {
  182 + $this->role = $role;
  183 +
  184 + return $this;
  185 + }
  186 +
  187 + /**
  188 + * Get role
  189 + *
  190 + * @return string
  191 + */
  192 + public function getRole()
  193 + {
  194 + return $this->role;
  195 + }
  196 +}
src/Cacic/CommonBundle/Entity/Usuario.php
@@ -6,11 +6,13 @@ use Doctrine\ORM\Mapping as ORM; @@ -6,11 +6,13 @@ use Doctrine\ORM\Mapping as ORM;
6 use Symfony\Component\Security\Core\User\UserInterface; 6 use Symfony\Component\Security\Core\User\UserInterface;
7 use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 7 use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
8 use Symfony\Component\Security\Core\User\EquatableInterface; 8 use Symfony\Component\Security\Core\User\EquatableInterface;
  9 +use Symfony\Component\Security\Core\User\AdvancedUserInterface;
  10 +use Symfony\Component\Validator\Constraints\True;
9 11
10 /** 12 /**
11 * Usuario 13 * Usuario
12 */ 14 */
13 -class Usuario implements UserInterface, \Serializable, EquatableInterface 15 +class Usuario implements AdvancedUserInterface, \Serializable, EquatableInterface
14 { 16 {
15 /** 17 /**
16 * @var integer 18 * @var integer
@@ -381,7 +383,12 @@ class Usuario implements UserInterface, \Serializable, EquatableInterface @@ -381,7 +383,12 @@ class Usuario implements UserInterface, \Serializable, EquatableInterface
381 */ 383 */
382 public function getRoles() 384 public function getRoles()
383 { 385 {
384 - return array( 'ROLE_ADMIN' ); 386 + $role = $this->getIdGrupoUsuario()->getRole();
  387 + if (empty($role)) {
  388 + return array( 'ROLE_USER' );
  389 + } else {
  390 + return array( $role );
  391 + }
385 } 392 }
386 393
387 /** 394 /**
@@ -538,4 +545,76 @@ class Usuario implements UserInterface, \Serializable, EquatableInterface @@ -538,4 +545,76 @@ class Usuario implements UserInterface, \Serializable, EquatableInterface
538 return true; 545 return true;
539 } 546 }
540 547
  548 + /**
  549 + * Conta expirada
  550 + *
  551 + * @return bool
  552 + */
  553 + public function isAccountNonExpired()
  554 + {
  555 + return true;
  556 + }
  557 +
  558 + /**
  559 + * Conta travada
  560 + *
  561 + * @return bool
  562 + */
  563 + public function isAccountNonLocked()
  564 + {
  565 + return true;
  566 + }
  567 +
  568 + /**
  569 + * Credenciais expiradas
  570 + *
  571 + * @return bool
  572 + */
  573 + public function isCredentialsNonExpired()
  574 + {
  575 + return true;
  576 + }
  577 +
  578 + /**
  579 + * Usuário ativo
  580 + *
  581 + * @return bool
  582 + */
  583 + public function isEnabled()
  584 + {
  585 + return true;
  586 + //return $this->isActive;
  587 + }
  588 +
  589 + /**
  590 + * FIXME: Criar interface para ativar e desativar usuários
  591 + *
  592 + * @var boolean
  593 + */
  594 + private $isActive;
  595 +
  596 +
  597 + /**
  598 + * Set isActive
  599 + *
  600 + * @param boolean $isActive
  601 + * @return Usuario
  602 + */
  603 + public function setIsActive($isActive)
  604 + {
  605 + $this->isActive = $isActive;
  606 +
  607 + return $this;
  608 + }
  609 +
  610 + /**
  611 + * Get isActive
  612 + *
  613 + * @return boolean
  614 + */
  615 + public function getIsActive()
  616 + {
  617 + return true;
  618 + //return $this->isActive;
  619 + }
541 } 620 }
src/Cacic/CommonBundle/Entity/UsuarioRepository.php
@@ -34,13 +34,13 @@ class UsuarioRepository extends EntityRepository @@ -34,13 +34,13 @@ class UsuarioRepository extends EntityRepository
34 * Método que apresenta o grupo de acesso do respectivo usuario 34 * Método que apresenta o grupo de acesso do respectivo usuario
35 */ 35 */
36 public function nivel($usuario){ 36 public function nivel($usuario){
37 - $_dql = "SELECT g.teGrupoUsuarios 37 + $_dql = "SELECT g.nmGrupoUsuarios
38 FROM CacicCommonBundle:Usuario u 38 FROM CacicCommonBundle:Usuario u
39 JOIN u.idLocal l 39 JOIN u.idLocal l
40 JOIN u.idGrupoUsuario g 40 JOIN u.idGrupoUsuario g
41 LEFT JOIN u.locaisSecundarios ls 41 LEFT JOIN u.locaisSecundarios ls
42 WHERE u.idUsuario = :idUsuario 42 WHERE u.idUsuario = :idUsuario
43 - GROUP BY g.teGrupoUsuarios"; 43 + GROUP BY g.nmGrupoUsuarios";
44 44
45 return $this->getEntityManager() 45 return $this->getEntityManager()
46 ->createQuery( $_dql ) 46 ->createQuery( $_dql )
src/Cacic/CommonBundle/Form/Type/AgenteType.php 0 → 100644
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: eduardo
  5 + * Date: 18/10/14
  6 + * Time: 23:36
  7 + */
  8 +
  9 +namespace Cacic\CommonBundle\Form\Type;
  10 +
  11 +use Symfony\Component\Form\AbstractType;
  12 +use Symfony\Component\Form\FormBuilderInterface;
  13 +
  14 +/**
  15 + * Formulário para upload dos agentes
  16 + *
  17 + * Class AgenteType
  18 + * @package Cacic\CommonBundle\Form\Type
  19 + */
  20 +class AgenteType extends AbstractType {
  21 +
  22 + /**
  23 + * Nome do Formulário
  24 + * @return string
  25 + */
  26 +
  27 + public function getName() {
  28 + return 'agentes';
  29 + }
  30 +
  31 + public function buildForm( FormBuilderInterface $builder, array $options )
  32 + {
  33 + $builder->add('windows_version', 'text',
  34 + array(
  35 + 'label' => 'Versão dos Agentes Windows',
  36 + 'required' => false
  37 + )
  38 + );
  39 +
  40 + $builder->add('windows', 'file',
  41 + array(
  42 + 'label' => 'Agentes Windows',
  43 + 'required' => false
  44 + )
  45 + );
  46 +
  47 + $builder->add('linux_version', 'text',
  48 + array(
  49 + 'label' => 'Versão dos Agentes Linux',
  50 + 'required' => false
  51 + )
  52 + );
  53 +
  54 + $builder->add('linux', 'file',
  55 + array(
  56 + 'label' => 'Agentes Linux',
  57 + 'required' => false
  58 + )
  59 + );
  60 + }
  61 +
  62 +}
0 \ No newline at end of file 63 \ No newline at end of file
src/Cacic/CommonBundle/Resources/config/doctrine/GrupoUsuario.orm.yml
@@ -34,4 +34,8 @@ Cacic\CommonBundle\Entity\GrupoUsuario: @@ -34,4 +34,8 @@ Cacic\CommonBundle\Entity\GrupoUsuario:
34 type: integer 34 type: integer
35 nullable: true 35 nullable: true
36 column: cs_nivel_administracao 36 column: cs_nivel_administracao
  37 + role:
  38 + type: text
  39 + nullable: true
  40 + column: role
37 lifecycleCallbacks: { } 41 lifecycleCallbacks: { }
src/Cacic/CommonBundle/Resources/config/doctrine/Usuario.orm.yml
@@ -60,6 +60,11 @@ Cacic\CommonBundle\Entity\Usuario: @@ -60,6 +60,11 @@ Cacic\CommonBundle\Entity\Usuario:
60 fixed: false 60 fixed: false
61 nullable: true 61 nullable: true
62 column: crypt_key 62 column: crypt_key
  63 + isActive:
  64 + type: boolean
  65 + fixed: false
  66 + nullable: true
  67 + column: is_active
63 manyToMany: 68 manyToMany:
64 locaisSecundarios: 69 locaisSecundarios:
65 targetEntity: Local 70 targetEntity: Local
src/Cacic/CommonBundle/Resources/config/routing.yml
@@ -537,4 +537,12 @@ cacic_grupo_usuario_excluir: @@ -537,4 +537,12 @@ cacic_grupo_usuario_excluir:
537 537
538 cacic_ateste: 538 cacic_ateste:
539 pattern: /ateste/ 539 pattern: /ateste/
540 - defaults: { _controller: CacicCommonBundle:Ateste:index }  
541 \ No newline at end of file 540 \ No newline at end of file
  541 + defaults: { _controller: CacicCommonBundle:Ateste:index }
  542 +
  543 +cacic_agente:
  544 + pattern: /admin/agente/
  545 + defaults: { _controller: CacicCommonBundle:Agente:index }
  546 +
  547 +cacic_agente_excluir:
  548 + pattern: /admin/agente/excluir
  549 + defaults: { _controller: CacicCommonBundle:Agente:excluir }
542 \ No newline at end of file 550 \ No newline at end of file
src/Cacic/CommonBundle/Resources/views/Agente/index.html.twig 0 → 100644
@@ -0,0 +1,207 @@ @@ -0,0 +1,207 @@
  1 +{% extends 'CacicCommonBundle::base.html.twig' %}
  2 +
  3 +{% macro bytesToSize(bytes) %}
  4 + {% spaceless %}
  5 + {% set kilobyte = 1024 %}
  6 + {% set megabyte = kilobyte * 1024 %}
  7 + {% set gigabyte = megabyte * 1024 %}
  8 + {% set terabyte = gigabyte * 1024 %}
  9 +
  10 + {% if bytes < kilobyte %}
  11 + {{ bytes ~ ' B' }}
  12 + {% elseif bytes < megabyte %}
  13 + {{ (bytes / kilobyte)|number_format(2, '.') ~ ' KB' }}
  14 + {% elseif bytes < gigabyte %}
  15 + {{ (bytes / megabyte)|number_format(2, '.') ~ ' MB' }}
  16 + {% elseif bytes < terabyte %}
  17 + {{ (bytes / gigabyte)|number_format(2, '.') ~ ' GB' }}
  18 + {% else %}
  19 + {{ (bytes / terabyte)|number_format(2, '.') ~ ' TB' }}
  20 + {% endif %}
  21 + {% endspaceless %}
  22 +{% endmacro %}
  23 +
  24 +{% block breadcrumb %}
  25 + <li class="active">{{ 'Upload de Agentes'|trans }}</li>
  26 +{% endblock %}
  27 +
  28 +{% block body %}
  29 + {% import _self as format %}
  30 +
  31 +<div class="row-fluid">
  32 +
  33 + <div class="span8">
  34 + <div class="box grad_colour_black">
  35 +
  36 + <h2 class="box_head round_top"><i class="icon-search"></i> {{'Upload de agentes' |trans }}</h2>
  37 +
  38 + <div class="block box_content round_bottom padding_10">
  39 + {{ form_start(form, {'id': 'formAgentes'|trans, 'action': path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')), 'method': 'POST'}) }}
  40 +
  41 + {{ form_errors(form) }}
  42 +
  43 + {{ form_row(form.windows_version) }}
  44 +
  45 + {{ form_row(form.windows) }}
  46 +
  47 + {{ form_row(form.linux_version) }}
  48 +
  49 + {{ form_row(form.linux) }}
  50 +
  51 + <input type="submit">
  52 +
  53 + {{ form_end(form) }}
  54 +
  55 + </div> <!-- /block -->
  56 + </div> <!-- /box -->
  57 + </div> <!-- /span8 -->
  58 +
  59 + <div class="span4">
  60 + <div class="box grad_colour_black">
  61 +
  62 + <h2 class="box_head round_top"><i class="icon-info-sign"></i> {{ "Informações Adicionais"|trans }}</h2>
  63 +
  64 + <div class="block box_content round_bottom padding_10">
  65 + <p>
  66 + {{ "Este módulo permite a visualização dos computadores monitorados pelos agentes do cacic"|trans }}.
  67 + </p>
  68 + <p>
  69 + {{ "É possível pesquisar por IP's, nome ou Mac da máquina e por data de instalação da máquina, bastando selecionar uma de suas opções"|trans }}.
  70 + </p>
  71 + <p>
  72 + {{ "Não selecionar nenhum valor em determinado critério é o mesmo que selecionar todos"|trans }}.
  73 + </p>
  74 + </div> <!-- /block -->
  75 + </div> <!-- /box -->
  76 + </div> <!-- span4 -->
  77 +
  78 +</div> <!-- /row -->
  79 +
  80 +<div class="row-fluid">
  81 + <div class="span12">
  82 + <div class="box grad_colour_black">
  83 + <h2 class="box_head round_top"><i class="icon-list"></i> {{'Resultado da pesquisa' |trans }}</h2>
  84 +
  85 + <div class="block box_content round_bottom padding_10">
  86 + <h4><center>{{ "Agentes para GNU/LINUX"|trans }}</h4>
  87 + <table class="table table-striped table-bordered">
  88 + <thead>
  89 + <tr>
  90 + <th width="15%" style="text-align: center">{{ 'Versão'|trans }}</th>
  91 + <th width="30%" style="text-align: center">{{ 'Arquivo'|trans }}</th>
  92 + <th width="25%" style="text-align: center">{{ 'Hash'|trans }}</th>
  93 + <th width="20%" style="text-align: center">{{ 'Tamanho'|trans }}</th>
  94 + <th style="text-align: center">{{ "Ações"|trans }}</th>
  95 + </tr>
  96 + </thead>
  97 + <tbody>
  98 +
  99 + {% for version, value in saida.linux.versions %}
  100 +
  101 + {% if version == saida.linux.live_version %}
  102 + <tr>
  103 + <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;">
  104 + {{ "Versão"|trans }} {{ version }} <br> {{ "(Em Produção)"|trans }}
  105 + </th>
  106 + </tr>
  107 + {% else %}
  108 + <tr>
  109 + <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;">
  110 + {{ "Versão"|trans }} {{ version }}
  111 + </th>
  112 + </tr>
  113 + {% endif %}
  114 +
  115 + {% for modulo in value %}
  116 +
  117 + <tr id="{{ modulo['filename'] }}" class="{{ cycle(['row0', 'row1'], loop.index) }}">
  118 + <td style="text-align: center">{{ version }}</td>
  119 + <td style="text-align: center" >{{ modulo['name'] }}</td>
  120 + <td style="text-align: center" >{{ modulo['hash'] }}</td>
  121 + <td style="text-align: center" >{{ format.bytesToSize(modulo['size']) }}</td>
  122 + <td class="td-actions">
  123 + <a href="{{ path('cacic_agente_excluir') }}" class="btn btn-small btn-danger bt-excluir" title="{{ "Excluir Item"|trans }}">
  124 + <i class="btn-icon-only icon-trash icon-large"></i>
  125 + </a>
  126 + </td>
  127 + </tr>
  128 + {% else %}
  129 + <tr>
  130 + <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td>
  131 + </tr>
  132 + {% endfor %}
  133 + {% else %}
  134 + <tr>
  135 + <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td>
  136 + </tr>
  137 + {% endfor %}
  138 + </tbody>
  139 + </table>
  140 +
  141 + <h4><center>{{ "Agentes para Windows"|trans }}</h4>
  142 + <table class="table table-striped table-bordered">
  143 + <thead>
  144 + <tr>
  145 + <th width="15%" style="text-align: center">{{ 'Versão'|trans }}</th>
  146 + <th width="30%" style="text-align: center">{{ 'Arquivo'|trans }}</th>
  147 + <th width="25%" style="text-align: center">{{ 'Hash'|trans }}</th>
  148 + <th width="20%" style="text-align: center">{{ 'Tamanho'|trans }}</th>
  149 + <th style="text-align: center">{{ "Ações"|trans }}</th>
  150 + </tr>
  151 + </thead>
  152 + <tbody>
  153 +
  154 + {% for version, value in saida.windows.versions %}
  155 +
  156 + {% if version == saida.windows.live_version %}
  157 + <tr>
  158 + <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;">
  159 + {{ "Versão"|trans }} {{ version }} <br> {{ "(Em Produção)"|trans }}
  160 + </th>
  161 + </tr>
  162 + {% else %}
  163 + <tr>
  164 + <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;">
  165 + {{ "Versão"|trans }} {{ version }}
  166 + </th>
  167 + </tr>
  168 + {% endif %}
  169 +
  170 +
  171 + {% for modulo in value %}
  172 +
  173 + <tr id="{{ modulo['filename'] }}" class="{{ cycle(['row0', 'row1'], loop.index) }}">
  174 + <td style="text-align: center" >{{ modulo['name'] }}</td>
  175 + <td style="text-align: center" >{{ modulo['hash'] }}</td>
  176 + <td style="text-align: center" >{{ format.bytesToSize(modulo['size']) }}</td>
  177 + <td class="td-actions">
  178 + <a href="{{ path('cacic_agente_excluir') }}" class="btn btn-small btn-danger bt-excluir" title="{{ "Excluir Item"|trans }}">
  179 + <i class="btn-icon-only icon-trash icon-large"></i>
  180 + </a>
  181 + </td>
  182 + </tr>
  183 + {% else %}
  184 + <tr>
  185 + <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td>
  186 + </tr>
  187 + {% endfor %}
  188 + {% else %}
  189 + <tr>
  190 + <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td>
  191 + </tr>
  192 + {% endfor %}
  193 + </tbody>
  194 + </table>
  195 +
  196 + </div> <!-- /block -->
  197 + </div> <!-- /box -->
  198 + </div> <!-- /span -->
  199 +</div> <!-- /row -->
  200 +
  201 +{% endblock %}
  202 +
  203 +{% block javascripts %}
  204 +
  205 + {{ parent() }}
  206 +
  207 +{% endblock %}
0 \ No newline at end of file 208 \ No newline at end of file
src/Cacic/CommonBundle/Resources/views/Agente/listar.html.twig 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +<div class="row-fluid">
  2 + <div class="span12">
  3 + <div class="box grad_colour_black">
  4 + <h2 class="box_head round_top"><i class="icon-list"></i> {{'Resultado da pesquisa' |trans }}</h2>
  5 + <div class="block box_content round_bottom padding_10">
  6 +
  7 + <iframe src="{{ path('cacic_common_homepage') }}elfinder/form" height="300px" width="100%"></iframe>
  8 +
  9 +
  10 + </div> <!-- /block -->
  11 + </div> <!-- /box -->
  12 + </div> <!-- /span -->
  13 +</div> <!-- /row -->
0 \ No newline at end of file 14 \ No newline at end of file
src/Cacic/CommonBundle/Resources/views/Default/index.html.twig
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 <div class="row-fluid"> 5 <div class="row-fluid">
6 6
7 - {% if nivel['teGrupoUsuarios'] == 'Administração' %} 7 + {% if nivel['nmGrupoUsuarios'] == 'Admin' %}
8 <div class="span6 column ui-sortable" id="col0"> 8 <div class="span6 column ui-sortable" id="col0">
9 <div class="box grad_colour_black" id="box0"> 9 <div class="box grad_colour_black" id="box0">
10 <h2 class="box_head round_top"><i class="icon-bar-chart"></i> {{ 'Estatísticas do sistema'|trans }}</h2> 10 <h2 class="box_head round_top"><i class="icon-bar-chart"></i> {{ 'Estatísticas do sistema'|trans }}</h2>
src/Cacic/CommonBundle/Tests/Controller/AgenteControllerTest.php 0 → 100644
@@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: eduardo
  5 + * Date: 18/10/14
  6 + * Time: 21:14
  7 + */
  8 +
  9 +namespace Cacic\CommonBundle\Tests\Controller;
  10 +
  11 +use Cacic\CommonBundle\Tests\BaseTestCase;
  12 +use Symfony\Component\HttpFoundation\Session;
  13 +
  14 +
  15 +class AgenteControllerTest extends BaseTestCase {
  16 +
  17 + public function setUp() {
  18 + // Load setup from BaseTestCase method
  19 + parent::setUp();
  20 +
  21 + // Cria o cliente utilizando autenticação HTTP para o usuário admin padrão
  22 + $this->client = static::createClient(
  23 + array(),
  24 + array(
  25 + 'PHP_AUTH_USER' => 'admin',
  26 + 'PHP_AUTH_PW' => '123456',
  27 + )
  28 + );
  29 + $this->container = $this->client->getContainer();
  30 + }
  31 +
  32 + public function tearDown() {
  33 + // Executa método de limpeza de todos os casos de teste
  34 + parent::tearDown();
  35 + }
  36 +
  37 +}
0 \ No newline at end of file 38 \ No newline at end of file
src/Cacic/WSBundle/Controller/NeoController.php
@@ -783,6 +783,7 @@ class NeoController extends Controller { @@ -783,6 +783,7 @@ class NeoController extends Controller {
783 if(empty($computadorColeta)) { 783 if(empty($computadorColeta)) {
784 $logger->error("COLETA: Erro na identificação da coleta. O software está cadastrado mas não há ocorrência de coletas no computador"); 784 $logger->error("COLETA: Erro na identificação da coleta. O software está cadastrado mas não há ocorrência de coletas no computador");
785 $computadorColeta = new ComputadorColeta(); 785 $computadorColeta = new ComputadorColeta();
  786 + $computador->addHardware( $computadorColeta );
786 } 787 }
787 } else { 788 } else {
788 $logger->info("COLETA: Cadastrando software não encontrado $software"); 789 $logger->info("COLETA: Cadastrando software não encontrado $software");
@@ -842,7 +843,9 @@ class NeoController extends Controller { @@ -842,7 +843,9 @@ class NeoController extends Controller {
842 $computadorColeta->setDtHrInclusao( new \DateTime() ); 843 $computadorColeta->setDtHrInclusao( new \DateTime() );
843 844
844 // Mando salvar os dados do computador 845 // Mando salvar os dados do computador
  846 + $computador->addHardware($computadorColeta);
845 $em->persist( $computadorColeta ); 847 $em->persist( $computadorColeta );
  848 + $em->persist( $computador );
846 849
847 // Persistencia de Historico 850 // Persistencia de Historico
848 $computadorColetaHistorico = new ComputadorColetaHistorico(); 851 $computadorColetaHistorico = new ComputadorColetaHistorico();