Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario Vavti
2018-05-02 09:22:23 +02:00
9 changed files with 114 additions and 86 deletions

View File

@@ -460,3 +460,28 @@ function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) {
\DBA::$logging = false;
\DBA::$dba->debug = $saved;
}
function db_columns($table) {
if($table) {
if(ACTIVE_DBTYPE === DBTYPE_POSTGRES) {
$r = q("SELECT column_name as field FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '%s'",
dbesc($table)
);
if($r) {
return ids_to_array($r,'field');
}
}
else {
$r = q("show columns in %s",
dbesc($table)
);
if($r) {
return ids_to_array($r,'Field');
}
}
}
return [];
}

View File

@@ -14,7 +14,7 @@ require_once('include/perm_upgrade.php');
* @param int $seize
* @return boolean|array
*/
function import_channel($channel, $account_id, $seize) {
function import_channel($channel, $account_id, $seize, $newname = '') {
if(! array_key_exists('channel_system',$channel)) {
$channel['channel_system'] = (($channel['channel_pageflags'] & 0x1000) ? 1 : 0);
@@ -30,6 +30,11 @@ function import_channel($channel, $account_id, $seize) {
$channel['channel_hash'] = make_xchan_hash($channel['channel_guid'],$channel['channel_guid_sig']);
if($newname) {
$channel['channel_address'] = $newname;
}
// Check for duplicate channels
$r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s' or channel_address = '%s' ) limit 1",