diff --git a/mod/data/lang/en/data.php b/mod/data/lang/en/data.php
index 0487fbe625f..5841ddc7a05 100644
--- a/mod/data/lang/en/data.php
+++ b/mod/data/lang/en/data.php
@@ -69,6 +69,7 @@ $string['commentsoff'] = 'Comments feature is not enabled';
$string['configenablerssfeeds'] = 'This switch will enable the possibility of RSS feeds for all databases. You will still need to turn feeds on manually in the settings for each database.';
$string['confirmdeletefield'] = 'You are about to delete this field, are you sure?';
$string['confirmdeleterecord'] = 'Are you sure you want to delete this entry?';
+$string['confirmdeleterecords'] = 'Are you sure you want to delete these entries?';
$string['csstemplate'] = 'CSS template';
$string['csvfailed'] = 'Unable to read the raw data from the CSV file';
$string['csvfile'] = 'CSV file';
@@ -99,6 +100,7 @@ $string['dateentered'] = 'Date entered';
$string['defaultfielddelimiter'] = '(default is the comma character)';
$string['defaultfieldenclosure'] = '(default is none)';
$string['defaultsortfield'] = 'Default sort field';
+$string['delcheck'] = 'Bulk delete checkbox';
$string['delete'] = 'Delete';
$string['deleteallentries'] = 'Delete all entries';
$string['deletecomment'] = 'Are you sure you want to delete this comment?';
diff --git a/mod/data/lib.php b/mod/data/lib.php
index eecd8acfd5f..8e108b9fc23 100644
--- a/mod/data/lib.php
+++ b/mod/data/lib.php
@@ -536,7 +536,13 @@ function data_generate_default_template(&$data, $template, $recordid=0, $form=fa
$table->data[] = $row;
}
- $str = html_writer::start_tag('div', array('class' => 'defaulttemplate'));
+ $str = '';
+ if ($template == 'listtemplate'){
+ $str .= '##delcheck##';
+ $str .= html_writer::empty_tag('br');
+ }
+
+ $str .= html_writer::start_tag('div', array('class' => 'defaulttemplate'));
$str .= html_writer::table($table);
$str .= html_writer::end_tag('div');
if ($template == 'listtemplate'){
@@ -1160,6 +1166,7 @@ function data_grade_item_delete($data) {
*/
function data_print_template($template, $records, $data, $search='', $page=0, $return=false) {
global $CFG, $DB, $OUTPUT;
+
$cm = get_coursemodule_from_instance('data', $data->id);
$context = context_module::instance($cm->id);
@@ -1200,10 +1207,12 @@ function data_print_template($template, $records, $data, $search='', $page=0, $r
$replacement[] = highlight($search, $field->display_browse_field($record->id, $template));
}
+ $canmanageentries = has_capability('mod/data:manageentries', $context);
+
// Replacing special tags (##Edit##, ##Delete##, ##More##)
$patterns[]='##edit##';
$patterns[]='##delete##';
- if (has_capability('mod/data:manageentries', $context) || (!$readonly && data_isowner($record->id))) {
+ if ($canmanageentries || (!$readonly && data_isowner($record->id))) {
$replacement[] = '';
$replacement[] = 'wwwroot.'/user/view.php?id='.$record->userid.
'&course='.$data->course.'">'.fullname($record).'';
@@ -3634,3 +3650,34 @@ function data_user_can_delete_preset($context, $preset) {
return $candelete;
}
}
+
+/**
+ * Delete a record entry.
+ *
+ * @param int $recordid The ID for the record to be deleted.
+ * @param object $data The data object for this activity.
+ * @param int $courseid ID for the current course (for logging).
+ * @param int $cmid The course module ID.
+ * @return bool True if the record deleted, false if not.
+ */
+function data_delete_record($recordid, $data, $courseid, $cmid) {
+ global $DB;
+
+ if ($deleterecord = $DB->get_record('data_records', array('id' => $recordid))) {
+ if ($deleterecord->dataid == $data->id) {
+ if ($contents = $DB->get_records('data_content', array('recordid' => $deleterecord->id))) {
+ foreach ($contents as $content) {
+ if ($field = data_get_field_from_id($content->fieldid, $data)) {
+ $field->delete_content($content->recordid);
+ }
+ }
+ $DB->delete_records('data_content', array('recordid'=>$deleterecord->id));
+ $DB->delete_records('data_records', array('id'=>$deleterecord->id));
+
+ add_to_log($courseid, 'data', 'record delete', "view.php?id=$cmid", $data->id, $cmid);
+ return true;
+ }
+ }
+ }
+ return false;
+}
diff --git a/mod/data/module.js b/mod/data/module.js
new file mode 100644
index 00000000000..12c981c38a6
--- /dev/null
+++ b/mod/data/module.js
@@ -0,0 +1,15 @@
+M.mod_data = {};
+
+M.mod_data.init_view = function(Y) {
+ Y.on('click', function(e) {
+ Y.all('input.recordcheckbox').each(function() {
+ this.set('checked', 'checked');
+ });
+ }, '#checkall');
+
+ Y.on('click', function(e) {
+ Y.all('input.recordcheckbox').each(function() {
+ this.set('checked', '');
+ });
+ }, '#checknone');
+};
\ No newline at end of file
diff --git a/mod/data/templates.php b/mod/data/templates.php
index e7b09b66f57..4a34fb51bb9 100644
--- a/mod/data/templates.php
+++ b/mod/data/templates.php
@@ -253,6 +253,7 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') {
// more points to single template - not useable there
echo '';
echo '';
+ echo '';
}
echo '';
echo '