static function registerRedirect($intro, $plan)
 {
     $_POST['intro'] = $intro;
     // The plans are supposed to be first, so the details form should hold the values
     if (!empty($plan['id'])) {
         $_POST['usage'] = $plan['id'];
         $_POST['processor'] = $plan['gw'][0]->processor_name;
         if (isset($plan['gw'][0]->recurring)) {
             $_POST['recurring'] = $plan['gw'][0]->recurring;
         }
     }
     // Send to registration handler
     if (aecComponentHelper::detect_component('anyCB')) {
         aecRegistration::registerRedirectCB($plan);
     } elseif (aecComponentHelper::detect_component('JUSER')) {
         aecRegistration::registerRedirectJUser();
     } elseif (aecComponentHelper::detect_component('JOMSOCIAL')) {
         aecRegistration::registerRedirectJomSocial($plan);
     } else {
         aecRegistration::registerRedirectJoomla($plan);
     }
 }
Example #2
0
 public function procTriggerCreate($user, $payment, $usage)
 {
     $db = JFactory::getDBO();
     // Create a new cmsUser from user details - only allowing basic details so far
     // Try different types of usernames to make sure we have a unique one
     $usernames = array($user['username'], $user['username'] . substr(md5($user['name']), 0, 3), $user['username'] . substr(md5($user['name'] . (int) gmdate('U')), 0, 3));
     $username = '';
     // Iterate through semi-random and pseudo-random usernames until a non-existing is found
     $id = 1;
     $k = 0;
     while ($id) {
         $username = $usernames[min($k, count($usernames) - 1)];
         $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $username . '\'';
         $db->setQuery($query);
         $id = $db->loadResult();
         $k++;
     }
     $var['id'] = 0;
     $var['gid'] = 0;
     $var['username'] = $username;
     $var['name'] = $user['name'];
     $var['email'] = $user['email'];
     $var['password'] = $user['password'];
     $userid = aecRegistration::saveUserRegistration($var, true);
     // Create a new invoice with $invoiceid as secondary ident
     $invoice = new Invoice();
     $invoice->create($userid, $usage, $payment['processor'], $payment['secondary_ident']);
     // return nothing, the invoice will be handled by the second ident anyways
     return;
 }
Example #3
0
 public function save($coupon = null)
 {
     global $aecConfig;
     $this->confirmed = 1;
     $this->loadPlanObject();
     $add =& $this;
     $exchange = $silent = null;
     $this->triggerMIs('before_invoice_confirm', $exchange, $add, $silent);
     if (empty($this->userid)) {
         if (!empty($aecConfig->cfg['skip_registration'])) {
             if (!$this->reCaptchaCheck()) {
                 return false;
             }
         }
         $dbtmpl = new configTemplate();
         $dbtmpl->loadDefault();
         if (!empty($dbtmpl->settings['tos'])) {
             $tos = aecGetParam('tos', 0, true, array('bool'));
             if (!$tos) {
                 $this->confirmed = 0;
                 return $this->confirm();
             }
         }
         if (!empty($this->plan)) {
             if (!isset($this->plan->params['override_activation'])) {
                 $this->plan->params['override_activation'] = false;
             }
             if (!isset($this->plan->params['override_regmail'])) {
                 $this->plan->params['override_regmail'] = false;
             }
             $this->userid = aecRegistration::saveUserRegistration($this->passthrough, false, $this->plan->params['override_activation'], $this->plan->params['override_regmail']);
         } else {
             $this->userid = aecRegistration::saveUserRegistration($this->passthrough);
         }
         if (!$this->userid) {
             $errors = JError::getErrors();
             aecErrorAlert(JText::_('COM_USERS_REGISTRATION_SAVE_FAILED'));
         }
     }
     $this->loadMetaUser(true);
     $this->metaUser->setTempAuth();
     if (!empty($this->plan)) {
         if ($this->verifyMIForms($this->plan) === false) {
             $this->confirmed = 0;
             return $this->confirm();
         }
     } elseif (!empty($this->cart)) {
         $check = true;
         foreach ($this->cart as $ci) {
             if ($this->verifyMIForms($ci['obj']) === false) {
                 $check = false;
             }
         }
         if (!$check) {
             $this->confirmed = 0;
             return $this->confirm();
         }
     }
     return $this->checkout(0, null, $coupon);
 }
Example #4
0
 public function createUsers($amount)
 {
     $db = JFactory::getDBO();
     if (!$_POST['create_users']) {
         $query = 'SELECT MIN(id)' . ' FROM #__users' . ' WHERE `id` > 64';
         $db->setQuery($query);
         $this->range['users']['start'] = $db->loadResult();
         $query = 'SELECT MAX(id)' . ' FROM #__users';
         $db->setQuery($query);
         $this->range['users']['end'] = $db->loadResult();
         return;
     }
     for ($i = 0; $i <= $amount; $i++) {
         $rname = $this->getRandomName();
         $var = array('username' => $this->generateUsername($rname), 'password' => 'password', 'password2' => 'password', 'email' => $this->generateEmail($rname), 'name' => $rname);
         $userid = aecRegistration::saveUserRegistration($var, true, true, true, true);
         if ($i == 0) {
             $this->range['users']['start'] = $userid;
         } elseif ($i == $amount) {
             $this->range['users']['end'] = $userid;
         }
     }
 }
Example #5
0
 public function createUser($fields)
 {
     return aecRegistration::saveUserRegistration($fields, true, true, true, true);
 }
 public function parseNotification($post)
 {
     if (empty($this->settings)) {
         $this->getSettings();
     }
     $return = $this->processor->parseNotification($post);
     // Check whether this is an ad-hoc notification
     if (!empty($return['_aec_createuser']) && empty($return['invoice'])) {
         // Identify usage
         $usage = 1;
         // Create new user account and fetch id
         $userid = aecRegistration::saveUserRegistration($return['_aec_createuser'], true, true, false);
         // Create Invoice
         $invoice = new Invoice();
         $invoice->create($userid, $usage, $this->processor_name);
         $invoice->computeAmount();
         // Set new return variable - we now know what invoice this is
         $return['invoice'] = $invoice->invoice_number;
     }
     // Always amend secondary ident codes
     if (!empty($return['secondary_ident']) && !empty($return['invoice'])) {
         $invoice = new Invoice();
         $invoice->loadInvoiceNumber($return['invoice']);
         $invoice->secondary_ident = $return['secondary_ident'];
         $invoice->storeload();
     }
     if (!empty($return['_aec_createuser'])) {
         unset($return['_aec_createuser']);
     }
     return $return;
 }