Completed
Push — master ( f6dfc7...eed325 )
by Hugo
02:57
created
app/library/DisplayedMessage.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -10,6 +10,10 @@
 block discarded – undo
10 10
 	private $timerInterval;
11 11
 	private $dismissable;
12 12
 	private $visible;
13
+
14
+	/**
15
+	 * @param string $content
16
+	 */
13 17
 	public function DisplayedMessage($content,$type="success",$timerInterval=0,$dismissable=true,$visible=true){
14 18
 		$this->content=$content;
15 19
 		$this->type=$type;
Please login to merge, or discard this patch.
app/config/services.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * The URL component is used to generate all kind of urls in the application
22 22
  */
23
-$di->set('url', function () use ($config) {
23
+$di->set('url', function() use ($config) {
24 24
     $url = new UrlResolver();
25 25
     $url->setBaseUri($config->application->baseUri);
26 26
 
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 /**
31 31
  * Setting up the view component
32 32
  */
33
-$di->set('view', function () use ($config) {
33
+$di->set('view', function() use ($config) {
34 34
 
35 35
     $view = new View();
36 36
 
37 37
     $view->setViewsDir($config->application->viewsDir);
38 38
 
39 39
     $view->registerEngines(array(
40
-        '.volt' => function ($view, $di) use ($config) {
40
+        '.volt' => function($view, $di) use ($config) {
41 41
 
42 42
             $volt = new VoltEngine($view, $di);
43 43
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 /**
58 58
  * Database connection is created based in the parameters defined in the configuration file
59 59
  */
60
-$di->set('db', function () use ($config) {
60
+$di->set('db', function() use ($config) {
61 61
     return new DbAdapter(array(
62 62
         'host' => $config->database->host,
63 63
         'username' => $config->database->username,
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 });
71 71
 
72 72
 
73
-$di->set('baseUrl', function () use ($config) {
73
+$di->set('baseUrl', function() use ($config) {
74 74
     $baseUrl = $config->application->baseUri;
75 75
     return $baseUrl;
76 76
 });
@@ -78,34 +78,34 @@  discard block
 block discarded – undo
78 78
 /**
79 79
  * If the configuration specify the use of metadata adapter use it or use memory otherwise
80 80
  */
81
-$di->set('modelsMetadata', function () {
81
+$di->set('modelsMetadata', function() {
82 82
     return new MetaDataAdapter();
83 83
 });
84 84
 
85 85
 /**
86 86
  * Start the session the first time some component request the session service
87 87
  */
88
-$di->set('session', function () {
88
+$di->set('session', function() {
89 89
     $session = new SessionAdapter();
90 90
     $session->start();
91 91
 
92 92
     return $session;
93 93
 });
94 94
 
95
-$di->set("jquery", function () {
95
+$di->set("jquery", function() {
96 96
     $jquery = new JsUtils(array("driver" => "Jquery"));
97 97
     $jquery->bootstrap(new Bootstrap());
98 98
     //$jquery->ui(new Ajax\JqueryUI());//optional for JQuery UI
99 99
     return $jquery;
100 100
 });
101 101
 
102
-$di->set('dispatcher', function () {
102
+$di->set('dispatcher', function() {
103 103
 
104 104
     // Create an event manager
105 105
     $eventsManager = new EventsManager();
106 106
 
107 107
     // Attach a listener for type "dispatch"
108
-    $eventsManager->attach("dispatch", function ($event, $dispatcher) {
108
+    $eventsManager->attach("dispatch", function($event, $dispatcher) {
109 109
         // ...
110 110
     });
111 111
 
Please login to merge, or discard this patch.
app/controllers/IndexController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
     protected $title;
7 7
     protected $controller;
8 8
 
9
-    public function initialize(){
9
+    public function initialize() {
10 10
         $this->model = "Index";
11 11
         $this->title = "Accueil";
12
-        $this->controller= "Index";
12
+        $this->controller = "Index";
13 13
     }
14 14
 
15 15
     public function indexAction()
Please login to merge, or discard this patch.
app/controllers/MessagesController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@
 block discarded – undo
3 3
 class MessagesController extends ControllerBase
4 4
 {
5 5
 
6
-    public function initialize(){
6
+    public function initialize() {
7 7
         $this->model = "Message";
8 8
         $this->title = "Messages";
9
-        $this->controller= "Messages";
9
+        $this->controller = "Messages";
10 10
 
11 11
     }
12 12
 }
Please login to merge, or discard this patch.
app/models/Message.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@
 block discarded – undo
249 249
         return parent::findFirst($parameters);
250 250
     }
251 251
 
252
-    public function toString(){
252
+    public function toString() {
253 253
         return $this->content;
254 254
     }
255 255
 
Please login to merge, or discard this patch.
app/models/TypeUser.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,6 @@  discard block
 block discarded – undo
31 31
     /**
32 32
      * Method to set the value of field objet
33 33
      *
34
-     * @param string $objet
35 34
      * @return $this
36 35
      */
37 36
     public function setLibelle($libelle)
@@ -94,7 +93,7 @@  discard block
 block discarded – undo
94 93
     /**
95 94
      * Allows to query the first record that match the specified conditions
96 95
      *
97
-     * @param mixed $parameters
96
+     * @param string $parameters
98 97
      * @return TypeUser
99 98
      */
100 99
     public static function findFirst($parameters = null)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
     }
103 103
     
104 104
     public function toString() {
105
-    	return $this->libelle;
105
+     return $this->libelle;
106 106
     }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
app/models/Operation.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
     }
103 103
     
104 104
     public function toString() {
105
-    	return $this->operation;
105
+     return $this->operation;
106 106
     }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
app/models/Ressource.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
     }
103 103
     
104 104
     public function toString() {
105
-    	return $this->libelle;
105
+     return $this->libelle;
106 106
     }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
app/controllers/ControllerBase.php 5 patches
Doc Comments   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -171,6 +171,10 @@  discard block
 block discarded – undo
171 171
     	return $acl;
172 172
     }
173 173
     
174
+    /**
175
+     * @param string $activeResource
176
+     * @param string $activeOperation
177
+     */
174 178
     public function verifyAccessAction($activeResource, $activeOperation) {
175 179
         if($this->session->has("user")){
176 180
             $user = $this->session->get("user");
@@ -200,7 +204,7 @@  discard block
 block discarded – undo
200 204
      * Affiche un message Alert bootstrap
201 205
      * @param string $message texte du message
202 206
      * @param string $type type du message (info, success, warning ou danger)
203
-     * @param number $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
207
+     * @param integer $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
204 208
      * @param string $dismissable si vrai, l'alert dispose d'une croix de fermeture
205 209
      */
206 210
     public function _showMessage($message, $type = "success", $timerInterval = 0, $dismissable = true, $visible = true)
@@ -218,7 +222,7 @@  discard block
 block discarded – undo
218 222
     /**
219 223
      * Affiche un message Alert bootstrap de type warning
220 224
      * @param string $message texte du message
221
-     * @param number $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
225
+     * @param integer $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
222 226
      * @param string $dismissable si vrai, l'alert dispose d'une croix de fermeture
223 227
      */
224 228
     public function messageWarning($message, $timerInterval = 0, $dismissable = true)
@@ -229,7 +233,7 @@  discard block
 block discarded – undo
229 233
     /**
230 234
      * Affiche un message Alert bootstrap de type danger
231 235
      * @param string $message texte du message
232
-     * @param number $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
236
+     * @param integer $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
233 237
      * @param string $dismissable si vrai, l'alert dispose d'une croix de fermeture
234 238
      */
235 239
     public function messageDanger($message, $timerInterval = 0, $dismissable = true)
@@ -240,7 +244,7 @@  discard block
 block discarded – undo
240 244
     /**
241 245
      * Affiche un message Alert bootstrap de type info
242 246
      * @param string $message texte du message
243
-     * @param number $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
247
+     * @param integer $timerInterval durée en millisecondes d'affichage du message (0 pour que le message reste affiché)
244 248
      * @param string $dismissable si vrai, l'alert dispose d'une croix de fermeture
245 249
      */
246 250
     public function messageInfo($message, $timerInterval = 0, $dismissable = true)
Please login to merge, or discard this patch.
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -1,11 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 use Phalcon\Mvc\Controller;
4
-
5 4
 use Phalcon\Acl\Adapter\Memory as AclList;
6
-use Phalcon\Acl\Role;
7
-use Phalcon\Acl\Resource;
8
-use Phalcon\Mvc\Url;
9 5
 
10 6
 class ControllerBase extends Controller
11 7
 {
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $this->view->pick("main/index");
44 44
         } else {
45 45
             $this->view->pick("main/error");
46
-    	}
46
+     }
47 47
     }
48 48
 
49 49
     public function getInstance($id = NULL)
@@ -141,34 +141,34 @@  discard block
 block discarded – undo
141 141
     }    
142 142
     
143 143
     public function loadAclAction($typeUser) {
144
-    	$acl = new AclList();
145
-    	$acl->setDefaultAction(Phalcon\Acl::DENY);
144
+     $acl = new AclList();
145
+     $acl->setDefaultAction(Phalcon\Acl::DENY);
146 146
     	
147
-    	$roles = TypeUser::find();
148
-    	foreach ($roles as $role) {
149
-    		$acl->addRole($role->getLibelle());
150
-    	}
151
-
152
-    	$operationsBdd = Operation::find();
153
-    	$operations = array();
154
-    	foreach ($operationsBdd as $operation) {
155
-    		$operations[] = $operation->getOperation();
156
-    	}
147
+     $roles = TypeUser::find();
148
+     foreach ($roles as $role) {
149
+      $acl->addRole($role->getLibelle());
150
+     }
151
+
152
+     $operationsBdd = Operation::find();
153
+     $operations = array();
154
+     foreach ($operationsBdd as $operation) {
155
+      $operations[] = $operation->getOperation();
156
+     }
157 157
     	
158
-    	$ressources = Ressource::find();
159
-    	foreach ($ressources as $ressource) {
160
-    		$acl->addResource($ressource->getLibelle(), $operations);
161
-    	}
158
+     $ressources = Ressource::find();
159
+     foreach ($ressources as $ressource) {
160
+      $acl->addResource($ressource->getLibelle(), $operations);
161
+     }
162 162
  
163
-    	$aclsBdd = Acl::find();
164
-    	foreach ($aclsBdd as $aclBdd) {
165
-    		$typeUserBdd = TypeUser::findFirst("id = ".$aclBdd->getIdTypeUser());
166
-    		$ressourceBdd = Ressource::findFirst("id = ".$aclBdd->getIdRessource());
167
-    		$operationBdd = Operation::findFirst("id = ".$aclBdd->getIdOperation());
168
-    		$acl->allow($typeUserBdd->getLibelle(), $ressourceBdd->getLibelle(), $operationBdd->getOperation());
169
-    	}
163
+     $aclsBdd = Acl::find();
164
+     foreach ($aclsBdd as $aclBdd) {
165
+      $typeUserBdd = TypeUser::findFirst("id = ".$aclBdd->getIdTypeUser());
166
+      $ressourceBdd = Ressource::findFirst("id = ".$aclBdd->getIdRessource());
167
+      $operationBdd = Operation::findFirst("id = ".$aclBdd->getIdOperation());
168
+      $acl->allow($typeUserBdd->getLibelle(), $ressourceBdd->getLibelle(), $operationBdd->getOperation());
169
+     }
170 170
     	
171
-    	return $acl;
171
+     return $acl;
172 172
     }
173 173
     
174 174
     public function verifyAccessAction($activeResource, $activeOperation) {
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                 $this->view->setVar("object", $object);
67 67
                 $this->view->pick("main/read");
68 68
             }
69
-        }else{
69
+        } else{
70 70
 
71 71
         }
72 72
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
             } else {
196 196
                 return 0;
197 197
             }
198
-        }else{
198
+        } else{
199 199
             return 0;
200 200
         }
201 201
     }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         $user = User::findFirst($userId);
272 272
         if($user->getTypeUser() == 0){
273 273
             return true;
274
-        }else{
274
+        } else{
275 275
             return false;
276 276
         }
277 277
     }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     public function isActual($user){
280 280
         if($this->session->has("user") || $user == $this->session->get("user")->getId()){
281 281
             return true;
282
-        }else{
282
+        } else{
283 283
             return false;
284 284
         }
285 285
     }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     public function isAdminAndActual($user){
288 288
         if($this->isAdmin($user) || $this->isActual($user)){
289 289
             return true;
290
-        }else{
290
+        } else{
291 291
             return false;
292 292
         }
293 293
     }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $this->view->setVar("title", $this->title);
24 24
     }
25 25
 
26
-    public function frmAction(){
26
+    public function frmAction() {
27 27
 
28 28
     }
29 29
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             $msg = $this->_showDisplayedMessage($message);
40 40
         }
41 41
         $this->view->setVar("msg", $msg);
42
-        $objects = call_user_func($this->model . "::find");
42
+        $objects = call_user_func($this->model."::find");
43 43
         $this->view->setVar("objects", $objects);
44 44
         $this->view->pick("main/index");
45 45
         } else {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function getInstance($id = NULL)
51 51
     {
52 52
         if (isset($id)) {
53
-            $object = call_user_func($this->model . "::findfirst", $id);
53
+            $object = call_user_func($this->model."::findfirst", $id);
54 54
         } else {
55 55
             $className = $this->model;
56 56
             $object = new $className();
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     {
63 63
         if ($this->verifyAccessAction($this->controller, "read")) {
64 64
             if ($id != null) {
65
-                $object = call_user_func($this->model . '::find', "id = $id");
65
+                $object = call_user_func($this->model.'::find', "id = $id");
66 66
                 $this->view->setVar("object", $object);
67 67
                 $this->view->pick("main/read");
68 68
             }
69
-        }else{
69
+        } else {
70 70
 
71 71
         }
72 72
     }
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
                 if ($id) {
90 90
                     try {
91 91
                         $object->save();
92
-                        $msg = new DisplayedMessage("Instance de " . $this->model . " modifiée");
92
+                        $msg = new DisplayedMessage("Instance de ".$this->model." modifiée");
93 93
                     } catch (\Exception $e) {
94
-                        $msg = new DisplayedMessage("Impossible d'ajouter l'instance de " . $this->model, "danger : $e");
94
+                        $msg = new DisplayedMessage("Impossible d'ajouter l'instance de ".$this->model, "danger : $e");
95 95
                     }
96 96
                 } else {
97 97
                     try {
98 98
                         $object->save();
99
-                        $msg = new DisplayedMessage("Instance de " . $this->model . " ajoutée");
99
+                        $msg = new DisplayedMessage("Instance de ".$this->model." ajoutée");
100 100
                     } catch (\Exception $e) {
101
-                        $msg = new DisplayedMessage("Impossible d'ajouter l'instance de " . $this->model, "danger : $e");
101
+                        $msg = new DisplayedMessage("Impossible d'ajouter l'instance de ".$this->model, "danger : $e");
102 102
                     }
103 103
                 }
104 104
                 $this->dispatcher->forward(array("controller" => $this->dispatcher->getControllerName(), "action" => "index", "params" => array($msg)));
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
     public function soloUpdateAction()
111 111
     {
112 112
         if ($this->verifyAccessAction($this->controller, "write")) {
113
-            if($this->session->has("user") && ($this->session->get("user")->getId() == $this->request->getPost('pk', 'int')) || $this->session->get("user")->getIdTypeUser() == 0){
113
+            if ($this->session->has("user") && ($this->session->get("user")->getId() == $this->request->getPost('pk', 'int')) || $this->session->get("user")->getIdTypeUser() == 0) {
114 114
                 $name = $this->request->getPost('name', 'string');
115 115
                 //Créer la fonction variable 'set' en fonction du name en POST
116
-                $func = 'set' . ucfirst($name);
117
-                $projet = call_user_func($this->model . '::findFirst', $_POST['pk']);
116
+                $func = 'set'.ucfirst($name);
117
+                $projet = call_user_func($this->model.'::findFirst', $_POST['pk']);
118 118
                 $projet->$func($_POST['value']);
119 119
                 $projet->save();
120 120
             }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     public function deleteAction($id = null)
127 127
     {
128 128
         if ($this->verifyAccessAction($this->controller, "write")) {
129
-            $object = call_user_func($this->model . '::findFirst', "$id");
129
+            $object = call_user_func($this->model.'::findFirst', "$id");
130 130
             $object->delete();
131 131
         }
132 132
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     }
186 186
     
187 187
     public function verifyAccessAction($activeResource, $activeOperation) {
188
-        if($this->session->has("user")){
188
+        if ($this->session->has("user")) {
189 189
             $user = $this->session->get("user");
190 190
             $typeUser = TypeUser::findFirst("id = ".$user->getIdTypeUser());
191 191
             $typeUserSession = $user->getIdTypeUser();
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
             } else {
196 196
                 return 0;
197 197
             }
198
-        }else{
198
+        } else {
199 199
             return 0;
200 200
         }
201 201
     }
202 202
 
203 203
 
204
-    public function moreAction(){
204
+    public function moreAction() {
205 205
         $this->view->pick("main/more");
206 206
     }
207 207
 
@@ -267,27 +267,27 @@  discard block
 block discarded – undo
267 267
     }
268 268
 
269 269
 
270
-    public function isAdmin($userId){
270
+    public function isAdmin($userId) {
271 271
         $user = User::findFirst($userId);
272
-        if($user->getTypeUser() == 0){
272
+        if ($user->getTypeUser() == 0) {
273 273
             return true;
274
-        }else{
274
+        } else {
275 275
             return false;
276 276
         }
277 277
     }
278 278
 
279
-    public function isActual($user){
280
-        if($this->session->has("user") || $user == $this->session->get("user")->getId()){
279
+    public function isActual($user) {
280
+        if ($this->session->has("user") || $user == $this->session->get("user")->getId()) {
281 281
             return true;
282
-        }else{
282
+        } else {
283 283
             return false;
284 284
         }
285 285
     }
286 286
 
287
-    public function isAdminAndActual($user){
288
-        if($this->isAdmin($user) || $this->isActual($user)){
287
+    public function isAdminAndActual($user) {
288
+        if ($this->isAdmin($user) || $this->isActual($user)) {
289 289
             return true;
290
-        }else{
290
+        } else {
291 291
             return false;
292 292
         }
293 293
     }
Please login to merge, or discard this patch.