PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/httpdocs/lib/Object/User.php

https://github.com/leftnode/tuneto.us
PHP | 79 lines | 55 code | 20 blank | 4 comment | 2 complexity | c401e0629f9fc47557e24b2263c61dd7 MD5 | raw file
  1. <?php
  2. require_once 'DataModeler/DataObject.php';
  3. class User extends DataObject {
  4. private $track_list = NULL;
  5. private $favorite_list = NULL;
  6. private $following_list = NULL;
  7. private $follower_list = NULL;
  8. public function setTrackList(DataIterator $list) {
  9. $this->track_list = $list;
  10. return $this;
  11. }
  12. public function setFavoriteList(DataIterator $list) {
  13. $this->favorite_list = $list;
  14. return $this;
  15. }
  16. public function setFollowingList(DataIterator $list) {
  17. $this->following_list = $list;
  18. return $this;
  19. }
  20. public function setFollowerList(DataIterator $list) {
  21. $this->follower_list = $list;
  22. return $this;
  23. }
  24. public function setEmailAddress($email_address) {
  25. if ( false === filter_var($email_address, FILTER_VALIDATE_EMAIL) ) {
  26. throw new TuneToUs_Exception(_('The email address for this user is not valid.'));
  27. }
  28. $this->__set('email_address', $email_address);
  29. return $this;
  30. }
  31. public function getTrackList() {
  32. return $this->track_list;
  33. }
  34. public function getFavoriteList() {
  35. return $this->favorite_list;
  36. }
  37. public function getFollowingList() {
  38. return $this->following_list;
  39. }
  40. public function getFollowerList() {
  41. return $this->follower_list;
  42. }
  43. public function createDirectory() {
  44. /**
  45. * While it's not good to use sha1() on a uniqid, this isn't for
  46. * encryption purposes, just random string generation purposes.
  47. */
  48. $uniqid = uniqid(NULL, true);
  49. $uniqid_sha1 = sha1($uniqid);
  50. $char1 = substr($uniqid_sha1, 0, 1);
  51. $char2 = substr($uniqid_sha1, 1, 1);
  52. $directory = $char1 . DS . $char2 . DS . $uniqid;
  53. $full_path = DIR_PRIVATE . $directory;
  54. if ( false === is_dir($full_path) ) {
  55. @mkdir($full_path, 0777, true);
  56. }
  57. return $directory;
  58. }
  59. }