From 1e976ee223460d025e3468e2f94c105077322d8a Mon Sep 17 00:00:00 2001 From: mrded Date: Thu, 9 Aug 2012 11:03:16 +0100 Subject: [PATCH] hide Time field --- scheduler.module | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scheduler.module b/scheduler.module index 48b22d1..2b9edd6 100644 --- a/scheduler.module +++ b/scheduler.module @@ -176,7 +176,7 @@ function scheduler_admin_validate($form, &$form_state) { $time_format = date_limit_format($format, array('hour', 'minute', 'second')); $acceptable = date_popup_time_formats(); - if (!in_array($time_format, $acceptable)) { + if (!empty($time_format) && !in_array($time_format, $acceptable)) { form_set_error('scheduler_date_format', t('The Date Popup module only accepts the following formats: !formats', array('!formats' => implode($acceptable, ', ')))); } } @@ -190,6 +190,22 @@ function _scheduler_use_date_popup() { } /** + * Validate date format for date_popup + * - allowed 'Y-m-d H:i:s' & 'Y-m-d' formats only + * + * @param $date_format + * @return bool + */ +function _scheduler_date_popup_format_validate($date_format) { + $valid_formats = array( + SCHEDULER_DATE_FORMAT, + 'Y-m-d' + ); + + return in_array($date_format, $valid_formats); +} + +/** * Implements hook_form_node_type_form_alter(). */ function scheduler_form_node_type_form_alter(&$form, $form_state) { @@ -481,7 +497,7 @@ function _scheduler_strtotime($str) { if ($str && trim($str) != "" ) { $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT); - if (_scheduler_use_date_popup()) { + if (_scheduler_use_date_popup() && !_scheduler_date_popup_format_validate($date_format)) { $date_format = SCHEDULER_DATE_FORMAT; } $time = _scheduler_strptime(trim($str), $date_format); -- 1.7.9.6 (Apple Git-31.1)