/**
  * Fill the form with the configuration data
  */
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, [OpenGraph::DOMAIN_NAME], AccessManager::UPDATE))) {
         return $response;
     }
     // Create the form from the request
     $form = $this->createForm('open.graph.configuration.form');
     // Initialize the potential error
     $error_message = null;
     try {
         // Check the form against constraints violations
         $validateForm = $this->validateForm($form);
         // Get the form field values
         $data = $validateForm->getData();
         OpenGraph::setConfigValue(OpenGraphConfigValue::ENABLE_SHARING_BUTTONS, is_bool($data["enable_sharing_buttons"]) ? (int) $data["enable_sharing_buttons"] : $data["enable_sharing_buttons"]);
         foreach ($data as $name => $value) {
             ConfigQuery::write("opengraph_" . $name, $value, false, true);
         }
         // Redirect to the configuration page if everything is OK
         return $this->redirectToConfigurationPage();
     } catch (FormValidationException $e) {
         // Form cannot be validated. Create the error message using
         // the BaseAdminController helper method.
         $error_message = $this->createStandardFormValidationErrorMessage($e);
     }
     if (null !== $error_message) {
         $this->setupFormErrorContext('configuration', $error_message, $form);
         $response = $this->render("module-configure", ['module_code' => 'OpenGraph']);
     }
     return $response;
 }
예제 #2
0
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::STORE, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $error_msg = false;
     $response = null;
     $configStoreForm = new ConfigStoreForm($this->getRequest());
     try {
         $form = $this->validateForm($configStoreForm);
         $data = $form->getData();
         // Update store
         foreach ($data as $name => $value) {
             if (!in_array($name, array('success_url', 'error_message'))) {
                 ConfigQuery::write($name, $value, false);
             }
         }
         $this->adminLogAppend(AdminResources::STORE, AccessManager::UPDATE, "Store configuration changed");
         if ($this->getRequest()->get('save_mode') == 'stay') {
             $response = $this->generateRedirectFromRoute('admin.configuration.store.default');
         } else {
             $response = $this->generateSuccessRedirect($configStoreForm);
         }
     } catch (\Exception $ex) {
         $error_msg = $ex->getMessage();
     }
     if (false !== $error_msg) {
         $this->setupFormErrorContext($this->getTranslator()->trans("Store configuration failed."), $error_msg, $configStoreForm, $ex);
         $response = $this->renderTemplate();
     }
     return $response;
 }
예제 #3
0
 public function postActivation(ConnectionInterface $con = null)
 {
     // register config variables
     if (null === ConfigQuery::read(self::CONFIG_TRACKING_URL, null)) {
         ConfigQuery::write(self::CONFIG_TRACKING_URL, self::DEFAULT_TRACKING_URL);
     }
     if (null === ConfigQuery::read(self::CONFIG_PICKING_METHOD, null)) {
         ConfigQuery::write(self::CONFIG_PICKING_METHOD, self::DEFAULT_PICKING_METHOD);
     }
     if (null === ConfigQuery::read(self::CONFIG_TAX_RULE_ID, null)) {
         ConfigQuery::write(self::CONFIG_TAX_RULE_ID, self::DEFAULT_TAX_RULE_ID);
     }
     // create new message
     if (null === MessageQuery::create()->findOneByName('mail_custom_delivery')) {
         $message = new Message();
         $message->setName('mail_custom_delivery')->setHtmlTemplateFileName('custom-delivery-shipping.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('custom-delivery-shipping.txt')->setTextLayoutFileName('')->setSecured(0);
         $languages = LangQuery::create()->find();
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Custom delivery shipping message', [], $locale));
             $message->setSubject($this->trans('Your order {$order_ref} has been shipped', [], $locale));
         }
         $message->save();
     }
 }
