Reputation:
Hello I have a website that I have 3 classes AnonymousUser
(for users who are not logged),Users
(for common users registered) and UsersInSession
(Users who has a session) all of these classes inherit from People class.
I get user data from a sql query and I serialize it who is logging and I save it to _SESSION["objectSession"]
,when the user is logged each PHP file I unserialize the _SESSION["objectSession"]
to $objectSession
object..
when I want to get my friendlist (in resources of MySQL) in objects I do:
$myFriends=$objectSession->getFriends();
then I can print the data of my friends this way:
<table> <tr> <td>Name</td><td>Lastnames</td> </tr> <?php
while($objectFriend=$myFriends->fetchObject("Users")){ ?> <tr> <td><?
echo $objectFriend->name; ?></td> <td><? echo
$objectFriend->lastnames; ?></td> <?php } ?></tr></table>
Can I implement in Zend Framework with these classes?
I don't know if these classes can be Model or Controller..
Upvotes: 0
Views: 204
Reputation: 8519
For this question your version of ZF is irrelevant as it more of a structure question then anything else.
For starters you currently have 3 classes that do largely the same thing. You can probably condense those 3 classes down to one user class that has 3 (or more) levels of authentication and access.
When using ZF2 you can your authentication (login) system using: Zend\Authentication
and then when your application decides which level of access each user gets you can use one of the access control components to control which resources the user can access.
Zend/Permissions/Acl, traditional Object based ACL.
Zend/Permissions/Rbac, Role based ACL.
If you really don't want/need to role your own solution, you can find some really good access control and authentication solutions at ZF2 modules
[EDIT]
Can I implement in Zend Framework with these classes?
Yes, although you may need to rename them for easier implementation.
I don't know if these classes can be Model or Controller..
From your description it's likely your classes incorporate model, controller and probably even view elements in each class. So some refactoring will likely be required.
Typically these classes would be mostly model classes of the 'Domain Model' type that would interact with one or more controller to be processed and presented through the view.
Upvotes: 0
Reputation:
Thanks,Well maybe I did not ask the question very good..what I do with that 3 classes is check if the user have "privileges" to do it,for example:
-Anonymous users (that inherits from People class) can't comment any profile.
-Users (inherits from People class too) can comment,and have its profile and pictures.Each user have a table of privacy,so dependends of the user if can comment their friends,or all users.This class have the checkprivacy($iduser) method that checks if the user can see the profile of $iduser. This class have the checkBlocked($iduserblock) function too,because it can check if the user is blocked and can't see the profile.
-People class (this class do the job) check if the session is an anonymous user,or a user (who is logged) if is logged we check if is blocked and we'll check if he can comment.If is an anonymouser is not necessary to check if he is blocked.. this class have the method loadProfile($id) to load a profile and more issues
Upvotes: 0