mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 15:55: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;
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
use Zotlabs\Lib\Libzotdir;
|
use Zotlabs\Lib\Libzotdir;
|
||||||
|
use Zotlabs\Lib\Libsync;
|
||||||
|
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
|
@ -13,11 +14,14 @@ class Directory extends \Zotlabs\Web\Controller {
|
||||||
function init() {
|
function init() {
|
||||||
\App::set_pager_itemspage(60);
|
\App::set_pager_itemspage(60);
|
||||||
|
|
||||||
if(x($_GET,'ignore')) {
|
if(x($_GET,'ignore') && local_channel()) {
|
||||||
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
|
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
|
||||||
intval(local_channel()),
|
intval(local_channel()),
|
||||||
dbesc($_GET['ignore'])
|
dbesc($_GET['ignore'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Libsync::build_sync_packet(local_channel(), [ 'xign' => [ [ 'uid' => local_channel(), 'xchan' => $_GET['ignore'] ]]] );
|
||||||
|
|
||||||
goaway(z_root() . '/directory?f=&suggest=1');
|
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;
|
namespace Zotlabs\Widget;
|
||||||
|
|
||||||
|
use Zotlabs\Lib\Apps;
|
||||||
|
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,49 +11,49 @@ class Suggestions {
|
||||||
|
|
||||||
function widget($arr) {
|
function widget($arr) {
|
||||||
|
|
||||||
if((! local_channel()) || (! feature_enabled(local_channel(),'suggest')))
|
if ((! local_channel()) || (! Apps::system_app_installed(local_channel(),'Suggest Channels'))) {
|
||||||
return '';
|
return EMPTY_STR;
|
||||||
|
}
|
||||||
|
|
||||||
$r = suggestion_query(local_channel(),get_observer_hash(),0,20);
|
$r = suggestion_query(local_channel(),get_observer_hash(),0,20);
|
||||||
|
|
||||||
if(! $r) {
|
if (! $r) {
|
||||||
return;
|
return EMPTY_STR;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = array();
|
$arr = [];
|
||||||
|
|
||||||
// Get two random entries from the top 20 returned.
|
// Get two random entries from the top 20 returned.
|
||||||
// We'll grab the first one and the one immediately following.
|
// We'll grab the first one and the one immediately following.
|
||||||
// This will throw some entropy intot he situation so you won't
|
// This will throw some entropy into the situation so you won't
|
||||||
// be looking at the same two mug shots every time the widget runs
|
// be looking at the same two mug shots every time the widget runs
|
||||||
|
|
||||||
$index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
|
$index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
|
||||||
|
|
||||||
for($x = $index; $x <= ($index+1); $x ++) {
|
for ($x = $index; $x <= ($index+1); $x ++) {
|
||||||
$rr = $r[$x];
|
$rr = $r[$x];
|
||||||
if(! $rr['xchan_url'])
|
if (! $rr['xchan_url'])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
|
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
|
||||||
|
|
||||||
$arr[] = array(
|
$arr[] = [
|
||||||
'url' => chanlink_url($rr['xchan_url']),
|
'url' => chanlink_url($rr['xchan_url']),
|
||||||
'profile' => $rr['xchan_url'],
|
'profile' => $rr['xchan_url'],
|
||||||
'name' => $rr['xchan_name'],
|
'name' => $rr['xchan_name'],
|
||||||
'photo' => $rr['xchan_photo_m'],
|
'photo' => $rr['xchan_photo_m'],
|
||||||
'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'],
|
'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'],
|
||||||
'conntxt' => t('Connect'),
|
'conntxt' => t('Connect'),
|
||||||
'connlnk' => $connlnk,
|
'connlnk' => $connlnk,
|
||||||
'ignore' => t('Ignore/Hide')
|
'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'),
|
'$title' => t('Suggestions'),
|
||||||
'$more' => t('See more...'),
|
'$more' => t('See more...'),
|
||||||
'$entries' => $arr
|
'$entries' => $arr
|
||||||
));
|
] );
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
version: 1
|
version: 2
|
||||||
url: $baseurl/suggest
|
url: $baseurl/suggestions
|
||||||
requires: local_channel
|
requires: local_channel
|
||||||
name: Suggest Channels
|
name: Suggest Channels
|
||||||
photo: icon:lightbulb-o
|
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 ( 'ZOT_REVISION', '6.0' );
|
||||||
|
|
||||||
define ( 'DB_UPDATE_VERSION', 1232 );
|
define ( 'DB_UPDATE_VERSION', 1232 );
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="clear"></div>
|
<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>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue