Binary files moodle/admin/.module.php.swp and /var/www/moodle/admin/.module.php.swp differ
diff -ruN moodle/lang/en_utf8/data.php /var/www/moodle/lang/en_utf8/data.php
--- moodle/lang/en_utf8/data.php	2008-04-02 09:16:01.000000000 +0100
+++ /var/www/moodle/lang/en_utf8/data.php	2008-04-14 15:28:48.000000000 +0100
@@ -42,6 +42,8 @@
 $string['csvimport'] = 'CSV file import';
 $string['data:approve'] = 'Approve unapproved entries';
 $string['data:comment'] = 'Write comments';
+$string['data:deleteownentries'] = 'Delete own entries';
+$string['data:editownentries'] = 'Edit own entries';
 $string['data:managecomments'] = 'Manage comments';
 $string['data:manageentries'] = 'Manage entries';
 $string['data:managetemplates'] = 'Manage templates';
diff -ruN moodle/mod/data/db/access.php /var/www/moodle/mod/data/db/access.php
--- moodle/mod/data/db/access.php	2007-05-15 17:58:05.000000000 +0100
+++ /var/www/moodle/mod/data/db/access.php	2008-04-14 15:16:52.000000000 +0100
@@ -165,8 +165,31 @@
         'legacy' => array(
             'admin' => CAP_ALLOW
         )
-    )
+    ),
 
+    'mod/data:editownentries' => array(
+        'riskbitmask' => RISK_SPAM,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'student' => CAP_ALLOW,
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'mod/data:deleteownentries' => array(
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'student' => CAP_ALLOW,
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
 );
 
 ?>
diff -ruN moodle/mod/data/edit.php /var/www/moodle/mod/data/edit.php
--- moodle/mod/data/edit.php	2008-04-09 16:17:02.000000000 +0100
+++ /var/www/moodle/mod/data/edit.php	2008-04-14 15:43:21.000000000 +0100
@@ -81,8 +81,14 @@
     }
 
     if ($rid) {    // So do you have access?
-        if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) {
-            print_error('noaccess','data');
+        if (!confirm_sesskey()) {
+            print_error('confirmsesskeybad', 'error');
+        }
+
+        if (data_isowner($rid)){
+            require_capability('mod/data:editownentries', $context);
+        }else{
+            require_capability('mod/data:manageentries', $context);
         }
     }
 
diff -ruN moodle/mod/data/lib.php /var/www/moodle/mod/data/lib.php
--- moodle/mod/data/lib.php	2008-04-14 10:20:09.000000000 +0100
+++ /var/www/moodle/mod/data/lib.php	2008-04-14 15:17:29.000000000 +0100
@@ -948,15 +948,23 @@
     /// Replacing special tags (##Edit##, ##Delete##, ##More##)
         $patterns[]='##edit##';
         $patterns[]='##delete##';
-        if (has_capability('mod/data:manageentries', $context) or data_isowner($record->id)) {
+        $isteacher = has_capability('mod/data:manageentries', $context);
+        $isowner = data_isowner($record->id);
+
+        if ($isteacher or ($isowner && has_capability('mod/data:editownentries', $context)) ) {
             $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/edit.php?d='
                              .$data->id.'&amp;rid='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.get_string('edit').'" title="'.get_string('edit').'" /></a>';
+        }else{
+            $replacement[] = '';
+        }
+
+        if($isteacher or ($isowner && has_capability('mod/data:deleteownentries', $context)) ) {
             $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='
                              .$data->id.'&amp;delete='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.get_string('delete').'" title="'.get_string('delete').'" /></a>';
-        } else {
-            $replacement[] = '';
+        }else{
             $replacement[] = '';
         }
+
         $patterns[]='##more##';
         $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id.'"><img src="'.$CFG->pixpath.'/i/search.gif" class="iconsmall" alt="'.get_string('more', 'data').'" title="'.get_string('more', 'data').'" /></a>';
 
diff -ruN moodle/mod/data/version.php /var/www/moodle/mod/data/version.php
--- moodle/mod/data/version.php	2008-03-27 11:16:37.000000000 +0000
+++ /var/www/moodle/mod/data/version.php	2008-04-14 14:46:32.000000000 +0100
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101509;
+$module->version  = 2007101510;
 $module->requires = 2007101509;  // Requires this Moodle version
 $module->cron     = 60;
 
diff -ruN moodle/mod/data/view.php /var/www/moodle/mod/data/view.php
--- moodle/mod/data/view.php	2008-04-02 09:16:06.000000000 +0100
+++ /var/www/moodle/mod/data/view.php	2008-04-14 15:43:42.000000000 +0100
@@ -262,7 +262,18 @@
 
 /// Delete any requested records
 
-    if ($delete && confirm_sesskey() && (has_capability('mod/data:manageentries', $context) or data_isowner($delete))) {
+    if ($delete){
+
+        if (!confirm_sesskey()) {
+            print_error('confirmsesskeybad', 'error');
+        }
+
+        if(data_isowner($delete)){
+            require_capability('mod/data:deleteownentries', $context);
+        }else{
+            require_capability('mod/data:manageentries', $context);
+        }
+
         if ($confirm = optional_param('confirm',0,PARAM_INT)) {
             if ($deleterecord = get_record('data_records', 'id', $delete)) {   // Need to check this is valid
                 if ($deleterecord->dataid == $data->id) {                       // Must be from this database
