From 4c047fee13514a337a4f6c20e81aa2e8ca693b1c Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Mon, 27 Dec 2010 09:03:08 +0800 Subject: [PATCH] Add check to see if current user is the owner before displaying shorten link menu item. --- 3.1/modules/bitly/helpers/bitly_event.php | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/3.1/modules/bitly/helpers/bitly_event.php b/3.1/modules/bitly/helpers/bitly_event.php index 4074b4e4..29463606 100644 --- a/3.1/modules/bitly/helpers/bitly_event.php +++ b/3.1/modules/bitly/helpers/bitly_event.php @@ -27,22 +27,25 @@ class bitly_event_Core { } static function site_menu($menu, $theme) { - $item = $theme->item(); - $menu->get("options_menu") - ->append(Menu::factory("link") - ->id("bitly") - ->label(t("Shorten link with bit.ly")) - ->url(url::site("bitly/shorten/$item->id?csrf=$theme->csrf")) - ->css_id("g-bitly-link") - ->css_class("g-bitly-shorten ui-icon-link")); + if ($theme->item->owner->id == identity::active_user()->id) { + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("bitly") + ->label(t("Shorten link with bit.ly")) + ->url(url::site("bitly/shorten/{$theme->item->id}?csrf=$theme->csrf")) + ->css_id("g-bitly-link") + ->css_class("g-bitly-shorten ui-icon-link")); + } } static function context_menu($menu, $theme, $item) { - $menu->get("options_menu") - ->append(Menu::factory("link") - ->id("bitly") - ->label(t("Shorten link with bit.ly")) - ->url(url::site("bitly/shorten/$item->id?csrf=$theme->csrf")) - ->css_class("g-bitly-shorten ui-icon-link")); + if ($theme->item->owner->id == identity::active_user()->id) { + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("bitly") + ->label(t("Shorten link with bit.ly")) + ->url(url::site("bitly/shorten/$item->id?csrf=$theme->csrf")) + ->css_class("g-bitly-shorten ui-icon-link")); + } } }