Beispiel #1
0
 /**
  * Runs any "cron" jobs necessary
  * @return void
  */
 public function run()
 {
     // Garbage collection
     Log::garbageCollect();
     Cart::garbageCollect();
     Wishlist::garbageCollect();
     // Check for new version
     _xls_check_version();
     // Attemp to send pending emails
     $this->_sendQueueEmails();
 }
 protected function changeTheme($post)
 {
     if (_xls_get_conf('THEME') != $post['theme']) {
         //we're going to swap out template information
         //Get (or create) Module entry for this theme.
         //If outgoing theme does not have an Admin Form,
         if (!Theme::hasAdminForm(_xls_get_conf('THEME'))) {
             $objCurrentSettings = Modules::model()->findByAttributes(array('module' => _xls_get_conf('THEME'), 'category' => 'theme'));
             if (!$objCurrentSettings) {
                 $objCurrentSettings = new Modules();
                 $objCurrentSettings->active = 1;
             }
             $objCurrentSettings->module = _xls_get_conf('THEME');
             $objCurrentSettings->category = 'theme';
             $arrDimensions = array();
             $arrItems = Configuration::model()->findAllByAttributes(array('template_specific' => 1));
             foreach ($arrItems as $objConf) {
                 $arrDimensions[$objConf->key_name] = $objConf->key_value;
             }
             $objCurrentSettings->configuration = serialize($arrDimensions);
             if (!$objCurrentSettings->save()) {
                 Yii::log("Error on switching old theme " . print_r($objCurrentSettings->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
             unset($objCurrentSettings);
         }
         //Now that we've saved the current settings, see if there are new ones to load
         $objCurrentSettings = Modules::model()->findByAttributes(array('module' => $post['theme'], 'category' => 'theme'));
         list($themeDefaults, $themeVersion) = $this->loadDefaults($post['theme']);
         $themeVersion = round($themeVersion, PHP_ROUND_HALF_DOWN);
         if ($objCurrentSettings) {
             //We found settings, load them
             $arrDimensions = unserialize($objCurrentSettings->configuration);
             if (is_array($arrDimensions)) {
                 foreach ($arrDimensions as $key => $val) {
                     _xls_set_conf($key, $val);
                 }
             }
             //Make sure our version number is up to date
             $objCurrentSettings->version = $themeVersion;
             if (!$objCurrentSettings->save()) {
                 Yii::log("Error on switching themes " . print_r($objCurrentSettings->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
         } else {
             //Create entry in our modules table
             $objCurrentSettings = new Modules();
             $objCurrentSettings->module = $post['theme'];
             $objCurrentSettings->category = 'theme';
             $objCurrentSettings->configuration = serialize($themeDefaults);
             $objCurrentSettings->version = $themeVersion;
             $objCurrentSettings->active = 1;
             //we use this for autochecking
             if (!$objCurrentSettings->save()) {
                 Yii::log("Error on new module entry when switching themes " . print_r($objCurrentSettings->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
         }
     }
     _xls_set_conf('THEME', $post['theme']);
     Yii::app()->theme = $post['theme'];
     if (isset($post['subtheme-' . $post['theme']])) {
         $child = $post['subtheme-' . $post['theme']];
     } else {
         $child = "";
         $arrOptions = $this->buildSubThemes($post['theme']);
         if ($arrOptions) {
             $keys = array_keys($arrOptions);
             $child = array_shift($keys);
         }
     }
     _xls_set_conf('CHILD_THEME', $child);
     // now that we have changed themes, rebuild the activecss array
     $arrActiveCss = Yii::app()->theme->info->cssfiles;
     $arrActiveCss[] = Yii::app()->theme->config->CHILD_THEME;
     Yii::app()->theme->config->activecss = $arrActiveCss;
     Yii::app()->user->setFlash('success', Yii::t('admin', 'Theme set as "{theme}" at {time}.', array('{theme}' => Yii::app()->theme->info->name, '{time}' => date("d F, Y  h:i:sa"))));
     $arrThemes = $this->getInstalledThemes();
     $this->beforeAction('manage');
     _xls_check_version();
     //to report new active theme
     return $arrThemes;
 }
 /**
  * Creates a new item
  *
  * @access public
  * @return void
  */
 public function actionCreate()
 {
     $this->_checkAuth();
     switch ($_GET['model']) {
         case 'configuration':
             //Configuration keys are handled a bit differently than normal records
             $json = file_get_contents('php://input');
             $obj = json_decode($json);
             foreach ($obj as $var => $value) {
                 if ($var != 'Testing') {
                     _xls_set_conf($var, $value);
                 }
             }
             $arrobj = (array) $obj;
             // if we're doing testing, don't push or register
             if (isset($arrobj['Testing']) == false) {
                 _upload_default_header_to_s3();
                 _xls_check_version();
                 //Register ourselves to stat server
             }
             break;
             // Get an instance of the respective model
         // Get an instance of the respective model
         default:
             $this->_sendResponse(501, sprintf('Mode <b>create</b> is not implemented for model <b>%s</b>', $_GET['model']));
             exit;
     }
     $this->_sendResponse(200, json_encode(array('status' => 'success')));
 }
 /**
  * Default action when no other routes specified.
  *
  * This action also checks to see if there are Web Store updates available and if so, installs (or prompts)
  * to keep Web Store up to date.
  *
  * @return void
  */
 public function actionIndex()
 {
     $oXML = json_decode(_xls_check_version());
     if (!empty($oXML)) {
         //We check for schema updates first to make sure our current version is up to date before pulling more code
         if (isset($oXML->webstore->schema) && $oXML->webstore->schema != "current") {
             $strUpdateUrl = $this->createAbsoluteUrl("upgrade/index", array(), 'http');
             //update without patch file
             //Some circumstances because of domain switching could get https url, so double check here
             $strUpdateUrl = str_replace("https://", "http://", $strUpdateUrl);
             $this->redirect($strUpdateUrl);
         } elseif ($oXML->webstore->version > XLSWS_VERSIONBUILD) {
             $strUpdateUrl = $this->createAbsoluteUrl("upgrade/index", array('patch' => $oXML->webstore->autopathfile), 'http');
             //Some circumstances because of domain switching could get https url, so double check here
             $strUpdateUrl = str_replace("https://", "http://", $strUpdateUrl);
             if (_xls_get_conf('LIGHTSPEED_HOSTING', '0') != "1" && _xls_get_conf('AUTO_UPDATE', '1') == '1' && $oXML->webstore->autopathfile) {
                 $this->redirect($strUpdateUrl);
             } else {
                 $strVersion = (string) $oXML->webstore->version;
                 $strDashVersion = $strVersion[0] . '-' . $strVersion[1] . '-' . $strVersion[2];
                 $strReleaseNotesUrl = 'https://www.lightspeedretail.com/release-notes/webstore/web-store-' . $strDashVersion . '/?hide=yes';
                 $this->render("newversion", array('oXML' => $oXML->webstore, 'strUpdateUrl' => $strUpdateUrl, 'strReleaseNotesUrl' => $strReleaseNotesUrl));
             }
             return;
         } elseif (isset($oXML->webstore->themedisplayversion) && Yii::app()->params['LIGHTSPEED_HOSTING'] == 0) {
             // only self hosted customers should see this
             $this->render("newtemplate", array('oXML' => $oXML->webstore));
             return;
         }
     }
     if (Yii::app()->params['LIGHTSPEED_SHOW_RELEASENOTES']) {
         $this->redirect(Yii::app()->createUrl('admin/default/releasenotes'));
     }
     $this->render("index", array('inls' => Yii::app()->user->fullname == "Lightspeed" ? "1" : "0"));
     // Deleting install.php for security reasons.
     $installFile = YiiBase::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'install.php';
     if (file_exists($installFile)) {
         unlink($installFile);
     }
 }
 /**
  * Force stat report
  */
 public function actionTransponder()
 {
     _xls_check_version();
 }