Guest User

Untitled

a guest
Jul 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2.  
  3. class myUser extends sfGuardSecurityUser {
  4. /**
  5. * Returns the id of the logged in User
  6. * @return int
  7. * @author Ayoub Hidri
  8. */
  9. public function getId() {
  10. return $this->getAttribute('user_id', null, 'sfGuardSecurityUser');
  11. }
  12. public function signin($user, $remember = false, $con = null) {
  13. $attributes = array(
  14. 'username'=>'getUsername',
  15. 'last_login'=>'getLastLogin',
  16. 'birthdate'=>'getBirthdate',
  17. 'first_name'=>'getFirstName',
  18. 'last_name'=>'getLastName',
  19. );
  20. $this->setAttributes($user, $attributes);
  21.  
  22. $this->setAttribute('permissions', $user->getAllPermissionNames(),'sfGuardSecurityUser');
  23. $this->setAttribute('permissions', $user->getAllPermissionNames(),'sfGuardSecurityUser');
  24.  
  25. parent::signIn($user, $remember, $con);
  26. }
  27. /**
  28. * Sets Attributes to the sfGuardSecurityUser attributeHolder name space
  29. */
  30. private function setAttributes($user,$attributes) {
  31. foreach ($attributes as $name=>$method) {
  32. $this->setAttribute($name, $user->$method(), 'sfGuardSecurityUser');
  33. }
  34.  
  35. }
  36.  
  37.  
  38.  
  39. }
Add Comment
Please, Sign In to add comment