### Eclipse Workspace Patch 1.0
#P 19stable
Index: mod/data/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/lib.php,v
retrieving revision 1.137.2.55
diff -u -r1.137.2.55 lib.php
--- mod/data/lib.php	21 Apr 2009 14:13:15 -0000	1.137.2.55
+++ mod/data/lib.php	16 Jul 2009 21:33:49 -0000
@@ -920,7 +920,7 @@
     // Replacing special tags (##Edit##, ##Delete##, ##More##)
         $patterns[]='##edit##';
         $patterns[]='##delete##';
-        if (has_capability('mod/data:manageentries', $context) or data_isowner($record->id)) {
+        if (has_capability('mod/data:manageentries', $context) or (data_isowner($record->id) AND (!isguest()))) {
             $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>';
             $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='
Index: mod/data/tabs.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/tabs.php,v
retrieving revision 1.28.2.3
diff -u -r1.28.2.3 tabs.php
--- mod/data/tabs.php	12 Jun 2008 13:49:40 -0000	1.28.2.3
+++ mod/data/tabs.php	16 Jul 2009 21:33:49 -0000
@@ -36,18 +36,19 @@
     $activetwo = NULL;
     $tabs = array();
     $row = array();
-
-    $row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'));
+    if (has_capability('mod/data:viewentry', $context)) {
+        $row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'));
+        
+        if (isset($record)) {
+            $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id, get_string('single','data'));
+        } else {
+            $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=single', get_string('single','data'));
+        }
     
-    if (isset($record)) {
-        $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id, get_string('single','data'));
-    } else {
-        $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=single', get_string('single','data'));
+        // Add an advanced search tab.
+        $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=asearch', get_string('search', 'data'));
     }
 
-    // Add an advanced search tab.
-    $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=asearch', get_string('search', 'data'));
-
     if (isloggedin()) {
         if (data_user_can_add_entry($data, $currentgroup, $groupmode)) { // took out participation list here!
             $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
Index: mod/data/edit.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/edit.php,v
retrieving revision 1.32.2.7
diff -u -r1.32.2.7 edit.php
--- mod/data/edit.php	23 Mar 2009 21:22:52 -0000	1.32.2.7
+++ mod/data/edit.php	16 Jul 2009 21:33:49 -0000
@@ -58,7 +58,7 @@
 
     require_login($course->id, false, $cm);
 
-    if (!isloggedin() or isguest()) {
+    if (!isloggedin()) {
         redirect('view.php?d='.$data->id);
     }
 
Index: mod/data/view.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/view.php,v
retrieving revision 1.70.2.31
diff -u -r1.70.2.31 view.php
--- mod/data/view.php	4 Jun 2009 09:53:20 -0000	1.70.2.31
+++ mod/data/view.php	16 Jul 2009 21:33:49 -0000
@@ -84,7 +84,7 @@
     require_course_login($course, true, $cm);
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-    require_capability('mod/data:viewentry', $context);
+    // require_capability('mod/data:viewentry', $context);
 
 /// If we have an empty Database then redirect because this page is useless without data
     if (has_capability('mod/data:managetemplates', $context)) {
@@ -584,54 +584,55 @@
             }
 
         } else { //  We have some records to print
-
-            if ($maxcount != $totalcount) {
-                $a = new object();
-                $a->num = $totalcount;
-                $a->max = $maxcount;
-                $a->reseturl = "view.php?id=$cm->id&amp;mode=$mode&amp;search=&amp;advanced=0";
-                notify(get_string('foundrecords', 'data', $a), 'notifysuccess'); 
-            }
-
-            if ($mode == 'single') {                  // Single template
-                $baseurl = 'view.php?d=' . $data->id . '&amp;mode=single&amp;';
-                if (!empty($search)) {
-                    $baseurl .= 'filter=1&amp;';
-                }
-                print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
-
-                if (empty($data->singletemplate)){
-                    notify(get_string('nosingletemplate','data'));
-                    data_generate_default_template($data, 'singletemplate', 0, false, false);
+            if (has_capability('mod/data:viewentry', $context)) {
+            
+                if ($maxcount != $totalcount) {
+                    $a = new object();
+                    $a->num = $totalcount;
+                    $a->max = $maxcount;
+                    $a->reseturl = "view.php?id=$cm->id&amp;mode=$mode&amp;search=&amp;advanced=0";
+                    notify(get_string('foundrecords', 'data', $a), 'notifysuccess'); 
                 }
-
-                data_print_template('singletemplate', $records, $data, $search, $page);
-
-                print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
-
-            } else {                                  // List template
-                $baseurl = 'view.php?d='.$data->id.'&amp;';
-                //send the advanced flag through the URL so it is remembered while paging.
-                $baseurl .= 'advanced='.$advanced.'&amp;';
-                if (!empty($search)) {
-                    $baseurl .= 'filter=1&amp;';
-                }
-                //pass variable to allow determining whether or not we are paging through results.
-                $baseurl .= 'paging='.$paging.'&amp;';
-
-                print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
-
-                if (empty($data->listtemplate)){
-                    notify(get_string('nolisttemplate','data'));
-                    data_generate_default_template($data, 'listtemplate', 0, false, false);
+    
+                if ($mode == 'single') {                  // Single template
+                    $baseurl = 'view.php?d=' . $data->id . '&amp;mode=single&amp;';
+                    if (!empty($search)) {
+                        $baseurl .= 'filter=1&amp;';
+                    }
+                    print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
+    
+                    if (empty($data->singletemplate)){
+                        notify(get_string('nosingletemplate','data'));
+                        data_generate_default_template($data, 'singletemplate', 0, false, false);
+                    }
+    
+                    data_print_template('singletemplate', $records, $data, $search, $page);
+    
+                    print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
+    
+                } else {                                  // List template
+                    $baseurl = 'view.php?d='.$data->id.'&amp;';
+                    //send the advanced flag through the URL so it is remembered while paging.
+                    $baseurl .= 'advanced='.$advanced.'&amp;';
+                    if (!empty($search)) {
+                        $baseurl .= 'filter=1&amp;';
+                    }
+                    //pass variable to allow determining whether or not we are paging through results.
+                    $baseurl .= 'paging='.$paging.'&amp;';
+    
+                    print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
+    
+                    if (empty($data->listtemplate)){
+                        notify(get_string('nolisttemplate','data'));
+                        data_generate_default_template($data, 'listtemplate', 0, false, false);
+                    }
+                    echo $data->listtemplateheader;
+                    data_print_template('listtemplate', $records, $data, $search, $page);
+                    echo $data->listtemplatefooter;
+    
+                    print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
                 }
-                echo $data->listtemplateheader;
-                data_print_template('listtemplate', $records, $data, $search, $page);
-                echo $data->listtemplatefooter;
-
-                print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
             }
-
         }
     }
     
