Index: lang/en_utf8/data.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/data.php,v
retrieving revision 1.53.4.3
diff -u -r1.53.4.3 data.php
--- lang/en_utf8/data.php	12 Feb 2008 15:06:52 -0000	1.53.4.3
+++ lang/en_utf8/data.php	4 Mar 2008 23:01:13 -0000
@@ -18,9 +18,9 @@
 $string['atmaxentry'] = 'You have entered the maximum number of entries allowed!';
 $string['autogenallforms'] = 'Generate all default templates';
 $string['autolinkurl'] = 'Autolink the URL';
-$string['availablefromdate'] = 'Available from';
+$string['availablefromdate'] = 'Available for submission from';
 $string['availabletags'] = 'Available tags';
-$string['availabletodate'] = 'Available to';
+$string['availabletodate'] = 'Available for submission to';
 $string['blank'] = 'Blank';
 $string['buttons'] = 'Buttons';
 $string['bynameondate'] = 'by $a->name - $a->date';
@@ -166,6 +166,7 @@
 $string['nomaximum'] = 'No maximum';
 $string['norecords'] = 'No entries in database';
 $string['nosingletemplate'] = 'Single template is not yet defined';
+$string['notavailable'] = 'This database is not currently available for adding/editing submissions.';
 $string['notinjectivemap'] = 'Not an injective map';
 $string['number'] = 'Number';
 $string['numberrssarticles'] = 'RSS articles';
Index: mod/data/edit.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/edit.php,v
retrieving revision 1.32.2.1
diff -u -r1.32.2.1 edit.php
--- mod/data/edit.php	12 Oct 2007 16:09:45 -0000	1.32.2.1
+++ mod/data/edit.php	4 Mar 2008 23:01:14 -0000
@@ -73,6 +73,14 @@
         notice(get_string("activityiscurrentlyhidden"));
     }
 
+/// If it's not "available", don't allow editing
+    if (!data_isavailable($data)) {
+        $navigation = build_navigation('', $cm);
+        print_header_simple(format_string($data->name), "", $navigation, "", "", true, '', navmenu($course, $cm));
+        data_show_available_dates($data);
+        notice(get_string("notavailable", "data"));
+    }
+
 /// Can't use this if there are no fields
     if (has_capability('mod/data:managetemplates', $context)) {
         if (!record_exists('data_fields','dataid',$data->id)) {      // Brand new database!
Index: mod/data/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/lib.php,v
retrieving revision 1.137.2.9
diff -u -r1.137.2.9 lib.php
--- mod/data/lib.php	13 Feb 2008 17:01:45 -0000	1.137.2.9
+++ mod/data/lib.php	4 Mar 2008 23:01:15 -0000
@@ -2240,4 +2240,55 @@
 
     return $status;
 }
+
+function data_isviewable($data) {
+    $time = time();
+
+    $isviewable = (!$data->timeviewfrom || $data->timeviewfrom <= $time) &&
+                  (!$data->timeviewto || $data->timeviewto >= $time);
+
+    return $isviewable;
+}
+
+/* database can be modified */
+function data_isavailable($data) {
+  $time = time();
+
+  $isavailable = (!$data->timeavailablefrom || $data->timeavailablefrom <= $time) &&
+                 (!$data->timeavailableto || $data->timeavailableto >= $time);
+
+  return $isavailable;
+}
+
+function data_show_viewable_dates ($data) {
+    print_simple_box_start('center', '', '', 0, 'generalbox', 'dates');
+    echo '<table>';
+    if ($data->timeviewfrom) {
+        echo '<tr><td class="c0">'.get_string('viewfromdate','data').':</td>';
+        echo '    <td class="c1">'.userdate($data->timeviewfrom).'</td></tr>';
+    }
+    if ($data->timeviewto) {
+        echo '<tr><td class="c0">'.get_string('viewtodate','data').':</td>';
+        echo '    <td class="c1">'.userdate($data->timeviewto).'</td></tr>';
+    }
+    echo '</table>';
+    print_simple_box_end();
+
+}
+
+function data_show_available_dates ($data) {
+    print_simple_box_start('center', '', '', 0, 'generalbox', 'dates');
+    echo '<table>';
+    if ($data->timeavailablefrom) {
+        echo '<tr><td class="c0">'.get_string('availablefromdate','data').':</td>';
+        echo '    <td class="c1">'.userdate($data->timeavailablefrom).'</td></tr>';
+    }
+    if ($data->timeavailableto) {
+        echo '<tr><td class="c0">'.get_string('availabletodate','data').':</td>';
+        echo '    <td class="c1">'.userdate($data->timeavailableto).'</td></tr>';
+    }
+    echo '</table>';
+    print_simple_box_end();
+
+}
 ?>
Index: mod/data/styles.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/styles.php,v
retrieving revision 1.3
diff -u -r1.3 styles.php
--- mod/data/styles.php	2 Oct 2006 17:24:55 -0000	1.3
+++ mod/data/styles.php	4 Mar 2008 23:01:15 -0000
@@ -17,3 +17,14 @@
 .presetcontrols form {
   display: inline;
 }
+
+#mod-data-view #dates, #mod-data-edit #dates {
+  font-size: 0.8em;
+  margin-top: 30px;
+  margin-bottom: 30px;
+}
+
+#mod-data-view #dates .c0, #mod-data-edit #dates .c0{
+  text-align:right;
+  font-weight:bold;
+}
Index: mod/data/view.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/view.php,v
retrieving revision 1.70.2.6
diff -u -r1.70.2.6 view.php
--- mod/data/view.php	12 Feb 2008 15:55:34 -0000	1.70.2.6
+++ mod/data/view.php	4 Mar 2008 23:01:15 -0000
@@ -82,6 +82,8 @@
 
     require_course_login($course, true, $cm);
 
+    $viewable = data_isviewable($data);
+
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     require_capability('mod/data:viewentry', $context);
 
@@ -299,7 +301,12 @@
         }
     }
 
-
+    if (!$viewable) {
+      data_show_viewable_dates($data);
+    } else {
+    // the indentation should be increased for this block, but leave it out for
+    // the sake of not complicating the patch (more likely to apply successfully
+    // if this block of code changes).
 
 /// Print the tabs
 
@@ -563,6 +570,7 @@
     if ($records || $search || $page ||  $mode == 'asearch'  && $mode != 'single') {
         data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
     }
+    }
 
 /// If we have blocks, then print the left side here
     if (!empty($CFG->showblocksonmodpages)) {
