moduserprofile.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. /**
  11. * Represents extended user profile data.
  12. *
  13. * @property int $internalKey The ID of the modUser record related to this User
  14. * @property string $fullname A full name for the User
  15. * @property string $email An email address for the User
  16. * @property string $phone A phone number for the User
  17. * @property string $mobilephone A mobile phone number for the User
  18. * @property boolean $blocked Whether or not this User is blocked, or prevented from logging in
  19. * @property int $blockeduntil If set, the User will be blocked until this date
  20. * @property int $blockedafter If set, the User will be blocked after this date
  21. * @property int $logincount The total number of times this User has logged into MODX
  22. * @property int $lastlogin A UNIX timestamp showing the last time the User logged in
  23. * @property int $thislogin A UNIX timestamp showing the time this User currently logged in
  24. * @property int $failedlogincount The number of failed logins this User has accumulated
  25. * @property int $sessionid The PHP sessionid of the User
  26. * @property int $dob The date of birth of the User, in UNIX timestamp format
  27. * @property int gender The gender of the user; 1 for male, 2 for female, 0 for unknown
  28. * @property string $address The address of the User
  29. * @property string $country The country the User resides in
  30. * @property string $city The city of the User
  31. * @property string $state The state, province or region for the User
  32. * @property string $zip The postal code for the User
  33. * @property string $fax A facsimile address for the User
  34. * @property string $photo Deprecated. Can still be used to store a photo location for the user.
  35. * @property string $comment Any user-provided comments
  36. * @property string $website The website for the User
  37. * @property json $extended A JSON array of extended properties that can be used to store custom fields for the User
  38. *
  39. * @see modUser
  40. * @package modx
  41. */
  42. class modUserProfile extends xPDOSimpleObject
  43. {
  44. /**
  45. * Overrides xPDOObject::save to fire modX-specific events.
  46. *
  47. * {@inheritDoc}
  48. */
  49. public function save($cacheFlag = null)
  50. {
  51. $isNew = $this->isNew();
  52. if ($this->xpdo instanceof modX) {
  53. $this->xpdo->invokeEvent('OnUserProfileBeforeSave', array(
  54. 'mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD,
  55. 'userprofile' => &$this,
  56. 'cacheFlag' => $cacheFlag,
  57. ));
  58. }
  59. $saved = parent:: save($cacheFlag);
  60. if ($saved && $this->xpdo instanceof modX) {
  61. $this->xpdo->invokeEvent('OnUserProfileSave', array(
  62. 'mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD,
  63. 'userprofile' => &$this,
  64. 'cacheFlag' => $cacheFlag,
  65. ));
  66. }
  67. return $saved;
  68. }
  69. /**
  70. * Overrides xPDOObject::remove to fire modX-specific events
  71. *
  72. * {@inheritDoc}
  73. */
  74. public function remove(array $ancestors = array())
  75. {
  76. if ($this->xpdo instanceof modX) {
  77. $this->xpdo->invokeEvent('OnUserProfileBeforeRemove', array(
  78. 'userprofile' => &$this,
  79. 'ancestors' => $ancestors,
  80. ));
  81. }
  82. $removed = parent:: remove($ancestors);
  83. if ($this->xpdo instanceof modX) {
  84. $this->xpdo->invokeEvent('OnUserProfileRemove', array(
  85. 'userprofile' => &$this,
  86. 'ancestors' => $ancestors,
  87. ));
  88. }
  89. return $removed;
  90. }
  91. }