X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=pumpio%2Fpumpio.php;h=cd44b682e6ddf5e760cd65ade8e4ed152cee7252;hb=a0344101f122248c3069a5dcfa3ebfcb67215d5a;hp=92132a98a7e68b1bf7ba14f160b55fd30d9b27a3;hpb=bbaf463a204f84d0ac05336925abf99ae3583b8e;p=friendica-addons.git
diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php
index 92132a98..cd44b682 100644
--- a/pumpio/pumpio.php
+++ b/pumpio/pumpio.php
@@ -9,9 +9,7 @@
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
@@ -25,7 +23,6 @@ use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityNamespace;
use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\XML;
@@ -48,25 +45,12 @@ function pumpio_install()
Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
}
-function pumpio_uninstall()
-{
- Hook::unregister('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config');
- Hook::unregister('hook_fork', 'addon/pumpio/pumpio.php', 'pumpio_hook_fork');
- Hook::unregister('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
- Hook::unregister('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
- Hook::unregister('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
- Hook::unregister('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
- Hook::unregister('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
- Hook::unregister('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
- Hook::unregister('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
-}
-
function pumpio_module() {}
function pumpio_content(App $a)
{
if (!local_user()) {
- notice(L10n::t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.') . EOL);
return '';
}
@@ -102,13 +86,13 @@ function pumpio_registerclient(App $a, $host)
$params = [];
- $application_name = Config::get('pumpio', 'application_name');
+ $application_name = DI::config()->get('pumpio', 'application_name');
if ($application_name == "") {
$application_name = DI::baseUrl()->getHostname();
}
- $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
+ $adminlist = explode(",", str_replace(" ", "", DI::config()->get('config', 'admin_email')));
$params["type"] = "client_associate";
$params["contacts"] = $adminlist[0];
@@ -161,8 +145,7 @@ function pumpio_connect(App $a)
if (($consumer_key == "") || ($consumer_secret == "")) {
Logger::log("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname));
- $o .= L10n::t("Unable to register the client at the pump.io server '%s'.", $hostname);
- return $o;
+ return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname);
}
// The callback URL is the script that gets called after the user authenticates with pumpio
@@ -202,8 +185,8 @@ function pumpio_connect(App $a)
if ($success) {
Logger::log("pumpio_connect: authenticated");
- $o = L10n::t("You are now authenticated to pumpio.");
- $o .= '
'.L10n::t("return to the connector page").'';
+ $o = DI::l10n()->t("You are now authenticated to pumpio.");
+ $o .= '
'.DI::l10n()->t("return to the connector page").'';
} else {
Logger::log("pumpio_connect: could not connect");
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
@@ -223,7 +206,7 @@ function pumpio_jot_nets(App $a, array &$jotnets_fields)
'type' => 'checkbox',
'field' => [
'pumpio_enable',
- L10n::t('Post to pumpio'),
+ DI::l10n()->t('Post to pumpio'),
DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default')
]
];
@@ -264,20 +247,20 @@ function pumpio_settings(App $a, &$s)
/* Add some HTML to the existing form */
$s .= '';
- $s .= ''. L10n::t('Pump.io Import/Export/Mirror').'
';
+ $s .= ''. DI::l10n()->t('Pump.io Import/Export/Mirror').'
';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= ''. L10n::t('Pump.io Import/Export/Mirror').'
';
+ $s .= ''. DI::l10n()->t('Pump.io Import/Export/Mirror').'
';
$s .= '';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
@@ -288,36 +271,36 @@ function pumpio_settings(App $a, &$s)
$s .= '
';
if (($oauth_token == "") || ($oauth_token_secret == "")) {
$s .= '
';
} else {
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
}
@@ -327,7 +310,7 @@ function pumpio_settings(App $a, &$s)
/* provide a submit button */
- $s .= '
';
+ $s .= '
';
}
function pumpio_settings_post(App $a, array &$b)
@@ -528,7 +511,7 @@ function pumpio_send(App $a, array &$b)
if ($oauth_token && $oauth_token_secret) {
$title = trim($b['title']);
- $content = BBCode::convert($b['body'], false, 4);
+ $content = BBCode::convert($b['body'], false, BBCode::CONNECTORS);
$params = [];
@@ -674,7 +657,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
if ($success) {
Logger::log('pumpio_action '.$username.' '.$action.': success '.$uri);
} else {
- Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
+ Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri);
Worker::defer();
}
}
@@ -687,9 +670,9 @@ function pumpio_sync(App $a)
return;
}
- $last = Config::get('pumpio', 'last_poll');
+ $last = DI::config()->get('pumpio', 'last_poll');
- $poll_interval = intval(Config::get('pumpio', 'poll_interval', PUMPIO_DEFAULT_POLL_INTERVAL));
+ $poll_interval = intval(DI::config()->get('pumpio', 'poll_interval', PUMPIO_DEFAULT_POLL_INTERVAL));
if ($last) {
$next = $last + ($poll_interval * 60);
@@ -708,7 +691,7 @@ function pumpio_sync(App $a)
}
}
- $abandon_days = intval(Config::get('system', 'account_abandon_days'));
+ $abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}
@@ -746,7 +729,7 @@ function pumpio_sync(App $a)
Logger::log('pumpio: cron_end');
- Config::set('pumpio', 'last_poll', time());
+ DI::config()->set('pumpio', 'last_poll', time());
}
function pumpio_cron(App $a, $b)
@@ -769,7 +752,7 @@ function pumpio_fetchtimeline(App $a, $uid)
// hostname of the node if neither one is set.
$application_name = DI::pConfig()->get($uid, 'pumpio', 'application_name');
if ($application_name == "") {
- $application_name = Config::get('pumpio', 'application_name');
+ $application_name = DI::config()->get('pumpio', 'application_name');
}
if ($application_name == "") {
$application_name = DI::baseUrl()->getHostname();
@@ -916,7 +899,7 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
}
}
- Item::delete(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
+ Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
if (DBA::isResult($r)) {
Logger::log("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
@@ -927,8 +910,6 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = true)
{
- require_once('include/items.php');
-
if (empty($post->object->id)) {
Logger::log('Got empty like: '.print_r($post, true), Logger::DEBUG);
return;
@@ -996,11 +977,11 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
$author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
$objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
- $post_type = L10n::t('status');
+ $post_type = DI::l10n()->t('status');
$plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
$likedata['object-type'] = Activity\ObjectType::NOTE;
- $likedata['body'] = L10n::t('%1$s likes %2$s\'s %3$s', $author, $objauthor, $plink);
+ $likedata['body'] = DI::l10n()->t('%1$s likes %2$s\'s %3$s', $author, $objauthor, $plink);
$likedata['object'] = '';
@@ -1073,7 +1054,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
}
if (!empty($contact->image->url)) {
- Contact::updateAvatar($contact->image->url, $uid, $contact_id);
+ Contact::updateAvatar($contact_id, $contact->image->url);
}
return $contact_id;
@@ -1084,13 +1065,13 @@ function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
// Two queries for speed issues
$condition = ['uri' => $post->object->id, 'uid' => $uid];
if (Item::exists($condition)) {
- Item::delete($condition);
+ Item::markForDeletion($condition);
return true;
}
$condition = ['extid' => $post->object->id, 'uid' => $uid];
if (Item::exists($condition)) {
- Item::delete($condition);
+ Item::markForDeletion($condition);
return true;
}
return false;
@@ -1098,8 +1079,6 @@ function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcompletion = true)
{
- require_once('include/items.php');
-
if (($post->verb == "like") || ($post->verb == "favorite")) {
return pumpio_dolike($a, $uid, $self, $post, $own_id);
}
@@ -1279,9 +1258,8 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$created = '';
}
- $postarray['body'] = share_header($share_author, $post->object->author->url,
- $post->object->author->image->url, "",
- $created, $post->links->self->href).
+ $postarray['body'] = Friendica\Content\Text\BBCode::getShareOpeningTag($share_author, $post->object->author->url,
+ $post->object->author->image->url, $post->links->self->href, $created) .
$postarray['body']."[/share]";
}
@@ -1525,12 +1503,12 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
// Fetching the original post
$condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
- $item = Item::selectFirst(['extid'], $condition);
- if (!DBA::isResult($item)) {
+ $original = Item::selectFirst(['extid'], $condition);
+ if (!DBA::isResult($original)) {
return false;
}
- $url = $item["extid"];
+ $url = $original["extid"];
$client = new oauth_client_class;
$client->oauth_version = '1.0a';
@@ -1612,7 +1590,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
function pumpio_reachable($url)
{
- return Network::curl($url, false, ['timeout' => 10])->isSuccess();
+ return DI::httpRequest()->get($url, ['timeout' => 10])->isSuccess();
}
/*