Commit eba1e9ff authored by Dave Reid's avatar Dave Reid

Issue #1354868: Added hook_xmlsitemap_link_insert() and hook_xmlsitemap_link_update().

parent cf4fa0d9
......@@ -69,6 +69,44 @@ function hook_xmlsitemap_link_alter(&$link) {
}
}
/**
* Inform modules that an XML sitemap link has been created.
*
* @param $link
* Associative array defining an XML sitemap link as passed into
* xmlsitemap_link_save().
*
* @see hook_xmlsitemap_link_update()
*/
function hook_xmlsitemap_link_insert(array $link) {
db_insert('mytable')
->fields(array(
'link_type' => $link['type'],
'link_id' => $link['id'],
'link_status' => $link['status'],
))
->execute();
}
/**
* Inform modules that an XML sitemap link has been updated.
*
* @param $link
* Associative array defining an XML sitemap link as passed into
* xmlsitemap_link_save().
*
* @see hook_xmlsitemap_link_insert()
*/
function hook_xmlsitemap_link_update(array $link) {
db_update('mytable')
->fields(array(
'link_type' => $link['type'],
'link_id' => $link['id'],
'link_status' => $link['status'],
))
->execute();
}
/**
* Index links for the XML sitemaps.
*/
......
......@@ -596,16 +596,16 @@ function xmlsitemap_link_save(array $link) {
_xmlsitemap_check_changed_link($link, $existing, TRUE);
}
// Save the link and allow other modules to respond to the link being saved.
if ($existing) {
drupal_write_record('xmlsitemap', $link, array('type', 'id'));
module_invoke_all('xmlsitemap_link_update', $link);
}
else {
drupal_write_record('xmlsitemap', $link);
module_invoke_all('xmlsitemap_link_insert', $link);
}
// Allow other modules to respond after saving the link.
//module_invoke_all('xmlsitemap_save_link', $link);
return $link;
}
......@@ -682,6 +682,8 @@ function xmlsitemap_link_delete_multiple(array $conditions) {
_xmlsitemap_check_changed_links($conditions, array(), TRUE);
}
// @todo Add a hook_xmlsitemap_link_delete() hook invoked here.
$query = db_delete('xmlsitemap');
foreach ($conditions as $field => $value) {
$query->condition($field, $value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment