Index: openacs-4/contrib/packages/form-to-mail/form-to-mail.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/form-to-mail.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/form-to-mail.info 30 Jul 2003 21:09:55 -0000 1.1 @@ -0,0 +1,34 @@ + + + + + Form To Mail + Form To Mail forms + f + f + ftm + + + Steve Ivy + Form-to-Email Handling + 2003-07-09 + <p>The Form-To-Mail package is designed to work somewhat like formmail.pl - the user enters information into an HTML form on a page, and upon submitting the page the data is collected and emailed to an address + of the administrator&#39;s choosing. +</p> + <p>Form-to-Mail (FTM) is designed with reuse, and hopefully some security, in mind. Email addresses such as sender and recipient are configured by the administrator, stored in the database, and cannnot be overridden by form variables, whic +h limits abuse of the form by third parties. +</p> + <p>FTM is designed to be included on other pages in the site, and provides a facility for adding custom form elements to the form, using a .tcl file that can be as simple or complex as the developer requires. The package uses a single inst +ance to generate the included HTML form, and to process the submitted form. +</p> + + + + + + + + + + + Index: openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-create.sql 30 Jul 2003 21:09:55 -0000 1.1 @@ -0,0 +1,11 @@ +-- +-- packages/form-to-mail/sql/postgresql/form-to-mail-create.sql +-- +-- @author steve@redmonk.net +-- @creation-date 2003-06-19 +-- @cvs-id $Id +-- +-- + +\i form-to-mail-table-create.sql +\i form-to-mail-functions-create.sql \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-drop.sql 30 Jul 2003 21:09:55 -0000 1.1 @@ -0,0 +1,39 @@ +-- packages/form-to-mail/sql/form-to-mail-drop.sql +-- drop script +-- +-- @author steve@redmonk.net +-- @creation-date 2003-06-19 +-- @cvs-id $Id +-- /* This script removes from the database everything associated with our table. */ + +-- drop package, which drops all functions created with define_function_args + +select drop_package('formtomail'); + +-- drop permissions +delete from acs_permissions where object_id in (select form_id from formtomail); + +-- drop objects +create function inline_0 () +returns integer as ' +declare + object_rec record; +begin + for object_rec in select object_id from acs_objects where object_type=''formtomail'' + loop + perform acs_object__delete( object_rec.object_id ); + end loop; + return 0; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +-- drop table +drop table formtomail; + +-- drop type +select acs_object_type__drop_type( + 'formtomail', + 't' +); \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-functions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-functions-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-functions-create.sql 30 Jul 2003 21:09:55 -0000 1.1 @@ -0,0 +1,134 @@ +-- +-- packages/form-to-mail/sql/postgresql/form-to-mail-functions-create.sql +-- +-- @author steve@redmonk.net +-- @creation-date 2003-06-19 +-- @cvs-id $Id +-- +-- +/* Since each record is also an Object, we make a creation function that will create an object and then use the object id to create a record in our table. The function also takes several input variables. + Form Name is required + Form Pretty Name is required + Title is required + Body is required + Required User Subject is optional and defaults to + Creation date is optional and defaults to now + Creation user, required, is the user id owns the object + Context id, required, is the id of the package instance. This allows + segregation of records by package, required to make the package + "package-aware." + + define_function_args prepares the function to be used by a tcl wrapper function. */ + +select define_function_args('formtomail__new','form_id,package_id,form_name,form_pretty_name,subject_prefix,subject_default,requires_user_subject,requires_user_comments,recipient,sender,confirm_msg,creation_date,creation_user,context_id'); + +create or replace function formtomail__new( + integer, -- form_id + varchar, -- form_name + varchar, -- form_pretty_name + varchar, -- subject_prefix + varchar, -- subject_default + integer, -- requires_user_subject + integer, -- requires_user_comments + varchar, -- recipient + varchar, -- sender + varchar, + timestamptz, -- creation_date + integer, -- creation_user + integer -- context_id +) returns integer as ' +declare + p_form_id alias for $1; + p_form_name alias for $2; + p_form_pretty_name alias for $3; + p_subject_prefix alias for $4; + p_subject_default alias for $5; + p_requires_user_subject alias for $6; + p_requires_user_comments alias for $7; + p_recipient alias for $8; + p_sender alias for $9; + p_confirm_msg alias for $10; + p_creation_date alias for $11; + p_creation_user alias for $12; + p_context_id alias for $13; + v_formtomail_id int; +begin + v_formtomail_id := acs_object__new ( + p_form_id, + ''formtomail'', + p_creation_date, + p_creation_user, + NULL, + p_context_id + ); + insert into formtomail ( + form_id, + package_id, + form_name, + form_pretty_name, + subject_prefix, + subject_default, + requires_user_subject, + requires_user_comments, + recipient, + sender, + confirm_msg + ) values ( + v_formtomail_id, + p_context_id, + p_form_name, + p_form_pretty_name, + p_subject_prefix, + p_subject_default, + p_requires_user_subject, + p_requires_user_comments, + p_recipient, + p_sender, + p_confirm_msg + ); + PERFORM acs_permission__grant_permission + ( + v_formtomail_id, + p_creation_user, + ''admin'' + ); + return v_formtomail_id; +end;' language 'plpgsql'; + +/* The __delete function deletes a record and all related overhead. */ + +select define_function_args('formtomail___delete','form_id'); +create or replace function formtomail__delete (integer) +returns integer as ' +declare + p_formtomail_id alias for $1; +begin + delete from acs_permissions + where object_id = p_formtomail_id; + delete from formtomail + where form_id = p_formtomail_id; + raise NOTICE ''Deleting formtomail...''; + PERFORM acs_object__delete(p_formtomail_id); + return 0; +end;' language 'plpgsql'; + +/* When we created the acs object type above, we specified a +'name_method'. This is the name of a function that will return the +name of the object. This is a convention ensuring that all objects +can be identified. Now we have to build that function. In this case, +we'll return a field called title as the name. */ + +select define_function_args('formtomail___name','form_id'); + +create or replace function formtomail__name (integer) +returns varchar as ' +declare + p_formtomail_id alias for $1; + v_formtomail_name formtomail.form_name%TYPE; +begin + select form_name into v_formtomail_name + from formtomail + where form_id = p_formtomail_id; + return v_formtomail_name; +end; +' language 'plpgsql'; \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-table-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-table-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/sql/postgresql/form-to-mail-table-create.sql 30 Jul 2003 21:09:55 -0000 1.1 @@ -0,0 +1,42 @@ +-- +-- packages/form-to-mail/sql/postgresql/form-to-mail-table-create.sql +-- +-- @author steve@redmonk.net +-- @creation-date 2003-06-19 +-- @cvs-id $Id +-- +/* Create the table. Each constraint is named to make it easier to identify during debugging. The form_id is identical to the object id. */ + +create table formtomail ( + form_id integer constraint formtomail_fk + references acs_objects(object_id) + constraint formtomail_pk + primary key, + package_id integer + constraint formtomail_package_id_fk + references apm_packages(package_id), + form_name varchar(255) constraint formtomail_name_nn + not null, + form_pretty_name varchar(255) constraint formtomail_pretty_nn + not null, + subject_prefix varchar(1024), + subject_default varchar(1024), + requires_user_subject integer, + requires_user_comments integer, + recipient varchar(255), + sender varchar(255), + confirm_msg varchar(2048) +); + +select acs_object_type__create_type ( + 'formtomail', -- object_type + 'Form To Mail form', -- pretty_name + 'Form To Mail forms', -- pretty_plural + 'acs_object', -- supertype + 'formmail', -- table_name + 'form_id', -- id_column + 'form-to-mail', -- package_name + 'f', -- abstract_p + null, -- type_extension_table + 'formmail__name' -- name_method +); \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/sql/postgresql/upgrade/upgrade-0.1b9-0.1b10.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/sql/postgresql/upgrade/upgrade-0.1b9-0.1b10.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/sql/postgresql/upgrade/upgrade-0.1b9-0.1b10.sql 30 Jul 2003 21:09:55 -0000 1.1 @@ -0,0 +1,76 @@ +alter table formtomail add confirm_msg text; + +select define_function_args('formtomail__new','form_id,package_id,form_name,form_pretty_name,subject_prefix,subject_default,requires_user_subject,requires_user_comments,recipient,sender,confirm_msg,creation_date,creation_user,context_id'); + +create or replace function formtomail__new( + integer, -- form_id + varchar, -- form_name + varchar, -- form_pretty_name + varchar, -- subject_prefix + varchar, -- subject_default + integer, -- requires_user_subject + integer, -- requires_user_comments + varchar, -- recipient + varchar, -- sender + text, -- confirm_msg + timestamptz, -- creation_date + integer, -- creation_user + integer -- context_id +) returns integer as ' +declare + p_form_id alias for $1; + p_form_name alias for $2; + p_form_pretty_name alias for $3; + p_subject_prefix alias for $4; + p_subject_default alias for $5; + p_requires_user_subject alias for $6; + p_requires_user_comments alias for $7; + p_recipient alias for $8; + p_sender alias for $9; + p_confirm_msg alias for $10; + p_creation_date alias for $11; + p_creation_user alias for $12; + p_context_id alias for $13; + v_formtomail_id int; +begin + v_formtomail_id := acs_object__new ( + p_form_id, + ''formtomail'', + p_creation_date, + p_creation_user, + NULL, + p_context_id + ); + insert into formtomail ( + form_id, + package_id, + form_name, + form_pretty_name, + subject_prefix, + subject_default, + requires_user_subject, + requires_user_comments, + recipient, + sender, + confirm_msg + ) values ( + v_formtomail_id, + p_context_id, + p_form_name, + p_form_pretty_name, + p_subject_prefix, + p_subject_default, + p_requires_user_subject, + p_requires_user_comments, + p_recipient, + p_sender, + p_confirm_msg + ); + PERFORM acs_permission__grant_permission + ( + v_formtomail_id, + p_creation_user, + ''admin'' + ); + return v_formtomail_id; +end;' language 'plpgsql'; \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/.DS_Store =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/Attic/.DS_Store,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/.DS_Store 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,8 @@ +Bud1 nIlocblob  @� @� @� @adminIlocblobP������adminfwi0blobf��clmvadminfwvhshorJadmininfoblob0�1�G������������ ����������������docIlocblob�������docinfoblob0�,�c������������ +���������������� +form-proc.adpIlocblob������� +form-proc.adpinfoblob0�1�2�������������������������������� +form-proc.tclIlocblobPs������ +form-proc.tclinfoblob0�1�|�������������������������������� +form-proc.xqlIlocblob�s������ +form-proc.xqlinfoblob0�,�c��������������������������������form.adpIlocblob�s������form.adpinfoblob0�.���������������������������������form.tclIlocblobP�������form.tclinfoblob0�1�:��������������������������������form.xqlIlocblob��������form.xqlinfoblob0�,���������������������������������� index.adpIlocblob�������� index.adpinfoblob0�,�d�������������������������������� XC2Prc.htmlIlocblobP������ XC2Prc.htmlinfoblob0�/���������������������������������� E DSDB `� @� @� @rc.htmlIlocblobP������ XC2Prc.htmlinfoblob0�/���������������������������������� \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/form-proc.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/form-proc.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/form-proc.adp 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,13 @@ + +Thank You + +

