diff --git a/mod/data/db/access.php b/mod/data/db/access.php
index 855ac13a61a..71444b3e61b 100644
--- a/mod/data/db/access.php
+++ b/mod/data/db/access.php
@@ -165,31 +165,8 @@ $mod_data_capabilities = array(
'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 --git a/mod/data/edit.php b/mod/data/edit.php
index 9dc6117b5fd..40eb0e7a0c5 100755
--- a/mod/data/edit.php
+++ b/mod/data/edit.php
@@ -81,14 +81,8 @@
}
if ($rid) { // So do you have access?
- if (!confirm_sesskey()) {
- print_error('confirmsesskeybad', 'error');
- }
-
- if (data_isowner($rid)){
- require_capability('mod/data:editownentries', $context);
- }else{
- require_capability('mod/data:manageentries', $context);
+ if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) {
+ print_error('noaccess','data');
}
}
diff --git a/mod/data/lib.php b/mod/data/lib.php
index 7e457aabc15..a5cac29eed5 100755
--- a/mod/data/lib.php
+++ b/mod/data/lib.php
@@ -954,25 +954,14 @@ function data_print_template($template, $records, $data, $search='',$page=0, $re
/// Replacing special tags (##Edit##, ##Delete##, ##More##)
$patterns[]='##edit##';
$patterns[]='##delete##';
- $isteacher = has_capability('mod/data:manageentries', $context);
- $isowner = data_isowner($record->id);
- $canedit = $isteacher or ($isowner && has_capability('mod/data:editownentries', $context));
- $candelete = $isteacher or ($isowner && has_capability('mod/data:deleteownentries', $context));
-
- if ($canedit) {
+ if (has_capability('mod/data:manageentries', $context) or data_isowner($record->id)) {
$replacement[] = '
';
- }else{
- $replacement[] = '';
- }
-
- if($candelete) {
$replacement[] = '
';
- }else{
+ } else {
$replacement[] = '';
}
-
$patterns[]='##more##';
$replacement[] = '
';
diff --git a/mod/data/version.php b/mod/data/version.php
index c4507d5ccf1..b399e7a1af9 100644
--- a/mod/data/version.php
+++ b/mod/data/version.php
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2007101510;
+$module->version = 2007101511;
$module->requires = 2007101509; // Requires this Moodle version
$module->cron = 60;
diff --git a/mod/data/view.php b/mod/data/view.php
index bd5670b4883..772a52058b0 100755
--- a/mod/data/view.php
+++ b/mod/data/view.php
@@ -305,18 +305,7 @@
/// Delete any requested records
- 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 ($delete && confirm_sesskey() && (has_capability('mod/data:manageentries', $context) or data_isowner($delete))) {
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