Subversion Repository Public Repository

Nextrek

Diff Revisions 467 vs 508 for /Android/SmartCharging/endPoints/nightly/repositories/UserRepository.php

Diff revisions: vs.
  @@ -53,10 +53,11 @@
53 53 $hashedPwd = password_hash($password, PASSWORD_DEFAULT);
54 54 $newToken = sha1($user->username.session_id().time());
55 55
56 - $query = "INSERT INTO utente(username, password, nominativo, cell, email, token)
56 + $query = "INSERT INTO utente(username, password, nome, cognome, cell, email, token)
57 57 VALUES ('".$user->username."',
58 58 '".$hashedPwd."',
59 - '".$user->nominativo."',
59 + '".$user->nome."',
60 + '".$user->cognome."',
60 61 '".$user->cell."',
61 62 '".$user->email."',
62 63 '".$newToken."')";
  @@ -155,7 +156,7 @@
155 156 }
156 157
157 158 //richiesta alla facebook graph, richiedendo id_utente, nome ed email
158 - $request = new FacebookRequest($session, 'GET', '/me?fields=id,name,email');
159 + $request = new FacebookRequest($session, 'GET', '/me?fields=id,first_name,last_name,email');
159 160 $response = $request->execute();
160 161 $graphObject = $response->getGraphObject();
161 162
  @@ -166,7 +167,8 @@
166 167 return $status;
167 168 }
168 169
169 - $u_name = $graphObject->getProperty('name');
170 + $u_first_name = $graphObject->getProperty('first_name');
171 + $u_last_name = $graphObject->getProperty('last_name');
170 172 $u_email = $graphObject->getProperty('email');
171 173
172 174 $sql = "SELECT id FROM utente WHERE email='".$user_email."'";
  @@ -177,7 +179,7 @@
177 179 if (!is_null($row)) { //utente già esistente
178 180
179 181 $sql = "UPDATE utente
180 - SET nominativo='".$u_name."', email='".$u_email."', token='".$fb_token."'
182 + SET nome='".$u_first_name."', cognome='".$u_last_name."', email='".$u_email."', token='".$fb_token."'
181 183 WHERE id=".$row["id"];
182 184
183 185 $this->db->exec($sql);
  @@ -185,8 +187,8 @@
185 187
186 188 } else { //creazione nuova utenza
187 189
188 - $sql = "INSERT INTO users (nominativo,email,token)
189 - VALUES ('".$u_name."','".$u_email."','".$fb_token."')";
190 + $sql = "INSERT INTO users (nome,cognome,email,token)
191 + VALUES ('".$u_first_name."','".$u_last_name."','".$u_email."','".$fb_token."')";
190 192
191 193 $this->db->exec($query);
192 194 $status["id"] = $this->db->lastInsertId();
  @@ -277,8 +279,12 @@
277 279
278 280 $setString = "";
279 281
280 - if (isset($user->nominativo) && !is_null($user->nominativo)) {
281 - $setString = ($setString == "") ? "nominativo='".$user->nominativo."'" : $setString.",nominativo='".$user->nominativo."'";
282 + if (isset($user->nome) && !is_null($user->nome)) {
283 + $setString = ($setString == "") ? "nome='".$user->nome."'" : $setString.",nome='".$user->nome."'";
284 + }
285 +
286 + if (isset($user->cognome) && !is_null($user->cognome)) {
287 + $setString = ($setString == "") ? "cognome='".$user->cognome."'" : $setString.",cognome='".$user->cognome."'";
282 288 }
283 289
284 290 if (isset($user->cell) && !is_null($user->cell)) {