Skip to content

Commit 259cf8d

Browse files
committed
Orange Summer IV
1 parent 06d988c commit 259cf8d

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

Db.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class Row
178178
'parms'=>null,
179179
'id'=>null
180180
];
181-
public $teste = 'este é um teste';
182181

183182
/**
184183
* Constructor

User.php

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static function this()
9393
*
9494
* @return bool True/false to login
9595
*/
96-
public function doLogin($login, $password)
96+
public function login($login, $password)
9797
{
9898
$this->_db->query(
9999
'SELECT * FROM '.$this->_dbConfig['table']
@@ -176,6 +176,36 @@ public function getById($id)
176176
return false;
177177
}
178178

179+
/**
180+
* Get User by Login
181+
*
182+
* @param string $login login name
183+
*
184+
* @return object|bool User data or false
185+
*/
186+
public function getByLogin($login)
187+
{
188+
$this->_db->query(
189+
'SELECT * FROM '.$this->_dbConfig['table']
190+
.' WHERE '.$this->_dbConfig['login'].' = :lg',
191+
[':lg'=>$login]
192+
);
193+
$row = $this->_db->result();
194+
if (isset($row[0])) {
195+
$row = $row[0]->getAll();
196+
197+
$this->_login = true; //Setando LOGIN como válido/logado
198+
199+
foreach ($this->_data as $i => $d) {
200+
if (isset($row[$this->_dbConfig[$i]])) {
201+
$this->_data[$i] = $row[$this->_dbConfig[$i]];
202+
}
203+
}
204+
return $this->_data;
205+
}
206+
return false;
207+
}
208+
179209

180210
/**
181211
* Set TOKEN data key
@@ -220,6 +250,17 @@ public function getToken($id)
220250
return false;
221251
}
222252

253+
254+
/**
255+
* Is loged?!
256+
*
257+
* @return bool true/false for LOGIN
258+
*/
259+
public function loged()
260+
{
261+
return $this->_login;
262+
}
263+
223264
/**
224265
* Universal GET
225266
*
@@ -248,8 +289,9 @@ public function get($node = null)
248289
*/
249290
public function set($node, $value = null)
250291
{
251-
if (!is_array($node)) {
252-
$node[$node] = $value;
292+
if (!is_array($node)
293+
&& isset($this->_data[$node])) {
294+
$this->_data[$node] = $value;
253295
}
254296
foreach ($node as $i => $d) {
255297
if (isset($this->_data[$i])) {

0 commit comments

Comments
 (0)