W
W
webquestions2016-03-03 18:14:57
PHP
webquestions, 2016-03-03 18:14:57

Essence the user as object in php correctly I think?

Essence the user as object in php correctly I think?
Let's say we have a user.
There are three types of moderator admin and regular user.
User has first name last name patronymic year of birth
moderator has editing
rights admin has editing rights + the right to appoint moderators
How to correctly describe a User using OOP?
As I understand it, it will be something like
a user class
with properties First name last name patronymic year of birth,
further under the moderator and admin classes with their unique properties and methods,
if I'm already wrong, please correct me.
After we create an instance of the class, and through the object we get the data we need

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2016-03-03
@xmoonlight

Yes

A
Andrey, 2016-03-03
@VladimirAndreev

Well, there will still be one class - User.
which will have a status field.
otherwise, you have an ID, if there are three classes - then FIG knows who he is there - a user, a moderator or an admin, which of the instances to create?
although it's easy to get around...

T
ThunderCat, 2016-03-03
@ThunderCat

This is called ACL, smoke Google, there are many implementations, the point is to give objects an access level, a user with sufficient rights can steer the object, the rest smoke bamboo). It is very convenient, especially where there are many objects and there are different access levels, such as reading, creating, changing, etc.
And what kind of methods can a modera have in a class that are not like a mere mortal???

<?
class Article extends Model
{
    public $table = "article";
    public $haveImages = true;
    public $isML = true;
    public $ACL = 2;    

    public function __construct($id = "")
    {
        parent::__construct($id);
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question