User.class.php 1.6 KB
Newer Older
Zohten's avatar
Zohten committed
1 2
<?php

Zohten's avatar
Zohten committed
3 4
class User extends Model
{
Zohten's avatar
Zohten committed
5 6

   // ===========
Zohten's avatar
Zohten committed
7 8
    // = Statics =
    // ===========
Zohten's avatar
Zohten committed
9
    protected static $table_name = 'MJ_USER';
Zohten's avatar
Zohten committed
10

Zohten's avatar
Zohten committed
11 12 13 14 15 16 17 18 19 20 21
    // load all users from Db
    public static function getList()
    {
        $stm = parent::exec('USER_LIST');
        return $stm->fetchAll();
    }
    public static function getRow($id)
    {
        $stm = parent::exec('USER_GET_WITH_ID', ['id' => $id]);
        return $stm->fetchAll();
    }
Zohten's avatar
Zohten committed
22

Zohten's avatar
Zohten committed
23 24 25 26 27
    public static function addRow($array)
    {
        $stm = parent::exec('USER_CREATE', $array);
    }

Zohten's avatar
Zohten committed
28 29 30 31 32
    public static function deleteRow($id)
    {
        $stm = parent::exec('USER_DELETE', ['id' => $id]);
    }

Zohten's avatar
Zohten committed
33 34 35 36
    public static function updateUser($array)
    {
        $stm = parent::exec('USER_UPDATE', $array);
    }
Zohten's avatar
Zohten committed
37

Zohten's avatar
Zohten committed
38 39 40
    public static function tryLogin($login)
    {
        $stm = parent::exec('USER_GET_WITH_LOGIN', ['login' => $login]);
Zohten's avatar
Zohten committed
41
        return $stm->fetch();
Zohten's avatar
Zohten committed
42
    }
Zohten's avatar
Zohten committed
43

Zohten's avatar
Zohten committed
44
    public function id()
Zohten's avatar
Zohten committed
45
    {
Zohten's avatar
Zohten committed
46
        return trim($this->ID_USER);
Zohten's avatar
Zohten committed
47
    }
Zohten's avatar
Zohten committed
48
    public function role()
Zohten's avatar
Zohten committed
49
    {
Zohten's avatar
Zohten committed
50
        return trim($this->ID_ROLE);
Zohten's avatar
Zohten committed
51
    }
Zohten's avatar
Zohten committed
52 53 54 55 56
    public function password()
    {
        return trim($this->PASWORD);
    }
    public function avatar()
Zohten's avatar
Zohten committed
57
    {
Zohten's avatar
Zohten committed
58
        return trim($this->AVATAR);
Zohten's avatar
Zohten committed
59 60 61
    }
    public function lastname()
    {
Zohten's avatar
Zohten committed
62 63 64 65 66
        return trim($this->LASTNAME);
    }
    public function firstname()
    {
        return trim($this->FIRSTNAME);
Zohten's avatar
Zohten committed
67 68 69
    }
    public function email()
    {
Zohten's avatar
Zohten committed
70 71 72 73 74 75 76 77 78
        return trim($this->MAIL);
    }
    public function isBanned()
    {
        return trim($this->BAN_ACCOUNT);
    }
    public function lastIP()
    {
        return trim($this->LAST_IP);
Zohten's avatar
Zohten committed
79 80
    }
}