Guest User

Untitled

a guest
Jul 3rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <?php
  2.  
  3. class Page extends Controller
  4. {
  5.  
  6. public function __construct()
  7. {
  8. //Load predefined objects that will be used
  9. //throughout the controller
  10. $this->captcha = self::loadLibrary('captcha');
  11. $this->image = self::loadLibrary('image');
  12. $this->session = self::loadLibrary('session');
  13.  
  14. //We have our session object now check if a user is logged in
  15. //and call up the member control
  16. if( $this->session->isPresent('userSession') )
  17. {
  18. $this->user = Modal::Load('user');
  19. }
  20. }
  21.  
  22. public function login()
  23. {
  24. $username = $this->request->username;
  25. $password = $this->request->password;
  26.  
  27. $user = Modal::Load(
  28. 'user',
  29. array(
  30. 'username' => $username,
  31. 'password' => $password
  32. )
  33. );
  34. //UserModal is easy discernable as all loaded modals follow the same convention
  35. if( $user instanceof UserModal )
  36. {
  37. $this->session->storeObject(
  38. 'userSession',
  39. $user
  40. );
  41. }
  42. }
  43.  
  44. public function register($user, $password, $email)
  45. {
  46. $register = Modal::Load('register');
  47.  
  48. //The modal has required properties which must be filled
  49. $register->username = $user;
  50. $register->password = $password;
  51. $register->email = $email;
  52.  
  53. //here we define properties which are completely unique and determined only by the programmer
  54. $register->totalluniqueproperty = 'foo';
  55. $register->anotheruniqueone = 'doothis';
  56.  
  57. //We must save
  58. if( !$register->save() )
  59. {
  60. //Do your error handling here
  61. $errors = $register->getErrors();
  62. return;
  63. }
  64.  
  65. //Go about success
  66. }
  67.  
  68. public function randomPage()
  69. {
  70. $genericData = Modal::Load('generic');
  71. $genericData->datapeice1 = 'foo';
  72. $genericData->datapeice2 = 'foof';
  73. $genericData->name = 'fofof';
  74. $genericData->save();
  75.  
  76.  
  77. $genricCopy = Modal::Load(
  78. 'generic',
  79. array(
  80. 'datapeice2' => 'foof'
  81. )
  82. );
  83. //We now have an exact copy of the object above because it was saved
  84. }
  85. }
Add Comment
Please, Sign In to add comment