예제 #4
0
 public function postActivation(ConnectionInterface $con = null)
 {
     $languages = LangQuery::create()->find();
     ConfigQuery::write(self::CONFIG_ENABLED, self::DEFAULT_ENABLED);
     ConfigQuery::write(self::CONFIG_THRESHOLD, self::DEFAULT_THRESHOLD);
     ConfigQuery::write(self::CONFIG_EMAILS, self::DEFAULT_EMAILS);
     // create new message
     if (null === MessageQuery::create()->findOneByName('stockalert_customer')) {
         $message = new Message();
         $message->setName('stockalert_customer')->setHtmlTemplateFileName('alert-customer.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('alert-customer.txt')->setTextLayoutFileName('')->setSecured(0);
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Stock Alert - Customer', [], $locale));
             $message->setSubject($this->trans('Product {$product_title} is available again', [], $locale));
         }
         $message->save();
         $message = new Message();
         $message->setName('stockalert_administrator')->setHtmlTemplateFileName('alert-administrator.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('alert-administrator.txt')->setTextLayoutFileName('')->setSecured(0);
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Stock Alert - Administrator', [], $locale));
             $message->setSubject($this->trans('Product {$product_title} is (nearly) out of stock', [], $locale));
         }
         $message->save();
     }
     try {
         RestockingAlertQuery::create()->findOne();
     } catch (\Exception $e) {
         $database = new Database($con);
         $database->insertSql(null, [__DIR__ . '/Config/thelia.sql']);
     }
 }
 public function exapaqConfigure()
 {
     if (null !== ($response = $this->checkAuth([AdminResources::MODULE], ['Predict'], AccessManager::UPDATE))) {
         return $response;
     }
     $error_msg = false;
     $save_mode = "stay";
     $form = new ConfigureForm($this->getRequest());
     try {
         $vform = $this->validateForm($form);
         $save_mode = $this->getRequest()->request->get("save_mode");
         ConfigQuery::write("store_exapaq_account", $vform->get("account_number")->getData());
         ConfigQuery::write("store_cellphone", $vform->get("store_cellphone")->getData());
         ConfigQuery::write("store_predict_option", $vform->get("predict_option")->getData() ? "1" : "");
     } catch (FormValidationException $ex) {
         // Form cannot be validated
         $error_msg = $this->createStandardFormValidationErrorMessage($ex);
     } catch (\Exception $ex) {
         // Any other error
         $error_msg = $ex->getMessage();
     }
     if (false !== $error_msg) {
         $form->setErrorMessage($error_msg);
         $this->getParserContext()->addForm($form)->setGeneralError($error_msg);
     }
     if ($save_mode !== "stay") {
         return $this->generateRedirectFromRoute("admin.module", [], ['_controller' => 'Thelia\\Controller\\Admin\\ModuleController::indexAction']);
     }
     return $this->render("module-configure", ["module_code" => "Predict", "tab" => "configure"]);
 }
예제 #6
0
 /**
  * Shuts the kernel down if it was used in the test.
  */
 protected function tearDown()
 {
     ConfigQuery::write('one_domain_foreach_lang', $this->isMultiDomainActivated);
     if (null !== static::$kernel) {
         static::$kernel->shutdown();
     }
 }
예제 #7
0
파일: Update.php 프로젝트: alex63530/thelia
 protected function updateToVersion($version, Database $database, Tlog $logger)
 {
     if (file_exists(THELIA_ROOT . '/setup/update/' . $version . '.sql')) {
         $logger->debug(sprintf('inserting file %s', $version . '$sql'));
         $database->insertSql(null, array(THELIA_ROOT . '/setup/update/' . $version . '.sql'));
         $logger->debug(sprintf('end inserting file %s', $version . '$sql'));
     }
     ConfigQuery::write('thelia_version', $version);
 }
예제 #8
0
 /**
  *
  * in this function you add all the fields you need for your Form.
  * Form this you have to call add method on $this->formBuilder attribute :
  *
  * $this->formBuilder->add("name", "text")
  *   ->add("email", "email", array(
  *           "attr" => array(
  *               "class" => "field"
  *           ),
  *           "label" => "email",
  *           "constraints" => array(
  *               new \Symfony\Component\Validator\Constraints\NotBlank()
  *           )
  *       )
  *   )
  *   ->add('age', 'integer');
  *
  * @return null
  */
 protected function buildForm()
 {
     $account = ConfigQuery::read("store_exapaq_account");
     if (!is_numeric($account)) {
         ConfigQuery::write("store_exapaq_account", 0);
         $account = 0;
     }
     $translator = Translator::getInstance();
     $this->formBuilder->add("account_number", "integer", array("label" => $translator->trans("Account number", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "account_number"], "constraints" => [new NotBlank()], "required" => true, "data" => $account))->add("store_cellphone", "text", array("label" => $translator->trans("Store's cellphone", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "store_cellphone"], "required" => false, "data" => ConfigQuery::read("store_cellphone")))->add("predict_option", "checkbox", array("label" => $translator->trans("Predict SMS option", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "predict_option"], "required" => false, "data" => @(bool) ConfigQuery::read("store_predict_option")));
 }
