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 ( d34f53...5569b4 )
by Stefano
03:50
created
src/BitPrepared/Bundle/D1b0Workspace/Controller/V1/SecurityController.php 1 patch
Braces   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,15 +53,14 @@  discard block
 block discarded – undo
53 53
                         "clientId"=>$user->id
54 54
                 ];
55 55
                 $response = JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300);
56
-            }else {
56
+            } else {
57 57
                 $headers = [];
58 58
                 $res = [
59 59
                         "errore"=>"sbagliato password o user" //TODO roba
60 60
                 ];
61 61
                 $response = JsonResponse::create($res, 401, $headers)->setSharedMaxAge(300);
62 62
             }
63
-        }
64
-        else {
63
+        } else {
65 64
             //Facebook Redirect
66 65
         }
67 66
         return $response; // JsonResponse::create($output, 200, $headers)->setSharedMaxAge(300);
@@ -82,14 +81,14 @@  discard block
 block discarded – undo
82 81
             if (!$bean->id) {
83 82
                 //TODO mettere un controllo agli IP che forzano le richieste di token falsi
84 83
                 $response = "<html><head></head><body>Token non esistente!</body></html>";
85
-            }else {
84
+            } else {
86 85
                 if (strtotime($verify->inserttime) < strtotime("-15 minutes")) {
87 86
                     $user = R::load('user', $verify->user);
88 87
                     $user->status = "enabled";
89 88
                     $user->updatetime = date('Y-m-d H:i:s');
90 89
                     $id = R::store($user);
91 90
                     $response = "<html><head></head><body>Account attivato complimenti!</body></html>";
92
-                }else {
91
+                } else {
93 92
                     $response = "<html><head></head><body>Impossibile attivare account inserire mail e password per richiedere un nuovo token!</body></html>";
94 93
                 }
95 94
             }
Please login to merge, or discard this patch.
src/BitPrepared/Bundle/D1b0Workspace/Controller/V1/UserController.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@
 block discarded – undo
106 106
                 $user->updatetime = date('Y-m-d G:i:s');
107 107
                 $id = R::store($user);
108 108
                 $res = (object)["id" => $id];
109
-            }catch (Exception $e) {
109
+            } catch (Exception $e) {
110 110
                 echo $e;
111 111
             }
112 112
 
113
-        }else {
113
+        } else {
114 114
 
115 115
         }
116 116
 
Please login to merge, or discard this patch.
src/BitPrepared/Bundle/D1b0Workspace/Controller/V1/BadgeController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
         $filter = $request->get('filterBy');
29 29
         echo $filter;
30 30
 
31
-        $badge = R::findAll("badge","type = ? AND enable = 1",[$filter]);
31
+        $badge = R::findAll("badge", "type = ? AND enable = 1", [$filter]);
32 32
 
33 33
         $res = [];
