|
@@ -1020,6 +1020,27 @@ public function create_directory($contextid, $component, $filearea, $itemid, $fi |
|
|
return $dir_info; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Add new file record to database and handle callbacks. |
|
|
* |
|
|
* @param stdClass $newrecord |
|
|
*/ |
|
|
protected function create_file($newrecord) { |
|
|
global $DB; |
|
|
$newrecord->id = $DB->insert_record('files', $newrecord); |
|
|
|
|
|
if ($newrecord->filename !== '.') { |
|
|
// Callback for file created. |
|
|
if ($pluginsfunction = get_plugins_with_function('after_file_created')) { |
|
|
foreach ($pluginsfunction as $plugintype => $plugins) { |
|
|
foreach ($plugins as $pluginfunction) { |
|
|
$pluginfunction($newrecord); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Add new local file based on existing local file. |
|
|
* |
|
@@ -1134,7 +1155,7 @@ public function create_file_from_storedfile($filerecord, $fileorid) { |
|
|
} |
|
|
|
|
|
try { |
|
|
$newrecord->id = $DB->insert_record('files', $newrecord); |
|
|
$this->create_file($newrecord); |
|
|
} catch (dml_exception $e) { |
|
|
throw new stored_file_creation_exception($newrecord->contextid, $newrecord->component, $newrecord->filearea, $newrecord->itemid, |
|
|
$newrecord->filepath, $newrecord->filename, $e->debuginfo); |
|
@@ -1302,7 +1323,7 @@ public function create_file_from_pathname($filerecord, $pathname) { |
|
|
$newrecord->pathnamehash = $this->get_pathname_hash($newrecord->contextid, $newrecord->component, $newrecord->filearea, $newrecord->itemid, $newrecord->filepath, $newrecord->filename); |
|
|
|
|
|
try { |
|
|
$newrecord->id = $DB->insert_record('files', $newrecord); |
|
|
$this->create_file($newrecord); |
|
|
} catch (dml_exception $e) { |
|
|
if ($newfile) { |
|
|
$this->move_to_trash($newrecord->contenthash); |
|
@@ -1421,7 +1442,7 @@ public function create_file_from_string($filerecord, $content) { |
|
|
$newrecord->pathnamehash = $this->get_pathname_hash($newrecord->contextid, $newrecord->component, $newrecord->filearea, $newrecord->itemid, $newrecord->filepath, $newrecord->filename); |
|
|
|
|
|
try { |
|
|
$newrecord->id = $DB->insert_record('files', $newrecord); |
|
|
$this->create_file($newrecord); |
|
|
} catch (dml_exception $e) { |
|
|
if ($newfile) { |
|
|
$this->move_to_trash($newrecord->contenthash); |
|
|
0 comments on commit
023037d