Пример #1
0
 /**
  * Default action is product display. This action requires the product id to be passed.
  * If we do not receive this id, redirect back to the home page since something
  * went wrong.
  */
 public function actionView()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     if (empty($id)) {
         _xls_404();
     }
     //Load a product and display the information
     $model = $this->objProduct = Product::model()->findByPk($id);
     if (!$model || !$model->IsDisplayable) {
         _xls_404();
     }
     //If our request_url (based on description) has changed, redirect properly
     if ($model->request_url != Yii::app()->getRequest()->getQuery('name')) {
         _xls_301($model->Link);
     }
     //Set breadcrumbs
     $this->breadcrumbs = $model->Breadcrumbs;
     $this->pageImageUrl = $model->SmallImageAbsolute;
     $objWishlistAddForm = new WishlistAddForm();
     $objWishlistAddForm->id = $this->objProduct->id;
     $objWishlistAddForm->qty = 1;
     $objWishlistAddForm->lists = $objWishlistAddForm->getLists();
     $objWishlistAddForm->gift_code = Wishlist::LoadFirstCode();
     $this->setPageTitle($model->PageTitle);
     $this->pageDescription = $model->PageDescription;
     $this->canonicalUrl = $model->canonicalUrl;
     $this->returnUrl = $model->absoluteLink;
     $model->intQty = 1;
     //Raise any events first
     $objEvent = new CEventProduct(get_class($this), 'onActionProductView', $model);
     _xls_raise_events('CEventProduct', $objEvent);
     $this->widget('ext.wscartanimate.wscartanimate');
     $this->widget('ext.wsproduct.wsproduct');
     $this->render('index', array('model' => $model, 'WishlistAddForm' => $objWishlistAddForm));
 }
Пример #2
0
 /**
  * Show an SRO. Does not require the customer to be logged in to view
  */
 public function actionView()
 {
     $this->layout = '//layouts/column2';
     $strLink = Yii::app()->getRequest()->getQuery('code');
     if (empty($strLink)) {
         Yii::app()->controller->redirect(Yii::app()->createUrl('site/index'));
     }
     //Use our class variable which is accessible from the view
     $model = Sro::model()->findByAttributes(array('linkid' => $strLink));
     if (!$model instanceof Sro) {
         _xls_404();
     }
     $this->render('sro', array('model' => $model));
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = CustomPage::LoadByRequestUrl(Yii::app()->getRequest()->getQuery('id'));
     if (!$model instanceof CustomPage) {
         _xls_404();
     }
     $this->pageTitle = $model->PageTitle;
     $this->pageDescription = $model->meta_description;
     $this->pageImageUrl = '';
     $this->breadcrumbs = array($model->title => $model->RequestUrl);
     $this->canonicalUrl = $model->canonicalUrl;
     $this->layout = "//layouts/column" . $model->column_template;
     if (!empty($model->product_tag) && $model->product_display == 2) {
         $_GET['tag'] = $model->product_tag;
         $_GET['cpc'] = $model->id;
         $this->forward("search/results");
     } else {
         $this->render('index', array('model' => $model, 'objCustomPage' => $model));
     }
 }
