PageRenderTime 121ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/src/libraries/default/users/domain/entity/user.php

https://github.com/bhar1red/anahita
PHP | 67 lines | 25 code | 4 blank | 38 comment | 0 complexity | 97857c8a7f3ae796ec07d718024e8760 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * LICENSE: ##LICENSE##
  4. *
  5. * @category Anahita
  6. * @package Lib_Users
  7. * @subpackage Domain_Entity
  8. * @author Arash Sanieyan <ash@anahitapolis.com>
  9. * @author Rastin Mehr <rastin@anahitapolis.com>
  10. * @copyright 2008 - 2010 rmdStudio Inc./Peerglobe Technology Inc
  11. * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl-3.0.html>
  12. * @version SVN: $Id$
  13. * @link http://www.anahitapolis.com
  14. */
  15. /**
  16. * User object
  17. *
  18. * @category Anahita
  19. * @package Lib_Users
  20. * @subpackage Domain_Entity
  21. * @author Arash Sanieyan <ash@anahitapolis.com>
  22. * @author Rastin Mehr <rastin@anahitapolis.com>
  23. * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl-3.0.html>
  24. * @link http://www.anahitapolis.com
  25. */
  26. class LibUsersDomainEntityUser extends AnDomainEntityDefault
  27. {
  28. /**
  29. * Initializes the default configuration for the object
  30. *
  31. * Called from {@link __construct()} as a first step of object instantiation.
  32. *
  33. * @param KConfig $config An optional KConfig object with configuration options.
  34. *
  35. * @return void
  36. */
  37. protected function _initialize(KConfig $config)
  38. {
  39. $config->append(array(
  40. 'resources' => array('users'),
  41. 'attributes' => array(
  42. 'params' => array('required'=>false, 'default'=>''),
  43. 'activation' => array('required'=>false, 'default'=>''),
  44. ),
  45. 'auto_generate' => true
  46. ));
  47. return parent::_initialize($config);
  48. }
  49. /**
  50. * Automatically sets the activation token for the user
  51. *
  52. * @return LibUsersDomainEntityUser
  53. */
  54. public function requiresActivation()
  55. {
  56. jimport('joomla.user.helper');
  57. $token = JUtility::getHash(JUserHelper::genRandomPassword());
  58. $salt = JUserHelper::getSalt('crypt-md5');
  59. $hashedToken = md5($token.$salt).':'.$salt;
  60. $this->activation = $hashedToken;
  61. return $this;
  62. }
  63. }