aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-31 00:50:20 -0800
committerfriendica <info@friendica.com>2015-01-31 00:50:20 -0800
commite6a5f7800390e5091743d6a97c6fd8f54c5d1530 (patch)
tree20c49c7d11b411b91530ef43374a208274ebbb57 /include/zot.php
parent4a243b63f7019a1e56ecf03b138cd7fc396236c2 (diff)
parent3e5226adc70838c784a0b208de25fffde37a6679 (diff)
downloadvolse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.tar.gz
volse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.tar.bz2
volse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.zip
Merge branch 'master' into tres
Conflicts: include/zot.php
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php43
1 files changed, 34 insertions, 9 deletions
diff --git a/include/zot.php b/include/zot.php
index 58cb9a8cc..ed8f1e72e 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -296,14 +296,24 @@ function zot_refresh($them,$channel = null, $force = false) {
if($channel)
logger('zot_refresh: channel: ' . print_r($channel,true), LOGGER_DATA);
+ $url = null;
+
if($them['hubloc_url'])
$url = $them['hubloc_url'];
else {
- $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1",
+ $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'",
dbesc($them['xchan_hash'])
);
- if($r)
- $url = $r[0]['hubloc_url'];
+ if($r) {
+ foreach($r as $rr) {
+ if($rr['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) {
+ $url = $rr['hubloc_url'];
+ break;
+ }
+ }
+ if(! $url)
+ $url = $r[0]['hubloc_url'];
+ }
}
if(! $url) {
logger('zot_refresh: no url');
@@ -1954,10 +1964,18 @@ function sync_locations($sender,$arr,$absolute = false) {
}
}
- if((intval($r[0]['hubloc_primary']) && (! $location['primary']))
- || ((! intval($r[0]['hubloc_primary'])) && ($location['primary']))) {
- $m = q("update hubloc set hubloc_primary = %d, hubloc_updated = '%s' where hubloc_id = %d",
- intval($location['primary']),
+ if(intval($r[0]['hubloc_primary']) && (! $location['primary'])) {
+ $m = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_id = %d",
+ dbesc(datetime_convert()),
+ intval($r[0]['hubloc_id'])
+ );
+ $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY;
+ hubloc_change_primary($r[0]);
+ $what .= 'primary_hub ';
+ $changed = true;
+ }
+ elseif((! intval($r[0]['hubloc_primary'])) && ($location['primary'])) {
+ $m = q("update hubloc set hubloc_primary = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
@@ -1977,8 +1995,15 @@ function sync_locations($sender,$arr,$absolute = false) {
}
if((intval($r[0]['hubloc_deleted']) && (! $location['deleted']))
|| ((! (intval($r[0]['hubloc_deleted']))) && ($location['deleted']))) {
- $n = q("update hubloc set hubloc_deleted = %d, hubloc_updated = '%s' where hubloc_id = %d",
- intval($location['deleted']),
+ $n = q("update hubloc set hubloc_deleted = 0, hubloc_updated = '%s' where hubloc_id = %d",
+ dbesc(datetime_convert()),
+ intval($r[0]['hubloc_id'])
+ );
+ $what .= 'delete_hub ';
+ $changed = true;
+ }
+ elseif((! intval($r[0]['hubloc_deleted'])) && ($location['deleted'])) {
+ $n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);