public function onConfigBeforeSave(ConfigEvent $event)
 {
     $values = $event->getConfig();
     $passwords = array('mailer_password', 'transifex_password');
     foreach ($passwords as $key) {
         // Check to ensure we don't save a blank password to the config which may remove the user's old password
         if (array_key_exists($key, $values['coreconfig']) && empty($values['coreconfig'][$key])) {
             unset($values['coreconfig'][$key]);
         }
     }
     // Check if the selected locale has been downloaded already, fetch it if not
     $installedLanguages = $this->factory->getParameter('supported_languages');
     if (!array_key_exists($values['coreconfig']['locale'], $installedLanguages)) {
         /** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
         $languageHelper = $this->factory->getHelper('language');
         $fetchLanguage = $languageHelper->extractLanguagePackage($values['coreconfig']['locale']);
         // If there is an error, fall back to 'en_US' as it is our system default
         if ($fetchLanguage['error']) {
             $values['coreconfig']['locale'] = 'en_US';
             // TODO - Raise a flash message
             $this->factory->getSession()->getFlashBag()->add('notice', 'mautic.core.could.not.set.language');
         }
     }
     $event->setConfig($values);
 }
Beispiel #2
0
 public function onConfigBeforeSave(ConfigEvent $event)
 {
     $values = $event->getConfig();
     // Preserve existing value
     $event->unsetIfEmpty('transifex_password');
     // Check if the selected locale has been downloaded already, fetch it if not
     $installedLanguages = $this->coreParametersHelper->getParameter('supported_languages');
     if (!array_key_exists($values['coreconfig']['locale'], $installedLanguages)) {
         $fetchLanguage = $this->languageHelper->extractLanguagePackage($values['coreconfig']['locale']);
         // If there is an error, fall back to 'en_US' as it is our system default
         if ($fetchLanguage['error']) {
             $values['coreconfig']['locale'] = 'en_US';
             $message = 'mautic.core.could.not.set.language';
             $messageVars = [];
             if (isset($fetchLanguage['message'])) {
                 $message = $fetchLanguage['message'];
             }
             if (isset($fetchLanguage['vars'])) {
                 $messageVars = $fetchLanguage['vars'];
             }
             $event->setError($message, $messageVars);
         }
     }
     $event->setConfig($values);
 }
 public function onConfigBeforeSave(ConfigEvent $event)
 {
     $event->unsetIfEmpty(array('mailer_password'));
     $data = $event->getConfig('emailconfig');
     // Get the original data so that passwords aren't lost
     $monitoredEmail = $this->factory->getParameter('monitored_email');
     if (isset($data['monitored_email'])) {
         foreach ($data['monitored_email'] as $key => $monitor) {
             if (empty($monitor['password']) && !empty($monitoredEmail[$key]['password'])) {
                 $data['monitored_email'][$key]['password'] = $monitoredEmail[$key]['password'];
             }
             if ($key != 'general') {
                 if (empty($monitor['host']) || empty($monitor['address']) || empty($monitor['folder'])) {
                     $data['monitored_email'][$key]['override_settings'] = '';
                     $data['monitored_email'][$key]['address'] = '';
                     $data['monitored_email'][$key]['host'] = '';
                     $data['monitored_email'][$key]['user'] = '';
                     $data['monitored_email'][$key]['password'] = '';
                     $data['monitored_email'][$key]['ssl'] = '1';
                     $data['monitored_email'][$key]['port'] = '993';
                 }
             }
         }
         $event->setConfig($data, 'emailconfig');
     }
 }
 public function onConfigSave(ConfigEvent $event)
 {
     $values = $event->getConfig();
     if (!empty($values['pageconfig']['google_analytics'])) {
         $values['pageconfig']['google_analytics'] = htmlspecialchars($values['pageconfig']['google_analytics']);
         $event->setConfig($values);
     }
 }
Beispiel #5
0
 /**
  * @param ConfigEvent $event
  */
 public function onConfigSave(ConfigEvent $event)
 {
     /** @var array $values */
     $values = $event->getConfig();
     // Manipulate the values
     if (!empty($values['campaignconfig']['campaign_time_wait_on_event_false'])) {
         $values['campaignconfig']['campaign_time_wait_on_event_false'] = htmlspecialchars($values['campaignconfig']['campaign_time_wait_on_event_false']);
     }
     // Set updated values
     $event->setConfig($values);
 }
Beispiel #6
0
 /**
  * @param ConfigEvent $event
  */
 public function onConfigSave(ConfigEvent $event)
 {
     /** @var array $values */
     $values = $event->getConfig();
     // Manipulate the values
     if (!empty($values['social_config']['twitter_handle_field'])) {
         $values['social_config']['twitter_handle_field'] = htmlspecialchars($values['social_config']['twitter_handle_field']);
     }
     // Set updated values
     $event->setConfig($values);
 }
 public function onConfigBeforeSave(ConfigEvent $event)
 {
     $values = $event->getConfig();
     // Preserve existing value
     $event->unsetIfEmpty('transifex_password');
     // Check if the selected locale has been downloaded already, fetch it if not
     $installedLanguages = $this->factory->getParameter('supported_languages');
     if (!array_key_exists($values['coreconfig']['locale'], $installedLanguages)) {
         /** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
         $languageHelper = $this->factory->getHelper('language');
         $fetchLanguage = $languageHelper->extractLanguagePackage($values['coreconfig']['locale']);
         // If there is an error, fall back to 'en_US' as it is our system default
         if ($fetchLanguage['error']) {
             $values['coreconfig']['locale'] = 'en_US';
             // TODO - Raise a flash message
             $this->factory->getSession()->getFlashBag()->add('notice', 'mautic.core.could.not.set.language');
         }
     }
     $event->setConfig($values);
 }
Beispiel #8
0
 public function onConfigBeforeSave(ConfigEvent $event)
 {
     $event->unsetIfEmpty(array('mailer_password', 'mailer_api_key'));
     $data = $event->getConfig('emailconfig');
     // Get the original data so that passwords aren't lost
     $monitoredEmail = $this->factory->getParameter('monitored_email');
     if (isset($data['monitored_email'])) {
         foreach ($data['monitored_email'] as $key => $monitor) {
             if (empty($monitor['password']) && !empty($monitoredEmail[$key]['password'])) {
                 $data['monitored_email'][$key]['password'] = $monitoredEmail[$key]['password'];
             }
             if ($key != 'general') {
                 if (empty($monitor['host']) || empty($monitor['address']) || empty($monitor['folder'])) {
                     $data['monitored_email'][$key]['override_settings'] = '';
                     $data['monitored_email'][$key]['address'] = '';
                     $data['monitored_email'][$key]['host'] = '';
                     $data['monitored_email'][$key]['user'] = '';
                     $data['monitored_email'][$key]['password'] = '';
                     $data['monitored_email'][$key]['ssl'] = '1';
                     $data['monitored_email'][$key]['port'] = '993';
                 }
             }
         }
     }
     // Ensure that percent signs are decoded in the unsubscribe/webview settings
     $decode = array('unsubscribe_text', 'webview_text', 'unsubscribe_message', 'resubscribe_message');
     foreach ($decode as $key) {
         if (strpos($data[$key], '%') !== false) {
             $data[$key] = urldecode($data[$key]);
             if (preg_match_all('/([^%]|^)(%{1}[^%]\\S+[^%]%{1})([^%]|$)/i', $data[$key], $matches)) {
                 // Encode any left over to prevent Symfony from crashing
                 foreach ($matches[0] as $matchKey => $match) {
                     $replaceWith = $matches[1][$matchKey] . '%' . $matches[2][$matchKey] . '%' . $matches[3][$matchKey];
                     $data[$key] = str_replace($match, $replaceWith, $data[$key]);
                 }
             }
         }
     }
     $event->setConfig($data, 'emailconfig');
 }
 /**
  * @param ConfigEvent $event
  */
 public function onConfigSave(ConfigEvent $event)
 {
     /** @var array $values */
     $values = $event->getConfig();
     $event->setConfig($values);
 }