*
*/
function blockem_install() {
register_hook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
register_hook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
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('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
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['html'] = '' . sprintf( t('Blocked %s - Click to open/close'),$word ) . '
' . $b['html'] . '
';
}
}
function blockem_display_item(&$a,&$b) {
if(strstr($b['output'],'id="blockem-wrap-'))
$b['output'] = preg_replace('/\/','get_baseurl() . "/images/default-profile-sm.jpg" . '" class="wall-item-photo$3>',$b['output']);
}