remote post module so that from anywhere on the web or at least within the matrix you'll be able to share content or we can have apps on other sites that post status updates on your wall. All with your permission of course as you'll have to click "share" to actually post it.

This commit is contained in:
friendica 2013-10-27 20:01:28 -07:00
parent c9f51d7860
commit 9b7994a9b7
3 changed files with 96 additions and 4 deletions

View File

@ -1096,7 +1096,7 @@ function status_editor($a,$x,$popup=false) {
'$shortsetloc' => t('set location'), '$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'), '$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'), '$shortnoloc' => t('clear location'),
'$title' => "", '$title' => ((x($x,'title')) ? htmlspecialchars($x['title']) : ''),
'$placeholdertitle' => t('Set title'), '$placeholdertitle' => t('Set title'),
'$catsenabled' => ((feature_enabled($x['profile_uid'],'categories') && (! $webpage)) ? 'categories' : ''), '$catsenabled' => ((feature_enabled($x['profile_uid'],'categories') && (! $webpage)) ? 'categories' : ''),
'$category' => "", '$category' => "",
@ -1105,7 +1105,7 @@ function status_editor($a,$x,$popup=false) {
'$permset' => t('Permission settings'), '$permset' => t('Permission settings'),
'$shortpermset' => t('permissions'), '$shortpermset' => t('permissions'),
'$ptyp' => (($notes_cid) ? 'note' : 'wall'), '$ptyp' => (($notes_cid) ? 'note' : 'wall'),
'$content' => '', '$content' => ((x($x,'body')) ? htmlspecialchars($x['body']) : ''),
'$post_id' => '', '$post_id' => '',
'$baseurl' => $a->get_baseurl(true), '$baseurl' => $a->get_baseurl(true),
'$defloc' => $x['default_location'], '$defloc' => $x['default_location'],

View File

@ -1,4 +1,4 @@
<?php <?php /** @file */
require_once('acl_selectors.php'); require_once('acl_selectors.php');
require_once('include/crypto.php'); require_once('include/crypto.php');
@ -36,6 +36,8 @@ function editpost_content(&$a) {
if(feature_enabled(local_user(),'richtext')) if(feature_enabled(local_user(),'richtext'))
$plaintext = false; $plaintext = false;
$channel = $a->get_channel();
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit post') '$title' => t('Edit post')
)); ));
@ -46,7 +48,7 @@ function editpost_content(&$a) {
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'), '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag, '$geotag' => $geotag,
'$nickname' => $a->user['nickname'] '$nickname' => $channel['channel_address']
)); ));

90
mod/rpost.php Normal file
View File

@ -0,0 +1,90 @@
<?php /** @file */
require_once('acl_selectors.php');
require_once('include/crypto.php');
require_once('include/items.php');
require_once('include/taxonomy.php');
require_once('include/conversation.php');
/**
* remote post
*
* https://yoursite/rpost?f=&title=&body=&remote_return=
*
* This can be called via either GET or POST, use POST for long body content as suhosin often limits GET parameter length
*
* f= placeholder, often required
* title= Title of post
* body= Body of post
* remote_return= absolute URL to return after posting is finished
*
* currently content type is Red Matrix bbcode, though HTML is possible. This is left as an exercise for future developers
*/
function rpost_content(&$a) {
$o = '';
if(! local_user()) {
// FIXME
// probably need to figure out how to preserve the $_REQUEST variables in the session
// in case you aren't currently logged in. Otherwise you'll have to go back to
// the site that sent you here and try again.
return login();
}
if($_REQUEST['remote_return']) {
$_SESSION['remote_return'] = $_REQUEST['remote_return'];
}
if(argc() > 1 && argv(1) === 'return' && $_SESSION['remote_return']) {
goaway($_SESSION['remote_return']);
}
$plaintext = true;
if(feature_enabled(local_user(),'richtext'))
$plaintext = false;
$channel = $a->get_channel();
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit post')
));
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
'$baseurl' => $a->get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $channel['channel_address']
));
$x = array(
'is_owner' => true,
'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''),
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => populate_acl($channel, $false),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
'title' => $_REQUEST['title'],
'body' => $_REQUEST['body'],
'return_path' => 'rpost/return'
);
$o .= status_editor($a,$x);
return $o;
}