[blockem] Use content_filter hook
This commit is contained in:
parent
02eb1b74f7
commit
31e55d6d5a
1 changed files with 20 additions and 24 deletions
|
@ -12,7 +12,7 @@ use Friendica\Core\PConfig;
|
||||||
|
|
||||||
function blockem_install()
|
function blockem_install()
|
||||||
{
|
{
|
||||||
Addon::registerHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
|
Addon::registerHook('content_filter', 'addon/blockem/blockem.php', 'blockem_content_filter');
|
||||||
Addon::registerHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
|
Addon::registerHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
|
||||||
Addon::registerHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
|
Addon::registerHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
|
||||||
Addon::registerHook('addon_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
|
Addon::registerHook('addon_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
|
||||||
|
@ -23,6 +23,7 @@ function blockem_install()
|
||||||
|
|
||||||
function blockem_uninstall()
|
function blockem_uninstall()
|
||||||
{
|
{
|
||||||
|
Addon::unregisterHook('content_filter', 'addon/blockem/blockem.php', 'blockem_content_filter');
|
||||||
Addon::unregisterHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
|
Addon::unregisterHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
|
||||||
Addon::unregisterHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
|
Addon::unregisterHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
|
||||||
Addon::unregisterHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
|
Addon::unregisterHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
|
||||||
|
@ -106,38 +107,33 @@ function blockem_enotify_store(&$a,&$b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function blockem_prepare_body(&$a,&$b) {
|
function blockem_content_filter(\Friendica\App $a, &$hook_data)
|
||||||
|
{
|
||||||
if(! local_user())
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$words = null;
|
$profiles_string = null;
|
||||||
if(local_user()) {
|
if (local_user()) {
|
||||||
$words = PConfig::get(local_user(),'blockem','words');
|
$profiles_string = PConfig::get(local_user(), 'blockem', 'words');
|
||||||
}
|
}
|
||||||
if($words) {
|
|
||||||
$arr = explode(',',$words);
|
if ($profiles_string) {
|
||||||
}
|
$profiles_array = explode(',', $profiles_string);
|
||||||
else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
if(count($arr)) {
|
foreach ($profiles_array as $word) {
|
||||||
foreach($arr as $word) {
|
if (link_compare($hook_data['item']['author-link'], trim($word))) {
|
||||||
if(! strlen(trim($word))) {
|
$found = true;
|
||||||
continue;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if(link_compare($b['item']['author-link'],$word)) {
|
|
||||||
$found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($found) {
|
|
||||||
$rnd = random_string(8);
|
if ($found) {
|
||||||
$b['html'] = '<div id="blockem-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'blockem-' . $rnd . '\'); >' . L10n::t('Hidden content by %s - Click to open/close', $word) . '</div><div id="blockem-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
|
$hook_data['filter_reasons'][] = L10n::t('Filtered user: %s', $hook_data['item']['author-name']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue