]> git.mxchange.org Git - friendica-addons.git/commitdiff
Use globals instead of $a->data
authorMichael <heluecht@pirati.ca>
Sun, 25 Jul 2021 17:28:07 +0000 (17:28 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 25 Jul 2021 17:28:07 +0000 (17:28 +0000)
blockem/blockem.php
forumdirectory/forumdirectory.php
js_upload/js_upload.php

index 1880b9be44e5029bcc36a7da1e20c78746177bc8..3183915c5aa56bb2d14184f0ff04ad744d8d167f 100644 (file)
@@ -12,6 +12,8 @@ use Friendica\Core\Hook;
 use Friendica\DI;
 use Friendica\Util\Strings;
 
+global $blockem_words;
+
 function blockem_install()
 {
        Hook::register('prepare_body_content_filter', 'addon/blockem/blockem.php', 'blockem_prepare_body_content_filter');
@@ -141,6 +143,8 @@ function blockem_display_item(App $a, array &$b = null)
 
 function blockem_conversation_start(App $a, array &$b)
 {
+       global $blockem_words;
+
        if (!local_user()) {
                return;
        }
@@ -148,7 +152,7 @@ function blockem_conversation_start(App $a, array &$b)
        $words = DI::pConfig()->get(local_user(), 'blockem', 'words');
 
        if ($words) {
-               $a->data['blockem'] = explode(',', $words);
+               $blockem_words = explode(',', $words);
        }
 
        DI::page()['htmlhead'] .= <<< EOT
@@ -171,6 +175,8 @@ EOT;
 
 function blockem_item_photo_menu(App $a, array &$b)
 {
+       global $blockem_words;
+
        if (!local_user() || $b['item']['self']) {
                return;
        }
@@ -178,8 +184,8 @@ function blockem_item_photo_menu(App $a, array &$b)
        $blocked = false;
        $author = $b['item']['author-link'];
 
-       if (!empty($a->data['blockem'])) {
-               foreach($a->data['blockem'] as $bloke) {
+       if (!empty($blockem_words)) {
+               foreach($blockem_words as $bloke) {
                        if (Strings::compareLink($bloke,$author)) {
                                $blocked = true;
                                break;
index bf15ab62c80d8c2b152bd6aad3b92665379843ec..cf65bcc14733337877b5cea22c6e73cadc936907 100644 (file)
@@ -18,6 +18,8 @@ use Friendica\Model\Profile;
 use Friendica\Model\User;
 use Friendica\Util\Strings;
 
+global $forumdirectory_search;
+
 function forumdirectory_install()
 {
        Hook::register('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
@@ -42,13 +44,17 @@ function forumdirectory_init(App $a)
 
 function forumdirectory_post(App $a)
 {
+       global $forumdirectory_search;
+
        if (!empty($_POST['search'])) {
-               $a->data['search'] = $_POST['search'];
+               $forumdirectory_search = $_POST['search'];
        }
 }
 
 function forumdirectory_content(App $a)
 {
+       global $forumdirectory_search;
+
        if ((DI::config()->get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
                notice(DI::l10n()->t('Public access denied.') . EOL);
                return;
@@ -59,8 +65,8 @@ function forumdirectory_content(App $a)
 
        Nav::setSelected('directory');
 
-       if (!empty($a->data['search'])) {
-               $search = Strings::escapeTags(trim($a->data['search']));
+       if (!empty($forumdirectory_search)) {
+               $search = Strings::escapeTags(trim($forumdirectory_search));
        } else {
                $search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
        }
index 6a86575fe8e9a8ec7649d08b274ed1400329bdae..89f62ea4dac04ef38714fc4e8ab8bf374d2baba4 100644 (file)
@@ -14,6 +14,9 @@ use Friendica\Core\Renderer;
 use Friendica\DI;
 use Friendica\Util\Strings;
 
+global $js_upload_jsonresponse;
+global $js_upload_result;
+
 function js_upload_install()
 {
        Hook::register('photo_upload_form', __FILE__, 'js_upload_form');
@@ -42,6 +45,8 @@ function js_upload_form(App $a, array &$b)
 
 function js_upload_post_init(App $a, &$b)
 {
+       global $js_upload_result, $js_upload_jsonresponse;
+
        // list of valid extensions
        $allowedExtensions = ['jpeg', 'gif', 'png', 'jpg'];
 
@@ -53,7 +58,7 @@ function js_upload_post_init(App $a, &$b)
        $result = $uploader->handleUpload();
 
        // to pass data through iframe you will need to encode all html tags
-       $a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
+       $js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 
        if (isset($result['error'])) {
                Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'], Logger::DEBUG);
@@ -61,12 +66,14 @@ function js_upload_post_init(App $a, &$b)
                exit();
        }
 
-       $a->data['upload_result'] = $result;
+       $js_upload_result = $result;
 }
 
 function js_upload_post_file(App $a, &$b)
 {
-       $result = $a->data['upload_result'];
+       global $js_upload_result;
+
+       $result = $js_upload_result;
 
        $b['src'] = $result['path'];
        $b['filename'] = $result['filename'];
@@ -76,9 +83,11 @@ function js_upload_post_file(App $a, &$b)
 
 function js_upload_post_end(App $a, &$b)
 {
+       global $js_upload_jsonresponse;
+
        Logger::log('upload_post_end');
-       if (!empty($a->data['upload_jsonresponse'])) {
-               echo $a->data['upload_jsonresponse'];
+       if (!empty($js_upload_jsonresponse)) {
+               echo $js_upload_jsonresponse;
                exit();
        }
 }