handle UNO move channel operation
This commit is contained in:
parent
b9b46a3f88
commit
7732532964
@ -134,11 +134,18 @@ function hubloc_change_primary($hubloc) {
|
|||||||
$r = q("select channel_id, channel_primary from channel where channel_hash = '%s' limit 1",
|
$r = q("select channel_id, channel_primary from channel where channel_hash = '%s' limit 1",
|
||||||
dbesc($hubloc['hubloc_hash'])
|
dbesc($hubloc['hubloc_hash'])
|
||||||
);
|
);
|
||||||
if(($r) && (! $r[0]['channel_primary'])) {
|
if($r) {
|
||||||
|
if(! $r[0]['channel_primary']) {
|
||||||
q("update channel set channel_primary = 1 where channel_id = %d",
|
q("update channel set channel_primary = 1 where channel_id = %d",
|
||||||
intval($r[0]['channel_id'])
|
intval($r[0]['channel_id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
q("update channel set channel_primary = 0 where channel_id = %d",
|
||||||
|
intval($r[0]['channel_id'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// do we even have an xchan for this hubloc and if so is it already set as primary?
|
// do we even have an xchan for this hubloc and if so is it already set as primary?
|
||||||
|
|
||||||
|
@ -2233,6 +2233,56 @@ function process_location_delivery($sender,$arr,$deliveries) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief checks for a moved UNO channel and sets the channel_moved flag
|
||||||
|
*
|
||||||
|
* Currently the effect of this flag is to turn the channel into 'read-only' mode.
|
||||||
|
* New content will not be processed (there was still an issue with blocking the
|
||||||
|
* ability to post comments as of 10-Mar-2016).
|
||||||
|
* We do not physically remove the channel at this time. The hub admin may choose
|
||||||
|
* to do so, but is encouraged to allow a grace period of several days in case there
|
||||||
|
* are any issues migrating content. This packet will generally be received by the
|
||||||
|
* original site when the basic channel import has been processed.
|
||||||
|
*
|
||||||
|
* This will only be executed on the UNO system which is the old location
|
||||||
|
* if a new location is reported and there is only one location record.
|
||||||
|
* The rest of the hubloc syncronisation will be handled within
|
||||||
|
* sync_locations
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function check_location_move($sender_hash,$locations) {
|
||||||
|
|
||||||
|
if(! $locations)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(! UNO)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(count($locations) != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$loc = $locations[0];
|
||||||
|
|
||||||
|
$r = q("select * from channel where channel_hash = '%s' limit 1",
|
||||||
|
dbesc($sender_hash)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(! $r)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if($loc['url'] !== z_root()) {
|
||||||
|
$x = q("update channel set channel_moved = '%s' where channel_hash = '%s' limit 1",
|
||||||
|
dbesc($loc['url']),
|
||||||
|
dbesc($sender_hash)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Synchronises locations.
|
* @brief Synchronises locations.
|
||||||
*
|
*
|
||||||
@ -2247,6 +2297,10 @@ function sync_locations($sender, $arr, $absolute = false) {
|
|||||||
|
|
||||||
if($arr['locations']) {
|
if($arr['locations']) {
|
||||||
|
|
||||||
|
if($absolute)
|
||||||
|
check_location_move($sender['hash'],$arr['locations']);
|
||||||
|
|
||||||
|
|
||||||
$xisting = q("select hubloc_id, hubloc_url, hubloc_sitekey from hubloc where hubloc_hash = '%s'",
|
$xisting = q("select hubloc_id, hubloc_url, hubloc_sitekey from hubloc where hubloc_hash = '%s'",
|
||||||
dbesc($sender['hash'])
|
dbesc($sender['hash'])
|
||||||
);
|
);
|
||||||
|
@ -109,8 +109,7 @@ function import_account(&$a, $account_id) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(UNO)
|
$moving = false;
|
||||||
return;
|
|
||||||
|
|
||||||
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
|
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
|
||||||
$v1 = substr($data['compatibility']['database'],-4);
|
$v1 = substr($data['compatibility']['database'],-4);
|
||||||
@ -119,13 +118,12 @@ function import_account(&$a, $account_id) {
|
|||||||
$t = sprintf( t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1 );
|
$t = sprintf( t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1 );
|
||||||
notice($t);
|
notice($t);
|
||||||
}
|
}
|
||||||
if(array_key_exists('server_role',$data['compatibility'])
|
if(array_key_exists('server_role',$data['compatibility']) && $data['compatibility']['server_role'] == 'basic')
|
||||||
&& $data['compatibility']['server_role'] != Zotlabs\Project\System::get_server_role()) {
|
$moving = true;
|
||||||
notice( t('Server platform is not compatible. Operation not permitted.') . EOL);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if($moving)
|
||||||
|
$seize = 1;
|
||||||
|
|
||||||
// import channel
|
// import channel
|
||||||
|
|
||||||
@ -189,7 +187,7 @@ function import_account(&$a, $account_id) {
|
|||||||
|
|
||||||
if($completed < 4) {
|
if($completed < 4) {
|
||||||
|
|
||||||
if(is_array($data['hubloc'])) {
|
if(is_array($data['hubloc']) && (! $moving)) {
|
||||||
import_hublocs($channel,$data['hubloc'],$seize);
|
import_hublocs($channel,$data['hubloc'],$seize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user