Don't show shorten link if the link's already short! Only show the shorten link to the item's owner.
This commit is contained in:
parent
e1ad88ab10
commit
dbf31cd320
@ -85,7 +85,7 @@ class Admin_Bitly_Controller extends Admin_Controller {
|
||||
if ($valid_config) {
|
||||
$link = ORM::factory("bitly_link")->where("item_id", "=", 1)->find();
|
||||
if ($link->loaded()) {
|
||||
$view->content->g3_url = "http://" . module::get_var("bitly", "domain") . "/$link->hash";
|
||||
$view->content->g3_url = bitly::bitly_link($link->hash);
|
||||
} else {
|
||||
$view->content->g3_url = bitly::shorten_url(1);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class bitly_Core {
|
||||
|
||||
public static $test_mode = TEST_MODE;
|
||||
|
||||
public static $api_host = "api.bit.ly";
|
||||
@ -207,4 +208,15 @@ class bitly_Core {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a bit.ly link for a specified hash
|
||||
* @param string $hash
|
||||
* @return string
|
||||
*/
|
||||
static function bitly_link($hash) {
|
||||
if (!empty($hash)) {
|
||||
return "http://" . module::get_var("bitly", "domain") . "/$hash";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class bitly_event_Core {
|
||||
|
||||
public static $shorten_link_text = "Shorten link with bit.ly";
|
||||
|
||||
static function admin_menu($menu, $theme) {
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
@ -27,23 +30,25 @@ class bitly_event_Core {
|
||||
}
|
||||
|
||||
static function site_menu($menu, $theme) {
|
||||
if ($theme->item->owner->id == identity::active_user()->id) {
|
||||
$link = ORM::factory("bitly_link")->where("item_id", "=", $theme->item->id)->find();
|
||||
if (!$link->loaded() && $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"))
|
||||
->label(t(self::$shorten_link_text))
|
||||
->url(url::site("bitly/shorten/{$theme->item->id}?csrf=$theme->csrf"))
|
||||
->css_id("g-bitly-link")
|
||||
->css_id("g-bitly-shorten")
|
||||
->css_class("g-bitly-shorten ui-icon-link"));
|
||||
}
|
||||
}
|
||||
|
||||
static function context_menu($menu, $theme, $item) {
|
||||
if ($theme->item->owner->id == identity::active_user()->id) {
|
||||
$link = ORM::factory("bitly_link")->where("item_id", "=", $item->id)->find();
|
||||
if (!$link->loaded() && $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"))
|
||||
->label(t(self::$shorten_link_text))
|
||||
->url(url::site("bitly/shorten/$item->id?csrf=$theme->csrf"))
|
||||
->css_class("g-bitly-shorten ui-icon-link"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user