aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-06-17 17:34:51 -0700
committerfriendica <info@friendica.com>2014-06-17 17:34:51 -0700
commitdafd3a9e43dbcde07fb900c27cb7f386a40900ce (patch)
tree595ac46b93c05da7fd69040960f3c09645eccb41
parent70b99ee23bbe88f4ff1cc231a87f9e53d27ff6fb (diff)
downloadvolse-hubzilla-dafd3a9e43dbcde07fb900c27cb7f386a40900ce.tar.gz
volse-hubzilla-dafd3a9e43dbcde07fb900c27cb7f386a40900ce.tar.bz2
volse-hubzilla-dafd3a9e43dbcde07fb900c27cb7f386a40900ce.zip
sync profiles to nomadic clones
-rw-r--r--include/zot.php39
-rw-r--r--mod/profiles.php11
-rw-r--r--version.inc2
3 files changed, 50 insertions, 2 deletions
diff --git a/include/zot.php b/include/zot.php
index 00cfa62a9..65d2a6f13 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2254,6 +2254,45 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
}
}
}
+
+ if(array_key_exists('profile',$arr) && is_array($arr['profile']) && count($arr['profile'])) {
+
+ $disallowed = array('id','aid','uid');
+
+ foreach($arr['profile'] as $profile) {
+ $x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
+ dbesc($profile['profile_guid']),
+ intval($channel['channel_id'])
+ );
+ if(! $x) {
+ q("insert into profile ( profile_guid, aid, uid ) values ('%s', %d, %d)",
+ dbesc($profile['profile_guid']),
+ intval($channel['channel_account_id']),
+ intval($channel['channel_id'])
+ );
+ $x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
+ dbesc($profile['profile_guid']),
+ intval($channel['channel_id'])
+ );
+ if(! $x)
+ continue;
+ }
+ $clean = array();
+ foreach($profile as $k => $v) {
+ if(in_array($k,$disallowed))
+ continue;
+ $clean[$k] = $v;
+ // TODO - check if these are allowed, otherwise we'll error
+ }
+ if(count($clean)) {
+ foreach($clean as $k => $v) {
+ $r = dbq("UPDATE profile set " . dbesc($k) . " = '" . dbesc($v)
+ . "' where profile_guid = '" . dbesc($profile['profile_guid']) . "' and uid = " . intval($channel['channel_id'])
+ . " limit 1");
+ }
+ }
+ }
+ }
$result[] = array($d['hash'],'channel sync updated',$channel['channel_name'],'');
diff --git a/mod/profiles.php b/mod/profiles.php
index 481680a12..2e91db600 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -419,13 +419,22 @@ function profiles_post(&$a) {
dbesc($work),
dbesc($education),
intval($hide_friends),
- intval($a->argv[1]),
+ intval(argv(1)),
intval(local_user())
);
if($r)
info( t('Profile updated.') . EOL);
+ $r = q("select * from profile where id = %d and uid = %d limit 1",
+ intval(argv(1)),
+ intval(local_user())
+ );
+ if($r) {
+ require_once('include/zot.php');
+ build_sync_packet(local_user(),array('profile' => $r));
+ }
+
$channel = $a->get_channel();
if($namechanged && $is_default) {
diff --git a/version.inc b/version.inc
index 3523ee071..1b79e011f 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-06-16.708
+2014-06-17.709