예제 #1
0
 public function setUp()
 {
     ActiveRecordModel::getApplication()->clearCachedVars();
     ActiveRecordModel::beginTransaction();
     if (empty($this->autoincrements)) {
         foreach ($this->getUsedSchemas() as $table) {
             $res = $this->db->executeQuery("SHOW TABLE STATUS LIKE '{$table}'");
             $res->next();
             $this->autoincrements[$table] = (int) $res->getInt("Auto_increment");
         }
     }
     if ($this instanceof BackendControllerTestCase) {
         ClassLoader::import('application.model.user.SessionUser');
         ClassLoader::import('application.model.user.UserGroup');
         // set up user
         $group = UserGroup::getNewInstance('Unit tester');
         $group->save();
         $group->setAllRoles();
         $group->save();
         $user = User::getNewInstance('*****@*****.**', null, $group);
         $user->save();
         SessionUser::setUser($user);
     }
     if ($this instanceof ControllerTestCase) {
         $this->request = self::getApplication()->getRequest();
     }
 }
예제 #2
0
 /**
  *  Process actual login
  */
 public function doLogin()
 {
     $user = User::getInstanceByLogin($this->request->get('email'), $this->request->get('password'));
     if (!$user) {
         return new ActionRedirectResponse('backend.session', 'index', array('query' => array('failed' => 'true', 'email' => $this->request->get('email'))));
     }
     // login
     SessionUser::setUser($user);
     return new ActionRedirectResponse('backend.index', 'index');
 }
예제 #3
0
파일: update.php 프로젝트: saiber/livecart
 *
 *  @author Integry Systems
 */
