basic friend suggestions (but not "new to the network and have no friends at all" suggestions)
This commit is contained in:
parent
fbda9ababc
commit
4062be2869
2
boot.php
2
boot.php
@ -17,7 +17,7 @@ require_once('include/features.php');
|
||||
define ( 'FRIENDICA_PLATFORM', 'Friendica Red');
|
||||
define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R');
|
||||
define ( 'ZOT_REVISION', 1 );
|
||||
define ( 'DB_UPDATE_VERSION', 1032 );
|
||||
define ( 'DB_UPDATE_VERSION', 1033 );
|
||||
|
||||
define ( 'EOL', '<br />' . "\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
@ -254,12 +254,26 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) {
|
||||
|
||||
|
||||
|
||||
function suggestion_query($uid, $start = 0, $limit = 80) {
|
||||
function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
|
||||
|
||||
if(! $uid)
|
||||
if((! $uid) || (! $myxchan))
|
||||
return array();
|
||||
|
||||
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
|
||||
$r = q("SELECT count(xlink_xchan) as `total`, xchan.* from xchan
|
||||
left join xlink on xlink_link = xchan_hash
|
||||
where not xchan_hash in ( select abook_xchan from abook where abook_channel = %d )
|
||||
and not xchan_hash in ( select xchan from xign where uid = %d )
|
||||
and xchan_hash != '%s'
|
||||
group by xchan_hash order by total desc limit %d, %d ",
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
dbesc($myxchan),
|
||||
intval($start),
|
||||
intval($limit)
|
||||
);
|
||||
|
||||
/*
|
||||
$r = q("SELECT count(xlink.xchan) as `total`, gcontact.* from gcontact
|
||||
left join glink on glink.gcid = gcontact.id
|
||||
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
|
||||
and not gcontact.name in ( select name from contact where uid = %d )
|
||||
@ -272,7 +286,12 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
||||
intval($start),
|
||||
intval($limit)
|
||||
);
|
||||
*/
|
||||
|
||||
if($r)
|
||||
return $r;
|
||||
|
||||
/*
|
||||
if(count($r) && count($r) >= ($limit -1))
|
||||
return $r;
|
||||
|
||||
@ -291,7 +310,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
||||
|
||||
|
||||
return array_merge($r,$r2);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
function update_suggestions() {
|
||||
|
@ -909,6 +909,15 @@ CREATE TABLE IF NOT EXISTS `xchan` (
|
||||
KEY `xchan_connurl` (`xchan_connurl`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `xign` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uid` int(11) NOT NULL DEFAULT '0',
|
||||
`xchan` char(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `uid` (`uid`),
|
||||
KEY `xchan` (`xchan`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `xlink` (
|
||||
`xlink_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`xlink_xchan` char(255) NOT NULL DEFAULT '',
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
define( 'UPDATE_VERSION' , 1032 );
|
||||
define( 'UPDATE_VERSION' , 1033 );
|
||||
|
||||
/**
|
||||
*
|
||||
@ -52,7 +52,7 @@ function update_r1001() {
|
||||
`meta` CHAR( 255 ) NOT NULL DEFAULT '',
|
||||
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE = MYISAM ");
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$r2 = q("alter table `verify` add index (`channel`), add index (`type`), add index (`token`),
|
||||
add index (`meta`), add index (`created`)");
|
||||
@ -91,7 +91,7 @@ function update_r1004() {
|
||||
`site_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`site_directory` CHAR( 255 ) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY ( `site_url` )
|
||||
) ENGINE = MYISAM ");
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$r2 = q("alter table site add index (site_flags), add index (site_update), add index (site_directory) ");
|
||||
|
||||
@ -204,7 +204,7 @@ function update_r1013() {
|
||||
`xlink_xchan` CHAR( 255 ) NOT NULL DEFAULT '',
|
||||
`xlink_link` CHAR( 255 ) NOT NULL DEFAULT '',
|
||||
`xlink_updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
|
||||
) ENGINE = MYISAM ");
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$r2 = q("alter table xlink add index ( xlink_xchan ), add index ( xlink_link ), add index ( xlink_updated ) ");
|
||||
if($r && $r2)
|
||||
@ -367,7 +367,7 @@ ADD INDEX ( `channel_deleted` ) ");
|
||||
}
|
||||
|
||||
function update_r1030() {
|
||||
$r = q("CREATE TABLE IF NOT EXISTS`issue` (
|
||||
$r = q("CREATE TABLE IF NOT EXISTS `issue` (
|
||||
`issue_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`issue_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`issue_updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
@ -381,7 +381,7 @@ KEY `issue_assigned` (`issue_assigned`),
|
||||
KEY `issue_priority` (`issue_priority`),
|
||||
KEY `issue_status` (`issue_status`),
|
||||
KEY `issue_component` (`issue_component`)
|
||||
) ENGINE = MYISAM ");
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
if($r)
|
||||
return UPDATE_SUCCESS;
|
||||
@ -397,3 +397,16 @@ ADD INDEX ( `account_external` )");
|
||||
}
|
||||
|
||||
|
||||
function update_r1032() {
|
||||
$r = q("CREATE TABLE if not exists `xign` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`uid` INT NOT NULL DEFAULT '0',
|
||||
`xchan` CHAR( 255 ) NOT NULL DEFAULT '',
|
||||
KEY `uid` (`uid`),
|
||||
KEY `xchan` (`xchan`)
|
||||
) ENGINE = MYISAM DEFAULT CHARSET = utf8");
|
||||
|
||||
if($r)
|
||||
return UPDATE_SUCCESS;
|
||||
return UPDATE_FAILED;
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ function suggest_init(&$a) {
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
if(x($_GET,'ignore') && intval($_GET['ignore'])) {
|
||||
q("insert into gcign ( uid, gcid ) values ( %d, %d ) ",
|
||||
if(x($_GET,'ignore')) {
|
||||
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
|
||||
intval(local_user()),
|
||||
intval($_GET['ignore'])
|
||||
dbesc($_GET['ignore'])
|
||||
);
|
||||
}
|
||||
|
||||
@ -37,10 +37,9 @@ function suggest_content(&$a) {
|
||||
|
||||
$o .= '<h2>' . t('Friend Suggestions') . '</h2>';
|
||||
|
||||
$r = suggestion_query(local_user(),get_observer_hash());
|
||||
|
||||
$r = suggestion_query(local_user());
|
||||
|
||||
if(! count($r)) {
|
||||
if(! $r) {
|
||||
$o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
|
||||
return $o;
|
||||
}
|
||||
@ -49,13 +48,13 @@ function suggest_content(&$a) {
|
||||
|
||||
foreach($r as $rr) {
|
||||
|
||||
$connlnk = $a->get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
|
||||
$connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['xchan_addr'];
|
||||
|
||||
$o .= replace_macros($tpl,array(
|
||||
'$url' => zid($rr['url']),
|
||||
'$name' => $rr['name'],
|
||||
'$photo' => $rr['photo'],
|
||||
'$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'],
|
||||
'$url' => zid($rr['xchan_url']),
|
||||
'$name' => $rr['xchan_name'],
|
||||
'$photo' => $rr['xchan_photo_m'],
|
||||
'$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['xchan_hash'],
|
||||
'$conntxt' => t('Connect'),
|
||||
'$connlnk' => $connlnk,
|
||||
'$ignore' => t('Ignore/Hide')
|
||||
|
@ -1,9 +1,17 @@
|
||||
<div id="main-slider" class="slider" ><input id="main-range" type="text" name="cminmax" value="$val" /></div>
|
||||
<script>
|
||||
var old_cmin = 0;
|
||||
var old_cmax = 99;
|
||||
$("#main-range").slider({ from: 0, to: 99, step: 1, scale: ['$me', '|', '$intimate', '|', '$friends', '|', '$oldfriends', '|', '$acquaintances', '|', '$world' ], onstatechange: function(v) {
|
||||
var carr = v.split(";");
|
||||
if(carr[0] != bParam_cmin) {
|
||||
old_cmin = bParam_cmin;
|
||||
bParam_cmin = carr[0];
|
||||
}
|
||||
if(carr[1] != bParam_cmax) {
|
||||
old_cmax = bParam_cmax;
|
||||
bParam_cmax = carr[1];
|
||||
}
|
||||
networkRefresh();
|
||||
} });
|
||||
|
||||
@ -11,6 +19,8 @@
|
||||
function networkRefresh() {
|
||||
if((document.readyState !== "complete") || (slideTimer !== null))
|
||||
return;
|
||||
if((bParam_cmin == old_cmin) && (bParam_cmax == old_cmax))
|
||||
return;
|
||||
setTimeout(function() { $("#profile-jot-text-loading").show(); }, 1000 );
|
||||
slideTimer = setTimeout(networkTimerRefresh,2000);
|
||||
}
|
||||
|
@ -5,10 +5,18 @@
|
||||
*}}
|
||||
<div id="main-slider" class="slider" ><input id="main-range" type="text" name="cminmax" value="{{$val}}" /></div>
|
||||
<script>
|
||||
var old_cmin = 0;
|
||||
var old_cmax = 99;
|
||||
$("#main-range").slider({ from: 0, to: 99, step: 1, scale: ['{{$me}}', '|', '{{$intimate}}', '|', '{{$friends}}', '|', '{{$oldfriends}}', '|', '{{$acquaintances}}', '|', '{{$world}}' ], onstatechange: function(v) {
|
||||
var carr = v.split(";");
|
||||
if(carr[0] != bParam_cmin) {
|
||||
old_cmin = bParam_cmin;
|
||||
bParam_cmin = carr[0];
|
||||
}
|
||||
if(carr[1] != bParam_cmax) {
|
||||
old_cmax = bParam_cmax;
|
||||
bParam_cmax = carr[1];
|
||||
}
|
||||
networkRefresh();
|
||||
} });
|
||||
|
||||
@ -16,6 +24,8 @@
|
||||
function networkRefresh() {
|
||||
if((document.readyState !== "complete") || (slideTimer !== null))
|
||||
return;
|
||||
if((bParam_cmin == old_cmin) && (bParam_cmax == old_cmax))
|
||||
return;
|
||||
setTimeout(function() { $("#profile-jot-text-loading").show(); }, 1000 );
|
||||
slideTimer = setTimeout(networkTimerRefresh,2000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user