Index: openacs-4/packages/xowiki/tcl/import-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/import-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/xowiki/tcl/import-procs.tcl 9 Jun 2008 11:32:36 -0000 1.3 +++ openacs-4/packages/xowiki/tcl/import-procs.tcl 9 Jul 2008 11:39:48 -0000 1.4 @@ -21,7 +21,7 @@ return "$added objects newly inserted, $updated objects updated, $replaced objects replaced
" } - Importer instproc import {-object -replace -base_object} { + Importer instproc import {-object -replace -base_object -keep_user_ids} { my instvar package_id folder_id user_id $object demarshall -parent_id $folder_id -package_id $package_id -creation_user $user_id set item_id [::xo::db::CrClass lookup -name [$object name] -parent_id [$object parent_id]] @@ -60,7 +60,7 @@ } } - Importer instproc import_all {-replace -objects:required } { + Importer instproc import_all {-replace -objects:required {-keep_user_ids 0}} { my instvar package_id folder_id set todo [list] foreach o $objects { @@ -70,7 +70,7 @@ continue } my log "importing (1st round) $o [$o name] [$o info class]" - my import -object $o -replace $replace + my import -object $o -replace $replace -keep_user_ids $keep_user_ids } while {[llength $todo] > 0} { @@ -101,7 +101,7 @@ break } my log "importing (2nd round) process $o, todo=$todo" - my import -object $o -replace $replace -base_object $template_id + my import -object $o -replace $replace -base_object $template_id -keep_user_ids $keep_user_ids } foreach o $objects {$o destroy} } Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.120 -r1.121 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 9 May 2008 21:15:39 -0000 1.120 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 9 Jul 2008 11:39:48 -0000 1.121 @@ -602,7 +602,7 @@ # Package import # - Package ad_instproc import {-user_id -folder_id {-replace 0} -objects} { + Package ad_instproc import {-user_id -folder_id {-replace 0} -objects {-keep_user_ids 0}} { import the specified pages into the xowiki instance } { if {![info exists folder_id]} {set folder_id [my folder_id]} @@ -611,7 +611,7 @@ set msg "processing objects: $objects
"
set importer [Importer new -package_id [my id] -folder_id $folder_id -user_id $user_id]
- $importer import_all -replace $replace -objects $objects
+ $importer import_all -replace $replace -objects $objects -keep_user_ids $keep_user_ids
append msg [$importer report]
}
Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v
diff -u -r1.258 -r1.259
--- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 9 Jul 2008 10:37:44 -0000 1.258
+++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 9 Jul 2008 11:39:48 -0000 1.259
@@ -393,11 +393,14 @@
return $result
}
- Page instproc reverse_map_party {-entry -default_party} {
+ Page instproc reverse_map_party {-entry -default_party {-keep_user_ids 0}} {
# So far, we just handle users, but we should support parties in
# the future as well.http://localhost:8003/nimawf/admin/export
+ if {!$keep_user_ids} {
+ # we do not want to create new parties
+ return $default_party
+ }
array set "" $entry
- #return $default_party
if {$(email) ne ""} {
set id [party::get_by_email -email $(email)]
if {$id ne ""} { return $id }
@@ -418,24 +421,27 @@
}
- Page instproc reverse_map_party_attribute {-attribute {-default_party 0}} {
+ Page instproc reverse_map_party_attribute {-attribute {-default_party 0} {-keep_user_ids 0}} {
if {![my exists $attribute]} {
my set $attribute $default_party
} elseif {[llength [my set $attribute]] < 2} {
my set $attribute $default_party
} else {
my set $attribute [my reverse_map_party \
-entry [my set $attribute] \
- -default_party $default_party]
+ -default_party $default_party \
+ -keep_user_ids $keep_user_ids]
}
}
- Page instproc demarshall {-parent_id -package_id -creation_user} {
+ Page instproc demarshall {-parent_id -package_id -creation_user {-keep_user_ids 0}} {
# this method is the counterpart of marshall
my set parent_id $parent_id
my set package_id $package_id
- my reverse_map_party_attribute -attribute creation_user -default_party $creation_user
- my reverse_map_party_attribute -attribute modifying_user -default_party $creation_user
+ my reverse_map_party_attribute -attribute creation_user \
+ -default_party $creation_user -keep_user_ids $keep_user_ids
+ my reverse_map_party_attribute -attribute modifying_user \
+ -default_party $creation_user -keep_user_ids $keep_user_ids
# if we import from an old database without page_order, take care about this
if {![my exists page_order]} {my set page_order ""}
# handle category import
@@ -472,10 +478,10 @@
}
next
}
- FormPage instproc demarshall {-parent_id -package_id -creation_user} {
+ FormPage instproc demarshall {-parent_id -package_id -creation_user {-keep_user_ids 0}} {
my instvar page_template
#
- my reverse_map_party_attribute -attribute assignee
+ my reverse_map_party_attribute -attribute assignee -keep_user_ids $keep_user_ids
#
# FormPages must be demarshalled after Form, since Form builds
# the reverse category map.
@@ -502,8 +508,9 @@
} elseif {$use($name) eq "party_id"} {
lappend ia $name [my reverse_map_party \
-entry $value \
- -default_party $creation_user]
- #my msg "field $name mapping $value to [my reverse_map_party -entry $value -default_party $creation_user]"
+ -default_party $creation_user \
+ -keep_user_ids $keep_user_ids]
+ #my msg "field $name mapping $value to [my reverse_map_party -entry $value -default_party $creation_user -keep_user_ids $keep_user_ids]"
} elseif {$value eq ""} {
lappend ia $name ""
} else {
Index: openacs-4/packages/xowiki/www/admin/import.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/admin/import.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/xowiki/www/admin/import.adp 5 Jan 2007 12:11:03 -0000 1.3
+++ openacs-4/packages/xowiki/www/admin/import.adp 9 Jul 2008 11:39:48 -0000 1.4
@@ -3,26 +3,7 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
Index
Index: openacs-4/packages/xowiki/www/admin/import.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/admin/import.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/xowiki/www/admin/import.tcl 21 Feb 2008 21:44:53 -0000 1.12
+++ openacs-4/packages/xowiki/www/admin/import.tcl 9 Jul 2008 11:39:48 -0000 1.13
@@ -4,17 +4,28 @@
@author Gustaf Neumann (gustaf.neumann@wu-wien.ac.at)
@creation-date Aug 11, 2006
@cvs-id $Id$
+} -parameter {
+ {keep_user_ids 0}
+ {replace 0}
+}
-}
+
set msg ""
ad_form \
-name upload_form \
-mode edit \
- -export {fs_package_id folder_id orderby selector_type file_types} \
-html { enctype multipart/form-data } \
-form {
- {upload_file:file(file) {html {size 30}} }
+ {upload_file:file(file) {html {size 30}} {label "Import file for upload"} }
+ {keep_user_ids:integer(radio),optional {options {{yes 1} {no 0}}} {value 0}
+ {label "Keep user_ids"}
+ {help_text "If checked, import will keep the original user_ids and create the needed user_ids if necessary"}
+ }
+ {replace:integer(radio),optional {options {{yes 1} {no 0}}} {value 0}
+ {label "Replace objects"}
+ {help_text "If checked, import will delete the object if it exists and create it new, otherwise import just adds a revision"}
+ }
{ok_btn:text(submit) {label "[_ acs-templating.HTMLArea_SelectUploadBtn]"}
}
} \
@@ -37,7 +48,7 @@
if {[catch {namespace eval ::xo::import $content} error]} {
set msg "Error: $error"
} else {
- set msg [$package_id import -replace 0]
+ set msg [$package_id import -replace $replace -keep_user_ids $keep_user_ids]
}
namespace delete ::xo::import
}