34
-        foreach($badge as $b){
35
-            array_push($res,[
34
+        foreach ($badge as $b) {
35
+            array_push($res, [
36 36
                 "id"=>$b->id,
37 37
                 "name"=>$b->name,
38 38
                 "descritpion"=>$b->description,
Please login to merge, or discard this patch.
applications/workspace/test/Tests/WorkspaceTest.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace Tests;
4 4
 
5 5
 use Silex\WebTestCase;
6
-use JsonSchema\Validator;
7 6
 
8 7
 class WorkspaceTest extends WebTestCase
9 8
 {
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
           }';
92 92
 
93 93
         $client->request(
94
-          'POST',
95
-          '/api/v1/workspace/',
96
-          [],
97
-          [],
98
-          ['CONTENT_TYPE' => 'application/json'],
99
-          $wp);
94
+            'POST',
95
+            '/api/v1/workspace/',
96
+            [],
97
+            [],
98
+            ['CONTENT_TYPE' => 'application/json'],
99
+            $wp);
100 100
 
101 101
         $response = $client->getResponse();
102 102
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 
132 132
         print_r("\nID: ".$id."\n");
133 133
         $client->request(
134
-          'PUT',
135
-          '/api/v1/workspace/'.$id.'',
136
-          [],
137
-          [],
138
-          ['CONTENT_TYPE' => 'application/json'],
139
-          $wp);
134
+            'PUT',
135
+            '/api/v1/workspace/'.$id.'',
136
+            [],
137
+            [],
138
+            ['CONTENT_TYPE' => 'application/json'],
139
+            $wp);
140 140
 
141 141
         $response = $client->getResponse();
142 142
         print($response);
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
         $client = $this->logIn($client);
155 155
 
156 156
         $client->request(
157
-          'DELETE',
158
-          '/api/v1/workspace/'.$id.'',
159
-          [],
160
-          [],
161
-          [],
162
-          '');
157
+            'DELETE',
158
+            '/api/v1/workspace/'.$id.'',
159
+            [],
160
+            [],
161
+            [],
162
+            '');
163 163
 
164 164
         $response = $client->getResponse();
165 165
 
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -27,6 +27,10 @@
 block discarded – undo
27 27
         return $data;
28 28
     }
29 29
     /*Verifico che l'elenco dei workspace si possa scaricare correttamente*/
30
+
31
+    /**
32
+     * @return string
33
+     */
30 34
     public function testGetWorkspaceList(){
31 35
         $schema = __DIR__.'/../../../../api/schemas/workspaceList.json';
32 36
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     use AbstractAppTest;
11 11
 
12 12
     /*Verifico che il Workspace si possa scaricare correttamente*/
13
-    public function testGetWorkSpace(){
13
+    public function testGetWorkSpace() {
14 14
         $schema = __DIR__.'/../../../../api/schemas/workspace.json';
15 15
 
16 16
         $client = $this->createClient();
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         $crawler = $client->request('GET', '/api/v1/workspace/1');
20 20
         $response = $client->getResponse();
21 21
         $data = $client->getResponse()->getContent();
22
-        $validator = $this->askValidation($data,$schema);
22
+        $validator = $this->askValidation($data, $schema);
23 23
 
24 24
         $assert = $this->evalValidation($validator);
25 25
         $this->assertTrue($assert);
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         return $data;
28 28
     }
29 29
     /*Verifico che l'elenco dei workspace si possa scaricare correttamente*/
30
-    public function testGetWorkspaceList(){
30
+    public function testGetWorkspaceList() {
31 31
         $schema = __DIR__.'/../../../../api/schemas/workspaceList.json';
32 32
 
33 33
         $client = $this->createClient();
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
         $response = $client->getResponse();
38 38
 
39 39
         $data = $client->getResponse()->getContent();
40
-        $validator = $this->askValidation($data,$schema);
40
+        $validator = $this->askValidation($data, $schema);
41 41
 
42 42
         $assert = $this->evalValidation($validator);
43 43
         $this->assertTrue($assert);
44 44
         return $data;
45 45
     }
46 46
     /*verifico che si possa condividere il workspace */
47
-    public function testGetWorkspaceShare(){
47
+    public function testGetWorkspaceShare() {
48 48
         $schema = __DIR__.'/../../../../api/schemas/workspaceShare.json';
49 49
 
50 50
         $client = $this->createClient();
@@ -55,19 +55,19 @@  discard block
 block discarded – undo
55 55
 
56 56
         //print_r($response);
57 57
         $data = $client->getResponse()->getContent();
58
-        $validator = $this->askValidation($data,$schema);
58
+        $validator = $this->askValidation($data, $schema);
59 59
 
60 60
         $assert = $this->evalValidation($validator);
61 61
         $this->assertTrue($assert);
62 62
     }
63 63
 
64
-    public function testPostWorkspace(){
64
+    public function testPostWorkspace() {
65 65
         //$schema = __DIR__.'/../../../../api/schemas/workspace.json';
66 66
 
67 67
         $client = $this->createClient();
68 68
         $client = $this->logIn($client);
69 69
 
70
-        $wp ='{
70
+        $wp = '{
71 71
               "title":"Sopraelevata",
72 72
               "description":"I Sarchiaponi sono pronti a lanciarsi nella costruzione di una sopraelevata",
73 73
               "environment": 22,
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
         $data = $client->getResponse()->getContent();
93 93
         $id = json_decode($data);
94 94
 
95
-        $id=$id->id;
95
+        $id = $id->id;
96 96
 
97 97
         $this->assertTrue(is_numeric($id));
98 98
 
99 99
         return $id;
100 100
     }
101
-    public function testPutWorkspace(){
101
+    public function testPutWorkspace() {
102 102
         //$schema = __DIR__.'/../../../../api/schemas/workspace.json';
103 103
 
104 104
         $id = $this->testPostWorkspace();
105
-        $wp ='{
105
+        $wp = '{
106 106
               "id":'.$id.',
107 107
               "title":"Sopraelevata_EDIT",
108 108
               "description":"I Sarchiaponi sono pronti a lanciarsi nella costruzione di una sopraelevata",
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         $this->assertTrue($response->isOk());
138 138
     }
139
-    public function testDeleteWorkspace(){
139
+    public function testDeleteWorkspace() {
140 140
         //$schema = __DIR__.'/../../../../api/schemas/workspace.json';
141 141
         $id = $this->testPostWorkspace();
142 142
         $client = $this->createClient();
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
         $this->assertTrue($response->isOk());
155 155
 
156 156
         $data = $this->testGetWorkspaceList();
157
-        $js= json_decode($data);
157
+        $js = json_decode($data);
158 158
         $trovato = false;
159
-        foreach($js as $w){
160
-            if($w->id === $id){
161
-                $trovato=true;
159
+        foreach ($js as $w) {
160
+            if ($w->id === $id) {
161
+                $trovato = true;
162 162
             }
163 163
         }
164 164
         $this->assertTrue(!$trovato);
Please login to merge, or discard this patch.
applications/workspace/src/App.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,10 @@
 block discarded – undo
26 26
 $app['log.level'] = Monolog\Logger::DEBUG; //ERROR in prod
27 27
 $app['api.version'] = "v1";
28 28
 $app['api.endpoint'] = "/api";
29
-if (!defined('ROOT_PATH'))
30
-    define('ROOT_PATH', __DIR__); //solo in dev va bene
29
+if (!defined('ROOT_PATH')) {
30
+    define('ROOT_PATH', __DIR__);
31
+}
32
+//solo in dev va bene
31 33
 // @remember: https://{enviroment}.{domain}/{contextPath}/api/v1
32 34
 
33 35
 // manca il contesto , FIXME: da pensare le ACL di haproxy come saranno da qui si decide come usare come mountpoint
Please login to merge, or discard this patch.
applications/workspace/test/Tests/AbstractAppTest.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -33,6 +33,9 @@
 block discarded – undo
33 33
         return $client;
34 34
     }
35 35
 
36
+    /**
37
+     * @param string $schema
38
+     */
36 39
     public function askValidation($data, $schema)
37 40
     {
38 41
         $validator = new \JsonSchema\Validator;
Please login to merge, or discard this patch.
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -2,11 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Tests;
4 4
 
5
-use JsonSchema\Constraints\Constraint;
6
-use JsonSchema\SchemaStorage;
7
-use JsonSchema\Uri\UriResolver;
8 5
 use JsonSchema\Validator;
9
-use Prophecy\Argument;
10 6
 
11 7
 trait AbstractAppTest
12 8
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,17 +36,17 @@
 block discarded – undo
36 36
     public function askValidation($data, $schema)
37 37
     {
38 38
         $validator = new \JsonSchema\Validator;
39
-        $js_schema =  (object)['$ref' => 'file://' . $schema];
39
+        $js_schema = (object)['$ref' => 'file://'.$schema];
40 40
         $validator->check(json_decode($data), $js_schema);
41 41
         return $validator;
42 42
     }
43 43
 
44
-    public function evalValidation($validator){
44
+    public function evalValidation($validator) {
45 45
         $assert = false;
46 46
         if ($validator->isValid()) {
47 47
             echo "The supplied JSON validates against the schema.\n";
48 48
             $assert = true;
49
-        } else {
49
+        }else {
50 50
             echo "JSON does not validate. Violations:\n";
51 51
             foreach ($validator->getErrors() as $error) {
52 52
                 echo "[{$error['property']}] {$error['message']}\n";
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@
 block discarded – undo
24 24
     public function logIn($client)
25 25
     {
26 26
         $client->request(
27
-          'POST',
28
-          '/api/v1/security/login',
29
-          [],
30
-          [],
31
-          ['CONTENT_TYPE' => 'application/json'],
32
-          '{"authMode":"Email","email":"[email protected]","name":"ugo","surname":"ugo","password":"cane"}');
27
+            'POST',
28
+            '/api/v1/security/login',
29
+            [],
30
+            [],
31
+            ['CONTENT_TYPE' => 'application/json'],
32
+            '{"authMode":"Email","email":"[email protected]","name":"ugo","surname":"ugo","password":"cane"}');
33 33
         return $client;
34 34
     }
35 35
     public function logIn2($client)
36 36
     {
37 37
         $client->request(
38
-          'POST',
39
-          '/api/v1/security/login',
40
-          [],
41
-          [],
42
-          ['CONTENT_TYPE' => 'application/json'],
43
-          '{"authMode":"Email","email":"ugo2","name":"ugo2","surname":"ugo2","password":"cane"}');
38
+            'POST',
39
+            '/api/v1/security/login',
40
+            [],
41
+            [],
42
+            ['CONTENT_TYPE' => 'application/json'],
43
+            '{"authMode":"Email","email":"ugo2","name":"ugo2","surname":"ugo2","password":"cane"}');
44 44
         return $client;
45 45
     }
46 46
 
Please login to merge, or discard this patch.
src/BitPrepared/Bundle/D1b0Workspace/Controller/V1/WorkspaceController.php 2 patches
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                 $headers = [];
276 276
                 $response = JsonResponse::create(["id"=>$wp_id], 200, $headers)->setSharedMaxAge(300);
277 277
 
278
-            }else{
278
+            } else{
279 279
                 $headers = [];
280 280
                 $response = JsonResponse::create(["message"=>"Key no more valid"], 498, $headers)->setSharedMaxAge(300);
281 281
             }
@@ -358,8 +358,9 @@  discard block
 block discarded – undo
358 358
         }
359 359
         foreach($partecipants as $p){
360 360
             array_push($res['partecipants'],$p->user);//TODO forse va usato l'id del c'ero e non l'id dell'utente
361
-            if($user_id == $r['id'])
362
-                $checked = true;
361
+            if($user_id == $r['id']) {
362
+                            $checked = true;
363
+            }
363 364
         }
364 365
         $res['present'] = true;
365 366
 
@@ -402,8 +403,10 @@  discard block
 block discarded – undo
402 403
                 $resource->totalpoint = 0;
403 404
             $resource_id = R::store($resource);
404 405
             $rem_id=getPositionInArray($delete_res,$resource_id);
405
-            if($rem_id != 0)
406
-                array_splice($delete_res,$rem_id,1); //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
406
+            if($rem_id != 0) {
407
+                            array_splice($delete_res,$rem_id,1);
408
+            }
409
+            //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
407 410
         }
408 411
 
409 412
         foreach($delete_res as $d){
@@ -421,8 +424,10 @@  discard block
 block discarded – undo
421 424
                 $pb->part = $part_id;
422 425
             $tmp = R::store($pb);
423 426
             $rem_id=getPositionInArray($delete_badge,$tmp);
424
-            if($rem_id != 0)
425
-                array_splice($delete_badge,$rem_id,1); //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
427
+            if($rem_id != 0) {
428
+                            array_splice($delete_badge,$rem_id,1);
429
+            }
430
+            //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
426 431
         }
427 432
 
428 433
         foreach($delete_badge as $d){
@@ -465,7 +470,7 @@  discard block
 block discarded – undo
465 470
                 if($b->completed === True){
466 471
                     echo "CASO 1;<BR />";
467 472
                     return $this->POINT_FOR_USING_A_CONQUERED_BADGE;
468
-                }else{
473
+                } else{
469 474
                     echo "CASO 2;<BR />";
470 475
                     return $this->POINT_FOR_USING_A_BADGE;
471 476
                 }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         return JsonResponse::create($res, 201, $headers)->setSharedMaxAge(300);
135 135
     }
136 136
 
137
-    public function putWorkspace($id,Request $request)
137
+    public function putWorkspace($id, Request $request)
138 138
     {
139 139
         $user_id = $this->getSessionId();
140 140
         $data = json_decode($request->getContent(), true);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         $unit = $data['team']['unit'];
149 149
         $group = $data['team']['group'];
150 150
 
151
-        $ws = R::load("workspace",intval($id));
151
+        $ws = R::load("workspace", intval($id));
152 152
             $ws->title = $title;
153 153
             $ws->description = $description;
154 154
             $ws->environment = $environment;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         $id = R::store($ws);
158 158
 
159 159
         //save the team
160
-        $team = R::findOne("team","workspace = ?",[$id]);
160
+        $team = R::findOne("team", "workspace = ?", [$id]);
161 161
             $team->patrol = $patrol;
162 162
             $team->unit = $unit;
163 163
             $team->group = $group;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         $team = R::findOne("team", "workspace = ?", [$id]);
181 181
         $part = R::findAll("part", "workspace = ? AND DELETED = 0", [$id]);
182 182
 
183
-        $badges = R::findAll("workspacebadge", "workspace = ?", [$id]);//TODO controllare i deleted
183
+        $badges = R::findAll("workspacebadge", "workspace = ?", [$id]); //TODO controllare i deleted
184 184
 
185 185
         $l_part = [];
186 186
         foreach ($part as $p) {
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
         return JsonResponse::create($res, 201, $headers)->setSharedMaxAge(300);
210 210
     }
211 211
 
212
-    public function deleteWorkspace($id,Request $request)
212
+    public function deleteWorkspace($id, Request $request)
213 213
     {
214 214
         //Disassocia un utente da un workspace
215 215
         $user_id = $this->getSessionId();
216 216
 
217
-        $wp = R::findOne("userworkspace","workspace = ? AND user = ?",[$id,$user_id]);
217
+        $wp = R::findOne("userworkspace", "workspace = ? AND user = ?", [$id, $user_id]);
218 218
         R::trash($wp);
219 219
 
220 220
         $response = new Response();
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 
260 260
         $key = $data['key'];
261 261
 
262
-        $share = R::findOne("share","key = ?",[$key]);
262
+        $share = R::findOne("share", "key = ?", [$key]);
263 263
         echo $share->inserttime;
264
-        if($share !== NULL){
264
+        if ($share !== NULL) {
265 265
             $date = new \DateTime();
266 266
             date_sub($date, date_interval_create_from_date_string('15 minutes'));
267 267
 
268
-            $wp_id=$share['workspace'];
268
+            $wp_id = $share['workspace'];
269 269
 
270 270
             $dateOld = new \DateTime($share->inserttime);
271
-            if($dateOld > $date){
271
+            if ($dateOld > $date) {
272 272
                 $usw = R::dispense("userworkspace");
273 273
                     $usw->user = $user_id;
274 274
                     $usw->workspace = $wp_id;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 $headers = [];
278 278
                 $response = JsonResponse::create(["id"=>$wp_id], 200, $headers)->setSharedMaxAge(300);
279 279
 
280
-            }else{
280
+            }else {
281 281
                 $headers = [];
282 282
                 $response = JsonResponse::create(["message"=>"Key no more valid"], 498, $headers)->setSharedMaxAge(300);
283 283
             }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $part_id = R::store($part);
302 302
 
303 303
 
304
-        foreach($data['part'] as $r){ //TODO va fixato nelle api
304
+        foreach ($data['part'] as $r) { //TODO va fixato nelle api
305 305
             $resource = R::dispense("resource");
306 306
                 $resource->part = $part_id;
307 307
                 $resource->inserttime = date($this->DATE_FORMAT);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             $resource_id = R::store($resource);
315 315
         }
316 316
 
317
-        foreach($data['badges'] as $badge_id){ //TODO va fixato nelle api
317
+        foreach ($data['badges'] as $badge_id) { //TODO va fixato nelle api
318 318
             $pb = R::dispense("partbadge");
319 319
                 $pb->badge = $badge_id;
320 320
                 $pb->part = $part_id;
@@ -327,21 +327,21 @@  discard block
 block discarded – undo
327 327
         return JsonResponse::create($res, 201, $headers)->setSharedMaxAge(300);
328 328
     }
329 329
 
330
-    public function getPart($id,$part_id, Request $request) {
330
+    public function getPart($id, $part_id, Request $request) {
331 331
         $user_id = $this->getSessionId();
332 332
 
333 333
         $data = json_decode($request->getContent(), true);
334 334
 
335
-        $part = R::findOne("part","id = ?",[$part_id]);
335
+        $part = R::findOne("part", "id = ?", [$part_id]);
336 336
 
337
-        $resource = R::findAll("resource","part = ?",[$part_id]);
337
+        $resource = R::findAll("resource", "part = ?", [$part_id]);
338 338
 
339
-        $partecipants = R::findAll("cero","part = ?",[$part_id]);
339
+        $partecipants = R::findAll("cero", "part = ?", [$part_id]);
340 340
 
341
-        $badges = R::findAll("partbadge","part = ? AND deleted = 0",[$part_id]);
341
+        $badges = R::findAll("partbadge", "part = ? AND deleted = 0", [$part_id]);
342 342
 
343 343
         $checked = false;
344
-        $res= [
344
+        $res = [
345 345
             "id"=>intval($part->id),
346 346
             "creation"=>$part->inserttime,
347 347
             "points"=>intval($part->points),
@@ -350,20 +350,20 @@  discard block
 block discarded – undo
350 350
             "partecipants"=>[]
351 351
         ];
352 352
 
353
-        foreach($badges as $b){
354
-            array_push($res['badges'],$b->id);
353
+        foreach ($badges as $b) {
354
+            array_push($res['badges'], $b->id);
355 355
         }
356
-        foreach($resource as $r){
357
-            array_push($res['part'],[
356
+        foreach ($resource as $r) {
357
+            array_push($res['part'], [
358 358
                 "type"=>$r->type,
359 359
                 "hash"=>$r->hash,
360 360
                 "ref"=>$r->ref
361 361
             ]);
362 362
 
363 363
         }
364
-        foreach($partecipants as $p){
365
-            array_push($res['partecipants'],$p->user);//TODO forse va usato l'id del c'ero e non l'id dell'utente
366
-            if($user_id == $r['id'])
364
+        foreach ($partecipants as $p) {
365
+            array_push($res['partecipants'], $p->user); //TODO forse va usato l'id del c'ero e non l'id dell'utente
366
+            if ($user_id == $r['id'])
367 367
                 $checked = true;
368 368
         }
369 369
         $res['present'] = true;
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
         return JsonResponse::create($res, 201, $headers)->setSharedMaxAge(300);
373 373
     }
374 374
 
375
-    private function getPositionInArray($array,$id){
376
-        $count =0;
377
-        foreach($array as $a){
378
-            if($a->id === $id){
375
+    private function getPositionInArray($array, $id) {
376
+        $count = 0;
377
+        foreach ($array as $a) {
378
+            if ($a->id === $id) {
379 379
                 return $count;
380 380
             }
381 381
             $count = $count + 1;
@@ -383,13 +383,13 @@  discard block
 block discarded – undo
383 383
         return -1;
384 384
     }
385 385
 
386
-    public function putPart($id,$part_id, Request $request) {
386
+    public function putPart($id, $part_id, Request $request) {
387 387
         $user_id = $this->getSessionId();
388 388
 
389 389
         $data = json_decode($request->getContent(), true);
390 390
 
391 391
 
392
-        $part = R::load("part",$part_id);
392
+        $part = R::load("part", $part_id);
393 393
             $part->workspace = $id;
394 394
             $part->user = $user_id;
395 395
             $part->lastupdatetime = date($this->DATE_FORMAT);
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
             $part->deleted = false;
398 398
         $part_id = R::store($part);
399 399
 
400
-        $delete_res=R::findAll("resource","WHERE part = ?",[$part_id]);
400
+        $delete_res = R::findAll("resource", "WHERE part = ?", [$part_id]);
401 401
 
402
-        foreach($data['part'] as $r){ //TODO va fixato nelle api
403
-            $resource = R::findOne("resource","WHERE hash = ? AND deleted = 0",[$r['hash']]);//TODO BISOGNA FARE IL DIFF TRA QUELLE PRESENTI E QUELLE NON PRESENTI
404
-                if($resource == 0){
402
+        foreach ($data['part'] as $r) { //TODO va fixato nelle api
403
+            $resource = R::findOne("resource", "WHERE hash = ? AND deleted = 0", [$r['hash']]); //TODO BISOGNA FARE IL DIFF TRA QUELLE PRESENTI E QUELLE NON PRESENTI
404
+                if ($resource == 0) {
405 405
                     $resource = R::dispense("resource");
406 406
                     $resource->available = false;
407 407
                     $resource->inserttime = date($this->DATE_FORMAT);
@@ -413,34 +413,34 @@  discard block
 block discarded – undo
413 413
                 $resource->hash = $r['hash'];
414 414
                 $resource->totalpoint = 0;
415 415
             $resource_id = R::store($resource);
416
-            $rem_id=$this->getPositionInArray($delete_res,$resource_id);
417
-            if($rem_id != 0)
418
-                array_splice($delete_res,$rem_id,1); //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
416
+            $rem_id = $this->getPositionInArray($delete_res, $resource_id);
417
+            if ($rem_id != 0)
418
+                array_splice($delete_res, $rem_id, 1); //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
419 419
         }
420 420
 
421
-        foreach($delete_res as $d){
421
+        foreach ($delete_res as $d) {
422 422
             //RIMUOVO REALMENTE DAL DB LE COSE CHE HO LASCIATO FUORI DALLA PUT (PRESENTI NEL DB MA NON NELLA NUOVA VERSIONE ODIO LE PUT)
423
-            $resource = R::load("resource",$d->id);
424
-            $resource->deleted=true;
423
+            $resource = R::load("resource", $d->id);
424
+            $resource->deleted = true;
425 425
             R::store($resource);
426 426
         }
427 427
 
428
-        $delete_badge=R::findAll("partbadge","WHERE part = ? AND deleted = 0",[$part_id]);
428
+        $delete_badge = R::findAll("partbadge", "WHERE part = ? AND deleted = 0", [$part_id]);
429 429
 
430
-        foreach($data['badges'] as $badge_id){
431
-            $pb = R::load("partbadge",$badge_id);
430
+        foreach ($data['badges'] as $badge_id) {
431
+            $pb = R::load("partbadge", $badge_id);
432 432
                 $pb->badge = $badge_id;
433 433
                 $pb->part = $part_id;
434 434
             $tmp = R::store($pb);
435
-            $rem_id=$this->getPositionInArray($delete_badge,$tmp);
436
-            if($rem_id != 0)
437
-                array_splice($delete_badge,$rem_id,1); //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
435
+            $rem_id = $this->getPositionInArray($delete_badge, $tmp);
436
+            if ($rem_id != 0)
437
+                array_splice($delete_badge, $rem_id, 1); //RIMUOVO GLI ELEMENTI CHE HO MODIFICATO
438 438
         }
439 439
 
440
-        foreach($delete_badge as $d){
440
+        foreach ($delete_badge as $d) {
441 441
             //RIMUOVO REALMENTE DAL DB LE COSE CHE HO LASCIATO FUORI DALLA PUT (PRESENTI NEL DB MA NON NELLA NUOVA VERSIONE ODIO LE PUT)
442
-            $badge = R::load("partbadge",$d['id']);//FORSE RILOADARLI NON È NECESSARIO
443
-            $badge->deleted=true;
442
+            $badge = R::load("partbadge", $d['id']); //FORSE RILOADARLI NON È NECESSARIO
443
+            $badge->deleted = true;
444 444
             R::store($badge);
445 445
         }
446 446
 
@@ -449,17 +449,17 @@  discard block
 block discarded – undo
449 449
         return JsonResponse::create($res, 201, $headers)->setSharedMaxAge(300);
450 450
     }
451 451
 
452
-    public function deletePart($id,$part_id, Request $request) {
452
+    public function deletePart($id, $part_id, Request $request) {
453 453
         $user_id = $this->getSessionId();
454
-        $part = R::load("part",$part_id);
455
-            $part->deleted=true;
454
+        $part = R::load("part", $part_id);
455
+            $part->deleted = true;
456 456
         R::store($part);
457 457
 
458 458
 
459
-        $delete_badge=R::findAll("partbadge","WHERE part = ?",[$part_id]);
460
-        foreach($delete_badge as $d){
461
-            $badge = R::load("partbadge",[$d->id]);//FORSE RILOADARLI NON È NECESSARIO BASTA FARE $d->deleted=true; e store($d)
462
-                $badge->deleted=true;
459
+        $delete_badge = R::findAll("partbadge", "WHERE part = ?", [$part_id]);
460
+        foreach ($delete_badge as $d) {
461
+            $badge = R::load("partbadge", [$d->id]); //FORSE RILOADARLI NON È NECESSARIO BASTA FARE $d->deleted=true; e store($d)
462
+                $badge->deleted = true;
463 463
             R::store($badge);
464 464
         }
465 465
 
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
         $response->setSharedMaxAge(300);
472 472
     }
473 473
 
474
-    private function getPoint($badge_id,$badges){
475
-        foreach($badges as $b){
476
-            if($b->id === $badge_id){
477
-                if($b->completed === True){
474
+    private function getPoint($badge_id, $badges) {
475
+        foreach ($badges as $b) {
476
+            if ($b->id === $badge_id) {
477
+                if ($b->completed === True) {
478 478
                     echo "CASO 1;<BR />";
479 479
                     return $this->POINT_FOR_USING_A_CONQUERED_BADGE;
480
-                }else{
480
+                }else {
481 481
                     echo "CASO 2;<BR />";
482 482
                     return $this->POINT_FOR_USING_A_BADGE;
483 483
                 }
@@ -486,16 +486,16 @@  discard block
 block discarded – undo
486 486
         echo "CASO 3;<BR />";
487 487
         return $this->POINT_DEFAULT;
488 488
     }
489
-    public function checkin($id,$part_id, Request $request) {
489
+    public function checkin($id, $part_id, Request $request) {
490 490
         $user_id = $this->getSessionId();
491 491
 
492
-        $badges = R::findAll("partbadge","part = ? AND deleted = 0",[$part_id]);
493
-        $u_badges = R::findAll("userbadge","user = ? AND deleted = 0",[$user_id]);
492
+        $badges = R::findAll("partbadge", "part = ? AND deleted = 0", [$part_id]);
493
+        $u_badges = R::findAll("userbadge", "user = ? AND deleted = 0", [$user_id]);
494 494
 
495 495
         $point_earned = 0;
496
-        foreach($badges as $b){ //SE CI SONO DEI BADGE
497
-            $point = $this->getPoint($b->id,$u_badges);
498
-            if($point != $this->POINT_DEFAULT){ //SE SEI IN CAMMINO PER QUEI BADGE O SE LI POSSIEDI GIÀ
496
+        foreach ($badges as $b) { //SE CI SONO DEI BADGE
497
+            $point = $this->getPoint($b->id, $u_badges);
498
+            if ($point != $this->POINT_DEFAULT) { //SE SEI IN CAMMINO PER QUEI BADGE O SE LI POSSIEDI GIÀ
499 499
                 echo "PUNTI:".$point;
500 500
                 $point_earned = $point_earned + $point;
501 501
                 $pb = R::dispense("cero");
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
                     $pb->points = $point;
507 507
                 $tmp = R::store($pb);
508 508
 
509
-                if($point === $this->POINT_FOR_USING_A_BADGE){ //SE SEI IN CAMMINO MA NON LI HAI ANCORA RAGGIUNTI
509
+                if ($point === $this->POINT_FOR_USING_A_BADGE) { //SE SEI IN CAMMINO MA NON LI HAI ANCORA RAGGIUNTI
510 510
                     $ubc = R::dispense("userbadgeclove");
511 511
                         $ubc->user = $user_id;
512 512
                         $ubc->badge = $b->id;
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
             }
518 518
         }
519 519
 
520
-        if($point_earned <= 0){ //SE NON CI SONO BADGE O SE TU NON SEI IN CAMMINO PER NESSUNO DI LORO
520
+        if ($point_earned <= 0) { //SE NON CI SONO BADGE O SE TU NON SEI IN CAMMINO PER NESSUNO DI LORO
521 521
             $pb = R::dispense("cero");
522 522
                 $pb->user = $user_id;
523 523
                 $pb->part = $part_id;
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
 
532 532
     }
533 533
 
534
-    public function deleteCheckin($id,$part_id, Request $request) {
534
+    public function deleteCheckin($id, $part_id, Request $request) {
535 535
         $user_id = $this->getSessionId();
536 536
 
537
-        $u_badges = R::findAll("userbadge","user = ? AND part = ?",[$user_id,$part_id]);
537
+        $u_badges = R::findAll("userbadge", "user = ? AND part = ?", [$user_id, $part_id]);
538 538
         R::trashAll($u_badges);
539 539
 
540
-        $cero = R::findAll("cero","user = ? AND part = ?",[$user_id,$part_id]);
540
+        $cero = R::findAll("cero", "user = ? AND part = ?", [$user_id, $part_id]);
541 541
         R::trashAll($cero);
542 542
 
543 543
         $response = new Response();
Please login to merge, or discard this patch.
applications/workspace/test/Tests/PartTest.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace Tests;
4 4
 
5
-use Silex\WebTestCase;
6
-use JsonSchema\Validator;
7
-
8 5
 class PartTest extends WorkspaceTest
9 6
 {
10 7
     use AbstractAppTest;
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
             "badges":[13,28]}';
62 62
 
63 63
         $client->request(
64
-          'POST',
65
-          '/api/v1/workspace/'.$id.'/part',
66
-          [],
67
-          [],
68
-          ['CONTENT_TYPE' => 'application/json'],
69
-          $part);
64
+            'POST',
65
+            '/api/v1/workspace/'.$id.'/part',
66
+            [],
67
+            [],
68
+            ['CONTENT_TYPE' => 'application/json'],
69
+            $part);
70 70
 
71 71
         $response = $client->getResponse();
72 72
 
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
             "badges":[13,30]}';
108 108
 
109 109
         $client->request(
110
-          'PUT',
111
-          '/api/v1/workspace/'.$id.'/part/'.$part_id.'',
112
-          [],
113
-          [],
114
-          ['CONTENT_TYPE' => 'application/json'],
115
-          $part);
110
+            'PUT',
111
+            '/api/v1/workspace/'.$id.'/part/'.$part_id.'',
112
+            [],
113
+            [],
114
+            ['CONTENT_TYPE' => 'application/json'],
115
+            $part);
116 116
 
117 117
         $response = $client->getResponse();
118 118
         $data = $client->getResponse()->getContent();
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
         $part_id = $this->testPostWorkspacePart();
132 132
 
133 133
         $client->request(
134
-          'DELETE',
135
-          '/api/v1/workspace/'.$id.'/part/'.$part_id.'',
136
-          [],
137
-          [],
138
-          [],
139
-          '');
134
+            'DELETE',
135
+            '/api/v1/workspace/'.$id.'/part/'.$part_id.'',
136
+            [],
137
+            [],
138
+            [],
139
+            '');
140 140
 
141 141
         $response = $client->getResponse();
142 142
         $this->assertTrue($response->isOk());
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 
13 13
     /*verifico che una parte si possa scaricare correttamente*/
14
-    public function testGetWorkspacePart(){
14
+    public function testGetWorkspacePart() {
15 15
         $schema = __DIR__.'/../../../../api/schemas/part.json';
16 16
 
17 17
         $client = $this->createClient();
@@ -22,40 +22,40 @@  discard block
 block discarded – undo
22 22
 
23 23
         //print_r($response);
24 24
         $data = $client->getResponse()->getContent();
25
-        $validator = $this->askValidation($data,$schema);
25
+        $validator = $this->askValidation($data, $schema);
26 26
 
27 27
         $assert = $this->evalValidation($validator);
28 28
         $this->assertTrue($assert);
29 29
     }
30 30
 
31 31
 
32
-    public function testPostWorkspacePart(){
32
+    public function testPostWorkspacePart() {
33 33
         //$schema = __DIR__.'/../../../../api/schemas/part.json';
34 34
 
35 35
         $client = $this->createClient();
36 36
         $client = $this->logIn($client);
37 37
 
38 38
         $id = $this->testPostWorkspace();
39
-        $part ='{"part":[
39
+        $part = '{"part":[
40 40
                 {
41 41
                     "type": "image",
42 42
                     "ref": "afaifnanabnawnfawba",
43
-                    "hash":"'.hash("md5",$id."prova0").'"
43
+                    "hash":"'.hash("md5", $id."prova0").'"
44 44
                 },
45 45
                 {
46 46
                     "type": "image",
47 47
                     "ref": "awfaowapaegbgepng",
48
-                    "hash":"'.hash("md5",$id."prova1").'"
48
+                    "hash":"'.hash("md5", $id."prova1").'"
49 49
                 },
50 50
                 {
51 51
                     "type": "text",
52 52
                     "ref": "afaafaafafafifnanabnawnfawba",
53
-                    "hash":"'.hash("md5",$id."prova2").'"
53
+                    "hash":"'.hash("md5", $id."prova2").'"
54 54
                 },
55 55
                 {
56 56
                     "type": "video",
57 57
                     "ref": "aaafawafaggagaagegaa",
58
-                    "hash":"'.hash("md5",$id."prova3").'"
58
+                    "hash":"'.hash("md5", $id."prova3").'"
59 59
                 }
60 60
             ],
61 61
             "badges":[13,28]}';
@@ -73,37 +73,37 @@  discard block
 block discarded – undo
73 73
         $data = $client->getResponse()->getContent();
74 74
         $part_id = json_decode($data);
75 75
 
76
-        $part_id=$part_id->id;
76
+        $part_id = $part_id->id;
77 77
 
78 78
         $this->assertTrue(is_numeric($id));
79
-        return [$id,$part_id];
79
+        return [$id, $part_id];
80 80
     }
81 81
 
82
-    public function testPutWorkspacePart(){
82
+    public function testPutWorkspacePart() {
83 83
         $client = $this->createClient();
84 84
         $client = $this->logIn($client);
85 85
 
86 86
 
87 87
         $blob = $this->testPostWorkspacePart();
88 88
         $id = $blob[0];
89
-        $part_id= $blob[1];
90
-        $part ='{
89
+        $part_id = $blob[1];
90
+        $part = '{
91 91
                 "id":'.$part_id.',
92 92
                 "part":[
93 93
                 {
94 94
                     "type": "image",
95 95
                     "ref": "afaifnanabnawnfawba",
96
-                    "hash":"'.hash("md5",$id."prova0").'"
96
+                    "hash":"'.hash("md5", $id."prova0").'"
97 97
                 },
98 98
                 {
99 99
                     "type": "image",
100 100
                     "ref": "awfaowapaegbgepng",
101
-                    "hash":"'.hash("md5",$id."prova1").'"
101
+                    "hash":"'.hash("md5", $id."prova1").'"
102 102
                 },
103 103
                 {
104 104
                     "type": "text",
105 105
                     "ref": "blablablablabla",
106
-                    "hash":"'.hash("md5",$id."prova2").'"
106
+                    "hash":"'.hash("md5", $id."prova2").'"
107 107
                 }
108 108
             ],
109 109
             "badges":[13,30]}';
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
         $data = $client->getResponse()->getContent();
121 121
         $id = json_decode($data);
122 122
 
123
-        $res_id=$id->id;
123
+        $res_id = $id->id;
124 124
 
125
-        $this->assertEquals($part_id,$res_id);
125
+        $this->assertEquals($part_id, $res_id);
126 126
     }
127 127
 
128
-    public function testDeleteWorkspacePart(){
128
+    public function testDeleteWorkspacePart() {
129 129
         $client = $this->createClient();
130 130
         $client = $this->logIn($client);
131 131
 
132 132
         $blob = $this->testPostWorkspacePart();
133 133
         $id = $blob[0];
134
-        $part_id= $blob[1];
134
+        $part_id = $blob[1];
135 135
 
136 136
         $client->request(
137 137
           'DELETE',
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         var_dump($data);
155 155
         $trovato = false;
156 156
 
157
-        foreach($js->parts as $w){
158
-            if($w === $part_id){
159
-                $trovato=true;
157
+        foreach ($js->parts as $w) {
158
+            if ($w === $part_id) {
159
+                $trovato = true;
160 160
             }
161 161
         }
162 162
         $this->assertTrue(!$trovato);
Please login to merge, or discard this patch.