export/import channel permissions
This commit is contained in:
parent
f7833411a1
commit
10fa5c20e7
@ -6,6 +6,7 @@
|
|||||||
require_once('include/zot.php');
|
require_once('include/zot.php');
|
||||||
require_once('include/crypto.php');
|
require_once('include/crypto.php');
|
||||||
require_once('include/menu.php');
|
require_once('include/menu.php');
|
||||||
|
require_once('include/perm_upgrade.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when creating a new channel.
|
* @brief Called when creating a new channel.
|
||||||
@ -497,7 +498,8 @@ function identity_basic_export($channel_id, $items = false) {
|
|||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
$ret['channel'] = $r[0];
|
translate_channel_perms_outbound($r[0]);
|
||||||
|
$ret['channel'] = $r[0];
|
||||||
$ret['relocate'] = [ 'channel_address' => $r[0]['channel_address'], 'url' => z_root()];
|
$ret['relocate'] = [ 'channel_address' => $r[0]['channel_address'], 'url' => z_root()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,15 +61,35 @@ function import_channel($channel, $account_id, $seize) {
|
|||||||
if(! is_site_admin())
|
if(! is_site_admin())
|
||||||
$channel['channel_pageflags'] = $channel['channel_pageflags'] ^ PAGE_ALLOWCODE;
|
$channel['channel_pageflags'] = $channel['channel_pageflags'] ^ PAGE_ALLOWCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbesc_array($channel);
|
|
||||||
|
|
||||||
$r = dbq("INSERT INTO channel (`"
|
// remove all the permissions related settings, we will import/upgrade them after the channel
|
||||||
. implode("`, `", array_keys($channel))
|
// is created.
|
||||||
. "`) VALUES ('"
|
|
||||||
. implode("', '", array_values($channel))
|
$disallowed = [
|
||||||
. "')"
|
'channel_id', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook',
|
||||||
);
|
'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall',
|
||||||
|
'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'
|
||||||
|
];
|
||||||
|
|
||||||
|
$clean = array();
|
||||||
|
foreach($channel as $k => $v) {
|
||||||
|
if(in_array($k,$disallowed))
|
||||||
|
continue;
|
||||||
|
$clean[$k] = $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($clean) {
|
||||||
|
dbesc_array($clean);
|
||||||
|
|
||||||
|
$r = dbq("INSERT INTO channel (`"
|
||||||
|
. implode("`, `", array_keys($clean))
|
||||||
|
. "`) VALUES ('"
|
||||||
|
. implode("', '", array_values($clean))
|
||||||
|
. "')"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
logger('mod_import: channel clone failed. ', print_r($channel,true));
|
logger('mod_import: channel clone failed. ', print_r($channel,true));
|
||||||
@ -86,6 +106,14 @@ function import_channel($channel, $account_id, $seize) {
|
|||||||
notice( t('Cloned channel not found. Import failed.') . EOL);
|
notice( t('Cloned channel not found. Import failed.') . EOL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extract the permissions from the original imported array and use our new channel_id to set them
|
||||||
|
// These could be in the old channel permission stule or the new pconfig. We have a function to
|
||||||
|
// translate and store them no matter which they throw at us.
|
||||||
|
|
||||||
|
$channel['channel_id'] = $r[0]['channel_id'];
|
||||||
|
translate_channel_perms_inbound($channel);
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
$channel = $r[0];
|
$channel = $r[0];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user