Removing blanks with tabs
This commit is contained in:
parent
2275f7e327
commit
ca9bd8b877
|
@ -69,7 +69,7 @@ function fbpost_init(&$a) {
|
|||
|
||||
if(strlen($nick))
|
||||
$r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
||||
dbesc($nick)
|
||||
dbesc($nick)
|
||||
);
|
||||
if(!(isset($r) && count($r)))
|
||||
return;
|
||||
|
@ -154,7 +154,7 @@ function fbpost_post(&$a) {
|
|||
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
|
||||
if (count($result) > 0) {
|
||||
set_pconfig(local_user(),'fbsync','sync',intval($_POST['fbsync']));
|
||||
set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
|
||||
set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
|
||||
}
|
||||
|
||||
info( t('Settings updated.') . EOL);
|
||||
|
@ -316,11 +316,11 @@ function fbpost_content(&$a) {
|
|||
|
||||
$o .= '<div class="clear"></div>';
|
||||
|
||||
$sync_enabled = get_pconfig(local_user(),'fbsync','sync');
|
||||
$sync_enabled = get_pconfig(local_user(),'fbsync','sync');
|
||||
$checked = (($sync_enabled) ? ' checked="checked" ' : '');
|
||||
$o .= '<input type="checkbox" name="fbsync" value="1"' . $checked . '/>' . ' ' . t('Import Facebook newsfeed.') . EOL;
|
||||
|
||||
$create_user = get_pconfig(local_user(),'fbsync','create_user');
|
||||
$create_user = get_pconfig(local_user(),'fbsync','create_user');
|
||||
$checked = (($create_user) ? ' checked="checked" ' : '');
|
||||
$o .= '<input type="checkbox" name="create_user" value="1"' . $checked . '/>' . ' ' . t('Automatically create contacts.') . EOL;
|
||||
|
||||
|
|
355
pumpio/pumpio.php
Executable file → Normal file
355
pumpio/pumpio.php
Executable file → Normal file
|
@ -11,23 +11,23 @@ require('addon/pumpio/oauth/oauth_client.php');
|
|||
define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||
|
||||
function pumpio_install() {
|
||||
register_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||
register_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||
register_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||
register_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||
register_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||
register_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||
register_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||
register_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||
register_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||
register_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||
register_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||
register_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||
register_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||
register_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||
}
|
||||
|
||||
function pumpio_uninstall() {
|
||||
unregister_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||
unregister_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||
unregister_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||
unregister_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||
unregister_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||
unregister_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||
unregister_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||
unregister_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||
unregister_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||
unregister_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||
unregister_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||
unregister_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||
unregister_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||
unregister_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||
}
|
||||
|
||||
function pumpio_module() {}
|
||||
|
@ -61,37 +61,37 @@ function pumpio_registerclient(&$a, $host) {
|
|||
|
||||
$url = "https://".$host."/api/client/register";
|
||||
|
||||
$params = array();
|
||||
$params = array();
|
||||
|
||||
$application_name = get_config('pumpio', 'application_name');
|
||||
|
||||
if ($application_name == "")
|
||||
$application_name = $a->get_hostname();
|
||||
|
||||
$params["type"] = "client_associate";
|
||||
$params["contacts"] = $a->config['admin_email'];
|
||||
$params["application_type"] = "native";
|
||||
$params["application_name"] = $application_name;
|
||||
$params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
|
||||
$params["redirect_uris"] = $a->get_baseurl()."/pumpio/connect";
|
||||
$params["type"] = "client_associate";
|
||||
$params["contacts"] = $a->config['admin_email'];
|
||||
$params["application_type"] = "native";
|
||||
$params["application_name"] = $application_name;
|
||||
$params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
|
||||
$params["redirect_uris"] = $a->get_baseurl()."/pumpio/connect";
|
||||
|
||||
logger("pumpio_registerclient: ".$url." parameters ".print_r($params, true), LOGGER_DEBUG);
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
|
||||
|
||||
$s = curl_exec($ch);
|
||||
$curl_info = curl_getinfo($ch);
|
||||
$s = curl_exec($ch);
|
||||
$curl_info = curl_getinfo($ch);
|
||||
|
||||
if ($curl_info["http_code"] == "200") {
|
||||
$values = json_decode($s);
|
||||
if ($curl_info["http_code"] == "200") {
|
||||
$values = json_decode($s);
|
||||
logger("pumpio_registerclient: success ".print_r($values, true), LOGGER_DEBUG);
|
||||
return($values);
|
||||
}
|
||||
}
|
||||
logger("pumpio_registerclient: failed: ".print_r($curl_info, true), LOGGER_DEBUG);
|
||||
return(false);
|
||||
|
||||
|
@ -156,10 +156,10 @@ function pumpio_connect(&$a) {
|
|||
}
|
||||
$success = $client->Finalize($success);
|
||||
}
|
||||
if($client->exit)
|
||||
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
|
||||
if($client->exit)
|
||||
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
|
||||
|
||||
if($success) {
|
||||
if($success) {
|
||||
logger("pumpio_connect: authenticated");
|
||||
$o .= t("You are now authenticated to pumpio.");
|
||||
$o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.t("return to the connector page").'</a>';
|
||||
|
@ -172,118 +172,117 @@ function pumpio_connect(&$a) {
|
|||
}
|
||||
|
||||
function pumpio_jot_nets(&$a,&$b) {
|
||||
if(! local_user())
|
||||
return;
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
$pumpio_post = get_pconfig(local_user(),'pumpio','post');
|
||||
if(intval($pumpio_post) == 1) {
|
||||
$pumpio_defpost = get_pconfig(local_user(),'pumpio','post_by_default');
|
||||
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
|
||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="pumpio_enable"' . $selected . ' value="1" /> '
|
||||
. t('Post to pumpio') . '</div>';
|
||||
}
|
||||
$pumpio_post = get_pconfig(local_user(),'pumpio','post');
|
||||
if(intval($pumpio_post) == 1) {
|
||||
$pumpio_defpost = get_pconfig(local_user(),'pumpio','post_by_default');
|
||||
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
|
||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="pumpio_enable"' . $selected . ' value="1" /> '
|
||||
. t('Post to pumpio') . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pumpio_settings(&$a,&$s) {
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pumpio/pumpio.css' . '" media="all" />' . "\r\n";
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pumpio/pumpio.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
/* Get the current state of our config variables */
|
||||
/* Get the current state of our config variables */
|
||||
|
||||
$import_enabled = get_pconfig(local_user(),'pumpio','import');
|
||||
$import_checked = (($import_enabled) ? ' checked="checked" ' : '');
|
||||
$import_enabled = get_pconfig(local_user(),'pumpio','import');
|
||||
$import_checked = (($import_enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$enabled = get_pconfig(local_user(),'pumpio','post');
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
$enabled = get_pconfig(local_user(),'pumpio','post');
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
|
||||
$def_enabled = get_pconfig(local_user(),'pumpio','post_by_default');
|
||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||
$def_enabled = get_pconfig(local_user(),'pumpio','post_by_default');
|
||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$public_enabled = get_pconfig(local_user(),'pumpio','public');
|
||||
$public_checked = (($public_enabled) ? ' checked="checked" ' : '');
|
||||
$public_enabled = get_pconfig(local_user(),'pumpio','public');
|
||||
$public_checked = (($public_enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$mirror_enabled = get_pconfig(local_user(),'pumpio','mirror');
|
||||
$mirror_checked = (($mirror_enabled) ? ' checked="checked" ' : '');
|
||||
$mirror_enabled = get_pconfig(local_user(),'pumpio','mirror');
|
||||
$mirror_checked = (($mirror_enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$servername = get_pconfig(local_user(), "pumpio", "host");
|
||||
$username = get_pconfig(local_user(), "pumpio", "user");
|
||||
$servername = get_pconfig(local_user(), "pumpio", "host");
|
||||
$username = get_pconfig(local_user(), "pumpio", "user");
|
||||
|
||||
/* Add some HTML to the existing form */
|
||||
/* Add some HTML to the existing form */
|
||||
|
||||
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$s .= '<div id="pumpio-username-wrapper">';
|
||||
$s .= '<label id="pumpio-username-label" for="pumpio-username">'.t('pump.io username (without the servername)').'</label>';
|
||||
$s .= '<input id="pumpio-username" type="text" name="pumpio_user" value="'.$username.'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-username-wrapper">';
|
||||
$s .= '<label id="pumpio-username-label" for="pumpio-username">'.t('pump.io username (without the servername)').'</label>';
|
||||
$s .= '<input id="pumpio-username" type="text" name="pumpio_user" value="'.$username.'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pumpio-servername-wrapper">';
|
||||
$s .= '<label id="pumpio-servername-label" for="pumpio-servername">'.t('pump.io servername (without "http://" or "https://" )').'</label>';
|
||||
$s .= '<input id="pumpio-servername" type="text" name="pumpio_host" value="'.$servername.'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-servername-wrapper">';
|
||||
$s .= '<label id="pumpio-servername-label" for="pumpio-servername">'.t('pump.io servername (without "http://" or "https://" )').'</label>';
|
||||
$s .= '<input id="pumpio-servername" type="text" name="pumpio_host" value="'.$servername.'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
if (($username != '') AND ($servername != '')) {
|
||||
if (($username != '') AND ($servername != '')) {
|
||||
|
||||
$oauth_token = get_pconfig(local_user(), "pumpio", "oauth_token");
|
||||
$oauth_token_secret = get_pconfig(local_user(), "pumpio", "oauth_token_secret");
|
||||
$oauth_token = get_pconfig(local_user(), "pumpio", "oauth_token");
|
||||
$oauth_token_secret = get_pconfig(local_user(), "pumpio", "oauth_token_secret");
|
||||
|
||||
$s .= '<div id="pumpio-password-wrapper">';
|
||||
if (($oauth_token == "") OR ($oauth_token_secret == "")) {
|
||||
$s .= '<div id="pumpio-authenticate-wrapper">';
|
||||
$s .= '<a href="'.$a->get_baseurl().'/pumpio/connect">'.t("Authenticate your pump.io connection").'</a>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
} else {
|
||||
$s .= '<div id="pumpio-import-wrapper">';
|
||||
$s .= '<label id="pumpio-import-label" for="pumpio-import">' . t('Import the remote timeline') . '</label>';
|
||||
$s .= '<input id="pumpio-import" type="checkbox" name="pumpio_import" value="1" ' . $import_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-password-wrapper">';
|
||||
if (($oauth_token == "") OR ($oauth_token_secret == "")) {
|
||||
$s .= '<div id="pumpio-authenticate-wrapper">';
|
||||
$s .= '<a href="'.$a->get_baseurl().'/pumpio/connect">'.t("Authenticate your pump.io connection").'</a>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
} else {
|
||||
$s .= '<div id="pumpio-import-wrapper">';
|
||||
$s .= '<label id="pumpio-import-label" for="pumpio-import">' . t('Import the remote timeline') . '</label>';
|
||||
$s .= '<input id="pumpio-import" type="checkbox" name="pumpio_import" value="1" ' . $import_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pumpio-enable-wrapper">';
|
||||
$s .= '<label id="pumpio-enable-label" for="pumpio-checkbox">' . t('Enable pump.io Post Plugin') . '</label>';
|
||||
$s .= '<input id="pumpio-checkbox" type="checkbox" name="pumpio" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-enable-wrapper">';
|
||||
$s .= '<label id="pumpio-enable-label" for="pumpio-checkbox">' . t('Enable pump.io Post Plugin') . '</label>';
|
||||
$s .= '<input id="pumpio-checkbox" type="checkbox" name="pumpio" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pumpio-bydefault-wrapper">';
|
||||
$s .= '<label id="pumpio-bydefault-label" for="pumpio-bydefault">' . t('Post to pump.io by default') . '</label>';
|
||||
$s .= '<input id="pumpio-bydefault" type="checkbox" name="pumpio_bydefault" value="1" ' . $def_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-bydefault-wrapper">';
|
||||
$s .= '<label id="pumpio-bydefault-label" for="pumpio-bydefault">' . t('Post to pump.io by default') . '</label>';
|
||||
$s .= '<input id="pumpio-bydefault" type="checkbox" name="pumpio_bydefault" value="1" ' . $def_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pumpio-public-wrapper">';
|
||||
$s .= '<label id="pumpio-public-label" for="pumpio-public">' . t('Should posts be public?') . '</label>';
|
||||
$s .= '<input id="pumpio-public" type="checkbox" name="pumpio_public" value="1" ' . $public_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-public-wrapper">';
|
||||
$s .= '<label id="pumpio-public-label" for="pumpio-public">' . t('Should posts be public?') . '</label>';
|
||||
$s .= '<input id="pumpio-public" type="checkbox" name="pumpio_public" value="1" ' . $public_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pumpio-mirror-wrapper">';
|
||||
$s .= '<label id="pumpio-mirror-label" for="pumpio-mirror">' . t('Mirror all public posts') . '</label>';
|
||||
$s .= '<input id="pumpio-mirror" type="checkbox" name="pumpio_mirror" value="1" ' . $mirror_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="pumpio-mirror-wrapper">';
|
||||
$s .= '<label id="pumpio-mirror-label" for="pumpio-mirror">' . t('Mirror all public posts') . '</label>';
|
||||
$s .= '<input id="pumpio-mirror" type="checkbox" name="pumpio_mirror" value="1" ' . $mirror_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pumpio-delete-wrapper">';
|
||||
$s .= '<label id="pumpio-delete-label" for="pumpio-delete">' . t('Check to delete this preset') . '</label>';
|
||||
$s .= '<input id="pumpio-delete" type="checkbox" name="pumpio_delete" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
}
|
||||
|
||||
$s .= '<div id="pumpio-delete-wrapper">';
|
||||
$s .= '<label id="pumpio-delete-label" for="pumpio-delete">' . t('Check to delete this preset') . '</label>';
|
||||
$s .= '<input id="pumpio-delete" type="checkbox" name="pumpio_delete" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
}
|
||||
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
}
|
||||
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||
}
|
||||
|
||||
|
||||
|
@ -591,28 +590,28 @@ function pumpio_action(&$a, $uid, $uri, $action, $content) {
|
|||
|
||||
|
||||
function pumpio_cron(&$a,$b) {
|
||||
$last = get_config('pumpio','last_poll');
|
||||
$last = get_config('pumpio','last_poll');
|
||||
|
||||
$poll_interval = intval(get_config('pumpio','poll_interval'));
|
||||
if(! $poll_interval)
|
||||
$poll_interval = PUMPIO_DEFAULT_POLL_INTERVAL;
|
||||
$poll_interval = intval(get_config('pumpio','poll_interval'));
|
||||
if(! $poll_interval)
|
||||
$poll_interval = PUMPIO_DEFAULT_POLL_INTERVAL;
|
||||
|
||||
if($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if($next > time()) {
|
||||
logger('pumpio: poll intervall not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
logger('pumpio: cron_start');
|
||||
if($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if($next > time()) {
|
||||
logger('pumpio: poll intervall not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
logger('pumpio: cron_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('pumpio: mirroring user '.$rr['uid']);
|
||||
pumpio_fetchtimeline($a, $rr['uid']);
|
||||
}
|
||||
}
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('pumpio: mirroring user '.$rr['uid']);
|
||||
pumpio_fetchtimeline($a, $rr['uid']);
|
||||
}
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
|
||||
if(count($r)) {
|
||||
|
@ -961,7 +960,7 @@ function pumpio_get_contact($uid, $contact) {
|
|||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s'
|
||||
WHERE `id` = %d
|
||||
",
|
||||
",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
|
@ -983,15 +982,15 @@ function pumpio_get_contact($uid, $contact) {
|
|||
$photos = import_profile_photo($contact->image->url, $uid, $r[0]['id']);
|
||||
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s',
|
||||
`name` = '%s',
|
||||
`nick` = '%s'
|
||||
WHERE `id` = %d
|
||||
",
|
||||
",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
|
@ -1171,9 +1170,9 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
|||
if ($post->verb == "share") {
|
||||
if (!intval(get_config('system','wall-to-wall_share'))) {
|
||||
$postarray['body'] = "[share author='".$post->object->author->displayName.
|
||||
"' profile='".$post->object->author->url.
|
||||
"' avatar='".$post->object->author->image->url.
|
||||
"' link='".$post->links->self->href."']".$postarray['body']."[/share]";
|
||||
"' profile='".$post->object->author->url.
|
||||
"' avatar='".$post->object->author->image->url.
|
||||
"' link='".$post->links->self->href."']".$postarray['body']."[/share]";
|
||||
} else {
|
||||
// Let shares look like wall-to-wall posts
|
||||
$postarray['author-name'] = $post->object->author->displayName;
|
||||
|
@ -1259,28 +1258,28 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
|||
|
||||
function pumpio_fetchinbox(&$a, $uid) {
|
||||
|
||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
||||
$lastdate = get_pconfig($uid, 'pumpio', 'lastdate');
|
||||
$hostname = get_pconfig($uid, 'pumpio','host');
|
||||
$username = get_pconfig($uid, "pumpio", "user");
|
||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
||||
$lastdate = get_pconfig($uid, 'pumpio', 'lastdate');
|
||||
$hostname = get_pconfig($uid, 'pumpio','host');
|
||||
$username = get_pconfig($uid, "pumpio", "user");
|
||||
|
||||
$own_id = "https://".$hostname."/".$username;
|
||||
|
||||
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
$client = new oauth_client_class;
|
||||
$client->oauth_version = '1.0a';
|
||||
$client->authorization_header = true;
|
||||
$client->url_parameters = false;
|
||||
$client = new oauth_client_class;
|
||||
$client->oauth_version = '1.0a';
|
||||
$client->authorization_header = true;
|
||||
$client->url_parameters = false;
|
||||
|
||||
$client->client_id = $ckey;
|
||||
$client->client_secret = $csecret;
|
||||
$client->access_token = $otoken;
|
||||
$client->access_token_secret = $osecret;
|
||||
$client->client_id = $ckey;
|
||||
$client->client_secret = $csecret;
|
||||
$client->access_token = $otoken;
|
||||
$client->access_token_secret = $osecret;
|
||||
|
||||
$last_id = get_pconfig($uid,'pumpio','last_id');
|
||||
|
||||
|
@ -1289,7 +1288,7 @@ function pumpio_fetchinbox(&$a, $uid) {
|
|||
if ($last_id != "")
|
||||
$url .= '?since='.urlencode($last_id);
|
||||
|
||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
|
||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
|
||||
|
||||
if ($user->items) {
|
||||
$posts = array_reverse($user->items);
|
||||
|
@ -1305,31 +1304,31 @@ function pumpio_fetchinbox(&$a, $uid) {
|
|||
}
|
||||
|
||||
function pumpio_getallusers(&$a, $uid) {
|
||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
||||
$hostname = get_pconfig($uid, 'pumpio','host');
|
||||
$username = get_pconfig($uid, "pumpio", "user");
|
||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
||||
$hostname = get_pconfig($uid, 'pumpio','host');
|
||||
$username = get_pconfig($uid, "pumpio", "user");
|
||||
|
||||
$client = new oauth_client_class;
|
||||
$client->oauth_version = '1.0a';
|
||||
$client->authorization_header = true;
|
||||
$client->url_parameters = false;
|
||||
$client = new oauth_client_class;
|
||||
$client->oauth_version = '1.0a';
|
||||
$client->authorization_header = true;
|
||||
$client->url_parameters = false;
|
||||
|
||||
$client->client_id = $ckey;
|
||||
$client->client_secret = $csecret;
|
||||
$client->access_token = $otoken;
|
||||
$client->access_token_secret = $osecret;
|
||||
$client->client_id = $ckey;
|
||||
$client->client_secret = $csecret;
|
||||
$client->access_token = $otoken;
|
||||
$client->access_token_secret = $osecret;
|
||||
|
||||
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
|
||||
|
||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
||||
|
||||
if ($users->totalItems > count($users->items)) {
|
||||
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
|
||||
|
||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
||||
}
|
||||
|
||||
foreach ($users->items AS $user)
|
||||
|
@ -1426,7 +1425,7 @@ function pumpio_getreceiver(&$a, $b) {
|
|||
|
||||
$public = get_pconfig($b['uid'], "pumpio", "public");
|
||||
|
||||
if ($public)
|
||||
if ($public)
|
||||
$receiver["to"][] = Array(
|
||||
"objectType" => "collection",
|
||||
"id" => "http://activityschema.org/collection/public");
|
||||
|
|
|
@ -171,8 +171,8 @@ function statusnet_settings_post ($a,$post) {
|
|||
del_pconfig(local_user(), 'statusnet', 'lastid');
|
||||
del_pconfig(local_user(), 'statusnet', 'mirror_posts');
|
||||
del_pconfig(local_user(), 'statusnet', 'import');
|
||||
del_pconfig(local_user(), 'statusnet', 'create_user');
|
||||
del_pconfig(local_user(), 'statusnet', 'own_id');
|
||||
del_pconfig(local_user(), 'statusnet', 'create_user');
|
||||
del_pconfig(local_user(), 'statusnet', 'own_id');
|
||||
} else {
|
||||
if (isset($_POST['statusnet-preconf-apiurl'])) {
|
||||
/***
|
||||
|
@ -279,9 +279,9 @@ function statusnet_settings(&$a,&$s) {
|
|||
$mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts');
|
||||
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
||||
$importenabled = get_pconfig(local_user(),'statusnet','import');
|
||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||
$create_userenabled = get_pconfig(local_user(),'statusnet','create_user');
|
||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||
$create_userenabled = get_pconfig(local_user(),'statusnet','create_user');
|
||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
|
||||
|
@ -390,12 +390,12 @@ function statusnet_settings(&$a,&$s) {
|
|||
$s .= '</div>';
|
||||
|
||||
$s .= '<label id="statusnet-import-label" for="statusnet-import">'.t('Import the remote timeline').'</label>';
|
||||
$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
/*
|
||||
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.t('Automatically create contacts').'</label>';
|
||||
$s .= '<input id="statusnet-create_user" type="checkbox" name="statusnet-create_user" value="1" '. $create_userchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.t('Automatically create contacts').'</label>';
|
||||
$s .= '<input id="statusnet-create_user" type="checkbox" name="statusnet-create_user" value="1" '. $create_userchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
*/
|
||||
$s .= '<div id="statusnet-disconnect-wrapper">';
|
||||
$s .= '<label id="statusnet-disconnect-label" for="statusnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||
|
@ -439,20 +439,20 @@ function statusnet_action($a, $uid, $pid, $action) {
|
|||
|
||||
$connection = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
|
||||
|
||||
logger("statusnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
|
||||
logger("statusnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
|
||||
|
||||
switch ($action) {
|
||||
case "delete":
|
||||
$result = $connection->post("statuses/destroy/".$pid);
|
||||
break;
|
||||
case "like":
|
||||
$result = $connection->post("favorites/create/".$pid);
|
||||
break;
|
||||
case "unlike":
|
||||
$result = $connection->post("favorites/destroy/".$pid);
|
||||
break;
|
||||
}
|
||||
logger("statusnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
|
||||
switch ($action) {
|
||||
case "delete":
|
||||
$result = $connection->post("statuses/destroy/".$pid);
|
||||
break;
|
||||
case "like":
|
||||
$result = $connection->post("favorites/create/".$pid);
|
||||
break;
|
||||
case "unlike":
|
||||
$result = $connection->post("favorites/destroy/".$pid);
|
||||
break;
|
||||
}
|
||||
logger("statusnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
function statusnet_post_hook(&$a,&$b) {
|
||||
|
@ -510,19 +510,19 @@ function statusnet_post_hook(&$a,&$b) {
|
|||
}
|
||||
|
||||
if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
|
||||
statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete");
|
||||
statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete");
|
||||
|
||||
if($b['verb'] == ACTIVITY_LIKE) {
|
||||
logger("statusnet_post_hook: parameter 2 ".substr($b["thr-parent"], $hostlength), LOGGER_DEBUG);
|
||||
if ($b['deleted'])
|
||||
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike");
|
||||
else
|
||||
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like");
|
||||
return;
|
||||
if($b['verb'] == ACTIVITY_LIKE) {
|
||||
logger("statusnet_post_hook: parameter 2 ".substr($b["thr-parent"], $hostlength), LOGGER_DEBUG);
|
||||
if ($b['deleted'])
|
||||
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike");
|
||||
else
|
||||
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like");
|
||||
return;
|
||||
}
|
||||
|
||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
|
||||
// if posts comes from statusnet don't send it back
|
||||
if($b['app'] == "StatusNet")
|
||||
|
@ -700,12 +700,12 @@ function statusnet_cron($a,$b) {
|
|||
}
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('statusnet: importing timeline from user '.$rr['uid']);
|
||||
statusnet_fetchhometimeline($a, $rr["uid"]);
|
||||
}
|
||||
}
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('statusnet: importing timeline from user '.$rr['uid']);
|
||||
statusnet_fetchhometimeline($a, $rr["uid"]);
|
||||
}
|
||||
}
|
||||
|
||||
logger('statusnet: cron_end');
|
||||
|
||||
|
@ -1429,7 +1429,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
|
|||
$expanded_url = original_url($match[1]);
|
||||
|
||||
$oembed_data = oembed_fetch_url($expanded_url, true);
|
||||
print_r($oembed_data);
|
||||
|
||||
if ($type == "")
|
||||
$type = $oembed_data->type;
|
||||
if ($oembed_data->type == "video") {
|
||||
|
|
200
tumblr/tumblr.php
Executable file → Normal file
200
tumblr/tumblr.php
Executable file → Normal file
|
@ -12,19 +12,19 @@ require_once('library/OAuth1.php');
|
|||
require_once('addon/tumblr/tumblroauth/tumblroauth.php');
|
||||
|
||||
function tumblr_install() {
|
||||
register_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||
register_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||
register_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||
register_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
||||
register_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
||||
register_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||
register_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||
register_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||
register_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
||||
register_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
||||
|
||||
}
|
||||
function tumblr_uninstall() {
|
||||
unregister_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||
unregister_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||
unregister_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||
unregister_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
||||
unregister_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
||||
unregister_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||
unregister_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||
unregister_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||
unregister_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
||||
unregister_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
||||
}
|
||||
|
||||
function tumblr_module() {}
|
||||
|
@ -85,22 +85,22 @@ function tumblr_connect($a) {
|
|||
|
||||
// Check the HTTP Code. It should be a 200 (OK), if it's anything else then something didn't work.
|
||||
switch ($tum_oauth->http_code) {
|
||||
case 200:
|
||||
// Ask Tumblr to give us a special address to their login page
|
||||
$url = $tum_oauth->getAuthorizeURL($token);
|
||||
case 200:
|
||||
// Ask Tumblr to give us a special address to their login page
|
||||
$url = $tum_oauth->getAuthorizeURL($token);
|
||||
|
||||
// Redirect the user to the login URL given to us by Tumblr
|
||||
header('Location: ' . $url);
|
||||
// Redirect the user to the login URL given to us by Tumblr
|
||||
header('Location: ' . $url);
|
||||
|
||||
// That's it for our side. The user is sent to a Tumblr Login page and
|
||||
// asked to authroize our app. After that, Tumblr sends the user back to
|
||||
// our Callback URL (callback.php) along with some information we need to get
|
||||
// an access token.
|
||||
// That's it for our side. The user is sent to a Tumblr Login page and
|
||||
// asked to authroize our app. After that, Tumblr sends the user back to
|
||||
// our Callback URL (callback.php) along with some information we need to get
|
||||
// an access token.
|
||||
|
||||
break;
|
||||
default:
|
||||
// Give an error message
|
||||
$o = 'Could not connect to Tumblr. Refresh the page or try again later.';
|
||||
break;
|
||||
default:
|
||||
// Give an error message
|
||||
$o = 'Could not connect to Tumblr. Refresh the page or try again later.';
|
||||
}
|
||||
return($o);
|
||||
}
|
||||
|
@ -133,9 +133,9 @@ function tumblr_callback($a) {
|
|||
|
||||
// Make sure nothing went wrong.
|
||||
if (200 == $tum_oauth->http_code) {
|
||||
// good to go
|
||||
// good to go
|
||||
} else {
|
||||
return('Unable to authenticate');
|
||||
return('Unable to authenticate');
|
||||
}
|
||||
|
||||
// What's next? Now that we have an Access Token and Secret, we can make an API call.
|
||||
|
@ -148,96 +148,96 @@ function tumblr_callback($a) {
|
|||
}
|
||||
|
||||
function tumblr_jot_nets(&$a,&$b) {
|
||||
if(! local_user())
|
||||
return;
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
$tmbl_post = get_pconfig(local_user(),'tumblr','post');
|
||||
if(intval($tmbl_post) == 1) {
|
||||
$tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
|
||||
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
|
||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
|
||||
. t('Post to Tumblr') . '</div>';
|
||||
}
|
||||
$tmbl_post = get_pconfig(local_user(),'tumblr','post');
|
||||
if(intval($tmbl_post) == 1) {
|
||||
$tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
|
||||
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
|
||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
|
||||
. t('Post to Tumblr') . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function tumblr_settings(&$a,&$s) {
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/tumblr/tumblr.css' . '" media="all" />' . "\r\n";
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/tumblr/tumblr.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
/* Get the current state of our config variables */
|
||||
/* Get the current state of our config variables */
|
||||
|
||||
$enabled = get_pconfig(local_user(),'tumblr','post');
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
$enabled = get_pconfig(local_user(),'tumblr','post');
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
|
||||
$def_enabled = get_pconfig(local_user(),'tumblr','post_by_default');
|
||||
$def_enabled = get_pconfig(local_user(),'tumblr','post_by_default');
|
||||
|
||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
/* Add some HTML to the existing form */
|
||||
/* Add some HTML to the existing form */
|
||||
|
||||
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$s .= '<div id="tumblr-username-wrapper">';
|
||||
$s .= '<a href="'.$a->get_baseurl().'/tumblr/connect">'.t("(Re-)Authenticate your tumblr page").'</a>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="tumblr-username-wrapper">';
|
||||
$s .= '<a href="'.$a->get_baseurl().'/tumblr/connect">'.t("(Re-)Authenticate your tumblr page").'</a>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="tumblr-enable-wrapper">';
|
||||
$s .= '<label id="tumblr-enable-label" for="tumblr-checkbox">' . t('Enable Tumblr Post Plugin') . '</label>';
|
||||
$s .= '<input id="tumblr-checkbox" type="checkbox" name="tumblr" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="tumblr-enable-wrapper">';
|
||||
$s .= '<label id="tumblr-enable-label" for="tumblr-checkbox">' . t('Enable Tumblr Post Plugin') . '</label>';
|
||||
$s .= '<input id="tumblr-checkbox" type="checkbox" name="tumblr" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="tumblr-bydefault-wrapper">';
|
||||
$s .= '<label id="tumblr-bydefault-label" for="tumblr-bydefault">' . t('Post to Tumblr by default') . '</label>';
|
||||
$s .= '<input id="tumblr-bydefault" type="checkbox" name="tumblr_bydefault" value="1" ' . $def_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="tumblr-bydefault-wrapper">';
|
||||
$s .= '<label id="tumblr-bydefault-label" for="tumblr-bydefault">' . t('Post to Tumblr by default') . '</label>';
|
||||
$s .= '<input id="tumblr-bydefault" type="checkbox" name="tumblr_bydefault" value="1" ' . $def_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$oauth_token = get_pconfig(local_user(), "tumblr", "oauth_token");
|
||||
$oauth_token_secret = get_pconfig(local_user(), "tumblr", "oauth_token_secret");
|
||||
$oauth_token = get_pconfig(local_user(), "tumblr", "oauth_token");
|
||||
$oauth_token_secret = get_pconfig(local_user(), "tumblr", "oauth_token_secret");
|
||||
|
||||
$s .= '<div id="tumblr-page-wrapper">';
|
||||
if (($oauth_token != "") and ($oauth_token_secret != "")) {
|
||||
$s .= '<div id="tumblr-page-wrapper">';
|
||||
if (($oauth_token != "") and ($oauth_token_secret != "")) {
|
||||
|
||||
$page = get_pconfig(local_user(),'tumblr','page');
|
||||
$consumer_key = get_config('tumblr','consumer_key');
|
||||
$consumer_secret = get_config('tumblr','consumer_secret');
|
||||
$page = get_pconfig(local_user(),'tumblr','page');
|
||||
$consumer_key = get_config('tumblr','consumer_key');
|
||||
$consumer_secret = get_config('tumblr','consumer_secret');
|
||||
|
||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||
|
||||
$userinfo = $tum_oauth->get('user/info');
|
||||
$userinfo = $tum_oauth->get('user/info');
|
||||
|
||||
$blogs = array();
|
||||
$blogs = array();
|
||||
|
||||
$s .= '<label id="tumblr-page-label" for="tumblr-page">' . t('Post to page:') . '</label>';
|
||||
$s .= '<select name="tumblr_page" id="tumblr-page">';
|
||||
foreach($userinfo->response->user->blogs as $blog) {
|
||||
$blogurl = substr(str_replace(array("http://", "https://"), array("", ""), $blog->url), 0, -1);
|
||||
if ($page == $blogurl)
|
||||
$s .= "<option value='".$blogurl."' selected>".$blogurl."</option>";
|
||||
else
|
||||
$s .= "<option value='".$blogurl."'>".$blogurl."</option>";
|
||||
}
|
||||
$s .= '<label id="tumblr-page-label" for="tumblr-page">' . t('Post to page:') . '</label>';
|
||||
$s .= '<select name="tumblr_page" id="tumblr-page">';
|
||||
foreach($userinfo->response->user->blogs as $blog) {
|
||||
$blogurl = substr(str_replace(array("http://", "https://"), array("", ""), $blog->url), 0, -1);
|
||||
if ($page == $blogurl)
|
||||
$s .= "<option value='".$blogurl."' selected>".$blogurl."</option>";
|
||||
else
|
||||
$s .= "<option value='".$blogurl."'>".$blogurl."</option>";
|
||||
}
|
||||
|
||||
$s .= "</select>";
|
||||
} else
|
||||
$s .= t("You are not authenticated to tumblr");
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= "</select>";
|
||||
} else
|
||||
$s .= t("You are not authenticated to tumblr");
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
/* provide a submit button */
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="tumblr-submit" name="tumblr-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="tumblr-submit" name="tumblr-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||
|
||||
}
|
||||
|
||||
|
@ -267,19 +267,19 @@ function tumblr_post_local(&$a,&$b) {
|
|||
if($b['private'] || $b['parent'])
|
||||
return;
|
||||
|
||||
$tmbl_post = intval(get_pconfig(local_user(),'tumblr','post'));
|
||||
$tmbl_post = intval(get_pconfig(local_user(),'tumblr','post'));
|
||||
|
||||
$tmbl_enable = (($tmbl_post && x($_REQUEST,'tumblr_enable')) ? intval($_REQUEST['tumblr_enable']) : 0);
|
||||
|
||||
if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'tumblr','post_by_default')))
|
||||
$tmbl_enable = 1;
|
||||
|
||||
if(! $tmbl_enable)
|
||||
return;
|
||||
if(! $tmbl_enable)
|
||||
return;
|
||||
|
||||
if(strlen($b['postopts']))
|
||||
$b['postopts'] .= ',';
|
||||
$b['postopts'] .= 'tumblr';
|
||||
if(strlen($b['postopts']))
|
||||
$b['postopts'] .= ',';
|
||||
$b['postopts'] .= 'tumblr';
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,14 +287,14 @@ function tumblr_post_local(&$a,&$b) {
|
|||
|
||||
function tumblr_send(&$a,&$b) {
|
||||
|
||||
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
|
||||
if(! strstr($b['postopts'],'tumblr'))
|
||||
return;
|
||||
if(! strstr($b['postopts'],'tumblr'))
|
||||
return;
|
||||
|
||||
if($b['parent'] != $b['id'])
|
||||
return;
|
||||
if($b['parent'] != $b['id'])
|
||||
return;
|
||||
|
||||
$oauth_token = get_pconfig($b['uid'], "tumblr", "oauth_token");
|
||||
$oauth_token_secret = get_pconfig($b['uid'], "tumblr", "oauth_token_secret");
|
||||
|
|
247
twitter/twitter.php
Executable file → Normal file
247
twitter/twitter.php
Executable file → Normal file
|
@ -161,10 +161,10 @@ function twitter_settings_post ($a,$post) {
|
|||
*/
|
||||
del_pconfig(local_user(), 'twitter', 'consumerkey');
|
||||
del_pconfig(local_user(), 'twitter', 'consumersecret');
|
||||
del_pconfig(local_user(), 'twitter', 'oauthtoken');
|
||||
del_pconfig(local_user(), 'twitter', 'oauthsecret');
|
||||
del_pconfig(local_user(), 'twitter', 'post');
|
||||
del_pconfig(local_user(), 'twitter', 'post_by_default');
|
||||
del_pconfig(local_user(), 'twitter', 'oauthtoken');
|
||||
del_pconfig(local_user(), 'twitter', 'oauthsecret');
|
||||
del_pconfig(local_user(), 'twitter', 'post');
|
||||
del_pconfig(local_user(), 'twitter', 'post_by_default');
|
||||
del_pconfig(local_user(), 'twitter', 'lastid');
|
||||
del_pconfig(local_user(), 'twitter', 'mirror_posts');
|
||||
del_pconfig(local_user(), 'twitter', 'import');
|
||||
|
@ -183,30 +183,30 @@ function twitter_settings_post ($a,$post) {
|
|||
$connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
|
||||
$token = $connection->getAccessToken( $_POST['twitter-pin'] );
|
||||
// ok, now that we have the Access Token, save them in the user config
|
||||
set_pconfig(local_user(),'twitter', 'oauthtoken', $token['oauth_token']);
|
||||
set_pconfig(local_user(),'twitter', 'oauthtoken', $token['oauth_token']);
|
||||
set_pconfig(local_user(),'twitter', 'oauthsecret', $token['oauth_token_secret']);
|
||||
set_pconfig(local_user(),'twitter', 'post', 1);
|
||||
// reload the Addon Settings page, if we don't do it see Bug #42
|
||||
goaway($a->get_baseurl().'/settings/connectors');
|
||||
set_pconfig(local_user(),'twitter', 'post', 1);
|
||||
// reload the Addon Settings page, if we don't do it see Bug #42
|
||||
goaway($a->get_baseurl().'/settings/connectors');
|
||||
} else {
|
||||
// if no PIN is supplied in the POST variables, the user has changed the setting
|
||||
// to post a tweet for every new __public__ posting to the wall
|
||||
set_pconfig(local_user(),'twitter','post',intval($_POST['twitter-enable']));
|
||||
set_pconfig(local_user(),'twitter','post_by_default',intval($_POST['twitter-default']));
|
||||
set_pconfig(local_user(),'twitter','post_by_default',intval($_POST['twitter-default']));
|
||||
set_pconfig(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
|
||||
set_pconfig(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
|
||||
set_pconfig(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
|
||||
|
||||
if (!intval($_POST['twitter-mirror']))
|
||||
del_pconfig(local_user(),'twitter','lastid');
|
||||
if (!intval($_POST['twitter-mirror']))
|
||||
del_pconfig(local_user(),'twitter','lastid');
|
||||
|
||||
info(t('Twitter settings updated.') . EOL);
|
||||
info(t('Twitter settings updated.') . EOL);
|
||||
}}
|
||||
}
|
||||
function twitter_settings(&$a,&$s) {
|
||||
if(! local_user())
|
||||
return;
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
|
||||
if(! local_user())
|
||||
return;
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
|
||||
/***
|
||||
* 1) Check that we have global consumer key & secret
|
||||
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
||||
|
@ -216,16 +216,16 @@ function twitter_settings(&$a,&$s) {
|
|||
$csecret = get_config('twitter', 'consumersecret' );
|
||||
$otoken = get_pconfig(local_user(), 'twitter', 'oauthtoken' );
|
||||
$osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
|
||||
$enabled = get_pconfig(local_user(), 'twitter', 'post');
|
||||
$enabled = get_pconfig(local_user(), 'twitter', 'post');
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
$defenabled = get_pconfig(local_user(),'twitter','post_by_default');
|
||||
$defenabled = get_pconfig(local_user(),'twitter','post_by_default');
|
||||
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
|
||||
$mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
|
||||
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
||||
$importenabled = get_pconfig(local_user(),'twitter','import');
|
||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||
$create_userenabled = get_pconfig(local_user(),'twitter','create_user');
|
||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||
$mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
|
||||
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
||||
$importenabled = get_pconfig(local_user(),'twitter','import');
|
||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||
$create_userenabled = get_pconfig(local_user(),'twitter','create_user');
|
||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
|
||||
|
@ -254,7 +254,7 @@ function twitter_settings(&$a,&$s) {
|
|||
* which the user can request a PIN to connect the account to a
|
||||
* account at Twitter.
|
||||
*/
|
||||
require_once('library/twitteroauth.php');
|
||||
require_once('library/twitteroauth.php');
|
||||
$connection = new TwitterOAuth($ckey, $csecret);
|
||||
$request_token = $connection->getRequestToken();
|
||||
$token = $request_token['oauth_token'];
|
||||
|
@ -268,50 +268,50 @@ function twitter_settings(&$a,&$s) {
|
|||
$s .= '<input id="twitter-pin" type="text" name="twitter-pin" />';
|
||||
$s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="'.$token.'" />';
|
||||
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="'.$request_token['oauth_token_secret'].'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
||||
} else {
|
||||
/***
|
||||
* we have an OAuth key / secret pair for the user
|
||||
* so let's give a chance to disable the postings to Twitter
|
||||
*/
|
||||
require_once('library/twitteroauth.php');
|
||||
require_once('library/twitteroauth.php');
|
||||
$connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
|
||||
$details = $connection->get('account/verify_credentials');
|
||||
$s .= '<div id="twitter-info" ><img id="twitter-avatar" src="'.$details->profile_image_url.'" /><p id="twitter-info-block">'. t('Currently connected to: ') .'<a href="https://twitter.com/'.$details->screen_name.'" target="_twitter">'.$details->screen_name.'</a><br /><em>'.$details->description.'</em></p></div>';
|
||||
$s .= '<p>'. t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') .'</p>';
|
||||
if ($a->user['hidewall']) {
|
||||
$s .= '<p>'. t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'</p>';
|
||||
}
|
||||
if ($a->user['hidewall']) {
|
||||
$s .= '<p>'. t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'</p>';
|
||||
}
|
||||
$s .= '<div id="twitter-enable-wrapper">';
|
||||
$s .= '<label id="twitter-enable-label" for="twitter-checkbox">'. t('Allow posting to Twitter'). '</label>';
|
||||
$s .= '<input id="twitter-checkbox" type="checkbox" name="twitter-enable" value="1" ' . $checked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
$s .= '<label id="twitter-default-label" for="twitter-default">'. t('Send public postings to Twitter by default') .'</label>';
|
||||
$s .= '<input id="twitter-default" type="checkbox" name="twitter-default" value="1" ' . $defchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
$s .= '<label id="twitter-default-label" for="twitter-default">'. t('Send public postings to Twitter by default') .'</label>';
|
||||
$s .= '<input id="twitter-default" type="checkbox" name="twitter-default" value="1" ' . $defchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
|
||||
$s .= '<label id="twitter-mirror-label" for="twitter-mirror">'.t('Mirror all posts from twitter that are no replies').'</label>';
|
||||
$s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
|
||||
$s .= '<label id="twitter-mirror-label" for="twitter-mirror">'.t('Mirror all posts from twitter that are no replies').'</label>';
|
||||
$s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
$s .= '</div>';
|
||||
|
||||
$s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
|
||||
$s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
|
||||
$s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
|
||||
$s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
|
||||
$s .= '<label id="twitter-create_user-label" for="twitter-create_user">'.t('Automatically create contacts').'</label>';
|
||||
$s .= '<input id="twitter-create_user" type="checkbox" name="twitter-create_user" value="1" '. $create_userchecked . '/>';
|
||||
$s .= '<label id="twitter-create_user-label" for="twitter-create_user">'.t('Automatically create contacts').'</label>';
|
||||
$s .= '<input id="twitter-create_user" type="checkbox" name="twitter-create_user" value="1" '. $create_userchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="twitter-disconnect-wrapper">';
|
||||
$s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||
$s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
|
||||
$s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||
$s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
||||
}
|
||||
}
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
}
|
||||
|
||||
|
||||
|
@ -329,12 +329,12 @@ function twitter_post_local(&$a,&$b) {
|
|||
if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default')))
|
||||
$twitter_enable = 1;
|
||||
|
||||
if(! $twitter_enable)
|
||||
return;
|
||||
if(! $twitter_enable)
|
||||
return;
|
||||
|
||||
if(strlen($b['postopts']))
|
||||
$b['postopts'] .= ',';
|
||||
$b['postopts'] .= 'twitter';
|
||||
if(strlen($b['postopts']))
|
||||
$b['postopts'] .= ',';
|
||||
$b['postopts'] .= 'twitter';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,29 +385,31 @@ function twitter_post_hook(&$a,&$b) {
|
|||
if($b['parent'] != $b['id']) {
|
||||
logger("twitter_post_hook: parameter ".print_r($b, true), LOGGER_DATA);
|
||||
|
||||
// Looking if its a reply to a twitter post
|
||||
// Looking if its a reply to a twitter post
|
||||
if ((substr($b["parent-uri"], 0, 9) != "twitter::") AND (substr($b["extid"], 0, 9) != "twitter::") AND (substr($b["thr-parent"], 0, 9) != "twitter::")) {
|
||||
logger("twitter_post_hook: no twitter post ".$b["parent"]);
|
||||
return;
|
||||
logger("twitter_post_hook: no twitter post ".$b["parent"]);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
|
||||
dbesc($b["thr-parent"]),
|
||||
intval($b["uid"]));
|
||||
$r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
|
||||
dbesc($b["thr-parent"]),
|
||||
intval($b["uid"]));
|
||||
|
||||
if(!count($r)) {
|
||||
logger("twitter_post_hook: no parent found ".$b["thr-parent"]);
|
||||
return;
|
||||
} else {
|
||||
$iscomment = true;
|
||||
$orig_post = $r[0];
|
||||
}
|
||||
if(!count($r)) {
|
||||
logger("twitter_post_hook: no parent found ".$b["thr-parent"]);
|
||||
return;
|
||||
} else {
|
||||
$iscomment = true;
|
||||
$orig_post = $r[0];
|
||||
}
|
||||
|
||||
$nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||
$nickname = "@[url=".$orig_post["author-link"]."]".$nickname."[/url]";
|
||||
|
||||
logger("twitter_post_hook: comparing ".$nickname." with ".$b["body"], LOGGER_DEBUG);
|
||||
if (strpos($b["body"], $nickname) === false)
|
||||
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||
$nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
|
||||
$nicknameplain = "@".$nicknameplain;
|
||||
|
||||
logger("twitter_post_hook: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
|
||||
if ((strpos($b["body"], $nickname) === false) AND (strpos($b["body"], $nicknameplain) === false))
|
||||
$b["body"] = $nickname." ".$b["body"];
|
||||
|
||||
logger("twitter_post_hook: parent found ".print_r($orig_post, true), LOGGER_DATA);
|
||||
|
@ -428,10 +430,10 @@ function twitter_post_hook(&$a,&$b) {
|
|||
else
|
||||
twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "like");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
return;
|
||||
|
||||
// if post comes from twitter don't send it back
|
||||
if($b['app'] == "Twitter")
|
||||
|
@ -484,7 +486,7 @@ function twitter_post_hook(&$a,&$b) {
|
|||
// so we are using a new library for twitter
|
||||
// To-Do:
|
||||
// Switching completely to this library with all functions
|
||||
require_once("addon/twitter/codebird.php");
|
||||
require_once("addon/twitter/codebird.php");
|
||||
|
||||
$cb = \Codebird\Codebird::getInstance();
|
||||
$cb->setConsumerKey($ckey, $csecret);
|
||||
|
@ -554,7 +556,7 @@ function twitter_post_hook(&$a,&$b) {
|
|||
function twitter_plugin_admin_post(&$a){
|
||||
$consumerkey = ((x($_POST,'consumerkey')) ? notags(trim($_POST['consumerkey'])) : '');
|
||||
$consumersecret = ((x($_POST,'consumersecret')) ? notags(trim($_POST['consumersecret'])): '');
|
||||
$applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'])):'');
|
||||
$applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'])):'');
|
||||
set_config('twitter','consumerkey',$consumerkey);
|
||||
set_config('twitter','consumersecret',$consumersecret);
|
||||
set_config('twitter','application_name',$applicationname);
|
||||
|
@ -567,8 +569,8 @@ function twitter_plugin_admin(&$a, &$o){
|
|||
'$submit' => t('Save Settings'),
|
||||
// name, label, value, help, [extra values]
|
||||
'$consumerkey' => array('consumerkey', t('Consumer key'), get_config('twitter', 'consumerkey' ), ''),
|
||||
'$consumersecret' => array('consumersecret', t('Consumer secret'), get_config('twitter', 'consumersecret' ), ''),
|
||||
'$applicationname' => array('applicationname', t('Name of the Twitter Application'), get_config('twitter','application_name'),t('set this to avoid mirroring postings from ~friendica back to ~friendica'))
|
||||
'$consumersecret' => array('consumersecret', t('Consumer secret'), get_config('twitter', 'consumersecret' ), ''),
|
||||
'$applicationname' => array('applicationname', t('Name of the Twitter Application'), get_config('twitter','application_name'),t('set this to avoid mirroring postings from ~friendica back to ~friendica'))
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -605,21 +607,21 @@ function twitter_cron($a,$b) {
|
|||
|
||||
/*
|
||||
// To-Do
|
||||
// check for new contacts once a day
|
||||
$last_contact_check = get_pconfig($rr['uid'],'pumpio','contact_check');
|
||||
if($last_contact_check)
|
||||
$next_contact_check = $last_contact_check + 86400;
|
||||
else
|
||||
$next_contact_check = 0;
|
||||
// check for new contacts once a day
|
||||
$last_contact_check = get_pconfig($rr['uid'],'pumpio','contact_check');
|
||||
if($last_contact_check)
|
||||
$next_contact_check = $last_contact_check + 86400;
|
||||
else
|
||||
$next_contact_check = 0;
|
||||
|
||||
if($next_contact_check <= time()) {
|
||||
pumpio_getallusers($a, $rr["uid"]);
|
||||
set_pconfig($rr['uid'],'pumpio','contact_check',time());
|
||||
}
|
||||
if($next_contact_check <= time()) {
|
||||
pumpio_getallusers($a, $rr["uid"]);
|
||||
set_pconfig($rr['uid'],'pumpio','contact_check',time());
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger('twitter: cron_end');
|
||||
|
||||
|
@ -628,26 +630,26 @@ function twitter_cron($a,$b) {
|
|||
|
||||
function twitter_expire($a,$b) {
|
||||
|
||||
$days = get_config('twitter', 'expire');
|
||||
$days = get_config('twitter', 'expire');
|
||||
|
||||
if ($days == 0)
|
||||
return;
|
||||
if ($days == 0)
|
||||
return;
|
||||
|
||||
$r = q("DELETE FROM `item` WHERE `deleted` AND `network` = '%s'", dbesc(NETWORK_TWITTER));
|
||||
|
||||
require_once("include/items.php");
|
||||
require_once("include/items.php");
|
||||
|
||||
logger('twitter_expire: expire_start');
|
||||
logger('twitter_expire: expire_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('twitter_expire: user '.$rr['uid']);
|
||||
item_expire($rr['uid'], $days, NETWORK_TWITTER, true);
|
||||
}
|
||||
}
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
logger('twitter_expire: user '.$rr['uid']);
|
||||
item_expire($rr['uid'], $days, NETWORK_TWITTER, true);
|
||||
}
|
||||
}
|
||||
|
||||
logger('twitter_expire: expire_end');
|
||||
logger('twitter_expire: expire_end');
|
||||
}
|
||||
|
||||
function twitter_fetchtimeline($a, $uid) {
|
||||
|
@ -684,7 +686,7 @@ function twitter_fetchtimeline($a, $uid) {
|
|||
|
||||
$posts = array_reverse($items);
|
||||
|
||||
if (count($posts)) {
|
||||
if (count($posts)) {
|
||||
foreach ($posts as $post) {
|
||||
if ($post->id_str > $lastid)
|
||||
$lastid = $post->id_str;
|
||||
|
@ -767,8 +769,8 @@ function twitter_fetchtimeline($a, $uid) {
|
|||
// require_once('mod/item.php');
|
||||
|
||||
item_post($a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
set_pconfig($uid, 'twitter', 'lastid', $lastid);
|
||||
}
|
||||
|
@ -842,7 +844,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
|
|||
|
||||
// Check if the unique contact is existing
|
||||
// To-Do: only update once a while
|
||||
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
||||
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
||||
dbesc(normalise_link("https://twitter.com/".$contact->screen_name)));
|
||||
|
||||
if (count($r) == 0)
|
||||
|
@ -1114,16 +1116,16 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
|||
}
|
||||
|
||||
// it seems as if the entities aren't always covering all mentions. So the rest will be checked here
|
||||
$tags = get_tags($body);
|
||||
$tags = get_tags($body);
|
||||
|
||||
if(count($tags)) {
|
||||
if(count($tags)) {
|
||||
foreach($tags as $tag) {
|
||||
if (strstr(trim($tag), " "))
|
||||
continue;
|
||||
|
||||
if(strpos($tag,'#') === 0) {
|
||||
if(strpos($tag,'[url='))
|
||||
continue;
|
||||
if(strpos($tag,'#') === 0) {
|
||||
if(strpos($tag,'[url='))
|
||||
continue;
|
||||
|
||||
// don't link tags that are already embedded in links
|
||||
|
||||
|
@ -1138,8 +1140,8 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
|||
$tags_arr["#".$basetag] = $url;
|
||||
continue;
|
||||
} elseif(strpos($tag,'@') === 0) {
|
||||
if(strpos($tag,'[url='))
|
||||
continue;
|
||||
if(strpos($tag,'[url='))
|
||||
continue;
|
||||
|
||||
$basetag = substr($tag,1);
|
||||
$url = '@[url=https://twitter.com/'.rawurlencode($basetag).']'.$basetag.'[/url]';
|
||||
|
@ -1458,7 +1460,7 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
return;
|
||||
}
|
||||
|
||||
$posts = array_reverse($items);
|
||||
$posts = array_reverse($items);
|
||||
|
||||
logger("twitter_fetchhometimeline: Fetching timeline for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
|
||||
|
||||
|
@ -1501,7 +1503,7 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
return;
|
||||
}
|
||||
|
||||
$posts = array_reverse($items);
|
||||
$posts = array_reverse($items);
|
||||
|
||||
logger("twitter_fetchhometimeline: Fetching mentions for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
|
||||
|
||||
|
@ -1535,19 +1537,19 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_TAGSELF,
|
||||
'notify_flags' => $u[0]['notify-flags'],
|
||||
'language' => $u[0]['language'],
|
||||
'to_name' => $u[0]['username'],
|
||||
'to_email' => $u[0]['email'],
|
||||
'uid' => $u[0]['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'notify_flags' => $u[0]['notify-flags'],
|
||||
'language' => $u[0]['language'],
|
||||
'to_name' => $u[0]['username'],
|
||||
'to_email' => $u[0]['email'],
|
||||
'uid' => $u[0]['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item'
|
||||
));
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1578,8 +1580,8 @@ function twitter_fetch_own_contact($a, $uid) {
|
|||
$contact_id = twitter_fetch_contact($uid, $user, true);
|
||||
|
||||
} else {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("twitter::".$own_id));
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("twitter::".$own_id));
|
||||
if(count($r))
|
||||
$contact_id = $r[0]["id"];
|
||||
else
|
||||
|
@ -1636,5 +1638,4 @@ function twitter_is_retweet($a, $uid, $body) {
|
|||
|
||||
return(!isset($result->errors));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue