Index: openacs-4/packages/xowiki/tcl/folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/folder-procs.tcl,v diff -u -r1.25 -r1.26 --- openacs-4/packages/xowiki/tcl/folder-procs.tcl 8 Jul 2013 19:18:28 -0000 1.25 +++ openacs-4/packages/xowiki/tcl/folder-procs.tcl 20 Jul 2013 15:48:35 -0000 1.26 @@ -503,6 +503,10 @@ if {[info exists hide]} { foreach column $hide {if {[info exists ::hidden($column)]} {set ::hidden($column) 1}} } + # + # We have to use the global variable for the time being due to + # scoping in "-columns" + set ::with_publish_status [expr {$publish_status ne "ready"}] set t [::YUI::DataTable new -skin $skin -volatile \ -columns { @@ -519,6 +523,11 @@ AnchorField edit -CSSclass edit-item-button -label "" \ -hide $::hidden(edit) \ -html {style "padding: 0px;"} + if {$::with_publish_status} { + ImageAnchorField publish_status -orderby publish_status.src -src "" \ + -width 8 -height 8 -border 0 -title "Toggle Publish Status" \ + -alt "publish status" -label [_ xowiki.publish_status] -html {style "padding: 2px;text-align: center;"} + } Field object_type -label [_ xowiki.page_kind] -orderby object_type -richtext false \ -hide $::hidden(object_type) \ -html {style "padding: 0px;"} @@ -536,10 +545,10 @@ set extra_where_clause "true" # TODO: why filter on title and name? if {[info exists regexp]} {set extra_where_clause "(bt.title ~ '$regexp' OR ci.name ~ '$regexp' )"} - set publish_status_clause [::xowiki::Includelet publish_status_clause $publish_status] set items [::xowiki::FormPage get_all_children \ -folder_id $current_folder_id \ + -publish_status $publish_status \ -object_types [my types_to_show] \ -extra_where_clause $extra_where_clause] @@ -585,6 +594,22 @@ -delete "" \ -delete.href $delete_link \ -delete.title #xowiki.delete# + + if {$::with_publish_status} { + # TODO: this should get some architectural support + if {[$c set publish_status] eq "ready"} { + set image active.png + set state "production" + } else { + set image inactive.png + set state "ready" + } + set revision_id [$c set revision_id] + [$t last_child] set publish_status.src /resources/xowiki/$image + [$t last_child] set publish_status.href \ + [export_vars -base [$package_id package_url]admin/set-publish-state \ + {state revision_id return_url}] + } } foreach {att order} [split $orderby ,] break 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.26 -r1.27 --- openacs-4/packages/xowiki/tcl/import-procs.tcl 13 Sep 2012 16:05:27 -0000 1.26 +++ openacs-4/packages/xowiki/tcl/import-procs.tcl 20 Jul 2013 15:48:35 -0000 1.27 @@ -294,7 +294,7 @@ if {[$item_id istype ::xowiki::PageInstance]} { set template_id [$item_id page_template] if {![info exists items($template_id)]} { - ns_log notice "--export including parent-object $template_id [$template_id name]" + ns_log notice "--export including template-object $template_id [$template_id name]" set items($template_id) 1 ::xo::db::CrClass get_instance_from_db -item_id $template_id set new 1 @@ -306,7 +306,7 @@ # check for child objects of the item # set sql [::xowiki::Page instance_select_query -folder_id $item_id -with_subtypes true] - db_foreach instance_select $sql { + db_foreach [my qn export_child_obj] $sql { if {![info exists items($item_id)]} { ::xo::db::CrClass get_instance_from_db -item_id $item_id ns_log notice "--export including child $item_id [$item_id name]" @@ -326,6 +326,7 @@ foreach item_id $item_ids { if {[catch {set obj [$item_id marshall]} errorMsg]} { ns_log error "Error while exporting $item_id [$item_id name]\n$errorMsg\n$::errorInfo" + error $errorMsg } else { append content $obj\n } @@ -347,6 +348,7 @@ foreach item_id $item_ids { ns_log notice "--exporting $item_id [$item_id name]" + ns_write "# exporting $item_id [$item_id name] [$item_id pretty_link]\n" if {[catch {set obj [$item_id marshall]} errorMsg]} { ns_log error "Error while exporting $item_id [$item_id name]\n$errorMsg\n$::errorInfo" } else { 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.470 -r1.471 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 24 Jun 2013 11:08:32 -0000 1.470 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 20 Jul 2013 15:48:35 -0000 1.471 @@ -523,39 +523,65 @@ if {$party_id eq "" || $party_id == 0} { return $party_id } - if {[catch {acs_user::get -user_id $party_id -array info}]} { - ns_log warning "Cannot map party_id $party_id, probably not a user; property $property lost during export" - return {} + if {![catch {acs_user::get -user_id $party_id -array info}]} { + set result [list] + foreach a {username email first_names last_name screen_name url} { + lappend result $a $info($a) + } + ns_log notice "-- map_party $party_id: $result" + return $result } - set result [list] - foreach a {username email first_names last_name screen_name url} { - lappend result $a $info($a) + if {![catch {group::get -group_id $party_id -array info}]} { + ns_log notice "got group info: [array get info]" + set result [array get info] + set members {} + foreach member_id [group::get_members -group_id $party_id] { + lappend members [my map_party -property $property $member_id] + } + lappend result members $members + ns_log notice "-- map_party $party_id: $result" + return $result } - return $result + ns_log warning "Cannot map party_id $party_id, probably not a user; property $property lost during export" + return {} } Page instproc reverse_map_party {-entry -default_party {-create_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 array set "" $entry - if {$(email) ne ""} { + if {[info exists (email)] && $(email) ne ""} { set id [party::get_by_email -email $(email)] if {$id ne ""} { return $id } } - if {$(username) ne ""} { + if {[info exists (username)] && $(username) ne ""} { set id [acs_user::get_by_username -username $(username)] if {$id ne ""} { return $id } } + if {[info exists (group_name)] && $(group_name) ne ""} { + set id [group::get_id -group_name $(group_name)] + if {$id ne ""} { return $id } + } + if {$create_user_ids} { - my log "+++ create a new user username=$(username), email=$(email)" - array set status [auth::create_user -username $(username) -email $(email) \ - -first_names $(first_names) -last_name $(last_name) \ - -screen_name $(screen_name) -url $(url)] - if {$status(creation_status) eq "ok"} { - return $status(user_id) + if {[info exists (group_name)] && $(group_name) ne ""} { + my log "+++ create a new group group_name=$(group_name)" + set group_id [group::new -group_name $(group_name)] + array set info [list join_policy $(join_policy)] + group::update -group_id $group_id -array info + ns_log notice "+++ reverse_party_map: we could add members $(members) - but we don't" + return $group_id + } else { + my log "+++ create a new user username=$(username), email=$(email)" + array set status [auth::create_user -username $(username) -email $(email) \ + -first_names $(first_names) -last_name $(last_name) \ + -screen_name $(screen_name) -url $(url)] + if {$status(creation_status) eq "ok"} { + return $status(user_id) + } + my log "+++ create user username=${username}, email=$(email) failed, reason=$status(creation_status)" } - my log "+++ create user username=${username}, email=$(email) failed, reason=$status(creation_status)" } return $default_party } Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -r1.316 -r1.317 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 6 Jul 2013 14:18:56 -0000 1.316 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 20 Jul 2013 15:48:35 -0000 1.317 @@ -95,10 +95,10 @@ my instvar package_id set clipboard [::xowiki::clipboard get] ::xowiki::exporter export $clipboard + ns_conn close ::xowiki::clipboard clear #::$package_id returnredirect [my query_parameter "return_url" [::xo::cc url]] } - # # externally callable method: create-new @@ -267,6 +267,35 @@ } # + # externally callable method: use-template + # + PageInstance instproc use-template {} { + my instvar package_id + set formName [my query_parameter "form" ""] + if {$formName eq ""} { + error "no form specified" + } + $package_id get_lang_and_name -default_lang [::xo::cc lang] -path $formName lang stripped_url + array set "" [$package_id item_ref -default_lang $lang -parent_id [$package_id folder_id] $formName] + if {$(item_id) == 0} { error "cannot lookup page $formName" } + ::xo::db::CrClass get_instance_from_db -item_id $(item_id) + if {[info command ::$(item_id)] eq "" + || "::xowiki::PageTemplate" ni [$(item_id) info precedence]} { + error "OK $formName is not suited to be used as template. Should be a Form!" + } + if {[my page_template] == $(item_id)} { + my msg "old page_template $(item_id) is already the same as the new one" + } else { + set msg "change template_id [my page_template] to $(item_id)" + my page_template $(item_id) + my save + my msg "ok $msg" + } + $package_id returnredirect [::xo::cc url] + } + + + # # externally callable method: delete # @@ -962,7 +991,7 @@ return [my view [my include [list form-usages -form_item_id [my item_id]]]] } if {[my is_folder_page]} { - return [my view [my include [list child-resources]]] + return [my view [my include [list child-resources -publish_status all]]] } #my msg "method list undefined for this kind of object" [my package_id] returnredirect [::xo::cc url] Index: openacs-4/packages/xowiki/www/admin/export.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/admin/export.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/xowiki/www/admin/export.tcl 20 Nov 2012 10:42:33 -0000 1.20 +++ openacs-4/packages/xowiki/www/admin/export.tcl 20 Jul 2013 15:48:35 -0000 1.21 @@ -37,4 +37,4 @@ # needed objects. # ::xowiki::exporter export [array names items] - +ns_conn close 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.22 -r1.23 --- openacs-4/packages/xowiki/www/admin/import.tcl 13 Sep 2012 16:05:32 -0000 1.22 +++ openacs-4/packages/xowiki/www/admin/import.tcl 20 Jul 2013 15:48:35 -0000 1.23 @@ -46,9 +46,15 @@ foreach o [::xowiki::Page allinstances] { set preexists($o) 1 } - if {[catch {namespace eval ::xo::import $content} error]} { - #my msg "Error: $::errorInfo" - set msg "Error: $error\n$::errorInfo" + if {[catch {namespace eval ::xo::import $content} errorMsg]} { + set msg "Error: $errorMsg\n$::errorInfo" + ns_log notice $msg + # cleanup all objects, that did not exist before + foreach o [::xowiki::Page allinstances] { + if {![info exists preexists($o)]} { + if {[::xotcl::Object isobject $o]} {$o destroy} + } + } } else { set objects [list] foreach o [::xowiki::Page allinstances] {