// change to application root directory
chdir('..');
// initialize LiveCart
include_once 'application/Initialize.php';
ClassLoader::import('application.LiveCart');
session_start();
$livecart = new LiveCart();
// process update
ClassLoader::import('application.controller.backend.UpdateController');
$user = SessionUser::getUser();
$user->allowBackendAccess();
$user->setID(1);
SessionUser::setUser($user);
$controller = new UpdateController($livecart);
$response = $controller->update();
if ($response instanceof RawResponse) {
    echo $response->getContent() . "\n";
} elseif ($response instanceof ActionResponse) {
    foreach ($response->get('progress') as $key => $value) {
        echo $key . ': OK' . "\n";
    }
    if ($response->get('errors')) {
        echo "\n" . 'Errors:' . "\n\n";
        foreach ($response->get('errors') as $key => $value) {
            echo $key . ': ' . $value . "\n";
        }
        echo "\n" . 'Failed to complete update. If you\'re not able to resolve the problems and complete the update successfuly, please contact the LiveCart support team at http://support.livecart.com';
    } else {
예제 #4
0
 public function setAdmin()
 {
     if (!$this->buildAdminValidator()->isValid()) {
         return new ActionRedirectResponse('install', 'admin');
     }
     ClassLoader::import('application.model.user.UserGroup');
     ClassLoader::import('application.model.user.User');
     ClassLoader::import('application.model.user.SessionUser');
     ActiveRecordModel::beginTransaction();
     // create user group for administrators
     $group = UserGroup::getNewInstance('Administrators');
     $group->setAllRoles();
     $group->save();
     // create administrator account
     $user = User::getNewInstance($this->request->get('email'), null, $group);
     $user->loadRequestData($this->request);
     $user->setPassword($this->request->get('password'));
     $user->isEnabled->set(true);
     $user->save();
     ActiveRecordModel::commit();
     // log in
     SessionUser::setUser($user);
     // set store email
     $this->config->set('MAIN_EMAIL', $this->request->get('email'));
     $this->config->set('NOTIFICATION_EMAIL', $this->request->get('email'));
     $this->config->set('NEWSLETTER_EMAIL', $this->request->get('email'));
     $this->config->save();
     return new ActionRedirectResponse('install', 'config');
 }
예제 #5
0
 /**
  *	@return User
  */
 private function createUser($password = '', $prefix = '')
 {
     $user = User::getNewInstance($this->request->get('email'), $this->request->get('password'));
     $user->firstName->set($this->request->get($prefix . 'firstName'));
     $user->lastName->set($this->request->get($prefix . 'lastName'));
     $user->companyName->set($this->request->get($prefix . 'companyName'));
     $user->email->set($this->request->get('email'));
     $user->isEnabled->set(!$this->config->get('REG_EMAIL_CONFIRM'));
     // custom fields
     $user->loadRequestData($this->request, array());
     if ($password) {
         $this->session->set('password', $password);
         $user->setPassword($password);
     }
     $user->save();
     if (!$this->config->get('REG_EMAIL_CONFIRM')) {
         SessionUser::setUser($user);
         $this->sendWelcomeEmail($user);
     } else {
         $code = rand(1, 10000000) . rand(1, 10000000);
         $user->setPreference('confirmation', $code);
         $user->save();
         $email = new Email($this->application);
         $email->setUser($user);
         $email->set('code', $code);
         $email->setTemplate('user.confirm');
         $email->send();
     }
     return $user;
 }
예제 #6
0
 protected function registerAnonUser()
 {
     if ($this->user->isAnonymous()) {
         $this->order->loadAll();
         ActiveRecord::beginTransaction();
         $this->user->setPassword($this->session->get('password'));
         $this->user->resetModifiedStatus(true);
         $this->user->defaultBillingAddress->resetModifiedStatus();
         $this->user->defaultShippingAddress->resetModifiedStatus();
         if ($this->user->getSpecification()) {
             $this->user->setSpecification(clone $this->user->getSpecification());
         }
         $this->user->save();
         foreach (array('billingAddress' => 'defaultBillingAddress', 'shippingAddress' => 'defaultShippingAddress') as $order => $key) {
             $address = $this->user->{$key}->get();
             if ($address) {
                 $newAddress = clone $address;
                 $newAddress->userAddress->set(clone $newAddress->userAddress->get());
                 $newAddress->user->set($this->user);
                 $this->user->{$key}->set($newAddress);
                 $newAddress->save();
                 $this->order->{$order}->set($newAddress->userAddress->get());
             }
         }
         $this->order->resetArrayData();
         // shipping and billing addresses the same? save only the billing address
         if ($this->order->shippingAddress->get() && $this->order->billingAddress->get()->toString() == $this->order->shippingAddress->get()->toString()) {
             $this->user->defaultShippingAddress->get()->delete();
             $this->user->defaultShippingAddress->setNull();
         }
         $this->user->save();
         $this->order->user->set($this->user);
         $this->order->user->setAsModified();
         SessionUser::setUser($this->user);
         $this->session->set('checkoutUser', null);
         ActiveRecord::commit();
         $this->getUserController()->sendWelcomeEmail($this->user);
     }
 }
예제 #7
0
 public function expressReturn()
 {
     $class = $this->request->get('id');
     $this->order->setPaymentMethod($class);
     $handler = $this->application->getExpressPaymentHandler($class, $this->getTransaction());
     $handler->setOrder($this->order);
     $details = $handler->getTransactionDetails($this->request->toArray());
     $address = UserAddress::getNewInstanceByTransaction($details);
     $address->save();
     $paymentData = array_diff_key($this->request->toArray(), array_flip(array('controller', 'action', 'id', 'route', 'PHPSESSID')));
     // @todo - determine if the order is new or completed earlier, but unpaid
     // for now only new orders can be paid with express checkout methods
     $order = $this->getPaymentOrder();
     $express = ExpressCheckout::getNewInstance($order, $handler);
     $express->address->set($address);
     $express->paymentData->set(serialize($paymentData));
     $express->save();
     // auto-login user if anonymous
     if ($this->user->isAnonymous()) {
         // create new user account if it doesn't exist
         if (!($user = User::getInstanceByEmail($details->email->get()))) {
             $user = User::getNewInstance($details->email->get());
             $user->firstName->set($details->firstName->get());
             $user->lastName->set($details->lastName->get());
             $user->companyName->set($details->companyName->get());
             $user->isEnabled->set(true);
             $user->save();
         }
         SessionUser::setUser($user);
         $order->setUser($user);
     }
     $order->billingAddress->set($address);
     if ($order->isShippingRequired()) {
         $order->shippingAddress->set($address);
     }
     $order->save();
     return new ActionRedirectResponse('checkout', 'shipping');
 }