Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/datamanager.info'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-callback-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,177 @@ +ad_library { + callback routines for faq package + @author Luis de la Fuente (lfuente@it.uc3m.es) + @creation_date 2005-07-08 +} + +ad_proc -public -callback datamanager::move_faq -impl datamanager { + -object_id:required + -selected_community:required +} { + Move a faq to another class or community +} { + + #db_1row get_faqs_package {} + set new_package_id [datamanager::get_faq_package_id -community_id $selected_community] + + + + db_transaction { + db_dml update_faqs_q_and_a {} + db_dml update_faqs {} + } on_error { + ad_return_error "Database error" "A database error occured:
$errmsg
" + } +} + +ad_proc -public -callback datamanager::delete_faq -impl datamanager { + -object_id:required + -selected_community:required +} { + Move a faq to the trash +} { + set trash_id [datamanager::get_trash_id] + set trash_package_id [datamanager::get_trash_package_id] + db_transaction { + db_dml del_update_faqs_q_and_a {} + db_dml del_update_faqs {} + } on_error { + ad_return_error "Database error" "A database error occured" + } +} + +ad_proc -public -callback datamanager::copy_faq -impl datamanager { + -object_id:required + -selected_community:required + -sufix:required +} { + Copy a faq to another class or community. Q&A are also copied +} { + + #get data about the faq + set package_id [datamanager::get_faq_package_id -community_id $selected_community] + db_1row get_faq_name {} + + set user_id [ad_conn user_id] + set creation_ip [ad_conn host] + set faq_id [faq::faq_new -package_id $package_id -faq_name "$faq_name$sufix" -separate_p $separate_p] + + #get list of Q&A (ids) + set q_a_list [db_list_of_lists get_q_a_list {}] + set q_a_number [llength $q_a_list] + + #for each Q&A, one entry + for {set i 0} {$i < $q_a_number} {incr i} { + + set one_question [lindex [lindex $q_a_list $i] 0] + set one_answer [lindex [lindex $q_a_list $i] 1] + set entry_id [db_nextval acs_object_id_seq] + set sort_key $entry_id + + db_transaction { + db_exec_plsql create_q_and_a { + begin + :1 := faq.new_q_and_a ( + entry_id => :entry_id, + context_id => :faq_id, + faq_id=> :faq_id, + question => :one_question, + answer => :one_answer, + sort_key => :sort_key, + creation_user => :user_id, + creation_ip => :creation_ip + ); + end; + } + } + } + return $faq_id +} + +ad_proc -public -callback datamanager::export_faq -impl datamanager { + -object_id:required +} { + Export a faq with Q&A +} { + set lista [list []] + db_1row select_faq {} + + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + db_multirow faq_q_and_ans faq_q_and_ans {} + template::multirow foreach faq_q_and_ans { + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + } + lappend lista "" + return $lista +} + +#Callbacks for application-track + +ad_proc -callback application-track::getApplicationName -impl faqs {} { + callback implementation + } { + return "faqs" + } + +ad_proc -callback application-track::getGeneralInfo -impl faqs {} { + callback implementation + } { + db_1row my_query { + select count(f.faq_id) as result + from faqs f, acs_objects o, dotlrn_communities com + where o.object_id=f.faq_id + and com.community_id=:comm_id + and apm_package__parent_id(o.context_id) = com.package_id + } + + return "$result" + } + +ad_proc -callback application-track::getSpecificInfo -impl faqs {} { + callback implementation + } { + + upvar $query_name my_query + upvar $elements_name my_elements + + set my_query { + select f.faq_name as name,f1.question as question,f1.answer as answer + from faqs f, acs_objects o, dotlrn_communities com,faq_q_and_as f1 + where o.object_id=f.faq_id + and com.community_id=:class_instance_id + and apm_package__parent_id(o.context_id) = com.package_id + and f.faq_id = f1.faq_id + } + + set my_elements { + name { + label "Name" + display_col name + html {align center} + + } + questions { + label "Questions" + display_col question + html {align center} + } + questions { + label "Answers" + display_col answer + html {align center} + } + + } + + return "OK" + } + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-callback-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-callback-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,112 @@ + + + + + + update acs_objects + set context_id = :new_package_id,package_id=:new_package_id + where object_id = :object_id + + + + + + update acs_objects + set package_id = :new_package_id + where context_id = :object_id + + + + + + + UPDATE acs_objects + SET context_id = :trash_package_id,package_id=:trash_package_id + WHERE object_id = :object_id + + + + + + UPDATE acs_objects + SET package_id = :trash_package_id + WHERE context_id = :object_id + + + + + + SELECT b.object_id as package_id + FROM acs_objects as a,acs_objects as b + WHERE a.context_id=:selected_community and a.object_type='apm_package' and a.object_id=b.context_id and b.title='FAQ'; + + + + + + SELECT faq_name,separate_p + FROM faqs + WHERE faq_id=:object_id; + + + + + + SELECT question, + answer + FROM faq_q_and_as + WHERE faq_id=:object_id; + + + + + + select faq__new_q_and_a ( + :entry_id, + :faq_id, + :one_question, + :one_answer, + :sort_key, + 'faq_q_and_a', + now(), + :user_id, + :creation_ip, + :faq_id + ); + + + +--SELECT FAQS + + + select f.faq_id, + f.faq_name, + f.separate_p, + f.disabled_p, + ao.creation_ip, + ao.context_id, + u.username as creation_user + from faqs f, + acs_objects ao, + users u + where f.faq_id = ao.object_id and + f.faq_id = :object_id and + ao.creation_user = u.user_id + + + +--SELECT FAQ_Q_AND_AS + + + select question, + answer + from faq_q_and_as + where faq_id = :faq_id + order by sort_key + + + + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,74 @@ +ad_library { + + Faq Library - Reply Handling + + @creation-date 2004-03-31 + @author Ben Adida + @Modifyed by Gerardo Morales +} + +namespace eval faq { + ad_proc -public get_package_id { + -community_id + } { + if {[info exist community_id]} { } else { set community_id [ad_conn community_id] } + + db_1row get_faqs_package {} + return $package_id + + } + + + ad_proc -public faq_new { + -package_id + {-separate_p "f"} + -faq_name:required + } { + if {[info exist package_id]} { } else { set package_id [ad_conn package_id] } + set faq_id [db_nextval acs_object_id_seq] + set user_id [ad_conn user_id] + set creation_ip [ad_conn host] + + db_transaction { + db_exec_plsql create_faq { + begin + :1 := faq.new_faq ( + faq_id => :faq_id, + faq_name => :faq_name, + separate_p => :separate_p, + creation_user => :user_id, + creation_ip => :creation_ip, + context_id => :package_id + ); + end; + } + } + + return $faq_id + + } + + +} + + + +namespace eval faq::notification { + + ad_proc -public get_url { + object_id + } { + returns a full url to the object_id. + handles messages and forums. + } { + + set q_and_a_id $object_id + db_1row get_faq_id "*SQL*" + set faq_url "[ad_url][ad_conn package_url]" + return ${faq_url}one-faq?faq_id=$faq_id + + } +} + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/faq-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,36 @@ + + + + + + select faq_id from faq_q_and_as + where entry_id = $q_and_a_id + + + + + + SELECT package_id + FROM dotlrn_community_applets + WHERE community_id = :community_id and applet_id = (select applet_id from dotlrn_applets where applet_key = 'dotlrn_faq') + + + + + + select faq__new_faq (:faq_id, :faq_name,:separate_p,'faq', now(), :user_id,:creation_ip,:package_id); + + + + + + + + + + + + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-callback-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,211 @@ +# packages/file-storage/tcl/file-storage-callback-procs.tcl + +ad_library { + + Callback procs for file storage + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-15 + @arch-tag: 921a2c2a-5593-495b-9a60-9d815d80a39d + @cvs-id $Id: file-storage-callback-procs.tcl,v 1.1 2006/06/22 14:21:34 darior Exp $ +} + +namespace eval fs::folder_chunk {} + +ad_proc -public -callback fs::folder_chunk::add_bulk_actions { + {-bulk_variable:required} + {-folder_id:required} + {-var_export_list:required} +} { +} + +ad_proc -public -callback fs::file_delete { + {-package_id:required} + {-file_id:required} +} { +} + +ad_proc -public -callback fs::file_new { + {-package_id:required} + {-file_id:required} +} { +} + +ad_proc -public -callback fs::file_revision_new { + {-package_id:required} + {-file_id:required} + {-parent_id:required} +} { +} + +ad_proc -public -callback datamanager::move_folder -impl datamanager { + -object_id:required + -selected_community:required +} { + Move a folder to another class or community +} { + +#get the working package +db_1row get_working_package {} +set root_folder_id [fs::get_root_folder -package_id $package_id] + +#update forums_forums table + db_transaction { + db_dml update_cr_items {} + db_dml update_acs_objects {} + } +} + +ad_proc -public -callback datamanager::delete_folder -impl datamanager { + -object_id:required +} { + Move a folder to the trash +} { + +#get the trash_id +set trash_id [datamanager::get_trash_id] + + db_transaction { + #update forums_forums table + db_dml del_update_cr_items {} + db_dml del_update_acs_objects {} + } +} + + + +ad_proc -public -callback datamanager::copy_folder -impl datamanager { + -object_id:required + -selected_community:required + {-mode: "both"} +} { + Copy a folder to another class or community +} { +#get the destiny's root folder + set parent_id [dotlrn_fs::get_community_root_folder -community_id $selected_community] + set new_folder_id [fs_folder_copy -old_folder_id $object_id -new_parent_id $parent_id -mode $mode] + return $new_folder_id + +} + +ad_proc -public -callback fs::folder_new { + {-package_id:required} + {-folder_id:required} +} { +} + +ad_proc -public -callback pm::project_new -impl file_storage { + {-package_id:required} + {-project_id:required} +} { + create a new folder for each new project +} { + set pm_name [pm::project::name -project_item_id $project_id] + + foreach fs_package_id [application_link::get_linked -from_package_id $package_id -to_package_key "file-storage"] { + set root_folder_id [fs::get_root_folder -package_id $fs_package_id] + + set folder_id [fs::new_folder \ + -name $root_folder_id \ + -pretty_name $pm_name \ + -parent_id $root_folder_id \ + -no_callback] + + application_data_link::new -this_object_id $project_id -target_object_id $folder_id + } +} + +#Callbacks for application-track + +ad_proc -callback application-track::getApplicationName -impl file_storage {} { + callback implementation + } { + return "file_storage" + } + + ad_proc -callback application-track::getGeneralInfo -impl file_storage {} { + callback implementation + } { + + db_1row my_query { + select count(1) as result + from acs_objects a, acs_objects b + where b.object_id = :comm_id + and a.tree_sortkey between b.tree_sortkey + and tree_right(b.tree_sortkey) + and a.object_type = 'file_storage_object' + } + + + return "$result" + } + + + ad_proc -callback application-track::getSpecificInfo -impl file_storage {} { + callback implementation + } { + + upvar $query_name my_query + upvar $elements_name my_elements + + + set my_query { + + SELECT f.name as name, f.file_id, f.type as type, f.content_size as size, + fo.name as folder_name, + to_char(f.last_modified, 'YYYY-MM-DD HH24:MI:SS') as last_modified, + to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date, + (select site_node__url(site_nodes.node_id) + from site_nodes, acs_objects + where site_nodes.object_id = file_storage__get_package_id(f.parent_id) and acs_objects.object_id = f.file_id) as url, + com.community_id as class_id + FROM fs_files f,fs_folders fo,dotlrn_communities_full com,acs_objects o, acs_objects o2 + WHERE f.file_id = o.object_id + and com.community_id=:class_instance_id + and o2.object_id= file_storage__get_package_id(f.parent_id) + and o2.context_id=com.package_id + and fo.folder_id = f.parent_id + + } + + + set my_elements { + name { + label "Name" + display_col name + html {align center} + + } + type { + label "Type" + display_col type + html {align center} + + } + folder { + label "Folder" + display_col folder_name + html {align center} + } + size { + label "Size (bytes)" + display_col size + html {align center} + + } + last_modification_date { + label "Last_Modification_Date" + display_col last_modified + html {align center} + } + post_date { + label "Post_Date" + display_col creation_date + html {align center} + + } + + } + + + } Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-callback-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-callback-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,47 @@ + + + + + + select package_id + from dotlrn_community_applets + where applet_id=(select applet_id from dotlrn_applets where applet_key='dotlrn_fs') and community_id=:selected_community; + + + + + + update cr_items + set parent_id=:root_folder_id + where item_id=:object_id + + + + + + + update acs_objects + set context_id =:root_folder_id + where object_id=:object_id + + + + + + update cr_items + set parent_id=:trash_id + where item_id=:object_id + + + + + + + update acs_objects + set context_id =:trash_id + where object_id=:object_id + + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-copy-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-copy-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-copy-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,103 @@ +ad_library { + TCL library for the file-storage system (v.4) + + @author Luis de la Fuente (lfuente@it.uc3m.es) + @creation-date 16 September 2005 +} + +ad_proc fs_folder_copy { + {-old_folder_id:required} + {-new_parent_id:required} + {-also_subfolders_p "t"} + {-also_files_p "t"} + {-mode: "both"} +} { + Copy a folder and its subfolders and files, if selected. +} { + + switch $mode { + "empty" { + set also_subfolders_p "f" + set also_files_p "f" + } + "files" { + set also_subfolders_p "f" + set also_files_p "t" + } + "subfolders" { + set also_subfolders_p "t" + set also_files_p "f" + } + "both" { + set also_subfolders_p "t" + set also_files_p "t" + } + } + + set item_id -1 + #get data + db_1row get_folder_data {} + + # First of all we have to check that don't exists a folder with the same name and parent_id + set exist_folder [db_0or1row get_folder "select folder_id from fs_folders where parent_id = :new_parent_id and name = :name"] + + if {$exist_folder == 0} { + #If folder don't exists we create it + set new_folder_id [fs::new_folder -name $pretty_name\ + -pretty_name $name -parent_id $new_parent_id -creation_user $creation_user -creation_ip $creation_ip -description $description] + } else { + # If folder exists we reuse it + set new_folder_id $folder_id + } + #copy containing files + if {$also_files_p=="t"} { + #get files list + set file_list [db_list_of_lists get_file_list {}] + set file_number [llength $file_list] + + #copy them + for {set i 0} {$i < $file_number} {incr i} { + + # Question - do we copy revisions or not? + # Current Answer - we copy the live revision only + set file_id [lindex [lindex $file_list $i] 0] + db_1row get_file_name "select name as file_name from fs_files where file_id = :file_id" + set user_id [lindex [lindex $file_list $i] 1] + set ip_address [lindex [lindex $file_list $i] 2] + + + # Now, we have to check that don't exist a file with the same name and parent_id + # set old_file_id $file_id + # set exist_file [db_0or1row get_file "select * from fs_files where parent_id = :new_folder_id and name = :file_name"] + + ######### NEW VERSION + set creation_user [ad_conn user_id] + set creation_ip [ns_info address] + set version "datamanager" + db_transaction { + set rdo [db_exec_plsql file_copy {}] + } + ######### FIN NEW VERSION + } + } + +#while there are more subfolders... + if {$also_subfolders_p=="t"} { + + set subfolders_list [db_list get_subfolders_list {}] + set subfolders_number [llength $subfolders_list] + + for {set i 0} {$i < $subfolders_number} {incr i} { + + set object_id [lindex $subfolders_list $i] + + fs_folder_copy -old_folder_id $object_id -new_parent_id $new_folder_id + } + + } + + return $new_folder_id + } + + +#} Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-copy-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-copy-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/file-storage-copy-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,115 @@ + + + + + + SELECT fsf.name, + fsf.key as pretty_name, + fsf.parent_id, + ao.creation_user, + ao.creation_ip, + crf.description + FROM fs_folders as fsf, + acs_objects as ao, + cr_folders as crf + WHERE ao.object_id=:old_folder_id and crf.folder_id=ao.object_id and fsf.folder_id=ao.object_id + + + + + + SELECT folder_id as subfolders_list + FROM fs_folders + WHERE parent_id= :old_folder_id + + + + + + + SELECT ao.object_id, + ao.creation_user, + ao.creation_ip + FROM acs_objects as ao, fs_files as fsf + WHERE ao.context_id=:old_folder_id and fsf.file_id=ao.object_id + + + + + + select file_storage__copy_file ( + :file_id, -- file_id + :new_folder_id, -- taget_folder_id + :creation_user, -- creation_user + :creation_ip, -- creation_ip + :version -- nothing + ) + + + + + + select file_storage__new_version ( + :file_name, -- file_name + :description, -- file_description + :mime_type, -- file_mime_type + :item_id, -- item_id + :creation_user, -- creation_user + :creation_ip -- creation_ip + ) + + + + + + + select content_revision__new ( + :file_name, -- title + :description, -- description + now(), -- publish_date + :mime_type, -- mime_type + null, -- nls_language + :data, -- data (default) + :file_id, -- item_id + null, -- revision_id + now(), -- creation_date + :creation_user, -- creation_user + :creation_ip, -- creation_ip + :content_length --new__content_length + ) + + + + + + select content_revision__get_content ( + :revision_id -- revision_id + ) + + + + + + select content_item__set_live_revision ( + :revision_id -- revision_id + ) + + + + + + select acs_object__update_last_modified ( + :new_folder_or_revision_id, -- new folder or revision_id + :creation_user, -- creation_user + :creation_ip -- creation_ip + ) + + + + + + UPDATE cr_revisions SET content_length = :content_length where revision_id = :v_revision_id + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/forums-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/forums-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/forums-callback-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,416 @@ +ad_library { +} + +ad_proc -public -callback navigation::package_admin -impl forums {} { + return the admin actions for the forum package. +} { + set actions {} + + # Check for admin on the package... + if {[permission::permission_p -object_id $package_id -privilege admin -party_id $user_id]} { + lappend actions [list LINK admin/ [_ acs-kernel.common_Administration] {} [_ forums.Admin_for_all]] + + lappend actions [list LINK \ + [export_vars -base admin/permissions {{object_id $package_id}}] \ + [_ acs-kernel.common_Permissions] {} [_ forums.Permissions_for_all]] + lappend actions [list LINK admin/forum-new [_ forums.Create_a_New_Forum] {} {}] + } + + # check for admin on the individual forums. + db_foreach forums { + select forum_id, name, enabled_p + from forums_forums + where package_id = :package_id + and exists (select 1 from acs_object_party_privilege_map pm + where pm.object_id = forum_id + and pm.party_id = :user_id + and pm.privilege = 'admin') + } { + lappend actions [list SECTION "Forum $name ([ad_decode $enabled_p t [_ forums.enabled] [_ forums.disabled]])" {}] + + lappend actions [list LINK [export_vars -base admin/forum-edit forum_id] \ + [_ forums.Edit_forum_name] {} {}] + lappend actions [list LINK [export_vars -base admin/permissions {{object_id $forum_id} return_url}] \ + [_ forums.Permission_forum_name] {} {}] + } + return $actions +} + + +ad_proc -callback merge::MergeShowUserInfo -impl forums { + -user_id:required +} { + Merge the *forums* of two users. + The from_user_id is the user_id of the user + that will be deleted and all the *forums* + of this user will be mapped to the to_user_id. + +} { + set msg "Forums items of $user_id" + set result [list $msg] + + set last_poster [db_list_of_lists sel_poster {*SQL*} ] + set msg "Last Poster of $last_poster" + lappend result $msg + + set poster [db_list_of_lists sel_user_id {*SQL*} ] + set msg "Poster of $poster" + lappend result $msg + + return $result +} + +ad_proc -callback merge::MergePackageUser -impl forums { + -from_user_id:required + -to_user_id:required +} { + Merge the *forums* of two users. + The from_user_id is the user_id of the user + that will be deleted and all the *forums* + of this user will be mapped to the to_user_id. + +} { + set msg "Merging forums" + set result [list $msg] + + db_dml upd_poster { *SQL* } + db_dml upd_user_id { *SQL* } + + lappend result "Merge of forums is done" + + return $result +} + +ad_proc -public -callback datamanager::move_forum -impl datamanager { + -object_id:required + -selected_community:required +} { + Move a forum to another class or community +} { + + #get the new_package_id + set new_package_id [datamanager::get_forum_package_id -community_id $selected_community] + + #update forums_forums table + db_dml update_forums {} + #update acs_objects table (because data redundancy) + db_dml update_forums_acs_objects {} +} + +ad_proc -public -callback datamanager::delete_forum -impl datamanager { + -object_id:required +} { + Move a forum to the trash +} { + + #get trash_id + set trash_package_id [datamanager::get_trash_package_id] + + #update forums_forums table + db_dml del_update_forums {} + #update acs_objects table (because data redundancy) + db_dml del_update_forums_acs_objects {} +} + +ad_proc -public -callback datamanager::copy_forum -impl datamanager { + -object_id:required + -selected_community:required + -sufix:required +} { + Copy a forum to another class or community +} { + #get forum's data + set forum_id [db_nextval acs_object_id_seq] + set package_id [datamanager::get_forum_package_id -community_id $selected_community] + db_1row get_forum_data {} + + set newname "$name$sufix" + #create the new forums + set forum_id [forum::new -forum_id $forum_id \ + -name $newname \ + -charter $charter \ + -presentation_type $presentation_type \ + -posting_policy $posting_policy \ + -package_id $package_id \ + ] + + set first_messages_list [db_list_of_lists get_first_messages_list {}] + set first_messages_number [llength $first_messages_list] + + for {set i 0} {$i < $first_messages_number} {incr i} { + set message_id [db_nextval acs_object_id_seq] + set subject [lindex [lindex $first_messages_list $i] 0] + set content [lindex [lindex $first_messages_list $i] 1] + set user_id [lindex [lindex $first_messages_list $i] 2] + set formato [lindex [lindex $first_messages_list $i] 3] + set parent_id [lindex [lindex $first_messages_list $i] 4] + + set message_id [forum::message::new \ + -forum_id $forum_id \ + -message_id $message_id \ + -parent_id $parent_id \ + -subject $subject \ + -content $content \ + -format $formato \ + -user_id $user_id \ + ] + set all_messages_list [db_list_of_lists get_all_messages_list {}] + set all_messages_number [llength $all_messages_list] + + for {set i 0} {$i < $all_messages_number} {incr i} { + set message_id [db_nextval acs_object_id_seq] + set subject [lindex [lindex $all_messages_list $i] 0] + set content [lindex [lindex $all_messages_list $i] 1] + set user_id [lindex [lindex $all_messages_list $i] 2] + set formato [lindex [lindex $all_messages_list $i] 3] + set parent_id [lindex [lindex $all_messages_list $i] 4] + set message_id [forum::message::new \ + -forum_id $forum_id \ + -message_id $message_id \ + -parent_id $parent_id \ + -subject $subject \ + -content $content \ + -format $formato \ + -user_id $user_id \ + ] + } + } +} + +ad_proc -public -callback datamanager::copy_forums -impl datamanager { + -object_id:required + -selected_community:required + -sufix:required +} { + Copy a forum to another class or community +} { + #get forum's data + set package_id [datamanager::get_forum_package_id -community_id $selected_community] + + db_1row get_forum_data {} + # modified to not creating lost of testing forums + set forum_exist [db_string get_forum_num "select forum_id from forums_forums where name=:name and package_id=:package_id limit 1" -default 0] + + if {$forum_exist > 0} { + set new_forum_id $forum_exist + } else { + set new_forum_id [db_nextval acs_object_id_seq] + set newname "$name$sufix" + #create the new forums + set new_forum_id [forum::new -forum_id $new_forum_id \ + -name $newname \ + -charter $charter \ + -presentation_type $presentation_type \ + -posting_policy $posting_policy \ + -package_id $package_id \ + ] + } + + set l_msg [db_list_of_lists get_all_messages {}] + + ############################ + # UPDATE PROCESS --> message_id and parent_id + set l_msg2 $l_msg + set c 0 + + foreach msg $l_msg2 { + set index [lindex $msg 0] + set parent [lindex $msg 1] + #cogemos todos los datos y creamos el nuevo mensaje + set new_idx [forum::message::new \ + -forum_id $new_forum_id \ + -parent_id [lindex [lindex $l_msg2 $c] 1] \ + -subject [lindex [lindex $l_msg2 $c] 2] \ + -content [lindex [lindex $l_msg2 $c] 3] \ + -format [lindex [lindex $l_msg2 $c] 7] \ + -user_id [lindex [lindex $l_msg2 $c] 4]] + + # Update posting data and last_child_post + set p_date [lindex [lindex $l_msg2 $c] 5] + set lc_post [lindex [lindex $l_msg2 $c] 6] + db_dml update_pdates "update forums_messages set posting_date = :p_date , last_child_post = :lc_post where message_id = :new_idx" + + set cont 0 + foreach orig $l_msg { + if {[lindex $orig 1] == $index} { + set aux [lreplace $orig 1 1 $new_idx] + set l_msg2 [lreplace $l_msg2 $cont $cont $aux] + + } + incr cont +1 + } + set kk [lindex $l_msg2 $c] + set kk [lreplace $kk 0 0 $new_idx] + set l_msg2 [lreplace $l_msg2 $c $c $kk] + + incr c +1 + } + } + +ad_proc -public -callback datamanager::export_forum -impl datamanager { + -object_id:required +} { + Export a forum +} { + set lista [list []] + db_1row select_forum {} + + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + + set forum_id $object_id + set first_messages_list [db_list_of_lists get_first_messages_list {}] + set first_messages_number [llength $first_messages_list] + + for {set i 0} {$i < $first_messages_number} {incr i} { + lappend lista "" + + set subject [lindex [lindex $first_messages_list $i] 0] + set content [lindex [lindex $first_messages_list $i] 1] + set username [lindex [lindex $first_messages_list $i] 2] + set format [lindex [lindex $first_messages_list $i] 3] + set parent_id [lindex [lindex $first_messages_list $i] 4] + set message_id [lindex [lindex $first_messages_list $i] 5] + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + + set hijos_messages_list [db_list_of_lists get_hijos_messages_list {}] + set hijos_messages_number [llength $hijos_messages_list] + for {set j 0} {$j < $hijos_messages_number} {incr j} { + lappend lista "" + set subject [lindex [lindex $hijos_messages_list $j] 0] + set content [lindex [lindex $hijos_messages_list $j] 1] + set username [lindex [lindex $hijos_messages_list $j] 2] + set format [lindex [lindex $hijos_messages_list $j] 3] + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + } + + lappend lista "" + } + lappend lista "" + return $lista +} + +# created by fransola --> other algorithm to treat forums +ad_proc -public -callback datamanager::export_forums -impl datamanager { + -object_id:required +} { + Export a forum +} { + set lista [list []] + db_1row select_forums {} + + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + + set forum_id $object_id + set l_messages [db_list_of_lists get_all_messages {}] + set l_messages_number [llength $l_messages] + + for {set i 0} {$i < $l_messages_number} {incr i} { + lappend lista "" + # message_id, parent_id, subject, content, username, posting_date, last_child_post, format + set message_id [lindex [lindex $l_messages $i] 0] + set parent_id [lindex [lindex $l_messages $i] 1] + set subject [lindex [lindex $l_messages $i] 2] + set content [lindex [lindex $l_messages $i] 3] + set username [lindex [lindex $l_messages $i] 4] + set posting_date [lindex [lindex $l_messages $i] 5] + set last_child_post [lindex [lindex $l_messages $i] 6] + set format [lindex [lindex $l_messages $i] 7] + + + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + } + lappend lista "" + return $lista +} + + +#Callbacks for application-track + +ad_proc -callback application-track::getApplicationName -impl forums {} { + callback implementation + } { + return "forums" + } + +ad_proc -callback application-track::getGeneralInfo -impl forums {} { + callback implementation + } { + db_1row my_query { + select count(f.forum_id) as result + FROM forums_forums f, dotlrn_communities_full com + WHERE com.community_id=:comm_id + and apm_package__parent_id(f.package_id) = com.package_id + } + + return "$result" + } + +ad_proc -callback application-track::getSpecificInfo -impl forums {} { + callback implementation + } { + + upvar $query_name my_query + upvar $elements_name my_elements + + set my_query { + SELECT f.name as name,f.thread_count as threads, + f.last_post, + to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date + FROM forums_forums f,dotlrn_communities_full com,acs_objects o + WHERE com.community_id=:class_instance_id + and f.forum_id = o.object_id + and apm_package__parent_id(f.package_id) = com.package_id + } + + set my_elements { + name { + label "Name" + display_col name + html {align center} + + } + threads { + label "Threads" + display_col threads + html {align center} + } + creation_date { + label "creation_date" + display_col creation_date + html {align center} + } + last_post { + label "last_post" + display_col last_post + html {align center} + } + + + } + + return "OK" + } + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/forums-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/forums-callback-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/forums-callback-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,222 @@ + + + + + + update forums_messages + set last_poster = :to_user_id + where last_poster = :from_user_id + + + + + + update forums_messages + set user_id = :to_user_id + where user_id = :from_user_id + + + + + + select message_id, subject + from forums_messages + where user_id = :user_id + + + + + + select message_id, subject + from forums_messages + where last_poster = :user_id + + + + + + update forums_forums + set package_id = :new_package_id + where forum_id = :object_id + + + + + + update forums_forums + set package_id = :trash_package_id + where forum_id = :object_id + + + + + + + + update acs_objects + set package_id = :new_package_id, + context_id = :new_package_id + where object_id = :object_id + + + + + + +update acs_objects +set package_id = :trash_package_id, + context_id = :trash_package_id +where object_id = :object_id + + + + + + SELECT name,charter,presentation_type,posting_policy + FROM forums_forums + WHERE forum_id=:object_id; + + + + + + SELECT name,charter,presentation_type,posting_policy + FROM forums_forums + WHERE forum_id=:object_id; + + + + + + SELECT subject, + content, + user_id, + format as formato, + parent_id + FROM forums_messages + WHERE forum_id=:object_id and + parent_id IS NULL; + + + + + + SELECT subject, + content, + user_id, + format as formato, + parent_id + FROM forums_messages + WHERE forum_id=:object_id and + parent_id IS NOT NULL; + + + + + + + SELECT subject, + content, + username, + format, + parent_id, + message_id + FROM forums_messages fm, + users u + WHERE forum_id=:object_id and + parent_id IS NULL and + fm.user_id = u.user_id; + + + + + + SELECT subject, + content, + user_id, + format, + parent_id, + message_id + FROM forums_messages + WHERE forum_id=:object_id and + parent_id IS NOT NULL; + + + + + + SELECT subject, + content, + username, + format, + parent_id, + message_id + FROM forums_messages fm, + users u + WHERE forum_id = :object_id and + parent_id = :message_id and + fm.user_id = u.user_id; + + + + + + SELECT fo.name as name, + ao.object_id, + us1.username as creation_user, + to_char(ao.creation_date,'YYYY-MM-DD HH:MM:SS') as creation_date, + fo.charter, + fo.presentation_type, + fo.posting_policy, + fo.enabled_p, + fo.thread_count, + fo.approved_thread_count, + fo.forums_forums, + fo.last_post, + fo.autosubscribe_p + FROM acs_objects as ao, + users as us1, + forums_forums as fo + WHERE + us1.user_id = ao.creation_user and + ao.object_id = :object_id and + fo.forum_id = ao.object_id + ORDER BY name, ao.creation_date + + + + + + + SELECT + name, charter, presentation_type, posting_policy + FROM + forums_forums + WHERE + forum_id = :object_id + + + + + + SELECT message_id, parent_id, subject, content, user_id, posting_date, last_child_post, format + FROM forums_messages fm + WHERE forum_id = :object_id + ORDER BY posting_date + + + + + + + SELECT + message_id, parent_id, subject, content, username, posting_date, last_child_post, format + FROM forums_messages fm, + users u + WHERE forum_id = :object_id and + fm.user_id = u.user_id + ORDER BY posting_date + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-callback-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,140 @@ +ad_library { + callback routines for faq package + @author Luis de la Fuente (lfuente@it.uc3m.es) + @creation_date 2005-07-08 +} + + +ad_proc -public -callback datamanager::copy_new -impl datamanager { + -object_id:required + -selected_community:required + -sufix $sufix +} { + Copy a new to another class or community +} { +#get environment data + set package_id [news_get_package_id -community_id $selected_community] + +#get the revision's data + + set news_revisions_list [db_list_of_lists get_news_revisions_data {}] + set news_revisions_number [llength $news_revisions_list] +#do the first revision + set present_object_id [lindex [lindex $news_revisions_list 0] 0] + db_1row get_news_data {} + set publish_date_ansi [lindex [lindex $news_revisions_list 0] 1] + set publish_body [lindex [lindex $news_revisions_list 0] 2] + set mime_type [lindex [lindex $news_revisions_list 0] 3] + set publish_title [lindex [lindex $news_revisions_list 0] 4] + + + set live_revision_p "t" + append publish_title "_" $sufix +#create the new + set news_id [news_create_new -publish_body $publish_body \ + -publish_title $publish_title \ + -publish_date_ansi $publish_date_ansi \ + -mime_type $mime_type \ + -package_id $package_id \ + -archive_date_ansi $archive_date_ansi \ + -approval_user $approval_user \ + -approval_date $approval_date \ + -approval_ip $approval_ip \ + -creation_ip $creation_ip \ + -user_id $user_id \ + -live_revision_p $live_revision_p ] + + + + +#if there are revisions, they are included here + for {set i 1} {$i < $news_revisions_number} {incr i} { + + set present_object_id [lindex [lindex $news_revisions_list $i] 0] + db_1row get_news_data {} + db_1row get_present_new_item {} + + set publish_date_ansi [lindex [lindex $news_revisions_list $i] 1] + set publish_body [lindex [lindex $news_revisions_list $i] 2] + set mime_type [lindex [lindex $news_revisions_list $i] 3] + set publish_title [lindex [lindex $news_revisions_list $i] 4] + append publish_title "_" $sufix + set revision_log [lindex [lindex $news_revisions_list $i] 5] +# db_1row get_live_revision {} +# if {$live_revision == $present_object_id} { +# set active_revision_p "t" +# } else { +# set active_revision_p "f" +# } +set active_revision_p "t" + + db_exec_plsql create_news_item_revision {} + } +#does the new includes images? + + +return $news_id +} + + + +ad_proc -public -callback datamanager::export_new -impl datamanager { + -object_id:required +} { + Export a new +} { + + + + #get environment data + #set package_id [news_get_package_id -community_id $selected_community] + + #get the revision + db_0or1row get_live_revision {* SQL *} + if {$live_revision > 0} { + + set lista [list []] + set object_id $live_revision + + + lappend lista "" + db_1row get_news_revisions_data {* SQL *} + db_1row get_news_data {* SQL *} + + + set user_id $approval_user + set ctrl [db_0or1row get_username {* SQL *}] + if {$ctrl ne 0} { + set approval_user $username + } else { + set approval_user "" + } + + set user_id $creation_user + set ctrl [db_0or1row get_username {* SQL *}] + if {$ctrl ne 0} { + set creation_user $username + } else { + set creation_user "" + } + + + + set live_revision_p "t" + + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + + lappend lista "" + return $lista + } +} Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-callback-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-callback-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,144 @@ + + + + + + + SELECT a.archive_date as archive_date_ansi, + a.approval_user, + a.approval_date, + a.approval_ip, + b.creation_user as user_id, + b.creation_ip, + b.creation_date + FROM cr_news as a, acs_objects as b + WHERE a.news_id=:present_object_id and b.object_id=:present_object_id + + + + + +SELECT context_id as new_item_id +FROM acs_objects +WHERE object_id=:news_id + + + + + +SELECT a.live_revision +FROM cr_items as a, + acs_objects as b +WHERE b.object_id=:present_object_id and a.item_id=b.context_id + + + + + + +SELECT a.revision_id, + a.publish_date, + a.content as publish_body, + a.mime_type, + a.title as publish_title, + a.description as revision_log +FROM cr_revisions as a,cr_revisions as b +WHERE b.revision_id=:object_id and b.item_id=a.item_id +ORDER BY a.revision_id + + + + + + + select news__new( + null, -- p_item_id + null, -- p_locale + :publish_date_ansi, -- p_publish_date + :publish_body, -- p_text + null, -- p_nls_language + :publish_title, -- p_title + :mime_type, -- p_mime_type + :package_id, -- p_package_id + :archive_date_ansi, -- p_archive_date + :approval_user, -- p_approval_user + :approval_date, -- p_approval_date + :approval_ip, -- p_approval_ip + null, -- p_relation_tag + :creation_ip, -- p_creation_ip + :user_id, -- p_creation_user + :live_revision_p -- p_is_live_p + ); + + + + + + + select news__revision_new( + :new_item_id, -- p_item_id + :publish_date_ansi, -- p_publish_date + :publish_body, -- p_text + :publish_title, -- p_title + :revision_log, -- p_description + :mime_type, -- p_mime_type + :package_id, -- p_package_id + :archive_date_ansi, -- p_archive_date + :approval_user, -- p_approval_user + :approval_date, -- p_approval_date + :approval_ip, -- p_approval_ip + current_timestamp, -- p_creation_date + :creation_ip, -- p_creation_ip + :user_id, -- p_creation_user + :active_revision_p -- p_make_active_revision_p + ); + + + + + + SELECT a.live_revision + FROM cr_items as a, + acs_objects as b + WHERE b.object_id=:object_id and a.item_id=b.context_id + + + + + + +SELECT a.revision_id, + a.publish_date, + a.content as publish_body, + a.mime_type, + a.title as publish_title, + a.description as revision_log +FROM cr_revisions a +WHERE a.revision_id=:object_id + + + + + + + SELECT a.archive_date as archive_date_ansi, + a.approval_user, + a.approval_date, + a.approval_ip, + b.creation_user, + b.creation_ip, + b.creation_date + FROM cr_news as a, acs_objects as b + WHERE a.news_id=:object_id and b.object_id=:object_id + + + + + + SELECT username FROM acs_users_all + WHERE user_id = :user_id + + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,333 @@ +# /packages/news/tcl/news-procs.tcl + +ad_library { + + Utility functions for News Application + + @author stefan@arsdigita.com + @creation-date 12-14-00 + @cvs-id $Id: news-procs.tcl,v 1.1 2006/06/22 14:21:34 darior Exp $ +} + + +# News specific db-API wrapper functions and interpreters + +ad_proc news_items_archive { id_list when } { + + immediately gives all news items in list id_list + a status of archived as of ANSI date in when, i.e. when must be like 2000-10-11. + +} { + + foreach id $id_list { + db_exec_plsql news_item_archive { + begin + news.archive( + item_id => :id, + archive_date => :when); + end; + } + } + +} + + +ad_proc news_items_make_permanent { id_list } { + + immediately gives all news items in list id_list + a status of permanently published + +} { + + foreach id $id_list { + db_exec_plsql news_item_make_permanent { + begin + news.make_permanent(:id); + end; + } + } + +} + + +ad_proc news_items_delete { id_list } { + + deletes all news items with news_id in id_list + +} { + + foreach id $id_list { + db_exec_plsql news_item_delete { + begin + news.del(:id); + end; + } + } + +} + + +ad_proc news_util_get_url { + package_id +} { + @author Robert Locke +} { + + set url_stub "" + + db_0or1row get_url_stub " + select site_node__url(node_id) as url_stub + from site_nodes + where object_id=:package_id + " + + return $url_stub + +} + + +ad_proc news__datasource { + object_id +} { + We currently use the default content repository + datasource proc. + @author Robert Locke +} { + + return [content_search__datasource $object_id] + +} + + +ad_proc news__url { + object_id +} { + @author Robert Locke +} { + + set package_id [db_string get_package_id {}] + set url_stub [news_util_get_url $package_id] + + db_1row get_item_id " + select item_id + from cr_revisions + where revision_id=:object_id + " + + set url "${url_stub}item?item_id=$item_id" + + return $url +} + +ad_proc news_pretty_status { + {-publish_date:required} + {-archive_date:required} + {-status:required} +} { + Given the publish status of a news items return a localization human readable + sentence for the status. + + @param status Publish status short name. Valid values are returned + by the plsql function news_status. + + @author Peter Marklund +} { + array set news_status_keys { + unapproved news.Unapproved + going_live_no_archive news.going_live_no_archive + going_live_with_archive news.going_live_with_archive + published_no_archive news.published_no_archive + published_with_archive news.published_scheduled_for_archive + archived news.Archived + } + + set now_seconds [clock scan now] + set n_days_until_archive {} + + if { ![empty_string_p $archive_date] } { + set archive_date_seconds [clock scan $archive_date] + + if { $archive_date_seconds > $now_seconds } { + # Scheduled for archive + set n_days_until_archive [expr ($archive_date_seconds - $now_seconds) / 86400] + } + } + + if { ![empty_string_p $publish_date] } { + # The item has been published or is scheduled to be published + + set publish_date_seconds [clock scan $publish_date] + if { $publish_date_seconds > $now_seconds } { + # Will be published in the future + + set n_days_until_publish [expr ($publish_date_seconds - $now_seconds) / 86400] + } + } + + # Message lookup may use vars n_days_until_archive and n_days_until_publis + return [_ $news_status_keys($status)] +} + +ad_proc -public news__last_updated { + package_id +} { + + Return the timestamp of the most recent item in this news instance + + @author Dave Bauer (dave@thedesignexperience.org) + @creation-date 2005-01-22 + + @param package_id + + @return + + @error +} { + return [db_string get_last_updated ""] +} + +ad_proc -private news__rss_datasource { + summary_context_id +} { + This procedure implements the "datasource" operation of the + RssGenerationSubscriber service contract. + + @author Dave Bauer (dave@thedesignexperience.org) +} { + # TODO make limit a parameter + set limit 15 + + set items [list] + set counter 0 + set package_url [news_util_get_url $summary_context_id] + db_foreach get_news_items {} { + set entry_url [export_vars -base "[ad_url]${package_url}item" {item_id}] + + set content_as_text [ad_html_text_convert -from $mime_type -to text/plain $content] + # for now, support only full content in feed + set description $content_as_text + + # Always convert timestamp to GMT + set entry_date_ansi [lc_time_tz_convert -from [lang::system::timezone] -to "Etc/GMT" -time_value $last_modified] + set entry_timestamp "[clock format [clock scan $entry_date_ansi] -format "%a, %d %b %Y %H:%M:%S"] GMT" + + lappend items [list \ + link $entry_url \ + title $title \ + description $description \ + value $content_as_text \ + timestamp $entry_timestamp] + + if { $counter == 0 } { + set column_array(channel_lastBuildDate) $entry_timestamp + incr counter + } + } + set column_array(channel_title) "News" + set column_array(channel_description) "News" + set column_array(items) $items + set column_array(channel_language) "" + set column_array(channel_copyright) "" + set column_array(channel_managingEditor) "" + set column_array(channel_webMaster) "" + set column_array(channel_rating) "" + set column_array(channel_skipDays) "" + set column_array(channel_skipHours) "" + set column_array(version) 2.0 + set column_array(image) "" + set column_array(channel_link) "$package_url" + return [array get column_array] +} + +ad_proc -private news_update_rss { + -summary_context_id +} { + + Regenerate RSS feed + + @author Dave Bauer (dave@thedesignexperience.org) + @creation-date 2005-02-04 + + @param summary_context_id + + @return + + @error +} { + set subscr_id [rss_support::get_subscr_id \ + -summary_context_id $summary_context_id \ + -impl_name "news" \ + -owner "news"] + rss_gen_report $subscr_id +} + + +########### NEW FUNCTIONS + +ad_proc news_get_package_id { + -community_id +} { + Get the news package in the selected community + + @param community_id +} { + + if {[info exist community_id] == 0} { + set community_id [dotlrn_community::get_community_id] + } + db_1row get_news_package_id {} + + return $package_id +} + + +ad_proc news_create_new { + + {-item_id "null"} + {-locale "null"} + -publish_date_ansi + {-publish_body "null"} + {-nsl_language "null"} + {-publish_title "null"} + {-mime_type "text/plain"} + -package_id:required + -archive_date_ansi + -approval_user + -approval_date + -approval_ip + {-relation_tag "null"} + -creation_ip + -user_id + {-live_revision_p "t"} +} { + Create a New +} { + + if {[info exist user_id] == 0} { + set user_id [ad_conn user_id] + } + if {[info exist approval_user] == 0} { + set approval_user [ad_conn user_id] + } + + if {[info exist creation_ip] == 0} { + set creation_ip [ad_conn host] + } + if {[info exist approval_ip] == 0} { + set approval_ip [ad_conn host] + } + if {[info exist publish_date_ansi] == 0} { + set publish_date_ansi [dt_systime] + } + if {[info exist archive_date_ansi] == 0} { + set archive_date_ansi [dt_systime] + } + if {[info exist approval_date] == 0} { + set approval_date [dt_systime] + } + + set news_id [db_exec_plsql create_news_item {}] + + return $news_id +} + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/news-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,65 @@ + + + + + + + + select item_id + from cr_revisions + where revision_id=:object_id + + + + + + + select package_id + from cr_news + where news_id=:object_id + + + + + + select max(o.last_modified) + from acs_objects o, cr_news n + where n.package_id=:package_id + and o.object_id=n.news_id + + + + + + select ao.object_id as package_id + from acs_objects ao, apm_packages ap, dotlrn_communities_all dc + where ao.object_type = 'apm_package' and ao.context_id = dc.package_id and dc.community_id = :community_id and ao.object_id = ap.package_id and ap.package_key = 'news' + + + + + + + + select news__new( + null, -- p_item_id + null, -- p_locale + :publish_date_ansi, -- p_publish_date + :publish_body, -- p_text + null, -- p_nls_language + :publish_title, -- p_title + :mime_type, -- p_mime_type + :package_id, -- p_package_id + :archive_date_ansi, -- p_archive_date + :approval_user, -- p_approval_user + :approval_date, -- p_approval_date + :approval_ip, -- p_approval_ip + null, -- p_relation_tag + :creation_ip, -- p_creation_ip + :user_id, -- p_creation_user + :live_revision_p -- p_is_live_p + ) + + + + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/static-portlet-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/static-portlet-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/static-portlet-callback-procs.tcl 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,80 @@ +ad_library { + Navigation callbacks. + + @author Luis de la Fuente + @creation-date 2005-07-13 +} + + +ad_proc -public -callback datamanager::move_static -impl datamanager { + -object_id:required + -self_community + -selected_community:required +} { + Move an static portlet to another class or community +} { +if {[info exist self_community] == 0} { + set community_id [dotlrn_community::get_community_id] +} else {set community_id $self_community} + +set old_portal_id [dotlrn_community::get_portal_id -community_id $community_id] +set old_page_id [portal::get_page_id -portal_id $old_portal_id] + +set new_portal_id [dotlrn_community::get_portal_id -community_id $selected_community] +set new_page_id [portal::get_page_id -portal_id $new_portal_id] + + db_transaction { + db_dml update_static_portal_content {} + db_dml update_portal_element_map {} + } on_error { + ad_return_error "Error:" "The error was: $errmsg" + } +} + +ad_proc -public -callback datamanager::copy_static -impl datamanager { + -object_id:required + -selected_community:required + -sufix:required +} { + Copy an static portlet to another class or community +} { +#set the parameters + set portal_id [dotlrn_community::get_portal_id -community_id $selected_community] + db_1row get_static_portlet_data {} + +#create the object + db_transaction { + + set item_id [static_portal_content::new \ + -package_id $selected_community \ + -content $content \ + -pretty_name "$pretty_name$sufix" + ] + + set old_element_id [static_portal_content::add_to_portal \ + -portal_id $portal_id \ + -package_id $selected_community \ + -content_id $item_id] + } on_error { + #ad_return_error "Error:" "#static-portlet.already_exists#

The error was: $errmsg" + ad_return_error "Error:" "#static-portlet.already_exists#" + } + return $item_id +} + +ad_proc -public -callback datamanager::export_static -impl datamanager { + -object_id:required +} { + Export a static portlet +} { + set lista [list] + db_1row select_static {} + + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + lappend lista "" + return $lista +} + Index: openacs-4/packages/datamanager/CALLBACKS_CHANGES/static-portlet-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/CALLBACKS_CHANGES/static-portlet-callback-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/CALLBACKS_CHANGES/static-portlet-callback-procs.xql 22 Jun 2006 14:21:34 -0000 1.1 @@ -0,0 +1,42 @@ + + + + + + update static_portal_content + set package_id = :selected_community + where content_id = :object_id + + + + + + + update portal_element_map + set page_id=:new_page_id + where page_id=:old_page_id and pretty_name=(select pretty_name from static_portal_content where content_id=:object_id); + + + + + + SELECT body as content,pretty_name + FROM static_portal_content + WHERE content_id=:object_id + + + +--SELECT STATIC PORTLES + + + select content_id, + package_id, + pretty_name, + body, + format + from static_portal_content + where content_id = :object_id + + + + Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/catalog/datamanager.ca_ES.ISO-8859-1.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/catalog/datamanager.en_US.ISO-8859-1.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/catalog/datamanager.es_ES.ISO-8859-1.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/sql/postgresql/datamanager-create.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/sql/postgresql/datamanager-drop.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/tcl/datamanager-callback-procs.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/datamanager/tcl/datamanager-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/datamanager/tcl/datamanager-callback-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/datamanager/tcl/datamanager-callback-procs.xql 22 Jun 2006 14:26:30 -0000 1.1 @@ -0,0 +1,159 @@ + + + + + + + + + select u.username, u.password, u.salt, u.screen_name, + p.first_names, p.last_name, + pa.email, pa.url, + a.short_name as auth, + d.type as usr_type + from users u, persons p, parties pa, auth_authorities a, dotlrn_users d + where u.user_id = :user_id and u.user_id = p.person_id and + u.user_id = d.user_id and p.person_id = pa.party_id and + a.authority_id = u.authority_id + + + + + + + select attr_value as bio + from acs_attribute_values + where object_id = :user_id and + attribute_id = ( + select attribute_id + from acs_attributes + where object_type = 'person'and + attribute_name = 'bio') + + + + + + + + + select encode (data, 'base64') as photo + from lob_data + where lob_id = ( + select max(r.lob) + from acs_rels a, cr_revisions r + where a.object_id_two = r.item_id and + a.object_id_one = :user_id and + a.rel_type = 'user_portrait_rel') + + + + + + + + select revision_id + from acs_rels a, cr_revisions r, cr_items i + where a.object_id_two = r.item_id and + a.object_id_one = :user_id and + a.rel_type = 'user_portrait_rel' and + r.revision_id = i.live_revision + + + + + + + + select lob as content + from cr_revisions + where revision_id = :revision_id + + + + + + + SELECT pretty_name as name, + description + FROM dotlrn_communities_all + WHERE community_id = :object_id + + + + + + SELECT u.email, + u.last_name, + u.first_names, + u.username, + r.role, + u.user_id + FROM registered_users u, + dotlrn_member_rels_approved r + WHERE r.community_id = :community_id and + r.user_id = u.user_id + order by last_name, first_names + + + + + + + SELECT u.user_id, u.username, u.authority_id, r.rel_type + FROM registered_users u, + dotlrn_member_rels_approved r + WHERE r.community_id = :community_id and + r.user_id = u.user_id + order by last_name, first_names + + + + + + + + select content_id + from static_portal_content + where package_id = :community_id and + pretty_name <> '#dotlrn-static.community_info_portlet_pretty_name#'; + + + + + + + select news_id + from cr_news + where package_id = $pid; + + + + + + select news_id + from cr_news + where package_id = $pid; + + + + + + + select object_id + from acs_objects + where context_id = $pid and + object_type = 'faq' + + + + + + select forum_id + from forums_forums + where package_id = $pid + + + + + Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/tcl/datamanager-procs.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/datamanager/tcl/datamanager-procs.xql'. Fisheye: No comparison available. Pass `N' to diff?