Index: openacs-4/packages/acs-subsite/catalog/acs-subsite.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/catalog/acs-subsite.en_US.ISO-8859-1.xml,v diff -u -r1.78 -r1.79 --- openacs-4/packages/acs-subsite/catalog/acs-subsite.en_US.ISO-8859-1.xml 18 Nov 2007 21:27:10 -0000 1.78 +++ openacs-4/packages/acs-subsite/catalog/acs-subsite.en_US.ISO-8859-1.xml 27 Nov 2007 20:18:42 -0000 1.79 @@ -156,6 +156,7 @@ Welcome to %system_name% Enabled Enter your username to begin password recovery. + Erase Erase Portrait erase portrait Error Fisheye: Tag 1.7 refers to a dead (removed) revision in file `openacs-4/packages/acs-subsite/www/user/portrait/erase-2.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-subsite/www/user/portrait/erase.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/erase.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-subsite/www/user/portrait/erase.adp 21 Nov 2007 17:01:55 -0000 1.7 +++ openacs-4/packages/acs-subsite/www/user/portrait/erase.adp 27 Nov 2007 20:18:43 -0000 1.8 @@ -9,11 +9,4 @@

#acs-subsite.lt_Sure_erase_user_por#

-
-
-
@export_vars;noquote@
-

- -

-
-
+ Index: openacs-4/packages/acs-subsite/www/user/portrait/erase.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/erase.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-subsite/www/user/portrait/erase.tcl 10 Jan 2007 21:22:11 -0000 1.5 +++ openacs-4/packages/acs-subsite/www/user/portrait/erase.tcl 27 Nov 2007 20:18:43 -0000 1.6 @@ -23,10 +23,50 @@ ad_require_permission $user_id "write" if {$admin_p} { - set context [list [list "./?user_id=$user_id" "User's Portrait"] "Erase"] + set context [list [list "./?[export_vars user_id]" [_ acs-subsite.User_Portrait]] [_ acs-subsite.Erase]] } else { - set context [list [list "./" "Your Portrait"] "Erase"] + set context [list [list "./" [_ acs-subsite.Your_Portrait]] [_ acs-subsite.Erase]] } -set export_vars [export_form_vars user_id return_url] +if { $return_url eq "" } { + set return_url [ad_pvt_home] +} +ad_form -name "portrait_erase" -export {user_id return_url} -form {} -on_submit { + + set item_id [db_string get_item_id {} -default ""] + + if {$item_id eq ""} { + ad_returnredirect $return_url + ad_script_abort + } + + set resized_item_id [image::get_resized_item_id -item_id $item_id] + + # Delete the resized version + if {$resized_item_id ne ""} { + content::item::delete -item_id $resized_item_id + } + + # Delete all previous images + db_foreach get_images {} { + package_exec_plsql -var_list [list [list delete__object_id $object_id]] acs_object delete + } + + db_foreach old_item_id {} { + content::item::delete -item_id $object_id + } + + # Delete the relationship + db_dml delete_rel {} + + # Delete the item + content::item::delete -item_id $item_id + + # Flush the portrait cache + util_memoize_flush [list acs_user::get_portrait_id_not_cached -user_id $user_id] + + ad_returnredirect $return_url +} + +ad_return_template Index: openacs-4/packages/acs-subsite/www/user/portrait/erase.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/erase.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-subsite/www/user/portrait/erase.xql 27 Nov 2007 20:18:43 -0000 1.1 @@ -0,0 +1,46 @@ + + + + + + + + + + + select object_id_two + from acs_rels + where object_id_one = :user_id + and rel_type = 'user_portrait_rel' + + + + + + select object_id + from acs_objects + where object_type in ('cr_item_child_rel','image') + and context_id = :item_id + and object_id not in (select live_revision from cr_items where item_id = :item_id) + + + + + + select object_id + from acs_objects + where object_type = 'content_item' + and context_id = :item_id + + + + + + delete from acs_rels + where object_id_two = :item_id + and object_id_one = :user_id + and rel_type = 'user_portrait_rel' + + + + \ No newline at end of file