From: dongsheng Date: Thu, 17 Apr 2008 08:11:23 +0000 (+0000) Subject: MDL-11511, revert the changes, see tracker X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=046dd7dcf6ad0d163e83d6490032d43a40f2afd5;p=moodle.git MDL-11511, revert the changes, see tracker --- diff --git a/mod/data/db/access.php b/mod/data/db/access.php index 855ac13a61..71444b3e61 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 9dc6117b5f..40eb0e7a0c 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 7e457aabc1..a5cac29eed 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[] = ''.get_string('edit').''; - }else{ - $replacement[] = ''; - } - - if($candelete) { $replacement[] = ''.get_string('delete').''; - }else{ + } else { $replacement[] = ''; } - $patterns[]='##more##'; $replacement[] = ''.get_string('more', 'data').''; diff --git a/mod/data/version.php b/mod/data/version.php index c4507d5ccf..b399e7a1af 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 bd5670b488..772a52058b 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