Index: tipping.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tipping/tipping.module,v
retrieving revision 1.6
diff -u -r1.6 tipping.module
--- tipping.module	4 Jun 2008 09:27:21 -0000	1.6
+++ tipping.module	6 Jun 2008 10:42:44 -0000
@@ -159,7 +159,7 @@
 
   $enroled = tipping_is_enroled($user->uid);
   $required_mark = '<span class="form-required" title="'. t('No tips yet.') .'">*</span>';
-  $timelimit = variable_get('tipping_time_limit', 3600);
+  $timelimit = variable_get('tipping_time_limit', 0);
 
   $result = db_query("
     SELECT m.mid, m.timestamp, t1.abbr AS team1, t2.abbr AS team2, tips.goals1 AS tip
@@ -180,7 +180,7 @@
     while ($match = db_fetch_object($result)) {
       $match->team1 = '<strong>'. check_plain($match->team1) .'</strong>';
       $match->team2 = '<strong>'. check_plain($match->team2) .'</strong>';
-      $required = $enroled && !isset($match->tip) && $match->timestamp > (tipping_get_time() + $timelimit);
+      $required = FALSE;
       $items[] = '<span class="next-match">'. format_date($match->timestamp, 'small') .'&ensp;'. $match->team1 .'&ndash;'. $match->team2 . ($required ? $required_mark : '') .'</span>';
       $required_count += $required ? 1 : 0;
     }
@@ -729,13 +729,14 @@
 
 function tipping_admin_settings_form() {
   $form = array();
-  $time_limit_options = array(0 => '0 min', 300 => '5 min', 900 => '15 min', 1800 => '30 min', 3600 => '1 h');
+  $date = variable_get('tipping_time_limit', 0);
   $form['time_limit'] = array(
-    '#type' => 'select',
-    '#title' => t('Tip submission time limit'),
-    '#description' => t('The time before kick-off where player tip submissions are not allowed anymore.'),
-    '#options' => $time_limit_options,
-    '#default_value' => variable_get('tipping_time_limit', 3600),
+   '#type' => 'textfield', 
+   '#title' => t('Tip submission limit'), 
+   '#maxlength' => 25,
+   '#default_value' => date('Y-m-d H:i:s', $date),
+   '#description' => t('The date since player tip submissions are not allowed anymore.'). ' '. t('Format: %time.', array('%time' => date('Y-m-d H:i:s'))),
+   '#attributes' => (module_exists('jscalendar')) ? array('class' => 'jscalendar') : array()
   );
   $form['news'] = array(
     '#type' => 'textfield',
@@ -747,7 +748,7 @@
     '#default_value' => variable_get('tipping_news', ''),
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
-  return system_settings_form($form);
+  return $form;
 }
 
 function tipping_admin_settings_form_validate($form_id, $form_values, $form) {
@@ -763,7 +764,7 @@
 }
 
 function tipping_admin_settings_form_submit($form_id, $form_values) {
-  variable_set('tipping_time_limit', $form_values['time_limit']);
+  variable_set('tipping_time_limit', strtotime($form_values['time_limit']));
   variable_set('tipping_news', $form_values['news']);
   drupal_set_message(t('Settings saved.'));
 }
@@ -829,21 +830,22 @@
   if (!tipping_is_enroled($user->uid)) {
     return tipping_enrol();
   }
-
-  $result = db_query('
-    SELECT m.mid, m.tid1, m.tid2, m.round, m.timestamp, t.tid, t.goals1, t.goals2
-    FROM {tipping_matches} m LEFT JOIN {tipping_tips} t ON t.mid = m.mid AND t.uid = %d
-    WHERE m.tid1 IS NOT NULL AND m.tid2 IS NOT NULL AND m.timestamp > %d
-    ORDER BY m.timestamp', $user->uid, tipping_get_time() + variable_get('tipping_time_limit', 3600));
-  $matches =_tipping_fetch_matches($result);
-
-  if (count($matches)) {
-    if (variable_get('tipping_time_limit', 3600)) {
-      $timelimit = ' '. t('Time limit for tip submission is <em>%timelimit before kick-off</em>.', array('%timelimit' => format_interval(variable_get('tipping_time_limit', 3600))));
+  if (time() < variable_get('tipping_time_limit', 0)) {
+    $result = db_query('
+      SELECT m.mid, m.tid1, m.tid2, m.round, m.timestamp, t.tid, t.goals1, t.goals2
+      FROM {tipping_matches} m LEFT JOIN {tipping_tips} t ON t.mid = m.mid AND t.uid = %d
+      WHERE m.tid1 IS NOT NULL AND m.tid2 IS NOT NULL
+      ORDER BY m.timestamp', $user->uid);
+    $matches =_tipping_fetch_matches($result);
+  
+    if (count($matches)) {
+      if (variable_get('tipping_time_limit', 0)) {
+        $timelimit = ' '. t('Time limit for tip submission is <em>%timelimit</em>.', array('%timelimit' => format_date(variable_get('tipping_time_limit', 0))));
+      }
+  	$output .= '<p>'. t("Enter or change your tips (predictions) for the matches listed below. You don't need to enter all your tips at once.") . $timelimit .' ';
+      $output .= t("Note that as from the round of 16 the score that counts is after 90 minutes (without extra time and penalty kicks).") .'</p>';
+      $output .= drupal_get_form('tipping_tips_form', $matches);
     }
-	$output .= '<p>'. t("Enter or change your tips (predictions) for the matches listed below. You don't need to enter all your tips at once.") . $timelimit .' ';
-    $output .= t("Note that as from the round of 16 the score that counts is after 90 minutes (without extra time and penalty kicks).") .'</p>';
-    $output .= drupal_get_form('tipping_tips_form', $matches);
   }
   else {
     $output .= t('There are no matches to enter tips for.');
