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.9 -r1.10 --- openacs-4/packages/acs-templating/www/doc/demo/index.html 10 Feb 2006 00:47:17 -0000 1.9 +++ openacs-4/packages/acs-templating/www/doc/demo/index.html 12 Feb 2006 00:42:42 -0000 1.10 @@ -413,6 +413,23 @@ View + + Add a filter + + + index
+ postgres query
+ oracle query + + + index
+ + + index
+ + View + +

Forms

Index: openacs-4/packages/acs-templating/www/doc/demo/list7/add-disabled.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/add-disabled.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.adp 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title@ +@context;noquote@ + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.tcl 12 Feb 2006 00:42:42 -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/12 00:42:42 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/list7/add-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/add-edit.xql 12 Feb 2006 00:42:42 -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/list7/add.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/add.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list7/blank.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/blank.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list7/delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/delete-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/delete-oracle.xql 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,17 @@ + + + + oracle8.1.6 + + + + + begin + note.del(:note_id); + end; + + + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list7/delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/delete-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/delete-postgresql.xql 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,15 @@ + + + + postgresql7.1 + + + + + select note__delete( :note_id ); + + + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list7/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/delete.tcl 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,18 @@ +# 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/12 00:42:42 jiml Exp $ +} { + note_id:integer,notnull,multiple +} + +foreach note_id $note_id { + ad_require_permission $note_id delete + + package_exec_plsql -var_list [list [list note_id $note_id]] note del +} + +ad_returnredirect "./" Index: openacs-4/packages/acs-templating/www/doc/demo/list7/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/index-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/index-oracle.xql 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,43 @@ + + + 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') + [template::list::filter_where_clauses -and -name notes] + [template::list::orderby_clause -orderby -name notes] + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list7/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/index-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/index-postgresql.xql 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,30 @@ + + + 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::filter_where_clauses -and -name notes] + [template::list::orderby_clause -orderby -name notes] + + + + Index: openacs-4/packages/acs-templating/www/doc/demo/list7/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/index.adp 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,15 @@ + +Notes +@context;noquote@ + + + + + + +
+ + + +
+ Index: openacs-4/packages/acs-templating/www/doc/demo/list7/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/index.tcl 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,109 @@ +# 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/12 00:42:42 jiml Exp $ +} -query { + orderby:optional + color: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] + +set actions [list] + +if { $create_p } { + lappend actions "Create Note" add-edit "Create Note" +} + +# the following structure is a "list of lists". Each list describes a +# different choice value; the first item is the displayed name of the +# choice and the second is the value passed back as the value of the +# choice. +# +# Normally, you'd have a database query where the items in the select +# list of the query will appear in each inner list in order; again, +# the first would be a displayed name and the second would be the +# value that the form would send back as the choice. Note that this +# could be a primary key in a table, maybe an object ID. +# +# Since the colors column is a text column and not implemented as a +# separate table with a numeric key column, the value will be the +# name of the color. + +set color_choices { + {Blue blue} + {Green green} + {Red red} + {Orange orange} + {Yellow yellow} +} + +# Here's the list; notice the new -filters section + +template::list::create -name notes \ + -multirow template_demo_notes \ + -key "template_demo_note_id" \ + -actions $actions \ + -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" + } + } \ + -filters { + color { + label "Color" + where_clause { + n.color = :color + } + values $color_choices + } + } \ + -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/list7/view-one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/view-one.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/view-one.adp 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,5 @@ + +@title;noquote@ +@context;noquote@ + +@body;noquote@ \ No newline at end of file Index: openacs-4/packages/acs-templating/www/doc/demo/list7/view-one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/view-one.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/www/doc/demo/list7/view-one.tcl 12 Feb 2006 00:42:42 -0000 1.1 @@ -0,0 +1,22 @@ +ad_page_contract { + @author Neophytos Demetriou + @creation-date 2001-09-02 +} { + note_id:integer,notnull +} -properties { + context:onevalue + title:onevalue + body:onevalue +} + +set context [list "One note"] + +db_1row note_select { + select title, body + from notes + where note_id = :note_id +} + +set body [ad_text_to_html -- $body] + +ad_return_template Index: openacs-4/packages/acs-templating/www/doc/demo/list7/x-disabled.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/x-disabled.gif,v diff -u -N Binary files differ Index: openacs-4/packages/acs-templating/www/doc/demo/list7/x.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list7/x.gif,v diff -u -N Binary files differ