X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=pumpio%2Fpumpio.php;h=357f17433b1bf495eb1868760b8fc00ae124b264;hb=940d4658541eef8b5f92bcb0b8b1ec1e73c1cf7b;hp=c4093f2b8ff89fd1b04a55612cc07c1125ed0879;hpb=1acfd0b31c2c977e67f62a91a206762d2cbb658f;p=friendica-addons.git
diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php
index c4093f2b..357f1743 100644
--- a/pumpio/pumpio.php
+++ b/pumpio/pumpio.php
@@ -9,22 +9,21 @@
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\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Model\User;
-use Friendica\Util\Config\ConfigFileLoader;
+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;
@@ -47,25 +46,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 '';
}
@@ -89,8 +75,8 @@ function pumpio_content(App $a)
function pumpio_check_item_notification($a, &$notification_data)
{
- $hostname = PConfig::get($notification_data["uid"], 'pumpio', 'host');
- $username = PConfig::get($notification_data["uid"], "pumpio", "user");
+ $hostname = DI::pConfig()->get($notification_data["uid"], 'pumpio', 'host');
+ $username = DI::pConfig()->get($notification_data["uid"], "pumpio", "user");
$notification_data["profiles"][] = "https://".$hostname."/".$username;
}
@@ -101,20 +87,20 @@ 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 = $a->getHostName();
+ $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];
$params["application_type"] = "native";
$params["application_name"] = $application_name;
- $params["logo_url"] = $a->getBaseURL()."/images/friendica-256.png";
- $params["redirect_uris"] = $a->getBaseURL()."/pumpio/connect";
+ $params["logo_url"] = DI::baseUrl()->get()."/images/friendica-256.png";
+ $params["redirect_uris"] = DI::baseUrl()->get()."/pumpio/connect";
Logger::log("pumpio_registerclient: ".$url." parameters ".print_r($params, true), Logger::DEBUG);
@@ -141,18 +127,18 @@ function pumpio_registerclient(App $a, $host)
function pumpio_connect(App $a)
{
// Define the needed keys
- $consumer_key = PConfig::get(local_user(), 'pumpio', 'consumer_key');
- $consumer_secret = PConfig::get(local_user(), 'pumpio', 'consumer_secret');
- $hostname = PConfig::get(local_user(), 'pumpio', 'host');
+ $consumer_key = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_key');
+ $consumer_secret = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_secret');
+ $hostname = DI::pConfig()->get(local_user(), 'pumpio', 'host');
if ((($consumer_key == "") || ($consumer_secret == "")) && ($hostname != "")) {
Logger::log("pumpio_connect: register client");
$clientdata = pumpio_registerclient($a, $hostname);
- PConfig::set(local_user(), 'pumpio', 'consumer_key', $clientdata->client_id);
- PConfig::set(local_user(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key', $clientdata->client_id);
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
- $consumer_key = PConfig::get(local_user(), 'pumpio', 'consumer_key');
- $consumer_secret = PConfig::get(local_user(), 'pumpio', 'consumer_secret');
+ $consumer_key = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_key');
+ $consumer_secret = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_secret');
Logger::log("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret, Logger::DEBUG);
}
@@ -160,12 +146,11 @@ 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
- $callback_url = $a->getBaseURL()."/pumpio/connect";
+ $callback_url = DI::baseUrl()->get()."/pumpio/connect";
// Let's begin. First we need a Request Token. The request token is required to send the user
// to pumpio's login page.
@@ -189,8 +174,8 @@ function pumpio_connect(App $a)
if (($success = $client->Process())) {
if (strlen($client->access_token)) {
Logger::log("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret, Logger::DEBUG);
- PConfig::set(local_user(), "pumpio", "oauth_token", $client->access_token);
- PConfig::set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret);
+ DI::pConfig()->set(local_user(), "pumpio", "oauth_token", $client->access_token);
+ DI::pConfig()->set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret);
}
}
$success = $client->Finalize($success);
@@ -201,8 +186,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.';
@@ -217,13 +202,13 @@ function pumpio_jot_nets(App $a, array &$jotnets_fields)
return;
}
- if (PConfig::get(local_user(), 'pumpio', 'post')) {
+ if (DI::pConfig()->get(local_user(), 'pumpio', 'post')) {
$jotnets_fields[] = [
'type' => 'checkbox',
'field' => [
'pumpio_enable',
- L10n::t('Post to pumpio'),
- PConfig::get(local_user(), 'pumpio', 'post_by_default')
+ DI::l10n()->t('Post to pumpio'),
+ DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default')
]
];
}
@@ -237,86 +222,86 @@ function pumpio_settings(App $a, &$s)
/* Add our stylesheet to the page so we can make our settings look nice */
- $a->page['htmlhead'] .= '' . "\r\n";
+ DI::page()['htmlhead'] .= '' . "\r\n";
/* Get the current state of our config variables */
- $import_enabled = PConfig::get(local_user(), 'pumpio', 'import');
+ $import_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'import');
$import_checked = (($import_enabled) ? ' checked="checked" ' : '');
- $enabled = PConfig::get(local_user(), 'pumpio', 'post');
+ $enabled = DI::pConfig()->get(local_user(), 'pumpio', 'post');
$checked = (($enabled) ? ' checked="checked" ' : '');
$css = (($enabled) ? '' : '-disabled');
- $def_enabled = PConfig::get(local_user(), 'pumpio', 'post_by_default');
+ $def_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default');
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
- $public_enabled = PConfig::get(local_user(), 'pumpio', 'public');
+ $public_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'public');
$public_checked = (($public_enabled) ? ' checked="checked" ' : '');
- $mirror_enabled = PConfig::get(local_user(), 'pumpio', 'mirror');
+ $mirror_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'mirror');
$mirror_checked = (($mirror_enabled) ? ' checked="checked" ' : '');
- $servername = PConfig::get(local_user(), "pumpio", "host");
- $username = PConfig::get(local_user(), "pumpio", "user");
+ $servername = DI::pConfig()->get(local_user(), "pumpio", "host");
+ $username = DI::pConfig()->get(local_user(), "pumpio", "user");
/* Add some HTML to the existing form */
$s .= '';
- $s .= '![](images/pumpio.png)
'. L10n::t('Pump.io Import/Export/Mirror').'
';
+ $s .= '![](images/pumpio.png)
'. DI::l10n()->t('Pump.io Import/Export/Mirror').'
';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '![](images/pumpio.png)
'. L10n::t('Pump.io Import/Export/Mirror').'
';
+ $s .= '![](images/pumpio.png)
'. DI::l10n()->t('Pump.io Import/Export/Mirror').'
';
$s .= '';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
if (($username != '') && ($servername != '')) {
- $oauth_token = PConfig::get(local_user(), "pumpio", "oauth_token");
- $oauth_token_secret = PConfig::get(local_user(), "pumpio", "oauth_token_secret");
+ $oauth_token = DI::pConfig()->get(local_user(), "pumpio", "oauth_token");
+ $oauth_token_secret = DI::pConfig()->get(local_user(), "pumpio", "oauth_token_secret");
$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 .= '
';
}
@@ -326,26 +311,26 @@ function pumpio_settings(App $a, &$s)
/* provide a submit button */
- $s .= '
';
+ $s .= '
';
}
function pumpio_settings_post(App $a, array &$b)
{
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' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'oauth_token' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'oauth_token_secret', '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'post' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'import' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'host' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'user' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'public' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'mirror' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'post_by_default' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'lastdate' , 0);
+ DI::pConfig()->set(local_user(), 'pumpio', 'last_id' , '');
} else {
// filtering the username if it is filled wrong
$user = $_POST['pumpio_user'];
@@ -362,16 +347,16 @@ function pumpio_settings_post(App $a, array &$b)
$host = trim($host);
$host = str_replace(["https://", "http://"], ["", ""], $host);
- PConfig::set(local_user(), 'pumpio', 'post' , defaults($_POST, 'pumpio', false));
- PConfig::set(local_user(), 'pumpio', 'import' , defaults($_POST, 'pumpio_import', false));
- PConfig::set(local_user(), 'pumpio', 'host' , $host);
- PConfig::set(local_user(), 'pumpio', 'user' , $user);
- PConfig::set(local_user(), 'pumpio', 'public' , defaults($_POST, 'pumpio_public', false));
- PConfig::set(local_user(), 'pumpio', 'mirror' , defaults($_POST, 'pumpio_mirror', false));
- PConfig::set(local_user(), 'pumpio', 'post_by_default', defaults($_POST, 'pumpio_bydefault', false));
+ DI::pConfig()->set(local_user(), 'pumpio', 'post' , $_POST['pumpio'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'host' , $host);
+ DI::pConfig()->set(local_user(), 'pumpio', 'user' , $user);
+ DI::pConfig()->set(local_user(), 'pumpio', 'public' , $_POST['pumpio_public'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'mirror' , $_POST['pumpio_mirror'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'post_by_default', $_POST['pumpio_bydefault'] ?? false);
if (!empty($_POST['pumpio_mirror'])) {
- PConfig::delete(local_user(), 'pumpio', 'lastdate');
+ DI::pConfig()->delete(local_user(), 'pumpio', 'lastdate');
}
}
}
@@ -402,9 +387,9 @@ function pumpio_hook_fork(App $a, array &$b)
return;
}
- if (PConfig::get($post['uid'], 'pumpio', 'import')) {
+ if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
// Don't fork if it isn't a reply to a pump.io post
- if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
+ if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
Logger::log('No pump.io parent found for item ' . $post['id']);
$b['execute'] = false;
return;
@@ -424,11 +409,11 @@ function pumpio_post_local(App $a, array &$b)
return;
}
- $pumpio_post = intval(PConfig::get(local_user(), 'pumpio', 'post'));
+ $pumpio_post = intval(DI::pConfig()->get(local_user(), 'pumpio', 'post'));
$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'))) {
+ if ($b['api_source'] && intval(DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default'))) {
$pumpio_enable = 1;
}
@@ -445,7 +430,7 @@ function pumpio_post_local(App $a, array &$b)
function pumpio_send(App $a, array &$b)
{
- if (!PConfig::get($b["uid"], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
+ if (!DI::pConfig()->get($b["uid"], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
return;
}
@@ -454,7 +439,7 @@ function pumpio_send(App $a, array &$b)
if ($b['parent'] != $b['id']) {
// Looking if its a reply to a pumpio post
$condition = ['id' => $b['parent'], 'network' => Protocol::PUMPIO];
- $orig_post = Item::selectFirst([], $condition);
+ $orig_post = Post::selectFirst([], $condition);
if (!DBA::isResult($orig_post)) {
Logger::log("pumpio_send: no pumpio post ".$b["parent"]);
@@ -481,7 +466,7 @@ function pumpio_send(App $a, array &$b)
}
}
- if ($b['verb'] == ACTIVITY_LIKE) {
+ if ($b['verb'] == Activity::LIKE) {
if ($b['deleted']) {
pumpio_action($a, $b["uid"], $b["thr-parent"], "unlike");
} else {
@@ -490,15 +475,15 @@ function pumpio_send(App $a, array &$b)
return;
}
- if ($b['verb'] == ACTIVITY_DISLIKE) {
+ if ($b['verb'] == Activity::DISLIKE) {
return;
}
- if (($b['verb'] == ACTIVITY_POST) && ($b['created'] !== $b['edited']) && !$b['deleted']) {
+ if (($b['verb'] == Activity::POST) && ($b['created'] !== $b['edited']) && !$b['deleted']) {
pumpio_action($a, $b["uid"], $b["uri"], "update", $b["body"]);
}
- if (($b['verb'] == ACTIVITY_POST) && $b['deleted']) {
+ if (($b['verb'] == Activity::POST) && $b['deleted']) {
pumpio_action($a, $b["uid"], $b["uri"], "delete");
}
@@ -515,19 +500,19 @@ function pumpio_send(App $a, array &$b)
// Support for native shares
// http:///api//shares?id=
- $oauth_token = PConfig::get($b['uid'], "pumpio", "oauth_token");
- $oauth_token_secret = PConfig::get($b['uid'], "pumpio", "oauth_token_secret");
- $consumer_key = PConfig::get($b['uid'], "pumpio","consumer_key");
- $consumer_secret = PConfig::get($b['uid'], "pumpio","consumer_secret");
+ $oauth_token = DI::pConfig()->get($b['uid'], "pumpio", "oauth_token");
+ $oauth_token_secret = DI::pConfig()->get($b['uid'], "pumpio", "oauth_token_secret");
+ $consumer_key = DI::pConfig()->get($b['uid'], "pumpio","consumer_key");
+ $consumer_secret = DI::pConfig()->get($b['uid'], "pumpio","consumer_secret");
- $host = PConfig::get($b['uid'], "pumpio", "host");
- $user = PConfig::get($b['uid'], "pumpio", "user");
- $public = PConfig::get($b['uid'], "pumpio", "public");
+ $host = DI::pConfig()->get($b['uid'], "pumpio", "host");
+ $user = DI::pConfig()->get($b['uid'], "pumpio", "user");
+ $public = DI::pConfig()->get($b['uid'], "pumpio", "public");
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 = [];
@@ -561,8 +546,8 @@ function pumpio_send(App $a, array &$b)
$inReplyTo = ["id" => $orig_post["uri"],
"objectType" => "note"];
- if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA))) {
- $inReplyTo["objectType"] = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
+ if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], ActivityNamespace::ACTIVITY_SCHEMA))) {
+ $inReplyTo["objectType"] = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
}
$params["object"] = [
@@ -595,7 +580,7 @@ function pumpio_send(App $a, array &$b)
if ($success) {
if ($user->generator->displayName) {
- PConfig::set($b["uid"], "pumpio", "application_name", $user->generator->displayName);
+ DI::pConfig()->set($b["uid"], "pumpio", "application_name", $user->generator->displayName);
}
$post_id = $user->object->id;
@@ -614,18 +599,18 @@ function pumpio_send(App $a, array &$b)
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')) {
+ if (!DI::pConfig()->get($uid, 'pumpio', 'import')) {
return;
}
- $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");
+ $ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key');
+ $csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
+ $otoken = DI::pConfig()->get($uid, 'pumpio', 'oauth_token');
+ $osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
+ $hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
+ $username = DI::pConfig()->get($uid, "pumpio", "user");
- $orig_post = Item::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
+ $orig_post = Post::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
if (!DBA::isResult($orig_post)) {
return;
@@ -637,8 +622,8 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
$uri = $orig_post["uri"];
}
- if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA))) {
- $objectType = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
+ if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], ActivityNamespace::ACTIVITY_SCHEMA))) {
+ $objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
} elseif (strstr($uri, "/api/comment/")) {
$objectType = "comment";
} elseif (strstr($uri, "/api/note/")) {
@@ -673,7 +658,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();
}
}
@@ -686,9 +671,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);
@@ -707,7 +692,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;
}
@@ -729,7 +714,7 @@ function pumpio_sync(App $a)
pumpio_fetchinbox($a, $rr['uid']);
// check for new contacts once a day
- $last_contact_check = PConfig::get($rr['uid'], 'pumpio', 'contact_check');
+ $last_contact_check = DI::pConfig()->get($rr['uid'], 'pumpio', 'contact_check');
if ($last_contact_check) {
$next_contact_check = $last_contact_check + 86400;
} else {
@@ -738,14 +723,14 @@ function pumpio_sync(App $a)
if ($next_contact_check <= time()) {
pumpio_getallusers($a, $rr["uid"]);
- PConfig::set($rr['uid'], 'pumpio', 'contact_check', time());
+ DI::pConfig()->set($rr['uid'], 'pumpio', 'contact_check', time());
}
}
}
Logger::log('pumpio: cron_end');
- Config::set('pumpio', 'last_poll', time());
+ DI::config()->set('pumpio', 'last_poll', time());
}
function pumpio_cron(App $a, $b)
@@ -755,23 +740,23 @@ function pumpio_cron(App $a, $b)
function pumpio_fetchtimeline(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');
- $lastdate = PConfig::get($uid, 'pumpio', 'lastdate');
- $hostname = PConfig::get($uid, 'pumpio', 'host');
- $username = PConfig::get($uid, "pumpio", "user");
+ $ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key');
+ $csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
+ $otoken = DI::pConfig()->get($uid, 'pumpio', 'oauth_token');
+ $osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
+ $lastdate = DI::pConfig()->get($uid, 'pumpio', 'lastdate');
+ $hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
+ $username = DI::pConfig()->get($uid, "pumpio", "user");
// get the application name for the pump.io app
// 1st try personal config, then system config and fallback to the
// hostname of the node if neither one is set.
- $application_name = PConfig::get($uid, 'pumpio', 'application_name');
+ $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 = $a->getHostName();
+ $application_name = DI::baseUrl()->getHostname();
}
$first_time = ($lastdate == "");
@@ -880,7 +865,7 @@ function pumpio_fetchtimeline(App $a, $uid)
}
if ($lastdate != 0) {
- PConfig::set($uid, 'pumpio', 'lastdate', $lastdate);
+ DI::pConfig()->set($uid, 'pumpio', 'lastdate', $lastdate);
}
}
@@ -888,9 +873,9 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
{
// Searching for the unliked post
// Two queries for speed issues
- $orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
+ $orig_post = Post::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
if (!DBA::isResult($orig_post)) {
- $orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
+ $orig_post = Post::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
if (!DBA::isResult($orig_post)) {
return;
}
@@ -915,7 +900,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']);
@@ -926,8 +911,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;
@@ -935,9 +918,9 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
// Searching for the liked post
// Two queries for speed issues
- $orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
+ $orig_post = Post::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
if (!DBA::isResult($orig_post)) {
- $orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
+ $orig_post = Post::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
if (!DBA::isResult($orig_post)) {
return;
}
@@ -970,21 +953,21 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
}
}
- $condition = ['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']];
- if (Item::exists($condition)) {
+ $condition = ['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']];
+ if (Post::exists($condition)) {
Logger::log("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
return;
}
$likedata = [];
$likedata['parent'] = $orig_post['id'];
- $likedata['verb'] = ACTIVITY_LIKE;
+ $likedata['verb'] = Activity::LIKE;
$likedata['gravity'] = GRAVITY_ACTIVITY;
$likedata['uid'] = $uid;
$likedata['wall'] = 0;
$likedata['network'] = Protocol::PUMPIO;
$likedata['uri'] = Item::newURI($uid);
- $likedata['parent-uri'] = $orig_post["uri"];
+ $likedata['thr-parent'] = $orig_post['uri'];
$likedata['contact-id'] = $contactid;
$likedata['app'] = $post->generator->displayName;
$likedata['author-name'] = $post->actor->displayName;
@@ -995,13 +978,13 @@ 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_OBJ_NOTE;
+ $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'] = '