mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-06-07 09:54:27 +02:00
UserSession class - Refactor addon
This commit is contained in:
parent
8eca74cfab
commit
b0eb28143a
46 changed files with 534 additions and 580 deletions
|
@ -23,7 +23,6 @@ use Friendica\App;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
|
||||
function randplace_install()
|
||||
|
@ -65,12 +64,12 @@ function randplace_post_hook(App $a, &$item)
|
|||
*/
|
||||
Logger::notice('randplace invoked');
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
/* non-zero if this is a logged in user of this system */
|
||||
return;
|
||||
}
|
||||
|
||||
if (Session::getLocalUser() != $item['uid']) {
|
||||
if (DI::userSession()->getLocalUserId() != $item['uid']) {
|
||||
/* Does this person own the post? */
|
||||
return;
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ function randplace_post_hook(App $a, &$item)
|
|||
|
||||
/* Retrieve our personal config setting */
|
||||
|
||||
$active = DI::pConfig()->get(Session::getLocalUser(), 'randplace', 'enable');
|
||||
$active = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'randplace', 'enable');
|
||||
|
||||
if (!$active) {
|
||||
return;
|
||||
|
@ -123,12 +122,12 @@ function randplace_post_hook(App $a, &$item)
|
|||
*/
|
||||
function randplace_settings_post(App $a, $post)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_POST['randplace-submit']) {
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'randplace', 'enable', intval($_POST['randplace']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'randplace', 'enable', intval($_POST['randplace']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,11 +138,11 @@ function randplace_settings_post(App $a, $post)
|
|||
*/
|
||||
function randplace_settings(App &$a, array &$data)
|
||||
{
|
||||
if(!Session::getLocalUser()) {
|
||||
if(!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$enabled = DI::pConfig()->get(Session::getLocalUser(),'randplace','enable');
|
||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(),'randplace','enable');
|
||||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/randplace/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue