Index: openacs-4/packages/faq/faq.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/faq.info,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/faq/faq.info 19 May 2004 20:07:02 -0000 1.12 +++ openacs-4/packages/faq/faq.info 12 Aug 2004 13:57:46 -0000 1.13 @@ -7,26 +7,25 @@ f f - - Jennie Kim Housman + Elizabeth Wirth - Manage simple Question and Answer style FAQs - 2003-11-10 + Jennie Kim Housman + Nima Mazloumi + Manage simple and categorized Question and Answer style FAQs with WYSIWYG and notification functionalities. + 2004-08-12 Ybos Corporation - Handles frequently asked questions Q&A presentation. Can be one Q&A per page or all presented flat. Straightforward application with room for improvement. - 0 + Handles frequently asked questions Q&A presentation. Can be one Q&A per page or all presented flat. Straightforward application with room for improvement. Support for notification as well as WYSIQYG Editor and Categories - both optional. Category trees are displayed flat. No multiple filters. - + + - - - - + + Index: openacs-4/packages/faq/catalog/faq.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/catalog/faq.en_US.ISO-8859-1.xml,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/faq/catalog/faq.en_US.ISO-8859-1.xml 15 Oct 2003 15:28:21 -0000 1.9 +++ openacs-4/packages/faq/catalog/faq.en_US.ISO-8859-1.xml 12 Aug 2004 13:57:46 -0000 1.10 @@ -1,11 +1,15 @@ - + A: Add Q&A for %faq_name% administer + All Q&A Answer + Answer text in html Back to FAQs + Change settings + Configure Create a new FAQ Create an FAQ Create FAQ @@ -18,6 +22,8 @@ Edit edit Edit an FAQ + Enable Categories + Enable WYSIWYG FAQ Admin %faq_name% Admin FAQs @@ -38,6 +44,8 @@ Q&A On Separate Pages? Q&A on Separate Pages? Question + Question text in html + Set Category Mode swap with next Text type? Title: Index: openacs-4/packages/faq/www/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/index.vuh,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/www/index.vuh 12 Aug 2004 13:57:45 -0000 1.1 @@ -0,0 +1,11 @@ +set url /[ad_conn extra_url] + +if {[regexp {^/+cat/+([^/]+)/*} $url \ + ignore_whole sw_category_id]} { + # SWC (Site-wide categories) + # As the categories package currently doesn't have short names we + # are using IDs. We don't check whether this is a valid integer here + # because index.tcl will take care of that. + rp_form_put sw_category_id $sw_category_id +} +rp_internal_redirect "/packages/faq/www/one-faq" Index: openacs-4/packages/faq/www/one-faq.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/one-faq.adp,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/faq/www/one-faq.adp 29 Jun 2004 10:18:18 -0000 1.11 +++ openacs-4/packages/faq/www/one-faq.adp 12 Aug 2004 13:57:46 -0000 1.12 @@ -5,12 +5,13 @@

@faq_name;noquote@ + + +
#faq.lt_no_questions#

-

    @@ -42,4 +43,15 @@ - +
+ + +

@categories.tree_name@

+ + @categories.category_name@
+
+
+
#faq.All_QA# +
+
\ No newline at end of file Index: openacs-4/packages/faq/www/one-faq.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/one-faq.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/faq/www/one-faq.tcl 19 May 2004 20:07:02 -0000 1.3 +++ openacs-4/packages/faq/www/one-faq.tcl 12 Aug 2004 13:57:45 -0000 1.4 @@ -1,12 +1,13 @@ ad_page_contract { - View contents of one faq + View contents of one faq. Filter by categories if enabled @author Elizabeth Wirth (wirth@ybos.net) @author Jennie Housman (jennie@ybos.net) + @author Nima Mazloumi (nima.mazloumi@gmx.de) @creation-date 2000-10-24 } { - + {category_id:integer,optional {}} faq_id:naturalnum,notnull } @@ -22,11 +23,62 @@ set context [list $faq_name] -db_multirow one_question q_and_a_info "select entry_id, faq_id, question, answer, sort_key -from faq_q_and_as +# Use Categories? +set use_categories_p [parameter::get -parameter "EnableCategoriesP" -default 0] + +if { $use_categories_p == 1 && [exists_and_not_null category_id] } { + + set select_sql_query "select entry_id, faq_id, question, answer, sort_key +from faq_q_and_as qa, category_object_map com, acs_named_objects nam +where faq_id = :faq_id and +com.object_id = qa.entry_id and +nam.package_id = :package_id and +com.object_id = nam.object_id and +com.category_id = :category_id +order by sort_key" + +} else { + + set select_sql_query "select entry_id, faq_id, question, answer, sort_key +from faq_q_and_as where faq_id = :faq_id order by sort_key" +} +db_multirow one_question q_and_a_info $select_sql_query + +# Site-Wide Categories +if { $use_categories_p == 1} { + set package_url [ad_conn package_url] + if { ![empty_string_p $category_id] } { + set category_name [category::get_name $category_id] + if { [empty_string_p $category_name] } { + ad_return_exception_page 404 "No such category" "Site-wide \ + Category with ID $category_id doesn't exist" + return + } + # Show Category in context bar + append context_base_url /cat/$category_id + lappend context [list $context_base_url $category_name] + set type "all" + } + + # Cut the URL off the last item in the context bar + if { [llength $context] > 0 } { + set context [lreplace $context end end [lindex [lindex $context end] end]] + } + + db_multirow -unclobber -extend { category_name tree_name } categories categories { + select c.category_id as category_id, c.tree_id + from categories c, category_tree_map ctm + where ctm.tree_id = c.tree_id + and ctm.object_id = :package_id + } { + set category_name [category::get_name $category_id] + set tree_name [category_tree::get_name $tree_id] + } +} + set notification_chunk [notification::display::request_widget \ -type one_faq_qa_notif \ -object_id $faq_id \ Index: openacs-4/packages/faq/www/admin/configure.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/configure.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/www/admin/configure.adp 12 Aug 2004 13:57:43 -0000 1.1 @@ -0,0 +1,5 @@ + +@title@ +@context@ + + Index: openacs-4/packages/faq/www/admin/configure.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/configure.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/www/admin/configure.tcl 12 Aug 2004 13:57:43 -0000 1.1 @@ -0,0 +1,36 @@ +ad_page_contract { + + This page allows a faq admin to change instance wide settings. + + @author Nima Mazloumi (nima.mazloumi@gmx.de) + @creation-date 2004-08-11 + +} { + {return_url ""} +} + +set title "#faq.Configure#" +set context [list $title] + +set use_categories_p [parameter::get -parameter "EnableCategoriesP"] +set use_wysiwyg_p [parameter::get -parameter "UseWysiwygP"] + +ad_form -name categories_mode -form { + {cat_enabled_p:text(radio) + {label "#faq.Enable_Categories#"} + {options {{Yes 1} {No 0}}} + {value $use_categories_p}} + {wysiwyg_enabled_p:text(radio) + {label "#faq.Enable_WYSIWYG#"} + {options {{Yes t} {No f}}} + {value $use_wysiwyg_p} + } + {return_url:text(hidden) {value $return_url}} + {submit:text(submit) {label "[_ faq.Change_settings]"}} +} -on_submit { + parameter::set_value -parameter "EnableCategoriesP" -value $cat_enabled_p + parameter::set_value -parameter "UseWysiwygP" -value $wysiwyg_enabled_p + if {![empty_string_p $return_url]} { + ns_returnredirect $return_url + } +} Index: openacs-4/packages/faq/www/admin/faq-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/faq-delete.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/faq/www/admin/faq-delete.tcl 28 Nov 2003 16:55:15 -0000 1.2 +++ openacs-4/packages/faq/www/admin/faq-delete.tcl 12 Aug 2004 13:57:43 -0000 1.3 @@ -2,7 +2,7 @@ ad_page_contract { - delete an FAQ + delete an FAQ, also deletes entries in acs_named_objects for categories @author Elizabeth Wirth (wirth@ybos.net) @author Jennie Housman (jennie@ybos.net) @creation-date 2000-10-24 @@ -24,6 +24,7 @@ ); end; } + db_dml delete_named_object "delete from acs_named_objects where object_id in (select entry_id from faq_q_and_as where faq_id = :faq_id)" } ad_returnredirect "index" \ No newline at end of file Index: openacs-4/packages/faq/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/index.adp,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/faq/www/admin/index.adp 27 Feb 2004 16:09:27 -0000 1.9 +++ openacs-4/packages/faq/www/admin/index.adp 12 Aug 2004 13:57:43 -0000 1.10 @@ -6,6 +6,9 @@ - +
  • >#faq.Configure# + +
  • #categories.Site_wide_categories# + + Index: openacs-4/packages/faq/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/index.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/faq/www/admin/index.tcl 22 Dec 2003 23:42:33 -0000 1.7 +++ openacs-4/packages/faq/www/admin/index.tcl 12 Aug 2004 13:57:43 -0000 1.8 @@ -3,9 +3,11 @@ ad_page_contract { Admin for FAQs on this site + Categories for FAQ-Package added @author Jennie Housman (jennie@ybos.net) @author Elizabeth Wirth (wirth@ybos.net) + @author Nima Mazloumi (nima.mazloumi@gmx.de) @creation-date 2000-10-24 } { @@ -78,4 +80,10 @@ set enable_url [export_vars -base faq-enable { faq_id }] } +# for categories +set use_categories_p [parameter::get -parameter "EnableCategoriesP"] +set category_map_url [export_vars -base "[site_node::get_package_url -package_key categories]cadmin/one-object" { { object_id $package_id } }] + +set return_url [ns_conn url] + ad_return_template Index: openacs-4/packages/faq/www/admin/one-question.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/one-question.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/faq/www/admin/one-question.tcl 28 Nov 2003 16:55:15 -0000 1.4 +++ openacs-4/packages/faq/www/admin/one-question.tcl 12 Aug 2004 13:57:43 -0000 1.5 @@ -5,6 +5,7 @@ View contents of one Q&A @author Elizabeth Wirth (wirth@ybos.net) @author Jennie Housman (jennie@ybos.net) + @author Nima Mazloumi (nima.mazloumi@gx.de) @creation-date 2000-10-24 } { @@ -25,10 +26,10 @@ where entry_id = :entry_id and a.faq_id = f.faq_id" -set context [list [list "one-faq?faq_id=$faq_id" "$faq_name"] "One Q&A"] +set context [list [list "one-faq?faq_id=$faq_id" "$faq_name"] "[_ faq.One_Question]"] -set edit_url "q_and_a-edit?[export_vars { entry_id faq_id }]" +set edit_url "q-and-a-add-edit?[export_vars { entry_id faq_id }]" set delete_url "q_and_a-delete?[export_vars { entry_id faq_id }]" -set create_url "q_and_a-new?[export_vars { faq_id } ]" +set create_url "q-and-a-add-edit?[export_vars { faq_id } ]" ad_return_template Index: openacs-4/packages/faq/www/admin/q-and-a-add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/q-and-a-add-edit.adp,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/faq/www/admin/q-and-a-add-edit.adp 22 Dec 2003 23:24:41 -0000 1.2 +++ openacs-4/packages/faq/www/admin/q-and-a-add-edit.adp 12 Aug 2004 13:57:43 -0000 1.3 @@ -3,4 +3,7 @@ @context;noquote@ new_quest_answ.question - + + + #categories.Site_wide_categories# + Index: openacs-4/packages/faq/www/admin/q-and-a-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/q-and-a-add-edit.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/faq/www/admin/q-and-a-add-edit.tcl 29 Jun 2004 10:18:18 -0000 1.4 +++ openacs-4/packages/faq/www/admin/q-and-a-add-edit.tcl 12 Aug 2004 13:57:43 -0000 1.5 @@ -1,8 +1,9 @@ ad_page_contract { - Adds or Edit a new Q&A to a FAQ + Adds or Edit a new Q&A to a FAQ and Categories if Parameter EnableCategoriesP is Enabled @author Rocael Hernandez (roc@viaro.net) @author Gerardo Morales Cadoret (gmorales@galileo.edu) + @author Nima Mazloumi (nima.mazloumi@gmx.de) @creation-date 2003-11-26 } { @@ -22,82 +23,123 @@ if { ![ad_form_new_p -key entry_id]} { set page_title [_ faq.One_Question] - set context [list [list "one-faq?faq_id=$faq_id" "$faq_name"] "One Q&A"] + set context [list [list "one-faq?faq_id=$faq_id" "$faq_name"] [_ faq.One_Question]] + set submit_label "[_ faq.Update_This_QA]" permission::require_permission -object_id [ad_conn package_id] -privilege faq_modify_faq } else { set page_title [_ faq.Add_QA_for_faq_name] - set context [list [list "one-faq?faq_id=$faq_id" "$faq_name"] [_ faq.Create_new_QA]] + set context [list [list "one-faq?faq_id=$faq_id" "$faq_name"] [_ faq.Create_new_QA]] + set submit_label "[_ faq.Create_new_QA]" permission::require_permission -object_id [ad_conn package_id] -privilege faq_create_faq } set question "" set answer "" set insert_p "f" -set mime_type "" set question_q [ad_quotehtml $question] set answer_q [ad_quotehtml $answer] set user_id [ad_verify_and_get_user_id] set creation_ip [ad_conn host] -ad_form -name new_quest_answ -export {faq_id creation_ip} -form { +# Are categories used? +set use_categories_p [parameter::get -parameter "EnableCategoriesP" -default 0] +set package_id [ad_conn package_id] - entry_id:key - {prev_entry_id:text(hidden) {value $prev_entry_id}} - {question:text(textarea) {label "Question"} {html {rows 10 cols 40 wrap soft }} {help_text {Question text in html}}} - {answer:text(textarea) {label "Answer"} {html {rows 10 cols 40 wrap soft }} {help_text {Answer text in html}}} +# Is WYSIWYG enabled? +set use_wysiwyg_p [parameter::get -parameter "UseWysiwygP" -default "f"] -} -select_query { - - select question, answer,faq_name,qa.faq_id +set select_sql_query "select question, answer,faq_name,qa.faq_id from faq_q_and_as qa, faqs f where entry_id = :entry_id - and f.faq_id = qa.faq_id + and f.faq_id = qa.faq_id" -} -new_data { +ad_form -name new_quest_answ -export {faq_id creation_ip} -form { + {entry_id:key} + {prev_entry_id:text(hidden) {value $prev_entry_id}} + {question:text {label "[_ faq.Question]"} {html {size 50}} {help_text {[_ faq.Question_text_in_html]}}} + {answer:richtext(richtext) {htmlarea_p $use_wysiwyg_p} {label "[_ faq.Answer]"} {html {rows 10 cols 40 wrap soft }} {help_text {[_ faq.Answer_text_in_html]}}} +} - set page_title [_ faq.Add_QA_for_faq_name] - set last_entry_id $prev_entry_id - - db_transaction { +# customize form depending on category capabilities +if { $use_categories_p == 1 } { - set old_sort_key [db_string faq_sortkey_get "select sort_key from faq_q_and_as - where entry_id = :last_entry_id" -default 0] - - if ![string equal $old_sort_key 0] { - set sql_update_q_and_as " - update faq_q_and_as - set sort_key = sort_key + 1 - where sort_key > :old_sort_key" - - db_dml faq_update $sql_update_q_and_as - - set sort_key [expr $old_sort_key + 1] + #add link do define categories + set category_map_url [export_vars -base "[site_node::get_package_url -package_key categories]cadmin/one-object" { { object_id $package_id } }] - } else { + #extend the form to support categories + category::ad_form::add_widgets -form_name new_quest_answ -container_object_id $package_id -categorized_object_id [value_if_exists entry_id] + + ad_form -extend -name new_quest_answ -select_query $select_sql_query -on_submit { + set category_ids [category::ad_form::get_categories -container_object_id $package_id] + set answer [ template::util::richtext::get_property contents $answer] + } -on_request { + set htmlarea_p $use_wysiwyg_p + set answer [template::util::richtext::create $answer "text/html"] + } -new_data { + + set page_title [_ faq.Add_QA_for_faq_name] + set last_entry_id $prev_entry_id + + db_transaction { + set old_sort_key [db_string faq_sortkey_get "select sort_key from faq_q_and_as where entry_id = :last_entry_id" -default 0] + + if ![string equal $old_sort_key 0] { + set sql_update_q_and_as "update faq_q_and_as set sort_key = sort_key + 1 where sort_key > :old_sort_key" + db_dml faq_update $sql_update_q_and_as + set sort_key [expr $old_sort_key + 1] + } else { + set sort_key $entry_id + } + } - set sort_key $entry_id - - } + db_transaction { + db_exec_plsql create_q_and_a { *SQL* } + category::map_object -remove_old -object_id $entry_id $category_ids + db_dml insert_asc_named_object "insert into acs_named_objects (object_id, object_name, package_id) values ( :entry_id, 'FAQ', :package_id)" + } + } -edit_data { + db_dml q_and_a_edit "update faq_q_and_as set question = :question, answer = :answer where entry_id = :entry_id" + db_dml insert_asc_named_object "update acs_named_objects set object_name = 'FAQ', package_id = :package_id where object_id = :entry_id" + category::map_object -remove_old -object_id $entry_id $category_ids + } -after_submit { + ad_returnredirect "one-faq?faq_id=$faq_id" + ad_script_abort } - - - db_transaction { - db_exec_plsql create_q_and_a { *SQL* } - } +} else { + ad_form -extend -name new_quest_answ -select_query $select_sql_query -on_submit { + set answer [ template::util::richtext::get_property contents $answer] + } -on_request { + set htmlarea_p $use_wysiwyg_p + set answer [template::util::richtext::create $answer "text/html"] + } -new_data { -} -edit_data { + set page_title [_ faq.Add_QA_for_faq_name] + set last_entry_id $prev_entry_id -db_dml q_and_a_edit "update faq_q_and_as - set question = :question, - answer = :answer - where entry_id = :entry_id" -} -after_submit { - faq::notification_delivery::do_notification $question $answer $entry_id $faq_id $user_id - ad_returnredirect "one-faq?faq_id=$faq_id" - ad_script_abort -} + db_transaction { + set old_sort_key [db_string faq_sortkey_get "select sort_key from faq_q_and_as where entry_id = :last_entry_id" -default 0] + if ![string equal $old_sort_key 0] { + set sql_update_q_and_as "update faq_q_and_as set sort_key = sort_key + 1 where sort_key > :old_sort_key" + db_dml faq_update $sql_update_q_and_as + set sort_key [expr $old_sort_key + 1] + } else { + set sort_key $entry_id + } + } + db_transaction { + db_exec_plsql create_q_and_a { *SQL* } + } + } -edit_data { + db_dml q_and_a_edit "update faq_q_and_as set question = :question, answer = :answer where entry_id = :entry_id" + } -after_submit { + faq::notification_delivery::do_notification $question $answer $entry_id $faq_id $user_id + ad_returnredirect "one-faq?faq_id=$faq_id" + ad_script_abort + } +} + Index: openacs-4/packages/faq/www/admin/q_and_a-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/www/admin/q_and_a-delete.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/faq/www/admin/q_and_a-delete.tcl 28 Nov 2003 16:55:15 -0000 1.3 +++ openacs-4/packages/faq/www/admin/q_and_a-delete.tcl 12 Aug 2004 13:57:43 -0000 1.4 @@ -24,6 +24,7 @@ ); end; } + db_dml delete_named_object "delete from acs_named_objects where object_id = :entry_id" } ad_returnredirect "one-faq?faq_id=$faq_id"