Skip to content

Commit

Permalink
Merge branch 'MDL-42467_database' of https://github.com/andyjdavis/mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jun 30, 2014
2 parents 973508d + 607d581 commit 9d8c363
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mod/data/lib.php
Expand Up @@ -3704,7 +3704,7 @@ function data_user_can_delete_preset($context, $preset) {
* @return bool True if the record deleted, false if not.
*/
function data_delete_record($recordid, $data, $courseid, $cmid) {
global $DB;
global $DB, $CFG;

if ($deleterecord = $DB->get_record('data_records', array('id' => $recordid))) {
if ($deleterecord->dataid == $data->id) {
Expand All @@ -3717,6 +3717,12 @@ function data_delete_record($recordid, $data, $courseid, $cmid) {
$DB->delete_records('data_content', array('recordid'=>$deleterecord->id));
$DB->delete_records('data_records', array('id'=>$deleterecord->id));

// Delete cached RSS feeds.
if (!empty($CFG->enablerssfeeds)) {
require_once($CFG->dirroot.'/mod/data/rsslib.php');
data_rss_delete_file($data);
}

// Trigger an event for deleting this record.
$event = \mod_data\event\record_deleted::create(array(
'objectid' => $deleterecord->id,
Expand Down
12 changes: 12 additions & 0 deletions mod/data/rsslib.php
Expand Up @@ -177,3 +177,15 @@ function data_rss_newstuff($data, $time) {
return ($recs && !empty($recs));
}

/**
* Given a database object, deletes all cached RSS files associated with it.
*
* @param stdClass $data
*/
function data_rss_delete_file($data) {
global $CFG;
require_once("$CFG->libdir/rsslib.php");

rss_delete_file('mod_data', $data);
}

6 changes: 6 additions & 0 deletions mod/glossary/deleteentry.php
Expand Up @@ -114,6 +114,12 @@
$rm->delete_ratings($delopt);
}

// Delete cached RSS feeds.
if (!empty($CFG->enablerssfeeds)) {
require_once($CFG->dirroot.'/mod/glossary/rsslib.php');
glossary_rss_delete_file($glossary);
}

$event = \mod_glossary\event\entry_deleted::create(array(
'context' => $context,
'objectid' => $origentry->id,
Expand Down
12 changes: 11 additions & 1 deletion mod/glossary/rsslib.php
Expand Up @@ -196,4 +196,14 @@ function glossary_rss_newstuff($glossary, $time) {
return ($recs && !empty($recs));
}


/**
* Given a glossary object, deletes all cached RSS files associated with it.
*
* @param stdClass $glossary
*/
function glossary_rss_delete_file($glossary) {
global $CFG;
require_once("$CFG->libdir/rsslib.php");

rss_delete_file('mod_glossary', $glossary);
}

0 comments on commit 9d8c363

Please sign in to comment.