aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-03-05 21:00:25 -0800
committerfriendica <info@friendica.com>2013-03-05 21:00:25 -0800
commit4062be28699eb5fba93ff43ffb4d3e9ed7c4af6c (patch)
tree0b5a625703008a7dd7c4dda2590b6585b3380384
parentfbda9ababc76c103d82118a8f3cf24e619bfb80d (diff)
downloadvolse-hubzilla-4062be28699eb5fba93ff43ffb4d3e9ed7c4af6c.tar.gz
volse-hubzilla-4062be28699eb5fba93ff43ffb4d3e9ed7c4af6c.tar.bz2
volse-hubzilla-4062be28699eb5fba93ff43ffb4d3e9ed7c4af6c.zip
basic friend suggestions (but not "new to the network and have no friends at all" suggestions)
-rw-r--r--boot.php2
-rw-r--r--include/socgraph.php27
-rw-r--r--install/database.sql9
-rw-r--r--install/update.php25
-rw-r--r--mod/suggest.php21
-rw-r--r--view/tpl/main_slider.tpl20
-rw-r--r--view/tpl/smarty3/main_slider.tpl20
7 files changed, 92 insertions, 32 deletions
diff --git a/boot.php b/boot.php
index 6e12e1ae6..e2778d737 100644
--- a/boot.php
+++ b/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' );
diff --git a/include/socgraph.php b/include/socgraph.php
index 3c77a59a1..678d13d11 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -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() {
diff --git a/install/database.sql b/install/database.sql
index 31c5b441a..0262bce63 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -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 '',
diff --git a/install/update.php b/install/update.php
index 944841c41..afb4b08b9 100644
--- a/install/update.php
+++ b/install/update.php
@@ -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;
+}
diff --git a/mod/suggest.php b/mod/suggest.php
index 4aed2e61a..a5de5da04 100644
--- a/mod/suggest.php
+++ b/mod/suggest.php
@@ -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')
diff --git a/view/tpl/main_slider.tpl b/view/tpl/main_slider.tpl
index 662677684..a3b7769a6 100644
--- a/view/tpl/main_slider.tpl
+++ b/view/tpl/main_slider.tpl
@@ -1,16 +1,26 @@
<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(";");
- bParam_cmin = carr[0];
- bParam_cmax = carr[1];
- networkRefresh();
- } });
+ 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();
+ } });
var slideTimer = null;
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);
}
diff --git a/view/tpl/smarty3/main_slider.tpl b/view/tpl/smarty3/main_slider.tpl
index 481e23077..fe4495f77 100644
--- a/view/tpl/smarty3/main_slider.tpl
+++ b/view/tpl/smarty3/main_slider.tpl
@@ -5,17 +5,27 @@
*}}
<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(";");
- bParam_cmin = carr[0];
- bParam_cmax = carr[1];
- networkRefresh();
- } });
+ 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();
+ } });
var slideTimer = null;
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);
}