예제 #9
0
 public function testFormatTime()
 {
     $this->assertEquals("1 hour(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 61);
     $this->assertEquals("1 hour(s) 1 minute(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 59);
     $this->assertEquals("59 minute(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 5);
     $this->assertEquals("5 minute(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 132);
     $this->assertEquals("2 hour(s) 12 minute(s)", $this->form->getWaitingTime());
 }
예제 #10
0
 public function preActivation(ConnectionInterface $con = null)
 {
     $prefix = ConfigQuery::read(self::CONFIG_PATH);
     if ($prefix === null) {
         ConfigQuery::write(self::CONFIG_PATH, '', false, true);
     }
     $enabled = ConfigQuery::read(self::CONFIG_USE_DEFAULT_PATH, null);
     if ($enabled === null) {
         ConfigQuery::write(self::CONFIG_USE_DEFAULT_PATH, true, false, true);
     }
     return true;
 }
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, ['Twitter'], AccessManager::UPDATE))) {
         return $response;
     }
     $form = new ConfigurationForm($this->getRequest());
     $configurationForm = $this->validateForm($form);
     $consumer_key = $configurationForm->get('consumer_key')->getData();
     $consumer_secret = $configurationForm->get('consumer_secret')->getData();
     $screen_name = $configurationForm->get('screen_name')->getData();
     $count = $configurationForm->get('count')->getData();
     $cache_lifetime = $configurationForm->get('cache_lifetime')->getData();
     // $debug_mode     = $configurationForm->get('debug_mode')->getData();
     $errorMessage = null;
     $response = null;
     // Save config values
     ConfigQuery::write('twitter_consumer_key', $consumer_key, 1, 1);
     ConfigQuery::write('twitter_consumer_secret', $consumer_secret, 1, 1);
     ConfigQuery::write('twitter_screen_name', $screen_name, 1, 1);
     ConfigQuery::write('twitter_count', $count, 1, 1);
     ConfigQuery::write('twitter_cache_lifetime', $cache_lifetime * 60, 1, 1);
     // Minutes
     ConfigQuery::write('twitter_last_updated', 0, 1, 1);
     if ($screen_name && $consumer_key && $consumer_secret) {
         if (!extension_loaded('openssl')) {
             $sslError = $this->getTranslator()->trans("This module requires the PHP extension open_ssl to work.", [], Twitter::DOMAIN_NAME);
         } else {
             $config = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'output_format' => 'array');
             try {
                 $connection = new TwitterOAuth($config);
                 $bearer_token = $connection->getBearerToken();
             } catch (\Exception $e) {
                 $errorMessage = $e->getMessage();
             }
             try {
                 $params = array('screen_name' => $screen_name, 'count' => 1, 'exclude_replies' => true);
                 $response = $connection->get('statuses/user_timeline', $params);
                 if ($response['error']) {
                     throw new TwitterException($response['error']);
                 }
             } catch (\Exception $e) {
                 $erroMessage = $this->getTranslator()->trans("Unrecognized screen name", [], Twitter::DOMAIN_NAME);
             }
         }
     }
     $response = RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/Twitter'));
     if (null !== $errorMessage) {
         $this->setupFormErrorContext($this->getTranslator()->trans("Twitter configuration failed.", [], Twitter::DOMAIN_NAME), $errorMessage, $form);
         $response = $this->render("module-configure", ['module_code' => 'Twitter']);
     }
     return $response;
 }
예제 #12
0
 public function saveAction()
 {
     $baseForm = new MailjetConfigurationForm($this->getRequest());
     try {
         $form = $this->validateForm($baseForm);
         $data = $form->getData();
         ConfigQuery::write(Mailjet::CONFIG_API_KEY, $data["api_key"]);
         ConfigQuery::write(Mailjet::CONFIG_API_SECRET, $data["api_secret"]);
         ConfigQuery::write(Mailjet::CONFIG_API_WS_ADDRESS, $data["ws_address"]);
         ConfigQuery::write(Mailjet::CONFIG_NEWSLETTER_LIST, $data["newsletter_list"]);
         $this->getParserContext()->set("success", true);
     } catch (\Exception $e) {
         $this->getParserContext()->setGeneralError($e->getMessage())->addForm($baseForm);
     }
     if ("close" === $this->getRequest()->request->get("save_mode")) {
         return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/modules"));
     }
 }
예제 #13
0
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('hookanalytics'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = new \HookAnalytics\Form\Configuration($this->getRequest());
     $resp = array("error" => 0, "message" => "");
     $response = null;
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         ConfigQuery::write("hookanalytics_trackingcode", $data["trackingcode"], false, true);
     } catch (\Exception $e) {
         $resp["error"] = 1;
         $resp["message"] = $e->getMessage();
     }
     return JsonResponse::create($resp);
 }
예제 #14
0
 public function getTweets()
 {
     $cache_path = realpath('.') . '/cache/tweets';
     $last_updated = ConfigQuery::read('twitter_last_updated');
     $tweets_file = $cache_path . '/' . Twitter::TWEETS_FILENAME;
     $tweets = [];
     // Is the cache stale ?
     // if( $last_updated + 0 < time() )
     if ($last_updated + $this->cache_lifetime < time()) {
         if (!is_dir($cache_path)) {
             mkdir($cache_path);
             chmod($cache_path, 0755);
         }
         // Get the tweets
         $config = ['consumer_key' => $this->consumer_key, 'consumer_secret' => $this->consumer_secret];
         try {
             $connection = new TwitterOAuth($config);
             $bearer_token = $connection->getBearerToken();
         } catch (\Exception $e) {
             $errorMessage = $e->getMessage();
         }
         try {
             $params = array('screen_name' => $this->screen_name, 'count' => $this->count, 'exclude_replies' => true);
             $tweets = $connection->get('statuses/user_timeline', $params);
             if ($tweets['error']) {
                 throw new TwitterException($tweets['error']);
             }
             // Cache tweets
             unlink($tweets_file);
             $fh = fopen($tweets_file, 'w');
             fwrite($fh, json_encode($tweets));
             fclose($fh);
             // Update cache refresh timestamp
             ConfigQuery::write('twitter_last_updated', time(), 1, 1);
         } catch (\Exception $e) {
             $erroMessage = Translator::getInstance()->trans("Unrecognized screen name", [], Twitter::DOMAIN_NAME);
         }
     } else {
         // Get tweets from the cache
         $tweets = json_decode(file_get_contents($tweets_file));
     }
     return $tweets;
 }
예제 #15
0
 public function save()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('SoColissimo'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = new ConfigureSoColissimo($this->getRequest());
     try {
         $vform = $this->validateForm($form);
         ConfigQuery::write('socolissimo_login', $vform->get('accountnumber')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_pwd', $vform->get('password')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_url_prod', $vform->get('url_prod')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_url_test', $vform->get('url_test')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_test_mode', $vform->get('test_mode')->getData(), 1, 1);
         $this->redirectToRoute("admin.module.configure", [], ['module_code' => 'SoColissimo', 'current_tab' => 'configure']);
     } catch (\Exception $e) {
         $this->setupFormErrorContext(Translator::getInstance()->trans("So Colissimo update config"), $e->getMessage(), $form, $e);
         return $this->render('module-configure', ['module_code' => 'SoColissimo', 'current_tab' => 'configure']);
     }
 }
 public function configuration()
 {
     $errorMessage = null;
     $form = $this->createForm('stockalert.configuration.form', 'form');
     try {
         $configForm = $this->validateForm($form)->getData();
         ConfigQuery::write(StockAlert::CONFIG_ENABLED, $configForm['enabled']);
         ConfigQuery::write(StockAlert::CONFIG_THRESHOLD, $configForm['threshold']);
         $emails = str_replace(' ', '', $configForm['emails']);
         ConfigQuery::write(StockAlert::CONFIG_EMAILS, $emails);
         return $this->generateSuccessRedirect($form);
     } catch (FormValidationException $e) {
         $errorMessage = $e->getMessage();
     } catch (\Exception $e) {
         $errorMessage = $e->getMessage();
     }
     $form->setErrorMessage($errorMessage);
     $this->getParserContext()->addForm($form)->setGeneralError($errorMessage);
     return $this->render("module-configure", ["module_code" => StockAlert::getModuleCode()]);
 }
예제 #17
0
 public function doMigrateSystemAction()
 {
     $response = $this->checkAuth(AdminResources::COUNTRY, array(), AccessManager::UPDATE);
     if (null !== $response) {
         return $response;
     }
     $changeForm = $this->createForm('thelia.admin.country.state.migration', 'form');
     try {
         // Check the form against constraints violations
         $form = $this->validateForm($changeForm, "POST");
         // Get the form field values
         $data = $form->getData();
         foreach ($data['migrations'] as $migration) {
             if (!$migration['migrate']) {
                 continue;
             }
             $changeEvent = new MigrateCountryEvent($migration['country'], $migration['new_country'], $migration['new_state']);
             $this->dispatch(MigrateCountryEvents::MIGRATE_COUNTRY, $changeEvent);
             // memorize the migration
             $migratedCountries = json_decode(ConfigQuery::read('thelia_country_state_migration', '[]'), true);
             $migratedCountries[$changeEvent->getCountry()] = ['country' => $changeEvent->getNewCountry(), 'state' => $changeEvent->getNewState(), 'counter' => $changeEvent->getCounter()];
             ConfigQuery::write('thelia_country_state_migration', json_encode($migratedCountries));
             // message
             $message = $this->getTranslator()->trans('Country %id migrated to country (ID %country) and state (ID %state) (address: %address, tax rules: %tax, shipping zones: %zone)', ['%id' => $changeEvent->getCountry(), '%country' => $changeEvent->getNewCountry(), '%state' => $changeEvent->getNewState(), '%address' => $changeEvent->getCounter()[AddressTableMap::TABLE_NAME], '%tax' => $changeEvent->getCounter()[TaxRuleCountryTableMap::TABLE_NAME], '%zone' => $changeEvent->getCounter()[CountryAreaTableMap::TABLE_NAME]]);
             // add flash message
             $this->getSession()->getFlashBag()->add('migrate', $message);
             // Log migration
             $this->adminLogAppend(AdminResources::COUNTRY, AccessManager::UPDATE, $message, $changeEvent->getCountry());
         }
         return $this->generateSuccessRedirect($changeForm);
     } catch (FormValidationException $ex) {
         // Form cannot be validated
         $error_msg = $this->createStandardFormValidationErrorMessage($ex);
     }
     if (false !== $error_msg) {
         $this->setupFormErrorContext($this->getTranslator()->trans("Country migration"), $error_msg, $changeForm, $ex);
         return $this->render('countries-migrate', ['countriesMigrated' => $migratedCountries, 'showForm' => true]);
     }
 }
예제 #18
0
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('hooksocial'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = new \HookSocial\Form\Configuration($this->getRequest());
     $resp = array("error" => 0, "message" => "");
     $response = null;
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         foreach ($data as $name => $value) {
             if (!in_array($name, array('success_url', 'error_message'))) {
                 ConfigQuery::write("hooksocial_" . $name, $value, false, true);
             }
             Tlog::getInstance()->debug(sprintf("%s => %s", $name, $value));
         }
     } catch (\Exception $e) {
         $resp["error"] = 1;
         $resp["message"] = $e->getMessage();
     }
     return JsonResponse::create($resp);
 }
 public function saveAction()
 {
     if ($response = $this->checkAuth(array(AdminResources::MODULE), array('hookpiwikanalytics'), AccessManager::UPDATE) !== null) {
         return $response;
     }
     $form = new \HookPiwikAnalytics\Form\Configuration($this->getRequest());
     $resp = array('error' => 0, 'message' => '');
     $response = null;
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         ConfigQuery::write('hookpiwikanalytics_url', $data['hookpiwikanalytics_url']);
         ConfigQuery::write('hookpiwikanalytics_website_id', $data['hookpiwikanalytics_website_id']);
         ConfigQuery::write('hookpiwikanalytics_enable_subdomains', is_bool($data['hookpiwikanalytics_enable_subdomains']) ? (int) $data['hookpiwikanalytics_enable_subdomains'] : $data['hookpiwikanalytics_enable_subdomains']);
         ConfigQuery::write('hookpiwikanalytics_enable_contenttracking', is_bool($data['hookpiwikanalytics_enable_contenttracking']) ? (int) $data['hookpiwikanalytics_enable_contenttracking'] : $data['hookpiwikanalytics_enable_contenttracking']);
         ConfigQuery::write('hookpiwikanalytics_enable_contenttracking_visible_only', is_bool($data['hookpiwikanalytics_enable_contenttracking_visible_only']) ? (int) $data['hookpiwikanalytics_enable_contenttracking_visible_only'] : $data['hookpiwikanalytics_enable_contenttracking_visible_only']);
         ConfigQuery::write('hookpiwikanalytics_custom_campaign_name', $data['hookpiwikanalytics_custom_campaign_name']);
         ConfigQuery::write('hookpiwikanalytics_custom_campaign_keyword', $data['hookpiwikanalytics_custom_campaign_keyword']);
     } catch (\Exception $e) {
         $resp['error'] = 1;
         $resp['message'] = $e->getMessage();
     }
     return JsonResponse::create($resp);
 }
