diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-11-05 09:55:23 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-11-05 09:55:23 +0100 |
commit | 4830a1559d5ad9f59d809bf3d693592d3f7c8ab2 (patch) | |
tree | db87b400af1f3de1ca01bccef58b0bf4e55b1241 /include/hubloc.php | |
parent | c8dd516d6c743d0371dc2ccb476eb70bcc17fa0a (diff) | |
parent | 92ea3ef72036c39601b69565f3e03fa44ad9aef7 (diff) | |
download | volse-hubzilla-4830a1559d5ad9f59d809bf3d693592d3f7c8ab2.tar.gz volse-hubzilla-4830a1559d5ad9f59d809bf3d693592d3f7c8ab2.tar.bz2 volse-hubzilla-4830a1559d5ad9f59d809bf3d693592d3f7c8ab2.zip |
Merge branch 'dev'
Diffstat (limited to 'include/hubloc.php')
-rw-r--r-- | include/hubloc.php | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/include/hubloc.php b/include/hubloc.php index d1170a62c..b2903b0ee 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -186,31 +186,30 @@ function hubloc_change_primary($hubloc) { logger('no hubloc'); return false; } - if(! (intval($hubloc['hubloc_primary']))) { - logger('not primary: ' . $hubloc['hubloc_url']); - return false; - } - logger('setting primary: ' . $hubloc['hubloc_url']); + logger('setting primary: ' . $hubloc['hubloc_url'] . ((intval($hubloc['hubloc_primary'])) ? ' true' : ' false')); - // See if there's a local channel + // See if this is a local hubloc and if so update the primary for the corresponding channel record. - $r = q("select channel_id, channel_primary from channel where channel_hash = '%s' limit 1", - dbesc($hubloc['hubloc_hash']) - ); - if($r) { - if(! $r[0]['channel_primary']) { - q("update channel set channel_primary = 1 where channel_id = %d", - intval($r[0]['channel_id']) - ); - } - else { - q("update channel set channel_primary = 0 where channel_id = %d", + if($hubloc['hubloc_url'] === z_root()) { + $r = q("select channel_id from channel where channel_hash = '%s' limit 1", + dbesc($hubloc['hubloc_hash']) + ); + if($r) { + q("update channel set channel_primary = %d where channel_id = %d", + intval($hubloc['hubloc_primary']), intval($r[0]['channel_id']) ); } } + // we only need to proceed further if this particular hubloc is now primary + + if(! (intval($hubloc['hubloc_primary']))) { + logger('not primary: ' . $hubloc['hubloc_url']); + return false; + } + // do we even have an xchan for this hubloc and if so is it already set as primary? $r = q("select * from xchan where xchan_hash = '%s' limit 1", |