Skip to content
Snippets Groups Projects
Commit 3feafc8d authored by pancho's avatar pancho Committed by Liam Morland
Browse files

Issue #3038904 by Pancho, Liam Morland: Move all service validation into...

Issue #3038904 by Pancho, Liam Morland: Move all service validation into fillpdf_settings_validate()
parent 59bcd41e
No related branches found
No related tags found
No related merge requests found
......@@ -40,23 +40,6 @@ function fillpdf_settings($form, &$form_state) {
'local' => t('LEGACY. USE FILLPDF LOCALSERVER INSTEAD.'),
);
// Check for FillPDF LocalServer.
$local_status = fillpdf_localservice_check();
if ($local_status === FALSE) {
$options['local_service'] .= '<div class="messages warning">' . t('FillPDF LocalService is not properly installed. Was unable to contact %local_server', array('%local_server' => variable_get('fillpdf_local_service_endpoint'))) . '</div>';
}
// Check for JavaBridge.
if (!(file_exists(drupal_get_path('module', 'fillpdf') . '/lib/JavaBridge/java/Java.inc'))) {
$options['local'] .= '<div class="messages warning">' . t('JavaBridge is not installed locally.') . '</div>';
}
// Check for pdftk.
$status = fillpdf_pdftk_check(fillpdf_pdftk_path());
if ($status === FALSE) {
$options['pdftk'] .= '<div class="messages warning">' . t('pdftk is not properly installed.') . '</div>';
}
$form['fillpdf_service'] = array(
'#type' => 'radios',
'#title' => t('PDF-filling service'),
......@@ -144,12 +127,30 @@ function _fillpdf_scheme_options() {
*
*/
function fillpdf_settings_validate($form, &$form_state) {
if ($form_state['values']['fillpdf_pdftk_path']) {
$status = fillpdf_pdftk_check($form_state['values']['fillpdf_pdftk_path']);
if ($status === FALSE) {
form_set_error('fillpdf_pdftk_path', t('The path you have entered for
<em>pdftk</em> is invalid. Please enter a valid path.'));
}
switch ($form_state['values']['fillpdf_service']) {
case 'local_service':
// Check for FillPDF LocalServer.
$status = fillpdf_localservice_check();
if ($status === FALSE) {
form_set_error('fillpdf_local_service_endpoint', t('FillPDF LocalService is not properly installed. Was unable to contact %local_server', array('%local_server' => $form_state['values']['fillpdf_local_service_endpoint'])));
}
break;
case 'pdftk':
// Check for pdftk.
$status = fillpdf_pdftk_check($form_state['values']['fillpdf_pdftk_path']);
if ($status === FALSE) {
form_set_error('fillpdf_pdftk_path', t('The path you have entered for <em>pdftk</em> is invalid. Please enter a valid path.'));
}
break;
case 'local':
// Check for JavaBridge.
$status = file_exists(drupal_get_path('module', 'fillpdf') . '/lib/JavaBridge/java/Java.inc');
if ($status === FALSE) {
form_set_error('local', t('JavaBridge is not installed locally.'));
}
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment