@@ -6,10 +6,10 @@ |
||
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() |
@@ -63,9 +63,9 @@ |
||
63 | 63 | 'username' => $config->database->username, |
64 | 64 | 'password' => $config->database->password, |
65 | 65 | 'dbname' => $config->database->dbname, |
66 | - 'options' => array( |
|
67 | - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' |
|
68 | - ) |
|
66 | + 'options' => array( |
|
67 | + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' |
|
68 | + ) |
|
69 | 69 | )); |
70 | 70 | }); |
71 | 71 |
@@ -20,7 +20,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(){ |
|
96 | - $jquery= new JsUtils(array("driver"=>"Jquery")); |
|
95 | +$di->set("jquery", function() { |
|
96 | + $jquery = new JsUtils(array("driver"=>"Jquery")); |
|
97 | 97 | $jquery->bootstrap(new Bootstrap()); |
98 | - $jquery->ui(new Ajax\JqueryUI());//optional for JQuery UI |
|
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 |
@@ -2,60 +2,60 @@ |
||
2 | 2 | |
3 | 3 | use Phalcon\Mvc\Controller; |
4 | 4 | |
5 | -class ControllerBase extends Controller{ |
|
5 | +class ControllerBase extends Controller { |
|
6 | 6 | |
7 | 7 | protected $model; |
8 | 8 | protected $title; |
9 | 9 | protected $controller; |
10 | 10 | |
11 | - public function afterExecuteRoute($dispatcher){ |
|
11 | + public function afterExecuteRoute($dispatcher) { |
|
12 | 12 | $baseUrl = $this->baseUrl; |
13 | 13 | $this->view->setVar("baseUrl", $baseUrl); |
14 | 14 | $this->view->setVar("controller", $this->controller); |
15 | 15 | $this->view->setVar("title", $this->title); |
16 | 16 | } |
17 | 17 | |
18 | - public function indexAction(){ |
|
19 | - $objects = call_user_func($this->model."::find"); |
|
20 | - $this->view->setVar("objects",$objects); |
|
18 | + public function indexAction() { |
|
19 | + $objects = call_user_func($this->model . "::find"); |
|
20 | + $this->view->setVar("objects", $objects); |
|
21 | 21 | $this->view->pick("main/index"); |
22 | 22 | } |
23 | 23 | |
24 | - public function frmAction($id = NULL){ |
|
24 | + public function frmAction($id = NULL) { |
|
25 | 25 | echo "Pas encore implémenté..."; |
26 | 26 | } |
27 | 27 | |
28 | - public function readAction($id = NULL){ |
|
29 | - if($id != null){ |
|
30 | - $object = call_user_func($this->model.'::find', "id = $id"); |
|
31 | - $this->view->setVar("object",$object); |
|
28 | + public function readAction($id = NULL) { |
|
29 | + if ($id != null) { |
|
30 | + $object = call_user_func($this->model . '::find', "id = $id"); |
|
31 | + $this->view->setVar("object", $object); |
|
32 | 32 | $this->view->pick("main/read"); |
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | - public function updateAction(){ |
|
36 | + public function updateAction() { |
|
37 | 37 | echo "Pas encore implémenté..."; |
38 | 38 | } |
39 | 39 | |
40 | - public function deleteAction($id = null){ |
|
41 | - $object = call_user_func($this->model.'::findFirst', "id = $id"); |
|
40 | + public function deleteAction($id = null) { |
|
41 | + $object = call_user_func($this->model . '::findFirst', "id = $id"); |
|
42 | 42 | $object->delete(); |
43 | 43 | $this->response->redirect("Index/index"); |
44 | 44 | } |
45 | 45 | |
46 | - public function asAdminAction(){ |
|
46 | + public function asAdminAction() { |
|
47 | 47 | $user = User::findFirst("id=3"); |
48 | 48 | $this->session->set("user", $user); |
49 | 49 | $this->response->redirect("Index/index"); |
50 | 50 | } |
51 | 51 | |
52 | - public function asUserAction(){ |
|
52 | + public function asUserAction() { |
|
53 | 53 | $user = User::findFirst("id=1"); |
54 | 54 | $this->session->set("user", $user); |
55 | 55 | $this->response->redirect("Index/index"); |
56 | 56 | } |
57 | 57 | |
58 | - public function logoutAction(){ |
|
58 | + public function logoutAction() { |
|
59 | 59 | $this->session->destroy(); |
60 | 60 | $this->response->redirect("Index/index"); |
61 | 61 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - public function getSource(){ |
|
224 | + public function getSource() { |
|
225 | 225 | return 'projet'; |
226 | 226 | } |
227 | 227 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param mixed $parameters |
232 | 232 | * @return Projet[] |
233 | 233 | */ |
234 | - public static function find($parameters = null){ |
|
234 | + public static function find($parameters = null) { |
|
235 | 235 | return parent::find($parameters); |
236 | 236 | } |
237 | 237 | |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | return parent::findFirst($parameters); |
247 | 247 | } |
248 | 248 | |
249 | - public function toString(){ |
|
249 | + public function toString() { |
|
250 | 250 | return $this->nom; |
251 | 251 | } |
252 | 252 | |
253 | 253 | //Return a string containing the principal content of the model |
254 | - public function getPrincipal(){ |
|
255 | - return "Client : ".$this->client->toString()." <br/> Desciption : ".$this->description; |
|
254 | + public function getPrincipal() { |
|
255 | + return "Client : " . $this->client->toString() . " <br/> Desciption : " . $this->description; |
|
256 | 256 | } |
257 | 257 | } |
@@ -188,7 +188,7 @@ |
||
188 | 188 | return parent::findFirst($parameters); |
189 | 189 | } |
190 | 190 | |
191 | - public function toString(){ |
|
192 | - return $this->libelle."(".$this->avancement.")"; |
|
191 | + public function toString() { |
|
192 | + return $this->libelle . "(" . $this->avancement . ")"; |
|
193 | 193 | } |
194 | 194 | } |
@@ -219,7 +219,7 @@ |
||
219 | 219 | return parent::findFirst($parameters); |
220 | 220 | } |
221 | 221 | |
222 | - public function toString(){ |
|
223 | - return $this->nom."(".$this->avancement.")"; |
|
222 | + public function toString() { |
|
223 | + return $this->nom . "(" . $this->avancement . ")"; |
|
224 | 224 | } |
225 | 225 | } |
@@ -158,13 +158,13 @@ |
||
158 | 158 | $this->hasMany('id', 'Usecase', 'idDev', array('alias' => 'Usecases')); |
159 | 159 | } |
160 | 160 | |
161 | - public function toString(){ |
|
162 | - return $this->identite."(".$this->mail.")"; |
|
161 | + public function toString() { |
|
162 | + return $this->identite . "(" . $this->mail . ")"; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | //Return a string containing the principal content of the model |
166 | - public function getPrincipal(){ |
|
167 | - return "Identité : ".$this->identite." <br/> Email : ".$this->mail; |
|
166 | + public function getPrincipal() { |
|
167 | + return "Identité : " . $this->identite . " <br/> Email : " . $this->mail; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * Returns the value of field role |
143 | 143 | * |
144 | - * @return string |
|
144 | + * @return integer |
|
145 | 145 | */ |
146 | 146 | public function getRole() |
147 | 147 | { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | /** |
194 | 194 | * Allows to query the first record that match the specified conditions |
195 | 195 | * |
196 | - * @param mixed $parameters |
|
196 | + * @param string $parameters |
|
197 | 197 | * @return User |
198 | 198 | */ |
199 | 199 | public static function findFirst($parameters = null) |
@@ -43,6 +43,9 @@ |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | + /** |
|
47 | + * @param integer $typeUser |
|
48 | + */ |
|
46 | 49 | public function loadAclAction($typeUser) { |
47 | 50 | $acl = new AclList(); |
48 | 51 | $acl->setDefaultAction(Phalcon\Acl::DENY); |
@@ -21,47 +21,47 @@ |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | public function signInAction() { |
24 | - $bootstrap = $this->jquery->bootstrap(); |
|
24 | + $bootstrap = $this->jquery->bootstrap(); |
|
25 | 25 | |
26 | - if(!empty($_POST['identite']) && !empty($_POST['password'])) { |
|
26 | + if(!empty($_POST['identite']) && !empty($_POST['password'])) { |
|
27 | 27 | |
28 | - $userPseudo = User::findFirst("identite = '".$_POST['identite']."'"); |
|
28 | + $userPseudo = User::findFirst("identite = '".$_POST['identite']."'"); |
|
29 | 29 | |
30 | - $userMail = User::findFirst("mail = '".$_POST['identite']."'"); |
|
30 | + $userMail = User::findFirst("mail = '".$_POST['identite']."'"); |
|
31 | 31 | |
32 | - if($userPseudo != NULL && password_verify($_POST['password'], $userPseudo->getPassword())) { |
|
33 | - $this->session->set("user", $userPseudo); |
|
34 | - $this->response->redirect("Index/index"); |
|
35 | - $this->loadAclAction($userPseudo->getRole()); |
|
36 | - } else if($userMail != NULL && password_verify($_POST['password'], $userMail->getPassword())) { |
|
37 | - $this->session->set("user", $userMail); |
|
38 | - $this->response->redirect("Index/index"); |
|
39 | - $this->loadAclAction($userMail->getRole()); |
|
40 | - } else { |
|
41 | - echo $bootstrap->htmlAlert("alert1","L'identifiant ou le mot de passe est incorrecte."); |
|
42 | - } |
|
43 | - } |
|
32 | + if($userPseudo != NULL && password_verify($_POST['password'], $userPseudo->getPassword())) { |
|
33 | + $this->session->set("user", $userPseudo); |
|
34 | + $this->response->redirect("Index/index"); |
|
35 | + $this->loadAclAction($userPseudo->getRole()); |
|
36 | + } else if($userMail != NULL && password_verify($_POST['password'], $userMail->getPassword())) { |
|
37 | + $this->session->set("user", $userMail); |
|
38 | + $this->response->redirect("Index/index"); |
|
39 | + $this->loadAclAction($userMail->getRole()); |
|
40 | + } else { |
|
41 | + echo $bootstrap->htmlAlert("alert1","L'identifiant ou le mot de passe est incorrecte."); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function loadAclAction($typeUser) { |
47 | - $acl = new AclList(); |
|
48 | - $acl->setDefaultAction(Phalcon\Acl::DENY); |
|
49 | - $roleBdd = TypeUser::findFirst("id = ".$typeUser); |
|
47 | + $acl = new AclList(); |
|
48 | + $acl->setDefaultAction(Phalcon\Acl::DENY); |
|
49 | + $roleBdd = TypeUser::findFirst("id = ".$typeUser); |
|
50 | 50 | |
51 | - $aclsBdd = Acl::find("idTypeUser = ".$typeUser); |
|
52 | - foreach ($aclsBdd as $aclBdd) { |
|
53 | - $role = TypeUser::findFirst("id = ".$aclBdd->getIdTypeUser()); |
|
54 | - $ressource = Ressource::findFirst("id = ".$aclBdd->getIdRessource()); |
|
55 | - $operation = Operation::findFirst("id = ".$aclBdd->getIdOperation()); |
|
56 | - $acl->addRole(new Role($role->getLibelle())); |
|
57 | - $acl->addResource(new Resource($ressource->getLibelle(), $operation->getOperation())); |
|
58 | - } |
|
51 | + $aclsBdd = Acl::find("idTypeUser = ".$typeUser); |
|
52 | + foreach ($aclsBdd as $aclBdd) { |
|
53 | + $role = TypeUser::findFirst("id = ".$aclBdd->getIdTypeUser()); |
|
54 | + $ressource = Ressource::findFirst("id = ".$aclBdd->getIdRessource()); |
|
55 | + $operation = Operation::findFirst("id = ".$aclBdd->getIdOperation()); |
|
56 | + $acl->addRole(new Role($role->getLibelle())); |
|
57 | + $acl->addResource(new Resource($ressource->getLibelle(), $operation->getOperation())); |
|
58 | + } |
|
59 | 59 | |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | - public function readAction($id = NULL) { |
|
62 | + public function readAction($id = NULL) { |
|
63 | 63 | |
64 | - } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | protected $title; |
11 | 11 | protected $controller; |
12 | 12 | |
13 | - public function initialize(){ |
|
13 | + public function initialize() { |
|
14 | 14 | $this->model = "User"; |
15 | 15 | $this->title = "Utilisateurs"; |
16 | 16 | $this->controller = "Users"; |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | public function signInAction() { |
24 | 24 | $bootstrap = $this->jquery->bootstrap(); |
25 | 25 | |
26 | - if(!empty($_POST['identite']) && !empty($_POST['password'])) { |
|
26 | + if (!empty($_POST['identite']) && !empty($_POST['password'])) { |
|
27 | 27 | |
28 | - $userPseudo = User::findFirst("identite = '".$_POST['identite']."'"); |
|
28 | + $userPseudo = User::findFirst("identite = '" . $_POST['identite'] . "'"); |
|
29 | 29 | |
30 | - $userMail = User::findFirst("mail = '".$_POST['identite']."'"); |
|
30 | + $userMail = User::findFirst("mail = '" . $_POST['identite'] . "'"); |
|
31 | 31 | |
32 | - if($userPseudo != NULL && password_verify($_POST['password'], $userPseudo->getPassword())) { |
|
32 | + if ($userPseudo != NULL && password_verify($_POST['password'], $userPseudo->getPassword())) { |
|
33 | 33 | $this->session->set("user", $userPseudo); |
34 | 34 | $this->response->redirect("Index/index"); |
35 | 35 | $this->loadAclAction($userPseudo->getRole()); |
36 | - } else if($userMail != NULL && password_verify($_POST['password'], $userMail->getPassword())) { |
|
36 | + } else if ($userMail != NULL && password_verify($_POST['password'], $userMail->getPassword())) { |
|
37 | 37 | $this->session->set("user", $userMail); |
38 | 38 | $this->response->redirect("Index/index"); |
39 | 39 | $this->loadAclAction($userMail->getRole()); |
40 | 40 | } else { |
41 | - echo $bootstrap->htmlAlert("alert1","L'identifiant ou le mot de passe est incorrecte."); |
|
41 | + echo $bootstrap->htmlAlert("alert1", "L'identifiant ou le mot de passe est incorrecte."); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | public function loadAclAction($typeUser) { |
47 | 47 | $acl = new AclList(); |
48 | 48 | $acl->setDefaultAction(Phalcon\Acl::DENY); |
49 | - $roleBdd = TypeUser::findFirst("id = ".$typeUser); |
|
49 | + $roleBdd = TypeUser::findFirst("id = " . $typeUser); |
|
50 | 50 | |
51 | - $aclsBdd = Acl::find("idTypeUser = ".$typeUser); |
|
51 | + $aclsBdd = Acl::find("idTypeUser = " . $typeUser); |
|
52 | 52 | foreach ($aclsBdd as $aclBdd) { |
53 | - $role = TypeUser::findFirst("id = ".$aclBdd->getIdTypeUser()); |
|
54 | - $ressource = Ressource::findFirst("id = ".$aclBdd->getIdRessource()); |
|
55 | - $operation = Operation::findFirst("id = ".$aclBdd->getIdOperation()); |
|
53 | + $role = TypeUser::findFirst("id = " . $aclBdd->getIdTypeUser()); |
|
54 | + $ressource = Ressource::findFirst("id = " . $aclBdd->getIdRessource()); |
|
55 | + $operation = Operation::findFirst("id = " . $aclBdd->getIdOperation()); |
|
56 | 56 | $acl->addRole(new Role($role->getLibelle())); |
57 | 57 | $acl->addResource(new Resource($ressource->getLibelle(), $operation->getOperation())); |
58 | 58 | } |
@@ -31,7 +31,6 @@ discard block |
||
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 |
||
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) |
@@ -103,7 +103,7 @@ |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | public function toString() { |
106 | - return $this->libelle; |
|
106 | + return $this->libelle; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } |