mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
resolve some of the issues associated with having multiple suggestion implementations, and add xign sync to this subsystem
This commit is contained in:
parent
9678e44c4a
commit
dd0df677a6
7 changed files with 76 additions and 98 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Module;
|
||||
|
||||
use Zotlabs\Lib\Libzotdir;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -13,11 +14,14 @@ class Directory extends \Zotlabs\Web\Controller {
|
|||
function init() {
|
||||
\App::set_pager_itemspage(60);
|
||||
|
||||
if(x($_GET,'ignore')) {
|
||||
if(x($_GET,'ignore') && local_channel()) {
|
||||
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
|
||||
intval(local_channel()),
|
||||
dbesc($_GET['ignore'])
|
||||
);
|
||||
|
||||
Libsync::build_sync_packet(local_channel(), [ 'xign' => [ [ 'uid' => local_channel(), 'xchan' => $_GET['ignore'] ]]] );
|
||||
|
||||
goaway(z_root() . '/directory?f=&suggest=1');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
|
||||
|
||||
class Suggest extends \Zotlabs\Web\Controller {
|
||||
|
||||
function init() {
|
||||
if(! local_channel())
|
||||
return;
|
||||
|
||||
if(x($_GET,'ignore')) {
|
||||
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
|
||||
intval(local_channel()),
|
||||
dbesc($_GET['ignore'])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get() {
|
||||
|
||||
$o = '';
|
||||
if(! local_channel()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
nav_set_selected('Suggest Channels');
|
||||
|
||||
$_SESSION['return_url'] = z_root() . '/' . \App::$cmd;
|
||||
|
||||
$r = suggestion_query(local_channel(),get_observer_hash());
|
||||
|
||||
if(! $r) {
|
||||
info( t('No suggestions available. If this is a new site, please try again in 24 hours.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$arr = array();
|
||||
|
||||
foreach($r as $rr) {
|
||||
|
||||
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
|
||||
|
||||
$arr[] = array(
|
||||
'url' => chanlink_url($rr['xchan_url']),
|
||||
'common' => $rr['total'],
|
||||
'profile' => $rr['xchan_url'],
|
||||
'name' => $rr['xchan_name'],
|
||||
'photo' => $rr['xchan_photo_m'],
|
||||
'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'],
|
||||
'conntxt' => t('Connect'),
|
||||
'connlnk' => $connlnk,
|
||||
'ignore' => t('Ignore/Hide')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$o = replace_macros(get_markup_template('suggest_page.tpl'),array(
|
||||
'$title' => t('Channel Suggestions'),
|
||||
'$entries' => $arr
|
||||
));
|
||||
|
||||
return $o;
|
||||
|
||||
}
|
||||
|
||||
}
|
44
Zotlabs/Module/Suggestions.php
Normal file
44
Zotlabs/Module/Suggestions.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Apps;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
class Suggestions extends \Zotlabs\Web\Controller {
|
||||
|
||||
function init() {
|
||||
if (! local_channel())
|
||||
return;
|
||||
|
||||
if (x($_GET,'ignore')) {
|
||||
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
|
||||
intval(local_channel()),
|
||||
dbesc($_GET['ignore'])
|
||||
);
|
||||
Libsync::build_sync_packet(local_channel(), [ 'xign' => [ [ 'uid' => local_channel(), 'xchan' => $_GET['ignore'] ]]] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get() {
|
||||
|
||||
$o = '';
|
||||
if (! local_channel()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Apps::system_app_installed(local_channel(),'Suggest Channels')) {
|
||||
goaway(z_root() . '/directory?f=&suggest=1');
|
||||
}
|
||||
|
||||
$desc = t('This app (when installed) displays a small number of friend suggestions on selected pages or you can run the app to display a full list of channel suggestions.');
|
||||
|
||||
return '<div class="section-content-info-wrapper">' . $desc . '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
use Zotlabs\Lib\Apps;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
|
||||
|
@ -9,17 +11,17 @@ class Suggestions {
|
|||
|
||||
function widget($arr) {
|
||||
|
||||
if((! local_channel()) || (! feature_enabled(local_channel(),'suggest')))
|
||||
return '';
|
||||
|
||||
if ((! local_channel()) || (! Apps::system_app_installed(local_channel(),'Suggest Channels'))) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
$r = suggestion_query(local_channel(),get_observer_hash(),0,20);
|
||||
|
||||
if (! $r) {
|
||||
return;
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
$arr = array();
|
||||
$arr = [];
|
||||
|
||||
// Get two random entries from the top 20 returned.
|
||||
// We'll grab the first one and the one immediately following.
|
||||
|
@ -35,7 +37,7 @@ class Suggestions {
|
|||
|
||||
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
|
||||
|
||||
$arr[] = array(
|
||||
$arr[] = [
|
||||
'url' => chanlink_url($rr['xchan_url']),
|
||||
'profile' => $rr['xchan_url'],
|
||||
'name' => $rr['xchan_name'],
|
||||
|
@ -44,14 +46,14 @@ class Suggestions {
|
|||
'conntxt' => t('Connect'),
|
||||
'connlnk' => $connlnk,
|
||||
'ignore' => t('Ignore/Hide')
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$o = replace_macros(get_markup_template('suggest_widget.tpl'),array(
|
||||
$o = replace_macros(get_markup_template('suggest_widget.tpl'), [
|
||||
'$title' => t('Suggestions'),
|
||||
'$more' => t('See more...'),
|
||||
'$entries' => $arr
|
||||
));
|
||||
] );
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
version: 1
|
||||
url: $baseurl/suggest
|
||||
version: 2
|
||||
url: $baseurl/suggestions
|
||||
requires: local_channel
|
||||
name: Suggest Channels
|
||||
photo: icon:lightbulb-o
|
||||
|
|
2
boot.php
2
boot.php
|
@ -45,7 +45,7 @@ require_once('include/items.php');
|
|||
|
||||
|
||||
|
||||
define ( 'STD_VERSION', '2.11' );
|
||||
define ( 'STD_VERSION', '2.13' );
|
||||
define ( 'ZOT_REVISION', '6.0' );
|
||||
|
||||
define ( 'DB_UPDATE_VERSION', 1232 );
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
{{/foreach}}
|
||||
{{/if}}
|
||||
<div class="clear"></div>
|
||||
<div class="suggest-widget-more"><a href="suggest">{{$more}}</a></div>
|
||||
<div class="suggest-widget-more"><a href="suggestions">{{$more}}</a></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue