Index: openacs-4/packages/learning-content/tcl/learning-content-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/tcl/learning-content-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/learning-content/tcl/learning-content-procs.tcl 5 Mar 2009 21:28:57 -0000 1.1
+++ openacs-4/packages/learning-content/tcl/learning-content-procs.tcl 18 Aug 2011 23:18:57 -0000 1.2
@@ -254,7 +254,7 @@
set list_of_expressions [split $page_content ">"]
foreach expression $list_of_expressions {
if {[regexp \
- /dotlrn(.*)file-storage(.*)(\\.)(...|....)(\") \
+ /dotlrn(\[^"\]*)file-storage(\[^"\]*)(\\.)(...|....)(\") \
$expression one_match]} {
set one_match [string trimright $one_match "\""]
set this_match [list $one_match [learning_content::replace_path \
@@ -842,6 +842,106 @@
}
}
+ad_proc -public learning_content::category::set_category_publish_state {
+ -category_id
+ -tree_id
+ -wiki_folder_id
+ -state
+} {
+
+ set tree_list [learning_content::category::get_tree_levels -subtree_id $category_id -tree_id $tree_id]
+ foreach one_category $tree_list {
+ set cat_id [lindex $one_category 0]
+ db_foreach select_page {
+ select ci.item_id, r.revision_id, ci.name
+ from category_object_map c, cr_items ci, cr_revisions r, xowiki_page p
+ where c.object_id = ci.item_id and ci.parent_id = :wiki_folder_id
+ and ci.content_type not in ('::xowiki::PageTemplate')
+ and ci.name not in ('en:header_page','en:index','en:indexe')
+ and r.revision_id = ci.live_revision
+ and p.page_id = r.revision_id
+ and category_id = :cat_id
+ order by p.page_order} {
+ ns_cache flush xotcl_object_cache ::$item_id
+ ns_cache flush xotcl_object_cache ::$revision_id
+
+ ::xo::db::sql::content_item set_live_revision \
+ -revision_id $revision_id \
+ -publish_status $state
+
+ if {$state ne "production"} {
+ # ::xowiki::notification::do_notifications
+ # -revision_id $revision_id
+ # ::xowiki::datasource $revision_id
+ } else {
+ db_dml flush_syndication {delete from syndication where object_id = :revision_id}
+ }
+ }
+ }
+}
+
+ad_proc -public learning_content::category::get_ready_objects {
+ -category_id
+ {-object_type ""}
+ {-content_type ""}
+ {-include_children:boolean}
+} {
+ Returns a list of objects which are mapped to this category_id with publish_staus = ready
+
+ @param category_id CategoryID of the category we want to get the objects for
+ @param object_type Limit the search for objects of this object type
+ @param content_type Limit the search for objects of this content_type
+ @param include_children Include child categories' objects as well. Not yet implemented
+
+ @author malte ()
+ @creation-date Wed May 30 06:28:25 CEST 2007
+} {
+ set join_clause ""
+ set where_clause ""
+ if {$content_type ne ""} {
+ set join_clause ", cr_items i"
+ set where_clause "and i.item_id = com.object_id and i.content_type = :content_type and i.publish_status = 'ready' and i.name not in ('en:header_page','en:index','en:indexe')"
+ } elseif {$object_type ne ""} {
+ set join_clause ", acs_objects o"
+ set where_clause "and o.object_id = com.object_id and o.object_type = :object_type"
+ }
+ return [db_list get_ready_objects {}]
+}
+
+ad_proc -public learning_content::category::get_all_objects {
+ -category_id
+ {-object_type ""}
+ {-content_type ""}
+ {-show_all_p "f"}
+ {-include_children:boolean}
+} {
+ Returns a list of objects which are mapped to this category_id with publish_status = ready or production
+
+ @param category_id CategoryID of the category we want to get the objects for
+ @param object_type Limit the search for objects of this object type
+ @param content_type Limit the search for objects of this content_type
+ @param show_all_p Show all objects, ready and production publish_status
+ @param include_children Include child categories' objects as well. Not yet implemented
+
+ @author malte ()
+ @creation-date Wed May 30 06:28:25 CEST 2007
+} {
+ set join_clause ""
+ set where_clause ""
+ if {$content_type ne ""} {
+ set join_clause ", cr_items i"
+ if {$show_all_p} {
+ set where_clause "and i.item_id = com.object_id and i.content_type = :content_type and i.publish_status in ('production','ready') and i.name not in ('en:header_page','en:index','en:indexe')"
+ } else {
+ set where_clause "and i.item_id = com.object_id and i.content_type = :content_type and i.publish_status = 'ready' and i.name not in ('en:header_page','en:index','en:indexe')"
+ }
+ } elseif {$object_type ne ""} {
+ set join_clause ", acs_objects o"
+ set where_clause "and o.object_id = com.object_id and o.object_type = :object_type"
+ }
+ return [db_list get_all_objects {}]
+}
+
ad_proc -public learning_content::value_compare {
{-def:required}
x
Index: openacs-4/packages/learning-content/tcl/learning-content-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/tcl/learning-content-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/learning-content/tcl/learning-content-procs.xql 5 Mar 2009 21:28:57 -0000 1.1
+++ openacs-4/packages/learning-content/tcl/learning-content-procs.xql 18 Aug 2011 23:18:57 -0000 1.2
@@ -175,7 +175,7 @@
where c.object_id = ci.item_id
and ci.parent_id = :wiki_folder_id
and ci.content_type not in ('::xowiki::PageTemplate')
- and ci.name not in ('es:header_page','es:index','es:indexe')
+ and ci.name not in ('en:header_page','en:index','en:indexe')
and r.revision_id = ci.live_revision
and p.page_id = r.revision_id
and c.category_id = :cat_id
@@ -238,6 +238,22 @@
+
+
+ select com.object_id
+ from category_object_map com $join_clause
+ where com.category_id = :category_id $where_clause
+
+
+
+
+
+ select com.object_id
+ from category_object_map com $join_clause
+ where com.category_id = :category_id $where_clause
+
+
+
select count(p.page_id)
Index: openacs-4/packages/learning-content/www/content-categories.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/www/content-categories.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/learning-content/www/content-categories.tcl 5 Mar 2009 21:28:59 -0000 1.1
+++ openacs-4/packages/learning-content/www/content-categories.tcl 18 Aug 2011 23:18:57 -0000 1.2
@@ -20,6 +20,16 @@
set tree_name [lindex [lindex $tree_list 0] 1]
set folder_id [$package_id folder_id]
set categories [learning_content::get_categories -tree_id $tree_id]
+set show_all_p f
+set admin_p [::xo::cc permission \
+ -object_id $package_id -privilege admin \
+ -party_id [::xo::cc user_id]]
+if {$admin_p} {
+ # get production_mode parameter
+ if {[parameter::get -package_id $package_id -parameter production_mode -default 0]} {
+ set show_all_p t
+ }
+}
set page_id [string trimleft $__including_page "::"]
@@ -54,17 +64,17 @@
set is_open_unit false
}
- set total [expr $total + [llength [category::get_objects \
- -category_id $category_id] ]]
+ set total [expr $total + [llength [learning_content::category::get_all_objects \
+ -category_id $category_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p] ]]
set subcategories [db_list get_childrens {*SQL*}]
foreach subcategory_id $subcategories {
- set total [expr $total + [llength [category::get_objects \
- -category_id $subcategory_id] ]]
+ set total [expr $total + [llength [learning_content::category::get_all_objects \
+ -category_id $subcategory_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p] ]]
set in_subcategories [category::get_children \
-category_id $subcategory_id]
foreach in_subcategory_id $in_subcategories {
- set total [expr $total + [llength [category::get_objects \
- -category_id $in_subcategory_id] ]]
+ set total [expr $total + [llength [learning_content::category::get_all_objects \
+ -category_id $in_subcategory_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p] ]]
}
}
@@ -84,8 +94,8 @@
set child_list \
[expr [category::count_children \
-category_id $subcategory_id] \
- + [llength [category::get_objects \
- -category_id $subcategory_id]]]
+ + [llength [learning_content::category::get_all_objects \
+ -category_id $subcategory_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p]]]
if { $child_list } {
if {$open_category_id == $subcategory_id || \
@@ -99,12 +109,12 @@
-category_id $subcategory_id]
set subtotal 0
set subtotal [expr $subtotal \
- + [llength [category::get_objects \
- -category_id $subcategory_id]]]
+ + [llength [learning_content::category::get_all_objects \
+ -category_id $subcategory_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p]]]
foreach in_subcategory_id $in_subcategories {
set subtotal [expr $subtotal \
- + [llength [category::get_objects \
- -category_id $in_subcategory_id]]]
+ + [llength [learning_content::category::get_all_objects \
+ -category_id $in_subcategory_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p]]]
}
if { $subtotal > 0 } {
@@ -118,8 +128,8 @@
set in_child_list [expr \
[category::count_children \
-category_id $in_subcategory_id] \
- + [llength [category::get_objects \
- -category_id $in_subcategory_id]]]
+ + [llength [learning_content::category::get_all_objects \
+ -category_id $in_subcategory_id -content_type "::xowiki::PageInstance" -show_all_p $show_all_p]]]
if { $in_child_list } {
if {$open_category_id == $in_subcategory_id } {
set is_sub_open true
Index: openacs-4/packages/learning-content/www/content-admin/change-category-state.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/www/content-admin/change-category-state.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/learning-content/www/content-admin/change-category-state.tcl 18 Aug 2011 23:18:57 -0000 1.1
@@ -0,0 +1,20 @@
+::xowiki::Package initialize -ad_doc {
+
+ @author byron Haroldo Linares Roman (bhlr@byronLs-Computer-2.local)
+ @creation-date 2008-02-08
+ @arch-tag: 2DB9A129-4B88-4E91-8686-8D47FCA678AF
+ @cvs-id $Id: change-category-state.tcl,v 1.1 2011/08/18 23:18:57 byronl Exp $
+} -parameter {
+ -folder_id
+ -tree_id
+ -category_id
+ -state
+}
+
+learning_content::category::set_category_publish_state \
+ -category_id $category_id \
+ -tree_id $tree_id \
+ -wiki_folder_id $folder_id \
+ -state $state
+
+ad_returnredirect "set-category-publish-state?action=$state"
\ No newline at end of file
Index: openacs-4/packages/learning-content/www/content-admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/www/content-admin/index.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/learning-content/www/content-admin/index.adp 5 Mar 2009 21:29:04 -0000 1.1
+++ openacs-4/packages/learning-content/www/content-admin/index.adp 18 Aug 2011 23:18:57 -0000 1.2
@@ -31,6 +31,7 @@
#learning-content.edit_title#
#learning-content.user_views#
+ #learning-content.unit_publish#
Index: openacs-4/packages/learning-content/www/content-admin/set-category-publish-state.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/www/content-admin/set-category-publish-state.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/learning-content/www/content-admin/set-category-publish-state.adp 18 Aug 2011 23:18:57 -0000 1.1
@@ -0,0 +1,6 @@
+
+ @title@
+
+#learning-content.go_back#
+@action_txt@
+
\ No newline at end of file
Index: openacs-4/packages/learning-content/www/content-admin/set-category-publish-state.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/learning-content/www/content-admin/set-category-publish-state.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/learning-content/www/content-admin/set-category-publish-state.tcl 18 Aug 2011 23:18:57 -0000 1.1
@@ -0,0 +1,77 @@
+::xowiki::Package initialize -ad_doc {
+ Changes the publication state of a content item
+ @author Byron Linares (bhlr@galileo.edu)
+ @creation-date Feb. 8, 2008
+
+} -parameter {
+ {-action ""}
+}
+
+set title [_ learning-content.unit_publish]
+set action_txt ""
+if {![empty_string_p $action]} {
+ if { $action == "ready" } {
+ set action [_ learning-content.published]
+ } else {
+ set action [_ learning-content.unpublished]
+ }
+ set action_txt "[_ learning-content.you_have_changed_unit_publish_state]"
+}
+set folder_id [::$package_id folder_id]
+
+category_tree::get_mapped_trees $package_id
+set tree_id [lindex [lindex [category_tree::get_mapped_trees $package_id] 0] 0]
+set tree_list [learning_content::category::get_tree_levels -to_level 1 -tree_id $tree_id]
+multirow create tree_state category_id category_name production ready state_url
+
+
+template::list::create \
+ -name tree_state \
+ -multirow tree_state \
+ -pass_properties {folder_id tree_id} \
+ -elements {
+ category_name {
+ label "[_ learning-content.unit_name]"
+ html "align center"
+ }
+ production {
+ label "[_ learning-content.unit_publish_state]"
+ display_template {[_ learning-content.published]( [_ learning-content.do_not_publish] )[_ learning-content.unpublished]( [_ learning-content.do_publish])}
+ link_html {title "[_ learning-content.change_state]"}
+ html {align center}
+ }
+ }
+
+foreach one_category $tree_list {
+ set category_id [lindex $one_category 0]
+ set sub_tree_list [learning_content::category::get_tree_levels -subtree_id $category_id -tree_id $tree_id]
+ set my_state 0
+ foreach sub_category $sub_tree_list {
+
+ if {$my_state} {
+ continue
+ }
+ set sub_category_id [lindex $sub_category 0]
+
+ set my_state [db_string select_state {
+ select count(ci.item_id)
+ from category_object_map c, cr_items ci, cr_revisions r, xowiki_page p
+ where c.object_id = ci.item_id and ci.parent_id = :folder_id
+ and ci.content_type not in ('::xowiki::PageTemplate')
+ and ci.name not in ('en:header_page','en:index','en:indexe')
+ and r.revision_id = ci.live_revision
+ and p.page_id = r.revision_id
+ and ci.publish_status = 'production'
+ and category_id = :sub_category_id} -default 0]
+ }
+
+ if { $my_state } {
+ set state_url [export_vars -base change-category-state {tree_id folder_id category_id {state ready}}]
+ } else {
+ set state_url [export_vars -base change-category-state {tree_id folder_id category_id {state production}}]
+ }
+
+ multirow append tree_state $category_id [lindex $one_category 1] "[expr !$my_state]" $my_state $state_url
+ set global_state 0
+
+}
\ No newline at end of file