aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-12-22 04:33:32 -0800
committerfriendica <info@friendica.com>2012-12-22 04:33:32 -0800
commitce0d38969614fbc1c7e3d9d54d974962a1014357 (patch)
tree7e97d9d5ea30d438c0f6ed4d2a929c0c4c811cc1 /include/zot.php
parent91932ac5a8d13ba57070512389efaaffdafbd03b (diff)
downloadvolse-hubzilla-ce0d38969614fbc1c7e3d9d54d974962a1014357.tar.gz
volse-hubzilla-ce0d38969614fbc1c7e3d9d54d974962a1014357.tar.bz2
volse-hubzilla-ce0d38969614fbc1c7e3d9d54d974962a1014357.zip
profile messages for directory synchronisation
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php72
1 files changed, 71 insertions, 1 deletions
diff --git a/include/zot.php b/include/zot.php
index 049cf004b..ade35f0f1 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -722,8 +722,16 @@ function zot_import($arr) {
process_mail_delivery($i['notify']['sender'],$arr,$deliveries);
}
- }
+ elseif($i['message']['type'] === 'profile') {
+ $arr = get_profile_elements($i['message']);
+
+ logger('Profile received: ' . print_r($arr,true));
+ logger('Profile recipients: ' . print_r($deliveries,true));
+
+ process_profile_delivery($i['notify']['sender'],$arr,$deliveries);
+ }
+ }
}
}
}
@@ -901,3 +909,65 @@ function process_mail_delivery($sender,$arr,$deliveries) {
}
}
}
+
+function process_profile_delivery($sender,$arr,$deliveries) {
+
+ // deliveries is irrelevant
+
+ $r = q("select * from xprof where xprof_hash = '%s' limit 1",
+ dbesc($sender['hash'])
+ );
+ if(! $r) {
+ $x = q("insert into xprof ( xprof_hash, xprof_desc, xprof_dob, xprof_gender, xprof_marital, xprof_sexual,
+ xprof_locale, xprof_region, xprof_postcode, xprof_country ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
+ dbesc($sender['hash']),
+ dbesc($arr['desc']),
+ dbesc($arr['dob']),
+ dbesc($arr['gender']),
+ dbesc($arr['marital']),
+ dbesc($arr['sexual']),
+ dbesc($arr['locale']),
+ dbesc($arr['region']),
+ dbesc($arr['postcode']),
+ dbesc($arr['country'])
+ );
+ }
+ else {
+ $x = q("update xprof set
+ xprof_desc = '%s'
+ xprof_dob = '%s',
+ xprof_gender = '%s',
+ xprof_marital = '%s',
+ xprof_sexual = '%s',
+ xprof_locale = '%s',
+ xprof_region = '%s',
+ xprof_postcode = '%s',
+ xprof_country = '%s'
+ where xprof_hash = '%s' limit 1",
+ dbesc($arr['desc']),
+ dbesc($arr['dob']),
+ dbesc($arr['gender']),
+ dbesc($arr['marital']),
+ dbesc($arr['sexual']),
+ dbesc($arr['locale']),
+ dbesc($arr['region']),
+ dbesc($arr['postcode']),
+ dbesc($arr['country']),
+ dbesc($sender['hash'])
+ );
+ }
+
+ // optimise this, get existing tags and check which still exist and which don't!!!
+
+ $x = q("delete from xtag where xtag_hash = '%s'");
+ if($arr['keywords']) {
+ foreach($arr['keywords'] as $tag) {
+ $r = q("insert into xtag ( xtag_hash, xtag_term ) values ( '%s', '%s' )",
+ dbesc($sender['hash']),
+ dbesc($tag)
+ );
+ }
+ }
+
+
+} \ No newline at end of file