From 1069db936ba5a14482247740ea4bf53c8000ab52 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Jan 2012 01:16:09 -0800 Subject: [PATCH] add blockem plugin --- blockem.tgz | Bin 0 -> 1357 bytes blockem/blockem.css | 16 +++++++ blockem/blockem.php | 106 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 blockem.tgz create mode 100644 blockem/blockem.css create mode 100644 blockem/blockem.php diff --git a/blockem.tgz b/blockem.tgz new file mode 100644 index 0000000000000000000000000000000000000000..b01e8f98928c70e3e421492545a6f69e2babb06e GIT binary patch literal 1357 zcmV-T1+w}diwFS00Sr$71MOFBZ`(Ey_E+my+*GfUi`cSV+X)ieMVs~0+I3jAeMtg? zmMEJuB?=^!G#K*V$2Ysy>@HoAwiu=Zg23e6b9c}2j?{v(c#X5D@dc%)tI; zgTb)T8;u9!Vc)DfY4rQYy}|MEc-$K`di}w$KWM<{O9r)(Qb@!B8X1b0gx`?-BYMSh zH140AoP3R#zM?E#{oVg=u__+jhc57VJp5SwN8?`K)c?8GGxZ;i`r`)l9zBu+@;|Tt zL){s%`sfV?a4)R*|Z zjA9{tSaF%Q<+3s=WGw3Bvao7*}3JYC@|kcr)Ys`MboVKkTSkw zt<&%~ah$U(L#ni@agf9bxTy!f{qp8Q9|&V*LxV|V@c!C+wExKuAt;9@=V{O=sC`s*DufrG{=AkH$n#-?@6sXkx?G z;xZsoC3t-qAoCLH=>6dO$YD9CZLE?zyyij$wsz3w&+%e39WUJ2aFi!3o2y7w@xv2y zHV!yOH%L8e)g>`KIPm?5Wa>H*QG!!cQrU51sUx!PAH~w&pz7PkfOx^gz5{2i(0_8P z?tzZ>*eO;_vW^)rJ3$b0J*lQ_cR9}34Sp#l4}HO7zdeZ@kT&uT4_^zY6E>agra`JM zN=>K_ERQLP*Hc#D{G2j@!>euA?3!MwGX}f|eiZxi! zwgm%sVQi=4ZkW{w&D}fo6Cw(V?oJ_RIX(m5`raXOix->$*hc-v@Baf={-gVN;QOyP z7!Eey|NUWaV7~v9TK)a^6~uc|dCTZglTwD{DNvkBH3x1SuduwW|ir&cSeQSnlsil@$YN@4`T574KmRf45rIuQ1sil@$ P{+sd_coTnb04M+eC{3v2 literal 0 HcmV?d00001 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'] = +'' . +''; + } +} -- 2.39.5