aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/navigation.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-06-27 03:12:42 -0700
committerCash Costello <cash.costello@gmail.com>2011-06-27 03:12:42 -0700
commite82534d0bceb80f7a9e7ba8f00748ee1eb32b214 (patch)
treeae8e98a12caa77f78dbfdbc9c492ee808c411c1c /engine/lib/navigation.php
parent33f5c59d5318bc1e9a607215a31e48c6f7ab5b29 (diff)
parentfe1e3b3923659a4bea73e1596e0ba946f473635c (diff)
downloadelgg-e82534d0bceb80f7a9e7ba8f00748ee1eb32b214.tar.gz
elgg-e82534d0bceb80f7a9e7ba8f00748ee1eb32b214.tar.bz2
Merge pull request #52 from cash/banishing-auto-button
Fixes #3616 Banishing auto 'add' button
Diffstat (limited to 'engine/lib/navigation.php')
-rw-r--r--engine/lib/navigation.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4b2c998a2..1cb289654 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -154,6 +154,41 @@ function elgg_is_menu_item_registered($menu_name, $item_name) {
}
/**
+ * Convenience function for registering an add content button to title menu
+ *
+ * The add URL must be $handler/add/$guid where $guid is the guid of the page owner.
+ * The label of the button is "$handler:add" so that must be defined in a
+ * language file.
+ *
+ * @param string $handler The handler to use or null to autodetect from context
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_register_add_button($handler = null) {
+ if (elgg_is_logged_in()) {
+
+ if (!$handler) {
+ $handler = elgg_get_context();
+ }
+
+ $owner = elgg_get_page_owner_entity();
+ if (!$owner) {
+ // no owns the page so this is probably an all site list page
+ $owner = elgg_get_logged_in_user_entity();
+ }
+ if ($owner && $owner->canWriteToContainer()) {
+ $guid = $owner->getGUID();
+ elgg_register_menu_item('title', array(
+ 'name' => 'add',
+ 'href' => "$handler/add/$guid",
+ 'text' => elgg_echo("$handler:add"),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+ }
+ }
+}
+
+/**
* Adds a breadcrumb to the breadcrumbs stack.
*
* @param string $title The title to display