From 2becbae4022f6c418aa455e7477c00560bcd8b41 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 24 Feb 2014 20:46:52 -0800 Subject: remote "add bookmark" - like rpost but saves a bookmark from a remote hub into one of your own bookmark folders (or a new one if desired). --- mod/rbmark.php | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mod/rpost.php | 2 +- 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 mod/rbmark.php (limited to 'mod') diff --git a/mod/rbmark.php b/mod/rbmark.php new file mode 100644 index 000000000..1c962152c --- /dev/null +++ b/mod/rbmark.php @@ -0,0 +1,112 @@ +get_channel(); + + $t = array('url' => escape_tags($_REQUEST['url']),'term' => escape_tags($_REQUEST['title'])); + bookmark_add($channel,$channel,$t,((x($_REQUEST,'private')) ? intval($_REQUEST['private']) : 0), + array('menu_id' => ((x($_REQUEST,'menu_id')) ? intval($_REQUEST['menu_id']) : 0), + 'menu_name' => ((x($_REQUEST,'menu_name')) ? escape_tags($_REQUEST['menu_name']) : '') + )); + + goaway(z_root() . '/bookmarks'); + +} + + +function rbmark_content(&$a) { + + $o = ''; + + if(! local_user()) { + + // The login procedure is going to bugger our $_REQUEST variables + // so save them in the session. + + if(array_key_exists('url',$_REQUEST)) { + $_SESSION['bookmark'] = $_REQUEST; + } + return login(); + } + + // If we have saved rbmark session variables, but nothing in the current $_REQUEST, recover the saved variables + + if((! array_key_exists('url',$_REQUEST)) && (array_key_exists('bookmark',$_SESSION))) { + $_REQUEST = $_SESSION['bookmark']; + unset($_SESSION['bookmark']); + } + + if($_REQUEST['remote_return']) { + $_SESSION['remote_return'] = $_REQUEST['remote_return']; + } + if(argc() > 1 && argv(1) === 'return') { + if($_SESSION['remote_return']) + goaway($_SESSION['remote_return']); + goaway(z_root() . '/bookmarks'); + } + + $channel = $a->get_channel(); + + $m = menu_list($channel,'',MENU_BOOKMARK); + $menus = array(); + if($m) { + $menus = array(0 => ''); + foreach($m as $n) { + $menus[$n['menu_id']] = $n['menu_name']; + } + } + $menu_select = array('menu_id',t('Select a bookmark folder'),false,'',$menus); + + + $o .= replace_macros(get_markup_template('rbmark.tpl'), array( + + '$header' => t('Save Bookmark'), + '$url' => array('url',t('URL of bookmark'),escape_tags($_REQUEST['url'])), + '$title' => array('title',t('Description'),escape_tags($_REQUEST['title'])), + '$ischat' => (($ischat) ? 1 : 0), + '$private' => (($private) ? 1 : 0), + '$submit' => t('Save'), + '$menu_name' => array('menu_name',t('Or enter new bookmark folder name'),'',''), + '$menus' => $menu_select + + )); + + + + + + + return $o; + +} + + diff --git a/mod/rpost.php b/mod/rpost.php index 852a57d78..18d4c86cd 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -33,7 +33,7 @@ function rpost_content(&$a) { if(remote_user()) { // redirect to your own site. // We can only do this with a GET request so you'll need to keep the text short or risk getting truncated - // by the wretched beast called 'shusoin'. All the browsers now allow long GET requests, but suhosin + // by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin // blocks them. $url = get_rpost_path($a->get_observer()); -- cgit v1.2.3