diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-05-02 09:22:23 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-05-02 09:22:23 +0200 |
commit | 9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e (patch) | |
tree | 08ab408a73711eedbc231ba3bfb3325cdb7842b9 /include | |
parent | 3f75dd108374d24674436c58deb9d2a795fbf604 (diff) | |
parent | 7a55ead97db94284146612364b8ce1c59de8771f (diff) | |
download | volse-hubzilla-9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e.tar.gz volse-hubzilla-9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e.tar.bz2 volse-hubzilla-9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e.zip |
Merge remote-tracking branch 'mike/master' into dev
Diffstat (limited to 'include')
-rwxr-xr-x | include/dba/dba_driver.php | 25 | ||||
-rw-r--r-- | include/import.php | 7 |
2 files changed, 31 insertions, 1 deletions
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index b3298b673..9e9f24bb3 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -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 []; +}
\ No newline at end of file diff --git a/include/import.php b/include/import.php index 0d3fb8c32..ae6a0ab6a 100644 --- a/include/import.php +++ b/include/import.php @@ -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", |