function blog_rss_save_file($type, $id, $tagid = 0, $contents = '') { global $CFG; if (!($basedir = make_upload_directory("rss/blog/{$type}/{$id}"))) { return false; } $file = blog_rss_file_name($type, $id, $tagid); $rss_file = fopen($file, 'w'); if ($rss_file) { $status = fwrite($rss_file, $contents); fclose($rss_file); } else { $status = false; } return $status; }
/** * This function saves to file the rss feed specified in the parameters * * @param string $type The source of the RSS feed (site/course/group/user) * @param int $id The id of the item defined by $type * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @param string $contents The contents of the RSS Feed file * @return bool whether the save was successful or not */ function blog_rss_save_file($type, $id, $tagid = 0, $contents = '') { global $CFG; $status = true; //blog creates some additional dirs within the rss cache so make sure they all exist make_cache_directory('rss/blog'); make_cache_directory('rss/blog/' . $type); $filename = blog_rss_file_name($type, $id, $tagid); $expandfilename = false; //we're supplying a full file path $status = rss_save_file('blog', $filename, $contents, $expandfilename); return $status; }
/** * Delete the supplied user's cached blog post RSS feed. * Only user blogs are available by RSS. * This doesn't call rss_delete_file() as blog RSS caching uses it's own file structure. * * @param int $userid */ function blog_rss_delete_file($userid) { $filename = blog_rss_file_name('user', $userid); if (file_exists($filename)) { unlink($filename); } }