aboutsummaryrefslogtreecommitdiffstats
path: root/include/import.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-12-17 19:48:09 +0100
committerMario <mario@mariovavti.com>2021-12-17 19:48:09 +0100
commitbfd3da43ac9226e53188a03ff1414a18422e91b4 (patch)
treeb183e7c1c76aa8d39310fd702985bff7945e7053 /include/import.php
parent32a9eaf3b6a68626580078a3302f8dd8e85eb165 (diff)
downloadvolse-hubzilla-bfd3da43ac9226e53188a03ff1414a18422e91b4.tar.gz
volse-hubzilla-bfd3da43ac9226e53188a03ff1414a18422e91b4.tar.bz2
volse-hubzilla-bfd3da43ac9226e53188a03ff1414a18422e91b4.zip
access token refactor
Diffstat (limited to 'include/import.php')
-rw-r--r--include/import.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/import.php b/include/import.php
index 8707a9430..291dd2638 100644
--- a/include/import.php
+++ b/include/import.php
@@ -162,6 +162,64 @@ function import_config($channel, $configs) {
}
}
+function import_atoken($channel, $atokens) {
+ if ($channel && $atokens) {
+ foreach ($atokens as $atoken) {
+ unset($atoken['atoken_id']);
+ $atoken['atoken_aid'] = $channel['channel_account_id'];
+ $atoken['atoken_uid'] = $channel['channel_id'];
+ create_table_from_array('atoken', $atoken);
+ }
+ }
+}
+
+function sync_atoken($channel, $atokens) {
+
+ if ($channel && $atokens) {
+ foreach ($atokens as $atoken) {
+ unset($atoken['atoken_id']);
+ $atoken['atoken_aid'] = $channel['channel_account_id'];
+ $atoken['atoken_uid'] = $channel['channel_id'];
+
+ if ($atoken['deleted']) {
+ q("delete from atoken where atoken_uid = %d and atoken_guid = '%s' ",
+ intval($atoken['atoken_uid']),
+ dbesc($atoken['atoken_guid'])
+ );
+ continue;
+ }
+
+ $r = q("select * from atoken where atoken_uid = %d and atoken_guid = '%s' ",
+ intval($atoken['atoken_uid']),
+ dbesc($atoken['atoken_guid'])
+ );
+ if (! $r) {
+ create_table_from_array('atoken', $atoken);
+ }
+ else {
+ $columns = db_columns('atoken');
+ foreach ($atoken as $k => $v) {
+ if (! in_array($k,$columns)) {
+ continue;
+ }
+
+ if (in_array($k, ['atoken_guid','atoken_uid','atoken_aid'])) {
+ continue;
+ }
+
+ $r = q("UPDATE atoken SET " . TQUOT . "%s" . TQUOT . " = '%s' WHERE atoken_guid = '%s' AND atoken_uid = %d",
+ dbesc($k),
+ dbesc($v),
+ dbesc($atoken['atoken_guid']),
+ intval($channel['channel_id'])
+ );
+ }
+ }
+ }
+ }
+}
+
+
/**
* @brief Import profiles.
*