mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 11:35:13 +00:00
Merge branch 'dev' of /home/macgirvin/osada into dev
This commit is contained in:
commit
ea9c4572fb
8 changed files with 96 additions and 5 deletions
|
@ -306,6 +306,7 @@ class Apps {
|
|||
'Articles' => t('Articles'),
|
||||
'Cards' => t('Cards'),
|
||||
'Admin' => t('Site Admin'),
|
||||
'Content Filter' => t('Content Filter'),
|
||||
'Report Bug' => t('Report Bug'),
|
||||
'View Bookmarks' => t('View Bookmarks'),
|
||||
'Chatrooms' => t('Chatrooms'),
|
||||
|
|
|
@ -675,7 +675,7 @@ class Connedit extends \Zotlabs\Web\Controller {
|
|||
));
|
||||
}
|
||||
|
||||
if(feature_enabled(local_channel(),'connfilter')) {
|
||||
if(Apps::system_app_installed(local_channel(),'Content Filter')) {
|
||||
$sections['filter'] = [
|
||||
'label' => t('Filter'),
|
||||
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/?f=§ion=filter',
|
||||
|
@ -807,7 +807,7 @@ class Connedit extends \Zotlabs\Web\Controller {
|
|||
'$lbl_rating' => t('Rating'),
|
||||
'$lbl_rating_label' => t('Slide to adjust your rating'),
|
||||
'$lbl_rating_txt' => t('Optionally explain your rating'),
|
||||
'$connfilter' => feature_enabled(local_channel(),'connfilter'),
|
||||
'$connfilter' => Apps::system_app_installed(local_channel(),'Content Filter'),
|
||||
'$connfilter_label' => t('Custom Filter'),
|
||||
'$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
|
||||
'$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
|
||||
|
|
74
Zotlabs/Module/Content_filter.php
Normal file
74
Zotlabs/Module/Content_filter.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Web\Controller;
|
||||
|
||||
class Content_filter extends Controller {
|
||||
|
||||
function post() {
|
||||
|
||||
if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Content Filter'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($_POST['content_filter-submit']) {
|
||||
|
||||
$incl = ((x($_POST['message_filter_incl'])) ? htmlspecialchars_decode(trim($_POST['message_filter_incl']),ENT_QUOTES) : '');
|
||||
$excl = ((x($_POST['message_filter_excl'])) ? htmlspecialchars_decode(trim($_POST['message_filter_excl']),ENT_QUOTES) : '');
|
||||
|
||||
set_pconfig(local_channel(),'system','message_filter_incl',$incl);
|
||||
set_pconfig(local_channel(),'system','message_filter_excl',$excl);
|
||||
|
||||
info( t('Content Filter settings updated.') . EOL);
|
||||
|
||||
}
|
||||
|
||||
Libsync::build_sync_packet();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get() {
|
||||
|
||||
$desc = t('This app (when installed) allows you to filter incoming content from all sources or from specific connections. The filtering may be based on words, tags, regular expressions, or language');
|
||||
|
||||
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
|
||||
|
||||
if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Content Filter'))) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$text .= EOL . t('The settings on this page apply to all incoming content. To edit the settings for individual connetions, see the similar settings on the Connection Edit page for that connection.') . EOL . EOL;
|
||||
|
||||
$setting_fields = $text;
|
||||
|
||||
$setting_fields .= replace_macros(get_markup_template('field_textarea.tpl'), array(
|
||||
'$field' => [
|
||||
'message_filter_incl',
|
||||
t('Only import posts with this text'),
|
||||
get_pconfig(local_channel(),'system','message_filter_incl',''),
|
||||
t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')
|
||||
]
|
||||
));
|
||||
$setting_fields .= replace_macros(get_markup_template('field_textarea.tpl'), array(
|
||||
'$field' => [
|
||||
'message_filter_excl',
|
||||
t('Only import posts with this text'),
|
||||
get_pconfig(local_channel(),'system','message_filter_excl',''),
|
||||
t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')
|
||||
]
|
||||
));
|
||||
|
||||
$s .= replace_macros(get_markup_template('generic_app_settings.tpl'), array(
|
||||
'$addon' => array('content_filter', '' . t('Content Filter Settings'), '', t('Submit')),
|
||||
'$content' => $setting_fields
|
||||
));
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -146,6 +146,8 @@ class Channel {
|
|||
$autoperms = ((x($_POST,'autoperms')) ? intval($_POST['autoperms']) : 0);
|
||||
$anymention = ((x($_POST,'anymention')) ? intval($_POST['anymention']) : 0);
|
||||
$hyperdrive = ((x($_POST,'hyperdrive')) ? intval($_POST['hyperdrive']) : 0);
|
||||
|
||||
|
||||
$public_uploads = ((isset($_POST['public_uploads'])) ? intval($_POST['public_uploads']) : 0);
|
||||
$post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
|
||||
$post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
|
||||
|
@ -578,6 +580,7 @@ class Channel {
|
|||
'$autoperms' => $autoperms,
|
||||
'$anymention' => $anymention,
|
||||
'$hyperdrive' => $hyperdrive,
|
||||
|
||||
'$h_not' => t('Notification Settings'),
|
||||
'$activity_options' => t('By default post a status message when:'),
|
||||
'$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no),
|
||||
|
|
6
app/content_filter.apd
Normal file
6
app/content_filter.apd
Normal file
|
@ -0,0 +1,6 @@
|
|||
version: 1
|
||||
url: $baseurl/content_filter
|
||||
requires: local_channel
|
||||
name: Content Filter
|
||||
photo: icon:filter
|
||||
categories: Networking
|
|
@ -495,7 +495,7 @@ function create_identity($arr) {
|
|||
$clone['abconfig'] = $abconfig;
|
||||
}
|
||||
|
||||
Libsync::build_sync_packet(0, [ 'abook' => [ $clone ] ], true);
|
||||
Libsync::build_sync_packet($ret['channel']['channel_id'], [ 'abook' => [ $clone ] ], true);
|
||||
|
||||
$can_view_stream = their_perms_contains($ret['channel']['channel_id'],$clone['abook_xchan'],'view_stream');
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use Zotlabs\Lib\Libzot;
|
|||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Group;
|
||||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\Apps;
|
||||
|
||||
use Zotlabs\Lib as Zlib;
|
||||
use Zotlabs\Lib\Enotify;
|
||||
|
@ -3170,6 +3171,11 @@ function post_is_importable($channel_id,$item,$abook) {
|
|||
if(! $item)
|
||||
return false;
|
||||
|
||||
if(! Apps::system_app_installed($channel_id,'Content Filter')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$incl = PConfig::get($channel_id,'system','message_filter_incl',EMPTY_STR);
|
||||
$excl = PConfig::get($channel_id,'system','message_filter_excl',EMPTY_STR);
|
||||
if($incl || $excl) {
|
||||
|
@ -3180,8 +3186,6 @@ function post_is_importable($channel_id,$item,$abook) {
|
|||
}
|
||||
}
|
||||
|
||||
if(($channel_id) && (! feature_enabled($channel_id,'connfilter')))
|
||||
return true;
|
||||
|
||||
if(! $abook)
|
||||
return true;
|
||||
|
|
|
@ -830,6 +830,9 @@ function get_tags($s) {
|
|||
// ignore anything in [color= ], because it may contain color codes which are mistaken for tags
|
||||
$s = preg_replace('/\[color=(.*?)\]/sm','',$s);
|
||||
|
||||
// skip anchors in URL
|
||||
$s = preg_replace('/\[url=(.*?)\]/sm','',$s);
|
||||
|
||||
// match any double quoted tags
|
||||
|
||||
if(preg_match_all('/([@#\!]\"\;.*?\"\;)/',$s,$match)) {
|
||||
|
|
Loading…
Reference in a new issue