function register() { AImporter::helper('bookpro'); JSession::checkToken() or die(JText::_('Invalid Token')); $config = JBFactory::getConfig(); $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $params = JComponentHelper::getParams('com_users'); $useractivation = $params->get('useractivation'); $input = $mainframe->input; $post = $input->getArray($_POST); $db = JFactory::getDbo(); try { $db->transactionStart(); $post['name'] = $post['firstname'] . ' ' . $post['lastname']; $cuser = new JUser(); $cuser->bind($post); $cuser->name = $post['name']; //check Username if (!$this->checkUsernamePHP($post['username'])) { $mainframe->enqueueMessage(JText::_('COM_BOOKPRO_USERNAME_EXISTS'), 'warning'); $view = $this->getView('register', 'html', 'BookProView'); $view->assign('customer', (object) $post); $view->display(); return; } if (!$this->checkEmailPHP($post['email'])) { $mainframe->enqueueMessage(JText::_('COM_BOOKPRO_EMAIL_EXISTS'), 'warning'); $view = $this->getView('register', 'html', 'BookProView'); $view->assign('obj', (object) $post); $view->display(); return; } $cuser->activation = $useractivation; if ($post['group_id']) { $cuser->groups = array($post['group_id']); } else { $cuser->groups = array($config->get('customer_usergroup', 2)); } $cuser->sendEmail = 1; $cuser->registerDate = JFactory::getDate()->toSql(); $cuser->save(); AImporter::classes('customer'); $jbuser = new BookproCustomer(); $post['user'] = $cuser->id; $post['state'] = 1; $jbuser->saveNewCustomer($post); $db->transactionCommit(); } catch (Exception $e) { $mainframe->enqueueMessage($e->getMessage()); $db->transactionRollback(); $this->setRedirect(JUri::base() . 'index.php?option=com_bookpro&view=register'); } if ($useractivation == 1 || $useractivation == 2) { $post['activation'] = JApplication::getHash(JUserHelper::genRandomPassword()); $post['block'] = 1; } //handle email notification if ($useractivation == 1) { $config = JFactory::getConfig(); $post['fromname'] = $config->get('fromname'); $post['mailfrom'] = $config->get('mailfrom'); $post['sitename'] = $config->get('sitename'); $post['siteurl'] = JUri::root(); $post['activate'] = JUri::base() . 'index.php?option=com_users&task=registration.activate&token=' . $post['activation']; $emailSubject = JText::sprintf('COM_BOOKPRO_EMAIL_ACCOUNT_DETAILS', $post['name'], JUri::base()); $emailBody = JText::sprintf('COM_BOOKPRO_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $post['name'], $post['sitename'], $post['activate'], JUri::base(), $post['username']); $return = JFactory::getMailer()->sendMail($post['mailfrom'], $post['fromname'], $post['email'], $emailSubject, $emailBody); } //redirect to complete view if ($useractivation == 1 || $useractivation == 2) { $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE')); $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false)); return; } AImporter::helper('email'); $mailer = new EmailHelper(); if (isset($config->sendRegistrationsEmails) && $config->sendRegistrationsEmails > 0) { $mailer->registerNotify($id); } if ($config->get('auto_login')) { $options = array(); $options['remember'] = JRequest::getBool('remember', true); $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW); $error = $mainframe->login($credentials, $options); } $return = JRequest::getVar('return'); if ($return) { $mainframe->redirect(base64_decode($return)); } else { $mainframe->redirect(JURI::base() . 'index.php'); } }