Posted By

rblalock on 10/16/08


Tagged

login textmate joomla 15


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

the_coder
benrudolph


Login on Registration - Joomla 1.5


 / Published in: Other
 

  1. function register_save()
  2. {
  3. global $mainframe;
  4.  
  5. // Check for request forgeries
  6. JRequest::checkToken() or die( 'Invalid Token' );
  7.  
  8. // Get required system objects
  9. $user = clone(JFactory::getUser());
  10. $pathway =& $mainframe->getPathway();
  11. $config =& JFactory::getConfig();
  12. $authorize =& JFactory::getACL();
  13. $document =& JFactory::getDocument();
  14.  
  15. // If user registration is not allowed, show 403 not authorized.
  16. $usersConfig = &JComponentHelper::getParams( 'com_users' );
  17. if ($usersConfig->get('allowUserRegistration') == '0') {
  18. JError::raiseError( 403, JText::_( 'Access Forbidden' ));
  19. return;
  20. }
  21.  
  22. // Initialize new usertype setting
  23. $newUsertype = $usersConfig->get( 'new_usertype' );
  24. if (!$newUsertype) {
  25. $newUsertype = 'Registered';
  26. }
  27.  
  28. // Bind the post array to the user object
  29. if (!$user->bind( JRequest::get('post'), 'usertype' )) {
  30. JError::raiseError( 500, $user->getError());
  31. }
  32.  
  33. // Set some initial user values
  34. $user->set('id', 0);
  35. $user->set('usertype', '');
  36. $user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
  37.  
  38. // TODO: Should this be JDate?
  39. $user->set('registerDate', date('Y-m-d H:i:s'));
  40.  
  41. // If user activation is turned on, we need to set the activation information
  42. $useractivation = $usersConfig->get( 'useractivation' );
  43. if ($useractivation == '1')
  44. {
  45. jimport('joomla.user.helper');
  46. $user->set('activation', md5( JUserHelper::genRandomPassword()) );
  47. $user->set('block', '1');
  48. }
  49.  
  50. // If there was an error with registration, set the message and display form
  51. if ( !$user->save() )
  52. {
  53. JError::raiseWarning('', JText::_( $user->getError()));
  54. $this->register();
  55. return false;
  56. }
  57.  
  58. // Send registration confirmation mail
  59. $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
  60. $password = preg_replace('/[x00-x1Fx7F]/', '', $password); //Disallow control chars in the email
  61. UserController::_sendMail($user, $password);
  62.  
  63. // Everything went fine, set relevant message depending upon user activation state and display message
  64. if ( $useractivation == 1 ) {
  65. $message = JText::_( 'REG_COMPLETE_ACTIVATE' );
  66. } else {
  67. $message = JText::_( 'REG_COMPLETE' );
  68. }
  69.  
  70.  
  71. $options = array();
  72. $options['remember'] = false;
  73. $options['return'] = 'index.php?option=com_jcs&view=jcs&layout=form';
  74.  
  75. $credentials = array();
  76. $credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
  77. $credentials['password'] = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
  78.  
  79. //preform the login action
  80. $error = $mainframe->login($credentials, $options);
  81. $this->setRedirect('index.php?option=com_jcs&view=jcs&layout=form', 'Click PayPal button to Subscribe');
  82. }

Report this snippet  

You need to login to post a comment.