diff options
-rw-r--r-- | Zotlabs/Module/Admin.php | 4 | ||||
-rw-r--r-- | include/hubloc.php | 33 | ||||
-rw-r--r-- | include/import.php | 3 |
3 files changed, 18 insertions, 22 deletions
diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 6edced9b5..8ccdaf4f5 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -109,11 +109,9 @@ class Admin extends \Zotlabs\Web\Controller { // available channels, primary and clones $channels = array(); - $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN channel_primary = 1 THEN 1 ELSE NULL END) AS main, COUNT(CASE WHEN channel_primary = 0 THEN 1 ELSE NULL END) AS clones FROM channel WHERE channel_removed = 0 and channel_system = 0"); + $r = q("SELECT COUNT(*) AS total FROM channel WHERE channel_removed = 0 and channel_system = 0"); if ($r) { $channels['total'] = array('label' => t('Channels'), 'val' => $r[0]['total']); - $channels['main'] = array('label' => t('Primary'), 'val' => $r[0]['main']); - $channels['clones'] = array('label' => t('Clones'), 'val' => $r[0]['clones']); } // We can do better, but this is a quick queue status 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", diff --git a/include/import.php b/include/import.php index 714161c57..6476aa688 100644 --- a/include/import.php +++ b/include/import.php @@ -93,8 +93,7 @@ function import_channel($channel, $account_id, $seize, $newname = '') { 'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall', 'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish', 'channel_a_delegate', 'perm_limits', 'channel_password', 'channel_salt', - 'channel_moved', 'channel_primary', 'channel_removed', 'channel_deleted', - 'channel_system' + 'channel_moved', 'channel_removed', 'channel_deleted', 'channel_system' ]; $clean = array(); |