Пример #4
0
 /**
  * Default action.
  *
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  *
  * @return void
  */
 public function actionIndex()
 {
     $homePage = _xls_get_conf('HOME_PAGE', '*products');
     switch ($homePage) {
         case "*index":
             if (Yii::app()->params['LIGHTSPEED_MT'] == '1') {
                 if (Yii::app()->theme->info->showCustomIndexOption) {
                     $this->render("/site/index");
                 } else {
                     $this->forward("search/browse");
                 }
             } else {
                 $this->render("/site/index");
             }
             break;
         case "*products":
             $this->forward("search/browse");
             break;
         default:
             //Custom Page
             $objCustomPage = CustomPage::LoadByKey($homePage);
             $productsGrid = null;
             $dataProvider = null;
             if (!$objCustomPage instanceof CustomPage) {
                 _xls_404();
             }
             $this->pageTitle = $objCustomPage->PageTitle;
             $this->pageDescription = $objCustomPage->meta_description;
             $this->pageImageUrl = '';
             $this->breadcrumbs = array($objCustomPage->title => $objCustomPage->RequestUrl);
             if (CPropertyValue::ensureInteger($objCustomPage->product_display) === 2) {
                 $productsGrid = new ProductGrid($objCustomPage->getProductGridCriteria());
             } else {
                 $dataProvider = $objCustomPage->taggedProducts();
             }
             $this->canonicalUrl = $objCustomPage->canonicalUrl;
             $this->render('/custompage/index', array('model' => $objCustomPage, 'dataProvider' => $dataProvider, 'productsGrid' => $productsGrid));
             break;
     }
 }
 /**
  * Module editing (e.g. shipping, payment, theme module).
  *
  * @return void
  * @throws CHttpException Error if invalid module passed.
  */
 public function actionModule()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     if (Yii::app()->controller->id == 'theme' && Yii::app()->controller->action->id == 'module') {
         $id = 'wstheme';
     }
     $objComponent = Yii::app()->getComponent($id);
     if (!$objComponent || $objComponent->isDisplayable() === false) {
         _xls_404();
     }
     $model = $objComponent->getAdminModel();
     if (!is_null($model)) {
         // Get form elements (Admin panel configuration) and add our layout
         // formatting so the form looks nice within Admin Panel.
         $this->editSectionInstructions = $this->getInstructions(get_class($this)) . '<p>' . $this->editSectionInstructions;
         $adminModelName = Yii::app()->getComponent($id)->getAdminModelName();
         $objModule = $id == 'wstheme' ? Modules::LoadByName(Yii::app()->theme->name) : Modules::LoadByName($id);
         if ($id == 'wstheme') {
             $objModule->active = 1;
             $strOldChild = Yii::app()->theme->config->CHILD_THEME;
         }
         if (isset($_POST[$adminModelName])) {
             $config = $objModule->GetConfigValues();
             $newConfig = array_replace($config, $_POST[$adminModelName]);
             $model->attributes = $newConfig;
             $this->registerOnOff($objModule->id, 'Modules_active', _xls_number_only($_POST['Modules']['active']));
             if ($model->validate()) {
                 $objModule->active = _xls_number_only($_POST['Modules']['active']);
                 $objModule->SaveConfigValues($newConfig);
                 if (!$objModule->save()) {
                     Yii::app()->user->setFlash('error', print_r($objModule->getErrors(), true));
                 } else {
                     Yii::app()->user->setFlash('success', Yii::t('admin', 'Configuration updated on {time}.', array('{time}' => date('d F, Y  h:i:sa'))));
                     // Force a reload of config.
                     Yii::app()->getComponent($id)->init();
                     // If we happen to be updating a module that includes a
                     // promo code, we need to throw that to our restrictions.
                     if (isset($model->promocode)) {
                         Yii::app()->getComponent($id)->syncPromoCode();
                     }
                     $this->updateMenuAfterEdit($id);
                     if ($id == 'wstheme') {
                         $strNewChild = $newConfig['CHILD_THEME'];
                         if ($strOldChild !== $strNewChild && $strNewChild !== 'custom') {
                             Yii::app()->theme->config->activecss = $this->updateActiveCss($strNewChild, $strOldChild);
                         }
                     }
                 }
             } else {
                 if (YII_DEBUG) {
                     Yii::app()->user->setFlash('error', print_r($model->getErrors(), true));
                 } else {
                     Yii::app()->user->setFlash('error', Yii::t('global', 'Error saving, check form fields for specific errors'));
                 }
             }
         } else {
             //Load current attributes
             $this->registerOnOff($objModule->id, 'Modules_active', $objModule->active);
             $model->attributes = $objModule->getConfigValues();
         }
         //At this point, our $model has our values, so they are available for our form definition
         $formDefinition = $model->getAdminForm();
         foreach ($formDefinition['elements'] as $key => $value) {
             $formDefinition['elements'][$key]['layout'] = '<div class="span5 optionlabel">{label}</div><div class="span5 optionvalue">{input}</div>{error}<div class="span2 maxhint">{hint}</div>';
         }
         $this->registerAsset("js/shippingrestrictions.js");
         $this->registerAsset("js/destinationrates.js");
         $this->registerAsset("js/tiers.js");
         $this->registerAsset("js/offerservices.js");
         if ($id === 'cayan') {
             $this->registerAsset("js/cayan.js");
             $this->registerAsset("css/cayan.css");
             Yii::import('ext.SMiniColors.SActiveColorPicker');
             SActiveColorPicker::registerScriptFiles();
         }
         $this->render('admin.views.default.moduleedit', array('objModule' => $objModule, 'model' => $model, 'form' => new CForm($formDefinition, $model)));
     } else {
         //If null it means the AdminForm model file is missing.
         $this->render('admin.views.default.noconfig', array('id' => $id));
     }
 }
