From: friendica Date: Tue, 10 Jan 2012 09:16:09 +0000 (-0800) Subject: add blockem plugin X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1069db936ba5a14482247740ea4bf53c8000ab52;p=friendica-addons.git add blockem plugin --- diff --git a/blockem.tgz b/blockem.tgz new file mode 100644 index 00000000..b01e8f98 Binary files /dev/null and b/blockem.tgz differ diff --git a/blockem/blockem.css b/blockem/blockem.css new file mode 100644 index 00000000..72c0bcc3 --- /dev/null +++ b/blockem/blockem.css @@ -0,0 +1,16 @@ + +#blockem-label { + float: left; + width: 300px; + margin-top: 10px; +} + +#blockem-words { + float: left; + margin-top: 10px; +} + +#blockem-submit { + margin-top: 15px; +} + diff --git a/blockem/blockem.php b/blockem/blockem.php new file mode 100644 index 00000000..4fff2148 --- /dev/null +++ b/blockem/blockem.php @@ -0,0 +1,106 @@ + + * + */ + +function blockem_install() { + register_hook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body'); + register_hook('plugin_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings'); + register_hook('plugin_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post'); + +} + + +function blockem_uninstall() { + unregister_hook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body'); + unregister_hook('plugin_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings'); + unregister_hook('plugin_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post'); + +} + + + + + +function blockem_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"; + + + $words = get_pconfig(local_user(),'blockem','words'); + if(! $words) + $words = ''; + + $s .= '
'; + $s .= '

' . t('"Blockem" Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + + return; + +} + +function blockem_addon_settings_post(&$a,&$b) { + + if(! local_user()) + return; + + if($_POST['blockem-submit']) { + set_pconfig(local_user(),'blockem','words',trim($_POST['blockem-words'])); + info( t('BLOCKEM Settings saved.') . EOL); + } +} + +function blockem_prepare_body(&$a,&$b) { + + if(! local_user()) + return; + + $words = null; + if(local_user()) { + $words = get_pconfig(local_user(),'blockem','words'); + } + 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['item']['author-link'],$word)) { + $found = true; + break; + } + } + } + if($found) { + $rnd = random_string(8); + $b['item']['author-avatar'] = $a->get_baseurl() . "/images/default-profile-sm.jpg"; + $b['html'] = +'' . +''; + } +}