예제 #1
0
 function display($tpl = null)
 {
     FSS_CSSParse::OutputCSS('components/com_fss/assets/css/bootstrap/bootstrap_fssonly.less');
     $document = JFactory::getDocument();
     $document->addScriptDeclaration("\nvar fss_settings_url = '" . JRoute::_('index.php?option=com_fss&view=settings', false) . "';\n");
     $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/settings.js');
     FSS_Helper::StylesAndJS(array('csstest'));
     JHTML::_('behavior.modal');
     $what = JRequest::getString('what', '');
     $this->tab = JRequest::getVar('tab');
     if (JRequest::getVar('task') == "cancellist") {
         $mainframe = JFactory::getApplication();
         $link = FSSRoute::_('index.php?option=com_fss&view=fsss', false);
         $mainframe->redirect($link);
         return;
     }
     $settings = FSS_Settings::GetAllSettings();
     $db = JFactory::getDBO();
     if ($what == "testref") {
         return $this->TestRef();
     } else {
         if ($what == "testdates") {
             return $this->testdates();
         } else {
             if ($what == "send_test_email") {
                 return $this->test_email_send();
             } else {
                 if ($what == "save") {
                     $support_autoclose = JRequest::getInt('support_autoclose');
                     $support_autoclose_duration = JRequest::getInt('support_autoclose_duration');
                     $support_autoclose_audit = JRequest::getInt('support_autoclose_audit');
                     $support_autoclose_email = JRequest::getInt('support_autoclose_email');
                     $aparams = "addaudit:{$support_autoclose_audit};emailuser:{$support_autoclose_email};closeinterval:{$support_autoclose_duration};";
                     $qry = "UPDATE #__fss_cron SET params = '" . FSSJ3Helper::getEscaped($db, $aparams) . "', published = {$support_autoclose}, `interval` = 5 WHERE class = 'AutoClose'";
                     $db->setQuery($qry);
                     //echo $qry."<br>";
                     $db->Query();
                     unset($_POST['support_autoclose']);
                     unset($_POST['support_autoclose_duration']);
                     unset($_POST['support_autoclose_audit']);
                     unset($_POST['support_autoclose_email']);
                     $large = FSS_Settings::GetLargeList();
                     $templates = FSS_Settings::GetTemplateList();
                     // save any large settings that arent in the templates list
                     foreach ($large as $setting) {
                         // skip any setting that is in the templates list
                         if (array_key_exists($setting, $templates)) {
                             continue;
                         }
                         //
                         $value = JRequest::getVar($setting, '', 'post', 'string', JREQUEST_ALLOWRAW);
                         $qry = "REPLACE INTO #__fss_settings_big (setting, value) VALUES ('";
                         $qry .= FSSJ3Helper::getEscaped($db, $setting) . "','";
                         $qry .= FSSJ3Helper::getEscaped($db, $value) . "')";
                         $db->setQuery($qry);
                         $db->Query();
                         $qry = "DELETE FROM #__fss_settings WHERE setting = '" . FSSJ3Helper::getEscaped($db, $setting) . "'";
                         $db->setQuery($qry);
                         $db->Query();
                         unset($_POST[$setting]);
                     }
                     $data = JRequest::get('POST', JREQUEST_ALLOWRAW);
                     foreach ($data as $setting => $value) {
                         if (array_key_exists($setting, $settings)) {
                             $settings[$setting] = $value;
                         }
                     }
                     foreach ($settings as $setting => $value) {
                         if (!array_key_exists($setting, $data)) {
                             $settings[$setting] = 0;
                             $value = 0;
                         }
                         // skip any setting that is in the templates list
                         if (array_key_exists($setting, $templates)) {
                             continue;
                         }
                         if (array_key_exists($setting, $large)) {
                             continue;
                         }
                         $qry = "REPLACE INTO #__fss_settings (setting, value) VALUES ('";
                         $qry .= FSSJ3Helper::getEscaped($db, $setting) . "','";
                         $qry .= FSSJ3Helper::getEscaped($db, $value) . "')";
                         $db->setQuery($qry);
                         $db->Query();
                         //echo $qry."<br>";
                     }
                     FSS_Settings::reload();
                     $msg = JText::_("Settings_Saved");
                     $msgtytpe = "message";
                     if (!FSS_CSSParse::ParseStaticFiles()) {
                         $msg = "<p>Freestyle Support Portal cannot write to the following files:</p>";
                         $msg .= "<ul>";
                         foreach (FSS_CSSParse::$failed as $file) {
                             $msg .= "<li>" . $file . "</li>";
                         }
                         $msg .= "</ul>";
                         $msg .= "<p>Without this it may not display correctly on your site.</p>";
                         $msgtytpe = "error";
                     }
                     $link = 'index.php?option=com_fss&view=settings#' . $this->tab;
                     if (JRequest::getVar('task') == "save") {
                         $link = 'index.php?option=com_fss';
                     }
                     //exit;
                     $mainframe = JFactory::getApplication();
                     $mainframe->redirect($link, $msg, $msgtytpe);
                     return;
                 } else {
                     if ($what == "customtemplate") {
                         $this->CustomTemplate();
                         exit;
                     } else {
                         $qry = "SELECT * FROM #__fss_templates WHERE template = 'custom'";
                         $db->setQuery($qry);
                         $rows = $db->loadAssocList();
                         if (count($rows) > 0) {
                             foreach ($rows as $row) {
                                 if ($row['tpltype']) {
                                     $settings['support_list_head'] = $row['value'];
                                 } else {
                                     $settings['support_list_row'] = $row['value'];
                                 }
                             }
                         } else {
                             $settings['support_list_head'] = '';
                             $settings['support_list_row'] = '';
                         }
                         $qry = "SELECT * FROM #__fss_templates WHERE template = 'usercustom'";
                         $db->setQuery($qry);
                         $rows = $db->loadAssocList();
                         if (count($rows) > 0) {
                             foreach ($rows as $row) {
                                 if ($row['tpltype']) {
                                     $settings['support_user_head'] = $row['value'];
                                 } else {
                                     $settings['support_user_row'] = $row['value'];
                                 }
                             }
                         } else {
                             $settings['support_user_head'] = '';
                             $settings['support_user_row'] = '';
                         }
                         // ##NOT_EXT_START##
                         $qry = "SELECT * FROM #__fss_cron WHERE class = 'AutoClose' LIMIT 1";
                         $db->setQuery($qry);
                         $row = $db->loadAssoc();
                         if ($row) {
                             $settings['support_autoclose'] = $row['published'];
                             $aparams = $this->ParseParams($row['params']);
                             $settings['support_autoclose_duration'] = $aparams['closeinterval'];
                             $settings['support_autoclose_audit'] = $aparams['addaudit'];
                             $settings['support_autoclose_email'] = $aparams['emailuser'];
                         }
                         // ##NOT_EXT_END##
                         $document = JFactory::getDocument();
                         $document->addStyleSheet(JURI::root() . 'administrator/components/com_fss/assets/css/js_color_picker_v2.css');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/color_functions.js');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/js_color_picker_v2.js');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/codemirror/codemirror.js');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/codemirror/modes/css/css.js');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/codemirror/modes/javascript/javascript.js');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/codemirror/modes/xml/xml.js');
                         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/codemirror/modes/htmlmixed/htmlmixed.js');
                         $document->addStyleSheet(JURI::root() . 'administrator/components/com_fss/assets/css/codemirror/codemirror.css');
                         $this->settings = $settings;
                         // load languages
                         $lang = JFactory::getLanguage();
                         $lang->load("com_config");
                         JToolBarHelper::title(JText::_("FREESTYLE_SUPPORT_PORTAL") . ' - ' . JText::_("SETTINGS"), 'fss_settings');
                         JToolBarHelper::apply();
                         JToolBarHelper::save();
                         JToolBarHelper::cancel('cancellist');
                         FSSAdminHelper::DoSubToolbar();
                         parent::display($tpl);
                     }
                 }
             }
         }
     }
 }