* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
+use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
function pumpio_module() {}
-function pumpio_content(&$a)
+function pumpio_content(App $a)
{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
$notification_data["profiles"][] = "https://".$hostname."/".$username;
}
-function pumpio_registerclient(&$a, $host)
+function pumpio_registerclient(App $a, $host)
{
$url = "https://".$host."/api/client/register";
}
-function pumpio_connect(&$a)
+function pumpio_connect(App $a)
{
// Start a session. This is necessary to hold on to a few keys the callback script will also need
session_start();
return $o;
}
-function pumpio_jot_nets(&$a, &$b)
+function pumpio_jot_nets(App $a, &$b)
{
- if (!local_user()) {
+ if (! local_user()) {
return;
}
$pumpio_post = PConfig::get(local_user(), 'pumpio', 'post');
+
if (intval($pumpio_post) == 1) {
$pumpio_defpost = PConfig::get(local_user(), 'pumpio', 'post_by_default');
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
}
}
-function pumpio_settings(&$a, &$s)
+function pumpio_settings(App $a, &$s)
{
if (!local_user()) {
return;
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
}
-function pumpio_settings_post(&$a, &$b)
+function pumpio_settings_post(App $a, array &$b)
{
- if (x($_POST, 'pumpio-submit')) {
- if (x($_POST, 'pumpio_delete')) {
- PConfig::set(local_user(), 'pumpio', 'consumer_key', '');
- PConfig::set(local_user(), 'pumpio', 'consumer_secret', '');
- PConfig::set(local_user(), 'pumpio', 'oauth_token', '');
+ if (!empty($_POST['pumpio-submit'])) {
+ if (!empty($_POST['pumpio_delete'])) {
+ PConfig::set(local_user(), 'pumpio', 'consumer_key' , '');
+ PConfig::set(local_user(), 'pumpio', 'consumer_secret' , '');
+ PConfig::set(local_user(), 'pumpio', 'oauth_token' , '');
PConfig::set(local_user(), 'pumpio', 'oauth_token_secret', '');
- PConfig::set(local_user(), 'pumpio', 'post', false);
- PConfig::set(local_user(), 'pumpio', 'import', false);
- PConfig::set(local_user(), 'pumpio', 'host', '');
- PConfig::set(local_user(), 'pumpio', 'user', '');
- PConfig::set(local_user(), 'pumpio', 'public', false);
- PConfig::set(local_user(), 'pumpio', 'mirror', false);
- PConfig::set(local_user(), 'pumpio', 'post_by_default', false);
- PConfig::set(local_user(), 'pumpio', 'lastdate', 0);
- PConfig::set(local_user(), 'pumpio', 'last_id', '');
+ PConfig::set(local_user(), 'pumpio', 'post' , false);
+ PConfig::set(local_user(), 'pumpio', 'import' , false);
+ PConfig::set(local_user(), 'pumpio', 'host' , '');
+ PConfig::set(local_user(), 'pumpio', 'user' , '');
+ PConfig::set(local_user(), 'pumpio', 'public' , false);
+ PConfig::set(local_user(), 'pumpio', 'mirror' , false);
+ PConfig::set(local_user(), 'pumpio', 'post_by_default' , false);
+ PConfig::set(local_user(), 'pumpio', 'lastdate' , 0);
+ PConfig::set(local_user(), 'pumpio', 'last_id' , '');
} else {
// filtering the username if it is filled wrong
$user = $_POST['pumpio_user'];
if (strstr($user, "@")) {
$pos = strpos($user, "@");
+
if ($pos > 0) {
$user = substr($user, 0, $pos);
}
$host = trim($host);
$host = str_replace(["https://", "http://"], ["", ""], $host);
- PConfig::set(local_user(), 'pumpio', 'post',intval($_POST['pumpio']));
- PConfig::set(local_user(), 'pumpio', 'import', $_POST['pumpio_import']);
- PConfig::set(local_user(), 'pumpio', 'host', $host);
- PConfig::set(local_user(), 'pumpio', 'user', $user);
- PConfig::set(local_user(), 'pumpio', 'public', $_POST['pumpio_public']);
- PConfig::set(local_user(), 'pumpio', 'mirror', $_POST['pumpio_mirror']);
- PConfig::set(local_user(), 'pumpio', 'post_by_default',intval($_POST['pumpio_bydefault']));
+ PConfig::set(local_user(), 'pumpio', 'post' , intval($_POST['pumpio']));
+ PConfig::set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import']);
+ PConfig::set(local_user(), 'pumpio', 'host' , $host);
+ PConfig::set(local_user(), 'pumpio', 'user' , $user);
+ PConfig::set(local_user(), 'pumpio', 'public' , $_POST['pumpio_public']);
+ PConfig::set(local_user(), 'pumpio', 'mirror' , $_POST['pumpio_mirror']);
+ PConfig::set(local_user(), 'pumpio', 'post_by_default', intval($_POST['pumpio_bydefault']));
if (!$_POST['pumpio_mirror']) {
PConfig::delete(local_user(), 'pumpio', 'lastdate');
}
}
-function pumpio_load_config(\Friendica\App $a)
+function pumpio_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/pumpio.ini.php');
}
-function pumpio_post_local(&$a, &$b)
+function pumpio_post_local(App $a, array &$b)
{
if (!local_user() || (local_user() != $b['uid'])) {
return;
$pumpio_post = intval(PConfig::get(local_user(), 'pumpio', 'post'));
- $pumpio_enable = (($pumpio_post && x($_REQUEST, 'pumpio_enable')) ? intval($_REQUEST['pumpio_enable']) : 0);
+ $pumpio_enable = (($pumpio_post && !empty($_REQUEST['pumpio_enable'])) ? intval($_REQUEST['pumpio_enable']) : 0);
if ($b['api_source'] && intval(PConfig::get(local_user(), 'pumpio', 'post_by_default'))) {
$pumpio_enable = 1;
$b['postopts'] .= 'pumpio';
}
-function pumpio_send(&$a, &$b)
+function pumpio_send(App $a, array &$b)
{
- if (!PConfig::get($b["uid"], 'pumpio', 'import')) {
- if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
- return;
- }
+ if (!PConfig::get($b["uid"], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
+ return;
}
logger("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA);
}
}
-function pumpio_action(&$a, $uid, $uri, $action, $content = "")
+function pumpio_action(App $a, $uid, $uri, $action, $content = "")
{
// Don't do likes and other stuff if you don't import the timeline
if (!PConfig::get($uid, 'pumpio', 'import')) {
}
}
-function pumpio_sync(&$a)
+function pumpio_sync(App $a)
{
$r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'");
Config::set('pumpio', 'last_poll', time());
}
-function pumpio_cron(&$a, $b)
+function pumpio_cron(App $a, $b)
{
Worker::add(PRIORITY_MEDIUM,"addon/pumpio/pumpio_sync.php");
}
-function pumpio_fetchtimeline(&$a, $uid)
+function pumpio_fetchtimeline(App $a, $uid)
{
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
}
}
-function pumpio_dounlike(&$a, $uid, $self, $post, $own_id)
+function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
{
// Searching for the unliked post
// Two queries for speed issues
}
}
-function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = true)
+function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = true)
{
require_once('include/items.php');
return $contact_id;
}
-function pumpio_dodelete(&$a, $uid, $self, $post, $own_id)
+function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
{
// Two queries for speed issues
$condition = ['uri' => $post->object->id, 'uid' => $uid];
return false;
}
-function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcompletion = true)
+function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcompletion = true)
{
require_once('include/items.php');
return $top_item;
}
-function pumpio_fetchinbox(&$a, $uid)
+function pumpio_fetchinbox(App $a, $uid)
{
- $ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
- $csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
- $otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
- $osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
+ $ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
+ $csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
+ $otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
+ $osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$lastdate = PConfig::get($uid, 'pumpio', 'lastdate');
$hostname = PConfig::get($uid, 'pumpio', 'host');
$username = PConfig::get($uid, "pumpio", "user");
}
}
- foreach ($lastitems AS $item) {
+ foreach ($lastitems as $item) {
pumpio_fetchallcomments($a, $uid, $item["uri"]);
}
PConfig::set($uid, 'pumpio', 'last_id', $last_id);
}
-function pumpio_getallusers(&$a, $uid)
+function pumpio_getallusers(App &$a, $uid)
{
- $ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
- $csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
- $otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
- $osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
+ $ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
+ $csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
+ $otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
+ $osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$hostname = PConfig::get($uid, 'pumpio', 'host');
$username = PConfig::get($uid, "pumpio", "user");
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
if (pumpio_reachable($url)) {
- $success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError'=>true], $users);
+ $success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $users);
} else {
$success = false;
}
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
if (pumpio_reachable($url)) {
- $success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError'=>true], $users);
+ $success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $users);
} else {
$success = false;
}
}
if (is_array($users->items)) {
- foreach ($users->items AS $user) {
+ foreach ($users->items as $user) {
pumpio_get_contact($uid, $user);
}
}
}
-function pumpio_queue_hook(&$a, &$b)
+function pumpio_queue_hook(App $a, array &$b)
{
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
dbesc(NETWORK_PUMPIO)
);
+
if (!DBM::is_result($qi)) {
return;
}
//logger('pumpio_queue: fetching userdata '.print_r($userdata, true));
- $oauth_token = PConfig::get($userdata['uid'], "pumpio", "oauth_token");
+ $oauth_token = PConfig::get($userdata['uid'], "pumpio", "oauth_token");
$oauth_token_secret = PConfig::get($userdata['uid'], "pumpio", "oauth_token_secret");
- $consumer_key = PConfig::get($userdata['uid'], "pumpio","consumer_key");
- $consumer_secret = PConfig::get($userdata['uid'], "pumpio","consumer_secret");
+ $consumer_key = PConfig::get($userdata['uid'], "pumpio", "consumer_key");
+ $consumer_secret = PConfig::get($userdata['uid'], "pumpio", "consumer_secret");
$host = PConfig::get($userdata['uid'], "pumpio", "host");
$user = PConfig::get($userdata['uid'], "pumpio", "user");
}
}
-function pumpio_getreceiver(&$a, $b)
+function pumpio_getreceiver(App $a, array $b)
{
$receiver = [];
return $receiver;
}
-function pumpio_fetchallcomments(&$a, $uid, $id)
+function pumpio_fetchallcomments(App $a, $uid, $id)
{
- $ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
- $csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
- $otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
- $osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
+ $ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
+ $csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
+ $otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
+ $osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$hostname = PConfig::get($uid, 'pumpio', 'host');
$username = PConfig::get($uid, "pumpio", "user");