Only in /Applications/MAMP/htdocs/moodle19/mod/data/: .DS_Store
diff -ur /Users/daniele/Desktop/moodle/mod/data/db/access.php /Applications/MAMP/htdocs/moodle19/mod/data/db/access.php
--- /Users/daniele/Desktop/moodle/mod/data/db/access.php	2008-08-18 02:18:05.000000000 +0200
+++ /Applications/MAMP/htdocs/moodle19/mod/data/db/access.php	2008-12-16 14:39:32.000000000 +0100
@@ -167,6 +167,28 @@
         'legacy' => array(
             'admin' => CAP_ALLOW
         )
+    ),
+
+    'mod/data:viewrestricted' => array(
+
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'admin' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'teacher' => CAP_ALLOW
+        )
+    ),
+
+    'mod/data:editrestricted' => array(
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'admin' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'teacher' => CAP_ALLOW
+        )
     )
 
 );
diff -ur /Users/daniele/Desktop/moodle/mod/data/db/install.xml /Applications/MAMP/htdocs/moodle19/mod/data/db/install.xml
--- /Users/daniele/Desktop/moodle/mod/data/db/install.xml	2008-02-27 03:18:20.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/db/install.xml	2008-12-15 17:19:10.000000000 +0100
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/data/db" VERSION="20080226" COMMENT="XMLDB file for Moodle mod/data"
+<XMLDB PATH="mod/data/db" VERSION="20081215" COMMENT="XMLDB file for Moodle mod/data"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
diff -ur /Users/daniele/Desktop/moodle/mod/data/edit.php /Applications/MAMP/htdocs/moodle19/mod/data/edit.php
--- /Users/daniele/Desktop/moodle/mod/data/edit.php	2008-04-18 02:15:51.000000000 +0200
+++ /Applications/MAMP/htdocs/moodle19/mod/data/edit.php	2008-12-16 14:39:48.000000000 +0100
@@ -138,7 +138,6 @@
     }
     include('tabs.php');
 
-
 /// Process incoming data for adding/updating records
 
     if ($datarecord = data_submitted($CFG->wwwroot.'/mod/data/edit.php') and confirm_sesskey()) {
@@ -267,17 +266,33 @@
     /******************************************
      * Regular expression replacement section *
      ******************************************/
-    if ($data->addtemplate){
+    if ($data->addtemplate) {
         $possiblefields = get_records('data_fields','dataid',$data->id,'id');
 
         ///then we generate strings to replace
-        foreach ($possiblefields as $eachfield){
+        foreach ($possiblefields as $eachfield) {
             $field = data_get_field($eachfield, $data);
+            //print_object($field->field);
+            // the description
+            $fieldtoshow = empty($field->field->param9) || (data_user_can_view_restricted($data, $currentgroup, $groupmode));
+            // the field
             $patterns[]="[[".$field->field->name."]]";
-            $replacements[] = $field->display_add_field($rid);
+            // field id
             $patterns[]="[[".$field->field->name."#id]]";
-            $replacements[] = 'field_'.$field->field->id;
+            if ($fieldtoshow) {
+                $replacements[] = $field->display_add_field($rid);
+                $replacements[] = 'field_'.$field->field->id;
+            } else {     
+                $replacements[] = '';
+                $replacements[] = '';
+
+                $patterns[]=$field->field->description;
+                $replacements[] = '';
+            }
         }
+        print_object($patterns);
+        print_object($replacements);
+        //echo '$data->{$mode} = '.$data->{$mode}.'<br />';
         $newtext = str_ireplace($patterns, $replacements, $data->{$mode});
 
     } else {    //if the add template is not yet defined, print the default form!
Only in /Applications/MAMP/htdocs/moodle19/mod/data/field: .DS_Store
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/checkbox/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/checkbox/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/checkbox/mod.html	2006-12-13 03:22:06.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/checkbox/mod.html	2008-12-15 17:13:09.000000000 +0100
@@ -11,4 +11,12 @@
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/date/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/date/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/date/mod.html	2006-12-13 03:22:08.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/date/mod.html	2008-12-15 17:15:16.000000000 +0100
@@ -7,4 +7,12 @@
         <td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/file/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/file/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/file/mod.html	2006-12-13 03:22:09.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/file/mod.html	2008-12-15 17:15:03.000000000 +0100
@@ -18,4 +18,12 @@
             ?>
         </td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/latlong/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/latlong/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/latlong/mod.html	2006-12-13 03:22:10.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/latlong/mod.html	2008-12-15 17:14:53.000000000 +0100
@@ -45,4 +45,12 @@
         <td class="c0">&nbsp;</td>
         <td class="c1"><?php if($this->field->id) {echo "<a href='./field/latlong/kml.php?d=".$this->data->id."&fieldid=".$this->field->id."'>" . get_string('latlongdownloadallhint', 'data') . "</a>"; } ?></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/menu/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/menu/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/menu/mod.html	2006-12-13 03:22:10.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/menu/mod.html	2008-12-15 17:14:38.000000000 +0100
@@ -11,4 +11,12 @@
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/multimenu/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/multimenu/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/multimenu/mod.html	2006-12-13 03:22:12.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/multimenu/mod.html	2008-12-15 17:14:29.000000000 +0100
@@ -11,4 +11,12 @@
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/number/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/number/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/number/mod.html	2006-12-13 03:22:12.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/number/mod.html	2008-12-15 17:14:18.000000000 +0100
@@ -7,4 +7,12 @@
         <td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/picture/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/picture/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/picture/mod.html	2006-12-13 03:22:13.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/picture/mod.html	2008-12-15 17:14:05.000000000 +0100
@@ -50,4 +50,12 @@
             ?>
         </td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/radiobutton/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/radiobutton/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/radiobutton/mod.html	2006-12-13 03:22:14.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/radiobutton/mod.html	2008-12-15 17:13:55.000000000 +0100
@@ -11,4 +11,12 @@
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/text/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/text/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/text/mod.html	2006-12-13 03:22:15.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/text/mod.html	2008-12-16 12:52:19.000000000 +0100
@@ -11,4 +11,12 @@
         <td class="c0"><label for="param1"><?php echo get_string('fieldallowautolink', 'data'); ?></label></td>
         <td class="c1"><input type="checkbox" name="param1" id="param1" <?php if($this->field->param1) {echo 'checked="checked"';} ?> value="1" /></td>
     </tr>
-</table>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+</table>
\ No newline at end of file
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/textarea/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/textarea/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/textarea/mod.html	2007-07-17 04:12:04.000000000 +0200
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/textarea/mod.html	2008-12-15 17:13:34.000000000 +0100
@@ -38,4 +38,12 @@
             ?> /> <?php echo get_string('rows', 'data'); ?>
         </td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/field/url/mod.html /Applications/MAMP/htdocs/moodle19/mod/data/field/url/mod.html
--- /Users/daniele/Desktop/moodle/mod/data/field/url/mod.html	2007-04-16 04:06:17.000000000 +0200
+++ /Applications/MAMP/htdocs/moodle19/mod/data/field/url/mod.html	2008-12-15 17:13:20.000000000 +0100
@@ -15,4 +15,12 @@
         <td class="c0"><label for="param1"><?php echo get_string('autolinkurl', 'data') ?></label></td>
         <td class="c1"><input type="checkbox" name="param1" id="param1" <?php if($this->field->param1) {echo 'checked="checked"';} ?> value="1" /></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="param9"><?php echo get_string('restrictview', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param9" id="param9" <?php if($this->field->param9) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
+        <td class="c0"><label for="param10"><?php echo get_string('restrictedit', 'data'); ?></label></td>
+        <td class="c1"><input class="fielddescription" type="checkbox" name="param10" id="param10" <?php if($this->field->param10) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
diff -ur /Users/daniele/Desktop/moodle/mod/data/lib.php /Applications/MAMP/htdocs/moodle19/mod/data/lib.php
--- /Users/daniele/Desktop/moodle/mod/data/lib.php	2008-11-25 01:21:14.000000000 +0100
+++ /Applications/MAMP/htdocs/moodle19/mod/data/lib.php	2008-12-16 14:40:49.000000000 +0100
@@ -92,6 +92,8 @@
         $this->field->param1 = '';
         $this->field->param2 = '';
         $this->field->param3 = '';
+        $this->field->param9 = '';
+        $this->field->param10 = '';
         $this->field->name = '';
         $this->field->description = '';
         return true;
@@ -160,14 +162,21 @@
 
 // Print the relevant form element in the ADD template for this field
     function display_add_field($recordid=0){
+        global $data, $currentgroup, $groupmode;
         if ($recordid){
             $content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid);
         } else {
             $content = '';
         }
+        //print_object($content);
+        if ($this->field->param10) {
+            data_user_can_edit_restricted($data, $currentgroup, $groupmode) ? $enableflag = '' : $enableflag = ' disabled="disabled"';
+        } else {
+            $enableflag = '';
+        }
 
         $str = '<div title="'.s($this->field->description).'">';
-        $str .= '<input style="width:300px;" type="text" name="field_'.$this->field->id.'" id="field_'.$this->field->id.'" value="'.s($content).'" />';
+        $str .= '<input style="width:300px;"'.$enableflag.' type="text" name="field_'.$this->field->id.'" id="field_'.$this->field->id.'" value="'.s($content).'" />';
         $str .= '</div>';
 
         return $str;
@@ -334,7 +343,7 @@
  * output null
  */
 function data_generate_default_template(&$data, $template, $recordid=0, $form=false, $update=true) {
-
+    global $currentgroup, $groupmode;
     if (!$data && !$template) {
         return false;
     }
@@ -349,31 +358,31 @@
         $str .= '<table cellpadding="5">';
 
         foreach ($fields as $field) {
-
-            $str .= '<tr><td valign="top" align="right">';
-            // Yu: commenting this out, the id was wrong and will fix later
-            //if ($template == 'addtemplate') {
-                //$str .= '<label';
-                //if (!in_array($field->type, array('picture', 'checkbox', 'date', 'latlong', 'radiobutton'))) {
-                //    $str .= ' for="[['.$field->name.'#id]]"';
+            if ( ($field->param9 == 0) || (data_user_can_view_restricted($data, $currentgroup, $groupmode)) ) { //
+                $str .= '<tr><td valign="top" align="right">';
+                // Yu: commenting this out, the id was wrong and will fix later
+                //if ($template == 'addtemplate') {
+                    //$str .= '<label';
+                    //if (!in_array($field->type, array('picture', 'checkbox', 'date', 'latlong', 'radiobutton'))) {
+                    //    $str .= ' for="[['.$field->name.'#id]]"';
+                    //}
+                    //$str .= '>'.$field->name.'</label>';
+                    
+                //} else {
+                    $str .= $field->name.': ';
                 //}
-                //$str .= '>'.$field->name.'</label>';
-                
-            //} else {
-                $str .= $field->name.': ';
-            //}
-            $str .= '</td>';
-
-            $str .='<td>';
-            if ($form) {   // Print forms instead of data
-                $fieldobj = data_get_field($field, $data);
-                $str .= $fieldobj->display_add_field($recordid);
-
-            } else {           // Just print the tag
-                $str .= '[['.$field->name.']]';
+                $str .= '</td>';
+    
+                $str .='<td>';
+                if ($form) {   // Print forms instead of data
+                    $fieldobj = data_get_field($field, $data);
+                    $str .= $fieldobj->display_add_field($recordid);
+    
+                } else {           // Just print the tag
+                    $str .= '[['.$field->name.']]';
+                }
+                $str .= '</td></tr>';
             }
-            $str .= '</td></tr>';
-
         }
         if ($template == 'listtemplate') {
             $str .= '<tr><td align="center" colspan="2">##edit##  ##more##  ##delete##  ##approve##</td></tr>';
@@ -1663,6 +1672,56 @@
     }
 }
 
+function data_user_can_view_restricted($data, $currentgroup, $groupmode) {
+    global $USER;
+    if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
+        error('Course Module ID was incorrect');
+    }
+    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+    if (!has_capability('mod/data:viewrestricted', $context) and !has_capability('mod/data:manageentries',$context)) {
+        return false;
+    }
+    if (!$groupmode or has_capability('moodle/site:accessallgroups', $context)) {
+        return true;
+    }
+
+    if ($currentgroup) {
+        return groups_is_member($currentgroup);
+    } else {
+        //else it might be group 0 in visible mode
+        if ($groupmode == VISIBLEGROUPS){
+            return true;
+        } else {
+            return false;
+        }
+    }
+}
+
+function data_user_can_edit_restricted($data, $currentgroup, $groupmode) {
+    global $USER;
+    if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
+        error('Course Module ID was incorrect');
+    }
+    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+    if (!has_capability('mod/data:editrestricted', $context) and !has_capability('mod/data:manageentries',$context)) {
+        return false;
+    }
+    if (!$groupmode or has_capability('moodle/site:accessallgroups', $context)) {
+        return true;
+    }
+
+    if ($currentgroup) {
+        return groups_is_member($currentgroup);
+    } else {
+        //else it might be group 0 in visible mode
+        if ($groupmode == VISIBLEGROUPS){
+            return true;
+        } else {
+            return false;
+        }
+    }
+}
+
 
 function is_directory_a_preset($directory) {
     $directory = rtrim($directory, '/\\') . '/';
diff -ur /Users/daniele/Desktop/moodle/mod/data/version.php /Applications/MAMP/htdocs/moodle19/mod/data/version.php
--- /Users/daniele/Desktop/moodle/mod/data/version.php	2008-08-18 02:18:05.000000000 +0200
+++ /Applications/MAMP/htdocs/moodle19/mod/data/version.php	2008-12-16 14:49:50.000000000 +0100
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101513;
+$module->version  = 2008121600;
 $module->requires = 2007101509;  // Requires this Moodle version
 $module->cron     = 60;
 
