Index: openacs-4/packages/acs-templating/www/doc/demo/index.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/index.html,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-templating/www/doc/demo/index.html 9 Feb 2006 02:40:05 -0000 1.7 +++ openacs-4/packages/acs-templating/www/doc/demo/index.html 9 Feb 2006 06:39:54 -0000 1.8 @@ -377,6 +377,24 @@ View + + Add a bulk action to delete all checked notes + + + index
+ delete
+ postgres query
+ oracle query + + + index + + + index + + View + +

Forms

Index: openacs-4/packages/acs-templating/www/doc/demo/list5/add-disabled.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/add-disabled.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.adp 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title@ +@context;noquote@ + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.tcl 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,123 @@ +# packages/notes/www/add-edit.tcl +ad_page_contract { + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2000-10-23 + @cvs-id $Id: add-edit.tcl,v 1.1 2006/02/09 06:39:55 jiml Exp $ + + Example script that allows for the creation or editing of a simple note + object type, using ad_form and package Tcl API tools. + +} -query { + note_id:integer,notnull,optional +} -properties { + context:onevalue + page_title:onevalue +} + +# When using ad_form to generate or edit acs_objects, the object type's +# key column must be specified in ad_page_contract as is done above, +# and defined with the type "key" in ad_form. This enables the use of +# the various request and submission code blocks. + +set package_id [ad_conn package_id] + +ad_form -form { + + # The "note" object type's key + + note_id:key + + # "title" is of type text and will use a "text" widget. + + {title:text \ + {label Title} + {html {size 20}} + } + + # "body" is of type text and will use a "textarea" widget. + + {body:text(textarea) \ + {label Body} + {html {rows 10 cols 40 wrap soft}} + } + +} -new_request { + + # By convention packages only allow a user to create new objects if the user has + # the "create" privilege on the package instance itself. + + permission::require_permission -object_id $package_id -privilege create + + # Customize the page title to reflect the fact that this form is used to + # create a new note. + + set page_title "New Note" + +} -edit_request { + + permission::require_permission -object_id $note_id -privilege write + + # Customize the page title to reflect the fact that this form is used to + # edit an existing note. + + set page_title "Edit Note" + + # Fill the form with the values from the note we're editing. + + db_1row note_select {} + +} -on_validation_error { + + # There was an error in the form, let the page title reflect this. + + set page_title "Error in submission" + +} -new_data { + + # Create a new note. + + # Generate the new object automatically from the data set in the form. Standard + # acs_object attributes like creation_user are set automatically. + + package_instantiate_object -var_list [list [list context_id $package_id]] \ + -form_id add-edit \ + note + +} -edit_data { + + # Currently we need to update our object manually ... + + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_transaction { + db_dml object_update {} + db_dml note_update {} + } + +} -after_submit { + + # We've successfully processed the submission, send the user back to the index page. + + ad_returnredirect "./" + + # ad_returnredirect returns after redirecting the user, so abort the script rather + # than fall through to the display code. Failure to abort the script will burden + # your server with needless template processing, though the user won't notice due to + # having been redirected. + + ad_script_abort + +} + +# The following is only executed if we did not process a valid submission, in other +# words on the initial "new" or "edit" form request or after a submission which +# contained errors. Add the page title to the breadcrumb context bar. + +set context [list $page_title] + +# Display the form, blank if we're processing a "new" request, filled with data if we're +# processing an "edit" request or a submitted form that contains errors. + +ad_return_template Index: openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/add-edit.xql 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,30 @@ + + + + + + select title, body + from notes + where note_id = :note_id + + + + + + update acs_objects + set modifying_user = :modifying_user, + modifying_ip = :modifying_ip + where object_id = :note_id + + + + + + update notes + set title = :title, + body = :body + where note_id = :note_id + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/add.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/add.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list5/blank.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/blank.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list5/delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/delete-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/delete-oracle.xql 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,17 @@ + + + + oracle8.1.6 + + + + + begin + template_demo_note.del(:template_demo_note_id); + end; + + + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/delete-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/delete-postgresql.xql 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,15 @@ + + + + postgresql7.1 + + + + + select template_demo_note__delete( :template_demo_note_id ); + + + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/delete.tcl 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,36 @@ +# packages/notes/www/delete.tcl + +ad_page_contract { + + @author rhs@mit.edu + @creation-date 2000-10-23 + @cvs-id $Id: delete.tcl,v 1.1 2006/02/09 06:39:55 jiml Exp $ +} { + template_demo_note_id:integer,notnull,multiple +} + +# Here, we delete all the notes being fed to us, which is all +# the notes that were checked on the index page. This page doesn't +# know/care about the fact they are the checked notes, all it knows +# is there are a bunch of template_demo_note_id values coming in +# through the url. So, this list is sorta becoming a form too :) +# +# so this loop runs thru all passed-in values of template_demo_note_id +# and for each, deletes that note. + +foreach template_demo_note_id $template_demo_note_id { + ad_require_permission $template_demo_note_id delete + + package_exec_plsql \ + -var_list \ + [list \ + [list \ + template_demo_note_id \ + $template_demo_note_id \ + ] \ + ] \ + template_demo_note \ + del +} + +ad_returnredirect "./" Index: openacs-4/packages/acs-templating/www/doc/demo/list5/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/index-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/index-oracle.xql 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,42 @@ + + + oracle8.1.6 + + + + select n.template_demo_note_id, + n.title, + n.body, + n.color, + to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date, + p.first_names || ' ' || p.last_name as creation_user_name, + decode(acs_permission.permission_p(n.template_demo_note_id, + :user_id, + 'write'), + 't', 1, + 'f', 0) as write_p, + decode(acs_permission.permission_p(n.template_demo_note_id, + :user_id, + 'admin'), + 't', 1, + 'f', 0) as admin_p, + decode(acs_permission.permission_p(n.template_demo_note_id, + :user_id, + 'delete'), + 't', 1, + 'f', 0) as delete_p + from template_demo_notes n, + acs_objects o, + persons p + where n.template_demo_note_id = o.object_id + and o.creation_user = p.person_id + and exists (select 1 + from acs_object_party_privilege_map + where object_id = template_demo_note_id + and party_id = :user_id + and privilege = 'read') + order by creation_date + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/index-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/index-postgresql.xql 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,29 @@ + + + postgresql7.1 + + + + + select + n.template_demo_note_id, + n.title, + n.color, + to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date, + p.first_names || ' ' || p.last_name as creation_user_name + from + template_demo_notes n, + acs_objects o, + persons p + where n.template_demo_note_id = o.object_id + and o.creation_user = p.person_id + and exists (select 1 + from acs_object_party_privilege_map + where object_id = template_demo_note_id + and party_id = :user_id + and privilege = 'read') + [template::list::orderby_clause -orderby -name notes] + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/index.adp 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,6 @@ + +Notes +@context;noquote@ + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list5/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/index.tcl 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,71 @@ +# main index page for notes. + +ad_page_contract { + + @author rhs@mit.edu + @creation-date 2000-10-23 + @cvs-id $Id: index.tcl,v 1.1 2006/02/09 06:39:55 jiml Exp $ +} -query { + orderby:optional +} -properties { + notes:multirow + context:onevalue + create_p:onevalue +} + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +set context [list] +set create_p [ad_permission_p $package_id create] + +# New here, is the use of -key to signify which column is the key field, +# and the -bulk_actions to give us the ability to delete all the checked +# notes at once. + +template::list::create -name notes \ + -multirow template_demo_notes \ + -key "template_demo_note_id" \ + -bulk_actions { + "Delete Checked Notes" "delete" "Delete Checked Notes" + } \ + -elements { + title { + label "Title of Note" + link_url_col view_url + } + creation_user_name { + label "Owner of Note" + } + creation_date { + label "When Note Created" + } + color { + label "Color" + } + } \ + -orderby { + default_value title,asc + title { + label "Title of Note" + orderby n.title + } + creation_user_name { + label "Owner of Note" + orderby creation_user_name + } + creation_date { + label "When Note Created" + orderby o.creation_date + } + color { + label "Color" + orderby n.color + } + } + +db_multirow -extend { view_url } template_demo_notes template_demo_notes {} { + set view_url [export_vars -base view-one { template_demo_note_id }] +} + +ad_return_template Index: openacs-4/packages/acs-templating/www/doc/demo/list5/view-one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/view-one.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/view-one.adp 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,6 @@ + +@title;noquote@ +@context;noquote@ + +@body;noquote@
+@color@ \ No newline at end of file Index: openacs-4/packages/acs-templating/www/doc/demo/list5/view-one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list5/view-one.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list5/view-one.tcl 9 Feb 2006 06:39:55 -0000 1.1 @@ -0,0 +1,22 @@ +ad_page_contract { + @author Neophytos Demetriou + @creation-date 2001-09-02 +} { + template_demo_note_id:integer,notnull +} -properties { + context:onevalue + title:onevalue + body:onevalue +} + +set context [list "One note"] + +db_1row note_select { + select title, body, color + from template_demo_notes + where template_demo_note_id = :template_demo_note_id +} + +set body [ad_text_to_html -- $body] + +ad_return_template