Index: openacs-4/packages/acs-person/acs-person.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/Attic/acs-person.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/acs-person.info 24 Sep 2002 05:23:33 -0000 1.1 @@ -0,0 +1,59 @@ + + + + + ACS Person + ACS Persons + f + f + + + + oracle + postgresql + + Jon Griffin + This is an extension of the user/person acs legacy. + Mayuli Enterprises LLC + ACS Person follows the HR-XML PersonName DTD/Schema. It is used to add extended information to OpenACS. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/acs-person/sql/postgresql/acs-person-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/sql/postgresql/Attic/acs-person-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/sql/postgresql/acs-person-create.sql 24 Sep 2002 05:24:47 -0000 1.1 @@ -0,0 +1,197 @@ +-- @cvs-id:$Id: acs-person-create.sql,v 1.1 2002/09/24 05:24:47 jong Exp $ + +-- This is a fairly direct mapping of the HR-XML PersonName v1.0 schema +-- see the docs for explanations + +-- create a package sequence +create sequence acs_persons_seq; + +-- create some lookup tables + +-- affix_type +create table affix_type ( + affix_type_id integer + constraint affix_type_id_pk + primary key, + xml_name varchar(20) + constraint affix_type_xml_name_nn + not null, + help_text varchar(400) + constraint affix_type_pretty_name_nn + not null +); + +-- add some initial data + +insert into affix_type + (affix_type_id, xml_name,help_text) +values + (nextval('acs_persons_seq'),'aristocraticTitle','i.e. Baron, Graf, Earl, etc.'); + +insert into affix_type + (affix_type_id, xml_name,help_text) +values + (nextval('acs_persons_seq'),'aristocraticPrefix','i.e. Von, etc.'); + +insert into affix_type + (affix_type_id, xml_name,help_text) +values + (nextval('acs_persons_seq'),'formOfAddress','Contains the salutation, +i.e. Mr., Mrs., Hon., Dr., etc.'); + +insert into affix_type + (affix_type_id,xml_name,help_text) +values + (nextval('acs_persons_seq'),'FamilyNamePrefix','Contains the part of the person''s +name that precedes the family name. i.e. Van den, Von, etc.'); + +insert into affix_type + (affix_type_id,xml_name,help_text) +values + (nextval('acs_persons_seq'),'generation','i.e. Sr. Jr., III'); + +insert into affix_type + (affix_type_id,xml_name,help_text) +values + (nextval('acs_persons_seq'),'qualifications','Contains the letters used to describe the academic qualifications held by a person and/or the distinctions conferred upon them. +i.e. PhD, MD, CPA, MCSD, etc.'); + + + + +-- Main table +create table acs_persons ( + acs_person_id integer + constraint acs_person_id_pk + primary key + constraint acs_person_id_fk + references acs_objects(object_id), + formatted_name varchar (200), + given_name varchar (100), + preferred_given_name varchar (100), + middle_name varchar (100), + -- The spec says that all fields should be optional + -- This data model requires at least the family_name + -- element. Madonna and Prince go here whether they + -- consider that a family name or not. + family_name varchar (100) + constraint acs_prsn_fmly_nme_nn + not null, + -- link into users + user_id integer + constraint acs_user_id_fk + references users(user_id) +); + +create index acs_persons_full_name_ix on acs_persons (given_name,family_name); +create index acs_persons_family_name_ix on acs_persons (family_name); + +comment on table acs_persons is ' +This is the main table for acs_persons. It is a direct mapping of the HR-XML +PersonName v1.0 schema +'; + +comment on column acs_persons.acs_person_id is ' +Primary key. +'; + +comment on column acs_persons.family_name is ' +The last name. +'; + +comment on column acs_persons.given_name is ' +Given or first name. +'; + +comment on column acs_persons.middle_name is ' +This could also be more than one name. +'; + +comment on column acs_persons.formatted_name is ' +This is the name as it might appear in a letter. +'; + +comment on column acs_persons.preferred_given_name is ' +'; + + +comment on column acs_persons.acs_person_id is ' +Foriegn key. This can be null as we also want to use this for non-users progams +i.e. contact manager etc. +'; + + +-- Now the map tables + +-- affix_acs_persons_map +-- +-- This is necessary due to the way HR-XML implemented the affix system. +-- Since it is many to many this is the only way. + +create table affix_acs_persons_map ( + acs_person_id integer + constraint affix_person_id_fk + references persons(person_id), + affix_type_id integer + constraint affix_type_id_fk + references affix_type(affix_type_id), + ---- add the primary key to ensure uniqueness + constraint affix_acs_prsn_map_pk + primary key (acs_person_id,affix_type_id) +); + +-- acs_persons_given_names +create table acs_persons_given_names ( + given_name_id integer + constraint acs_prsn_gvn_nme_pk + primary key, + acs_person_id integer + constraint acs_prsn_gvn_nme_fk + references acs_persons(acs_person_id), + extra_given_name varchar(100) + constraint acs_prsn_gvn_nme_name_nn + not null, + sort_order integer, + ---- add some constraints to keep data sanity + constraint acs_prsn_gvn_nme_uq + unique (acs_person_id,extra_given_name,sort_order) +); + +create table acs_persons_middle_names ( + middle_name_id integer + constraint acs_prsn_mdl_nme_pk + primary key, + acs_person_id integer + constraint acs_prsn_mdl_nme_fk + references acs_persons(acs_person_id), + extra_middle_name varchar(100) + constraint acs_prsn_mdl_nme_name_nn + not null, + sort_order integer, + ---- add some constraints to keep data sanity + constraint acs_prsn_mdl_nme_uq + unique (acs_person_id,extra_middle_name,sort_order) +); + +create table acs_persons_family_names ( + family_name_id integer + constraint acs_prsn_fmly_nme_pk + primary key, + acs_person_id integer + constraint acs_prsn_fmly_nme_fk + references acs_persons(acs_person_id), + extra_family_name varchar(100) + constraint acs_prsn_fmly_nme_name_nn + not null, + sort_order integer, + ---- add some constraints to keep data sanity + constraint acs_prsn_fmly_nme_uq + unique (acs_person_id,extra_family_name,sort_order) +); + +-- plsql procs +\i acs-person-plsql.sql + +-- Service contract +-- Broken drop script +-- \i acs-person-sc-create.sql Index: openacs-4/packages/acs-person/sql/postgresql/acs-person-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/sql/postgresql/Attic/acs-person-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/sql/postgresql/acs-person-drop.sql 24 Sep 2002 05:24:47 -0000 1.1 @@ -0,0 +1,54 @@ +-- packages/acs-person/sql/postgresql/acs-person-drop.sql +-- +-- @author jon@jongriffin.com +-- @creation-date 2002-09-21 +-- @cvs-id $Id: acs-person-drop.sql,v 1.1 2002/09/24 05:24:47 jong Exp $ + + +\i acs-person-sc-drop.sql + +-- drop sequence +drop sequence acs_persons_seq; + +-- drop functions + +drop function acs_person__new (varchar, varchar, varchar, varchar, varchar, +integer,integer,varchar,integer); + +drop function acs_person__del (integer); + +drop function acs_person__set (varchar, varchar, varchar, varchar, varchar, +integer,integer); + +--drop permissions +delete from acs_permissions where object_id in (select acs_person_id from acs_persons); + +--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=''acs_person'' + loop + perform acs_object__delete( object_rec.object_id ); + end loop; + + return 0; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +-- drop the tables +drop table affix_type; +drop table affix_acs_persons_map; +drop table acs_persons_given_names; +drop table acs_persons_middle_names; +drop table acs_persons_family_names; +drop table acs_persons; + + +-- drop attributes and object types + +select acs_object_type__drop_type('acs_person','t'); Index: openacs-4/packages/acs-person/sql/postgresql/acs-person-plsql.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/sql/postgresql/Attic/acs-person-plsql.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/sql/postgresql/acs-person-plsql.sql 24 Sep 2002 05:24:47 -0000 1.1 @@ -0,0 +1,159 @@ +-- packages/acs-person/sql/postgresql/acs-person-plsql.sql +-- +-- @author jon@jongriffin.com +-- @creation-date 2002-09-21 +-- @cvs-id $Id: acs-person-plsql.sql,v 1.1 2002/09/24 05:24:47 jong Exp $ + +-- I don't use create or replace on these temp functions +-- because I want to have them explicitly deleted + +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''acs_person'', -- object_type + ''ACS Person'', -- pretty_name + ''ACS Persons'', -- pretty_plural + ''acs_object'', -- supertype + ''acs_persons'', -- table_name + ''acs_person_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + null -- name_method + ); + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); + +drop function inline_0 (); + +create or replace function acs_person__new (varchar, varchar, varchar, varchar, varchar, +integer,integer,varchar,integer) +returns integer as ' +declare + p_given_name alias for $1; + p_middle_name alias for $2; + p_family_name alias for $3; + p_formatted_name alias for $4; + p_preferred_given_name alias for $5; + p_user_id alias for $6; -- this is not the creation user + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + v_acs_person_id acs_persons.acs_person_id%TYPE; +begin + v_acs_person_id := acs_object__new ( + null, + ''acs_person'', + now(), + p_creation_user, + p_creation_ip, + p_context_id + ); + + insert into acs_persons + ( acs_person_id, + given_name, + middle_name, + family_name, + formatted_name, + preferred_given_name, + user_id + ) + values + ( + v_acs_person_id, + p_given_name, + p_middle_name, + p_family_name, + p_formatted_name, + p_preferred_given_name, + p_user_id + ); + + PERFORM acs_permission__grant_permission ( + v_acs_person_id, + p_creation_user, + ''admin'' + ); + + raise NOTICE ''Adding acs_person - %'',v_acs_person_id; + return v_acs_person_id; + +end;' language 'plpgsql'; + + +create or replace function acs_person__del (integer) +returns integer as ' +declare + p_acs_person_id alias for $1; + v_return integer := 0; +begin + + delete from acs_permissions + where object_id = p_acs_person_id; + + delete from acs_persons + where acs_person_id = p_acs_person_id; + + raise NOTICE ''Deleting acs_person - %'',p_acs_person_id; + + return v_return; + +end;' language 'plpgsql'; + +create or replace function acs_person__set (varchar, varchar, varchar, varchar, varchar, + integer,integer) +returns integer as ' +declare + p_given_name alias for $1; + p_middle_name alias for $2; + p_family_name alias for $3; + p_formatted_name alias for $4; + p_preferred_given_name alias for $5; + p_user_id alias for $6; -- this is not the creation user + p_acs_person_id alias for $7; + v_return integer := 0; +begin + + update acs_persons + set given_name = p_given_name, + middle_name = p_middle_name, + family_name = p_family_name, + formatted_name = p_formatted_name, + preferred_given_name = p_preferred_given_name, + user_id = p_user_id + where acs_person_id = p_acs_person_id; + + raise NOTICE ''Updating acs persons %'',p_acs_person_id; + + return v_return; + +end;' language 'plpgsql'; + +-- ancillary tables + +create or replace function acs_person_given_name__set (varchar, varchar, varchar,integer) +returns integer as ' +declare + p_acs_person_id alias for $1; + p_extra_given_name alias for $2; + p_sort_order alias for $3; + p_given_name_id alias for $4; + v_return integer := 0; +begin + + update acs_persons_given_name + set acs_person_id = p_acs_person_id, + given_name = p_given_name, + sort_order = p_sort_order + where given_name_id = p_given_name_id + + raise NOTICE ''Updating given_names - %'',p_given_name; + +return v_return;' language 'plpgsql'; + + Index: openacs-4/packages/acs-person/sql/postgresql/acs-person-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/sql/postgresql/Attic/acs-person-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/sql/postgresql/acs-person-sc-create.sql 24 Sep 2002 05:24:47 -0000 1.1 @@ -0,0 +1,58 @@ +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'acs_person', -- impl_name + 'acs_persons' -- impl_owner_name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'contact', -- impl_name + 'datasource', -- impl_operation_name + 'acs_persons__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'contact', -- impl_name + 'url', -- impl_operation_name + 'acs_persons__url', -- impl_alias + 'TCL' -- impl_pl +); + + +create function acs_persons__itrg () +returns opaque as ' +begin + perform search_observer__enqueue(new.contact_id,''INSERT''); + return new; +end;' language 'plpgsql'; + +create function acs_persons__dtrg () +returns opaque as ' +begin + perform search_observer__enqueue(old.contact_id,''DELETE''); + return old; +end;' language 'plpgsql'; + +create function acs_persons__utrg () +returns opaque as ' +begin + perform search_observer__enqueue(old.contact_id,''UPDATE''); + return old; +end;' language 'plpgsql'; + + +create trigger acs_persons__itrg after insert on acs_persons +for each row execute procedure acs_persons__itrg (); + +create trigger acs_persons__dtrg after delete on acs_persons +for each row execute procedure acs_persons__dtrg (); + +create trigger acs_persons__utrg after update on acs_persons +for each row execute procedure acs_persons__utrg (); + + + + + Index: openacs-4/packages/acs-person/sql/postgresql/acs-person-sc-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/sql/postgresql/Attic/acs-person-sc-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/sql/postgresql/acs-person-sc-drop.sql 24 Sep 2002 05:24:47 -0000 1.1 @@ -0,0 +1,23 @@ +select acs_sc_binding__delete( + 'FtsContentProvider', -- contract_name + 'acs_person' -- impl_name +); + +select acs_sc_impl__delete( + 'FtsContentProvider', -- impl_contract_name + 'acs_person' -- impl_name +); + + + + +drop trigger acs_persons__utrg on acs_persons; +drop trigger acs_persons__dtrg on acs_persons; +drop trigger acs_persons__itrg on acs_persons; + + + +drop function acs_persons__utrg (); +drop function acs_persons__dtrg (); +drop function acs_persons__itrg (); + Index: openacs-4/packages/acs-person/www/add-edit-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/add-edit-oracle.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,48 @@ + + + + oracle8.1.6 + + + + + declare + id integer; + begin + id := contact.new ( + family_name => :family_name, + given_name => :given_name, + middle_name => :middle_name, + formatted_name => :formatted_name, + preferred_given_name => :preferred_given_name, + affix => :affix, + suffix => :suffix, + title => :title, + email => :email, + category_id => :category_id, + company_name => :company_name, + company_type_id => :company_type_id, + notes => :notes, + creation_user => :user_id, + creation_ip => :peeraddr, + context_id => :package_id + ); + + acs_permission.grant_permission( + object_id => id, + grantee_id => :user_id, + privilege => 'write' + ); + + acs_permission.grant_permission ( + object_id => id, + grantee_id => :user_id, + privilege => 'delete' + ); + end; + + + + + + Index: openacs-4/packages/acs-person/www/add-edit-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/add-edit-postgresql.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,38 @@ + + + + postgresql7.1 + + + + select acs_person__new ( + :given_name, + :middle_name, + :family_name, + :formatted_name, + :preferred_given_name, + :acs_user_id, + :user_id, + :peeraddr, + :package_id + ); + + + + + + + select acs_person__set ( + :given_name, + :middle_name, + :family_name, + :formatted_name, + :preferred_given_name, + :acs_user_id, + :acs_person_id + ); + + + + + Index: openacs-4/packages/acs-person/www/add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/add-edit.adp 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,5 @@ + +@page_title@ + + + Index: openacs-4/packages/acs-person/www/add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/add-edit.tcl 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,133 @@ +# packages/acs-person/www/add-edit.tcl + +ad_page_contract { + @author Jon Griffin jon@jongriffin.com + @creation-date 2002-09-21 + @cvs-id $Id: add-edit.tcl,v 1.1 2002/09/24 05:23:52 jong Exp $ +} { + acs_person_id:integer,notnull,optional + {family_name ""} + {given_name ""} + {middle_name ""} + {formatted_name ""} + {preferred_given_name ""} + {affix ""} + {suffix ""} + {title ""} + {acs_user_id ""} +} -properties { + context_bar:onevalue + page_title:onevalue +} + +set package_id [ad_conn package_id] + +## vars for quasi localization +## since this isn't available yet this is a reminder to myself + +set cbar_title "Person Info" +#set cbar_title "Informacion de una persona" +set page_title_e "Edit Person" +set page_title_c "Create Person" + +if {[info exists acs_person_id]} { + ad_require_permission $acs_person_id write + set page_title $page_title_e + set context_bar [ad_context_bar [list "." $cbar_title ] [list "one?acs_person_id=$acs_person_id" $cbar_title] $page_title] +} else { + ad_require_permission $package_id create + set page_title $page_title_c + set context_bar [ad_context_bar [list "." $cbar_title] $page_title ] +} + +template::form create new_person + +if {[template::form is_request new_person] && [info exists acs_person_id]} { + + template::element create new_person acs_person_id \ + -widget hidden \ + -datatype number \ + -value $acs_person_id + + db_1row person_select { } + +} + +template::element create new_person affix \ + -datatype text \ + -label "Affix" \ + -html { size 20 } \ + -value $affix + +template::element create new_person given_name \ + -datatype text \ + -label "First Name" \ + -html { size 40 } \ + -value $given_name + +template::element create new_person middle_name \ + -datatype text \ + -label "Middle" \ + -html { size 30 } \ + -value $middle_name + +template::element create new_person family_name \ + -datatype text \ + -label "Last Name" \ + -html { size 40 } \ + -value $family_name + +template::element create new_person formatted_name \ + -datatype text \ + -label "Formatted Name" \ + -html { size 40 } \ + -value $formatted_name + +template::element create new_person preferred_given_name \ + -datatype text \ + -label "Preferred Name" \ + -html { size 40 } \ + -value $preferred_given_name + +template::element create new_person suffix \ + -datatype text \ + -label "Suffix" \ + -html { size 20 } \ + -value $suffix + +template::element create new_person spacer3 \ + -datatype text \ + -widget inform \ + -label "" \ + -value "
" + +template::element create new_person acs_user_id \ + -datatype text \ + -label "ACS User" \ + -html { size 20 } \ + -value $acs_user_id + +####################################### +### start of processing of update/new +####################################### +## this will only update the person part + +if [template::form is_valid new_person] { + set user_id [ad_conn user_id] + set peeraddr [ad_conn peeraddr] + + if [info exists acs_person_id] { + db_exec_plsql set_person { + } +} else { + db_exec_plsql new_person { + } +} + + ad_returnredirect "." +} + +ad_return_template + + + Index: openacs-4/packages/acs-person/www/add-edit.tcl.sav =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit.tcl.sav,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/add-edit.tcl.sav 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,223 @@ +# packages/contacts/www/add-edit.tcl + +ad_page_contract { + @author Jon Griffin jon@jongriffin.com + @creation-date 2002-01-11 + @cvs-id $Id: add-edit.tcl.sav,v 1.1 2002/09/24 05:23:52 jong Exp $ +} { + contact_id:integer,notnull,optional + {family_name ""} + {given_name ""} + {middle_name ""} + {formatted_name ""} + {preferred_given_name ""} + {affix ""} + {company_name ""} + {company_type_id ""} + {category_id ""} + {notes ""} +} -properties { + context_bar:onevalue +} + +set package_id [ad_conn package_id] + +# get the company types +# note make sure this is subsite aware. + +query company_types multilist "select company_type_name, company_type_id from company_types" +query categories multilist "select category_name, category_id from contact_categories" + + +if {[info exists contact_id]} { + ad_require_permission $contact_id write + set context_bar [ad_context_bar "Edit Contact"] +} else { + ad_require_permission $package_id create + set context_bar [ad_context_bar "New contact"] +} + +template::form create new_contact + +if {[template::form is_request new_contact] && [info exists contact_id]} { + + template::element create new_contact contact_id \ + -widget hidden \ + -datatype number \ + -value $contact_id + + db_1row contact_select { + select c.contact_id, + family_name, + given_name, + middle_name, + formatted_name, + preferred_given_name, + affix, + company_name, + company_type_id, + notes + from contacts c + where c.contact_id = :contact_id + } +} + +template::element create new_contact family_name \ + -datatype text \ + -label "Last Name" \ + -html { size 20 } \ + -value $family_name + +template::element create new_contact given_name \ + -datatype text \ + -label "First Name" \ + -html { size 10 } \ + -value $given_name + +template::element create new_contact middle_name \ + -datatype text \ + -label "Middle" \ + -html { size 30 } \ + -value $middle_name + +template::element create new_contact formatted_name \ + -datatype text \ + -label "Formatted Name" \ + -html { size 40 } \ + -value $formatted_name + +template::element create new_contact preferred_given_name \ + -datatype text \ + -label "Preferred Name" \ + -html { size 40 } \ + -value $preferred_given_name + +template::element create new_contact affix \ + -datatype text \ + -label "Affix" \ + -html { size 30 } \ + -value $affix + +template::element create new_contact company_name \ + -datatype text \ + -label "Company Name" \ + -html { size 40 } \ + -value $company_name + +template::element create new_contact company_type_id \ + -datatype text \ + -widget select \ + -label "Company Type" \ + -options $company_types \ + -value $company_type_id + + + +## category +template::element create new_contact category_id \ + -datatype text \ + -widget select \ + -label "Contact Category" \ + -options $categories \ + -value $category_id + +template::element create new_contact hr_add \ + -datatype text \ + -widget inform \ + -label "" \ + -value
+ +if { [info exists contact_id] } { + set link "

Edit Addresses

" +} else { + set link "" +} + +template::element create new_contact address_link \ + -datatype text \ + -widget inform \ + -label "" \ + -value $link + +if { [info exists contact_id] } { + set phono_link "Edit Phones" +} else { + set phono_link "" +} + +template::element create new_contact phone_link \ + -datatype text \ + -widget inform \ + -label "" \ + -value $phono_link + +##address +#template::form::section new_contact "Address Info" + +####################################### +### start of processing of update/new +####################################### +## this will only update the contact part +## seperate functions are needed for phone/address + +if [template::form is_valid new_contact] { + set user_id [ad_conn user_id] + set peeraddr [ad_conn peeraddr] + + if [info exists contact_id] { + db_dml note_update { + update contacts + set family_name = :family_name, + given_name = :given_name, + middle_name = :middle_name, + formatted_name = :formatted_name, + preferred_given_name = :preferred_given_name, + affix = :affix, + company_name = :company_name, + company_type_id = :company_type_id, + category_id = :category_id, + notes = :notes + where contact_id = :contact_id + } +} else { + db_dml new_contact { + declare + id integer; + begin + id := contact.new ( + given_name => :given_name, + middle_name => :middle_name, + formatted_name => :formatted_name, + preferred_given_name => :preferred_given_name, + affix => :affix, + company_name => :company_name, + company_type_id => :company_type_id, + category_id => :category_id, + notes => :notes, + creation_user => :user_id, + creation_ip => :peeraddr, + context_id => :package_id + ); + + acs_permission.grant_permission( + object_id => id, + grantee_id => :user_id, + privilege => 'write' + ); + + acs_permission.grant_permission ( + object_id => id, + grantee_id => :user_id, + privilege => 'delete' + ); + end; + } +} + + ad_returnredirect "." +} + +ad_return_template + + + Index: openacs-4/packages/acs-person/www/add-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/add-edit.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,20 @@ + + + + + + + select p.acs_person_id, + family_name, + given_name, + middle_name, + formatted_name, + preferred_given_name + from acs_persons p + where p.acs_person_id = :acs_person_id + + + + + + Index: openacs-4/packages/acs-person/www/delete-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/delete-2-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/delete-2-oracle.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,20 @@ + + + + oracle8.1.6 + + + + + begin + delete from acs_permissions + where object_id = :contact_id; + + contact.delete(:contact_id); + end; + + + + + + Index: openacs-4/packages/acs-person/www/delete-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/delete-2-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/delete-2-postgresql.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,14 @@ + + + + postgresql7.1 + + + + + select contact__del(:contact_id); + + + + + Index: openacs-4/packages/acs-person/www/delete-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/delete-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/delete-2.tcl 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + + @author Jon Griffin jon@jongriffin.com + @creation-date 2002-01-16 + @cvs-id $Id: delete-2.tcl,v 1.1 2002/09/24 05:23:52 jong Exp $ +} { + contact_id:integer,notnull +} + +ad_require_permission $contact_id delete + +db_exec_plsql contact_delete { + +} + +ad_returnredirect "." + Index: openacs-4/packages/acs-person/www/delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/delete.adp 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,10 @@ + +@title@ +@context_bar@ + +

@title@

+
+Are you sure you want to delete @one_contact.name@?
+ +Delete

+Return Index: openacs-4/packages/acs-person/www/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/delete.tcl 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,41 @@ +ad_page_contract { + + Delete Confirmation page for Contacts + + @author jon@jongriffin.com + @creation-date 2002-01-16 + @cvs-id $Id: delete.tcl,v 1.1 2002/09/24 05:23:52 jong Exp $ + +} { + contact_id:integer,notnull +} -validate { + contact_exists -requires {contact_id} { + if ![db_0or1row contact_exists { + select 1 from contacts where contact_id = :contact_id + }] { + ad_complain "Contact $contact_id does not exist" + return 0 + } + return 1 + } +} -properties { + title:onevalue + one_contact:onerow +} + +set title "Delete Contact" +set context_bar [ad_context_bar] +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +# make sure they don't perform URL surgery +ad_require_permission $contact_id delete + +db_1row contact_select { + select contact_id, + given_name || ' ' || family_name as name + from contacts + where contact_id = :contact_id +} -column_array one_contact + + \ No newline at end of file Index: openacs-4/packages/acs-person/www/delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/delete.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,25 @@ + + + + + + + select 1 from contacts where contact_id = :contact_id + + + + + + + + + select contact_id, + given_name || ' ' || family_name as name + from contacts + where contact_id = :contact_id + + + + + + Index: openacs-4/packages/acs-person/www/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/index-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/index-oracle.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,26 @@ + + + + oracle8.1.6 + + + + + select contact_id, + family_name, + given_name, + middle_name, + company_name, + g.category_name as category + from contacts c, acs_objects o, contact_categories g + where c.contact_id = o.object_id + and c.category_type_id = g.category_type_id(+) + and o.context_id = :package_id + ${search_clause} + ${starts_with_clause} + order by $ordering + + + + + Index: openacs-4/packages/acs-person/www/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/index-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/index-postgresql.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,21 @@ + + + + postgresql7.1 + + + + select acs_person_id, + family_name, + given_name, + middle_name, + acs_permission__permission_p(acs_person_id,:user_id,'write') as write_p, + acs_permission__permission_p(acs_person_id,:user_id,'delete') as delete_p + from acs_objects o,acs_persons p + where p.acs_person_id = o.object_id + and o.context_id = :package_id + order by $ordering + + + + Index: openacs-4/packages/acs-person/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/index.adp 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,105 @@ + +@title@ +@context_bar@ + + +

@title@

+ + +
+ Admin +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + @first_letter.letter@ + + + @first_letter.letter@ + + + + All + + + All + + + Other + + + Other + +
+
+ + +
+ @starts_with@ : +
+
+ + +
+ Search results : +
+
+
Last NameFirst Name  
@persons.family_name@@persons.given_name@ + Edit  + + Delete  +
+ +

+@pagination_link@ + +
+ + + + + +

There are no people
 
+
+ + +
+
+ New Person +
+
+ Index: openacs-4/packages/acs-person/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/index.tcl 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,124 @@ +ad_page_contract { + + Displays a list of people + + @author Jon Griffin (jon@jongriffin.com) + @creation-date 2002-09-21 + @cvs-id $Id: index.tcl,v 1.1 2002/09/24 05:23:52 jong Exp $ +} { + {start:integer "1"} + {search_p 0} + {search_string ""} + {search_in ""} + {sort ""} + {starts_with ""} +} -properties { + context_bar:onevalue + package_id:onevalue + user_id:onevalue + persons:multirow + title:onevalue + first_letter:multirow + acs_persons_create_p:onevalue +} + + +set user_id [ad_verify_and_get_user_id] +set package_id [ad_conn package_id] + +set title "People" +set context_bar [ad_context_bar $title] + +set acs_persons_create_p [ad_permission_p $package_id create] +set admin_p [ad_permission_p $package_id admin] + + +db_multirow first_letter get_first_letters { } + + +switch $sort { + "fname" { set ordering "given_name, family_name, company_name" } + "lname" { set ordering "family_name, given_name, company_name" } + default { set ordering "family_name" } +} + +if { ![empty_string_p $starts_with] } { + switch $starts_with { + "all" { set starts_with_clause "" } + "other" { set starts_with_clause "and family_name is null" } + default { set starts_with_clause "and upper(family_name) like '${starts_with}%'" } + } + +} else { + set starts_with_clause "" +} + + +## should be able to get rid of this with search package +if { $search_p == 1 && ![string equal $search_string ""]} { + switch $search_in { + "fname" { set search_clause "and lower(given_name) like '%' || lower(:search_string) || '%'" } + "lname" { set search_clause "and lower(family_name) like '%' || lower(:search_string) || '%'" } + "any" { set search_clause "and (lower(family_name) like '%' || lower(:search_string) || '%' or + lower(given_name) like '%' || lower(:search_string) || '%')" } + } + +} else { + set search_clause "" +} + + +set max_dspl [ad_parameter MaxPersonsShow acs_persons 10] +set count 0 + +db_multirow persons acs_persons_select { } + +set total_contacts [db_string retrieved_contacts "select count(*) + from contacts c, acs_objects o + where c.contact_id = o.object_id + ${search_clause} + ${starts_with_clause}"] + +# and o.context_id = :package_id + +# make paging links +if { $count < [expr $start + $max_dspl] } { + set next_start "" +} else { + if {[expr $start + 2 * $max_dspl - $total_contacts] < 0 } { + set next_val $max_dspl + } else { + set next_val [expr $total_contacts - $start - $max_dspl + 1] + } + + set next_start "NEXT $next_val" +} + +if { $start == 1 } { + set prev_start "" +} else { + set prev_start "PREV $max_dspl" +} + +if { ![empty_string_p $next_start] && ![empty_string_p $prev_start] } { + set divider " | " +} else { + set divider "" +} + +if { [expr $start + $max_dspl - 1] > $total_contacts } { + if { $total_contacts == 0 } { + set start 0 } + set showing "Showing: $start - $total_contacts" +} else { + set showing "Showing: $start - [expr $start + $max_dspl - 1]" +} + +set pagination_link " $prev_start$divider$next_start " + + +## setup a status bar +# where o.context_id = :package_id +# and acs_permission.permission_p(contact_id, :user_id, 'read') = 't' + +ad_return_template Index: openacs-4/packages/acs-person/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/index.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/index.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,24 @@ + + + + + + + select distinct substr(upper(family_name), 0, 1) as letter from acs_persons + + + + + + + + select count(*) + from acs_persons p, acs_objects o + where p.acs_person_id = o.object_id + ${search_clause} + ${starts_with_clause} + + + + + Index: openacs-4/packages/acs-person/www/one-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/one-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/one-oracle.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,33 @@ + + + + oracle8.1.6 + + + + + select acs_person_id, + given_name, + family_name, + middle_name, + preferred_given_name, + formatted_name, + given_name || ' ' || family_name as pretty_name, + decode(acs_permission.permission_p(contact_id, + :user_id, + 'write'), + 't',1, + 'f',0) as write_p, + decode(acs_permission.permission_p(contact_id, + :user_id, + 'delete'), + 't',1, + 'f',0) as delete_p + from acs_persons p + where acs_person_id = :acs_person_id + + + + + + Index: openacs-4/packages/acs-person/www/one-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/one-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/one-postgresql.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,25 @@ + + + + postgresql7.1 + + + + select acs_person_id, + given_name, + family_name, + middle_name, + preferred_given_name, + formatted_name, + given_name || ' ' || family_name as pretty_name, + case when acs_permission__permission_p(acs_person_id,:user_id,'write') = 't' + then 1 else 0 end as write_p, + case when acs_permission__permission_p(acs_person_id,:user_id,'delete') = 't' + then 1 else 0 end as delete_p + from acs_persons p + where acs_person_id = :acs_person_id + + + + + Index: openacs-4/packages/acs-person/www/one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/one.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/one.adp 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,39 @@ + +@page_title@ @person.pretty_name@ + +

@page_title@

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
First Name @person.given_name@
Middle Name @person.middle_name@
Family Name @person.family_name@
Preferred Name @person.preferred_given_name@
Formatted Name @person.formatted_name@
+ edit info +
+
+ + Index: openacs-4/packages/acs-person/www/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/one.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/one.tcl 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,42 @@ +# packages/acs-person/www/one.tcl + +ad_page_contract { + @author Jon Griffin jon@jongriffin.com + @creation-date 2002-09-21 + @cvs-id $Id: one.tcl,v 1.1 2002/09/24 05:23:52 jong Exp $ +} { + acs_person_id:integer,notnull +} -validate { + person_exists -requires {person_id} { + if ![db_0or1row person_exists { + }] { + ad_complain "$acs_person_id does not exist" + return 0 + } + return 1 + } +} -properties { + context_bar:onevalue + page_title:onevalue + person:onerow +} + +## vars for quasi localization +## since this isn't available yet this is a reminder to myself + +set page_title "Viewing" +set cbar_title "View One Person" + +## set cbar_title "Informacion de una persona" + +set context_bar [ad_context_bar $page_title] + +set user_id [ad_verify_and_get_user_id] + +set person_write_p [ad_permission_p $acs_person_id "write"] + +db_1row person_select { + +} -column_array person + + Index: openacs-4/packages/acs-person/www/one.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/one.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/one.xql 24 Sep 2002 05:23:52 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + + + select 1 from acs_persons where acs_person_id = :acs_person_id + + + + + + Index: openacs-4/packages/acs-person/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/admin/Attic/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/admin/index.adp 24 Sep 2002 05:24:08 -0000 1.1 @@ -0,0 +1,8 @@ + +@title@ +@context_bar@ + +

@title@

+
+Nothing Yet! + Index: openacs-4/packages/acs-person/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/admin/Attic/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-person/www/admin/index.tcl 24 Sep 2002 05:24:08 -0000 1.1 @@ -0,0 +1,27 @@ +ad_page_contract { + + Admin page for acs-person + + @author Jon Griffin (jon@jongriffin.com) + @creation-date 2002-09-21 + @cvs-id $Id: index.tcl,v 1.1 2002/09/24 05:24:08 jong Exp $ +} { +} -properties { + context_bar:onevalue + package_id:onevalue + user_id:onevalue + contacts:multirow + title:onevalue +} + +set package_id [ad_conn package_id] + +set title "Contacts Admin" +set context_bar [ad_context_bar $title] + +set user_id [ad_verify_and_get_user_id] + +## setup a status bar + + +ad_return_template