X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=superblock%2Fsuperblock.php;h=c33c699db45881b3b95df49fa22e83e606a6a7e3;hb=d9330e3b05c71bbd172293fb223271033d3b19f7;hp=41abb47146d0534953fb00c2261fd147b9d00948;hpb=4a400894aac9e71d33bec4562de6feb8265b40a4;p=friendica-addons.git diff --git a/superblock/superblock.php b/superblock/superblock.php old mode 100755 new mode 100644 index 41abb471..c33c699d --- a/superblock/superblock.php +++ b/superblock/superblock.php @@ -6,15 +6,19 @@ * Description: block people * Version: 1.0 * Author: Mike Macgirvin - * + * */ +use Friendica\Core\PConfig; + 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'); + } @@ -24,6 +28,7 @@ function superblock_uninstall() { 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'); } @@ -33,29 +38,34 @@ function superblock_uninstall() { function superblock_addon_settings(&$a,&$s) { - if(! local_user()) + 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 */ + $a->page['htmlhead'] .= '' . "\r\n"; - $words = get_pconfig(local_user(),'system','blocked'); - if(! $words) + $words = PConfig::get(local_user(),'system','blocked'); + if(! $words) { $words = ''; + } - $s .= '
'; - $s .= '

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

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

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

'; + $s .= '
'; + $s .= ''; + $s .= '
'; return; - } function superblock_addon_settings_post(&$a,&$b) { @@ -64,17 +74,46 @@ function superblock_addon_settings_post(&$a,&$b) { return; if($_POST['superblock-submit']) { - set_pconfig(local_user(),'system','blocked',trim($_POST['superblock-words'])); + PConfig::set(local_user(),'system','blocked',trim($_POST['superblock-words'])); info( t('SUPERBLOCK Settings saved.') . EOL); } } +function superblock_enotify_store(&$a,&$b) { + + $words = 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))) { + continue; + } + + if(link_compare($b['url'],$word)) { + $found = true; + break; + } + } + } + if($found) { + $b['abort'] = true; + } +} + + function superblock_conversation_start(&$a,&$b) { if(! local_user()) return; - $words = get_pconfig(local_user(),'system','blocked'); + $words = PConfig::get(local_user(),'system','blocked'); if($words) { $a->data['superblock'] = explode(',',$words); } @@ -108,7 +147,7 @@ function superblock_item_photo_menu(&$a,&$b) { } } - $b['menu'][ t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\');'; + $b['menu'][ t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\'); return false;'; } function superblock_module() {} @@ -119,7 +158,7 @@ function superblock_init(&$a) { if(! local_user()) return; - $words = get_pconfig(local_user(),'system','blocked'); + $words = PConfig::get(local_user(),'system','blocked'); if(array_key_exists('block',$_GET) && $_GET['block']) { if(strlen($words)) @@ -127,7 +166,7 @@ function superblock_init(&$a) { $words .= trim($_GET['block']); } - set_pconfig(local_user(),'system','blocked',$words); + PConfig::set(local_user(),'system','blocked',$words); info( t('superblock settings updated') . EOL ); killme(); }