예제 #20
0
 public function saveAction()
 {
     $response = $this->checkAuth([AdminResources::MODULE], ['backofficepath'], AccessManager::UPDATE);
     if ($response !== null) {
         return $response;
     }
     $form = new \BackOfficePath\Form\Configuration($this->getRequest());
     $message = '';
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         ConfigQuery::write('back_office_path', $data['back_office_path'], false, true);
         ConfigQuery::write('back_office_path_default_enabled', $data['back_office_path_default_enabled'] ? '1' : '0', false, true);
     } catch (\Exception $e) {
         $message = $e->getMessage();
     }
     if ($message) {
         $form->setErrorMessage($message);
         $this->getParserContext()->addForm($form);
         $this->getParserContext()->setGeneralError($message);
         return $this->render('module-configure', array('module_code' => BackOfficePath::getModuleCode()));
     }
     return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/' . BackOfficePath::getModuleCode()));
 }
예제 #21
0
 /**
  * @param ModuleGenerateEvent $event
  *
  * This method self prepares the event before running the generators.
  *
  * Here is the build process:
  * 1. Launch propel to validate the schema and generate model && sql
  * 2. Find / prepare all the resources
  * 3. Compile the module related classes
  * 4. Compile the table related classes
  * 5. Compile the templates
  * 6. Copy raw files
  * 7. Apply rules
  * 8. Add everything in config.xml and routing.xml
  */
 public function launchBuild(ModuleGenerateEvent $event)
 {
     // Backup trim level and set it to 0
     $previousTrimLevel = ConfigQuery::read("html_output_trim_level");
     ConfigQuery::write("html_output_trim_level", 0);
     $moduleCode = $event->getModuleCode();
     $modulePath = THELIA_MODULE_DIR . $moduleCode . DS;
     $resourcesPath = ConfigQuery::read(TheliaStudio::RESOURCE_PATH_CONFIG_NAME) . DS;
     if (!is_dir($resourcesPath) || !is_readable($resourcesPath)) {
         throw new FileNotFoundException(sprintf("The resources directory %s doesn't exist", $resourcesPath));
     }
     $e = null;
     try {
         $entities = $this->buildEntities($modulePath, $event->getTables());
         $event->setModulePath($modulePath)->setResourcesPath($resourcesPath)->setEntities($entities)->setKernel($this->kernel);
         $event->getDispatcher()->dispatch(TheliaStudioEvents::RUN_GENERATORS, $event);
     } catch (\Exception $e) {
     }
     // Restore trim level
     ConfigQuery::write("html_output_trim_level", $previousTrimLevel);
     if (null !== $e) {
         throw $e;
     }
 }
예제 #22
0
 public static function tearDownAfterClass()
 {
     ConfigQuery::write('active-front-template', self::$templateBackupPath);
 }
