|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rudolf\Modules\Users\One\Admin\Profile; |
|
4
|
|
|
|
|
5
|
|
|
use Rudolf\Component\Auth\Auth; |
|
6
|
|
|
use Rudolf\Framework\Model\AdminModel; |
|
7
|
|
|
|
|
8
|
|
|
class EditModel extends AdminModel |
|
9
|
|
|
{ |
|
10
|
|
|
public function edit($id, $f) |
|
11
|
|
|
{ |
|
12
|
|
|
$stmt = $this->pdo->prepare(" |
|
13
|
|
|
UPDATE |
|
14
|
|
|
{$this->prefix}users |
|
15
|
|
|
SET |
|
16
|
|
|
nick = :nick, |
|
17
|
|
|
first_name = :first_name, |
|
18
|
|
|
surname = :surname, |
|
19
|
|
|
email = :email, |
|
20
|
|
|
active = :active |
|
21
|
|
|
WHERE |
|
22
|
|
|
id = :id |
|
23
|
|
|
"); |
|
24
|
|
|
$stmt->bindValue(':nick', $f['nick']); |
|
25
|
|
|
$stmt->bindValue(':first_name', $f['first_name']); |
|
26
|
|
|
$stmt->bindValue(':surname', $f['surname']); |
|
27
|
|
|
$stmt->bindValue(':email', $f['email']); |
|
28
|
|
|
$stmt->bindValue(':active', $f['active'], \PDO::PARAM_STR); |
|
29
|
|
|
$stmt->bindValue(':id', $id, \PDO::PARAM_INT); |
|
30
|
|
|
|
|
31
|
|
|
return $stmt->execute(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function updatePassword($id, $password) |
|
35
|
|
|
{ |
|
36
|
|
|
$auth = new Auth($this->pdo, $this->prefix); |
|
37
|
|
|
$hash = $auth->getPasswordHash($password); |
|
38
|
|
|
|
|
39
|
|
|
$stmt = $this->pdo->prepare("UPDATE {$this->prefix}users SET password = :password WHERE id = :id"); |
|
40
|
|
|
$stmt->bindValue(':password', $hash); |
|
41
|
|
|
$stmt->bindValue('id', $id, \PDO::PARAM_INT); |
|
42
|
|
|
|
|
43
|
|
|
return $stmt->execute(); |
|
44
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getUserInfoById($id) |
|
48
|
|
|
{ |
|
49
|
|
|
$stmt = $this->pdo->prepare("SELECT * FROM {$this->prefix}users WHERE id =?"); |
|
50
|
|
|
$stmt->execute([$id]); |
|
51
|
|
|
return $stmt->fetch(\PDO::FETCH_ASSOC); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|