protected function doSave($con = null)
 {
     $message = parent::doSave($con);
     $message = $this->getObject();
     /* // Ajout des infos concernant la réservation lors de l'envoi du message
     		$message->setText("TEST REUSSI\n\n\n--------------------\n\n\n".$message->getText()); */
     $recipient = $message->getRecipientUser();
     $to = $recipient->getEmailAddress();
     $sender = $message->getSenderUser();
     $from = null;
     if (ConfigurationHelper::getParameter('Email', 'use_mail', false)) {
         if (!empty($to)) {
             if (!is_null($sender)) {
                 $from = $sender->getEmailAddress();
                 if (empty($from)) {
                     $from = null;
                 }
             }
             MailHelper::send($to, $message->getSubject(), $message->getText(), $recipient->getFullName(), $from, $message->getSender());
         }
     }
     if (!is_null($sender)) {
         $messageSent = $message->copy();
         $messageSent->setOwnerId($sender->getId());
         $messageSent->setWasRead(true);
         $messageSent->save();
     }
     return $message;
 }
 /**
  * @param ContactusForm $model
  */
 private function _send($model)
 {
     // $emails = array(Yii::app()->params['contactusEmail'], $model->email);
     $emails = array(Yii::app()->params['contactusTestEmail']);
     $oldLayout = $this->layout;
     $this->layout = "emailmaster";
     $emailBody = $this->render('../emails/emailContactAs', array('data' => array('email' => $model->email, 'name' => $model->name, 'message' => $model->message)), true);
     MailHelper::send($emailBody, "SharedKey.com - Contact Us - " . $model->name, $emails, "SharedKey.com", array($model->email));
     $this->layout = $oldLayout;
 }
 public function actionDelete()
 {
     if ($this->access > UserAccessTable::FULL_ACCESS) {
         return 0;
     }
     $id = $_POST['id'];
     $calendarModel = new Calendar();
     $calendarModel = $calendarModel->findByPk($id);
     if ($calendarModel == null || $calendarModel == false) {
         echo json_encode(array('result' => 0));
         die;
     }
     $usersEmail = array();
     if (YII::app()->request->getParam('notification', 0) == 1 || YII::app()->request->getParam('notification', 0) == true) {
         $links = $this->getPropertyMembers();
         foreach ($links as $key => $link) {
             array_push($usersEmail, $link['user']['email']);
         }
     }
     $attrs = $calendarModel->attributes;
     $result = $calendarModel->deleteByPk($id);
     $date1 = new DateTime();
     $end_date = date(strtotime($calendarModel->attributes['end_date']));
     $date1->setTimestamp($end_date);
     $real_end_date = $date1->modify('-1 day');
     $end_date1 = $real_end_date->format('F d, Y');
     if ($result == 1 || $result == true) {
         $this->layout = "emailmaster";
         $body = $this->render('../emails/emailCalendar', array('fullname' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'property' => $this->propertyName, 'start' => date('F d, Y', strtotime($attrs['create_date'])), 'end' => $end_date1, 'event' => $attrs['event'], 'message' => $attrs['notes'], 'action' => 'Deleted'), true);
         MailHelper::send($body, "SharedKey.com - " . $this->propertyName . " - Deleted  Calendar Event", $usersEmail);
     }
     echo json_encode(array('result' => $result));
     die;
 }
 public function actionRemoveproperty($id)
 {
     $userId = Yii::app()->user->getState('id');
     //all users can remove itself from property member's list
     if (!UserAccessTable::checkUser2PropertyAccess($userId, $id, UserAccessTable::GUEST)) {
         Yii::app()->request->redirect(basePath('app/gallery'));
     }
     $user2property = User2property::model()->findByAttributes(array('userId' => $userId, 'propertyId' => $id));
     if ($user2property->getAttribute('access') != UserAccessTable::OWNER) {
         //email to member (NOT admin)
         $this->layout = "emailmaster";
         $body = $this->render("../emails/emailItselfRemove", array('name' => $user2property->user->getAttribute('firstname') . ' ' . $user2property->user->getAttribute('lastname'), 'propertyName' => $user2property->property->getAttribute('property_name')), true);
         MailHelper::send($body, "SharedKey - Removed Property", array($user2property->user->getAttribute('email')));
         //clear calendar events first
         $calendar = new Calendar();
         $calendar = $calendar->findAllByAttributes(array('linkid' => $user2property->getAttribute('id')));
         foreach ($calendar as $cal) {
             $cal->delete();
         }
         //for not property Administrator we just remove a link to property
         $user2property->delete();
         if ($this->_isAllUserPropertiesDeactivated($userId)) {
             //removed last property need remove user
             $this->removeUser($userId);
             return;
         }
         Yii::app()->request->redirect(basePath('app/properties'));
         return;
     }
     //member is administrator we need cancel RecurringPaymentsProfile and deactivate property
     //lets find last transaction
     $transaction = Transaction::model()->findByAttributes(array('userid' => $userId, 'propertyid' => $id));
     if (!$transaction) {
         //no previous transactions not need to refund
     }
     $userApi = sharedkeyApi::create('usersAPI');
     $userEmail = Yii::app()->user->getState('email');
     $userApi->addParams(array('email' => $userEmail));
     $byEmail = json_decode($userApi->byEmail('get'));
     $userData = (array) $byEmail->data;
     $userData['property_id'] = $id;
     //close RecurringPaymentsProfile
     if ($transaction) {
         YII::app()->user->setState("addPropertyEmailed", true);
         $temp = PayPalHelper::cancelRecurringPaymentsProfile($transaction->getAttribute('pp_PROFILEID'), $userData);
     }
     //do deactivated
     $property = Properties::model()->findByPk($id);
     $property->isdeactivated = 1;
     $property->edt = new CDbExpression('NOW()');
     //$property->trialPeriodStartDate = null;
     $property->save();
     $this->layout = "emailmaster";
     //mail to admin
     $token = uniqid();
     $body = $this->render("../emails/emailAdminAfterRemove", array('name' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'url' => basePathByHost("/app/changeactiveproperty/" . $property->getAttribute("id")) . '?token=' . $token), true);
     MailHelper::send($body, "SharedKey - Removed Property", array($userEmail));
     //informative other user about property deactivated
     $users2properties = User2property::model()->with('user')->findAll('propertyId=:propertyId', array(':propertyId' => $id));
     foreach ($users2properties as $key => $u2p) {
         if ($u2p->getAttribute('access') == UserAccessTable::OWNER) {
             continue;
         }
     }
     if ($this->_isAllUserPropertiesDeactivated($userId)) {
         $user = User::model()->find('id=:id', array(':id' => $userId));
         $user->verificationToken = $token;
         $user->save();
         $this->redirect(basePath('user/logout'));
         return;
     }
     Yii::app()->request->redirect(basePath('app/properties'));
 }
 protected function NotificationMembers($action, $all = false, $data)
 {
     $usersEmail = array();
     if ($all == true) {
         $links = $this->getPropertyMembers();
         foreach ($links as $key => $link) {
             array_push($usersEmail, $link['user']['email']);
         }
     } else {
         $usersEmail = array();
     }
     $description = $action;
     if ($action == "Edited") {
         $action = "Updated";
     }
     if ($action == "Added") {
         $action = "New";
         $description = "Created";
     }
     $layoutBefore = $this->layout;
     if (!empty($usersEmail)) {
         $this->layout = "emailmaster";
         $emailBody = $this->render('../emails/emailHouseRule', array('data' => array('fullname' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'property' => $this->propertyName, 'text' => nl2p($data['text']), 'title' => $data['title'], 'action' => $action, 'description' => $description)), true);
         $property = $this->propertyName;
         MailHelper::send($emailBody, "SharedKey.com - {$property} - {$action} House Rules", $usersEmail);
     }
 }
 public function actionSignUp()
 {
     $data = $this->getSignUpData();
     $errors = $this->signUpValidation($data);
     if ($data['PP_TRIAL'] != 'YES') {
         $paypalModel = new PayPalPaymentModel();
         if (empty($errors)) {
             $paypalModel->setAttributes($_POST);
             $paypalModel->validate();
             $errors = $paypalModel->getErrors();
         }
     }
     if (empty($errors)) {
         //registration
         $userApi = sharedkeyApi::create('usersAPI');
         $verificationToken = uniqid();
         $data['verificationToken'] = $verificationToken;
         $data['status'] = 0;
         $userApi->addParams($data);
         $signup = $userApi->signUp('create');
         $signup = json_decode($signup);
         if ($signup->result == false) {
             $this->redirect(basePath('signup'));
         } else {
             $userApi = sharedkeyApi::create('usersAPI');
             $userApi->addParams(array('email' => $data['email'], 'password' => $data['password'], 'format' => 'json'));
             $byEmail = json_decode($userApi->byEmail('get'));
             $userData = $byEmail->data;
             if ($data['PP_TRIAL'] != 'YES') {
                 //send paypal request
                 $response = PayPalHelper::createBullingRequest($paypalModel, (array) $userData);
                 if (!$response->status) {
                     $this->clearDataAfterSignUpByEmail($data['email']);
                     $errors['paypal_error'] = $response->errorMessage;
                     //show errors
                     $this->setFlashErrors($errors);
                     $this->setFlashData($data);
                     $this->redirect(basePath('signup'));
                 }
             }
             $this->layout = "emailmaster";
             $message = $this->render('../emails/newuseremail', array('token' => $verificationToken, 'url' => Yii::app()->params['domain'] . '/activeuser', 'email' => $data['email'], 'password' => $data['password'], 'fullname' => $data['firstname'] . ' ' . $data['lastname']), true);
             MailHelper::send($message, "Welcome to SharedKey", array($data['email']));
             //$identity->authenticate();
             //Yii::app()->user->login($identity);
             Yii::app()->user->setState('new_email', $data['email']);
             $this->redirect(basePath('activateusermessage'));
         }
     } else {
         $this->clearDataAfterSignUpByEmail($data['email']);
         //show errors
         $this->setFlashErrors($errors);
         $this->setFlashData($data);
         $this->redirect(basePath('signup'));
     }
 }
 public function actionInviteGuestEmail($email = false)
 {
     $testData = array('data' => array('senderFullName' => "Dart Vaider", 'propertyName' => "Dead star", 'from' => "06/06/06 060606", 'to' => "07/07/07 070707", 'access' => UserAccessTable::accessLevelToString(UserAccessTable::GUEST), 'event' => "NewYear", 'message' => "hello !", 'userFullName' => 'Ilya Mineev', 'url' => "localhost/sfsdhuifg", 'token' => 'dgdfgdfgf', 'email' => '*****@*****.**', 'password' => 'pasw'), 'userFullName' => 'Ilya Mineev', 'url' => "localhost/sfsdhuifg", 'token' => 'dgdfgdfgf', 'email' => '*****@*****.**', 'password' => 'pasw');
     if ($email != false) {
         $emailBody = $this->renderPartial('InviteGuestEmail', $testData, true);
         MailHelper::send($emailBody, "SharedKey.com", array($email));
         $this->layout = 'app';
         $this->render('index', array('text' => "Letter was sent to {$email}"));
     } else {
         $this->renderPartial('InviteGuestEmail', $testData);
     }
 }
 public function actionInvite()
 {
     $newEvents = array();
     $propertyId = Yii::app()->user->getState('propertyId');
     if (isset($_POST['propId'])) {
         if (is_numeric($_POST['propId'])) {
             $propertyId = $_POST['propId'];
         }
     }
     if (!Yii::app()->request->isPostRequest) {
         echo json_encode(array('status' => 0, 'message' => 'Only Post request are allowed.'));
         die;
     }
     if (!UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), $propertyId, UserAccessTable::BASIC_ACCESS)) {
         echo json_encode(array('status' => 0, 'message' => 'You can not do this action.'));
         die;
     }
     //check login
     if (Yii::app()->user->isGuest) {
         echo json_encode(array('status' => 0, 'message' => 'Please login.'));
         die;
     }
     if (!UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), $propertyId, UserAccessTable::BASIC_ACCESS)) {
         echo json_encode(array('status' => 0, 'message' => 'You can not do this action.'));
         die;
     }
     $property = Properties::model()->findByPk($propertyId);
     $model = new InviteGuest();
     $model->setAttributes($_POST);
     //create user 2 property tables
     $u2propertyes = array();
     foreach ($model->emails as $key => $value) {
         $u2p = new User2property();
         $user = User::model()->findByAttributes(array('email' => $value));
         $newUserEmailBody = "";
         if ($user == null) {
             //need create new user
             if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                 continue;
             }
             $user = $this->createGuestUser($value, $model->names[$key], $propertyId);
             $this->layout = "emailmaster";
             $newUserEmailBody = $this->renderPartial('../emails/emailInviteNewGuest', array('userFullName' => $user->getAttribute('firstname') . ' ' . $user->getAttribute('lastname'), 'senderFullName' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'email' => $user->getAttribute('email'), 'access' => UserAccessTable::accessLevelToString(UserAccessTable::GUEST), 'password' => $user->getAttribute('password'), 'url' => basePathByHost('/')), true);
             // MailHelper::send($newUserEmailBody, "SharedKey.com - New Member Account", array($user->getAttribute('email')));
         } else {
             //we can use exist user
         }
         $checku2p = User2property::model()->findByAttributes(array('propertyId' => $propertyId, 'userId' => $user->getAttribute('id')));
         if ($checku2p != null) {
             echo json_encode(array('status' => 0, 'message' => 'User is already a member of this property.'));
             die;
         }
         $u2p->propertyId = $propertyId;
         $u2p->userId = $user->getAttribute('id');
         $u2p->access = UserAccessTable::GUEST;
         $u2p->status = UserAccessTable::STATUS_ACTIVE;
         $u2p->inviteDate = date('Y-m-d h:i:s');
         $fromDate = null;
         if (!empty($model->from)) {
             $fromDate = new DateTime($model->from);
             $u2p->fromDate = $fromDate->format('Y-m-d h:i:s');
         } else {
             $u2p->fromDate = null;
         }
         $toDate = null;
         if (!empty($model->to)) {
             $toDate = new DateTime($model->to);
             $u2p->toDate = $toDate->format('Y-m-d h:i:s');
         } else {
             $u2p->toDate = null;
         }
         $u2p->inviteUserId = Yii::app()->user->getState('id');
         $u2p->color = 'type13';
         $u2p->bookingName = $model->names[$key];
         $u2p->save();
         $this->layout = "emailmaster";
         $inviteEmail = $this->render('../emails/emailInvite', array('data' => array('fromName' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'from' => isset($fromDate) ? $fromDate->format('F j, Y') : '-', 'to' => isset($toDate) ? $toDate->format('F j, Y') : '-', 'access' => UserAccessTable::accessLevelToString(UserAccessTable::GUEST), 'event' => $model->event, 'message' => nl2br($model->message), 'toUser' => $user->getAttribute('firstname') . ' ' . $user->getAttribute('lastname'), 'newUserBody' => $newUserEmailBody)), true);
         MailHelper::send($inviteEmail, "Sharedkey.com - Invitation to " . $property->getAttribute('property_name'), array($user->getAttribute('email')), "SharedKey.com", array(Yii::app()->user->getState('email')));
         $u2propertyes[$key] = $u2p;
         $username = $model->names[$key];
         $calendarEvent = new Calendar();
         $calendarEvent->create_date = $u2p->fromDate;
         $calendarEvent->end_date = $u2p->toDate;
         $calendarEvent->event = $_POST['event'];
         $calendarEvent->propertyid = $u2p->propertyId;
         $calendarEvent->notes = $model->message;
         $calendarEvent->linkid = $this->linkWithProperty->id;
         $calendarEvent->isguest = true;
         $calendarEvent->guestid = $u2p->userId;
         $calendarEvent->guestname = $model->names[$key];
         $result = $calendarEvent->save();
         $outputEvent = array("result" => true, "data" => (array) $calendarEvent->getAttributes(), "event" => $calendarEvent->event);
         $outputEvent['data']['link'] = (array) $u2p->getAttributes();
         array_push($newEvents, $outputEvent);
     }
     $users = array();
     foreach ($u2propertyes as $key => $u2p) {
         $users[$key] = $this->createViewItem($u2p);
     }
     echo json_encode(array('status' => 1, 'users' => $users, 'events' => $newEvents));
     die;
 }
Exemple #9
0
 protected function processFormVisitor(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $user = $form->save();
         if (!is_null($user->getEmailAddress())) {
             $password = $user->autoSetPassword();
             if (!is_null($password)) {
                 $user->save();
                 $message = ConfigurationHelper::getParameter('General', 'registration_granted_message');
                 $message = preg_replace(array('/%username%/', '/%password%/'), array($user->getLogin(), $password), $message);
                 try {
                     if (!empty($message)) {
                         MailHelper::send($user->getEmailAddress(), 'Tempo\'s', $message);
                     }
                 } catch (Exception $ex) {
                     throw $ex;
                 }
             }
         }
         $this->redirect('user/indexVisitors');
     }
 }
 public function actionSaveMember()
 {
     if (!Yii::app()->request->isPostRequest) {
         echo json_encode(array('status' => 0, 'message' => 'Only Post request are allowed.'));
         die;
     }
     if (Yii::app()->user->isGuest) {
         echo json_encode(array('status' => 0, 'message' => 'Only authorize user can allow this.'));
         die;
     }
     $member = new Member();
     $member->setAttributes($_POST);
     $member->validate();
     if (!UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), $member->propertyId, UserAccessTable::FULL_ACCESS)) {
         echo json_encode(array('status' => 0, 'message' => 'You can not do this action.'));
         die;
     }
     $errors = $member->getErrors();
     if (count($errors) > 0) {
         echo json_encode(array('status' => 0, 'errors' => $errors));
         die;
     }
     //get property
     $property = Properties::model()->findByPk($member->propertyId);
     //check new user in database
     $user = User::model()->findByAttributes(array('email' => $member->email));
     if ($user != null) {
         //system already contains user with some email
         $eu2p = User2property::model()->with('user')->findByAttributes(array('userId' => $user->getAttribute('id'), 'propertyId' => $member->propertyId));
         if ($eu2p != null) {
             echo json_encode(array('status' => 0, 'message' => 'User already exist.'));
             die;
         }
         $u2p = new User2property();
         $u2p->setAttribute('userId', $user->getAttribute('id'));
         $u2p->setAttribute('bookingName', $member->bookname);
         $u2p->setAttributes($member->attributes);
         $u2p->save();
         $this->layout = "emailmaster";
         $emailBody = $this->render('../emails/emailInviteMember', array('userFullName' => $user->getAttribute('firstname') . ' ' . $user->getAttribute('lastname'), 'senderFullName' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'access' => UserAccessTable::accessLevelToString($member->access)), true);
         MailHelper::send($emailBody, "SharedKey.com - New Property Added to Your Account", array($user->getAttribute('email')));
         $temp = User2property::model()->with('user')->findByPk($u2p->getAttribute('id'));
         echo json_encode(array('status' => 1, 'member' => $this->createViewItem($temp)));
         die;
     }
     $newUser = new User();
     $newUser->setAttributes($member->attributes);
     $password = PasswordGenerator::generatePassword();
     $newUser->setAttribute('password', $password);
     $newUser->setAttribute('property_id', $member->propertyId);
     $tutorialModel = new TutorialModel();
     $tutorialModel->setAttributes(array('gallery' => 1, 'guest_book' => 1, 'house_rules' => 1, 'key_contacts' => 1, 'mapdirections' => 1, 'notice_board' => 1, 'tourist_info' => 1));
     $tutorialModel->save();
     $newUser->setAttribute('tutorial_id', $tutorialModel->id);
     $newUser->setAttribute('status', 1);
     $newUser->setAttribute('createdDate', new CDbExpression('NOW()'));
     $newUser->save();
     $u2p = new User2property();
     $u2p->setAttribute('userId', $newUser->getAttribute('id'));
     $u2p->setAttribute('bookingName', $member->bookname);
     $u2p->setAttributes($member->attributes);
     $u2p->save();
     $this->layout = "emailmaster";
     $emailBody = $this->render('../emails/emailInviteNewMember', array('userFullName' => $newUser->getAttribute('firstname') . ' ' . $newUser->getAttribute('lastname'), 'senderFullName' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'email' => $newUser->getAttribute('email'), 'access' => UserAccessTable::accessLevelToString($member->access), 'password' => $password), true);
     MailHelper::send($emailBody, "Sharedkey.com - Invitation to " . $property->getAttribute('property_name'), array($newUser->getAttribute('email')));
     $temp = User2property::model()->with('user')->findByPk($u2p->getAttribute('id'));
     echo json_encode(array('status' => 1, 'member' => $this->createViewItem($temp)));
     die;
 }
Exemple #11
0
 public static function SendRequest($pp_nvpstr, $userData)
 {
     set_time_limit(1000);
     ini_set('display_errors', 'On');
     $testflag = PayPalHelper::testflag;
     // Set up your API credentials, PayPal end point, and API version.
     if ($testflag) {
         //SANDBOX
         $pp_apiendpoint = "https://api-3t.sandbox.paypal.com/nvp";
         //$pp_nvpstr = $pp_nvpstr."&USER=selpro_1353406222_biz_api1.gmail.com&PWD=1353406266&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31A3EBHtTfV8lKwx45fvW2eMcJeim9&VERSION=60.0";	//API Signature: paypalproseller@createmethod.com
         //$pp_nvpstr = $pp_nvpstr."&USER=pro_sk_1359442731_biz_api1.createmethod.com&PWD=1359442797&SIGNATURE=AwiT0IXmzf7bDbash.EkFRUJAK5uAOJfRXjtrgH1-MykaZbUOcJ5BjA8&VERSION=60.0";	//API Signature: sunni@createmethod.com
         $pp_nvpstr = $pp_nvpstr . "&USER=sharedkey.test_api1.createmethod.com&PWD=1386645751&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31A5wmiz6FEGRIQ-f9Kr.e2KsqxoO-&VERSION=60.0";
         //API Signature: sharedkey.test@createmethod.com
         $domain = "http://createmethod.ca/sharedkey/";
     } else {
         //LIVE
         $pp_apiendpoint = "https://api-3t.paypal.com/nvp";
         $pp_nvpstr = $pp_nvpstr . "&USER=chris2thrall_api1.gmail.com&PWD=S7M4RXSP3NCBMX6Z&SIGNATURE=AXJTRBNIuY.F1LnvfgK2BtuvvH-dAjViO4DiGx.z.6lveIvnJekgClTv&VERSION=60.0";
         $domain = "http://www.sharedkey.com/";
     }
     try {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $pp_apiendpoint);
         curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($ch, CURLOPT_POST, TRUE);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $pp_nvpstr);
         curl_setopt($ch, CURLOPT_TIMEOUT, 320);
         $resp = curl_exec($ch);
         curl_close($ch);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     PayPalHelper::writeLog($pp_nvpstr);
     if (!$resp) {
         die("PayPal cURL error: " . curl_error($ch) . " (" . curl_errno($ch) . "). Please contact <a href='mailto:support@sharedkey.com?subject=PayPal cURL error: " . curl_error($ch) . " (" . curl_errno($ch) . ")'>support@sharedkey.com</a> for technical assistance.");
     }
     $resp_arr = explode("&", $resp);
     $parsedresp_arr = array();
     foreach ($resp_arr as $i => $value) {
         $temp_arr = explode("=", $value);
         if (sizeof($temp_arr) > 1) {
             $parsedresp_arr[$temp_arr[0]] = urldecode($temp_arr[1]);
         }
     }
     PayPalHelper::writeLog($resp);
     //        if ((0 == sizeof($parsedresp_arr)) || !array_key_exists('ACK', $parsedresp_arr)) {
     //            die("PayPal response error: Invalid HTTP Response for POST request to ".$pp_apiendpoint.". Please contact <a href='mailto:support@sharedkey.com?subject=PayPal response error: Invalid HTTP Response for POST request to ".$pp_apiendpoint."'>support@sharedkey.com</a> for technical assistance.");
     //        }
     if ("SUCCESS" == strtoupper($parsedresp_arr['ACK']) || "SUCCESSWITHWARNING" == strtoupper($parsedresp_arr['ACK'])) {
         $transaction = new Transaction();
         $transaction->userid = $userData['id'];
         // Yii::app()->user->getState('id');
         $transaction->username = $userData['firstname'] . ' ' . $userData['lastname'];
         //Yii::app()->user->getState('firstname').' '.Yii::app()->user->getState('lastname');
         $transaction->propertyid = $userData['property_id'];
         //Yii::app()->user->getState('propertyId');
         $transaction->pp_PROFILEID = $parsedresp_arr['PROFILEID'];
         $profileStatus = isset($parsedresp_arr['PROFILESTATUS']) ? $parsedresp_arr['PROFILESTATUS'] : 'CANCELED';
         $transaction->PROFILESTATUS = $profileStatus;
         $transaction->ACK = $parsedresp_arr['ACK'];
         $transaction->CORRELATIONID = $parsedresp_arr['CORRELATIONID'];
         $transaction->VERSION = $parsedresp_arr['VERSION'];
         $transaction->BUILD = $parsedresp_arr['BUILD'];
         $transaction->edt = date('Y-m-d H:i:s');
         if (!$transaction->save()) {
             if ($testflag) {
                 var_dump($userData['id']);
                 //Yii::app()->user->getState('id'));
             }
             echo "Error. Query failed due to: ";
             var_dump($transaction->getErrors());
             die;
         }
         $nowDate = new DateTime();
         $nowDate->setTimestamp(strtotime(PayPalHelper::testflag ? '+2 day' : '+1 year'));
         $countryModel = new OldLuCountries();
         $countryResults = $countryModel->findByAttributes(array('countrycode' => array_key_exists('PP_COUNTRYCODE', $userData) ? $userData['PP_COUNTRYCODE'] : 'US'));
         $property = Properties::model()->findByPk($userData['property_id']);
         $property->adminCountry = $countryResults->countryname;
         $property->renewalDate = $nowDate->format("Y-m-d H:i:s");
         $property->save();
         $date = $nowDate->format('l jS \\of F Y');
         //email customer
         if (!YII::app()->user->getState("addPropertyEmailed") == true) {
             $porpertyName = $property->property_name;
             $body = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.modules.site.views.emails.renew_success') . ".php", array('fullname' => $userData['firstname'] . ' ' . $userData['lastname'], 'propName' => $porpertyName, 'reneweDate' => $date), true);
             // if($profileStatus == 'ActiveProfile'){
             MailHelper::send($body, "SharedKey.com - Subscription Confirmed", array($userData['email']));
             // }
         }
         YII::app()->user->setState("addPropertyEmailed", null);
     }
     return $parsedresp_arr;
 }