Index: openacs-4/contrib/packages/photobook/lib/person-employment.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/lib/person-employment.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/lib/person-employment.adp 3 Nov 2003 20:10:55 -0000 1.1 +++ openacs-4/contrib/packages/photobook/lib/person-employment.adp 18 Mar 2004 22:45:41 -0000 1.2 @@ -2,16 +2,19 @@
- +

Summer internship

-

@phb_spans.institution@

+

@phb_spans.institution_position@

+

@phb_spans.institution_company@

+

@phb_spans.institution_city@

+

@phb_spans.institution_state@

UROP

-

@phb_person.urop_1@

-

@phb_person.urop_2@

+

@phb_person.urop_1@, Professor: @phb_person.urop_professor_1@

+

@phb_person.urop_2@, Professor: @phb_person.urop_professor_2@

Index: openacs-4/contrib/packages/photobook/lib/person-facebook.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/lib/person-facebook.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/lib/person-facebook.adp 3 Nov 2003 20:10:55 -0000 1.1 +++ openacs-4/contrib/packages/photobook/lib/person-facebook.adp 18 Mar 2004 22:45:41 -0000 1.2 @@ -1,9 +1,10 @@

- @phb_person.salutation@ @phb_person.full_name@ + @phb_person.salutation@  + @phb_person.full_name@ (@phb_person.preferred_name@) - @phb_person.role@ +
@phb_person.role@

(@phb_person.former_name@)

Spouse/Partner: @phb_person.partner_firstname@ @phb_person.partner_lastname@ @@ -59,4 +60,4 @@

@phb_person.email_primary@
-
\ No newline at end of file + Index: openacs-4/contrib/packages/photobook/lib/person-profile.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/lib/person-profile.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/lib/person-profile.adp 3 Nov 2003 20:10:55 -0000 1.1 +++ openacs-4/contrib/packages/photobook/lib/person-profile.adp 18 Mar 2004 22:45:41 -0000 1.2 @@ -68,9 +68,12 @@ - -

Past employers: @phb_person.past_employers@

+ +

Past employer: @phb_person.past_employer_company_1@, @phb_person.past_employer_citystate_1@

+ +

Past employer: @phb_person.past_employer_company_2@, @phb_person.past_employer_citystate_2@

+
@@ -79,9 +82,13 @@

- UROP: @phb_person.urop_1@ + UROP: @phb_person.urop_1@ + Professor: @phb_person.urop_professor_1@ + and - @phb_person.urop_2@ + @phb_person.urop_2@ + Professor: @phb_person.urop_professor_2@ +

Education

Index: openacs-4/contrib/packages/photobook/lib/person-thumbnail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/lib/person-thumbnail.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/lib/person-thumbnail.adp 3 Nov 2003 20:10:55 -0000 1.1 +++ openacs-4/contrib/packages/photobook/lib/person-thumbnail.adp 18 Mar 2004 22:45:41 -0000 1.2 @@ -3,10 +3,8 @@

@phb_person.full_name@ (@phb_person.preferred_name@) - @phb_person.role@
(@phb_person.former_name@)
- - +
@phb_person.role@

@phb_person.program@

