aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-12-27 23:33:37 -0800
committerfriendica <info@friendica.com>2012-12-27 23:33:37 -0800
commitdda4d689bbdd871f5bd8809ce5381aaee5004d5b (patch)
treeb70722cf3b35db85aa30ce61e902c592583a7b08 /include
parent55e77a57d0ea20844b481ff9b194bdf424857c5e (diff)
downloadvolse-hubzilla-dda4d689bbdd871f5bd8809ce5381aaee5004d5b.tar.gz
volse-hubzilla-dda4d689bbdd871f5bd8809ce5381aaee5004d5b.tar.bz2
volse-hubzilla-dda4d689bbdd871f5bd8809ce5381aaee5004d5b.zip
This was bloody hard to sort out.... but now it's sorted and we can move forward again. Put back xtag for efficient keyword searching, use it in conjunction with xprof['keywords'] to avoid a SQL triple join and group_concat (which simply won't scale on a directory server), figured out how best to work timezone corrected birthdays into the protocol. The directory can even provide an age if one was provided to it. Both of these things need some more work, but we have the mechanisms and a plan how to do it right instead of "how the !@#$ are we going to do pull this off?"
Diffstat (limited to 'include')
-rw-r--r--include/dir_fns.php3
-rw-r--r--include/zot.php42
2 files changed, 43 insertions, 2 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 2c2694782..904d27189 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -46,6 +46,9 @@ function syncdirs($uid) {
$r = q("delete from xprof where xprof_hash = '%s' limit 1",
dbesc($hash)
);
+ $r = q("delete from xtag where xtag_hash = '%s' limit 1",
+ dbesc($hash)
+ );
}
}
diff --git a/include/zot.php b/include/zot.php
index 0bd575b94..001088f6a 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -313,13 +313,15 @@ function zot_refresh($them,$channel = null) {
$r = q("delete from xprof where xprof_hash = '%s' limit 1",
dbesc($x['hash'])
);
+ $r = q("delete from xtag where xtag_hash = '%s' limit 1",
+ dbesc($x['hash'])
+ );
}
}
}
return true;
}
return false;
-
}
@@ -926,7 +928,9 @@ function process_mail_delivery($sender,$arr,$deliveries) {
}
function process_profile_delivery($sender,$arr,$deliveries) {
- // deliveries is irrelevant
+
+ // deliveries is irrelevant, what to do about birthday notification....?
+
import_directory_profile($sender['hash'],$arr);
}
@@ -950,6 +954,7 @@ function import_directory_profile($hash,$profile) {
$clean = array();
if(array_key_exists('keywords',$profile) and is_array($profile['keywords'])) {
+ import_directory_keywords($hash,$profile['keywords']);
foreach($profile['keywords'] as $kw) {
$kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8'));
}
@@ -1007,3 +1012,36 @@ function import_directory_profile($hash,$profile) {
return;
}
+function import_directory_keywords($hash,$keywords) {
+
+ $existing = array();
+ $r = q("select * from xtag where xtag_hash = '%s'",
+ dbesc($hash)
+ );
+
+ if($r) {
+ foreach($r as $rr)
+ $existing[] = $rr['xtag_term'];
+ }
+
+ $clean = array();
+ foreach($keywords as $kw) {
+ $kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8'));
+ $clean[] = $kw;
+ }
+
+ foreach($existing as $x) {
+ if(! in_array($x,$clean))
+ $r = q("delete from xtag where xtag_hash = '%s' and xtag_term = '%s' limit 1",
+ dbesc($hash),
+ dbesc($x)
+ );
+ }
+ foreach($clean as $x) {
+ if(! in_array($x,$existing))
+ $r = q("insert int xtag ( xtag_hash, xtag_term) values ( '%s' ,'%s' )",
+ dbesc($hash),
+ dbesc($x)
+ );
+ }
+} \ No newline at end of file