public function executeIndex(HTTPRequest $request)
 {
     if (!$this->app->user()->isAuthenticated()) {
         $this->app->httpResponse()->redirect404();
         exit;
     }
     if (Config::get('platform-fee-ratio') == 0) {
         $this->app->httpResponse()->redirect404();
         exit;
     }
     $reservationId = htmlspecialchars($request->getData('reservationId'));
     $reservation = $this->_announcementReservationManager->get($reservationId);
     if (is_null($reservation)) {
         $this->app->httpResponse()->redirect404();
         exit;
     }
     $userId = $this->app->user()->getAttribute('id');
     if ($userId != $reservation->getUserSubscriberId() || $reservation->getStateId() != PaiementStates::WAITING_PAIEMENT) {
         $this->app->httpResponse()->redirect404();
         exit;
     }
     $this->page->smarty()->assign('announcementReservationManager', $this->_announcementReservationManager);
     $this->page->smarty()->assign('usersManager', $this->_usersManager);
     $this->page->smarty()->assign('reservation', $reservation);
     $this->page->smarty()->assign('amount', round($reservation->getPrice() * Tipkin\Config::get('platform-fee-ratio'), 2));
 }
/**
 * Project specific Smarty plugins
 */
function smarty_function_config($params, $template)
{
    if ($params['name']) {
        trigger_error('Missing required name for smarty config function.');
    }
    return Tipkin\Config::get($params['name']);
}
 public function executeIndex(HTTPRequest $request)
 {
     $this->page->smarty()->assign('reservationsManager', $this->_reservationsManager);
     $this->page->smarty()->assign('announcementsManager', $this->_announcementsManager);
     $this->page->smarty()->assign('usersManager', $this->_usersManager);
     $this->page->smarty()->assign('platform_fee_ratio', Tipkin\Config::get('platform-fee-ratio'));
 }
 public function executeFaq(HTTPRequest $request)
 {
     if (Tipkin\Config::get('platform-fee-ratio') > 0) {
         $this->page->smarty()->assign('template', 'faq_with_platform_fee');
     } else {
         $this->page->smarty()->assign('template', 'faq_without_platform_fee');
     }
 }
 /**
  * (non-PHPdoc)
  * @see UsersManager::authenticate()
  */
 public function authenticate($login, $password)
 {
     $crypt_password = Users::cryptPassword($password, Tipkin\Config::get('secret-key'));
     $q = $this->dao->prepare('SELECT * FROM ' . $this->table() . ' WHERE (LOWER(MAIL) = :login OR LOWER(USERNAME) = :login) AND PASSWORD = :password');
     $q->bindValue(':login', $login);
     $q->bindValue(':password', $crypt_password);
     $q->execute();
     $user = $q->fetch(PDO::FETCH_ASSOC);
     return is_array($user) ? new Users($user) : null;
 }
 public function run()
 {
     if (Tipkin\Config::get('maintenance-mode') == 'on') {
         $this->httpResponse->redirect('/maintenance.html');
         exit;
     }
     $router = new Router($this);
     $controller = $router->getController();
     if (!is_null($controller)) {
         $controller->execute();
         $this->httpResponse->setPage($controller->page());
     }
 }
 public function executeReservationLanding(HTTPRequest $request)
 {
     if (!$request->postExists('user-subscriber-id')) {
         $this->app->httpResponse()->redirect404();
         exit;
     }
     $reservation = new AnnouncementReservation();
     $this->parsePostReservation($request, $reservation);
     if ($this->_announcementReservationManager->isReservationExists($reservation)) {
         $this->app->httpResponse()->redirect('/activities/reservation-exists');
         exit;
     }
     $reservation->setStateId(PaiementStates::WAITING_PAIEMENT);
     $reservation->setKeyCheck(mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand());
     $reservation->setTransactionRef($reservation->id());
     $this->_announcementReservationManager->save($reservation);
     $platformFee = $reservation->getPrice() * Tipkin\Config::get('platform-fee-ratio');
     if ($platformFee == 0 || $request->postData('currency-id') != 'default') {
         $reservation->setStateId(PaiementStates::WAITING_VALIDATION);
         $reservation->setTransactionRef('FREE');
         $this->_announcementReservationManager->save($reservation);
         $messageMail = new Mail();
         $messageMail->sendReservationOwnerValidation($this->_usersManager->get($reservation->getUserOwnerId()), $this->_usersManager->get($reservation->getUserSubscriberId()), $this->_announcementManager->get($reservation->getAnnouncementId()), $reservation);
         $messageMail->sendReservationSubscriberRecap($this->_usersManager->get($reservation->getUserOwnerId()), $this->_usersManager->get($reservation->getUserSubscriberId()), $this->_announcementManager->get($reservation->getAnnouncementId()));
         $this->app->httpResponse()->redirect('/activities/reservations');
         exit;
     } else {
         $this->app->httpResponse()->redirect('/paiement/' . $reservation->id());
         exit;
     }
 }
 private function parseForm(HTTPRequest $request)
 {
     $username = htmlspecialchars($request->postData('username'));
     $mail = htmlspecialchars($request->postData('mail'));
     $mailConfirmation = htmlspecialchars($request->postData('mail-confirmation'));
     if ($request->postExists('generate-password')) {
         $password = $passwordConfirmation = Users::CreateNewPassword();
     } else {
         $password = htmlspecialchars($request->postData('password'));
         $passwordConfirmation = htmlspecialchars($request->postData('password-confirmation'));
     }
     $role = htmlspecialchars($request->postData('role'));
     if ($mail == $mailConfirmation && $password == $passwordConfirmation && strlen($username) >= 6 && strlen($password) >= 6) {
         $user = new Users();
         $user->setUsername($username);
         $user->setMail($mail);
         $user->setPassword($password, Tipkin\Config::get('secret-key'));
         $user->setRoleId($role);
         if (!$this->_userManager->isUsernameOrMailExist($username, $mail)) {
             $this->_userManager->save($user);
             $messageMail = new Mail();
             $messageMail->sendRegistrationInfo($user, $password);
             $this->app->user()->setFlash('new-user-added');
             $this->app->httpResponse()->redirect('/admin/users');
             exit;
         } else {
             $this->app->user()->setFlash('username-or-mail-exist');
             $this->app->httpResponse()->redirect('/admin/users');
             exit;
         }
     } else {
         $this->app->user()->setFlash('form-invalid');
         $this->app->httpResponse()->redirect('/admin/users');
         exit;
     }
 }
 public function executeDelete(HTTPRequest $request)
 {
     if ($request->postExists('confirm')) {
         $messageMail = new Mail();
         $messageMail->sendDisableAccount($this->_user, Tipkin\Config::get('admin-mail'));
         $this->app->user()->setFlash('disable-account');
         $this->app->httpResponse()->redirect('/profile-pro');
     }
 }
Beispiel #10
0
    public function sendAdminReservationSubscriberCanceled(Users $userOwner, Users $userSubscriber, Announcement $announce, AnnouncementReservation $reservation)
    {
        $platform_fee_ratio = Tipkin\Config::get('platform-fee-ratio');
        $platform_fee_extra = $platform_fee_ratio > 0 ? 'et l\'acompte ne sera pas débité' : '';
        $this->to = $this->adminMail;
        $this->subject = 'Annulation de réservation';
        $this->content = '
								Bonjour,
								<br />
								Une demande de Tip de <b>' . $announce->getTitle() . '</b> n’a pas été validée.<br />
								Elle est donc annulée' . $platform_fee_extra . '.
								<br /><br />
								Référence de transation : <b>' . $reservation->getTransactionRef() . '</b>
								<br /><br />
								A très bientôt sur TIPKIN !
								<br /><br />
								Je possède. Tu empruntes. Nous partageons !
								<br /><br />
								Administration TIPKIN.
        						';
        $this->send();
    }