@@ -15,4 +13,4 @@ -
\ No newline at end of file + Index: openacs-4/contrib/packages/photobook/lib/person.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/lib/person.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/lib/person.adp 3 Nov 2003 20:10:55 -0000 1.1 +++ openacs-4/contrib/packages/photobook/lib/person.adp 18 Mar 2004 22:45:41 -0000 1.2 @@ -34,7 +34,7 @@ @nav.title@  - [edit | Manage portrait] + [edit | Manage portrait] Index: openacs-4/contrib/packages/photobook/lib/person.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/lib/person.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/lib/person.tcl 3 Nov 2003 20:10:55 -0000 1.1 +++ openacs-4/contrib/packages/photobook/lib/person.tcl 18 Mar 2004 22:45:41 -0000 1.2 @@ -78,28 +78,59 @@ set pre ", " } - db_multirow -append=[expr $i > 0] -extend role phb_all get_user_defaults "select c.user_id as def_user_id, - c.first_names as def_first_name, - c.last_name as def_last_name, - c.email as def_outside, - c.url as user_url, - c.creation_date, - c.member_state, - s.efl, s.alias, s.outside, + # when possible, we want to sort by the users role in the community first, + # then by their name. But this code can be used outside of a community + # as well, so we have to handle that case too, by sorting by name only + set community_id [dotlrn_community::get_community_id] + if { [string length $community_id] > 0 } { + db_multirow -append=[expr $i > 0] -extend role phb_all get_user_defaults "select pe.person_id as def_user_id, + pe.first_names as def_first_name, + pe.last_name as def_last_name, + pa.email as def_outside, + pa.url as user_url, + s.efl, s.alias, s.outside, decode(p.mime_type,'image/jpeg','jpg','image/gif','gif',decode(p.relation_tag,null,'','jpg')) as image_type - FROM cc_users c, sloan_email s, phb_portraits p - WHERE c.user_id in (${user_list}) - and s.user_id(+) = c.user_id - and p.user_id(+) = c.user_id + FROM persons pe, parties pa, sloan_email s, phb_portraits p, dotlrn_member_rels_approved r + WHERE pe.person_id in (${user_list}) + and pe.person_id = pa.party_id + and s.user_id(+) = pe.person_id + and p.user_id(+) = pe.person_id and p.relation_tag(+) = 'portrait_web' - order by upper(c.last_name), upper(c.first_names)" \ + and pe.person_id = r.user_id + and r.community_id = [dotlrn_community::get_community_id] + order by decode(r.role, + 'instructor',1, + 'admin',2, + 'teaching_assistant',3, + 'course_assistant',4, + 'course_admin',5, + 'student',6, + 'member',7), pe.last_name, pe.first_names" \ { set role $user_role($def_user_id) } + } else { + db_multirow -append=[expr $i > 0] -extend role phb_all get_user_defaults "select pe.person_id as def_user_id, + pe.first_names as def_first_name, + pe.last_name as def_last_name, + pa.email as def_outside, + pa.url as user_url, + s.efl, s.alias, s.outside, + decode(p.mime_type,'image/jpeg','jpg','image/gif','gif',decode(p.relation_tag,null,'','jpg')) as image_type + FROM persons pe, parties pa, sloan_email s, phb_portraits p + WHERE pe.person_id in (${user_list}) + and pe.person_id = pa.party_id + and s.user_id(+) = pe.person_id + and p.user_id(+) = pe.person_id + and p.relation_tag(+) = 'portrait_web' + order by pe.person_id, pe.first_names" \ + { + set role $user_role($def_user_id) + } + } } - if {![multirow size phb_all]} { ns_returnnotfound ad_script_abort @@ -126,16 +157,43 @@ # actually pull out the data # +# NOTE - this code was orinally very slow. I made a couple of changes. +# First I rewrote the qery to use, for example, phb_person instead of +# phb_personx. This helped considerably (we were doing full table scans +# before), but it was still too slow. Then I decided that the list of +# item ids should be a bind variable, but you can't use a bind variable +# directly in an IN clause (Oracle sees it as one string). The str2tbl +# function came from Tom Kyte (http://asktom.oracle.com) +# +# The big catch here is that the value passed to str2tbl can't be longer +# than 4000 characters. I did not attempt to fix this properly here; this +# code will probably be rewritten for phase 2 and I've already spent longer +# than I should have getting this to work. The max ids that will fit in 4000 +# chars is actually 500, but I cut it back to 450 to allow for the numbers to +# get longer as the object_ids get larger. This should suffice for now. +# +# I also tried inserting the ids into a temporary table and then having a +# simple select in the IN clause. It worked and looked nicer but took about +# twice as long to run as this does. +# +# Janine Sisk, 2-25-04 + +set max_ids 450 + foreach type [array name ids] { if {[string equal image $type] || ![llength $ids($type)]} { # Do not retrieve images or things with no rows. } else { - for {set i 0} {[llength $ids($type)] > [expr {$i * $max_in_items}]} {incr i} { + # need type name without prefix for id column + set id_col "[string range $type 4 end]_id" + for {set i 0} {[llength $ids($type)] > [expr {$i * $max_ids}]} {incr i} { + set id_list "[join [lrange $ids($type) [expr $i * $max_ids] [expr {($i+1)*$max_ids - 1}]] ","]" db_multirow -append=[expr $i > 0] $type get " - SELECT i.parent_id, r.relation_tag, t.item_id, t.revision_id, t.name, [join [phb::type_attributes $type] ", "] - FROM ${type}x t, cr_items i, cr_child_rels r - WHERE t.item_id in ([join [lrange $ids($type) [expr $i * $max_in_items] [expr {($i+1)*$max_in_items - 1}]] ", "]) - and t.revision_id = i.latest_revision + SELECT i.parent_id, r.relation_tag, rev.item_id, rev.revision_id, i.name, [join [phb::type_attributes $type] ", "] + FROM ${type} t, cr_items i, cr_child_rels r, cr_revisions rev + WHERE rev.item_id in (select * from table ( cast ( str2tbl(:id_list) as myTableType))) + and rev.revision_id = i.latest_revision + and t.${id_col} = rev.revision_id and r.parent_id(+) = i.parent_id and r.child_id(+) = i.item_id" \ { @@ -216,41 +274,66 @@ eval template::multirow extend phb_all [phb::type_attributes phb_person] item_id private_p photobook_user +# NOTE - this code originally walked through phb_all, and started over again +# at the beginning of phb_person each time, looking for a match. This was +# very, very slow. Now I create lists of lists, one from phb_all and one from +# phb_persons, each containing the user_id and it's actual location the array. +# We now walk through the lists at the same time, treating the one from phb_all +# as the master list. If there is a match to phb_person, we process it and +# move down both lists. If not, we process the record and only move down phb_all. +# We can do this because we know that every phb_person will be in phb_all. +# This code is now very fast. +# +# set up the lists of lists. +set phb_all_users [list] +set phb_person_users [list] for {set i 1} {$i <= [multirow size phb_all]} {incr i} { - set found_p 0 - for {set j 1} {$j <= [multirow size phb_person]} {incr j} { - if {[set phb_all:${i}(def_user_id)] == [set phb_person:${j}(user_id)]} { - set found_p 1 - array set phb_all:${i} [array get phb_person:${j}] - set phb_all:${i}(photobook_user) 1 - if {[exists_and_not_null phb_all:${i}(priv_$mode)]} { - set phb_all:${i}(private_p) [expr {[set phb_all:${i}(priv)] || [set phb_all:${i}(priv_$mode)]}] - } else { - set phb_all:${i}(private_p) [set phb_all:${i}(priv)] - } - foreach var {first_name last_name} { - if {![exists_and_not_null phb_all:${i}($var)]} { - set phb_all:${i}($var) [set phb_all:${i}(def_$var)] - } - } - break + lappend phb_all_users [list [set phb_all:${i}(def_user_id)] $i] +} +set phb_all_users [lsort $phb_all_users] +for {set i 1} {$i <= [multirow size phb_person]} {incr i} { + lappend phb_person_users [list [set phb_person:${i}(user_id)] $i] +} +set phb_person_users [lsort $phb_person_users] + +# walk through the list from phb_all +set phb_person_users_index 0 +for {set i 0} {$i < [llength $phb_all_users]} {incr i} { + set phb_all_user_id [lindex [lindex $phb_all_users $i] 0] + set phb_all_index [lindex [lindex $phb_all_users $i] 1] + set phb_person_user_id [lindex [lindex $phb_person_users $phb_person_users_index] 0] + set phb_person_index [lindex [lindex $phb_person_users $phb_person_users_index] 1] + if {$phb_all_user_id == $phb_person_user_id} { + # we found a match + incr phb_person_users_index + array set phb_all:${phb_all_index} [array get phb_person:${phb_person_index}] + set phb_all:${phb_all_index}(photobook_user) 1 + if {[exists_and_not_null phb_all:${phb_all_index}(priv_$mode)]} { + set phb_all:${phb_all_index}(private_p) [expr {[set phb_all:${phb_all_index}(priv)] || [set phb_all:${phb_all_index}(priv_$mode)]}] + } else { + set phb_all:${phb_all_index}(private_p) [set phb_all:${phb_all_index}(priv)] } - } - if {!$found_p} { + foreach var {first_name last_name} { + if {![exists_and_not_null phb_all:${phb_all_index}($var)]} { + set phb_all:${phb_all_index}($var) [set phb_all:${phb_all_index}(def_$var)] + } + } + } else { + # we didn't find a match, so just use the basics (user has not + # entered any profile data yet) foreach var {user_id first_name last_name outside} { - set phb_all:${i}($var) [set phb_all:${i}(def_$var)] + set phb_all:${phb_all_index}($var) [set phb_all:${phb_all_index}(def_$var)] } foreach var {salutation} { - set phb_all:${i}($var) {} + set phb_all:${phb_all_index}($var) {} } foreach var {private_p photobook_user} { - set phb_all:${i}($var) 0 + set phb_all:${phb_all_index}($var) 0 } } } - # Add any synthetic fields... # # @@ -438,14 +521,19 @@ outside_interest_3 outside_interest_3 partner_firstname partner_firstname partner_lastname partner_lastname - past_employers past_employers + past_employer_company_1 past_employer_company_1 + past_employer_citystate_1 past_employer_citystate_1 + past_employer_company_2 past_employer_company_2 + past_employer_citystate_2 past_employer_citystate_2 preferred_graduation preferred_graduation program program salutation salutation status status status_note status_note urop_1 urop_1 + urop_professor_1 urop_professor_1 urop_2 urop_2 + urop_professor_2 urop_professor_2 photobook_user photobook_user children children languages languages @@ -464,7 +552,10 @@ ended "Ended" } phb_span internship { - institution "Company" + institution_position "Position" + institution_company "Company" + institution_city "City" + institution_state "State" } phb_span job_current { institution "Employer" @@ -542,9 +633,9 @@ } if {[string equal $_type phb_span] && [string equal $_relation degree] - && [llength $rows] < 4 + && [llength $rows] < 6 } { - set rows [concat $rows [lrange {0 0 0 0} 0 [expr 3 - [llength $rows]]]] + set rows [concat $rows [lrange {0 0 0 0 0 0} 0 [expr 5 - [llength $rows]]]] } } else { set rows $i @@ -611,7 +702,7 @@ } } if {[string match "10" $phb_all(priv_employment)]} { - if {[lsearch [list past_employers] $_field] > -1} { + if {[lsearch [list past_employer_company_1 past_employer_citystate_1 past_employer_company_2 past_employer_citystate_2] $_field] > -1} { set output "$pre" } } Index: openacs-4/contrib/packages/photobook/sql/oracle/update/update-2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/sql/oracle/update/update-2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/photobook/sql/oracle/update/update-2.sql 18 Mar 2004 22:45:43 -0000 1.1 @@ -0,0 +1,25 @@ +-- this code comes from Thomas Kyte's book Expert One-on-One: Oracle. It's +-- used in lib/person.tcl, as a much faster way of selecting when the IN list +-- is very long. I tried a temporary table too, but it was considerably slower. + +create or replace type myTableType as table of number; +/ + + +create or replace function str2tbl( p_str in varchar2 ) return myTableType +as + l_str long default p_str || ','; + l_n number; + l_data myTableType := myTableType(); +begin + loop + l_n := instr(l_str, ','); + exit when (nvl(l_n,0) = 0); + l_data.extend; + l_data(l_data.count) := ltrim(rtrim(substr(l_str, 1, l_n-1))); + l_str := substr(l_str, l_n+1); + end loop; + return l_data; +end; +/ +show errors; Index: openacs-4/contrib/packages/photobook/tcl/photobook-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/tcl/photobook-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/tcl/photobook-procs.tcl 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/tcl/photobook-procs.tcl 18 Mar 2004 22:45:43 -0000 1.2 @@ -328,8 +328,10 @@ { expected_graduation d e e } { living_group e e a} { priv_living_group x x {} } - { urop_1 e e {e m}} - { urop_2 e e {e m}} + { urop_1 e e {e}} + { urop_professor_1 e e {e}} + { urop_2 e e {e}} + { urop_professor_2 e e {e}} { priv_urop x x {} } { concentration_1 e e e } { concentration_2 e e e } @@ -384,7 +386,10 @@ { language_3 e e p} { priv_language x x {} } { priv_portrait x x {} } - { past_employers e e m } + { past_employer_company_1 e e m } + { past_employer_citystate_1 e e m } + { past_employer_company_2 e e m } + { past_employer_citystate_2 e e m } { status x e {p z} } { status_note x e {p z} } } @@ -394,7 +399,11 @@ internship { return { { priv x x {}} - { institution e e {e m}} + { institution x x {}} + { institution_position e e {m}} + { institution_company e e {m}} + { institution_city e e {m}} + { institution_state e e {m}} { location x x {}} { department x x {}} { relation x x {}} @@ -408,6 +417,10 @@ return { { priv x x {}} { institution e e {m}} + { institution_position x x {m}} + { institution_company x x {m}} + { institution_city x x {m}} + { institution_state x x {m}} { location e e {m}} { department x x {}} { relation e e {m}} @@ -420,6 +433,10 @@ return { { priv x x {}} { institution e e e} + { institution_position x x {m}} + { institution_company x x {m}} + { institution_city x x {m}} + { institution_state x x {m}} { location x x {}} { department e e e} { relation e e e} @@ -608,7 +625,7 @@ set prefixes {} - array set section {{} "Personal data" a "Contact information" m "
Undergraduates
" e "Educational history" p "Personal data" z "Admin view"} + array set section {{} "Personal data" a "Contact information" m "
Undergraduates Only

Past Employers

" e "

Educational history

" p "Personal data" z "Admin view"} # Now go through the item types and see if we need to add each one @@ -722,7 +739,10 @@ -exclude $exclude \ -hidden {name span_type} - template::element set_properties $form_name ${prefix}institution label "Company" + template::element set_properties $form_name ${prefix}institution_position label "Position" + template::element set_properties $form_name ${prefix}institution_company label "Company" + template::element set_properties $form_name ${prefix}institution_city label "City" + template::element set_properties $form_name ${prefix}institution_state label "State" template::element set_properties $form_name ${prefix}span_type value internship } @@ -737,7 +757,7 @@ -content_type phb_span \ -content_method no_content \ -prefix $prefix \ - -section "
Graduate students
Current employer" \ + -section "
Graduate students Only
Current employer" \ -name "${base}_job_current" \ -relation "job_current" \ -item_id $child(phb_span.job_current) \ @@ -776,17 +796,37 @@ if {[phb::form::ask -admin=$admin_p degree $form_type]} { # Past Degrees set exclude [concat $exclude_base [phb::form::excludes -admin=$admin_p degree $form_type]] - foreach n {1 2 3 4} { + foreach n {1 2 3 4 5 6} { set prefix deg${n}_ lappend prefixes $prefix + # ok, I know this is horrible... but it's the only way to make it + # look the way they want it to. + if { $n == 1 || $n == 2 } { + set degree Undergraduate + set suffix "(completed degree only)" + set degree_num $n + } elseif { $n == 3 || $n == 4 } { + set degree Masters + set suffix "(completed degree only)" + set degree_num [expr $n - 2] + } elseif { $n == 5 } { + set degree PhD + set suffix "(completed degree only)" + set degree_num {} + } else { + set degree Other + set suffix "(Study Abroad, etc)" + set degree_num {} + } + content::new_item_form -form_name $form_name \ -parent_id $root_id \ -content_type phb_span \ -content_method no_content \ -prefix $prefix \ - -section "Past degree $n" \ + -section "$degree degree $degree_num $suffix" \ -name "${base}_degree_$n" \ -relation "degree" \ -item_id [lindex $child(phb_span.degree) [expr $n - 1]] \ @@ -1651,17 +1691,23 @@ } set child($parent_type.parent) $item_ids - set id_csv [join $item_ids {, }] - if {![empty_string_p $id_csv]} { - db_foreach children "SELECT child_type, c.relation_tag, rel.child_id - FROM cr_type_children c, acs_object_types o, cr_child_rels rel - WHERE c.child_type = o.object_type - and c.parent_type = :parent_type - and rel.relation_tag = c.relation_tag - and rel.parent_id in ($id_csv)" { - lappend child($child_type.$relation_tag) $child_id - } + set id_count [llength $item_ids] + set max_in_items 1000 + + for {set i 0} {$id_count > [expr {$i * $max_in_items}]} {incr i} { + set id_csv [join [lrange $item_ids [expr $i * $max_in_items] [expr {($i+1)*$max_in_items - 1}]] ","] + + if {![empty_string_p $id_csv]} { + db_foreach children "SELECT child_type, c.relation_tag, rel.child_id + FROM cr_type_children c, acs_object_types o, cr_child_rels rel + WHERE c.child_type = o.object_type + and c.parent_type = :parent_type + and rel.relation_tag = c.relation_tag + and rel.parent_id in ($id_csv)" { + lappend child($child_type.$relation_tag) $child_id + } + } } return [array get child] Index: openacs-4/contrib/packages/photobook/www/ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/ae.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/ae.adp 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/ae.adp 18 Mar 2004 22:45:43 -0000 1.2 @@ -10,7 +10,7 @@ @forms.name@ - Edit @form_name@ data [ Display ] + Edit @form_name@ data [ Display/Manage Portrait ]
 
@@ -34,4 +34,4 @@ Privacy Settings.

- + Index: openacs-4/contrib/packages/photobook/www/ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/ae.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/ae.tcl 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/ae.tcl 18 Mar 2004 22:45:43 -0000 1.2 @@ -93,15 +93,15 @@ if {![empty_string_p $alias]} { if {![regexp {^[A-Za-z0-9_]{3,20}$} $alias]} { template::element set_error phpb alias "Alias must be 3-20 characters and may only contain letters, numbers, and \"_\"" - } elseif {!$admin_p && ![phb::email_available [string trim $alias] $user_id]} { + } elseif {![phb::email_available [string trim $alias] $user_id]} { template::element set_error phpb alias "\"$alias\" is already in use. Please choose another alias." } } if {![empty_string_p $efl]} { if {![regexp {^[A-Za-z0-9._]{3,}$} $efl]} { template::element set_error phpb efl "EFL may only contain letters, numbers, \"_\" and \".\"" - } elseif {!$admin_p && ![phb::email_available [string trim $efl] $user_id]} { + } elseif {![phb::email_available [string trim $efl] $user_id]} { template::element set_error phpb efl "\"$efl\" is already in use. Please choose another EFL." } } @@ -126,22 +126,30 @@ # Update sloan_email and parties tables as appropriate set changed_login_p 0 - # we've had some trouble with students who have a pre-existing - # EFL, so can't enter their own, but can't have it set by an - # admin either because this row doesn't exist yet - if { [db_string email_row_ck "select count(*) from sloan_email where user_id = :user_id"] == 0 } { - db_dml insert_sloan { insert into sloan_email (user_id, outside, efl, alias, last_updated) values (:user_id, :outside, :efl, :alias, sysdate) } - } else { - db_dml update_sloan { update sloan_email set outside = :outside, efl = :efl, alias = :alias, last_updated = sysdate where user_id = :user_id} + + # only do these inserts if they have an efl (otherwise they're + # meaningless) + if { [info exists efl] } { + # if they have an efl they must have an alias, but they might not + # have filled in their forwarding address + if { ![info exists outside] } { + set outside "" + } + if { [db_string email_row_ck "select count(*) from sloan_email where user_id = :user_id"] == 0 } { + db_dml insert_sloan { insert into sloan_email (user_id, outside, efl, alias, last_updated) values (:user_id, :outside, :efl, :alias, sysdate) } + } else { + db_dml update_sloan { update sloan_email set outside = :outside, efl = :efl, alias = :alias, last_updated = sysdate where user_id = :user_id} + } + + if {![empty_string_p $alias]} { + set email_alias "$alias@sloan.mit.edu" + + set changed_login_p [db_string changed_login "select count(*) from dual where not exists (select * from parties where email = :email_alias and party_id = :user_id)"] + if { $changed_login_p } { + db_dml update_default_mail { update parties set email = :email_alias where party_id = :user_id } + } + } } - if {![empty_string_p $alias]} { - set email_alias "$alias@sloan.mit.edu" - - set changed_login_p [db_string changed_login "select count(*) from dual where not exists (select * from parties where email = :email_alias and party_id = :user_id)"] - if { $changed_login_p } { - db_dml update_default_mail { update parties set email = :email_alias where party_id = :user_id } - } - } } if {[exists_and_not_null return_url]} { Index: openacs-4/contrib/packages/photobook/www/new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/new.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/new.adp 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/new.adp 18 Mar 2004 22:45:43 -0000 1.2 @@ -38,4 +38,6 @@ can do this in your Profile at any time.

+ @only_one_msg@ + Index: openacs-4/contrib/packages/photobook/www/new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/new.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/new.tcl 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/new.tcl 18 Mar 2004 22:45:43 -0000 1.2 @@ -19,6 +19,11 @@ set efl {} +set name_display_mode "" +set alias_display_mode "" +set only_one_msg "" +set existing_efl_p 0 +set existing_alias_p 0 if {[empty_string_p $item_id] && [ db_0or1row current_data { select item_id, latest_revision @@ -31,13 +36,26 @@ select efl, alias, outside from sloan_email where user_id = :user_id } ] } { - # Is this users email or alias already defined - if {![string equal {} $efl] - || ![string equal {} $alias] - } { - ad_returnredirect "[phb::package_url]ae?form_type=a" - ad_script_abort - } + # handle case where they already have an EFL and/or an alias defined + if {![string equal {} $efl]} { + # they have an EFL but might not have an alias + if {![string equal {} $alias]} { + # they do have both, send them on their way + ad_returnredirect + ad_script_abort + } else { + set existing_efl_p 1 + set name_display_mode "display" + set only_one_msg "

You already have an EFL, so we just need you to enter your alias:

" + } + } else { + # no efl, but perhaps an alias + if {![string equal {} $alias]} { + set existing_alias_p 1 + set alias_display_mode "display" + set only_one_msg "

You already have an alias, so we just need you to enter your name for your EFL:

" + } + } } if {[empty_string_p $item_id]} { @@ -51,6 +69,8 @@ ad_return_error Error "User id $user_id does not exist" ad_script_abort } +# get alias if user already has one +set alias [db_string get-alias "select alias from sloan_email where user_id = :user_id" -default ""] ad_form -name new-user -export { item_id @@ -64,25 +84,28 @@ return_url } -form { {first_name:text(text) + {mode $name_display_mode} {label "First name"} {html {size 60 maxsize 200}} {value {[lindex $first_names 0]}} } - {middle_name:text(text) + {middle_name:text(text),optional + {mode $name_display_mode} {label "Middle names"} {html {size 60 maxsize 200}} {value {[lrange $first_names 1 end]}} - {optional} } {last_name:text(text) + {mode $name_display_mode} {label "Last name"} {html {size 60 maxsize 200}} {value $last_name} } - {alias:text(text) + {alias:text(text),optional + {mode $alias_display_mode} {label "Choose an email alias"} {html {size 60 maxsize 200}} - {optional} + {value $alias} } } -validate { {alias {[regexp {^[A-Za-z0-9_]*$} [string trim $alias]]} {Your email alias may only contain letters, numbers, and "_".}} @@ -98,7 +121,9 @@ db_transaction { # Need to lock excl the email table here. - phb::email_available $alias [ad_conn user_id] + if { !$existing_alias_p } { + phb::email_available $alias [ad_conn user_id] + } if {[empty_string_p $efl]} { set efl [phb::get_sloan_efl $first_name $middle_name $last_name $user_id] } @@ -108,7 +133,11 @@ cr::item::set_latest_revision_live -item_id $id # create the email record - db_dml create_sloan_email {insert into sloan_email(user_id, efl, alias, outside, last_updated) values (:user_id, :efl, :alias, :outside, sysdate)} + if { [db_string email_row_ck "select count(*) from sloan_email where user_id = :user_id"] == 0 } { + db_dml insert_sloan { insert into sloan_email (user_id, outside, efl, alias, last_updated) values (:user_id, :outside, :efl, :alias, sysdate) } + } else { + db_dml update_sloan { update sloan_email set outside = :outside, efl = :efl, alias = :alias, last_updated = sysdate where user_id = :user_id} + } set email_alias "$alias@sloan.mit.edu" db_dml update_default_mail { update parties set email = :email_alias where party_id = :user_id } Index: openacs-4/contrib/packages/photobook/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/search.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/search.tcl 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/search.tcl 18 Mar 2004 22:45:43 -0000 1.2 @@ -299,7 +299,7 @@ append sql "and p.priv = 0\n" } - if { ![string is space $q_institute_id]} { + if { $admin_p && ![string is space $q_institute_id]} { if {!$suppress} { append sql "and p.institute_id like '[__like $q_institute_id]'\n" } @@ -337,23 +337,23 @@ } } - if { ![string is space $q_gender] } { + if { $admin_p &&![string is space $q_gender] } { if {!$suppress} { append sql "and p.gender = :q_gender\n" } else { append sql "and p.gender = :q_gender and priv_gender = 0\n" } } - if { ![string is space $q_birthdate] } { + if { $admin_p && ![string is space $q_birthdate] } { if {!$suppress} { append sql "and p.birthdate = to_date(:q_birthdate, 'YYYY MM DD HH24 MI SS')\n" } else { append sql "and p.birthdate = to_date(:q_birthdate, 'YYYY MM DD HH24 MI SS') and priv_birthdate = 0\n" } } - if { ![string is space $q_ethnicity] } { + if { $admin_p && ![string is space $q_ethnicity] } { if {!$suppress} { append sql "and p.ethnicity = :q_ethnicity\n" } else { @@ -369,7 +369,7 @@ append sql "and p.priv_partner = 0 and lower(p.partner_firstname || ' ' || partner_lastname) like :q_partner_like\n" } } - if { ![string is space $q_child] } { + if { $admin_p && ![string is space $q_child] } { set q_child_like [__like $q_child] append sql "and ( lower(p.child_1) like :q_child_like @@ -382,7 +382,7 @@ } } - if { ![string is space $q_child_born] } { + if { $admin_p && ![string is space $q_child_born] } { append sql "and ( p.child_born_1 = :q_child_born or p.child_born_2 = :q_child_born @@ -435,22 +435,32 @@ set q_employment_like [__like $q_employment] if {!$suppress} { append sql "and ( - lower(p.past_employers) like :q_employment_like + lower(p.past_employer_company_1) like :q_employment_like + or lower(p.past_employer_citystate_1) like :q_employment_like + or lower(p.past_employer_company_2) like :q_employment_like + or lower(p.past_employer_citystate_2) like :q_employment_like or lower(p.urop_1) like :q_employment_like + or lower(p.urop_professor_1) like :q_employment_like or lower(p.urop_2) like :q_employment_like + or lower(p.urop_professor_2) like :q_employment_like or exists ( select 1 from phb_span emp, cr_items empi, cr_child_rels empr where empr.relation_tag IN ('job_current','job_past','internship') and empr.parent_id = p.item_id and empr.child_id = empi.item_id and empi.live_revision = emp.span_id - and lower (emp.institution || ' ' || emp.department || ' ' || emp.location) like :q_employment_like ) )\n" + and lower (emp.institution_position || ' ' || emp.institution_company || ' ' || emp.institution_city || ' ' || emp.institution_state || ' ' || emp.department || ' ' || emp.location) like :q_employment_like ) )\n" } else { append sql "and ( - (case when p.priv_past_employers = 0 then lower(p.past_employers) else '' end) like :q_employment_like + (case when p.priv_past_employers = 0 then lower(p.past_employer_company_1) else '' end) like :q_employment_like + (case when p.priv_past_employers = 0 then lower(p.past_employer_citystate_1) else '' end) like :q_employment_like + (case when p.priv_past_employers = 0 then lower(p.past_employer_company_2) else '' end) like :q_employment_like + (case when p.priv_past_employers = 0 then lower(p.past_employer_citystate_2) else '' end) like :q_employment_like or (case when p.priv_urop = 0 then lower(p.urop_1) else '' end) like :q_employment_like + or (case when p.priv_urop = 0 then lower(p.urop_professor_1) else '' end) like :q_employment_like or (case when p.priv_urop = 0 then lower(p.urop_2) else '' end) like :q_employment_like + or (case when p.priv_urop = 0 then lower(p.urop_professor_2) else '' end) like :q_employment_like or exists ( select 1 from phb_span emp, cr_items empi, cr_child_rels empr @@ -459,7 +469,7 @@ and empr.parent_id = p.item_id and empr.child_id = empi.item_id and empi.live_revision = emp.span_id - and lower (emp.institution || ' ' || emp.department || ' ' || emp.location) like :q_employment_like ) ) + and lower (emp.institution_position || ' ' || emp.institution_company || ' ' || emp.institution_city || ' ' || emp.institution_state || ' ' || emp.department || ' ' || emp.location) like :q_employment_like ) ) and priv_employment = 0\n" } } @@ -477,11 +487,11 @@ } } - if { ![string is space $q_grad_range_exp]} { + if { $admin_p && ![string is space $q_grad_range_exp]} { append sql "and p.expected_graduation = :q_grad_range_exp\n" } - if { ![string is space $q_grad_range_pref]} { + if { $admin_p && ![string is space $q_grad_range_pref]} { append sql "and p.preferred_graduation = :q_grad_range_pref\n" } @@ -506,7 +516,7 @@ if { ! [string is space $q_university] || ! [string is space $q_degree] || ! [string is space $q_major] - || ! [string is space $q_granted]} { + || ($admin_p && ! [string is space $q_granted])} { if {!$suppress} { append sql "and exists ( select 1 @@ -525,7 +535,7 @@ if { ! [string is space $q_major] } { append sql "and ed.department = :q_major\n" } - if { ! [string is space $q_granted] } { + if { $admin_p && ! [string is space $q_granted] } { append sql "and to_char(ed.ended,'YYYY') = :q_granted\n" } append sql ")\n" @@ -548,7 +558,7 @@ if { ! [string is space $q_major] } { append sql "and ed.department = :q_major\n" } - if { ! [string is space $q_granted] } { + if { $admin_p && ! [string is space $q_granted] } { append sql "and to_char(ed.ended,'YYYY') = :q_granted\n" } append sql ")\n" Index: openacs-4/contrib/packages/photobook/www/admin/add-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/admin/add-new.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/photobook/www/admin/add-new.tcl 18 Mar 2004 22:45:44 -0000 1.1 @@ -0,0 +1,324 @@ +ReturnHeaders + +ns_write "Starting...
\n" + +db_transaction { + ns_write "Doing UROP professors...
\n" + + # create new fields + + set type phb_person + + ns_write "Moving existing attributes...
\n" + + # first, increment existing sort_orders to make "holes" for the new + # fields. Do this starting with the largest numbers. + set start_at [db_string get "select sort_order from acs_attributes where attribute_name = 'urop_1' and object_type = 'phb_person'"] + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = :type and sort_order > [expr $start_at + 1] order by sort_order desc" { + db_dml update "update acs_attributes set sort_order = [expr $sort_order + 2] where object_type = :type and attribute_name = :attribute_name" + } + + # and move urop_2 up one, since we need to interleave the new fields + db_dml update "update acs_attributes set sort_order = [expr $start_at + 2] where object_type = :type and attribute_name = 'urop_2'" + + # Now create the acs attributes + + ns_write "Creating new attributes...
\n" + + set order [expr $start_at + 1] + foreach column { + {urop_professor_1 + {Professor 1} {Professor 1} + string {varchar(100)} {} } + {urop_professor_2 + {Professor 2} {Professor 2} + string {varchar(100)} {} } + } { + foreach {attribute pretty_name pretty_plural datatype column_spec default_value} $column { break } + + set column_spec [subst $column_spec] + + catch { cr::content_type::create_attribute \ + -content_type $type \ + -attribute_name $attribute \ + -datatype $datatype \ + -pretty_name $pretty_name \ + -pretty_plural $pretty_plural \ + -sort_order $order \ + -default_value $default_value \ + -column_spec $column_spec } err + ns_write "$err\n" + + incr order 2 + } + + ns_write "Creating new widgets...
\n" + + # now create the corresponding display widgets (no display widget for the + # privacy flag + foreach widget { + {urop_professor_1 text optional { + {size literal 60} + {maxlength literal 100}} + } + {urop_professor_2 text optional { + {size literal 60} + {maxlength literal 100}} + } + } { + foreach {key widget required params} $widget { break } + ns_write "Register: $key:$widget\n" + + cms_widget_register -content_type phb_person \ + -attribute $key \ + -widget $widget \ + -required=[string equal $required required] \ + -params $params + } + + ns_write "Done with UROP professors...
\n" +} + +db_transaction { + ns_write "Doing past_employers...
\n" + + # delete fields to get rid of, if any + + ns_write "Deleting old attribute...
\n" + + set attribute_id [db_string s "select attribute_id from acs_attributes where attribute_name = 'past_employers'"] + db_dml del_params {delete from cm_attribute_widget_params where attribute_id = :attribute_id} + db_dml del_widget {delete from cm_attribute_widgets where attribute_id = :attribute_id} + + # I tried this, but got "no function with name 'DROP_ATTRIBUTE' exists in this scope" + ## set result [db_exec_plsql create " + ## begin + ## :1 := content_type.drop_attribute ( + ## content_type => 'phb_person', + ## attribute_name => 'past_employers', + ## drop_column => 'f'); + ## end;"] + + # not wanting to wait to figure that out, I did it the brute force way: + db_dml del {delete from acs_attributes where object_type = 'phb_person' and attribute_name = 'past_employers'} + db_dml del {delete from acs_attributes where object_type = 'phb_person' and attribute_name = 'priv_past_employers'} + # seems to have worked... leaves the old field in the table so data can be + # retrieved + + # create replacement fields, if applicable + + set type phb_person + + ns_write "Moving existing attributes...
\n" + + # first, increment existing sort_orders to make "holes" for the new + # fields. Do this starting with the largest numbers. + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = :type and sort_order > 37 order by sort_order desc" { + db_dml update "update acs_attributes set sort_order = [expr $sort_order + 3] where object_type = :type and attribute_name = :attribute_name" + } + + # Now create the acs attributes + + ns_write "Creating new attributes...
\n" + + set order 38 + foreach column { + {past_employer_company_1 + {Company 1} {Company} + string {varchar(100)} {} } + {past_employer_citystate_1 + {City/State 1} {City/State} + string {varchar(100)} {} } + {past_employer_company_2 + {Company 2} {Professor} + string {varchar(100)} {} } + {past_employer_citystate_2 + {City/State 2} {City/State} + string {varchar(100)} {} } + {priv_past_employer + {Suppress past employer} {Suppress past employer} + integer integer 0 } + + } { + foreach {attribute pretty_name pretty_plural datatype column_spec default_value} $column { break } + + set column_spec [subst $column_spec] + + catch { cr::content_type::create_attribute \ + -content_type $type \ + -attribute_name $attribute \ + -datatype $datatype \ + -pretty_name $pretty_name \ + -pretty_plural $pretty_plural \ + -sort_order $order \ + -default_value $default_value \ + -column_spec $column_spec } err + ns_write "$err\n" + + incr order + } + + ns_write "Creating new widgets...
\n" + + # now create the corresponding display widgets (no display widget for the + # privacy flag + foreach widget { + {past_employer_company_1 text optional { + {size literal 60} + {maxlength literal 100}} + } + {past_employer_citystate_1 text optional { + {size literal 60} + {maxlength literal 100}} + } + {past_employer_company_2 text optional { + {size literal 60} + {maxlength literal 100}} + } + {past_employer_citystate_2 text optional { + {size literal 60} + {maxlength literal 100}} + } + } { + foreach {key widget required params} $widget { break } + ns_write "Register: $key:$widget\n" + + cms_widget_register -content_type phb_person \ + -attribute $key \ + -widget $widget \ + -required=[string equal $required required] \ + -params $params + } + + ns_write "Moving existing data to new fields...
\n" + + # and finally, move the old data to the new field. should delete the old field + # once this is for sure ok + db_foreach update "SELECT p.past_employers, p.user_id + FROM phb_personx p, cr_items i + WHERE p.item_id = i.item_id + and p.revision_id = i.live_revision + and p.past_employers is not null" { + if { [string length $past_employers] > 100 } { + set past_employers [string range $past_employers 0 99] + db_dml update "update phb_person set past_employer_company_1 = :past_employers where user_id = :user_id" + } + } + + ns_write "Done with past employers...
\n" +} + +db_transaction { + ns_write "Doing internship...
\n" + + # don't delete this time - the institution field is used by other data + # types that use phb_span + + # create new fields + + set type phb_span + + ns_write "Moving existing attributes...
\n" + + # first, increment existing sort_orders to make "holes" for the new + # fields. Do this starting with the largest numbers. Leave the existing + # institution field where it is and add the new ones after it. + set start_at [db_string get "select sort_order from acs_attributes where attribute_name = 'institution' and object_type = 'phb_span'"] + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = :type and sort_order > $start_at order by sort_order desc" { + db_dml update "update acs_attributes set sort_order = [expr $sort_order + 3] where object_type = :type and attribute_name = :attribute_name" + } + + # Now create the acs attributes + + ns_write "Creating new attributes...
\n" + + set order [expr $start_at + 1] + foreach column { + {institution_position + {Institution Position} {Institution Position} + string varchar(200) {} } + {institution_company + {Institution Company} {Institution Company} + string varchar(200) {} } + {institution_city + {Institution City} {Institution City} + string varchar(200) {} } + {institution_state + {Institution State} {Institution State} + string varchar(200) {} } + } { + foreach {attribute pretty_name pretty_plural datatype column_spec default_value} $column { break } + + set column_spec [subst $column_spec] + + catch { cr::content_type::create_attribute \ + -content_type $type \ + -attribute_name $attribute \ + -datatype $datatype \ + -pretty_name $pretty_name \ + -pretty_plural $pretty_plural \ + -sort_order $order \ + -default_value $default_value \ + -column_spec $column_spec } err + ns_write "$err\n" + + incr order + } + + ns_write "Creating new widgets...
\n" + + # now create the corresponding display widgets (no display widget for the + # privacy flag + foreach widget { + {institution_position text optional { + {size literal 60} + {maxlength literal 200} } + } + {institution_company text optional { + {size literal 60} + {maxlength literal 200} } + } + {institution_city text optional { + {size literal 60} + {maxlength literal 200} } + } + {institution_state text optional { + {size literal 60} + {maxlength literal 200} } + } + } { + foreach {key widget required params} $widget { break } + ns_write "Register: $key:$widget\n" + + cms_widget_register -content_type phb_span \ + -attribute $key \ + -widget $widget \ + -required=[string equal $required required] \ + -params $params + } + + ns_write "Moving existing data to new fields...
\n" + + # and finally, move the old data to the new field. should delete the old field + # once this is for sure ok + db_foreach update "SELECT t.span_id, t.institution + FROM phb_spanx t, cr_items i, cr_child_rels r + WHERE t.revision_id = i.live_revision + and r.parent_id = i.parent_id + and r.child_id = i.item_id + and t.institution is not null + and r.relation_tag = 'internship' + GROUP BY span_id, institution" { + db_dml update "update phb_span set institution_company = :institution where span_id = :span_id" + } + + ns_write "Done with internship...
\n" +} + +ns_write "Done...
\n" + +# other things to edit: +#in tcl/photobook-procs.tcl, every field group that uses phb_span has to include all the fields, with the extra internship ones turned off. + +#lib/person.tcl and lib/person-employment.adp both referred to the old internship fields and needed to be updated + Index: openacs-4/contrib/packages/photobook/www/admin/rearrange-order.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/admin/rearrange-order.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/photobook/www/admin/rearrange-order.tcl 18 Mar 2004 22:45:44 -0000 1.1 @@ -0,0 +1,62 @@ +ReturnHeaders + +ns_write "Starting...
\n" + +db_transaction { + + ns_write "Moving existing attributes...
\n" + + # first, increment existing sort_orders to make "holes" for the new + # fields. Do this starting with the largest numbers. + set start_at [db_string get "select sort_order from acs_attributes where attribute_name = 'urop_1' and object_type = 'phb_person'"] + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = 'phb_person' and sort_order >= $start_at order by sort_order desc" { + db_dml update "update acs_attributes set sort_order = [expr $sort_order + 3] where object_type = 'phb_person' and attribute_name = :attribute_name" + } + + ns_write "Moving fields into place...
\n" + + # move up the ones we're moving + set start_at2 [db_string get "select sort_order from acs_attributes where attribute_name = 'academic_interest_1' and object_type = 'phb_person'"] + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = 'phb_person' and sort_order >= $start_at2 and sort_order < [expr $start_at2 + 3] order by sort_order" { + db_dml update "update acs_attributes set sort_order = $start_at where object_type = 'phb_person' and attribute_name = :attribute_name" + incr start_at + } + + ns_write "Moving rest of fields up to fill gap...
\n" + + # and now fill in the hole where they were + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = 'phb_person' and sort_order > [expr $start_at2 + 2] order by sort_order" { + db_dml update "update acs_attributes set sort_order = sort_order - 3 where object_type = 'phb_person' and attribute_name = :attribute_name" + } + + # update labels + db_dml update "update acs_attributes set pretty_name = 'UROP 1
(undergrad only)' where pretty_name = 'UROP 1'" + db_dml update "update acs_attributes set pretty_name = 'Professor 1
(undergrad only)' where pretty_name = 'Professor 1'" + db_dml update "update acs_attributes set pretty_name = 'UROP 2
(undergrad only)' where pretty_name = 'UROP 2'" + db_dml update "update acs_attributes set pretty_name = 'Professor 2
(undergrad only)' where pretty_name = 'Professor 2'" +} + +db_transaction { + # make room for concentration + set start_at [db_string get "select sort_order from acs_attributes where attribute_name = 'urop_2' and object_type = 'phb_person'"] + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = 'phb_person' and sort_order >= $start_at order by sort_order desc" { + db_dml update "update acs_attributes set sort_order = [expr $sort_order + 1] where object_type = 'phb_person' and attribute_name = :attribute_name" + } + + # make room for concentration 2 + set start_at [db_string get "select sort_order from acs_attributes where attribute_name = 'urop_professor_1' and object_type = 'phb_person'"] + db_foreach get "select attribute_name, sort_order from acs_attributes where object_type = 'phb_person' and sort_order > $start_at order by sort_order desc" { + db_dml update "update acs_attributes set sort_order = [expr $sort_order + 2] where object_type = 'phb_person' and attribute_name = :attribute_name" + } + + # rearrange a bit (kludge, but things got out of order somewhere along the way + db_dml update "update acs_attributes set sort_order = 39 where object_type = 'phb_person' and attribute_name = 'urop_2'" + db_dml update "update acs_attributes set sort_order = 40 where object_type = 'phb_person' and attribute_name = 'urop_professor_2'" + db_dml update "update acs_attributes set sort_order = 42 where object_type = 'phb_person' and attribute_name = 'priv_urop'" + + # move them into place and update the labels + db_dml update "update acs_attributes set sort_order = 38, pretty_name = 'Concentration 1
(undergrad only)' where attribute_name = 'concentration_1'" + db_dml update "update acs_attributes set sort_order = 41, pretty_name = 'Concentration 2
(undergrad only)' where attribute_name = 'concentration_2'" +} + +ns_write "Done...
\n" Index: openacs-4/contrib/packages/photobook/www/admin/widget.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/admin/widget.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/admin/widget.tcl 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/admin/widget.tcl 18 Mar 2004 22:45:44 -0000 1.2 @@ -169,10 +169,18 @@ {size literal 60} {maxlength literal 100}} } + {urop_professor_1 text optional { + {size literal 60} + {maxlength literal 100}} + } {urop_2 text optional { {size literal 60} {maxlength literal 100}} } + {urop_professor_2 text optional { + {size literal 60} + {maxlength literal 100}} + } {concentration_1 select optional { {options eval {concat [phb::options -key concentration_ug ] [phb::options -key concentration_phd]}}} } Index: openacs-4/contrib/packages/photobook/www/image/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/photobook/www/image/index.vuh,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/photobook/www/image/index.vuh 3 Nov 2003 20:10:56 -0000 1.1 +++ openacs-4/contrib/packages/photobook/www/image/index.vuh 18 Mar 2004 22:45:44 -0000 1.2 @@ -16,12 +16,16 @@ if {($priv || $priv_portrait) && ![permission::permission_p -party_id [ad_conn user_id] -object_id [ad_conn package_id] -privilege admin] } { - ns_set update [ad_conn outputheaders] Cache-Control \ - "no-cache,max-age=0,must-revalidate,proxy-revalidate" + ns_set update [ns_conn outputheaders] "Expires" "-" + ns_set update [ns_conn outputheaders] "Last-Modified" "-" + ns_set update [ns_conn outputheaders] "Pragma" "no-cache" + ns_set update [ns_conn outputheaders] "Cache-Control" "no-cache" ns_returnfile 200 image/gif "[get_server_root]/packages/photobook/lib/noimage-$mode.gif" } else { - ns_set update [ad_conn outputheaders] Cache-Control \ - "no-cache,max-age=0,must-revalidate,proxy-revalidate" + ns_set update [ns_conn outputheaders] "Expires" "-" + ns_set update [ns_conn outputheaders] "Last-Modified" "-" + ns_set update [ns_conn outputheaders] "Pragma" "no-cache" + ns_set update [ns_conn outputheaders] "Cache-Control" "no-cache" cr_write_content -revision_id $image_revision_id } } else {