User.class.php 1.83 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 41 42 43
    public static function checkLogin($login)
    {
        $stm = parent::exec('USER_CHECK_LOGIN', ['login' => $login]);
        return $stm->fetch();
    }

Zohten's avatar
Zohten committed
44 45 46
    public static function tryLogin($login)
    {
        $stm = parent::exec('USER_GET_WITH_LOGIN', ['login' => $login]);
Zohten's avatar
Zohten committed
47
        return $stm->fetch();
Zohten's avatar
Zohten committed
48
    }
Zohten's avatar
Zohten committed
49

Zohten's avatar
Zohten committed
50
    public function id()
Zohten's avatar
Zohten committed
51
    {
Zohten's avatar
Zohten committed
52
        return trim($this->ID_USER);
Zohten's avatar
Zohten committed
53
    }
Zohten's avatar
Zohten committed
54
    public function role()
Zohten's avatar
Zohten committed
55
    {
Zohten's avatar
Zohten committed
56
        return trim($this->ID_ROLE);
Zohten's avatar
Zohten committed
57
    }
Zohten's avatar
Zohten committed
58 59 60 61
    public function login()
    {
        return trim($this->LOGIN);
    }
Zohten's avatar
Zohten committed
62 63 64 65 66
    public function password()
    {
        return trim($this->PASWORD);
    }
    public function avatar()
Zohten's avatar
Zohten committed
67
    {
Zohten's avatar
Zohten committed
68
        return trim($this->AVATAR);
Zohten's avatar
Zohten committed
69 70 71
    }
    public function lastname()
    {
Zohten's avatar
Zohten committed
72 73 74 75 76
        return trim($this->LASTNAME);
    }
    public function firstname()
    {
        return trim($this->FIRSTNAME);
Zohten's avatar
Zohten committed
77 78 79
    }
    public function email()
    {
Zohten's avatar
Zohten committed
80 81 82 83 84 85 86 87 88
        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
89 90
    }
}