Commit c6bb02c4 authored by Frank Bergmann's avatar Frank Bergmann

- joined b3-0-0-patches

parent 4ff28252
--
-- packages/acs-mail/sql/postgresql/acs-mail-drop.sql
--
-- @author Vinod Kurup <vkurup@massmed.org>
-- @creation-date 2001-07-05
-- @cvs-id $Id$
--
-- FIXME: This script has NOT been tested! - vinodk
@@ acs-mail-nt-drop
drop package acs_mail_queue_message;
drop table acs_mail_queue_incoming;
drop table acs_mail_queue_outgoing;
drop table acs_mail_queue_messages;
begin
acs_object_type.drop_type (
'acs_mail_queue_message',
't'
);
end;
/
show errors
drop package acs_mail_gc_object;
drop package acs_mail_body;
drop package acs_mail_multipart;
drop package acs_mail_link;
drop index acs_mail_body_hdrs_body_id_idx;
-- drop all acs-mail objects
begin
for v_rec in (select object_id from acs_objects where object_type in ('acs_mail_multipart', 'acs_mail_link', 'acs_mail_body','acs_mail_gc_object') order by object_id desc)
loop
acs_object.del(v_rec.object_id);
end loop;
end;
/
show errors
drop table acs_mail_body_headers;
drop table acs_mail_multipart_parts;
drop table acs_mail_multiparts;
drop table acs_mail_links;
drop table acs_mail_bodies;
drop table acs_mail_gc_objects;
begin
acs_object_type.drop_type (
'acs_mail_multipart',
't'
);
acs_object_type.drop_type (
'acs_mail_link',
't'
);
acs_object_type.drop_type (
'acs_mail_body',
't'
);
acs_object_type.drop_type (
'acs_mail_gc_object',
't'
);
end;
/
show errors
--
-- packages/acs-mail/sql/postgresql/acs-mail-drop.sql
--
-- @author Vinod Kurup <vkurup@massmed.org>
-- @creation-date 2001-07-05
-- @cvs-id $Id$
--
-- FIXME: This script has NOT been tested! - vinodk
@@ acs-mail-nt-drop
drop package acs_mail_queue_message;
drop table acs_mail_queue_incoming;
drop table acs_mail_queue_outgoing;
drop table acs_mail_queue_messages;
begin
acs_object_type.drop_type (
'acs_mail_queue_message',
't'
);
end;
/
show errors
drop package acs_mail_gc_object;
drop package acs_mail_body;
drop package acs_mail_multipart;
drop package acs_mail_link;
drop index acs_mail_body_hdrs_body_id_idx;
-- drop all acs-mail objects
begin
for v_rec in (select object_id from acs_objects where object_type in ('acs_mail_multipart', 'acs_mail_link', 'acs_mail_body','acs_mail_gc_object') order by object_id desc)
loop
acs_object.del(v_rec.object_id);
end loop;
end;
/
show errors
drop table acs_mail_body_headers;
drop table acs_mail_multipart_parts;
drop table acs_mail_multiparts;
drop table acs_mail_links;
drop table acs_mail_bodies;
drop table acs_mail_gc_objects;
begin
acs_object_type.drop_type (
'acs_mail_multipart',
't'
);
acs_object_type.drop_type (
'acs_mail_link',
't'
);
acs_object_type.drop_type (
'acs_mail_body',
't'
);
acs_object_type.drop_type (
'acs_mail_gc_object',
't'
);
end;
/
show errors
......@@ -164,7 +164,7 @@ create table acs_mail_gc_objects (
-- Mail bodies
create table acs_mail_bodies (
body_id integer
body_id integer
constraint acs_mail_bodies_body_id_pk
primary key
constraint acs_mail_bodies_body_id_fk
......@@ -177,7 +177,7 @@ create table acs_mail_bodies (
constraint acs_mail_bodies_body_from_fk
references parties on delete set null,
body_date timestamptz,
header_message_id varchar(1000)
header_message_id varchar(1000)
constraint acs_mail_bodies_h_m_id_un
unique
constraint acs_mail_bodies_h_m_id_nn
......@@ -233,7 +233,7 @@ create table acs_mail_multipart_parts (
constraint acs_mail_mp_parts_mp_id_fk
references acs_mail_multiparts on delete cascade,
mime_filename varchar(1000),
mime_disposition varchar(1000),
mime_disposition varchar(1000),
sequence_number integer,
content_item_id integer
constraint acs_mail_mp_parts_c_itm_id_fk
......@@ -248,12 +248,12 @@ create index acs_mail_mpp_cr_item_id_idx ON acs_mail_multipart_parts(content_ite
-- Mail Links
create table acs_mail_links (
mail_link_id integer
mail_link_id integer
constraint acs_mail_links_ml_id_pk
primary key
constraint acs_mail_links_ml_id_fk
references acs_objects on delete cascade,
body_id integer
body_id integer
constraint acs_mail_links_body_id_nn
not null
constraint acs_mail_links_body_id_fk
......
--
-- packages/acs-mail/sql/postgresql/acs-mail-drop.sql
--
-- @author Vinod Kurup <vkurup@massmed.org>
-- @creation-date 2001-07-05
-- @cvs-id $Id$
--
-- FIXME: This script has NOT been tested! - vinodk
\i acs-mail-nt-drop.sql
drop function acs_mail_queue_message__new (integer,integer,
integer,timestamptz,integer,varchar,varchar);
drop function acs_mail_queue_message__delete (integer);
drop table acs_mail_queue_incoming;
drop table acs_mail_queue_outgoing;
drop table acs_mail_queue_messages;
select acs_object_type__drop_type (
'acs_mail_queue_message',
't'
);
drop function acs_mail_gc_object__new (integer,varchar,timestamptz,integer,
varchar,integer);
drop function acs_mail_gc_object__delete(integer);
drop function acs_mail_body__new (integer,integer,integer,timestamptz,varchar,
varchar,text,text,text,integer,varchar,date,integer,varchar,integer);
drop function acs_mail_body__delete(integer);
drop function acs_mail_body__body_p(integer);
drop function acs_mail_body__clone (integer,integer,varchar,timestamptz,
integer,varchar,integer);
drop function acs_mail_body__set_content_object (integer,integer);
drop function acs_mail_multipart__new (integer,varchar,varchar,
timestamptz,integer,varchar,integer);
drop function acs_mail_multipart__delete (integer);
drop function acs_mail_multipart__multipart_p (integer);
drop function acs_mail_multipart__add_content (integer,integer);
drop function acs_mail_link__new (integer,integer,integer,timestamptz,
integer,varchar,varchar);
drop function acs_mail_link__delete (integer);
drop function acs_mail_link__link_p (integer);
drop index acs_mail_body_hdrs_body_id_idx;
create function inline_0 ()
returns integer as '
declare
v_rec acs_objects%ROWTYPE;
begin
for v_rec in select object_id from acs_objects where object_type in (''acs_mail_multipart'',''acs_mail_link'',''acs_mail_body'',''acs_mail_gc_object'') order by object_id desc
loop
perform acs_object__delete( v_rec.object_id );
end loop;
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
drop table acs_mail_body_headers;
drop table acs_mail_multipart_parts;
drop table acs_mail_multiparts;
drop table acs_mail_links;
drop table acs_mail_bodies;
drop table acs_mail_gc_objects;
select acs_object_type__drop_type (
'acs_mail_multipart',
't'
);
select acs_object_type__drop_type (
'acs_mail_link',
't'
);
select acs_object_type__drop_type (
'acs_mail_body',
't'
);
select acs_object_type__drop_type (
'acs_mail_gc_object',
't'
);
--
-- packages/acs-mail/sql/postgresql/acs-mail-drop.sql
--
-- @author Vinod Kurup <vkurup@massmed.org>
-- @creation-date 2001-07-05
-- @cvs-id $Id$
--
-- FIXME: This script has NOT been tested! - vinodk
\i acs-mail-nt-drop.sql
drop function acs_mail_queue_message__new (integer,integer,
integer,timestamptz,integer,varchar,varchar);
drop function acs_mail_queue_message__delete (integer);
drop table acs_mail_queue_incoming;
drop table acs_mail_queue_outgoing;
drop table acs_mail_queue_messages;
select acs_object_type__drop_type (
'acs_mail_queue_message',
't'
);
drop function acs_mail_gc_object__new (integer,varchar,timestamptz,integer,
varchar,integer);
drop function acs_mail_gc_object__delete(integer);
drop function acs_mail_body__new (integer,integer,integer,timestamptz,varchar,
varchar,text,text,text,integer,varchar,date,integer,varchar,integer);
drop function acs_mail_body__delete(integer);
drop function acs_mail_body__body_p(integer);
drop function acs_mail_body__clone (integer,integer,varchar,timestamptz,
integer,varchar,integer);
drop function acs_mail_body__set_content_object (integer,integer);
drop function acs_mail_multipart__new (integer,varchar,varchar,
timestamptz,integer,varchar,integer);
drop function acs_mail_multipart__delete (integer);
drop function acs_mail_multipart__multipart_p (integer);
drop function acs_mail_multipart__add_content (integer,integer);
drop function acs_mail_link__new (integer,integer,integer,timestamptz,
integer,varchar,varchar);
drop function acs_mail_link__delete (integer);
drop function acs_mail_link__link_p (integer);
drop index acs_mail_body_hdrs_body_id_idx;
create function inline_0 ()
returns integer as '
declare
v_rec acs_objects%ROWTYPE;
begin
for v_rec in select object_id from acs_objects where object_type in (''acs_mail_multipart'',''acs_mail_link'',''acs_mail_body'',''acs_mail_gc_object'') order by object_id desc
loop
perform acs_object__delete( v_rec.object_id );
end loop;
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
drop table acs_mail_body_headers;
drop table acs_mail_multipart_parts;
drop table acs_mail_multiparts;
drop table acs_mail_links;
drop table acs_mail_bodies;
drop table acs_mail_gc_objects;
select acs_object_type__drop_type (
'acs_mail_multipart',
't'
);
select acs_object_type__drop_type (
'acs_mail_link',
't'
);
select acs_object_type__drop_type (
'acs_mail_body',
't'
);
select acs_object_type__drop_type (
'acs_mail_gc_object',
't'
);
......@@ -27,19 +27,19 @@
-- @return The id of the new request
-- */
create function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer)
create or replace function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer)
returns integer as '
declare
p_party_from alias for $1;
p_party_to alias for $2;
p_party_to alias for $2;
p_expand_group alias for $3; -- default ''f''
p_subject alias for $4;
p_message alias for $5;
p_subject alias for $4;
p_message alias for $5;
p_max_retries alias for $6; -- default 0
v_header_from acs_mail_bodies.header_from%TYPE;
v_header_to acs_mail_bodies.header_to%TYPE;
v_body_id acs_mail_bodies.body_id%TYPE;
v_item_id cr_items.item_id%TYPE;
v_header_to acs_mail_bodies.header_to%TYPE;
v_body_id acs_mail_bodies.body_id%TYPE;
v_item_id cr_items.item_id%TYPE;
v_revision_id cr_revisions.revision_id%TYPE;
v_message_id acs_mail_queue_messages.message_id%TYPE;
v_header_to_rec record;
......@@ -50,7 +50,10 @@ begin
end if;
-- get the sender email address
select max(email) into v_header_from from parties where party_id = p_party_from;
select max(email)
into v_header_from
from parties
where party_id = p_party_from;
-- if sender address is null, then use site default OutgoingSender
if v_header_from is null then
......@@ -60,11 +63,16 @@ begin
-- make sure that this party is in users table. If not, let creation_user
-- be null to prevent integrity constraint violations on acs_objects
select max(user_id) into v_creation_user
from users where user_id = p_party_from;
select max(user_id)
into v_creation_user
from users
where user_id = p_party_from;
-- get the recipient email address
select max(email) into v_header_to from parties where party_id = p_party_to;
select max(email)
into v_header_to
from parties
where party_id = p_party_to;
-- do not let any of these addresses be null
if v_header_from is null or v_header_to is null then
......@@ -72,53 +80,51 @@ begin
end if;
-- create a mail body with empty content
select acs_mail_body__new (
null, -- p_body_id
null, -- p_body_reply_to
p_party_from, -- p_body_from
now(), -- p_body_date
null, -- p_header_message_id
null, -- p_header_reply_to
p_subject, -- p_header_subject
null, -- p_header_from
null, -- p_header_to
null, -- p_content_item_id
''acs_mail_body'', -- p_object_type
now(), -- p_creation_date
v_creation_user, -- p_creation_user
null, -- p_creation_ip
null -- p_context_id
null, -- p_body_id
null, -- p_body_reply_to
p_party_from, -- p_body_from
now(), -- p_body_date
null, -- p_header_message_id
null, -- p_header_reply_to
p_subject, -- p_header_subject
null, -- p_header_from
null, -- p_header_to
null, -- p_content_item_id
''acs_mail_body'', -- p_object_type
now() ::date, -- p_creation_date
v_creation_user, -- p_creation_user
null, -- p_creation_ip
null -- p_context_id
) into v_body_id;
-- create a CR item to stick p_message into
select content_item__new(
''acs-mail message'' || v_body_id, -- new__name
null, -- new__parent_id
p_subject, -- new__title
null, -- new__description
p_message -- new__text
''acs-mail message'' || v_body_id, -- new__name
null, -- new__parent_id
p_subject, -- new__title
null, -- new__description
p_message -- new__text
) into v_item_id;
-- content_item__new makes a CR revision. We need to get that revision
-- and make it live
select content_item__get_latest_revision (v_item_id)
into v_revision_id;
select content_item__get_latest_revision (v_item_id) into v_revision_id ;
perform content_item__set_live_revision ( v_revision_id );
-- set the content of the message
perform acs_mail_body__set_content_object( v_body_id, v_item_id );
-- queue the message
select acs_mail_queue_message__new (
null, -- p_mail_link_id
v_body_id, -- p_body_id
null, -- p_context_id
now(), -- p_creation_date
null, -- p_mail_link_id
v_body_id, -- p_body_id
null, -- p_context_id
now(), -- p_creation_date
v_creation_user, -- p_creation_user
null, -- p_creation_ip
null, -- p_creation_ip
''acs_mail_link'' -- p_object_type
) into v_message_id;
......@@ -127,8 +133,7 @@ begin
-- the idea is that you put a generic message into the main queue
-- without from or to address, and then insert a copy of the message
-- into the outgoing_queue with the specific from and to address
if p_expand_group = ''f'' then
if p_expand_group = ''f'' then
insert into acs_mail_queue_outgoing
( message_id, envelope_from, envelope_to )
values
......@@ -138,35 +143,38 @@ begin
-- expand the group
-- FIXME: need to check if this is a group and if there are members
-- if not, do we need to notify sender?
for v_header_to_rec in
select email from parties p
where party_id in (select member_id from group_approved_member_map
where group_id = p_party_to) loop
select email
from parties p
where party_id in (
select member_id
from group_approved_member_map
where group_id = p_party_to
)
loop
insert into acs_mail_queue_outgoing
( message_id, envelope_from, envelope_to )
values
( v_message_id, v_header_from, v_header_to_rec.email );
end loop;
end if;
end if;
return v_message_id;
end;' language 'plpgsql';
-- /** acs_mail_nt__post_request
-- * Overloaded function that
-- * only uses the basic params
-- * Overloaded function that
-- * only uses the basic params
--
-- @author: Vinod Kurup
-- @author: Vinod Kurup
-- @param party_from The id of the sending party
-- @param party_to The id of the sending party
-- @param subject A one-line subject for the message
-- @param message The body of the message
-- @return The id of the new request
--
create function acs_mail_nt__post_request(integer,integer,varchar,text)
create or replace function acs_mail_nt__post_request(integer,integer,varchar,text)
returns integer as '
declare
p_party_from alias for $1;
......@@ -193,7 +201,7 @@ end;' language 'plpgsql';
-- @param request_id Id of the request to cancel
-- */
create function acs_mail_nt__cancel_request (integer)
create or replace function acs_mail_nt__cancel_request (integer)
returns integer as '
declare
p_message_id alias for $1;
......@@ -210,7 +218,7 @@ end;' language 'plpgsql';
-- @author Vinod Kurup
-- */
create function acs_mail_nt__expand_requests ()
create or replace function acs_mail_nt__expand_requests ()
returns integer as '
begin
raise EXCEPTION ''-20000: Procedure no longer supported.'';
......@@ -225,7 +233,7 @@ end;' language 'plpgsql';
-- @author Vinod Kurup
-- */
create function acs_mail_nt__update_requests ()
create or replace function acs_mail_nt__update_requests ()
returns integer as '
begin
raise EXCEPTION ''-20000: Procedure no longer supported.'';
......@@ -240,7 +248,7 @@ end;' language 'plpgsql';
-- @author Vinod Kurup
-- */
create function acs_mail_nt__process_queue (varchar,integer)
create or replace function acs_mail_nt__process_queue (varchar,integer)
returns integer as '
declare
p_host alias for $1;
......@@ -254,7 +262,7 @@ end;' language 'plpgsql';
-- /** acs_mail_nt__schedule_process
-- * This was part of the nt package, but is no longer relevant
-- * Instead, use ad_schedule_proc to schedule
-- * Instead, use ad_schedule_proc to schedule
-- the tcl proc acs_mail_process_queue
-- * Note: this is already done in a default install
-- See packages/acs-mail/tcl/acs-mail-init.tcl
......@@ -262,7 +270,7 @@ end;' language 'plpgsql';
-- @author Vinod Kurup
-- */
create function acs_mail_nt__schedule_process (numeric,varchar,integer)
create or replace function acs_mail_nt__schedule_process (numeric,varchar,integer)
returns integer as '
declare
p_interval alias for $1;
......
......@@ -51,9 +51,13 @@ end;
-- first create a CR item.
-- then call acs_mail_body__new with the CR item's item_id
create or replace function acs_mail_body__new (integer,integer,integer,timestamptz,varchar,varchar,text,text,text,integer,varchar,timestamptz,integer,varchar,integer)
returns integer as '
create function acs_mail_body__new (
integer,integer,integer,
timestamptz,varchar,varchar,
text,text,text,
integer,varchar,date,
integer,varchar,integer
) returns integer as '
declare
p_body_id alias for $1; -- default null
p_body_reply_to alias for $2; -- default null
......
......@@ -140,12 +140,12 @@ where r.revision_id = $revision_id and
<querytext>
select acs_mail_gc_object__new (
:object_id, -- gc_object_id
:object_id, -- gc_object_id
'acs_mail_gc_object', -- object_type
now(), -- creation_date
:creation_user, -- creation_user
:creation_ip, -- creation_ip
null -- context_id
now(), -- creation_date
:creation_user, -- creation_user
:creation_ip, -- creation_ip
null -- context_id
);
</querytext>
......@@ -156,21 +156,21 @@ select acs_mail_gc_object__new (
<querytext>
select acs_mail_body__new (
:body_id, -- body_id
:body_id, -- body_id
:body_reply_to, -- body_reply_to
:body_from, -- body_from
:body_date, -- body_date
:header_message_id, -- header_message_id
:header_message_id, -- header_message_id
:header_reply_to, -- header_reply_to
:header_subject, -- header_subject
:header_subject, -- header_subject
:header_from, -- header_from
:header_to, -- header_to
:content_item_id, -- content_item_id
'acs_mail_body', -- object_type
now(), -- creation_date
now() ::date, -- creation_date
:creation_user, -- creation_user
:creation_ip, -- creation_ip
null -- context_id
null -- context_id
);
</querytext>
......
......@@ -198,147 +198,142 @@ ad_proc -private acs_mail_encode_content {
ns_log Debug "acs-mail: encode: starting $content_item_id"
# What sort of content do we have?
if ![acs_mail_multipart_p $content_item_id] {
ns_log Debug "acs-mail: encode: one part $content_item_id"
ns_log Debug "acs-mail: encode: one part $content_item_id"
# Easy as pie.
# Let's get the data.
# vinodk: first get the latest revision
set revision_id [db_exec_plsql get_latest_revision "
# vinodk: first get the latest revision
set revision_id [db_exec_plsql get_latest_revision "
begin
return content_item__get_latest_revision ( :content_item_id );
end;"
]
set storage_type [db_string get_storage_type "
select storage_type from cr_items
where item_id = :content_item_id
"]
if [db_0or1row acs_mail_body_to_mime_get_content_simple {
select content, mime_type as v_content_type
from cr_revisions
where revision_id = :revision_id
}] {
if [string equal $storage_type text] {
ns_log Debug "acs-mail: encode: one part hit $content_item_id"
# vinodk: no need for this, since we're checking
# storage_type
#
# We win! Hopefully. Check if there are 8bit characters/data.
# HT NL CR SP-~ The full range of ASCII with spaces but no
# control characters.
#if ![regexp "\[^\u0009\u000A\u000D\u0020-\u007E\]" $content] {
# ns_log Debug "acs-mail: encode: good code $content_item_id"
# # We're still okay. Use it!
return [list $v_content_type $content]
#}
#ns_log "Notice" "acs-mail: encode: bad code $content_item_id"
} else {
# this content is in the file system or a blob
ns_log Debug "acs-mail: encode: binary content $content_item_id"
if [string equal $storage_type file] {
ns_log Debug "acs-mail: encode: file $content_item_id"
set encoded_content [acs_mail_uuencode_file [cr_fs_path]$content]
} else {
ns_log Debug "acs-mail: encode: lob $content_item_id"
# Blob. Now we need to decide if this is binary
# so we can uuencode it if necessary.
# We'll use the mime type to decide
if { [string first "text" $v_content_type] == 0 } {
ns_log Debug "acs-mail: encode: plain content"
set encoded_content "$content"
} else {
# binary content - copy the blob to temp file
# that we will then uuencode
set file [ns_tmpnam]
db_blob_get_file copy_blob_to_file "
select r.content, i.storage_type
from cr_revisions r, cr_items i
where r.revision_id = $revision_id and
r.item_id = i.item_id " -file $file
ns_log Debug "acs-mail: encode: binary content"
set encoded_content [acs_mail_uuencode_file $file]
}
}
return [list $v_content_type $encoded_content]
}
}
} else {
# Harder. Oops.
ns_log Debug "acs-mail: encode: multipart $content_item_id"
set boundary "=-=-="
set contents {}
# Get the component pieces
set multipart_list [db_list_of_lists acs_mail_body_to_mime_get_contents {
select mime_filename, mime_disposition, content_item_id as ci_id
from acs_mail_multipart_parts
where multipart_id = :content_item_id
order by sequence_number
}
]
]
set storage_type [db_string get_storage_type "
select storage_type
from cr_items
where item_id = :content_item_id
"]
if ![empty_string_p $multipart_list] {
foreach multipart_item $multipart_list {
set mime_filename [lindex $multipart_item 0]
set mime_disposition [lindex $multipart_item 1]
set ci_id [lindex $multipart_item 2]
if {[string equal "" $mime_disposition]} {
if {![string equal "" $mime_filename]} {
set mime_disposition "attachment; filename=$mime_filename"
} else {
set mime_disposition "inline"
}
} else {
if {![string equal "" $mime_filename]} {
set mime_disposition \
"$mime_disposition; filename=$mime_filename"
}
}
set content [acs_mail_encode_content $ci_id]
while {[regexp -- "--$boundary--" $content]} {
set boundary "=$boundary"
}
lappend contents [list $mime_disposition $content]
}
if [db_0or1row acs_mail_body_to_mime_get_content_simple {
select content, mime_type as v_content_type
from cr_revisions
where revision_id = :revision_id
}] {
if [string equal $storage_type text] {
ns_log Debug "acs-mail: encode: one part hit $content_item_id"
return [list $v_content_type $content]
} else {
# this content is in the file system or a blob
ns_log Debug "acs-mail: encode: binary content $content_item_id"
if [string equal $storage_type file] {
ns_log Debug "acs-mail: encode: file $content_item_id"
set encoded_content [acs_mail_uuencode_file [cr_fs_path]$content]
} else {
# Defaults
return {
"text/plain; charset=us-ascii"
"An OpenACS object was unable to be encoded here.\n"
}
ns_log Debug "acs-mail: encode: lob $content_item_id"
# Blob. Now we need to decide if this is binary
# so we can uuencode it if necessary.
# We'll use the mime type to decide
if { [string first "text" $v_content_type] == 0 } {
ns_log Debug "acs-mail: encode: plain content"
set encoded_content "$content"
} else {
# binary content - copy the blob to temp file
# that we will then uuencode
set file [ns_tmpnam]
db_blob_get_file copy_blob_to_file "
select r.content, i.storage_type
from cr_revisions r, cr_items i
where r.revision_id = $revision_id and
r.item_id = i.item_id " -file $file
ns_log Debug "acs-mail: encode: binary content"
set encoded_content [acs_mail_uuencode_file $file]
}
}
set content_type \
"multipart/[acs_mail_multipart_type $content_item_id]; boundary=\"$boundary\""
set content ""
foreach {cont} $contents {
set c_disp [lindex $cont 0]
set c_type [lindex [lindex $cont 1] 0]
set c_cont [lindex [lindex $cont 1] 1]
append content "--$boundary\n"
append content "Content-Type: $c_type\n"
if { [string first "text" $c_type] != 0 } {
# not a text item: therefore base64
append content "Content-Transfer-Encoding: base64\n"
}
append content "Content-Disposition: $c_disp\n"
append content "\n"
append content $c_cont
append content "\n\n"
}
append content "--$boundary--\n"
return [list $content_type $content]
return [list $v_content_type $encoded_content]
}
}
} else {
# This is a multipart item.
# Harder. Oops.
ns_log Debug "acs-mail: encode: multipart $content_item_id"
set boundary "=-=-="
set contents {}
# Get the component pieces
set multipart_list [db_list_of_lists acs_mail_body_to_mime_get_contents {
select mime_filename, mime_disposition, content_item_id as ci_id
from acs_mail_multipart_parts
where multipart_id = :content_item_id
order by sequence_number
}]
# Defaults
return {
if ![empty_string_p $multipart_list] {
foreach multipart_item $multipart_list {
set mime_filename [lindex $multipart_item 0]
set mime_disposition [lindex $multipart_item 1]
set ci_id [lindex $multipart_item 2]
if {[string equal "" $mime_disposition]} {
if {![string equal "" $mime_filename]} {
set mime_disposition "attachment; filename=$mime_filename"
} else {
set mime_disposition "inline"
}
} else {
if {![string equal "" $mime_filename]} {
set mime_disposition \
"$mime_disposition; filename=$mime_filename"
}
}
set content [acs_mail_encode_content $ci_id]
while {[regexp -- "--$boundary--" $content]} {
set boundary "=$boundary"
}
lappend contents [list $mime_disposition $content]
}
} else {
# Defaults
return {
"text/plain; charset=us-ascii"
"An OpenACS object was unable to be encoded here.\n"
}
}
set content_type \
"multipart/[acs_mail_multipart_type $content_item_id]; boundary=\"$boundary\""
set content ""
foreach {cont} $contents {
set c_disp [lindex $cont 0]
set c_type [lindex [lindex $cont 1] 0]
set c_cont [lindex [lindex $cont 1] 1]
append content "--$boundary\n"
append content "Content-Type: $c_type\n"
if { [string first "text" $c_type] != 0 } {
# not a text item: therefore base64
append content "Content-Transfer-Encoding: base64\n"
}
append content "Content-Disposition: $c_disp\n"
append content "\n"
append content $c_cont
append content "\n\n"
}
append content "--$boundary--\n"
return [list $content_type $content]
}
# Defaults
return {
"text/plain; charset=us-ascii"
"An OpenACS object was unable to be encoded here.\n"
}
}
ad_proc -private acs_mail_body_to_output_format {
......@@ -404,7 +399,8 @@ ad_proc -private acs_mail_process_queue {
from acs_mail_queue_outgoing
} {
set to_send [acs_mail_body_to_output_format -link_id $message_id]
set to_send_2 [list $envelope_to $envelope_from [lindex $to_send 2] [lindex $to_send 3] [lindex $to_send 4]]
set to_send_2 [list $envelope_to $envelope_from [lindex $to_send 2] [lindex $to_send 3] [lindex $to_send 4]]
ns_log notice "acs_mail_process_queue: to_send_2=$to_send_2"
if [catch {
eval ns_sendmail $to_send_2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment