Index: openacs-4/packages/contacts/tcl/contacts-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-init.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/contacts/tcl/contacts-init.tcl 8 Jun 2005 05:10:58 -0000 1.7 +++ openacs-4/packages/contacts/tcl/contacts-init.tcl 28 Jun 2005 17:39:18 -0000 1.8 @@ -17,3 +17,68 @@ } { } } + + +if { [empty_string_p [info procs rel_types::create_role]] } { + + ns_log notice "rel_types::create_role didn't exist so we are adding it here" + namespace eval rel_types {} + ad_proc -public rel_types::create_role { + {-pretty_name:required} + {-pretty_plural:required} + {-role} + } { + + Create a new Relationship Role + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-04 + + @param pretty_name + + @param pretty_plural + + @param role + + @return 1 if successful + } { + if {![exists_and_not_null role]} { + set role [util_text_to_url \ + -text $pretty_name \ + -replacement "_" \ + -existing_urls [db_list get_roles {}]] + } + + set return_code 1 + + db_transaction { + + # Force internationalisation of Roles + + # Internationalising of Attributes. This is done by storing the + # attribute with it's acs-lang key + + set message_key "role_${role}" + + # Register the language keys + + lang::message::register en_US contacts $message_key $pretty_name + lang::message::register en_US contacts "${message_key}_plural" $pretty_plural + + # Replace the pretty_name and pretty_plural with the message key, so + # it is inserted correctly in the database + + set pretty_name "#contacts.${message_key}#" + set pretty_plural "#contacts.${message_key}_plural#" + db_exec_plsql create_role { + select acs_rel_type__create_role(:role, :pretty_name, :pretty_plural) + } + } on_error { + error $errmsg + set return_code 0 + } + return $return_code + } + + +}