X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=superblock%2Fsuperblock.php;h=e0b3ff83e9f859803e5e173aca6053c25492d9ee;hb=4e9838f5717f789c650a1109574189e23fdf88da;hp=1462c184df56defa62dc5521c45d4e266a9d4bff;hpb=72f23f7b5236bdfc1d8c1b878ca22261ae8e55dd;p=friendica-addons.git diff --git a/superblock/superblock.php b/superblock/superblock.php old mode 100755 new mode 100644 index 1462c184..e0b3ff83 --- a/superblock/superblock.php +++ b/superblock/superblock.php @@ -1,116 +1,117 @@ - * + * */ - -function superblock_install() { - - register_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings'); - register_hook('plugin_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post'); - register_hook('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start'); - register_hook('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu'); - register_hook('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store'); - +use Friendica\Core\Hook; +use Friendica\DI; +use Friendica\Util\Strings; + +function superblock_install() +{ + Hook::register('addon_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings'); + Hook::register('addon_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post'); + Hook::register('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start'); + Hook::register('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu'); + Hook::register('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store'); } - -function superblock_uninstall() { - - unregister_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings'); - unregister_hook('plugin_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post'); - unregister_hook('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start'); - unregister_hook('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu'); - unregister_hook('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store'); - +function superblock_uninstall() +{ + Hook::unregister('addon_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings'); + Hook::unregister('addon_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post'); + Hook::unregister('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start'); + Hook::unregister('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu'); + Hook::unregister('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store'); } - - - - -function superblock_addon_settings(&$a,&$s) { - - if(! local_user()) +function superblock_addon_settings(&$a, &$s) +{ + if (!local_user()) { return; + } - /* Add our stylesheet to the page so we can make our settings look nice */ - - $a->page['htmlhead'] .= '' . "\r\n"; + /* Add our stylesheet to the page so we can make our settings look nice */ + DI::page()['htmlhead'] .= '' . "\r\n"; - $words = get_pconfig(local_user(),'system','blocked'); - if(! $words) + $words = DI::pConfig()->get(local_user(), 'system', 'blocked'); + if (!$words) { $words = ''; + } - $s .= '
'; - $s .= '

' . t('"Superblock" Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; + $s .= ''; + $s .= '

' . DI::l10n()->t('Superblock') . '

'; + $s .= '
'; + $s .= ''; + $s .= '
'; return; - } -function superblock_addon_settings_post(&$a,&$b) { - - if(! local_user()) +function superblock_addon_settings_post(&$a, &$b) +{ + if (!local_user()) { return; + } - if($_POST['superblock-submit']) { - set_pconfig(local_user(),'system','blocked',trim($_POST['superblock-words'])); - info( t('SUPERBLOCK Settings saved.') . EOL); + if (!empty($_POST['superblock-submit'])) { + DI::pConfig()->set(local_user(), 'system', 'blocked',trim($_POST['superblock-words'])); + info(DI::l10n()->t('SUPERBLOCK Settings saved.') . EOL); } } function superblock_enotify_store(&$a,&$b) { - $words = get_pconfig($b['uid'],'system','blocked'); - if($words) { - $arr = explode(',',$words); - } - else { + $words = DI::pConfig()->get($b['uid'], 'system', 'blocked'); + if ($words) { + $arr = explode(',', $words); + } else { return; } $found = false; - if(count($arr)) { - foreach($arr as $word) { - if(! strlen(trim($word))) { + if (count($arr)) { + foreach ($arr as $word) { + if (!strlen(trim($word))) { continue; } - if(link_compare($b['url'],$word)) { + if (Strings::compareLink($b['url'], $word)) { $found = true; break; } } } - if($found) { - $b['abort'] = true; + if ($found) { + // Empty out the fields + $b = []; } } -function superblock_conversation_start(&$a,&$b) { - - if(! local_user()) +function superblock_conversation_start(&$a, &$b) +{ + if (!local_user()) { return; + } - $words = get_pconfig(local_user(),'system','blocked'); - if($words) { - $a->data['superblock'] = explode(',',$words); + $words = DI::pConfig()->get(local_user(), 'system', 'blocked'); + if ($words) { + $a->data['superblock'] = explode(',', $words); } - $a->page['htmlhead'] .= <<< EOT + DI::page()['htmlhead'] .= <<< EOT