getUser()->getUser(); $user = PhotoalbumUser::load($user->getId(),false); $this->getUser()->setUser($user); $this->userBalance = $this->getUser()->getUser()->balance; } public function executeDummy(sfWebRequest $request) { $dummy = new UserDummy(); $dummy->setUser($this->getUser()->getUser()); $dummyMake = $request->getParameter('dummyMake'); switch($dummyMake) { case 'projects': $dummy->createProject(3); break; case 'money': $dummy->addMoney(); break; } $redirectUrl = url_for('account_homepage', array('reload' => 1),true); $this->redirect($redirectUrl); } /** * Write reset confirm key and key expire date to data base * Show form for request password recovery * Send mail with password recovery link * * @param sfWebRequest $request * @return void */ public function executeForgotPassword(sfWebRequest $request) { $this->getResponse()->setTitle(__('PAGE_META_TITLE_FORGOT_PASSWORD')); $this->form = new ForgotPasswordForm(); if ($request->isMethod(sfRequest::POST)) { $formName = $this->form->getName(); $this->form->bind($request->getParameter($formName)); if ($this->form->isValid()) { $data = $this->form->getValues(); $data['email'] = strtolower($data['email']); try { $timeToExpire = sfConfig::get('app_time_to_reset_password'); $confirmKey = PhotoalbumUser::generateConfirmKey($data['email']); PhotoalbumLogin::updateLogin($data['email'], array('resetConfirmKey' => $confirmKey, 'resetKeyExpires' => time() + $timeToExpire )); $emailOptions = array( 'resetLink' => external_url('/account/resetpassword/' . $confirmKey) ); $email = new SystemEmailsPasswordRecovery($emailOptions); $email->send($data['email']); FlashMessages::getInstance()->addInfoMessage('FlashMessageResetEmailSent'); $this->redirect('@user_login'); } catch (RestServiceNotFoundException $nfEx) { FlashMessages::getInstance()->addErrorMessage('FlashMessageInvalidEmail'); } } } } /** * Check if confirm key is valid show form for password change * * @throws sfError404Exception * @param sfWebRequest $request * @return void */ public function executeResetPassword(sfWebRequest $request) { $confirmKey = $request->getParameter('confirmKey', false); try { $login = PhotoalbumLogin::getByResetConfirmKey($confirmKey); if ($confirmKey && ($login instanceof PhotoalbumLogin)) { $this->confirmKey = $confirmKey; $this->form = new ResetPasswordForm(); if ($request->isMethod(sfRequest::POST)) { $formName = $this->form->getName(); $this->form->bind($request->getParameter($formName)); if ($this->form->isValid()) { $data = $this->form->getValues(); $logInObject = PhotoalbumLogin::updateLogin($login->emailHash, array( 'password' => md5($data['password']), 'resetConfirmKey' => '', 'resetKeyExpires' => 0 )); FlashMessages::getInstance()->addInfoMessage('FlashMessagePasswordSuccessfullyChanged'); //$this->redirect('@user_login'); $user = PhotoalbumUser::load($logInObject->getUserId()); $this->getUser()->signIn($user); $this->redirect('@homepage_user'); } } } else { throw new sfError404Exception(); } } catch (RestServiceNotFoundException $nfEx) { throw new sfError404Exception(); } } /** * Change user password * * @param sfWebRequest $request * @return void */ public function executeChangePassword(sfWebRequest $request) { $this->form = new ChangePasswordForm(); if ($request->isMethod(sfRequest::POST)) { $formName = $this->form->getName(); $this->form->bind($request->getParameter($formName)); if ($this->form->isValid()) { $data = $this->form->getValues(); $userObject = $this->getUser()->getUser(); $loginObject = PhotoalbumLogin::logIn($userObject->email); $password = $loginObject->password; if ($password == md5($data['password_current'])) { PhotoalbumLogin::updateLogin($userObject->email, array('password' => md5($data['password_new']))); FlashMessages::getInstance()->addInfoMessage('FlashMessagePasswordSuccessfullyChanged'); $this->redirect('@user_homepage'); } else { FlashMessages::getInstance()->addErrorMessage('FlashMessageWrongCurrentPassword'); } } } } /** * Show list of user transactions * @param sfWebRequest $request * @return void */ public function executeTransactions(sfWebRequest $request) { $this->form = new TransactionsFilterForm(); $pagerParamName = 'page'; $currentPage = $this->getRequestParameter($pagerParamName,1); $limit = sfConfig::get('app_row_limit',30); $offset = ($currentPage-1) * $limit; if ($request->isMethod(sfRequest::GET)) { $this->form->bind($request->getParameter('filter')); if ($this->form->isValid()) { $data = $this->form->getValues(); $dateFrom = strtotime($data['dateFrom']); $dateTo = strtotime($data['dateTo']); if(is_null($data['dateFrom']) && is_null($data['dateTo'])) { $monthFirstDay = PhotoalbumDate::getMonthFirstDay(); $monthLastDay = PhotoalbumDate::getMonthLastDay(); $dateFrom = strtotime($monthFirstDay); $dateTo = strtotime($monthLastDay); $this->form->bind(array('dateFrom' => $monthFirstDay, 'dateTo' => $monthLastDay)); } $filterParameters = array('filterBy' => $data['filterBy'], 'amountFrom' => $data['amountFrom'], 'amountTo' => $data['amountTo'], 'dateFrom' => $dateFrom, 'dateTo' => $dateTo); $transactions = PhotoalbumTransaction::listUserTransactionsFilter($this->getUser()->getId(), $offset, $limit, $filterParameters); if(PhotoalbumTransaction::$_count > 0) { $this->transactions = $transactions; } } } $count = PhotoalbumTransaction::$_count; $this->currentUrl = $this->getRequest()->getUri(); $this->pager = new PhotoalbumPager('null', $count, $limit); $this->pager->setPagerParamName($pagerParamName); $this->pager->setResultArray($this->transactions); $this->pager->setPage($currentPage); $this->pager->init(); return sfView::SUCCESS; } /** * If is AJAX request setup PayPal payment for requested package id * and create new payment with status "created" in database. Return * redirect url for PayPal in JSON format * * If it's not AJAX request load list of available packages * * @param sfWebRequest $request * @return void */ public function executePaymentsFill(sfWebRequest $request) { if ($request->isXmlHttpRequest()) { $packageId = $request->getParameter('packageId', false); if ($packageId) { try { $package = PhotoalbumPackage::load($packageId); $payment = new PhotoalbumPayment(array( 'userId' => $this->getUser()->getId(), 'packageId' => $packageId, 'type' => PhotoalbumPayment::TYPE_COMMON, 'provider' => PhotoalbumPayment::PROVIDER_PAYPAL, 'method' => PhotoalbumPayment::METHOD_PAYPAL_CHECKOUT, 'amount' => $package->price, 'currency' => $package->currency, 'status' => PhotoalbumPayment::STATUS_CREATED, ) ); $paymentObject = $payment->save(); $payPal = new PayPalCheckOut($package, $paymentObject); $redirectUrl = $payPal->setup(); if ($redirectUrl) { $token = $payPal->getToken(); PhotoalbumPayment::update($payment->getId(), array('details' => array('ppToken' => $token))); $this->redirectUrl = $redirectUrl; } else { $this->redirect404(); } } catch (RestServiceNotFoundException $nfEx) { $this->redirect404(); } } else { $this->redirect404(); } } $this->packages = PhotoalbumPackage::loadByStatus(1); } /** * Confirmation for PayPal * Check payment id, token, payer id if it's right send * request to PayPal to confirm this payment if PayPal return * with success set payment status to "confirmed" and fill * payments details * @param sfWebRequest $request * @return void */ public function executePaymentsConfirm(sfWebRequest $request) { $paymentId = $request->getParameter('paymentId', false); $token = $request->getParameter('token', false); $payerId = $request->getParameter('PayerID', false); if ($paymentId && $token && $payerId) { try { $payment = PhotoalbumPayment::load($paymentId); if ($payment->userId == $this->getUser()->getId()) { $paymentDetails = $payment->details; $paymentToken = $paymentDetails['ppToken']; if ($paymentToken == $token) { $package = PhotoalbumPackage::load($payment->packageId); $payPal = new PayPalCheckOut($package, $payment); $payPalDetails = $payPal->getCheckOutDetails($token, $payerId); $confirmCheckOut = $payPal->doCheckOut($payPalDetails['TOKEN'], $payPalDetails['PAYERID']); if ($confirmCheckOut) { PhotoalbumPayment::update($paymentId, array('status' => PhotoalbumPayment::STATUS_CONFIRMED, 'details' => array( 'ppPayerId' => urldecode($payPalDetails['PAYERID']), 'ppEmail' => urldecode($payPalDetails['EMAIL']), 'ppFirstName' => urldecode($payPalDetails['FIRSTNAME']), 'ppLastName' => urldecode($payPalDetails['LASTNAME']), 'ppCountryCode' => urldecode($payPalDetails['COUNTRYCODE']) ) )); $this->forwardUrl = url_for('@account_transactions', true); FlashMessages::getInstance()->addInfoMessage('FlashMessagePaymentSuccess'); } else { FlashMessages::getInstance()->addErrorMessage('FlashMessageFailedToConfirmPayment'); } } else { FlashMessages::getInstance()->addErrorMessage('FlashMessageFailedToConfirmPayment'); } } else { FlashMessages::getInstance()->addErrorMessage('FlashMessageFailedToConfirmPayment'); } } catch (RestServiceNotFoundException $nfEx) { FlashMessages::getInstance()->addErrorMessage('FlashMessageFailedToConfirmPayment'); } } } /** * Cancel payment * @param sfWebRequest $request * @return void */ public function executePaymentsCancel(sfWebRequest $request) { $paymentId = $request->getParameter('paymentId', false); $this->forwardUrl = url_for('@account_transactions', true); if ($paymentId) { try { $payment = PhotoalbumPayment::load($paymentId); if ($payment->userId == $this->getUser()->getId()) { PhotoalbumPayment::update($paymentId, array('status' => PhotoalbumPayment::STATUS_CANCELLED)); FlashMessages::getInstance()->addInfoMessage('FlashMessagePaymentCancelled'); } } catch (RestServiceNotFoundException $nfEx) { FlashMessages::getInstance()->addErrorMessage('FlashMessagePaymentNotFound'); } } } }

Oops!

Error 404

Sorry, but the page you are looking for has not been found.
Try checking the URL for errors, then hit the refresh button on your browser.

Go to the home page

© 2017 InterMotion Technologies Inc, Inc. All rights reserved.