Пример #6
0
 public function actionIndex()
 {
     if (_xls_get_conf('INSTALLED', 0) == 1) {
         _xls_404();
     }
     $this->layout = "license";
     $this->editSectionInstructions = "";
     $this->license = $this->renderPartial("license", null, true, false);
     $model = new InstallForm();
     $getpage = "getPage" . $model->page;
     $model->scenario = "page1";
     $model->setScenario($this->cloudMtScenario($model->getScenario()));
     $formDefinition = $model->{$getpage}();
     if (isset($_POST['InstallForm'])) {
         $model->scenario = "page" . $_POST['InstallForm']['page'];
         if (isset($_POST['buttonSkip']) && $_POST['InstallForm']['page'] == 4) {
             $model->scenario = "page-skip" . $_POST['InstallForm']['page'];
         }
         $model->setScenario($this->cloudMtScenario($model->getScenario()));
         $model->attributes = $_POST['InstallForm'];
         if ($model->validate()) {
             switch ($model->page) {
                 case 1:
                     $model->page = 2;
                     break;
                 case 2:
                     $model->savePage(2);
                     $model->page = 3;
                     break;
                 case 3:
                     $model->savePage(3);
                     $model->page = 4;
                     break;
                 case 4:
                     $model->savePage(4);
                     _xls_set_conf('INSTALLED', 1);
                     $this->redirect($this->createUrl('license/end'));
                     break;
             }
             if (_xls_get_conf('LIGHTSPEED_CLOUD', 0) > 0 && $model->page == 2) {
                 $model->scenario = "page" . $model->page . "-cld";
             } else {
                 if (_xls_get_conf('LIGHTSPEED_CLOUD', 0) == 0 && _xls_get_conf('LIGHTSPEED_MT', 0) > 0 && $model->page == 2) {
                     $model->scenario = "page" . $model->page . "-mt";
                 } else {
                     $model->scenario = "page" . $model->page;
                 }
             }
             $model->attributes = $model->readFromSession($model->page);
         } else {
             Yii::log("Install Wizard " . $model->scenario . " error " . print_r($model->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
         //Possibly after submit, refetch these items
         $getpage = "getPage" . $model->page;
         $formDefinition = $model->{$getpage}();
     }
     foreach ($formDefinition['elements'] as $key => $value) {
         if ($key != "iagree") {
             $formDefinition['elements'][$key]['layout'] = '<div class="span3 optionlabel">{label}</div><div class="span4 optionvalue">{input}</div>{error}<div class="span2 maxhint">{hint}</div>';
         }
     }
     $this->render('index', array('model' => $model, 'form' => new CForm($formDefinition, $model)));
 }
 /**
  * Receiving function for flipping sides on common SSL. Depending on inbound information
  * we need to assign the CartID to the session so we're using it on both sides
  */
 public function actionSharedSSLReceive()
 {
     if (!Yii::app()->params['LIGHTSPEED_HOSTING_COMMON_SSL']) {
         _xls_404();
     }
     //Parse the information we were sent (encrypted) on the command line
     $strLink = Yii::app()->getRequest()->getQuery('link');
     if (empty($strLink)) {
         _xls_404();
     }
     $link = _xls_decrypt($strLink);
     $arrItems = explode(',', $link);
     $arrParams = array();
     //$strIdentity = $userID.",".$cartID.",".$controller.",".$action;
     $userID = $arrItems[0];
     $cartID = $arrItems[1];
     $controller = $arrItems[2];
     $action = $arrItems[3];
     if (isset($arrItems[6])) {
         $arrParams['orderId'] = $arrItems[5];
         $arrParams['errorNote'] = $arrItems[6];
     } elseif (isset($arrItems[4])) {
         $arrParams['linkid'] = $arrItems[4];
     }
     //If our session was previously logged in on this side of SSL, we overwrite, otherwise log out
     if ($userID > 0) {
         //we were logged in on the other URL so re-login here
         $objCustomer = Customer::model()->findByPk($userID);
         $identity = new UserIdentity($objCustomer->email, _xls_decrypt($objCustomer->password));
         $identity->authenticate();
         if ($identity->errorCode == UserIdentity::ERROR_NONE) {
             Yii::app()->user->login($identity, 3600 * 24 * 30);
         } else {
             Yii::log('Error attempting to switch to shared SSL and logging in, error ' . $identity->errorCode, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
     } elseif (!Yii::app()->user->isGuest) {
         Yii::app()->user->logout();
     }
     Yii::app()->user->setState('sharedssl', '1');
     if ($cartID > 0) {
         Yii::app()->user->setState('cartid', $cartID);
         Yii::app()->shoppingcart->setModelById($cartID);
         //Explicitly make this cart current under this URL
     }
     //Create our URL
     $url = $this->createUrl($controller . "/" . $action, $arrParams);
     //To avoid double-intercepting, we have to manually build URL instead of using createURL in this case
     if ($controller == "cart" && $action == "checkout") {
         $url = "https://" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . "/cart/checkout";
         if ($userID == 0) {
             $url .= "?c=" . urlencode(_xls_encrypt($cartID . "," . date("His")));
         }
     }
     if ($controller == 'checkout' && $action == 'index') {
         $url = 'https://' . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . '/checkout/' . $action;
         if ($userID == 0) {
             $url .= "?c=" . urlencode(_xls_encrypt($cartID . "," . date("His")));
         }
     }
     // We are setting this cookie here
     // TODO: Move this code to the extension itself so that we don't have to perform tasks that are extension-specific.
     Yii::app()->request->cookies['access_warning'] = new CHttpCookie('access_warning', 'false');
     //Finally, onward to the page
     $this->redirect($url);
 }
 /**
  * Handles the resetpassword scenario - that is, when a customer has forgotten
  * their password and has requested a reset.
  */
 public function actionResetpassword()
 {
     $id = '';
     $token = '';
     if (!isset($_GET['id']) || !isset($_GET['token'])) {
         _xls_404('Please make sure you have all the required information from password reset email.');
     } else {
         $id = $_GET['id'];
         $token = $_GET['token'];
     }
     if (!Yii::app()->user->isGuest) {
         $link = CHtml::link(Yii::t('customer', 'logout'), $this->createUrl('site/logout'));
         Yii::app()->user->setFlash('info', Yii::t('customer', 'Please {logout} to reset a password.', array('{logout}' => $link)));
         $this->redirect($this->createUrl('/myaccount'));
     }
     $model = Customer::model()->findByPk($id);
     if (!$model) {
         Yii::app()->user->setFlash('error', Yii::t('customer', 'Could not find the specified customer.  Please request another password reset.'));
         $this->redirect($this->createUrl('site/login'));
     }
     $model->scenario = Customer::SCENARIO_RESETPASSWORD;
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         $model->token = $token;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('customer', 'Password updated, please login!'));
             $this->redirect($this->createUrl('site/login'));
         }
         if ($model->hasErrors('token')) {
             Yii::app()->user->setFlash('error', Yii::t('customer', 'Could not authorize password reset. Please request a new reset e-mail by clicking "Forgot Password" link.'));
             $this->redirect($this->createUrl('site/login'));
         }
         Yii::app()->user->setFlash('error', Yii::t('customer', 'Could not reset password, please try again.'));
     }
     $this->breadcrumbs = array(Yii::t('global', 'My Account') => $this->createUrl('/myaccount'), Yii::t('global', 'Edit Account') => $this->createUrl('myaccount/resetpassword'));
     // TODO - this is to accommodate deprecated themes with password fields
     $model->password = null;
     $this->render('password', array('model' => $model));
 }
 /**
  * The "thank you" page, which also serves as the receipt page.
  *
  * This page contains a form which allows a guest customer to turn their
  * account into a normal one.
  *
  * @return void
  * @throws CHttpException
  */
 public function actionThankyou()
 {
     $strLink = Yii::app()->getRequest()->getQuery('linkid');
     // Redirect to homepage if there is no link id.
     if (empty($strLink)) {
         $this->redirect($this->createAbsoluteUrl("/", array(), 'http'));
     }
     // redirect to old receipt in the rare case Web Store is back on an old theme
     if (Yii::app()->theme->info->advancedCheckout === false) {
         $this->redirect($this->createAbsoluteUrl('/cart/receipt', array('getuid' => $strLink)));
     }
     $objCart = Cart::model()->findByAttributes(array('linkid' => $strLink));
     if ($objCart instanceof Cart === false) {
         _xls_404();
     }
     // Send any emails we may still have.
     Checkout::sendEmails($objCart->id);
     $customer = Customer::model()->findByPk(Yii::app()->user->id);
     // In order to upgrade from GUEST to NORMAL_USER there mustn't already
     // be a normal user with this email address.
     $registeredCustomerWithSameEmail = null;
     if ($customer !== null) {
         $registeredCustomerWithSameEmail = Customer::model()->findByAttributes(array('record_type' => Customer::NORMAL_USER, 'email' => $customer->email));
     }
     // Whether to show the createNewAccount section.
     // SSL is required for this, but is enforced by CheckoutController::beforeAction.
     $canCreateNewAccount = $customer !== null && $objCart !== null && $objCart->customer !== null && $customer->id === $objCart->customer->id && CPropertyValue::ensureInteger($customer->record_type) === Customer::GUEST && $registeredCustomerWithSameEmail === null;
     // Whether to show the "your account has been created" message.
     $showAccountCreated = false;
     // Possibility for guests to register for normal account.
     if ($canCreateNewAccount) {
         $customer->scenario = Customer::SCENARIO_UPDATEPASSWORD;
         if (isset($_POST['Customer'])) {
             $customer->password = $_POST['Customer']['password'];
             $customer->password_repeat = $_POST['Customer']['password_repeat'];
             $customer->record_type = Customer::NORMAL_USER;
             $customer->allow_login = Customer::NORMAL_USER;
             if ($customer->validate() === true) {
                 $customer->save();
                 $showAccountCreated = true;
                 $canCreateNewAccount = false;
             } else {
                 $this->checkoutForm->addErrors($customer->getErrors());
             }
         }
     }
     $this->layout = '/layouts/checkout-confirmation';
     $this->render('thankyou', array('cart' => $objCart, 'model' => $customer, 'showCreateNewAccount' => $canCreateNewAccount, 'showAccountCreated' => $showAccountCreated, 'arrError' => $this->formatErrors()));
 }
Пример #10
0
 public function actionCardtypes()
 {
     if ($this->_allowAdvancedPayments === false) {
         _xls_404();
     }
     $model = new CreditCard();
     $pk = Yii::app()->getRequest()->getPost('pk');
     $name = Yii::app()->getRequest()->getPost('name');
     $value = Yii::app()->getRequest()->getPost('value');
     if ($pk) {
         CreditCard::model()->updateByPk($pk, array($name => $value));
         echo "success";
     }
     $this->render("cardtypes", array('model' => $model));
 }
Пример #11
0
 public function actionEmail()
 {
     if (Yii::app()->user->isGuest) {
         _xls_404();
     }
     $model = new ShareForm();
     if (isset($_POST['ShareForm'])) {
         $model->attributes = $_POST['ShareForm'];
         if ($model->validate()) {
             $strCode = $model->code;
             //Make sure code we've been passed is valid
             $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode));
             if (!$objWishlist->Visible) {
                 _xls_404();
             }
             if (!Yii::app()->user->isGuest) {
                 $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id);
                 $model->fromEmail = $objCustomer->email;
                 $model->fromName = $objCustomer->fullname;
             }
             $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true);
             $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_WISHLIST', $objWishlist->customer->fullname, null);
             $objEmail = new EmailQueue();
             $objEmail->customer_id = $objWishlist->customer_id;
             $objEmail->htmlbody = $strHtmlBody;
             $objEmail->subject = $strSubject;
             $objEmail->to = $model->toEmail;
             $objHtml = new HtmlToText();
             //If we get back false, it means conversion failed which 99.9% of the time means improper HTML.
             $strPlain = $objHtml->convert_html_to_text($strHtmlBody);
             if ($strPlain !== false) {
                 $objEmail->plainbody = $strPlain;
             }
             $objEmail->save();
             $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your wish list has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true);
         } else {
             $response_array['status'] = 'error';
             $response_array['errormsg'] = _xls_convert_errors($model->getErrors());
         }
         echo json_encode($response_array);
     }
 }
