summaryrefslogtreecommitdiff
path: root/modules/menu
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-17 04:07:40 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-17 04:07:40 +0000
commitc9cac770bede964e0c187e08c0e4a5aac2300116 (patch)
tree3a6533ccfd24dc5494174cab0f80df94fa6375e0 /modules/menu
parent78737e8366ff2137d8876a0b39d38a083bac2de1 (diff)
downloadbrdo-c9cac770bede964e0c187e08c0e4a5aac2300116.tar.gz
brdo-c9cac770bede964e0c187e08c0e4a5aac2300116.tar.bz2
#457450 by agentrickard: Added hooks to track changes to menu links.
Diffstat (limited to 'modules/menu')
-rw-r--r--modules/menu/menu.api.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/modules/menu/menu.api.php b/modules/menu/menu.api.php
index bf37caae3..99fcb8e20 100644
--- a/modules/menu/menu.api.php
+++ b/modules/menu/menu.api.php
@@ -147,6 +147,78 @@ function hook_translated_menu_link_alter(&$item, $map) {
}
}
+ /**
+ * Inform modules that a menu link has been created.
+ *
+ * This hook is used to notify module that menu items have been
+ * created. Contributed modules may use the information to perform
+ * actions based on the information entered into the menu system.
+ *
+ * @param $link
+ * The $link record saved into the {menu_links} table.
+ * @return
+ * None.
+ *
+ * @see hook_menu_link_update()
+ * @see hook_menu_link_delete()
+ */
+function hook_menu_link_insert($link) {
+ // In our sample case, we track menu items as editing sections
+ // of the site. These are stored in our table as 'disabled' items.
+ $record['mlid'] = $link['mlid'];
+ $record['menu_name'] = $link['menu_name'];
+ $record['status'] = 0;
+ drupal_write_record('menu_example', $record);
+}
+
+/**
+ * Inform modules that a menu link has been updated.
+ *
+ * This hook is used to notify module that menu items have been
+ * updated. Contributed modules may use the information to perform
+ * actions based on the information entered into the menu system.
+ *
+ * @param $link
+ * The $link record saved into the {menu_links} table.
+ * @return
+ * None.
+ *
+ * @see hook_menu_link_insert()
+ * @see hook_menu_link_delete()
+ */
+function hook_menu_link_update($link) {
+ // If the parent menu has changed, update our record.
+ $menu_name = db_result(db_query("SELECT mlid, menu_name, status FROM {menu_example} WHERE mlid = :mlid", array(':mlid' => $link['mlid'])));
+ if ($menu_name != $link['menu_name']) {
+ db_update('menu_example')
+ ->fields(array('menu_name' => $link['menu_name']))
+ ->condition('mlid', $link['mlid'])
+ ->execute();
+ }
+}
+
+/**
+ * Inform modules that a menu link has been deleted.
+ *
+ * This hook is used to notify module that menu items have been
+ * deleted. Contributed modules may use the information to perform
+ * actions based on the information entered into the menu system.
+ *
+ * @param $link
+ * The $link record saved into the {menu_links} table.
+ * @return
+ * None.
+ *
+ * @see hook_menu_link_insert()
+ * @see hook_menu_link_update()
+ */
+function hook_menu_link_delete($link) {
+ // Delete the record from our table.
+ db_delete('menu_example')
+ ->condition('mlid', $link['mlid'])
+ ->execute();
+}
+
/**
* @} End of "addtogroup hooks".
*/