예제 #23
0
파일: Comment.php 프로젝트: blump/Comment
 public function postActivation(ConnectionInterface $con = null)
 {
     // Config
     if (null === ConfigQuery::read('comment_activated')) {
         ConfigQuery::write('comment_activated', Comment::CONFIG_ACTIVATED);
     }
     if (null === ConfigQuery::read('comment_moderate')) {
         ConfigQuery::write('comment_moderate', Comment::CONFIG_MODERATE);
     }
     if (null === ConfigQuery::read('comment_ref_allowed')) {
         ConfigQuery::write('comment_ref_allowed', Comment::CONFIG_REF_ALLOWED);
     }
     if (null === ConfigQuery::read('comment_only_customer')) {
         ConfigQuery::write('comment_only_customer', Comment::CONFIG_ONLY_CUSTOMER);
     }
     if (null === ConfigQuery::read('comment_only_verified')) {
         ConfigQuery::write('comment_only_verified', Comment::CONFIG_ONLY_VERIFIED);
     }
     if (null === ConfigQuery::read('comment_request_customer_ttl')) {
         ConfigQuery::write('comment_request_customer_ttl', Comment::CONFIG_REQUEST_CUSTOMMER_TTL);
     }
     if (null === ConfigQuery::read('comment_notify_admin_new_comment')) {
         ConfigQuery::write('comment_notify_admin_new_comment', Comment::CONFIG_NOTIFY_ADMIN_NEW_COMMENT);
     }
     // Schema
     try {
         CommentQuery::create()->findOne();
     } catch (\Exception $ex) {
         $database = new Database($con->getWrappedConnection());
         $database->insertSql(null, [__DIR__ . DS . 'Config' . DS . 'thelia.sql']);
     }
     // Messages
     // load the email localization files (the module was just loaded so they are not loaded yet)
     $languages = LangQuery::create()->find();
     /** @var Lang $language */
     foreach ($languages as $language) {
         Translator::getInstance()->addResource("php", __DIR__ . "/I18n/email/default/" . $language->getLocale() . ".php", $language->getLocale(), self::MESSAGE_DOMAIN_EMAIL);
     }
     // Request comment from customer
     if (null === MessageQuery::create()->findOneByName('comment_request_customer')) {
         $message = new Message();
         $message->setName('comment_request_customer')->setHtmlTemplateFileName('request-customer-comment.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('request-customer-comment.txt')->setTextLayoutFileName('')->setSecured(0);
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle(Translator::getInstance()->trans('Request customer comment', [], self::MESSAGE_DOMAIN));
             $message->setSubject(Translator::getInstance()->trans('', [], self::MESSAGE_DOMAIN));
         }
         $message->save();
     }
     // Notify admin of new comment
     if (null === MessageQuery::create()->findOneByName('new_comment_notification_admin')) {
         $message = new Message();
         $message->setName('new_comment_notification_admin')->setHtmlTemplateFileName('new-comment-notification-admin.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('new-comment-notification-admin.txt')->setTextLayoutFileName('')->setSecured(0);
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle(Translator::getInstance()->trans('Notify store admin of new comment', [], self::MESSAGE_DOMAIN_EMAIL, $locale));
             $subject = Translator::getInstance()->trans('New comment on %ref_type_title "%ref_title"', [], self::MESSAGE_DOMAIN_EMAIL, $locale);
             $subject = str_replace('%ref_type_title', '{$ref_type_title|lower}', $subject);
             $subject = str_replace('%ref_title', '{$ref_title}', $subject);
             $message->setSubject($subject);
         }
         $message->save();
     }
 }
예제 #24
0
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::SYSTEM_LOG, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $error_msg = false;
     $systemLogForm = $this->createForm(AdminForm::SYSTEM_LOG_CONFIGURATION);
     try {
         $form = $this->validateForm($systemLogForm);
         $data = $form->getData();
         ConfigQuery::write(Tlog::VAR_LEVEL, $data['level']);
         ConfigQuery::write(Tlog::VAR_PREFIXE, $data['format']);
         ConfigQuery::write(Tlog::VAR_SHOW_REDIRECT, $data['show_redirections']);
         ConfigQuery::write(Tlog::VAR_FILES, $data['files']);
         ConfigQuery::write(Tlog::VAR_IP, $data['ip_addresses']);
         // Save destination configuration
         $destinations = $this->getRequest()->get('destinations');
         $configs = $this->getRequest()->get('config');
         $active_destinations = array();
         foreach ($destinations as $classname => $destination) {
             if (isset($destination['active'])) {
                 $active_destinations[] = $destination['classname'];
             }
             if (isset($configs[$classname])) {
                 // Update destinations configuration
                 foreach ($configs[$classname] as $var => $value) {
                     ConfigQuery::write($var, $value, true, true);
                 }
             }
         }
         // Update active destinations list
         ConfigQuery::write(Tlog::VAR_DESTINATIONS, implode(';', $active_destinations));
         $this->adminLogAppend(AdminResources::SYSTEM_LOG, AccessManager::UPDATE, "System log configuration changed");
         $response = $this->generateRedirectFromRoute('admin.configuration.system-logs.default');
     } catch (\Exception $ex) {
         $error_msg = $ex->getMessage();
     }
     if (false !== $error_msg) {
         $this->setupFormErrorContext($this->getTranslator()->trans("System log configuration failed."), $error_msg, $systemLogForm, $ex);
         $response = $this->renderTemplate();
     }
     return $response;
 }
 public static function setEcotaxRule($taxId)
 {
     ConfigQuery::write("shopping_flux_ecotax_id", $taxId);
 }
예제 #26
0
 protected function tearDown()
 {
     $dir = TemplateHelper::getInstance()->getActiveMailTemplate()->getAbsolutePath();
     ConfigQuery::write('active-mail-template', $this->backup_mail_template);
     $fs = new Filesystem();
     $fs->remove($dir);
 }
예제 #27
0
 /**
  * Save module configuration
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function saveConfigurationAction()
 {
     $response = $this->checkAuth([AdminResources::MODULE], ['customdelivery'], AccessManager::UPDATE);
     if (null !== $response) {
         return $response;
     }
     $form = $this->createForm('customdelivery.configuration.form', 'form');
     $message = "";
     $response = null;
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         ConfigQuery::write(CustomDelivery::CONFIG_TRACKING_URL, $data['url']);
         ConfigQuery::write(CustomDelivery::CONFIG_PICKING_METHOD, $data['method']);
         ConfigQuery::write(CustomDelivery::CONFIG_TAX_RULE_ID, $data['tax']);
     } catch (\Exception $e) {
         $message = $e->getMessage();
     }
     if ($message) {
         $form->setErrorMessage($message);
         $this->getParserContext()->addForm($form);
         $this->getParserContext()->setGeneralError($message);
         return $this->render("module-configure", ["module_code" => CustomDelivery::getModuleCode()]);
     }
     return RedirectResponse::create(URL::getInstance()->absoluteUrl("/admin/module/" . CustomDelivery::getModuleCode()));
 }
예제 #28
0
파일: import.php 프로젝트: alex63530/thelia
function createConfig($faker, $folders, $contents, $con)
{
    // Store
    \Thelia\Model\ConfigQuery::write("store_name", "Thelia");
    \Thelia\Model\ConfigQuery::write("store_description", "E-commerce solution based on Symfony 2");
    \Thelia\Model\ConfigQuery::write("store_email", "Thelia");
    \Thelia\Model\ConfigQuery::write("store_address1", "5 rue Rochon");
    \Thelia\Model\ConfigQuery::write("store_city", "Clermont-Ferrrand");
    \Thelia\Model\ConfigQuery::write("store_phone", "+(33)444053102");
    \Thelia\Model\ConfigQuery::write("store_email", "*****@*****.**");
    // Contents
    \Thelia\Model\ConfigQuery::write("information_folder_id", $folders['Information']->getId());
    \Thelia\Model\ConfigQuery::write("terms_conditions_content_id", $contents["Terms and Conditions"]->getId());
}
예제 #29
0
 private function setConfig(InputInterface $input, OutputInterface $output)
 {
     $varName = $input->getArgument("name");
     $varValue = $input->getArgument("value");
     if (null === $varName || null === $varValue) {
         $output->writeln("<error>Need argument 'name' and 'value' for set command</error>");
         return;
     }
     ConfigQuery::write($varName, $varValue, $input->getOption("secured"), !$input->getOption("visible"));
     $output->writeln("<info>Variable has been set</info>");
 }
예제 #30
0
파일: end.php 프로젝트: GuiminZHOU/thelia
 if ($_SESSION['install']['step'] == 5) {
     // Check now if we can create the App.
     $thelia = new \Thelia\Core\Thelia("install", true);
     $thelia->boot();
     $admin = new \Thelia\Model\Admin();
     $admin->setLogin($_POST['admin_login'])->setPassword($_POST['admin_password'])->setFirstname('admin')->setLastname('admin')->setLocale(empty($_POST['admin_locale']) ? 'en_US' : $_POST['admin_locale'])->setLocale($_POST['admin_email'])->save();
     \Thelia\Model\ConfigQuery::create()->filterByName('store_email')->update(array('Value' => $_POST['store_email']));
     \Thelia\Model\ConfigQuery::create()->filterByName('store_notification_emails')->update(array('Value' => $_POST['store_email']));
     \Thelia\Model\ConfigQuery::create()->filterByName('store_name')->update(array('Value' => $_POST['store_name']));
     \Thelia\Model\ConfigQuery::create()->filterByName('url_site')->update(array('Value' => $_POST['url_site']));
     $lang = \Thelia\Model\LangQuery::create()->findOneByLocale(empty($_POST['shop_locale']) ? "en_US" : $_POST['shop_locale']);
     if (null !== $lang) {
         $lang->toggleDefault();
     }
     $secret = \Thelia\Tools\TokenProvider::generateToken();
     \Thelia\Model\ConfigQuery::write('form.secret', $secret, 0, 0);
 }
 //clean up cache directories
 $fs = new \Symfony\Component\Filesystem\Filesystem();
 $fs->remove(THELIA_ROOT . '/cache/prod');
 $fs->remove(THELIA_ROOT . '/cache/dev');
 $fs->remove(THELIA_ROOT . '/cache/install');
 $request = \Thelia\Core\HttpFoundation\Request::createFromGlobals();
 $_SESSION['install']['step'] = $step;
 // Retrieve the website url
 $url = $_SERVER['PHP_SELF'];
 $website_url = preg_replace("#/install/[a-z](.*)#", '', $url);
 ?>
 <div class="well">
     <p class="lead text-center">
         <?php