From: Michael Date: Sun, 25 Jul 2021 17:28:07 +0000 (+0000) Subject: Use globals instead of $a->data X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d902f6808d8c00c1abba103a2bedee379fce51f8;p=friendica-addons.git Use globals instead of $a->data --- diff --git a/blockem/blockem.php b/blockem/blockem.php index 1880b9be..3183915c 100644 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@ -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; diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index bf15ab62..cf65bcc1 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -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']))) : ''); } diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php index 6a86575f..89f62ea4 100644 --- a/js_upload/js_upload.php +++ b/js_upload/js_upload.php @@ -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(); } }