Thank You

+

+ + @confirm_msg@ + + + Thank you for your comments. Your information has been sent to the administrator at (@recipient@). + + +Return Index: openacs-4/contrib/packages/form-to-mail/www/form-proc.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/form-proc.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/form-proc.tcl 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,54 @@ +ad_page_contract { + This is the main page for the form package. + It gets a form from the db according to the form_name passed in to the include. + + @author steve@redmonk.net + @creation-date 2003-06-20 + @cvs-id $Id: form-proc.tcl,v 1.1 2003/07/30 21:09:56 stevei Exp $ + @return form_html html form constructed by querying the forms table + +} { + ftm:array,optional + ftmx:array,optional + form_id + return_url +} -properties { +} + + +########## +# +# get form details +# +# populates: +# form__pretty_name +# subject_prefix +# recipient +# sender +########## +db_1row get_form_details_query {} + +set some_output "" +set email_content "" + +if {![empty_string_p [array names ftm "body"]]} { + append email_content "$ftm(body)\n\n" +} + +foreach var [array names ftm] { + ns_log Notice "$var : $ftm($var)" +} + +foreach var [array names ftmx] { + ns_log Notice "$var : $ftmx($var)" + append some_output "$var : $ftmx($var)" + append email_content "$var : $ftmx($var)\n" + append some_output "
" +} + +append some_output "Return to url: $return_url" + + + +#ns_sendmail to from subject body ?extraheaders? ?bcc? +ns_sendmail $recipient $sender "$subject_prefix $ftm(subject)" $email_content \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/form-proc.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/form-proc.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/form-proc.xql 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + select form_name, + subject_prefix, + recipient, + sender + from formtomail + where form_id = :form_id + + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/form.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/form.adp 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,7 @@ +

