예제 #1
0
 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');
     }
 }
예제 #2
0
 function postpayment()
 {
     $app = JFactory::getApplication();
     $plugin = $app->input->getString('method');
     $pluginsms = $app->input->get('methodsms', 'product_sms', 'string');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('bookpro');
     $values = new JObject();
     $results = $dispatcher->trigger("onBookproPostPayment", array($plugin, $values));
     /// Send email
     if ($results) {
         AImporter::model('order');
         $model = new BookProModelOrder();
         $orderComplex = $model->getComplexItem($results[0]->id);
         //$smsresult=$dispatcher->trigger('onBookproSendSms',array($results[0]));
         if (!$results[0]->sendemail) {
             //$this->sendMail($results[0]->id);
             $url = JUri::root() . 'index.php?option=com_bookpro&controller=payment&task=urlsendmail&order_id=' . $results[0]->id;
             $response = BookProHelper::pingUrl($url);
         }
     }
     if ($app->input->getString('message') == 'cancelled') {
         $app->enqueseMessage(JText::_('COM_BOOKPRO_YOUR_BOOKING_HAS_BEEN_CANCELLED'));
         return;
     }
     if ($results[0]->order_status == 'CONFIRMED') {
         AImporter::classes('customer');
         $user = new BookproCustomer();
         $user->saveSunpassPoint($results[0]);
         $app->redirect('index.php?option=com_bookpro&view=postpayment&order=' . $results[0]->order_number . '&email=' . $orderComplex->customer->email);
     } else {
         $app->enqueseMessage(JText::_('COM_BOOKPRO_YOUR_BOOKING_HAS_NOT_BEEN_CONFIRMED'));
     }
     return;
 }