Пример #12
0
 public function actionIndex()
 {
     //Not used for this controller
     _xls_404();
 }
Пример #13
0
 /**
  * Hide controller behind 404 exception
  * @throws CHttpException
  */
 public function actionIndex()
 {
     _xls_404();
 }
Пример #14
0
 /**
  * Email a cart to a recipient email address
  */
 public function actionEmail()
 {
     $model = new ShareForm();
     if (isset($_POST['ShareForm'])) {
         $model->attributes = $_POST['ShareForm'];
         if (Yii::app()->user->isGuest) {
             $model->setScenario('guest');
         } else {
             $model->setScenario('loggedin');
         }
         if ($model->validate()) {
             $strCode = $model->code;
             //Make sure code we've been passed is valid
             $objCart = Cart::model()->findByAttributes(array('linkid' => $strCode));
             if (!$objCart instanceof Cart) {
                 _xls_404();
             }
             if (!Yii::app()->user->isGuest) {
                 $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id);
                 $model->fromEmail = $objCustomer->email;
                 $model->fromName = $objCustomer->fullname;
             }
             $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true);
             $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_CART', $model->fromName, null);
             $objEmail = new EmailQueue();
             $objEmail->htmlbody = $strHtmlBody;
             $objEmail->subject = $strSubject;
             $objEmail->to = $model->toEmail;
             $objEmail->save();
             $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your cart has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true);
         } else {
             $response_array['status'] = 'error';
             $response_array['errormsg'] = _xls_convert_errors($model->getErrors());
         }
         $this->renderJSON($response_array);
     }
 }