Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
acs-subsite
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
acs-subsite
Commits
8c0a8547
Commit
8c0a8547
authored
Apr 30, 2007
by
Malte Sussdorff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Malte
parent
9b7c53b7
Pipeline
#99
failed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
493 additions
and
0 deletions
+493
-0
email-image-procs-oracle.xql
tcl/email-image-procs-oracle.xql
+50
-0
email-image-procs-postgresql.xql
tcl/email-image-procs-postgresql.xql
+54
-0
email-image-procs.tcl
tcl/email-image-procs.tcl
+323
-0
email-image-procs.xql
tcl/email-image-procs.xql
+66
-0
No files found.
tcl/email-image-procs-oracle.xql
0 → 100644
View file @
8c0a8547
<?xml version="1.0"?>
<queryset>
<rdbms><type>
oracle
</type><version>
8.1.6
</version></rdbms>
<fullquery
name=
"email_image::new_item.lob_size"
>
<querytext>
update cr_revisions
set content_length = dbms_lob.getlength(content)
where revision_id = :revision_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::new_item.lob_content"
>
<querytext>
update cr_revisions
set content = empty_blob()
where revision_id = :revision_id
returning content into :1
</querytext>
</fullquery>
<fullquery
name=
"email_image::edit_email_image.lob_size"
>
<querytext>
update cr_revisions
set content_length = dbms_lob.getlength(content)
where revision_id = :revision_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::edit_email_image.lob_content"
>
<querytext>
update cr_revisions
set content = empty_blob()
where revision_id = :revision_id
returning content into :1
</querytext>
</fullquery>
<fullquery
name=
"email_image::add_relation.add_relation"
>
<querytext>
begin
:1 := acs_rel.new (
rel_type => 'email_image_rel',
object_id_one => :user_id,
object_id_two => :item_id);
end;
</querytext>
</fullquery>
</queryset>
tcl/email-image-procs-postgresql.xql
0 → 100644
View file @
8c0a8547
<?xml version="1.0"?>
<queryset>
<rdbms><type>
postgresql
</type><version>
7.1
</version></rdbms>
<fullquery
name=
"email_image::new_item.lob_size"
>
<querytext>
update cr_revisions
set content_length = lob_length(lob)
where revision_id = :revision_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::new_item.lob_content"
>
<querytext>
update cr_revisions
set mime_type = :mime_type,
lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]]
where revision_id = :revision_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::edit_email_image.lob_size"
>
<querytext>
update cr_revisions
set content_length = lob_length(lob)
where revision_id = :revision_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::edit_email_image.lob_content"
>
<querytext>
update cr_revisions
set mime_type = :mime_type,
lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]]
where revision_id = :revision_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::add_relation.add_relation"
>
<querytext>
select acs_rel__new (
null,
'email_image_rel',
:user_id,
:item_id,
null,
null,
null
)
</querytext>
</fullquery>
</queryset>
tcl/email-image-procs.tcl
0 → 100644
View file @
8c0a8547
ad_library
{
Tcl API for email_image store and manipulation
@author Miguel Marin
(
miguelmarin@viaro.net
)
Viaro Networks
(
www.viaro.net
)
}
namespace
eval email_image
{}
ad_proc -public email_image::update_private_p
{
-user_id:required
-level:required
}
{
Changes the priv_email field from the users table
@user_id
@level Change to this level
}
{
db_transaction
{
db_dml update_users
{
}
}
}
ad_proc -public email_image::get_priv_email
{
-user_id:required
}
{
Returns the priv_email field of the user from the users table.
@user_id
}
{
set priv_level
[
db_string get_private_email
{
}]
if
{
$priv
_level eq
"5"
}
{
set priv_level
[
parameter::get_from_package_key -package_key
"acs-subsite"
\
-parameter
"PrivateEmailLevelP"
-default 4
]
}
return
$priv
_level
}
ad_proc -public email_image::get_user_email
{
-user_id:required
{
-return_url
""
}
{
-bgcolor
""
}
{
-transparent
""
}
}
{
Returns the email in differnet diferent 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
)
.
@user_id
@return_url The url to return when the email is shown as a link
@bgcolor The Background color of the image. Default to
\#
ffffff
@transparent If the bgcolor is transparent. Default to 1
}
{
set email
[
email_image::get_email -user_id
$user
_id
]
set user_level
[
email_image::get_priv_email -user_id
$user
_id
]
if
{
$user
_level == 5
}
{
# We get the privacy level from PrivateEmailLevelP parameter
set priv_level
[
parameter::get_from_package_key -package_key
"acs-subsite"
\
-parameter
"PrivateEmailLevelP"
-default 4
]
}
else
{
# We use the privacy level that the user select
set priv_level
$user
_level
}
switch
$priv
_level
{
"4"
{
return
"<a href=
\"
mailto:
$email
\"
title=
\"
#acs-subsite.Send_email_to_this_user#
\"
>
$email
</a>"
}
"3"
{
set email_image_id
[
email_image::get_related_item_id -user_id
$user
_id
]
if
{
$email
_image_id !=
"-1"
}
{
# 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 export_vars
"user_id=
$user
_id&revision_id=
$revision
_id"
set email_image
"<a href=
\"
/shared/send-email?sendto=
$user
_id&return_url=
$return
_url
\"
><img border=0 align=middle src=/shared/email-image-bits.tcl?
$export
_vars></a>"
}
else
{
# Create a new email_image
if
{
[
catch
{
set email_image
[
email_image::new_item -user_id
$user
_id -bgcolor
$bgcolor
-transparent
$transparent
]
}
errmsg
]
}
{
# ImageMagick not present, we protect the email by adding
# an image replacing the
"@"
symbol
set email_user
[
lindex
[
split
$email
'@'
]
0
]
set email_domain
[
lindex
[
split
$email
'@'
]
1
]
set email_image
"<a href=
\"
/shared/send-email?sendto=
$user
_id&return_url=
$return
_url
\"
>
${email_user}
<img border=0 align=middle src=/shared/images/at.gif>
${email_domain}
</a>"
}
}
return
$email
_image
}
"2"
{
return
"<a href=
\"
/shared/send-email?sendto=
$user
_id&return_url=
$return
_url
\"
>
\#
acs-subsite.Send_email_to_this_user
\#
</a>"
}
"1"
{
#Do not show e-mail
return
"
\#
acs-subsite.email_not_available
\#
"
}
}
}
ad_proc -public email_image::get_email
{
-user_id:required
}
{
Returns the email of the user
@user_id
}
{
return
[
db_string get_email
{
}]
}
ad_proc -public email_image::new_item
{
-user_id:required
{
-bgcolor
""
}
{
-transparent
""
}
}
{
Creates the email_image of the user with his/her email on it and store it
in the content repository under the Email_Images folder.
@user_id
@bgcolor The background color of the image in the format
\#
xxxxxx, default to
\#
ffffff
@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
# will be stored.
set font_size 14
set font_type helvetica
set folder_id
[
email_image::get_folder_id
]
set email
[
email_image::get_email -user_id
$user
_id
]
set image_name
"email
${user_id}
.gif"
set email_length
[
string
length
$email
]
set dest_path
"/tmp/
$image
_name"
set width
[
expr
[
expr
$email
_length *
[
expr
$font
_size / 2
]]
+ 2
]
set height
$font
_size
set ypos
[
expr
[
expr
$height
/ 2
]
+ 3
]
set size
"
${width}
x
$height
"
if
{
[
string
equal
$bgcolor
""
]}
{
set bgcolor
"
\#
ffffff"
}
set bg
"xc:
$bgcolor
"
# Creating an image of the rigth length where the email will be
if
{[
catch
{
exec
convert -size
$size
$bg
$dest
_path
}
errmsg
]}
{
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
""
}
if
{
[
string
equal
$transparent
""
]
||
[
string
equal
$transparent
"1"
]
}
{
# 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
{
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
db_dml update_cr_items
{
}
db_dml 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 export_vars
"user_id=
$user
_id&revision_id=
$revision
_id"
set email_image
"<a href=
\"
/shared/send-email?sendto=
$user
_id
\"
><img align=middle border=0
\
src=/shared/email-image-bits.tcl?
$export
_vars></a>"
return
"
$email
_image"
}
ad_proc -public email_image::edit_email_image
{
-user_id:required
-new_email:required
{
-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.
@user_id
@bgcolor The background color of the image in the format
\#
xxxxxx, default to
\#
ffffff
@transparent If you want the background color transparent set it to 1. Default to 1
}
{
if
{
$new
_email ==
[
email_image::get_email -user_id
$user
_id
]
}
{
# Email didn't change
return
}
set font_size 14
set font_type helvetica
set folder_id
[
email_image::get_folder_id
]
set image_name
"email
${user_id}
.gif"
set email_length
[
string
length
$new
_email
]
set dest_path
"/tmp/
$image
_name"
set width
[
expr
[
expr
$email
_length *
[
expr
$font
_size / 2
]]
+ 2
]
set height
$font
_size
set ypos
[
expr
[
expr
$height
/ 2
]
+ 3
]
set size
"
${width}
x
$height
"
if
{
[
string
equal
$bgcolor
""
]}
{
set bgcolor
"
\#
ffffff"
}
set bg
"xc:
$bgcolor
"
# Creating an image of the rigth 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
if
{
[
string
equal
$transparent
""
]
||
[
string
equal
$transparent
"1"
]
}
{
# Making the bg color transparent
exec convert
$dest
_path -transparent
$bgcolor
$dest
_path
}
set email_image_id
[
email_image::get_related_item_id -user_id
$user
_id
]
set mime_type
[
cr_filename_to_mime_type -create
$dest
_path
]
set creation_ip
[
ad_conn peeraddr
]
if
{
$email
_image_id !=
"-1"
}
{
db_transaction
{
set item_id
$email
_image_id
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
]
db_dml update_cr_items
{
}
db_dml lob_content
{
}
-blob_files
[
list
${dest_path}
]
db_dml lob_size
{
}
}
}
else
{
db_transaction
{
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
db_dml update_cr_items
{
}
db_dml lob_content
{
}
-blob_files
[
list
${dest_path}
]
db_dml lob_size
{
}
}
}
# Delete the temporary file created by ImageMagick
catch
{
file delete
$dest
_path
}
errMsg
}
ad_proc -public email_image::get_folder_id
{
}
{
Returns the folder_id of the folder with the name
"Email_Images"
}
{
return
[
db_string check_folder_name
{
}
]
}
ad_proc -public email_image::add_relation
{
-user_id:required
-item_id:required
}
{
Add a new relation between user_id and item_id
@user_id
@item_id the item_id of the image in the content repository
}
{
db_exec_plsql add_relation
{
}
}
ad_proc -public email_image::get_related_item_id
{
-user_id:required
}
{
Returns the item_id of the email_image stored in the content repository for
user_id.
@user_id
}
{
return
[
db_string get_rel_item
{
}
-default -1
]
}
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
)
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 folder_id
[
content::folder::new -name
"Email_Images"
-label
"Email_Images"
]
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
}
tcl/email-image-procs.xql
0 → 100644
View file @
8c0a8547
<?xml version="1.0"?>
<queryset>
<fullquery
name=
"email_image::get_email.get_email"
>
<querytext>
select email
from cc_users
where user_id = :user_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::get_priv_email.get_private_email"
>
<querytext>
select priv_email
from users
where user_id = :user_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::get_folder_id.check_folder_name"
>
<querytext>
select folder_id from cr_folders
where label = 'Email_Images'
</querytext>
</fullquery>
<fullquery
name=
"email_image::get_related_item_id.get_rel_item"
>
<querytext>
select object_id_two from acs_rels
where rel_type = 'email_image_rel' and object_id_one = :user_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::update_private_p.update_users"
>
<querytext>
update users
set priv_email = :level
where user_id = :user_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::new_item.update_cr_items"
>
<querytext>
update cr_items
set live_revision = :revision_id
where item_id = :item_id
</querytext>
</fullquery>
<fullquery
name=
"email_image::edit_email_image.update_cr_items"
>
<querytext>
update cr_items
set live_revision = :revision_id
where item_id = :item_id
</querytext>
</fullquery>
</queryset>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment