Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-26847_amended' of git://github.com/timhunt/moodle

  • Loading branch information...
commit 25bd4d9a375b83655b2d8c82f5f3d6780c321042 2 parents 4386e0d + af7b367
@skodak skodak authored
Showing with 32 additions and 2 deletions.
  1. +32 −2 lib/filestorage/file_storage.php
View
34 lib/filestorage/file_storage.php
@@ -434,14 +434,44 @@ public function delete_area_files($contextid, $component = false, $filearea = fa
$file_records = $DB->get_records('files', $conditions);
foreach ($file_records as $file_record) {
- $stored_file = $this->get_file_instance($file_record);
- $stored_file->delete();
+ $this->get_file_instance($file_record)->delete();
}
return true; // BC only
}
/**
+ * Delete all the files from certain areas where itemid is limited by an
+ * arbitrary bit of SQL.
+ *
+ * @param int $contextid the id of the context the files belong to. Must be given.
+ * @param string $component the owning component. Must be given.
+ * @param string $filearea the file area name. Must be given.
+ * @param string $itemidstest an SQL fragment that the itemid must match. Used
+ * in the query like WHERE itemid $itemidstest. Must used named parameters,
+ * and may not used named parameters called contextid, component or filearea.
+ * @param array $params any query params used by $itemidstest.
+ */
+ public function delete_area_files_select($contextid, $component,
+ $filearea, $itemidstest, array $params = null) {
+ global $DB;
+
+ $where = "contextid = :contextid
+ AND component = :component
+ AND filearea = :filearea
+ AND itemid $itemidstest";
+ $params['contextid'] = $contextid;
+ $params['component'] = $component;
+ $params['filearea'] = $filearea;
+
+ $file_records = $DB->get_recordset_select('files', $where, $params);
+ foreach ($file_records as $file_record) {
+ $this->get_file_instance($file_record)->delete();
+ }
+ $file_records->close();
+ }
+
+ /**
* Move all the files in a file area from one context to another.
* @param integer $oldcontextid the context the files are being moved from.
* @param integer $newcontextid the context the files are being moved to.
Please sign in to comment.
Something went wrong with that request. Please try again.