aboutsummaryrefslogtreecommitdiffstats
path: root/mod/import.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-02-21 21:18:36 -0800
committerfriendica <info@friendica.com>2013-02-21 21:18:36 -0800
commit1abce176ff35a0ce5cf6c9b2a762afe279387db7 (patch)
tree23781797fa9e9536a867c0a286330c417d308ff7 /mod/import.php
parent1e464120ebccf8d4cb03db748f08ce19eb31a6f4 (diff)
downloadvolse-hubzilla-1abce176ff35a0ce5cf6c9b2a762afe279387db7.tar.gz
volse-hubzilla-1abce176ff35a0ce5cf6c9b2a762afe279387db7.tar.bz2
volse-hubzilla-1abce176ff35a0ce5cf6c9b2a762afe279387db7.zip
add groups and personal configs to export/import
Diffstat (limited to 'mod/import.php')
-rw-r--r--mod/import.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/mod/import.php b/mod/import.php
index f35ca149b..8b8019a99 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -250,6 +250,63 @@ function import_post(&$a) {
}
}
+
+ $configs = $data['config'];
+ if($configs) {
+ foreach($configs as $config) {
+ unset($config['id']);
+ $config['uid'] = $channel['channel_id'];
+ dbesc_array($config);
+ $r = dbq("INSERT INTO pconfig (`"
+ . implode("`, `", array_keys($config))
+ . "`) VALUES ('"
+ . implode("', '", array_values($config))
+ . "')" );
+ }
+ }
+
+ $groups = $data['group'];
+ if($groups) {
+ $saved = array();
+ foreach($groups as $group) {
+ $saved[$group['hash']] = array('old' => $group['id']);
+ unset($group['id']);
+ $group['uid'] = $channel['channel_id'];
+ dbesc_array($group);
+ $r = dbq("INSERT INTO group (`"
+ . implode("`, `", array_keys($group))
+ . "`) VALUES ('"
+ . implode("', '", array_values($group))
+ . "')" );
+ }
+ $r = q("select * from group where uid = %d",
+ intval($channel['channel_id'])
+ );
+ if($r) {
+ foreach($r as $rr) {
+ $saved[$rr['hash']]['new'] = $rr['id'];
+ }
+ }
+ }
+
+ $group_members = $data['group_member'];
+ if($groups_members) {
+ foreach($group_members as $group_member) {
+ unset($group_member['id']);
+ $group_member['uid'] = $channel['channel_id'];
+ foreach($saved as $x) {
+ if($x['old'] == $group_member['gid'])
+ $group_member['gid'] = $x['new'];
+ }
+ dbesc_array($group_member);
+ $r = dbq("INSERT INTO group_member (`"
+ . implode("`, `", array_keys($group_member))
+ . "`) VALUES ('"
+ . implode("', '", array_values($group_member))
+ . "')" );
+ }
+ }
+
// FIXME - ensure we have a self entry if somebody is trying to pull a fast one
if($seize) {