Index: openacs-4/packages/acs-subsite/tcl/email-image-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/email-image-procs.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/acs-subsite/tcl/email-image-procs.tcl 21 Dec 2018 15:13:54 -0000 1.20 +++ openacs-4/packages/acs-subsite/tcl/email-image-procs.tcl 21 Dec 2018 15:16:26 -0000 1.21 @@ -13,7 +13,7 @@ -level:required } { Changes the priv_email field from the users table - @param user_id + @param user_id @param level Change to this level } { db_transaction { @@ -67,12 +67,16 @@ {-transparent "" } {-subsite_id ""} } { - Returns the email in different ways (text level 4, image or text and image level 3, link level 2, ...) - according to the priv_email field in the users table. To create an image the ImageMagick software is required, - if ImageMagick is not present then the @ symbol in the email will be shown as an image. When creating an image - you can choose the background color (In this format \#xxxxxx). Also you can make the background color transparent - (1 or 0). + Returns the email in different ways (text level 4, image or text + and image level 3, link level 2, ...) according to the priv_email + field in the users table. To create an image the ImageMagick + software is required, if ImageMagick is not present then the @ + symbol in the email will be shown as an image. When creating an + image you can choose the background color (In this format + \#xxxxxx). Also you can make the background color transparent (1 + or 0). + @param return_url The url to return when the email is shown as a link @param bgcolor The Background color of the image. Default to \#ffffff @param transparent If the bgcolor is transparent. Default to 1 @@ -97,7 +101,7 @@ # The user has an email image stored in the content repository set revision_id [content::item::get_latest_revision -item_id $email_image_id] set img_src [ns_quotehtml "/shared/email-image-bits.tcl?user_id=$user_id&revision_id=$revision_id"] - return [subst {#acs-subsite.Email#}] + return [subst {#acs-subsite.Email#}] } else { # Create a new email_image if { [catch { set email_image [email_image::new_item -user_id $user_id -return_url $return_url -bgcolor $bgcolor -transparent $transparent] } errmsg ] } { @@ -114,7 +118,7 @@ "2" { return [subst {#acs-subsite.Send_email_to_this_user#}] } - "1" { + "1" { #Do not show e-mail return "\#acs-subsite.email_not_available\#" } @@ -145,9 +149,9 @@ @param bgcolor The background color of the image in the format \#xxxxxx, default to \#ffffff @param transparent If you want the background color transparent set it to 1. Default to 1 } { - - # First we create a type and a folder in the content repository - # with label Email_Images where only items of type email_image + + # First we create a type and a folder in the content repository + # with label Email_Images where only items of type email_image # will be stored. set font_size 14 @@ -167,46 +171,46 @@ } set bg "xc:$bgcolor" - + # Creating an image of the right length where the email will be if {[catch {exec convert -size $size $bg $dest_path} errmsg]} { - return "" + return "" } - + # Creating the image with the email of the user on it if {[catch {exec convert -font $font_type -fill blue -pointsize $font_size -draw "text 0,$ypos $email" \ - $dest_path $dest_path} errmsg]} { - return "" + $dest_path $dest_path} errmsg]} { + return "" } if { $transparent eq "" || $transparent eq "1" } { - # Making the bg color transparent - if {[catch {exec convert $dest_path -transparent $bgcolor $dest_path} errmsg]} { - return "" - } + # Making the bg color transparent + if {[catch {exec convert $dest_path -transparent $bgcolor $dest_path} errmsg]} { + return "" + } } - + # Time to store the image in the content repository - db_transaction { + db_transaction { set mime_type [cr_filename_to_mime_type -create $dest_path] set creation_ip [ad_conn peeraddr] - + set item_id [content::item::new -name $image_name -parent_id $folder_id -content_type "email_image" \ -storage_type "lob" -creation_ip $creation_ip] - + set revision_id [content::revision::new -item_id $item_id -title $image_name -mime_type $mime_type \ -description "User email image" -creation_ip $creation_ip ] - + email_image::add_relation -user_id $user_id -item_id $item_id content::item::set_live_revision -revision_id $revision_id db_dml new_lob_content {} -blob_files [list ${dest_path}] db_dml lob_size {} } - + # Delete the temporary file created by ImageMagick catch { file delete -- $dest_path } errMsg - + set img_src [ns_quotehtml "/shared/email-image-bits.tcl?user_id=$user_id&revision_id=$revision_id"] set send_email_url [ns_quotehtml "/shared/send-email?sendto=$user_id&return_url=$return_url"] set email_image [subst {#acs-subsite.Email#} @@ -222,11 +226,13 @@ {-bgcolor ""} {-transparent ""} } { - Creates a new email_image of the user with his/her new edited email on it and store it - in the content repository under the Email_Images folder. If the user has an image already - stored it makes a new revision of the image, if not, it creates a new item with the new - image. + Creates a new email_image of the user with his/her new edited + email on it and store it in the content repository under the + Email_Images folder. If the user has an image already stored it + makes a new revision of the image, if not, it creates a new item + with the new image. + @param bgcolor The background color of the image in the format \#xxxxxx, default to \#ffffff @param transparent If you want the background color transparent set it to 1. Default to 1 } { @@ -250,13 +256,13 @@ } set bg "xc:$bgcolor" - + # Creating an image of the right length where the email will be if { [catch { exec convert -size $size $bg $dest_path } ] } { # ImageMagick not present return } - + # Creating the image with the email of the user on it exec convert -font $font_type -fill blue -pointsize $font_size -draw "text 0,$ypos $new_email" \ $dest_path $dest_path @@ -282,11 +288,13 @@ } } else { db_transaction { - - set item_id [content::item::new -name $image_name -parent_id $folder_id -content_type "email_image" \ + + set item_id [content::item::new \ + -name $image_name -parent_id $folder_id -content_type "email_image" \ -storage_type "lob" -creation_ip $creation_ip] - - set revision_id [content::revision::new -item_id $item_id -title $image_name -mime_type $mime_type \ + + set revision_id [content::revision::new \ + -item_id $item_id -title $image_name -mime_type $mime_type \ -description "User email image" -creation_ip $creation_ip ] email_image::add_relation -user_id $user_id -item_id $item_id @@ -332,16 +340,16 @@ ad_proc -public email_image::create_type_folder_rel { } { Creates a new folder in the content repository with the name and label Email_Images. Also create a new type and register this type to the created folder. - Makes a new relation type to asociate the item_id (email_image in the content repository) + Makes a new relation type to asociate the item_id (email_image in the content repository) with the user_id. } { - set type_id [content::type::new -content_type "email_image" -pretty_name "Email_Image" \ - -pretty_plural "Email_Images" -table_name "users_email_image" -id_column "email_image_id"] + set type_id [content::type::new \ + -content_type "email_image" -pretty_name "Email_Image" \ + -pretty_plural "Email_Images" -table_name "users_email_image" \ + -id_column "email_image_id"] set folder_id [content::folder::new -name "Email_Images" -label "Email_Images"] - - content::folder::register_content_type -folder_id $folder_id -content_type "email_image" - + content::folder::register_content_type -folder_id $folder_id -content_type "email_image" rel_types::new email_image_rel "Email Image" "Email Images" user 0 1 content_item 0 1 }