/** * Action to show the registration form */ public function executeIndex() { $this->wherefind = $this->getRequest()->getCookie('wherefind'); //If the user is logged in, don't let them regtutor if ($this->getUser()->isAuthenticated()) { $this->error = 'You are already logged in. You can not register again.'; return sfView::ERROR; } $this->requestedUserType = $this->getRequestedUserType(); //If the form hasn't yet been filled in, just display the form if (sfWebRequest::POST !== $this->getRequest()->getMethod()) { return sfView::SUCCESS; } if ($this->getRequestParameter('terms') != 1) { $this->error = 'You must agree to our <strong>Terms & Conditions</strong>. <a href="#" onClick="javascript: history.go(-1)">Click here</a> to go back to the previous page.'; return sfView::ERROR; } //Create and populate the User object $user = new User(); $user->setEmail($this->getRequestParameter('email')); $user->setPassword($this->getRequestParameter('password1')); $user->setName($this->getRequestParameter('realname')); // GENERATE USERNAME FROM FULL NAME FIELD $userName = str_replace(' ', '', strtolower($this->getRequestParameter('realname'))); $U_QRY = "select * from user where username='******'"; $u_res = mysql_query($U_QRY); $unamecount = mysql_num_rows($u_res); $dupval = 2; duplicationCheck: if ($unamecount >= 1) { $newUsername = $userName . $dupval; $unamequery = mysql_query("select * from user where username='******'"); $unamecount = mysql_num_rows($unamequery); if ($unamecount >= 1) { $dupval++; goto duplicationCheck; } else { $userName = $newUsername; } } $user->setUsername($userName); $user->setTypeUnconfirmed($this->requestedUserType); if (!$user->save()) { throw new PropelException('User creation failed'); } $uptSQL = "UPDATE user SET where_find_us='" . $this->getRequestParameter('where_find_us') . "' WHERE id='" . $user->getId() . "'"; mysql_query($uptSQL); if ($this->requestedUserType == UserPeer::getTypeFromValue('expert')) { $this->notify = $this->getRequestParameter('notify_email') . ',' . $this->getRequestParameter('notify_sms'); $user->setNotification($this->notify); $user->setPhoneNumber($this->getRequestParameter('phone_number')); $this->subscribeExpertToCategories($this->getRequestParameter('categories'), $user); } mysql_query("insert into expert_category(user_id,category_id) values('" . $user->getId() . "','1')") or die(mysql_error()); mysql_query("insert into user_score(user_id,score) values('" . $user->getId() . "','1')") or die(mysql_error()); $this->sendConfirmationEmail($user); $this->forward('regtutor', 'confirmationCodeSent'); }
public function executeRegister() { //If the user is logged in, don't let them register if ($this->getUser()->isAuthenticated()) { $this->error = 'You are already logged in. You can not register again.'; return sfView::ERROR; } if (!$this->hasRequestParameter('name') || !$this->hasRequestParameter('email') || !$this->hasRequestParameter('password')) { $this->error = 'Invalid Request.'; return sfView::ERROR; } $this->requestedUserType = '1'; //Create and populate the User object $user = new User(); $userName = str_replace(' ', '', strtolower($this->getRequestParameter('name'))); $user->setName($this->getRequestParameter('name')); $user->setEmail($this->getRequestParameter('email')); $user->setPassword($this->getRequestParameter('password')); $_SESSION['question'] = $this->getRequestParameter('question'); //$user->setPoints('10.11'); $user->setTypeUnconfirmed($this->requestedUserType); /* Username Duplication Check */ $unamequery = mysql_query("select * from user where username='******'"); $unamecount = mysql_num_rows($unamequery); $dupval = 2; duplicationCheck: if ($unamecount >= 1) { $newUsername = $userName . $dupval; $unamequery = mysql_query("select * from user where username='******'"); $unamecount = mysql_num_rows($unamequery); if ($unamecount >= 1) { $dupval++; goto duplicationCheck; } else { $userName = $newUsername; } } $user->setUsername($userName); //Try to save the User... throw an exception if something messes up if (!$user->save()) { throw new PropelException('User creation failed'); } mysql_query("insert into expert_category(user_id,category_id) values('" . $user->getId() . "','1')") or die(mysql_error()); mysql_query("insert into user_score(user_id,score) values('" . $user->getId() . "','1')") or die(mysql_error()); $this->sendConfirmationEmail($user, $_SESSION['question']); $this->user = $user; $this->forward('quickreg', 'confirmationcode'); //$this->redirect(sfConfig::get('app_rayku_url')."/quickreg/confirmationcodesent"); }
/** * Action to show the registration form */ public function executeIndex() { //If the user is logged in, don't let them register if ($this->getUser()->isAuthenticated()) { $this->error = 'You are already logged in. You can not register again.'; return sfView::ERROR; } $this->requestedUserType = $this->getRequestedUserType(); //If the form hasn't yet been filled in, just display the form if (sfWebRequest::POST !== $this->getRequest()->getMethod()) { return sfView::SUCCESS; } if ($this->getRequestParameter('terms') != 1) { $this->error = 'You must agree to our <strong>Terms & Conditions</strong>. <a href="#" onClick="javascript: history.go(-1)">Click here</a> to go back to the previous page.'; return sfView::ERROR; } //Create and populate the User object $user = new User(); $user->setEmail($this->getRequestParameter('email')); $user->setPassword($this->getRequestParameter('password1')); $user->setName($this->getRequestParameter('realname')); $expiration = substr($this->getRequestParameter('expiry_date'), 0, 2) . '/' . substr($this->getRequestParameter('expiry_date'), -2); require_once $_SERVER['DOCUMENT_ROOT'] . '/braintree_environment.php'; $result = Braintree_Customer::create(array('firstName' => $this->getRequestParameter('realname'), 'lastName' => '', 'creditCard' => array('cardholderName' => $this->getRequestParameter('realname'), 'number' => $this->getRequestParameter('credit_card'), 'cvv' => $this->getRequestParameter('cvv'), 'expirationDate' => $expiration, 'options' => array('verifyCard' => true)))); //error_log($result->customer->creditCards[0]->token, 0); if (false && !$result->success) { //error_log("invalid", 0); $this->error = 'Your credit card is invalid.'; return sfView::ERROR; } else { //should only save last 4 digit // $user->setCreditCard(substr($this->getRequestParameter('credit_card'),-4)); // $user->setCreditCardToken($result->customer->creditCards[0]->token); $userName = str_replace(' ', '', strtolower($this->getRequestParameter('realname'))); $U_QRY = "select * from user where username='******'"; $u_res = mysql_query($U_QRY); $unamecount = mysql_num_rows($u_res); $dupval = 2; duplicationCheck: if ($unamecount >= 1) { $newUsername = $userName . $dupval; $unamequery = mysql_query("select * from user where username='******'"); $unamecount = mysql_num_rows($unamequery); if ($unamecount >= 1) { $dupval++; goto duplicationCheck; } else { $userName = $newUsername; } } $user->setUsername($userName); $user->setTypeUnconfirmed($this->requestedUserType); if (!empty($_POST['coupon'])) { $query = mysql_query("select * from referral_code where referral_code='" . $_POST['coupon'] . "'") or die(mysql_error()); if (mysql_num_rows($query) > 0) { $rowValues = mysql_fetch_assoc($query); //$rowValues['user_id']; $query = mysql_query("select * from user where id=" . $rowValues['user_id']) or die(mysql_error()); $rowDetails = mysql_fetch_assoc($query); $newPoints = $rowDetails['points'] + 0.5; mysql_query("update user set points='" . $newPoints . "' where id=" . $rowValues['user_id']) or die(mysql_error()); mysql_query("delete from referral_code where referral_code='" . $_POST['coupon'] . "'") or die(mysql_error()); } else { if ($_POST['coupon'] == 'launch11') { $points = "10"; } elseif ($_POST['coupon'] == 'promo92') { $points = "12"; } elseif ($_POST['coupon'] == 'uoft9211') { $points = "8"; } } } if (!$user->save()) { throw new PropelException('User creation failed'); } if ($this->requestedUserType == UserPeer::getTypeFromValue('expert')) { $this->notify = $this->getRequestParameter('notify_email') . ',' . $this->getRequestParameter('notify_sms'); $user->setNotification($this->notify); $user->setPhoneNumber($this->getRequestParameter('phone_number')); $this->subscribeExpertToCategories($this->getRequestParameter('categories'), $user); } if (!empty($_POST['coupon']) && !empty($points)) { mysql_query("update user set points='" . $points . "' where id=" . $user->getId()) or die(mysql_error()); } elseif (!empty($_POST['coupon'])) { mysql_query("update user set points='11' where id=" . $user->getId()) or die(mysql_error()); } // Referral module // Rajesh Soni - 23 November 2012 if ($_POST['ref']) { $ref_by_user = mysql_real_escape_string($_POST['ref']); mysql_query("update user set referred_by='{$ref_by_user}' where id=" . $user->getId()) or die(mysql_error()); } mysql_query("insert into expert_category(user_id,category_id) values('" . $user->getId() . "','1')") or die(mysql_error()); mysql_query("insert into user_score(user_id,score) values('" . $user->getId() . "','1')") or die(mysql_error()); $this->sendConfirmationEmail($user); $this->forward('register', 'confirmationCodeSent'); } }