/**
  * Save Config
  */
 function config_save()
 {
     // -------------------------------------------
     //  Advanced Settings
     // -------------------------------------------
     $settings = $this->EE->input->post('settings');
     // empty toolbar
     if ($settings['toolbar'] === 'n') {
         $settings['toolbar'] = array();
     }
     // format_tags
     if (isset($settings['format_tags'])) {
         $settings['format_tags'] = implode(';', $settings['format_tags']);
     }
     // lists
     foreach (Wygwam_helper::config_lists() as $list) {
         if (isset($settings[$list])) {
             $settings[$list] = array_filter(preg_split('/[\\r\\n]+/', $settings[$list]));
         }
     }
     // -------------------------------------------
     //  Save and redirect to Index
     // -------------------------------------------
     $config_id = $this->EE->input->post('config_id');
     $config_name = $this->EE->input->post('config_name');
     if (!$config_name) {
         $config_name = 'Untitled';
     }
     $data = array('config_name' => $config_name, 'settings' => base64_encode(serialize($settings)));
     if ($config_id) {
         $this->EE->db->where('config_id', $config_id);
         $this->EE->db->update('wygwam_configs', $data);
     } else {
         $this->EE->db->insert('wygwam_configs', $data);
     }
     // redirect to Index
     $this->EE->session->set_flashdata('message_success', lang('wygwam_config_saved'));
     $this->EE->functions->redirect(BASE . AMP . $this->base . AMP . 'method=configs');
 }