@form_pretty_name@

+ +ftm_id: @ftm_id@
+package_id: @package_id@
+ + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/form.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/form.tcl 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,70 @@ +# /packages/form-to-mail/www/form.tcl + +ad_proc -private get_closest_pkg_id { + pkg_key +} { + set an_id [site_node::closest_ancestor_package -package_key $pkg_key] + if { ![exists_and_not_null an_id] } { + set an_id [site_node_apm_integration::get_child_package_id -package_key $pkg_key] + } + return $an_id +} + +set return_url [ad_conn url] + +################################ +# There should be only one instance of form-to-mail in a subsite. +################################ +set ftm_id [get_closest_pkg_id "form-to-mail"] + +set package_id [site_node_closest_ancestor_package "acs-subsite"] + +set closest_mount [site_node::get_url_from_object_id -object_id $ftm_id] + +ns_log Notice "closest mount: $closest_mount" + +set action "${closest_mount}form-proc" + +db_1row get_form_query {} + +ad_form -name mail_form -action $action -export { return_url form_id } -form { + {kludge:text(hidden) + {value "kluge since a form has to have something in it"} + } +} + +if {$requires_user_subject} { + ad_form -extend -name mail_form -form { + { ftm.subject:text(text) + {label "Title:"} + {html {size 40}} + {value "$subject_default"} + } + } +} else { + ad_form -extend -name mail_form -form { + { ftm.subject:text(hidden) + {value "$subject_default"} + } + } +} + +if {$requires_user_comments} { + ad_form -extend -name mail_form -form { + { ftm.body:text(textarea) + {label "Comments"} + {html {rows 4 cols 40}} + } + } +} + +# get the extra form data +if {[info exists extra_form_file]} { + if { [file exists [acs_root_dir]$extra_form_file] } { + source [acs_root_dir]$extra_form_file + } elseif { [file exists $extra_form_file] } { + source $extra_form_file + } +} + +ad_return_template \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/form.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/form.xql 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + select form_id, + form_pretty_name, + subject_default, + requires_user_subject, + requires_user_comments + from formtomail + where form_name = :form_name + and package_id = :package_id + + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/index.adp 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,8 @@ + +Form-To-Mail Package +

+This is an instance of the Form-to-Mail package. +

+

+Form-to-mail functions as an include only; see the docs for more information. +

\ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.adp 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,6 @@ + +@title@ +{@title@} +

@title@

+ + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.tcl 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,29 @@ +ad_page_contract { + A page that gets confirmation and then delete forms. + + @author steve@redmonk.net + @creation-date 2003-06-21 + @cvs-id $Id: form-delete.tcl,v 1.1 2003/07/30 21:09:56 stevei Exp $ +} { + form_id:integer + confirm_p:optional +} + +set title "Delete Form?" + +if {![exists_and_not_null confirm_p]} { + # first pass, not confirmed. Display a form for confirmation + set form_name [db_string get_name { *SQL* }] + set title "Confirm Delete Form: $form_name" + template::form::create form-del-confirm + template::element::create form-del-confirm form_id -value $form_id -widget hidden + template::element::create form-del-confirm confirm_p -value 1 -widget hidden + template::element::create form-del-confirm submit \ + -label "Delete Form" \ + -widget submit +} else { + # second pass, confirmed. Call the database to delete the record + db_1row do_delete { *SQL* } + ad_returnredirect "index" + ad_script_abort +} \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/form-delete.xql 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + select formtomail__delete(:form_id) + + + + + select formtomail__name(:form_id) + + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.adp 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,5 @@ + +@title@ +{@title@} + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.tcl 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,59 @@ +ad_page_contract { + Simple add/edit form for samplenote. +} { + form_id:integer,optional +} +set user_id [ad_maybe_redirect_for_registration] +set title "Add a form" + +if {[exists_and_not_null form_id]} { + set title "Edit a form" +} + +set package_id [site_node_closest_ancestor_package "acs-subsite"] + +ad_form -name form -form { + form_id:key + {form_name:text + {label "Form Name"} + {html {size 40}} + } + {form_pretty_name:text + {label "Pretty Name"} + {html {size 40} } + } + {subject_prefix:text,optional + {label "Subject Prefix"} + {html {size 40}} + } + {subject_default:text,optional + {label "Subject Default"} + {html {size 40}} + } + {requires_user_subject:text(radio),optional + {label "Show Subject"} + {options { {"Yes" 1} {"No" 0}}} + } + {requires_user_comments:text(radio),optional + {label "Show Comments"} + {options { {"Yes" 1} {"No" 0}}} + } + {recipient:text + {label "Recipient"} + {html {size 40}} + } + {sender:text + {label "Sender"} + {html {size 40}} + } + {confirm_msg:text(textarea) + {label "Confirmation/Thank You Message
(On successful send.)"} + {html {cols 34 rows 8} } + } +} -select_query_name form_query -new_data { + db_1row do_insert { *SQL* } +} -edit_data { + db_dml do_update { *SQL* } +} -after_submit { + ad_returnredirect "index" +} \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/form-edit.xql 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,52 @@ + + + + + select formtomail__new( + null, + :form_name, + :form_pretty_name, + :subject_prefix, + :subject_default, + cast(:requires_user_subject as integer), + cast(:requires_user_comments as integer), + :recipient, + :sender, + :confirm_msg, + null, + :user_id, + :package_id + ) + + + + + update formtomail + set form_name = :form_name, + form_pretty_name = :form_pretty_name, + subject_prefix = :subject_prefix, + subject_default = :subject_default, + requires_user_subject = int4(int2(:requires_user_subject)), + requires_user_comments = int4(int2(:requires_user_comments)), + recipient = :recipient, + sender = :sender, + confirm_msg = :confirm_msg + where form_id = :form_id + + + + + select form_name, + form_pretty_name, + subject_prefix, + subject_default, + requires_user_subject, + requires_user_comments, + recipient, + sender, + confirm_msg + from formtomail + where form_id = :form_id + + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/index.adp 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,4 @@ + +Form-To-Mail forms +@table_html@ +

Add a form

\ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/index.tcl 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,35 @@ +ad_page_contract { + This is the main admin page for the package. It lists all of the forms and provides links to edit them and to create new forms. + + @author steve@redmonk.net + @creation-date 2003-06-19 + @cvs-id $Id: index.tcl,v 1.1 2003/07/30 21:09:56 stevei Exp $ + @param orderby indicates when the user clicks on a column to order by that column + @return table_html preformatting html table constructed by querying the samplenotes table + +} { + {orderby:optional {name}} +} -properties { + table_html +} + +# is this user authorized? +permission::require_permission -object_id [ad_conn package_id] -privilege admin + +# package_id +set package_id [site_node_closest_ancestor_package "acs-subsite"] + +# define the columns in the table +set table_def { + {form_pretty_name "Pretty Name"} + {subject_prefix "Subject Prefix"} + {subject_default "Subject Default"} + {requires_user_subject "Show Subject?" } + {requires_user_comments "Show Comments?" } + {recipient "Recipient"} + {sender "Sender"} + {edit "" {} {\[Edit | Delete\]}} +} + +# construct an html table from the samplenotes database table +set table_html [ad_table -Torderby $orderby form_query { *SQL* } $table_def] \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/admin/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/admin/index.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/admin/index.xql 30 Jul 2003 21:09:56 -0000 1.1 @@ -0,0 +1,17 @@ + + + + + select form_id, + form_pretty_name, + subject_prefix, + subject_default, + requires_user_subject, + requires_user_comments, + recipient, + sender + from formtomail where package_id = :package_id + [ad_order_by_from_sort_spec $orderby $table_def] + + + \ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/doc/ad_form.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/ad_form.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/addForm.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/addForm.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/doc.ooutline =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/doc.ooutline,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/doc/doc.ooutline 30 Jul 2003 21:10:00 -0000 1.1 @@ -0,0 +1,1187 @@ + + + + + BackgroundColor + + b + 1 + g + 1 + r + 1 + + Columns + + + Identifier + 73e62b973f27fe9a2f800164 + MaximumWidth + 3.000000e+01 + MinimumWidth + 1.300000e+01 + OOPlainTextExportWidthKey + 1 + Title + + Width + 1.300000e+01 + + + Identifier + 53972b983f27fe9a2f800164 + MaximumWidth + 1.000000e+06 + MinimumWidth + 1.300000e+01 + OOPlainTextExportWidthKey + 72 + Title + Topic + Width + 6.120000e+02 + + + IsNoteExpanded + + NoteColumn + 73e62b973f27fe9a2f800164 + NoteHeight + 162 + Other Information + + Page Layout + + BAt0eXBlZHN0cmVhbYED6IQBQISEhAtOU1ByaW50SW5mbwGEhAhOU09iamVj + dACFkoSEhBNOU011dGFibGVEaWN0aW9uYXJ5AISEDE5TRGljdGlvbmFyeQCU + hAFpCJKEhIQITlNTdHJpbmcBlIQBKw5OU0JvdHRvbU1hcmdpboaShISECE5T + TnVtYmVyAISEB05TVmFsdWUAlIQBKoSEAWadJIaShJmZFk5TSG9yaXpvbnRh + bGx5Q2VudGVyZWSGkoSbnISEAXOeAIaShJmZDE5TTGVmdE1hcmdpboaShJuc + nZ0khpKEmZkNTlNSaWdodE1hcmdpboaShJucnZ0khpKEmZkUTlNWZXJ0aWNh + bFBhZ2luYXRpb26GkoSbnKCeAIaShJmZFE5TVmVydGljYWxseUNlbnRlcmVk + hpKfkoSZmQtOU1RvcE1hcmdpboaShJucnZ0khpKEmZkVTlNIb3Jpem9uYWxQ + YWdpbmF0aW9uhpKEm5ygngCGhoY= + + SpellCheckingEnabled + + + OutlineColumn + 53972b983f27fe9a2f800164 + Root Item + + Children + + + Children + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 The Form-To-Mail package is designed to work somewhat like formmail.pl - the user enters information into an HTML form on a page, and upon submitting the page the data is collected and emailed to an address of the administrator's choosing. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Form-to-Mail (FTM) is designed with reuse, and hopefully some security, in mind. Email addresses such as sender and recipient are configured by the administrator, stored in the database, and cannnot be overridden by form variables, which limits abuse of the form by third parties. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 FTM is designed to be included on other pages in the site, and provides a facility for adding custom form elements to the form, using a .tcl file that can be as simple or complex as the developer requires. The package uses a single instance to generate the included HTML form, and to process the submitted form. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Introduction } + + Expanded + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 Form-to-Mail is made up of two pages: form and form-proc. To add a mail form to your site, first mount an instance of Form-To-Mail under your site. The name of the instance doesn't really matter, but there should be only one instance and it would be good to name it something generic but that does not give away its purpose (i.e., naming it "Form-to-Mail" is likely to invite malcontents to try and abuse it). I like to use 'ftm'. } + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf2 <div><img src="forms.jpg" alt="" width="571" height="177" border="1" align="bottom" /><br>Fig 1: The Form-to-Mail Admin page</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 Visit /yoursite/<ftm-instance>/admin. (Replace <ftm-instance> with whatever you named your Form-to-Mail instance. } + + Expanded + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Form Name:</b> a descriptive name you can remember. You'll use it when adding the form to your pages. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Subject Prefix:</b> a prefix, often of a form like "[name of form]", but can be whatever you want. The user will not see this, but it can help the recipient recognize and filter incoming mail from the form. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Subject Default:</b> this will be the default subject, and will appear in the subject form field when the user creates a new form. The user can replace this with whatever they want. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Show Subject: Yes/No</b> - Should the form show a subject field, or just use the default subject?} + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Show Comments: Yes/No</b> - Should the form show the comments textarea?} + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Recipient:</b> valid email address where the email from the form will be directed. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Sender:</b> email address with at least a valid domain which will be used as the "from" address in the email. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 <b>Confirmation:</b> Enter the Confirmation or Thank You message you would like to display to the user when the form is successfully submitted.} + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720 + +\f0\fs22 \cf2 <div><img src="addForm.jpg" alt="" width="458" height="523" border="1" align="bottom" /><br>Fig 2: Adding a form</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 Add a new form, entering the information as requested: } + + Expanded + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Getting Started } + + Expanded + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 On the page or template where you want the form to appear, include it like this: } + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Arial-ItalicMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\i\fs24 \cf0 <include src="/packages/form-to-mail/www/form" form_name="name of the form" extra_form_file="/path/to/file"> } + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Arial-ItalicMT;\f1\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\i\fs24 \cf0 src +\f1\i0 : typical include src. Should always be "/packages/form-to-mail/www/form". } + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Arial-ItalicMT;\f1\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\i\fs24 \cf0 form_name +\f1\i0 : This is the descriptive name you gave the form when creating it. This tells the form-to-mail package which default values to pull fromt he database, and later, which sender and recipient to use. } + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720 + +\f0\fs22 \cf2 <div><img src="include.jpg" alt="" width="413" height="78" border="1" align="bottom" /><br>Fig 3: Including the form</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Arial-ItalicMT;\f1\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\i\fs24 \cf0 extra_form_file +\f1\i0 : Optional, this is a .tcl file containing at least a call to ad_form -extend, as documented below. } + + Expanded + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Usage } + + Expanded + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 Form-to-Mail is designed to be extensible. The forms you create in the admin area can be used as is - subject and body (actually title and comments) fields will be generated for you. However, most developers will want to collect a variety of information from the form. FTM provides for this by taking a .tcl file as a parameter to the <include> tag and sourcing it when generating the form.} + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fmodern\fcharset77 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 <pre>ad_form -extend -name mail_form -form \{\ + \{ ftmx.field1:text ... \}\ + \{ ftmx.field2:text(select) ... \}\ +\}</pre>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf2 <div><img src="extra_form.jpg" alt="" width="324" height="168" border="1" align="bottom" /><br>Fig 4: The extra_form_file</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 Create a .tcl file in your site somewhere. I usually name it after the form I'm extending, i.e. form_name_extra_form.tcl. In the file, you need at least one call to <code>ad_form -extend -name mail_form</code>, like this: } + + Expanded + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 The form name, "mail_form", is the name of the form generated by the package and should not be changed. } + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 In the call to ad_form, your form elements should be named with "ftmx." as a prefix. This adds the form element to an array passed to the form processor, and makes sure that it gets added to the outgoing email. } + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf2 <div><img src="moreInfoForm.jpg" alt="" width="458" height="234" border="1" align="bottom" /><br>Fig 5: The rendered form</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf2 <div><img src="thankYou.jpg" alt="" width="519" height="169" border="1" align="bottom" /><br>Fig 6: After submitting</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf2 <div><img src="email.jpg" alt="" width="313" height="137" border="1" align="bottom" /><br>Fig 7: The email</div>} + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 ArialMT;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 You can use whatever techniques you want to generate your form elements. One popular technique might be to fetch a list of values from the database to create the options for a select input (drop-down list element). Another might be grabbing the url of the current page to pass as a hidden field and thereby sent with the email. } + + Expanded + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Extra_form_file } + + Expanded + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Children + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 I would be completely remiss if I did not thank the denizens of #openacs - especially daveb, jadeforrest, jim, jaufrec, michaels, talli, and til - for their help, encouragement, and patience with a complete n00b. } + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Acknowledgements} + + Expanded + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 #template "<p style='font-size:small; font-style:italic'>%text%</p>"} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Form-to-Mail Package, Steve Ivy, <a href="mailto:steve@redmonk.net">steve@redmonk.net</a>, 2003} + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs24 \cf0 #template "<html><head><title>%text%</title><head><body style='margin:10px 30px 10px 10px;'>%pTarget%<h2>%text%</h2>%children%<p style='font-size:small'>Last Modified: %modified%</p></body></html>"\ +#template "%pTarget%<h3>%text% <span style='font-size:small'>%pLink%</span></h3>%children%"\ +#template "<p>%text% <span style='font-size:small'></span><blockquote>%children%</blockquote></p>"\ +#template "<p>%text%<br>%children%</p>"} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl\f0\fnil\fcharset77 LucidaGrande;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\fs22 \cf0 Form-To-Mail} + + Expanded + + Style + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + + Cols + + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + {\rtf1\mac\ansicpg10000\cocoartf102 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} + + Expanded + + + StatusHidden + Yes + Styles + + + Heading + + type + None + + ShouldAllowSorting + + TextColor + + b + 0 + g + 0 + r + 0 + + TextFont + + name + LucidaGrande + size + 1.100000e+01 + + + + Heading + + type + None + + ShouldAllowSorting + + + + Heading + + type + None + + ShouldAllowSorting + + + + Heading + + type + None + + ShouldAllowSorting + + + + Heading + + type + None + + ShouldAllowSorting + + + + Version + 6 + + Index: openacs-4/contrib/packages/form-to-mail/www/doc/email.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/email.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/extra_form.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/extra_form.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/forms.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/forms.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/include.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/include.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/index-old.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/index-old.html,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/doc/index-old.html 30 Jul 2003 21:10:07 -0000 1.1 @@ -0,0 +1,91 @@ + + + + + Form-to-Mail Documentation + + + + + +

Form-To-Mail Documentation

+ +

Introduction

+ +

The Form-To-Mail package is designed to work somewhat like formmail.pl - the user enters information into an HTML form on a page, and upon submitting the page the data is collected and emailed to an address of the administrator's choosing. +

+

Form-to-Mail (FTM) is designed with reuse, and hopefully some security, in mind. Email addresses such as sender and recipient are configured by the administrator, stored in the database, and cannnot be overridden by form variables, which limits abuse of the form by third parties. +

+

FTM is designed to be included on other pages in the site, and provides a facility for adding custom form elements to the form, using a .tcl file that can be as simple or complex as the developer requires. The package uses a single instance to generate the included HTML form, and to process the submitted form. +

+ +

Getting Started

+ +

Form-to-Mail is made up of two pages: form and form-proc. To add a mail form to your site, first mount an instance of Form-To-Mail under your site. The name of the instance doesn't really matter, but there should be only one instance and it would be good to name it something generic but that does not give away its purpose (i.e., naming it "Form-to-Mail" is likely to invite malcontents to try and abuse it). I like to use 'ftm'.

+ +

Visit /yoursite/<ftm-instance>/admin. (Replace <ftm-instance> with whatever you named your Form-to-Mail instance.

+ +


Fig 1: The Form-to-Mail Admin page

+ +

Add a new form, entering the information as requested:

+

+

  • Form Name: a descriptive name you can remember. You'll use it when adding the form to your pages.
  • +
  • Subject Prefix: a prefix, often of a form like "[name of form]", but can be whatever you want. The user will not see this, but it can help the recipient recognize and filter incoming mail from the form.
  • +
  • Subject Default: this will be the default subject, and will appear in the subject form field when the user creates a new form. The user can replace this with whatever they want.
  • +
  • Recipient: valid email address where the email from the form will be directed.
  • +
  • Sender: email address with at least a valid domain which will be used as the "from" address in the email.
+

+ +


Fig 2: Adding a form

+ +

Usage

+ +

On the page or template where you want the form to appear, include it like this:

+ +
+<include src="/packages/form-to-mail/www/form" form_name="name of the form" extra_form_file="/path/to/file"> +
+ +
    +
  • src: typical include src. Should always be "/packages/form-to-mail/www/form".
  • +
  • form_name: This is the descriptive name you gave the form when creating it. This tells the form-to-mail package which default values to pull fromt he database, and later, which sender and recipient to use.
  • +
  • extra_form_file: Optional, this is a .tcl file containing at least a call to ad_form -extend, as documented below.
  • +
+ +


Fig 3: Including the form

+ +

Extra_form_file

+ + Form-to-Mail is designed to be extensible. The forms you create in the admin area can be used as is - subject and body (actually title and comments) fields will be generated for you. However, most developers will want to collect a variety of information from the form. FTM provides for this by taking a .tcl file as a parameter to the <include> tag and sourcing it when generating the form. + Create a .tcl file in your site somewhere. I usually name it after the form I'm extending, i.e. form_name_extra_form.tcl. + In the file, you need at least one call to ad_form, like this: + +
+                ad_form -extend -name mail_form -form {
+                    { ftmx.field1:text ... }
+                    { ftmx.field2:text(select) ... }
+                }
+            
+ +


Fig 4: The extra_form_file

+ +

The form name, "mail_form", is the name of the form generated by the package and should not be changed.

+

In the call to ad_form, your form elements should be named with "ftmx." as a prefix. This adds the form element to an array passed to the form processor, and makes sure that it gets added to the outgoing email.

+

You can use whatever techniques you want to generate your form elements. One popular technique might be to fetch a list of values from the database to create the options for a select input (drop-down list element). Another might be grabbing the url of the current page to pass as a hidden field and thereby sent with the email. +

+ +


Fig 5: The rendered form

+ +


Fig 6: After submitting

+ +


Fig 7: The email

+ +

+I would be completly remiss if I did not thank the denizens of #openacs - especially daveb, jadeforrest, jim, jaufrec, michaels, talli, and til - for their help, encouragement, and patience with a complete n00b.
+Form-to-Mail Package, Steve Ivy, steve@redmonk.net, 2003 +

+ + + Index: openacs-4/contrib/packages/form-to-mail/www/doc/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/Attic/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/doc/index.adp 30 Jul 2003 21:10:08 -0000 1.1 @@ -0,0 +1,42 @@ +Form-To-Mail

Form-To-Mail

Introduction #

The Form-To-Mail package is designed to work somewhat like formmail.pl - the user enters information into an HTML form on a page, and upon submitting the page the data is collected and emailed to an address of the administrator's choosing.

+

Form-to-Mail (FTM) is designed with reuse, and hopefully some security, in mind. Email addresses such as sender and recipient are configured by the administrator, stored in the database, and cannnot be overridden by form variables, which limits abuse of the form by third parties.

+

FTM is designed to be included on other pages in the site, and provides a facility for adding custom form elements to the form, using a .tcl file that can be as simple or complex as the developer requires. The package uses a single instance to generate the included HTML form, and to process the submitted form.

+ +

Getting Started #

Form-to-Mail is made up of two pages: form and form-proc. To add a mail form to your site, first mount an instance of Form-To-Mail under your site. The name of the instance doesn't really matter, but there should be only one instance and it would be good to name it something generic but that does not give away its purpose (i.e., naming it "Form-to-Mail" is likely to invite malcontents to try and abuse it). I like to use 'ftm'.

+

Visit /yoursite//admin. (Replace with whatever you named your Form-to-Mail instance.


Fig 1: The Form-to-Mail Admin page

+

+

Add a new form, entering the information as requested:

Form Name: a descriptive name you can remember. You'll use it when adding the form to your pages.

+

Subject Prefix: a prefix, often of a form like "[name of form]", but can be whatever you want. The user will not see this, but it can help the recipient recognize and filter incoming mail from the form.

+

Subject Default: this will be the default subject, and will appear in the subject form field when the user creates a new form. The user can replace this with whatever they want.

+

Show Subject: Yes/No - Should the form show a subject field, or just use the default subject?

+

Show Comments: Yes/No - Should the form show the comments textarea?

+

Recipient: valid email address where the email from the form will be directed.

+

Sender: email address with at least a valid domain which will be used as the "from" address in the email.

+

Confirmation: Enter the Confirmation or Thank You message you would like to display to the user when the form is successfully submitted.

+


Fig 2: Adding a form

+

+ +

Usage #

On the page or template where you want the form to appear, include it like this:

+

+

src : typical include src. Should always be "/packages/form-to-mail/www/form".

+

form_name : This is the descriptive name you gave the form when creating it. This tells the form-to-mail package which default values to pull fromt he database, and later, which sender and recipient to use.

+

extra_form_file : Optional, this is a .tcl file containing at least a call to ad_form -extend, as documented below.


Fig 3: Including the form

+

+ +

Extra_form_file #

Form-to-Mail is designed to be extensible. The forms you create in the admin area can be used as is - subject and body (actually title and comments) fields will be generated for you. However, most developers will want to collect a variety of information from the form. FTM provides for this by taking a .tcl file as a parameter to the tag and sourcing it when generating the form.

+

Create a .tcl file in your site somewhere. I usually name it after the form I'm extending, i.e. form_name_extra_form.tcl. In the file, you need at least one call to ad_form -extend -name mail_form, like this:

ad_form -extend -name mail_form -form {
+    { ftmx.field1:text ... }
+    { ftmx.field2:text(select) ... }
+}

+


Fig 4: The extra_form_file

+

+

The form name, "mail_form", is the name of the form generated by the package and should not be changed.

+

In the call to ad_form, your form elements should be named with "ftmx." as a prefix. This adds the form element to an array passed to the form processor, and makes sure that it gets added to the outgoing email.

+

You can use whatever techniques you want to generate your form elements. One popular technique might be to fetch a list of values from the database to create the options for a select input (drop-down list element). Another might be grabbing the url of the current page to pass as a hidden field and thereby sent with the email.


Fig 5: The rendered form

+


Fig 6: After submitting

+


Fig 7: The email

+

+ +

Acknowledgements #

I would be completely remiss if I did not thank the denizens of #openacs - especially daveb, jadeforrest, jim, jaufrec, michaels, talli, and til - for their help, encouragement, and patience with a complete n00b.

+ +

Last Modified: Wednesday, July 30, 2003 11:54:08 AM

\ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/doc/index.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/index.html,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/form-to-mail/www/doc/index.html 30 Jul 2003 21:10:08 -0000 1.1 @@ -0,0 +1,42 @@ +Form-To-Mail

Form-To-Mail

Introduction #

The Form-To-Mail package is designed to work somewhat like formmail.pl - the user enters information into an HTML form on a page, and upon submitting the page the data is collected and emailed to an address of the administrator's choosing.

+

Form-to-Mail (FTM) is designed with reuse, and hopefully some security, in mind. Email addresses such as sender and recipient are configured by the administrator, stored in the database, and cannnot be overridden by form variables, which limits abuse of the form by third parties.

+

FTM is designed to be included on other pages in the site, and provides a facility for adding custom form elements to the form, using a .tcl file that can be as simple or complex as the developer requires. The package uses a single instance to generate the included HTML form, and to process the submitted form.

+ +

Getting Started #

Form-to-Mail is made up of two pages: form and form-proc. To add a mail form to your site, first mount an instance of Form-To-Mail under your site. The name of the instance doesn't really matter, but there should be only one instance and it would be good to name it something generic but that does not give away its purpose (i.e., naming it "Form-to-Mail" is likely to invite malcontents to try and abuse it). I like to use 'ftm'.

+

Visit /yoursite//admin. (Replace with whatever you named your Form-to-Mail instance.


Fig 1: The Form-to-Mail Admin page

+

+

Add a new form, entering the information as requested:

Form Name: a descriptive name you can remember. You'll use it when adding the form to your pages.

+

Subject Prefix: a prefix, often of a form like "[name of form]", but can be whatever you want. The user will not see this, but it can help the recipient recognize and filter incoming mail from the form.

+

Subject Default: this will be the default subject, and will appear in the subject form field when the user creates a new form. The user can replace this with whatever they want.

+

Show Subject: Yes/No - Should the form show a subject field, or just use the default subject?

+

Show Comments: Yes/No - Should the form show the comments textarea?

+

Recipient: valid email address where the email from the form will be directed.

+

Sender: email address with at least a valid domain which will be used as the "from" address in the email.

+

Confirmation: Enter the Confirmation or Thank You message you would like to display to the user when the form is successfully submitted.

+


Fig 2: Adding a form

+

+ +

Usage #

On the page or template where you want the form to appear, include it like this:

+

+

src : typical include src. Should always be "/packages/form-to-mail/www/form".

+

form_name : This is the descriptive name you gave the form when creating it. This tells the form-to-mail package which default values to pull fromt he database, and later, which sender and recipient to use.

+

extra_form_file : Optional, this is a .tcl file containing at least a call to ad_form -extend, as documented below.


Fig 3: Including the form

+

+ +

Extra_form_file #

Form-to-Mail is designed to be extensible. The forms you create in the admin area can be used as is - subject and body (actually title and comments) fields will be generated for you. However, most developers will want to collect a variety of information from the form. FTM provides for this by taking a .tcl file as a parameter to the tag and sourcing it when generating the form.

+

Create a .tcl file in your site somewhere. I usually name it after the form I'm extending, i.e. form_name_extra_form.tcl. In the file, you need at least one call to ad_form -extend -name mail_form, like this:

ad_form -extend -name mail_form -form {
+    { ftmx.field1:text ... }
+    { ftmx.field2:text(select) ... }
+}

+


Fig 4: The extra_form_file

+

+

The form name, "mail_form", is the name of the form generated by the package and should not be changed.

+

In the call to ad_form, your form elements should be named with "ftmx." as a prefix. This adds the form element to an array passed to the form processor, and makes sure that it gets added to the outgoing email.

+

You can use whatever techniques you want to generate your form elements. One popular technique might be to fetch a list of values from the database to create the options for a select input (drop-down list element). Another might be grabbing the url of the current page to pass as a hidden field and thereby sent with the email.


Fig 5: The rendered form

+


Fig 6: After submitting

+


Fig 7: The email

+

+ +

Acknowledgements #

I would be completely remiss if I did not thank the denizens of #openacs - especially daveb, jadeforrest, jim, jaufrec, michaels, talli, and til - for their help, encouragement, and patience with a complete n00b.

+ +

Last Modified: Wednesday, July 30, 2003 11:54:08 AM

\ No newline at end of file Index: openacs-4/contrib/packages/form-to-mail/www/doc/moreInfoForm.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/moreInfoForm.jpg,v diff -u Binary files differ Index: openacs-4/contrib/packages/form-to-mail/www/doc/thankYou.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/form-to-mail/www/doc/thankYou.jpg,v diff -u Binary files differ