PageRenderTime 25ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/protected/controllers/RegistrationController.php

https://github.com/LosYear/FluentCMS
PHP | 56 lines | 47 code | 9 blank | 0 comment | 4 complexity | 4b59e0e5f8511c8abc19afd0980e887c MD5 | raw file
  1. <?php
  2. Yii::import('application.modules.registration.controllers.YumRegistrationController');
  3. class RegistrationController extends YumRegistrationController
  4. {
  5. public $registrationView = '/registration/registration';
  6. public $defaultAction = 'registration';
  7. public function actionRegistration()
  8. {
  9. Yii::import('application.modules.profile.models.*');
  10. $profile = new YumProfile;
  11. if (isset($_POST['Profile'])) {
  12. $profile->attributes = $_POST['YumProfile'];
  13. if ($profile->save())
  14. $user = new YumUser;
  15. $password = YumUser::generatePassword();
  16. $user->register(md5($profile->email), $password, $profile);
  17. $this->sendRegistrationEmail($user, $password);
  18. Yum::setFlash('Thank you for your registration. Please check your email.');
  19. $this->redirect(Yum::module()->loginUrl);
  20. }
  21. $this->render('registration', array(
  22. 'profile' => $profile
  23. ));
  24. }
  25. public function sendRegistrationEmail($user, $password)
  26. {
  27. if (!isset($user->profile->email)) {
  28. throw new CException(Yum::t('Email is not set when trying to send Registration Email'));
  29. }
  30. $activation_url = $user->getActivationUrl();
  31. if (is_object($content)) {
  32. $body = strtr('Hi, {email}, your new password is {password}. Please activate your account by clicking this link: {activation_url}', array(
  33. '{email}' => $user->profile->email,
  34. '{password}' => $password,
  35. '{activation_url}' => $activation_url
  36. ));
  37. $mail = array(
  38. 'from' => Yum::module('registration')->registrationEmail,
  39. 'to' => $user->profile->email,
  40. 'subject' => 'Your registration on my example Website',
  41. 'body' => $body
  42. );
  43. $sent = YumMailer::send($mail);
  44. }
  45. return $sent;
  46. }
  47. }