Index: scheduler.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/scheduler/Attic/scheduler.module,v
retrieving revision 1.50.2.35
diff -u -p -r1.50.2.35 scheduler.module
--- scheduler.module	17 Jan 2010 16:24:33 -0000	1.50.2.35
+++ scheduler.module	18 Mar 2010 18:18:15 -0000
@@ -55,17 +55,51 @@ function scheduler_list_access_callback(
 }
 
 function scheduler_admin() {
+
   $form['scheduler_date_format'] = array(
     '#type' => 'textfield',
     '#title' => t('Date format'),
     '#default_value' => variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT),
     '#size' => 20,
     '#maxlength' => 20,
-    '#description' => t('The input format for the (un)scheduling time/date. See the date() function for formatting options: http://www.php.net/manual/en/function.date.php (only the following format characters are supported (don\'t use \'G\', \'a\' or \'A\' with Date Popup): djmnyYhHgGisaA)'),
+    '#description' => t('The input format for the (un)scheduling time/date. See the date() function for formatting options: http://www.php.net/manual/en/function.date.php (only the following format characters are supported: djmnyYhHgGisaA).'),
   );
+
+  $form['scheduler_field_type'] = array(
+    '#type' => 'radios',
+    '#title' => t('Field type'),
+    '#default_value' => variable_get('scheduler_field_type', 'textfield'),
+    '#options' => array(
+      'textfield' => t('Standard text field'),
+      'date_popup' => t('Date Popup field'),
+    ),
+    '#description' => t("If the Date module's Date Popup module is enabled you may use the popup calendar for your field type."),
+  );
+
+  if (!module_exists('date_popup')) {
+    $form['scheduler_field_type']['#default_value'] = 'textfield';
+    $form['scheduler_field_type']['#disabled'] = TRUE;
+  }
+  else {
+    $acceptable = implode(date_popup_time_formats(), ', ');
+    $form['scheduler_date_format']['#description'] .= t('If you are using Date Popup, the following time formats are supported: !formats', array('!formats' => $acceptable));
+  }
+
   return system_settings_form($form);
 }
 
+function scheduler_admin_validate($form, &$form_state) {
+  if ($form_state['values']['scheduler_field_type'] == 'date_popup') {
+    $format = $form_state['values']['scheduler_date_format'];
+    $time_format = date_limit_format($format, array('hour', 'minute', 'second'));
+    $acceptable = date_popup_time_formats();
+
+    if (!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, ', '))));
+    }
+  }
+}
+
 /**
  * Implementation of hook_form_alter().
  */
@@ -96,7 +130,9 @@ function scheduler_form_alter(&$form, $f
         $node = $form['#node'];
 
         $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);
-        $internal_date_format = module_exists('date_popup') ? SCHEDULER_DATE_FORMAT : $date_format;
+        $use_date_popup = module_exists('date_popup') && variable_get('scheduler_field_type', 'textfield') == 'date_popup';
+
+        $internal_date_format = $use_date_popup ? SCHEDULER_DATE_FORMAT : $date_format;
 
         // if this is a preview then get the values from the form, not the db
         if (isset($form_state['values']['op']) && $form_state['values']['op'] == 'Preview') {
@@ -152,7 +188,7 @@ function scheduler_form_alter(&$form, $f
           '#description' => t('Format: %time. Leave blank to disable scheduled unpublishing.', array('%time' => format_date(time(), 'custom', $date_format))),
         );
 
-        if (module_exists('date_popup')) {
+        if ($use_date_popup) {
           // Make this a popup calendar widget if Date Popup module is enabled.
           $form['scheduler_settings']['publish_on']['#type'] = 'date_popup';
           $form['scheduler_settings']['publish_on']['#date_format'] = $date_format;
@@ -224,7 +260,10 @@ function scheduler_list() {
 function _scheduler_strtotime($str) {
   if ($str && trim($str) != "" ) {
     $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);
-    if (module_exists('date_popup')) {
+
+    $use_date_popup = module_exists('date_popup') && variable_get('scheduler_field_type', 'textfield') == 'date_popup';
+
+    if ($use_date_popup) {
       $date_format = SCHEDULER_DATE_FORMAT;
     }
     $time=_scheduler_strptime(trim($str), $date_format);
