2011-06-10 21:55:32 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
|
|
* http://www.mysqldumper.net
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Controllers
|
|
|
|
* @version SVN: $Rev$
|
|
|
|
* @author $Author$
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Config Controller
|
|
|
|
*
|
|
|
|
* Controller to handle actions triggered on configuration screen
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Controllers
|
|
|
|
*/
|
|
|
|
class ConfigController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Active jQuery tab Id
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_activeTab = 'tab_general';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the form on demand.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _buildForm()
|
|
|
|
{
|
|
|
|
$form = new Zend_Form(
|
|
|
|
array(
|
2012-07-23 08:56:12 +00:00
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$form->addElementPrefixPath(
|
|
|
|
'Msd_Form_Decorator',
|
|
|
|
'Msd/Form/Decorator/',
|
|
|
|
'decorator'
|
|
|
|
);
|
|
|
|
$form->addPrefixPath(
|
|
|
|
'Msd_Form_Decorator',
|
|
|
|
'Msd/Form/Decorator/',
|
|
|
|
'decorator'
|
|
|
|
);
|
|
|
|
$form->setAction(
|
|
|
|
$this->view->url(
|
|
|
|
array(
|
2012-07-23 08:56:12 +00:00
|
|
|
'controller' => 'config',
|
|
|
|
'action' => 'index'
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$langs = $this->view->lang->getAvailableLanguages();
|
|
|
|
asort($langs);
|
|
|
|
|
2012-07-23 08:56:12 +00:00
|
|
|
$formGeneral = $this->_getSubformIni('general');
|
2011-06-10 21:55:32 +00:00
|
|
|
$elementTitle = $formGeneral->getElement('title');
|
|
|
|
$elementTitle->setValue(
|
|
|
|
$this->view->config->get('config.general.title')
|
|
|
|
);
|
|
|
|
|
|
|
|
$form->addSubForm($formGeneral, 'general');
|
|
|
|
$form->addSubForm($this->_getPanelDatabases(), 'dbuser');
|
|
|
|
$form->addSubForm($this->_getSubformIni('autodelete'), 'autodelete');
|
|
|
|
$form->addSubForm(new Application_Form_Config_Email(), 'email');
|
|
|
|
$form->addSubForm(new Application_Form_Config_Ftp(), 'ftp');
|
|
|
|
$form->addSubForm($this->_getSubformIni('cronscript'), 'cronscript');
|
|
|
|
|
|
|
|
$formInterface = $this->_getSubformIni('interface');
|
2012-07-23 08:56:12 +00:00
|
|
|
$themeSelect = $formInterface->getElement('theme');
|
2011-06-10 21:55:32 +00:00
|
|
|
$themeSelect->setMultiOptions(Msd_File::getThemeList());
|
|
|
|
$langSelect = $formInterface->getElement('language');
|
|
|
|
$langSelect->setMultiOptions($langs);
|
|
|
|
$form->addSubForm($formInterface, 'interface');
|
|
|
|
|
|
|
|
$form->clearDecorators();
|
|
|
|
$translator = $this->view->lang->getTranslator();
|
|
|
|
|
2012-07-23 08:56:12 +00:00
|
|
|
$saveIcon = $this->view->getIcon('save', $translator->_('L_SAVE'));
|
2011-06-10 21:55:32 +00:00
|
|
|
$form->addElement(
|
|
|
|
'submit',
|
|
|
|
'save',
|
|
|
|
array(
|
2012-07-23 08:56:12 +00:00
|
|
|
'class' => 'Formbutton',
|
|
|
|
'helper' => 'formButton',
|
|
|
|
'content' => $saveIcon . ' ' . $translator->_('L_SAVE'),
|
|
|
|
'escape' => false,
|
|
|
|
'type' => 'submit',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array(
|
|
|
|
'ViewHelper',
|
|
|
|
'Tooltip'
|
|
|
|
)
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$form->addDecorator('ConfigForm');
|
|
|
|
$this->_setFormDefaultValues($form);
|
|
|
|
$this->_setGroupVisibilities($form);
|
|
|
|
$this->view->form = $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index action
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function indexAction()
|
|
|
|
{
|
|
|
|
if ($this->_request->isPost()) {
|
|
|
|
// if language is changed, we need to refresh the config before
|
|
|
|
// the form is rendered
|
|
|
|
$postData = $this->_request->getParams();
|
|
|
|
if (isset($postData['language'])) {
|
|
|
|
$this->view->lang->loadLanguage($postData['language']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->_buildForm();
|
|
|
|
$this->_activeTab = $this->_getParam('selectedTab', 'tab_general');
|
|
|
|
if ($this->_request->isPost()) {
|
|
|
|
$this->_validateForm();
|
|
|
|
}
|
|
|
|
$this->view->currentTab = $this->_activeTab;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get validation errors and look for first tab with errors to jump to
|
|
|
|
*
|
|
|
|
* @param array $messages Form error messages
|
|
|
|
*
|
|
|
|
* @return array Array with messages and first tab to show
|
|
|
|
*/
|
|
|
|
private function _getFormErrors($messages)
|
|
|
|
{
|
2012-07-23 08:56:12 +00:00
|
|
|
$message = array();
|
2011-06-10 21:55:32 +00:00
|
|
|
$firstTab = null;
|
2012-07-23 08:56:12 +00:00
|
|
|
$form = $this->view->form;
|
2011-06-10 21:55:32 +00:00
|
|
|
foreach ($messages as $tabKey => $tabMessage) {
|
|
|
|
foreach ($tabMessage as $inputName => $inputMessage) {
|
|
|
|
foreach ($inputMessage as $messageId => $messageText) {
|
|
|
|
if ($firstTab === null) {
|
|
|
|
$firstTab = 'tab_' . $tabKey;
|
|
|
|
}
|
2012-07-23 08:56:12 +00:00
|
|
|
$subForm = $form->getSubForm($tabKey);
|
|
|
|
$formElement = $subForm->getElement($inputName);
|
2011-06-10 21:55:32 +00:00
|
|
|
$elementClass = $formElement->getAttrib('class');
|
|
|
|
$elementClass .= ' ' . 'inputError';
|
|
|
|
$formElement->setAttrib('class', $elementClass);
|
|
|
|
$message[] = $formElement->getLabel() . ': ' .
|
2012-07-23 08:56:12 +00:00
|
|
|
$this->view->lang->translateZendId(
|
|
|
|
$messageId,
|
|
|
|
$messageText
|
|
|
|
);
|
2011-06-10 21:55:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-23 08:56:12 +00:00
|
|
|
$ret = array();
|
2011-06-10 21:55:32 +00:00
|
|
|
$ret['messages'] = implode('<br />', $message);
|
|
|
|
$ret['firstTab'] = $firstTab;
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get view values for configuration panel databases
|
|
|
|
*
|
2011-11-20 09:17:58 +00:00
|
|
|
* @return Zend_Form_SubForm
|
2011-06-10 21:55:32 +00:00
|
|
|
*/
|
|
|
|
private function _getPanelDatabases()
|
|
|
|
{
|
|
|
|
$formDb = $this->_getSubformIni('dbuser');
|
|
|
|
|
|
|
|
// get database names
|
|
|
|
$dbAdapter = Msd_Db::getAdapter();
|
|
|
|
$databases = $dbAdapter->getDatabaseNames();
|
|
|
|
|
|
|
|
// fill select-options with database names
|
|
|
|
$formDb->getElement('defaultDb')->addMultioptions(
|
|
|
|
array_combine($databases, $databases)
|
|
|
|
);
|
|
|
|
|
2011-10-06 18:00:19 +00:00
|
|
|
// set dynamic actual database if it's changed in the panel
|
|
|
|
if ($this->_request->isPost()) {
|
|
|
|
$actualDb = $this->view->config->get('dynamic.dbActual');
|
|
|
|
if (isset($_POST['defaultDb']) && ($_POST['defaultDb'] != $actualDb)) {
|
|
|
|
$this->view->config->set('dynamic.dbActual', $_POST['defaultDb']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
return $formDb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read ini file and create subform
|
|
|
|
*
|
|
|
|
* @param string $subform
|
|
|
|
*
|
|
|
|
* @return Zend_Form_SubForm
|
|
|
|
*/
|
|
|
|
private function _getSubformIni($subform)
|
|
|
|
{
|
|
|
|
$subFormIni = new Zend_Config_Ini(
|
|
|
|
APPLICATION_PATH . DS . 'forms' . DS . 'Config' . DS . $subform .
|
2012-07-23 08:56:12 +00:00
|
|
|
'.ini'
|
2011-06-10 21:55:32 +00:00
|
|
|
);
|
2012-07-23 08:56:12 +00:00
|
|
|
$options = array('displayGroupPrefixPath' => $subform . '_');
|
2011-06-10 21:55:32 +00:00
|
|
|
return new Zend_Form_SubForm($subFormIni, $options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new Cc-Recipient to email form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function addRecipientCcAction()
|
|
|
|
{
|
|
|
|
$recipientsCc = $this->view->config->get('config.email.RecipientCc');
|
|
|
|
if ($recipientsCc === null) {
|
|
|
|
$recipientsCc = array();
|
|
|
|
}
|
2012-07-23 08:56:12 +00:00
|
|
|
$index = count($recipientsCc);
|
|
|
|
$recipientsCc[$index]['Name'] = '';
|
2011-06-10 21:55:32 +00:00
|
|
|
$recipientsCc[$index]['Address'] = '';
|
2012-07-23 08:56:12 +00:00
|
|
|
$recipientsCc = array_values($recipientsCc);
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->view->config->set('config.email.RecipientCc', $recipientsCc);
|
|
|
|
$this->_forward('index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a Cc-Recipient entry
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function deleteRecipientCcAction()
|
|
|
|
{
|
|
|
|
$recipientToDelete = (int)$this->_request->getPost('param');
|
2012-07-23 08:56:12 +00:00
|
|
|
$recipientsCc = $this->view->config->get('config.email.RecipientCc');
|
2011-06-10 21:55:32 +00:00
|
|
|
if (isset($recipientsCc[$recipientToDelete])) {
|
|
|
|
unset($recipientsCc[$recipientToDelete]);
|
|
|
|
}
|
|
|
|
$this->view->config->set('config.email.RecipientCc', $recipientsCc);
|
|
|
|
$this->_forward('index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new Ftp-Connection
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function addFtpConnectionAction()
|
|
|
|
{
|
|
|
|
$ftpConfig = $this->view->config->get('config.ftp');
|
2012-07-23 08:56:12 +00:00
|
|
|
$index = 0;
|
2011-06-10 21:55:32 +00:00
|
|
|
if (!empty($ftpConfig)) {
|
|
|
|
$index = max(array_keys($ftpConfig)) + 1;
|
|
|
|
}
|
2012-07-23 08:56:12 +00:00
|
|
|
$default = $this->view->config->loadConfiguration(
|
2011-06-10 21:55:32 +00:00
|
|
|
'defaultConfig',
|
|
|
|
false
|
|
|
|
);
|
2012-07-23 08:56:12 +00:00
|
|
|
$default = $default->toArray();
|
2011-06-10 21:55:32 +00:00
|
|
|
$ftpConfig[$index] = $default['ftp'][0];
|
|
|
|
$this->view->config->set('config.ftp', $ftpConfig);
|
|
|
|
$this->_forward('index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete Ftp-Connection
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function deleteFtpConnectionAction()
|
|
|
|
{
|
2012-07-23 08:56:12 +00:00
|
|
|
$index = (int)$this->_request->getPost('param');
|
2011-06-10 21:55:32 +00:00
|
|
|
$ftpConfig = $this->view->config->get('config.ftp');
|
2011-08-08 11:04:43 +00:00
|
|
|
if (count($ftpConfig) > 1) {
|
|
|
|
if (isset($ftpConfig[$index])) {
|
2011-08-08 17:34:43 +00:00
|
|
|
unset($ftpConfig[$index]);
|
|
|
|
sort($ftpConfig);
|
|
|
|
}
|
|
|
|
$this->view->config->set('config.ftp', $ftpConfig);
|
2011-06-10 21:55:32 +00:00
|
|
|
}
|
|
|
|
$this->_forward('index');
|
|
|
|
}
|
|
|
|
|
2012-07-23 08:56:12 +00:00
|
|
|
/**
|
|
|
|
* Test FTP-Connection
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-04-30 18:28:18 +00:00
|
|
|
public function testFtpConnectionAction()
|
|
|
|
{
|
|
|
|
$translator = $this->view->lang->getTranslator();
|
|
|
|
|
|
|
|
if ($this->_request->isPost()) {
|
|
|
|
|
|
|
|
$postData = $this->_request->getPost();
|
2012-07-23 08:56:12 +00:00
|
|
|
$index = (int)$this->_request->getPost('param');
|
2012-04-30 18:28:18 +00:00
|
|
|
|
|
|
|
// fetch the required params
|
2012-07-23 08:56:12 +00:00
|
|
|
$server = $postData['ftp_' . $index . '_server'];
|
|
|
|
$port = $postData['ftp_' . $index . '_port'];
|
|
|
|
$timeout = $postData['ftp_' . $index . '_timeout'];
|
|
|
|
$mode = $postData['ftp_' . $index . '_passiveMode'];
|
|
|
|
$ssl = $postData['ftp_' . $index . '_ssl'];
|
|
|
|
$user = $postData['ftp_' . $index . '_user'];
|
|
|
|
$password = $postData['ftp_' . $index . '_pass'];
|
|
|
|
$directory = $postData['ftp_' . $index . '_dir'];
|
2012-04-30 18:28:18 +00:00
|
|
|
|
|
|
|
// Params for transferring a test file
|
2012-07-23 08:56:12 +00:00
|
|
|
$name = 'ftp_transfer_testfile.txt';
|
|
|
|
$filename = APPLICATION_PATH . '/forms/Config/ftp_transfertest/ftp_transfer_testfile.txt';
|
2012-07-23 08:54:07 +00:00
|
|
|
$targetFolder = APPLICATION_PATH . '/forms/Config/ftp_transfertest/ftp_target/';
|
2012-07-23 08:56:12 +00:00
|
|
|
$upload = false;
|
2012-04-30 18:28:18 +00:00
|
|
|
|
|
|
|
// try to connect via ssl to the ftp server
|
|
|
|
if ($ssl == 'y' && function_exists('ftp_ssl_connect')) {
|
|
|
|
$ftpStream = ftp_ssl_connect($server, $port, $timeout);
|
|
|
|
} else {
|
2012-07-23 08:54:07 +00:00
|
|
|
// otherwise try to connect to the ftp server normally
|
2012-04-30 18:28:18 +00:00
|
|
|
$ftpStream = ftp_connect($server, $port, $timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
// got resource?
|
|
|
|
if (!is_resource($ftpStream)) {
|
|
|
|
$message = sprintf($translator->_('L_FTP_CONNECTION_ERROR'), $server, $port);
|
|
|
|
|
2012-07-23 08:56:12 +00:00
|
|
|
// connection ok? let's try to login
|
2012-04-30 18:28:18 +00:00
|
|
|
} else if (!ftp_login($ftpStream, $user, $password)) {
|
|
|
|
$message = sprintf($translator->_('L_FTP_LOGIN_ERROR'), $user);
|
|
|
|
|
|
|
|
// if passive mode is set turn it on
|
|
|
|
if ($mode == 'y') {
|
|
|
|
ftp_pasv($ftpStream, true);
|
|
|
|
}
|
|
|
|
|
2012-07-23 08:56:12 +00:00
|
|
|
// login ok? let's set/change the ftp upload directory
|
2012-04-30 18:28:18 +00:00
|
|
|
} else if (!ftp_chdir($ftpStream, $directory)) {
|
|
|
|
$message = sprintf($translator->_('L_CHANGEDIRERROR'));
|
2012-07-23 08:56:12 +00:00
|
|
|
// chmod target_folder if it's necessary
|
2012-07-23 08:54:07 +00:00
|
|
|
} else if (file_exists($targetFolder) && substr(sprintf('%o', fileperms($targetFolder)), -4) < '0755') {
|
|
|
|
ftp_chmod($ftpStream, 0755, $targetFolder);
|
2012-04-30 18:28:18 +00:00
|
|
|
$message = '';
|
2012-07-23 08:56:12 +00:00
|
|
|
// ftp directory exists and chmod ok? let's test the ftp transfer with a test file
|
|
|
|
} else if (!ftp_put($ftpStream, $targetFolder . $name, $filename, FTP_ASCII)) {
|
2012-04-30 18:28:18 +00:00
|
|
|
$message = sprintf($translator->_('L_FTP_FILE_TRANSFER_ERROR'), $name);
|
|
|
|
|
|
|
|
} else {
|
2012-07-23 08:56:12 +00:00
|
|
|
$upload = true;
|
2012-04-30 18:28:18 +00:00
|
|
|
$message = sprintf($translator->_('L_FTP_FILE_TRANSFER_SUCCESS'), $name)
|
2012-07-23 08:56:12 +00:00
|
|
|
. '<br /><br />' .
|
|
|
|
$translator->_('L_FTP_OK');
|
2012-04-30 18:28:18 +00:00
|
|
|
|
|
|
|
// delete the test file after a successful transfer test
|
2012-07-23 08:56:12 +00:00
|
|
|
if (file_exists($targetFolder . $name)) {
|
|
|
|
ftp_delete($ftpStream, $targetFolder . $name);
|
2012-04-30 18:28:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// let's show the error messages
|
|
|
|
if (!$upload && count($message) > 0) {
|
|
|
|
$this->view->popUpMessage()->addMessage(
|
2012-07-23 08:54:07 +00:00
|
|
|
'config-validate-error',
|
|
|
|
'L_ERROR',
|
|
|
|
$message,
|
|
|
|
array(
|
|
|
|
'modal' => true
|
|
|
|
)
|
2012-04-30 18:28:18 +00:00
|
|
|
);
|
2012-07-23 08:56:12 +00:00
|
|
|
// or show the confirmation message
|
2012-04-30 18:28:18 +00:00
|
|
|
} else if ($upload && count($message) > 0) {
|
|
|
|
$this->view->popUpMessage()->addMessage(
|
2012-07-23 08:54:07 +00:00
|
|
|
'config-validate-message',
|
|
|
|
'L_NOTICE',
|
|
|
|
$message,
|
|
|
|
array(
|
|
|
|
'modal' => true
|
|
|
|
)
|
2012-04-30 18:28:18 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// close ftp connection
|
|
|
|
ftp_close($ftpStream);
|
|
|
|
}
|
|
|
|
$this->_forward('index');
|
|
|
|
}
|
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
/**
|
|
|
|
* Set the default value of all sub forms to the configuration values
|
|
|
|
*
|
|
|
|
* @param Zend_Form $form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _setFormDefaultValues($form)
|
|
|
|
{
|
|
|
|
$subForms = $form->getSubForms();
|
|
|
|
foreach ($subForms as $subForm) {
|
2012-07-23 08:56:12 +00:00
|
|
|
$group = $subForm->getName();
|
2011-06-10 21:55:32 +00:00
|
|
|
$elements = array_keys($subForm->getElements());
|
|
|
|
foreach ($elements as $element) {
|
2011-08-08 17:34:43 +00:00
|
|
|
$element = str_replace($group . '_', '', $element);
|
|
|
|
$element = str_replace('_', '.', $element);
|
2012-07-23 08:56:12 +00:00
|
|
|
$value = $this->view->config->get(
|
2011-06-10 21:55:32 +00:00
|
|
|
'config.' .
|
2012-07-23 08:56:12 +00:00
|
|
|
$group . '.' .
|
|
|
|
$element
|
2011-06-10 21:55:32 +00:00
|
|
|
);
|
|
|
|
if ($value !== null) {
|
|
|
|
$subForm->setDefault($element, $value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate the config form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _validateForm()
|
|
|
|
{
|
|
|
|
$postData = $this->_request->getPost();
|
2012-07-23 08:56:12 +00:00
|
|
|
$form = $this->view->form;
|
2011-06-10 21:55:32 +00:00
|
|
|
$form->setDefaults($postData);
|
|
|
|
if (isset($postData['save'])) {
|
|
|
|
if (!$form->isValid($postData)) {
|
|
|
|
$errors = $this->_getFormErrors($form->getMessages());
|
|
|
|
if ($errors['messages'] != '') {
|
|
|
|
$this->view->popUpMessage()->addMessage(
|
|
|
|
'config-validate-error',
|
|
|
|
'L_ERROR',
|
|
|
|
$errors['messages'],
|
|
|
|
array(
|
2012-07-23 08:56:12 +00:00
|
|
|
'modal' => true
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
// jump to first tab with validation error
|
|
|
|
$this->_activeTab = $errors['firstTab'];
|
|
|
|
}
|
|
|
|
} else {
|
2012-07-23 08:56:12 +00:00
|
|
|
$configData = $form->getValidValues($postData);
|
|
|
|
$configData = $this->_addNonConfigurableConfigParams($configData);
|
2011-06-10 21:55:32 +00:00
|
|
|
$configValidator =
|
2012-07-23 08:56:12 +00:00
|
|
|
new Application_Model_Config_FormValidator($configData);
|
2011-06-10 21:55:32 +00:00
|
|
|
$configValidator->validate($this->view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:17:37 +00:00
|
|
|
/**
|
|
|
|
* Add configuration params that are not configurable in gui but must be saved.
|
|
|
|
*
|
|
|
|
* @param array $configData The config array
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function _addNonConfigurableConfigParams($configData)
|
|
|
|
{
|
2012-07-23 08:56:12 +00:00
|
|
|
$config = Msd_Configuration::getInstance();
|
2011-08-28 10:17:37 +00:00
|
|
|
$configData['systemDatabases'] = $config->get('config.systemDatabases');
|
|
|
|
return $configData;
|
|
|
|
}
|
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
/**
|
|
|
|
* Set the default visibilities of the display groups inside of the form.
|
|
|
|
* The visibilities depends on the current configuration.
|
|
|
|
*
|
|
|
|
* @param Zend_Form $form The whole form.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _setGroupVisibilities(Zend_Form $form)
|
|
|
|
{
|
2012-07-23 08:56:12 +00:00
|
|
|
$visibilityMap = array(
|
|
|
|
true => 'block',
|
2011-06-10 21:55:32 +00:00
|
|
|
false => 'none',
|
|
|
|
);
|
2012-07-23 08:56:12 +00:00
|
|
|
$emailForm = $form->getSubForm('email');
|
|
|
|
$sendmailConfig = $emailForm->getDisplayGroup('sendmailConfig');
|
|
|
|
$smtpConfig = $emailForm->getDisplayGroup('smtpConfig');
|
2011-06-10 21:55:32 +00:00
|
|
|
$sendmailVisibility = false;
|
2012-07-23 08:56:12 +00:00
|
|
|
$smtpVisibility = false;
|
2011-06-10 21:55:32 +00:00
|
|
|
switch ($this->view->config->get('config.email.Program')) {
|
|
|
|
case 'sendmail':
|
|
|
|
$sendmailVisibility = true;
|
|
|
|
break;
|
|
|
|
case 'smtp':
|
|
|
|
$smtpVisibility = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$sendmailConfig->addAttribs(
|
|
|
|
array(
|
2012-07-23 08:56:12 +00:00
|
|
|
'style' => 'display:'
|
|
|
|
. $visibilityMap[$sendmailVisibility] . ';',
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$smtpConfig->addAttribs(
|
|
|
|
array(
|
2012-07-23 08:56:12 +00:00
|
|
|
'style' => 'display:' . $visibilityMap[$smtpVisibility] . ';',
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|