mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-13 03:48:49 +00:00
UserSession class - Refactor addon
This commit is contained in:
parent
8eca74cfab
commit
b0eb28143a
46 changed files with 534 additions and 580 deletions
|
@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -39,7 +38,7 @@ function tumblr_module() {}
|
|||
|
||||
function tumblr_content(App $a)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return '';
|
||||
}
|
||||
|
@ -172,8 +171,8 @@ function tumblr_callback(App $a)
|
|||
}
|
||||
|
||||
// What's next? Now that we have an Access Token and Secret, we can make an API call.
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'tumblr', 'oauth_token', $access_token['oauth_token']);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'tumblr', 'oauth_token_secret', $access_token['oauth_token_secret']);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token', $access_token['oauth_token']);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token_secret', $access_token['oauth_token_secret']);
|
||||
|
||||
$o = DI::l10n()->t("You are now authenticated to tumblr.");
|
||||
$o .= '<br /><a href="' . DI::baseUrl()->get() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';
|
||||
|
@ -183,17 +182,17 @@ function tumblr_callback(App $a)
|
|||
|
||||
function tumblr_jot_nets(App $a, array &$jotnets_fields)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(),'tumblr','post')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'tumblr','post')) {
|
||||
$jotnets_fields[] = [
|
||||
'type' => 'checkbox',
|
||||
'field' => [
|
||||
'tumblr_enable',
|
||||
DI::l10n()->t('Post to Tumblr'),
|
||||
DI::pConfig()->get(Session::getLocalUser(),'tumblr','post_by_default')
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(),'tumblr','post_by_default')
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@ -201,18 +200,18 @@ function tumblr_jot_nets(App $a, array &$jotnets_fields)
|
|||
|
||||
function tumblr_settings(App $a, array &$data)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$enabled = DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'post', false);
|
||||
$def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'post_by_default', false);
|
||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post', false);
|
||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', false);
|
||||
|
||||
$oauth_token = DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'oauth_token');
|
||||
$oauth_token_secret = DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'oauth_token_secret');
|
||||
$oauth_token = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token');
|
||||
$oauth_token_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token_secret');
|
||||
|
||||
if ($oauth_token && $oauth_token_secret) {
|
||||
$page = DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'page');
|
||||
$page = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'page');
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||
|
||||
|
@ -252,9 +251,9 @@ function tumblr_settings(App $a, array &$data)
|
|||
function tumblr_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['tumblr-submit'])) {
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'tumblr', 'post', intval($_POST['tumblr']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'tumblr', 'page', $_POST['tumblr_page']);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'tumblr', 'post_by_default', intval($_POST['tumblr_bydefault']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'post', intval($_POST['tumblr']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'page', $_POST['tumblr_page']);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', intval($_POST['tumblr_bydefault']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +280,7 @@ function tumblr_post_local(App $a, array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) {
|
||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,11 +288,11 @@ function tumblr_post_local(App $a, array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
$tmbl_post = intval(DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'post'));
|
||||
$tmbl_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post'));
|
||||
|
||||
$tmbl_enable = (($tmbl_post && !empty($_REQUEST['tumblr_enable'])) ? intval($_REQUEST['tumblr_enable']) : 0);
|
||||
|
||||
if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(), 'tumblr', 'post_by_default'))) {
|
||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default'))) {
|
||||
$tmbl_enable = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue