mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
superblock upgrade
This commit is contained in:
parent
05018bb6fe
commit
9835501015
4 changed files with 98 additions and 91 deletions
|
@ -16,20 +16,29 @@ class Superblock extends Controller {
|
|||
return;
|
||||
}
|
||||
|
||||
$inline = (isset($_REQUEST['manual_block']) ? true : false);
|
||||
|
||||
$type = BLOCKTYPE_CHANNEL;
|
||||
$blocked = trim($_GET['block']);
|
||||
$blocked = trim($_REQUEST['block']);
|
||||
if (! $blocked) {
|
||||
$blocked = trim($_GET['blocksite']);
|
||||
$blocked = trim($_REQUEST['blocksite']);
|
||||
if ($blocked) {
|
||||
$type = BLOCKTYPE_SERVER;
|
||||
}
|
||||
}
|
||||
|
||||
$m = parse_url($blocked);
|
||||
if ($m['scheme'] && $m['host'] && (($type === BLOCKTYPE_SERVER) || (! $m['path']))) {
|
||||
$type = BLOCKTYPE_SERVER;
|
||||
$blocked = $m['host'];
|
||||
}
|
||||
|
||||
$handled = false;
|
||||
$ignored = [];
|
||||
|
||||
if ($blocked) {
|
||||
$handled = true;
|
||||
if ($type === BLOCKTYPE_CHANNEL) {
|
||||
$r = q("select xchan_url from xchan where ( xchan_hash = '%s' or xchan_addr = '%s' or xchan_url = '%s' )",
|
||||
dbesc($blocked),
|
||||
dbesc($blocked),
|
||||
|
@ -41,6 +50,9 @@ class Superblock extends Controller {
|
|||
|
||||
if (! $wf) {
|
||||
notice( t('Channel not found.') . EOL);
|
||||
if ($inline) {
|
||||
return;
|
||||
}
|
||||
killme();
|
||||
}
|
||||
|
||||
|
@ -57,13 +69,7 @@ class Superblock extends Controller {
|
|||
}
|
||||
|
||||
if ($r) {
|
||||
|
||||
$r = Libzot::zot_record_preferred($r,'xchan_network');
|
||||
|
||||
if ($type === BLOCKTYPE_SERVER) {
|
||||
$m = parse_url($r['xchan_url']);
|
||||
if ($m) {
|
||||
$blocked = $m['host'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,12 +121,11 @@ class Superblock extends Controller {
|
|||
}
|
||||
Libsync::build_sync_packet(0, $sync);
|
||||
}
|
||||
}
|
||||
|
||||
$type = BLOCKTYPE_CHANNEL;
|
||||
$unblocked = trim($_GET['unblock']);
|
||||
$unblocked = trim($_REQUEST['unblock']);
|
||||
if (! $unblocked) {
|
||||
$unblocked = trim($_GET['unblocksite']);
|
||||
$unblocked = trim($_REQUEST['unblocksite']);
|
||||
if ($unblocked) {
|
||||
$type = BLOCKTYPE_SERVER;
|
||||
}
|
||||
|
@ -174,7 +179,7 @@ class Superblock extends Controller {
|
|||
|
||||
info( t('superblock settings updated') . EOL );
|
||||
|
||||
if ($unblocked) {
|
||||
if ($unblocked || $inline) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -210,6 +215,7 @@ class Superblock extends Controller {
|
|||
'$remove' => t('Remove')
|
||||
]);
|
||||
|
||||
|
||||
$l = LibBlock::fetch(local_channel(),BLOCKTYPE_SERVER);
|
||||
$list = ids_to_array($l,'block_entity');
|
||||
if ($list) {
|
||||
|
|
|
@ -13,8 +13,8 @@ class Sblock {
|
|||
}
|
||||
|
||||
return replace_macros(get_markup_template('superblock_widget.tpl'), [
|
||||
'$connect' => t('Block Channel'),
|
||||
'$desc' => t('Enter channel address'),
|
||||
'$connect' => t('Block channel or site'),
|
||||
'$desc' => t('Enter channel address or URL'),
|
||||
'$hint' => t('Examples: bob@example.com, https://example.com/barbara'),
|
||||
'$follow' => t('Block'),
|
||||
'$abook_usage_message' => '',
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<li>
|
||||
<div>
|
||||
<a class="pull-right" href="superblock?f=&unblocksite={{$e.1}}§ok={{$token}}" title="{{$remove}}"><i class="fa fa-trash"></i></a>
|
||||
<a class="zid" href="{{$e.0}}"> {{$e.0}}</a>
|
||||
<a href="https://{{$e.0}}"> {{$e.0}}</a>
|
||||
</div>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<div id="follow-sidebar" class="widget">
|
||||
<h3>{{$connect}}</h3>
|
||||
<form action="superblock" method="post" />
|
||||
<form action="superblock" method="post" >
|
||||
<div class="input-group">
|
||||
<input class="form-control" id="follow_input" type="text" name="block" title="{{$hint}}" placeholder="{{$desc}}" />
|
||||
<input class="form-control" id="follow_input" type="text" name="block" title="{{$hint}}" placeholder="{{$desc}}" >
|
||||
<input type="hidden" name="manual_block" value="1">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-sm btn-success" type="submit" name="submit" value="{{$follow}}" title="{{$follow}}"><i class="fa fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue