intrasite-message/ 0040700 0000000 0000000 00000000000 10400202505 013156 5 ustar root root intrasite-message/sql/ 0040700 0000000 0000000 00000000000 10400202505 013755 5 ustar root root intrasite-message/sql/oracle/ 0040700 0000000 0000000 00000000000 10400202505 015222 5 ustar root root intrasite-message/sql/postgresql/ 0040700 0000000 0000000 00000000000 10400202505 016160 5 ustar root root intrasite-message/sql/postgresql/intrasite-message-create.sql 0100600 0000000 0000000 00000014245 10376312077 023615 0 ustar root root --
-- The Intrasite-Message Package
--
-- @author Richard Hamilton (richard.hamilton@webteamworks.com)
-- @version $Id:
--
--
-- GNU GPL v2
--
create table im_folder (
folder_id integer
not null
primary key,
folder_name varchar(50)
not null,
user_id integer,
created_timestampz timestamptz not null,
immutable_p boolean default 'f'
);
comment on column im_folder.immutable_p is '
Users will be able to create and delete folders without restriction. There is a need for
a means of distinguishing between user folders and default application folders that must
not be deleted. The immutable flag marks a folder as not available for deletion or
modification by any user.
';
create sequence im_folder_id_seq start 5;
insert into im_folder (folder_id, folder_name, created_timestampz, immutable_p)
values (1, 'In-box', now(), 't');
insert into im_folder (folder_id, folder_name, created_timestampz, immutable_p)
values (2, 'Sent-box', now(), 't');
insert into im_folder (folder_id, folder_name, created_timestampz, immutable_p)
values (3, 'Drafts', now(), 't');
insert into im_folder (folder_id, folder_name, created_timestampz, immutable_p)
values (4, 'Deleted', now(), 't');
create table im_address_mode (
mode_id integer
not null
primary key,
mode_desc varchar(8)
not null
);
insert into im_address_mode (mode_id, mode_desc) values (0,'Sent by');
insert into im_address_mode (mode_id, mode_desc) values (1,'To');
insert into im_address_mode (mode_id, mode_desc) values (2,'Cc');
insert into im_address_mode (mode_id, mode_desc) values (3,'Bcc');
create sequence im_message_id_seq;
create table im_message (
message_id integer
primary key,
sender_user_id integer
not null
constraint im_sender_user_id_fk
references users,
subject varchar(500),
body text,
sent_p boolean default 'f',
sent_timestamptz timestamptz,
priority_p boolean default 'f',
created_timestampz timestamptz not null,
deleted_p boolean default 'f',
deleted_timestampz timestamptz
);
comment on table im_message is '
This is the main table for the package and is to hold the messages themselves.
';
comment on column im_message.message_id is '
Primary key.
';
comment on column im_message.sender_user_id is '
Constrained to reference the user_id of the openacs users table. Only registered users will
be able to send and receive messages.
';
comment on column im_folder.folder_id is '
Constrained to reference the folder_id of the im_folder table. A message can only be in one
folder at a time.
';
comment on column im_message.priority_p is '
We must provide the facility for a message to be entered but not be sent, and then permit
editing of the message right up until it has been sent. The default "Drafts" folder will
be used to store messages that have not been sent, however the sent_p flag is required to
prevent a sent message being edited irrespective of the folder in which it resides. The
folders are for user convenience and should not be used to store message meta-data. It will
probably make sense to prevent a sent message being moved into the "Drafts" folder to
avoid confusion.
';
comment on column im_message.priority_p is '
To mark a message has a higher priotity.
';
-- im_addressees
-- this table will store the user_ids of those users to whom a message is addressed.
create table im_addressees (
message_id integer
not null
constraint im_message_id_fk
references im_message ON DELETE CASCADE,
addressee_id integer
not null
constraint user_id_fk
references users,
address_mode_id integer
not null
constraint address_mode_id_fk
references im_address_mode,
read_p boolean default 'f',
folder_id integer default 1
not null
constraint im_folder_id_fk
references im_folder,
deleted_p boolean default 'f',
deleted_timestampz timestamptz,
PRIMARY KEY (message_id, addressee_id, address_mode_id)
);
comment on table im_addressees is '
This table holds the addressee information and folder mapping information for each user. The
primary key is to create a unique constraint to ensure that each addressee can only be
addressed once by each address mode. The folder_id column
';
comment on column im_addressees.folder_id is '
Constrained to reference the folder_id of the im_folder table. A message can only be in one
folder at a time. The folder_id column is to allow each user to have a received message in a
folder of their choice. The folder information for the sender is stored here also and there
is a special addressee mode "0" that signifies "Sent-by".
';
comment on column im_addressees.deleted_p is '
When a message is deleted by the sender, the information is stored in the im_messages table.
However a user that has received that message must still be able to read it after the sender
has deleted it and so must have independent control of the message status. The intention is
that the message display query will not respect the im_message delete status but rather will
refer to the status info held here for each addressee.
';
comment on column im_addressees.read_p is '
Whether an addressee has read the message. This attribute is not really relevant for the sender
and so this special case will be handled by setting read_p to true for the sender during the
message send process.
';
-- Need to add a table to hold attachments. Table should be able to hold images and other
-- files in blob fields.
intrasite-message/sql/postgresql/intrasite-message-drop.sql 0100600 0000000 0000000 00000003567 10376330604 023317 0 ustar root root --
-- The Intrasite-Message Package
--
-- @author Richard Hamilton (richard.hamilton@webteamworks.com)
-- @version $Id:
--
--
-- GNU GPL v2
--
-- Uncomment once package is installed by OpenACS installer.
-- select drop_package('intrasite-message');
-- drop permissions
-- No permissions to drop since the only party able to read a message is the user.
-- drop objects
-- No objects to drop since there was no reason to use either the ACS Object model
-- or the Content Repository.
--drop tables
drop table im_message cascade;
drop table im_addressees cascade;
drop table im_address_mode;
drop table im_folder;
drop function im_folder__new (varchar,integer, boolean);
drop function im_folder__del (integer, integer);
drop function im_message__folder_owner_p (integer, integer);
drop function im_message__new (integer,varchar,varchar,boolean);
drop function im_message__admin_del (integer);
drop function im_message__del (integer, integer);
drop function im_message__delete (integer, integer);
drop function im_message__move (integer, integer, integer);
drop function im_folder_display__links (integer);
drop function im_message__send (integer,integer);
drop function im_message__sent_p (integer);
drop function im_message__author_p (integer, integer);
drop function im_message__addressee_p (integer, integer);
drop function im_addressee__insert (integer, integer, integer, integer);
drop function im_addressee__remove (integer, integer, integer, integer);
drop function im_to_addressees_horiz_list (integer);
drop function count_of_pending_messages (integer, integer);
drop function im_mark_read_p (integer, integer);
drop function im_embolden_unread (varchar, integer, integer);
drop function im_message__user_bcc_p (integer, integer);
drop function im_message__new_reply (integer, varchar, varchar, boolean, integer, integer);
drop function im_message__priority_sign_p (boolean);
intrasite-message/sql/postgresql/intrasite-message-plsql-create.sql 0100600 0000000 0000000 00000055551 10376332243 024750 0 ustar root root --
-- The Intrasite-Message Package
--
-- @author Richard Hamilton (richard.hamilton@webteamworks.com)
-- @version $Id:
--
--
-- GNU GPL v2
--
------ start of folder new proc
-- select define_function_args('im_folder__new','folder_name','user_id, 'immutable_p');
create or replace function im_folder__new (varchar,integer, boolean)
returns boolean as '
declare
p_folder_name alias for $1; -- The name of the required new folder.
p_user_id alias for $2; -- The user_id of the user to which the folder belongs.
p_immutable_p alias for $3; -- System default folder or user changeable.
-- local vars
v_folder_id integer;
begin
select nextval(''im_folder_id_seq'') into v_folder_id;
insert into im_folder (
folder_id,
folder_name,
user_id,
created_timestampz,
immutable_p
)
values (
v_folder_id,
p_folder_name,
p_user_id,
now(),
p_immutable_p
);
if FOUND = true then
raise NOTICE ''Creating folder - %'',p_folder_name;
else
raise NOTICE ''Folder create failed'';
end if;
return FOUND;
end;' language 'plpgsql';
------ end folder new proc
------ start of folder del proc
-- select define_function_args('im_folder__del','folder_id','user_id');
create or replace function im_folder__del (integer, integer)
returns boolean as '
declare
p_folder_id alias for $1;
p_user_id alias for $2;
-- local vars
v_message_count integer;
v_owner_p boolean;
begin
-- Start by checking that the requesting user owns the folder.
select im_message__folder_owner_p(p_folder_id, p_user_id) into v_owner_p;
if v_owner_p = true then
-- Check that the folder is empty to protect against url surgery. Remember that
-- deleted_p is only set when the message is deleted from the ''deleted'' folder.
select count(*) into v_message_count
from im_addressees
where folder_id = p_folder_id
and deleted_p = false;
if v_message_count = 0 then
-- Cater for possibility that a deleted and therefore invisible message remains in a user
-- added folder. This should never happen! :-)
update im_addressees
set folder_id = 4
where deleted_p = true
and folder_id = p_folder_id;
delete from im_folder
where folder_id = p_folder_id
and user_id = p_user_id
and immutable_p = false;
else
FOUND := false;
end if;
else
FOUND := false;
end if;
if FOUND = true then
raise NOTICE ''Deleting folder with id - %'',p_folder_id;
else
raise NOTICE ''Delete failed'';
end if;
return FOUND;
end;' language 'plpgsql';
------ end folder del proc
------ start of im_message__folder_owner_p
-- select define_function_args('im_message__folder_owner_p','folder_id', 'user_id');
create or replace function im_message__folder_owner_p (integer, integer)
returns boolean as '
declare
p_folder_id alias for $1;
p_user_id alias for $2;
-- local vars
v_owner_p boolean;
begin
-- Start by checking that the requesting user owns the folder.
select true into v_owner_p
from im_folder
where folder_id = p_folder_id
and user_id = p_user_id
and immutable_p = false;
if v_owner_p = true then
return v_owner_p;
else
return false;
end if;
end;' language 'plpgsql';
------ end of im_message__folder_owner_p proc
------ start of message new proc
-- select define_function_args('im_message__new','sender_user_id','subject','body','priority_p');
create or replace function im_message__new (integer,varchar,varchar,boolean)
returns integer as '
declare
p_sender_user_id alias for $1; -- The id of the user that is sending the message.
p_subject alias for $2; -- The subject of the message.
p_body alias for $3; -- The body text of the message.
p_priority_p alias for $4; -- Whether the message is high priority or not.
-- local vars
v_message_id integer;
begin
select nextval(''im_message_id_seq'') into v_message_id;
insert into im_message (
message_id,
sender_user_id,
subject,
body,
priority_p,
created_timestampz
)
values (
v_message_id,
p_sender_user_id,
p_subject,
p_body,
p_priority_p,
now()
);
if FOUND = true then
raise NOTICE ''Creating message from user_id - %'',p_sender_user_id;
insert into im_addressees (
message_id,
addressee_id,
address_mode_id,
folder_id
)
values (
v_message_id,
p_sender_user_id,
0,
3
);
else
raise NOTICE ''Message create failed'';
v_message_id := FOUND;
end if;
return v_message_id;
end;' language 'plpgsql';
------ end of message new proc
------ start of administrators message del proc
-- select define_function_args('im_message__admin_del','message_id');
create or replace function im_message__admin_del (integer)
returns boolean as '
declare
p_message_id alias for $1;
begin
-- This function deletes a message by flagging deleted_p = true in the im_message table which
-- has the effect of removing it from view for all users.
update im_message set deleted_p = true, deleted_timestampz = now()
where message_id = p_message_id
and deleted_p = false;
if FOUND = true then
raise NOTICE ''Deleting message with id - %'',p_message_id;
else
raise NOTICE ''Message delete failed'';
end if;
return FOUND;
end;' language 'plpgsql';
------ end of administrators message del proc
------ start of message del proc
-- select define_function_args('im_message__del','message_id','user_id');
create or replace function im_message__del (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
begin
update im_addressees set deleted_p = true, deleted_timestampz = now()
where message_id = p_message_id
and addressee_id = p_user_id
and folder_id = 4
and deleted_p = false;
if FOUND = true then
raise NOTICE ''Deleting message with id - %'',p_message_id;
else
raise NOTICE ''Message delete failed'';
end if;
return FOUND;
end;' language 'plpgsql';
------ end of message del proc
------ start of message delete proc
-- select define_function_args('im_message__delete','message_id','user_id');
create or replace function im_message__delete (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
--local vars
v_folder_id integer;
v_addressee_p boolean;
begin
select im_message__addressee_p(p_message_id, p_user_id) into v_addressee_p;
if v_addressee_p = true then
select folder_id from im_addressees into v_folder_id
where message_id = p_message_id
and addressee_id = p_user_id;
if v_folder_id = 4 then
perform im_message__del(p_message_id, p_user_id);
else
update im_addressees set folder_id = 4
where message_id = p_message_id
and addressee_id = p_user_id
and folder_id <> 4
and deleted_p = false;
end if;
else
raise NOTICE ''Permission denied'';
FOUND := false;
end if;
if FOUND = true then
raise NOTICE ''Delete operation successful for message with id - %'',p_message_id;
else
raise NOTICE ''Delete operation failed'';
end if;
return FOUND;
end;' language 'plpgsql';
------ end message delete proc
------ start of message move proc
-- select define_function_args('im_message__move','message_id','user_id');
create or replace function im_message__move (integer, integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
p_new_folder_id alias for $3;
--local vars
v_folder_id integer;
v_addressee_p boolean;
begin
select im_message__addressee_p(p_message_id, p_user_id) into v_addressee_p;
if v_addressee_p = true then
update im_addressees set folder_id = p_new_folder_id
where message_id = p_message_id
and addressee_id = p_user_id
and folder_id <> p_new_folder_id
and deleted_p = false;
else
raise NOTICE ''Permission denied'';
FOUND := false;
end if;
if FOUND = true then
raise NOTICE ''Move operation successful for message with id - %'',p_message_id;
else
raise NOTICE ''Move operation failed'';
end if;
return FOUND;
end;' language 'plpgsql';
------ end message move proc
------ start of folder display procs
-- select define_function_args('im_message__del','folder_id');
create or replace function im_folder_display__links (integer)
returns varchar as '
declare
p_folder_id alias for $1;
-- local vars
v_return_string varchar;
v_num_messages integer;
begin
select count(*) into v_num_messages
from im_addressees
where folder_id = p_folder_id
and deleted_p = false;
if v_num_messages <> 0 then
v_return_string := ''| Edit |'';
else
v_return_string := ''| Del |'';
end if;
return v_return_string;
end;' language 'plpgsql';
------ end folder display procs
------ start of message send proc
-- select define_function_args('im_message__send','message_id','user_id');
create or replace function im_message__send (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
-- local vars
v_sent_p boolean;
v_author_p boolean;
v_success_p boolean;
begin
v_sent_p := im_message__sent_p(p_message_id);
v_author_p := im_message__author_p(p_message_id, p_user_id);
if v_sent_p = true then
raise NOTICE ''Attempt to send a message that has already been "sent". message_id - %'',p_message_id;
v_success_p := FALSE;
elsif v_author_p = false then
raise NOTICE ''Attempt to send a message by user who is not the "sender". message_id- %'',p_message_id;
v_success_p := FALSE;
else
update im_message set sent_p = true, sent_timestamptz = now()
where message_id = p_message_id
and deleted_p = false;
if FOUND = FALSE then
raise NOTICE ''Message send failed for message_id - %'',p_message_id;
v_success_p := FALSE;
else
raise NOTICE ''Message send successful for message_id - %'',p_message_id;
v_success_p := FOUND;
update im_addressees set folder_id = 2
where message_id = p_message_id
and address_mode_id = 0
and deleted_p = false;
end if;
end if;
return v_success_p;
end;' language 'plpgsql';
------ end of message send proc
------ start of message sent? proc
-- select define_function_args('im_message__sent_p','message_id');
create or replace function im_message__sent_p (integer)
returns boolean as '
declare
p_message_id alias for $1;
-- local vars
v_sent_p boolean;
begin
select true into v_sent_p
from im_message
where message_id = p_message_id
and sent_p = true;
if v_sent_p = true then
return TRUE;
else
return FALSE;
end if;
end;' language 'plpgsql';
------ end of message sent proc
------ start of author_p proc
-- select define_function_args('im_message__author_p','message_id','user_id');
create or replace function im_message__author_p (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
-- local vars
v_author_p boolean;
begin
select true into v_author_p
from im_message
where message_id = p_message_id
and sender_user_id = p_user_id;
if v_author_p = true then
return TRUE;
else
return FALSE;
end if;
end;' language 'plpgsql';
------ end of author_p proc
-- select define_function_args('im_message__addressee_p','message_id','user_id');
create or replace function im_message__addressee_p (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
-- local vars
v_addressee_p boolean;
-- Only the sender and addreessees have the ability to do things with a message. This function
-- answers the question ''Is this user allowed to do that?''. Note that the sender is considered
-- an addressee,
begin
select true into v_addressee_p
from im_addressees
where message_id = p_message_id
and addressee_id = p_user_id;
if v_addressee_p = true then
return TRUE;
else
return FALSE;
end if;
end;' language 'plpgsql';
------ end of addressee_p proc
------ start of addressee insert proc
-- select define_function_args('im_addressee__insert','message_id','selected_addressee_id','address_mode_id','user_id');
create or replace function im_addressee__insert (integer, integer, integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_selected_addressee_id alias for $2;
p_address_mode_id alias for $3;
p_user_id alias for $4;
-- local vars
v_sent_p boolean;
v_author_p boolean;
v_success_p boolean;
begin
v_sent_p := im_message__sent_p(p_message_id);
v_author_p := im_message__author_p(p_message_id, p_user_id);
if v_sent_p = true then
raise NOTICE ''Attempt to insert addressees of "sent" message. message_id - %'',p_message_id;
v_success_p := FALSE;
elsif v_author_p = false then
raise NOTICE ''Attempt to insert addressees by user who is not the "sender". message_id - %'',p_message_id;
v_success_p := FALSE;
else
insert into im_addressees (message_id, addressee_id, address_mode_id)
values (p_message_id, p_selected_addressee_id, p_address_mode_id);
v_success_p := FOUND;
if FOUND = FALSE then
raise NOTICE ''Insert of addressee failed for message_id - %'',p_message_id;
else
raise NOTICE ''Addressee insert successful for message_id - %'',p_message_id;
end if;
end if;
return v_success_p;
end;' language 'plpgsql';
------ end of im_addressee__insert proc
----- start of addressee remove proc
-- select define_function_args('im_addressee__remove','message_id','selected_addressee_id','user_id');
create or replace function im_addressee__remove (integer, integer, integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_selected_addressee_id alias for $2;
p_address_mode_id alias for $3;
p_user_id alias for $4;
-- local vars
v_sent_p boolean;
v_author_p boolean;
v_success_p boolean;
begin
v_sent_p := im_message__sent_p(p_message_id);
v_author_p := im_message__author_p(p_message_id, p_user_id);
if v_sent_p = true then
raise NOTICE ''Attempt to remove addressees of a "sent" message. message_id - %'',p_message_id;
v_success_p := FALSE;
elsif v_author_p = false then
raise NOTICE ''Attempt to remove addressees by user who is not the "sender". message_id - %'',p_message_id;
v_success_p := FALSE;
else
delete from im_addressees
where message_id = p_message_id
and addressee_id = p_selected_addressee_id
and address_mode_id = p_address_mode_id;
v_success_p := FOUND;
if FOUND = FALSE then
raise NOTICE ''Removal of addressee failed for message_id - %'',p_message_id;
else
raise NOTICE ''Addressee removal successful for message_id - %'',p_message_id;
end if;
end if;
return v_success_p;
end;' language 'plpgsql';
------ end of im_addressee__remove proc
------ start of to_addressees_horiz_list proc
-- select define_function_args('to_addressees_horiz_list','message_id');
create or replace function im_to_addressees_horiz_list (integer)
returns varchar as '
declare
p_message_id alias for $1;
-- local vars
addressee record;
v_addressees varchar;
begin
v_addressees := '''';
for addressee in
select p.first_names||'' ''||p.last_name as identity
from im_message m, im_addressees a, persons p
where m.message_id = a.message_id
and a.addressee_id = p.person_id
and m.message_id = p_message_id
and a.address_mode_id = ''1''
loop
v_addressees := v_addressees||addressee.identity||''; '';
end loop;
v_addressees := trim ( trailing ''; '' from v_addressees );
return v_addressees;
end;' language 'plpgsql';
------ end of to_addressees_horiz_list proc
------ start of count_of_pending_messages
-- select define_function_args('count_of_pending_messages','folder_id', 'user_id');
create or replace function count_of_pending_messages (integer, integer)
returns varchar as '
declare
p_folder_id alias for $1;
p_user_id alias for $2;
-- local vars
v_message_count integer;
begin
select count(*) into v_message_count
from im_addressees a, im_message m
where a.message_id = m.message_id
and a.addressee_id = p_user_id
and a.folder_id = p_folder_id
and a.deleted_p = false
and ((a.read_p = ''f'' and m.sent_p = ''t'' and a.address_mode_id <> ''0'')
or (m.sent_p = ''f'' and m.sender_user_id = p_user_id));
if v_message_count = 0 then
v_message_count := null;
end if;
return ''(''||v_message_count||'')'';
end;' language 'plpgsql';
------ end of count_of_pending_messages proc
------ start of im_mark_read_p
-- select define_function_args('im_mark_read_p','message_id', 'user_id');
create or replace function im_mark_read_p (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
begin
update im_addressees set read_p = true
where message_id = p_message_id
and addressee_id = p_user_id
and address_mode_id <> 0;
return FOUND;
end;' language 'plpgsql';
------ end of im_mark_read_p proc
------ start of im_embolden_unread
-- select define_function_args('im_embolden_unread','message_id', 'user_id');
create or replace function im_embolden_unread (varchar, integer, integer)
returns varchar as '
declare
p_input_string alias for $1;
p_message_id alias for $2;
p_user_id alias for $3;
-- local vars
v_read_p boolean;
v_output_string varchar;
begin
select read_p into v_read_p
from im_addressees
where message_id = p_message_id
and addressee_id = p_user_id
and address_mode_id <> 0;
if v_read_p = false then
v_output_string = ''''||p_input_string||'''';
else
v_output_string = p_input_string;
end if;
return v_output_string;
end;' language 'plpgsql';
------ end of im_embolden_unread proc
------ start of im_message__user_bcc_p
-- select define_function_args('im_message__user_bcc_p','message_id', 'user_id');
create or replace function im_message__user_bcc_p (integer, integer)
returns boolean as '
declare
p_message_id alias for $1;
p_user_id alias for $2;
-- local vars
v_user_bcc_p boolean;
begin
select true into v_user_bcc_p
from im_addressees
where message_id = p_message_id
and addressee_id = p_user_id
and address_mode_id = 3;
if v_user_bcc_p = true then
return v_user_bcc_p;
else
return false;
end if;
end;' language 'plpgsql';
------ end of im_message__user_bcc_p proc
------ start of im_message__new_reply
-- select define_function_args('im_message__new', 'sender_user_id', 'subject', 'body', 'priority_p', 'original_sender_id', 'original_message_id');
create or replace function im_message__new_reply (integer, varchar, varchar, boolean, integer, integer)
returns integer as '
declare
p_sender_user_id alias for $1; -- The id of the user that is sending the reply.
p_subject alias for $2; -- The subject of the message.
p_body alias for $3; -- The body text of the message.
p_priority_p alias for $4; -- Whether the message is high priority or not.
p_original_sender_id alias for $5; -- The user_id of the person that sent the message to be replied to.
p_original_message_id alias for $6; -- The original message_id.
-- local vars
v_message_id integer; -- This will be the unique id of the new reply message.
v_cc_count integer; -- For checking how many cc addressees there are.
begin
select nextval(''im_message_id_seq'') into v_message_id;
insert into im_message (
message_id,
sender_user_id,
subject,
body,
priority_p,
created_timestampz
)
values (
v_message_id,
p_sender_user_id,
p_subject,
p_body,
p_priority_p,
now()
);
if FOUND = true then
raise NOTICE ''Created message from user_id - %'',p_sender_user_id;
insert into im_addressees (
message_id,
addressee_id,
address_mode_id,
folder_id
)
values (
v_message_id,
p_sender_user_id,
0,
3
);
if FOUND = true then
raise NOTICE ''Added user as sender to reply for message_id - %'',v_message_id;
insert into im_addressees (
message_id,
addressee_id,
address_mode_id,
folder_id
)
values (
v_message_id,
p_original_sender_id,
1,
1
);
if FOUND = true then
raise NOTICE ''Added original sender as recipient for reply with message_id - %'',v_message_id;
select count(*) into v_cc_count
from im_addressees
where message_id = p_original_message_id
and addressee_id not in (p_original_sender_id, p_sender_user_id)
and address_mode_id <> 3;
if v_cc_count > 0 then
insert into im_addressees (
select
v_message_id,
addressee_id,
address_mode_id,
false,
1 as folder_id
from im_addressees
where message_id = p_original_message_id
and addressee_id not in (p_original_sender_id, p_sender_user_id)
and address_mode_id <> 3
);
end if;
if FOUND = true then
raise NOTICE ''Addressees for cc added to reply with message_id - %'',v_message_id;
else
raise NOTICE ''Addition of cc addressees failed'';
v_message_id := FOUND;
end if;
else
raise NOTICE ''Addition of original sender to reply as recipient failed'';
v_message_id := FOUND;
end if;
else
raise NOTICE ''Addition of user to reply as sender failed'';
v_message_id := FOUND;
end if;
else
raise NOTICE ''Creation of reply failed'';
v_message_id := FOUND;
end if;
return v_message_id;
end;' language 'plpgsql';
------ end of im_message__new_reply
------ start of im_message__priority_sign_p
-- select define_function_args('im_message__priority_sign_p','value');
create or replace function im_message__priority_sign_p (boolean)
returns varchar as '
declare
p_value alias for $1;
begin
if p_value = true then
return ''!'';
else
return '''';
end if;
end;' language 'plpgsql';
------ end of im_message__priority_sign_p proc
intrasite-message/tcl/ 0040700 0000000 0000000 00000000000 10400202505 013740 5 ustar root root intrasite-message/www/ 0040700 0000000 0000000 00000000000 10400202505 014002 5 ustar root root intrasite-message/www/index-postgresql.xql 0100600 0000000 0000000 00000004536 10376327746 020102 0 ustar root root
select m.message_id, im_message__priority_sign_p(m.priority_p) as priority_p, im_embolden_unread(im_to_addressees_horiz_list(m.message_id), m.message_id, a.addressee_id) as identity, m.sender_user_id, f.folder_name, a.folder_id,
im_embolden_unread(m.subject, m.message_id, m.sender_user_id) as subject, to_char(m.sent_timestamptz,'MM/DD/YYYY HH:MI') as sent_date, a.read_p
from im_message m, persons p, im_folder f, im_addressees a
where m.sender_user_id = p.person_id
and m.message_id = a.message_id
and a.addressee_id = $user_id
and a.address_mode_id = 0
and a.folder_id = f.folder_id
and a.deleted_p = false
$context_clause
union
select m.message_id, im_message__priority_sign_p(m.priority_p) as priority_p, im_embolden_unread(p.first_names||' '||p.last_name, m.message_id, a.addressee_id) as identity, m.sender_user_id, f.folder_name, a.folder_id,
im_embolden_unread(m.subject, m.message_id, a.addressee_id) as subject, to_char(m.sent_timestamptz,'MM/DD/YYYY HH:MI') as sent_date, a.read_p
from im_message m, persons p, im_folder f, im_addressees a
where m.message_id = a.message_id
and a.addressee_id = p.person_id
and a.folder_id = f.folder_id
and m.sent_p = 't'
and a.addressee_id = $user_id
and a.address_mode_id <> 0
and a.deleted_p = false
$context_clause
$orderby
select folder_id, folder_name, count_of_pending_messages(f.folder_id, :user_id) as pending_messages, null as edit_link
from im_folder f
where immutable_p = True
union
select folder_id, folder_name, count_of_pending_messages(f.folder_id, :user_id) as pending_messages, im_folder_display__links (folder_id)
from im_folder f
where user_id = :user_id
and immutable_p = false
select folder_id, folder_name
from im_folder f
where immutable_p = True
or (immutable_p = False and user_id = :user_id)
intrasite-message/www/folder-delete.tcl 0100600 0000000 0000000 00000001327 10376145265 017250 0 ustar root root # packages/intrasite-message/www/folder-delete.tcl
ad_page_contract {
@author richard.hamilton@webteamworks.com
@creation-date 2005-09-27
@cvs-id $Id: Exp $
} {
folder_id:integer,notnull
}
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
set user_id [ad_verify_and_get_user_id]
ad_maybe_redirect_for_registration
# Ensure that the folder belongs to the requesting user.
db_1row folder_owner_p {
select im_message__folder_owner_p(:folder_id, :user_id) as folder_owner_p
}
if { [string is false $folder_owner_p] } { ad_script_abort }
db_exec_plsql delete_folder {
begin
intrasite-message.im_folder__del( :folder_id, :user_id );
end;
}
ad_returnredirect "./"
intrasite-message/www/add-remove-addressees-postgresql.xql 0100600 0000000 0000000 00000001723 10376102032 023104 0 ustar root root
select
count(*) as n_users,
sum(case when member_state = 'deleted' then 1 else 0 end) as n_deleted_users,
max(creation_date) as last_registration
from cc_users
where email not in ('anonymous', 'system')
select groups.group_id, groups.group_name, m.num as n_members, c.num as n_components
from groups, ( select group_id, count(*) as num from group_member_map gm, cc_users cu where cu.person_id = gm.member_id and cu.member_state <> 'deleted' group by group_id) m,
(select group_id, count(*) as num from group_component_map group by group_id) c
where groups.group_id = m.group_id
and groups.group_id = c.group_id
order by group_name;
intrasite-message/www/confirm-addressee-postgresql.xql 0100600 0000000 0000000 00000000361 10376102264 022337 0 ustar root root
select im_addressee__insert (:message_id, :selected_addressee, :address_mode, :user_id)
intrasite-message/www/folder-add-edit-postgresql.xql 0100600 0000000 0000000 00000001636 10376145116 021702 0 ustar root root
select folder_name
from im_folder
where folder_id = :folder_id
select folder_name
from im_folder
where folder_id = :folder_id
update im_folder
set folder_name = :folder_name
where folder_id = :folder_id
and ummutable_p = false
select im_folder__new(:folder_name, :user_id, 'false')
select im_message__folder_owner_p(:folder_id, :user_id) as folder_owner_p
intrasite-message/www/message-display-postgresql.xql 0100600 0000000 0000000 00000005550 10376151742 022046 0 ustar root root
postgresql7.1
select sender_user_id, party_name as sender, date_trunc('second', sent_timestamptz) as sent_date,
subject, body, priority_p
from im_message m, party_names p
where m.sender_user_id = p.party_id
and m.message_id = :message_id
select party_name as addressee_name, addressee_id as party_id
from im_addressees a, party_names p
where a.addressee_id = p.party_id
and address_mode_id = 1
and exists (
select * from im_message m
where m.message_id = :message_id
and a.message_id = m.message_id)
select party_name as addressee_name, addressee_id as party_id
from im_addressees a, party_names p
where a.addressee_id = p.party_id
and address_mode_id = 2
and exists (
select * from im_message m
where m.message_id = :message_id
and a.message_id = m.message_id)
select party_name as addressee_name, addressee_id as party_id
from im_addressees a, party_names p
where a.addressee_id = p.party_id
and address_mode_id = 3
and exists (
select * from im_message m
where m.message_id = :message_id
and a.message_id = m.message_id)
select im_message__user_bcc_p(:message_id, :user_id) as user_bcc_p
select party_name as bcc_user_name
from party_names
where party_id = :user_id
select im_message__send (:message_id) as message_send_successful_p
select im_message__sent_p(:message_id) as message_sent_p
select im_mark_read_p (:message_id, :user_id)
select im_message__author_p(:message_id, :user_id) as message_author_p
select im_message__addressee_p(:message_id, :user_id) as message_addressee_p
intrasite-message/www/folder-delete-postgresql.xql 0100600 0000000 0000000 00000000375 10376145316 021472 0 ustar root root
postgresql7.1
select im_folder__del( :folder_id, :user_id );
intrasite-message/www/message-display.adp 0100600 0000000 0000000 00000010727 10376135504 017605 0 ustar root root @title@@context@
intrasite-message/www/index.tcl 0100600 0000000 0000000 00000006751 10376330251 015641 0 ustar root root ad_page_contract {
@author Richard Hamilton (richard.hamilton@webteamworks.com)
@creation-date 18-09-2005
@cvs-id@ $Id$
Intrasite Message display page
} {
{extra_stuff:optional ""}
{objects_page:optional "1"}
{objects_orderby:optional "sent_date"}
{objects_context:optional "In-Box"}
}
# the unique identifier for this package
set package_id [ad_conn package_id]
set package_url [ad_conn package_url]
set user_id [ad_conn user_id]
# Check permissions on the package_id
ad_require_permission $package_id read
set title "Secure Messages"
set context [ list "Message List" ]
set extra_stuff "user_id"
lappend extra_stuff "$user_id"
set orderby "order by $objects_orderby"
set context_column "folder_name"
if {[empty_string_p $objects_context] } {
set context_clause ""
} else {
set context_clause "and upper($context_column) like upper('$objects_context%')"
}
# Set identity column header to be 'From' unless in the sent messages folder.
if { $objects_context == "Sent-box" || $objects_context == "Drafts" } {
set message_table_info {
{ priority_p "" {priority_p} "
" }
}
}
# Get count of unread or unsent messages for folder list
set sample_html [tools::paginate -name objects -page objects_page \
-queryname get_messages -context_field $context_column -array_name object_paginate_info \
-table_info $message_table_info -extra_vars [list extra_stuff]]
set folder_table_info {
{ folder_name "Folder" {folder_name} "
\n
$folder_name "}
{ pending_messages "" {pending_messages} "$pending_messages" }
{ edit_link "" {} r }
}
set folder_panel [ad_table -Tband_colors { {} {} } -Theader_row_extra { align="left" bgcolor="#f8f8f8"} get_folders "" $folder_table_info]
db_multirow folders_for_select folders_for_select {
select folder_id, folder_name
from im_folder f
where immutable_p = True
or (immutable_p = False and user_id = :user_id)
}
ad_return_template
intrasite-message/www/message-display.tcl 0100600 0000000 0000000 00000012167 10376135370 017624 0 ustar root root ad_page_contract {
@author Richard Hamilton
@creation-date 2005-09-27
} {
message_id:integer,notnull
{send_message_p:boolean 0}
{confirm_send_p:boolean 0}
} -properties {
title:onevalue
context:onevalue
sender:onevalue
subject:onevalue
body:onevalue
}
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] read
# Obtain the user_id of the requesting user
set user_id [ad_verify_and_get_user_id]
# Now perform checks to ensure that the requesting user is supposed to be looking at this message!
# Is this a 'sent' message or one in the process of being created?
db_1row message_sent_p {
select im_message__sent_p(:message_id) as message_sent_p
}
# Is the requesting user the author?
db_1row message_author_p {
select im_message__author_p(:message_id, :user_id) as message_author_p
}
# Is the requesting user an addressee?
db_1row message_addressee_p {
select im_message__addressee_p(:message_id, :user_id) as message_addressee_p
}
# If the message has not been sent yet then the only person who should see it is the
# author, so if the user is not the author, abort the page.
# If the message has been sent, the only people who should see it are addressees.
if { [string is false $message_sent_p] } {
if { [string is false $message_author_p] } { ad_script_abort }
} elseif { [string is false $message_addressee_p] } {
ad_script_abort
}
set context [list "Display Message"]
db_1row message-display {
select sender_user_id, party_name as sender, date_trunc('second', sent_timestamptz) as sent_date, subject, body, priority_p
from im_message m, party_names p
where m.sender_user_id = p.party_id
and m.message_id = :message_id
}
db_multirow to_addressees to_addressees {
select party_name as addressee_name, addressee_id as party_id
from im_addressees a, party_names p
where a.addressee_id = p.party_id
and address_mode_id = 1
and exists (
select * from im_message m
where m.message_id = :message_id
and a.message_id = m.message_id)
}
db_multirow cc_addressees cc_addressees {
select party_name as addressee_name, addressee_id as party_id
from im_addressees a, party_names p
where a.addressee_id = p.party_id
and address_mode_id = 2
and exists (
select * from im_message m
where m.message_id = :message_id
and a.message_id = m.message_id)
}
# Is the requesting user the sender? If so user should see all bcc addressees. Have to run query
# anyway because multiple rowcount is referenced in the adp.
db_multirow bcc_addressees bcc_addressees {
select party_name as addressee_name, addressee_id as party_id
from im_addressees a, party_names p
where a.addressee_id = p.party_id
and address_mode_id = 3
and exists (
select * from im_message m
where m.message_id = :message_id
and a.message_id = m.message_id)
}
# Prepare the blank value.
set bcc_user_name ""
if { [string is false $message_author_p] } {
# Is the requesting user a bcc addressee? If so user should see self in bcc addressees field.
db_1row user_bcc_p {
select im_message__user_bcc_p(:message_id, :user_id) as user_bcc_p
}
if { [string is true $user_bcc_p] } {
# Lookup the user's name for the ui display.
db_1row bcc_user_name {
select party_name as bcc_user_name
from party_names
where party_id = :user_id
}
}
}
set title "Message from $sender dated: $sent_date"
set sender [ad_text_to_html $sender]
set subject [ad_text_to_html $subject]
set body [ad_text_to_html $body]
# check to see if this user has viewed the message, if not set read_p to true for that user.
db_1row mark_read_if_appropriate {
select im_mark_read_p (:message_id, :user_id)
}
# This file displays a message when received, and both prior to edit and also prior to sending. Checks
# here are for requirement to send and confirmation to send.
if { [string is true $message_author_p] && [string is false $message_sent_p] && [string is true $send_message_p] && [string is false $confirm_send_p] } {
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
set title "Send Message"
set context [list $title]
set yes_url "./message-display?[export_vars { {message_id $message_id} {send_message_p 1} { confirm_send_p 1 } }]"
set no_url "./message-display?[export_vars { {message_id $message_id} {send_message_p 0} } ]"
return
}
if { [string is true $message_author_p] && [string is false $message_sent_p] && [string is true $send_message_p] && [string is true $confirm_send_p] } {
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
db_1row send_message {
select im_message__send (:message_id, :user_id) as message_send_successful_p
}
}
db_1row message_sent_p {
select im_message__sent_p(:message_id) as message_sent_p
}
ad_return_template
intrasite-message/www/folder-add-edit.tcl 0100600 0000000 0000000 00000004076 10376145170 017460 0 ustar root root # packages/notes/www/add-edit.tcl
ad_page_contract {
@author Richard Hamilton (richard.hamilton@webteamworks.com)
@creation-date 18-09-2005
@cvs-id@ $Id$
Intrasite Message folder add/edit' page
} {
folder_id:integer,notnull,optional
} -properties {
context:onevalue
}
# the unique identifier for this package
set package_id [ad_conn package_id]
set package_url [ad_conn package_url]
set user_id [ad_conn user_id]
# Check permissions on the package_id
ad_require_permission $package_id write
set title "Add or Edit Folder"
if {[info exists folder_id]} {
ad_require_permission $package_id write
# Need to replace this with a check for url surgery - i.e. check user_id and immutable_p
# Ensure that the folder belongs to the requesting user.
db_1row folder_owner_p {
select im_message__folder_owner_p(:folder_id, :user_id) as folder_owner_p
}
if { [string is false $folder_owner_p] } { ad_script_abort }
set context [list "Edit Folder"]
} else {
ad_require_permission $package_id create
set context [list "Add New Folder"]
}
template::form create new_folder
if {[template::form is_request new_folder] && [info exists folder_id]} {
template::element create new_folder folder_id \
-widget hidden \
-datatype number \
-value $folder_id
db_1row get_folder_name {
select folder_name
from im_folder
where folder_id = :folder_id
}
} else {
set folder_name {}
}
template::element create new_folder folder_name \
-datatype text \
-label "Folder Name" \
-html { size 30 } \
-value $folder_name
if [template::form is_valid new_folder] {
form get_values new_folder folder_name
set peeraddr [ad_conn peeraddr]
if [info exists folder_id] {
db_dml update_folder_name {
update im_folder
set folder_name = :folder_name
where folder_id = :folder_id
}
} else {
db_1row folder_new {
select im_folder__new(:folder_name, :user_id, 'false')
}
}
ad_returnredirect "./"
}
set title [ad_quotehtml $title]
ad_return_template
intrasite-message/www/folder-add-edit.adp 0100600 0000000 0000000 00000000221 10327712115 017421 0 ustar root root @title@@context@
intrasite-message/www/search-postgresql.xql 0100600 0000000 0000000 00000000557 10341424460 020216 0 ustar root root
select group_name from user_groups where group_id = :limit_to_users_in_group_id
select mode_desc, mode_id from im_address_mode
intrasite-message/www/message-add-edit.tcl 0100600 0000000 0000000 00000017546 10376334673 017647 0 ustar root root # packages/notes/www/add-edit.tcl
ad_page_contract {
@author Richard Hamilton (richard.hamilton@webteamworks.com)
@creation-date 18-09-2005
@cvs-id@ $Id$
Intrasite Message message add/edit' page
} {
{message_id:integer,notnull,optional}
{original_message_id:integer,notnull,optional}
{response:notnull,optional}
{original_sender_user_id:notnull,optional}
{original_message_id:notnull,optional}
} -properties {
context:onevalue
}
# the unique identifier for this package
set package_id [ad_conn package_id]
set package_url [ad_conn package_url]
set user_id [ad_conn user_id]
# This script has to take care of all message creation and editing. Consequently it has
# to determine the following things:
#
# 1) Does the user 'own' the message.
# 2) Is the message editable or has it been sent already and is therefore 'cast in stone'.
#
# We also need to know what action is required:
#
# a) Are we asking for a completely new message.
# b) Are we asking to edit an existing message.
# c) Do we want to forward a message to someone else.
# d) Do we want to reply to the sender of a message.
#
# Just a reminder:
#
# i) the package supports permissions at the package_id level
# ii) the package is a singleton.
if {[info exists message_id]} {
# Check permissions on the package_id
ad_require_permission $package_id write
# Check to make sure that this user owns the message. Users cannot edit each others' messages.
db_1row message_author_p {
select im_message__author_p(:message_id, :user_id) as message_author_p
}
if { [string is false $message_author_p] } {
ad_script_abort
}
# Check to see if message has been sent already - of so cannot be changed.
db_1row message_sent_p {
select im_message__sent_p(:message_id) as message_sent_p
}
if { $message_sent_p == "t" } {
ad_return_complaint 1 "This message is not editable - it has already been sent."
}
# If the request survives the preceeding tests then we are going to edit an existing message.
set title "Edit Message"
set context [list "Edit Message"]
} else {
# Check permissions on the package_id
ad_require_permission $package_id create
# Assume a new message - if not code below will overwrite these values
set title "New Message"
set context [list "New Message"]
# Find out whether we are creating a new message, a reply or a 'forward' and set page title accordingly.
if { [exists_and_not_null original_message_id] && [exists_and_not_null response] } {
if { $response == "reply" } {
set title "Reply to Message"
set context [list "Reply to Message"]
} elseif { $response == "forward" } {
set title "Forward Message"
set context [list "Forward Message"]
} else {
ad_script_abort
}
}
}
template::form create new_message
if {[template::form is_request new_message] && [info exists message_id]} {
# The user wants to edit an existing message.
db_1row get_message {
select subject, body, priority_p
from im_message
where message_id = :message_id
and sender_user_id = :user_id
and sent_p = false
and deleted_p = false
}
template::element create new_message message_id \
-widget hidden \
-datatype number \
-value $message_id
} else {
if { [exists_and_not_null original_message_id] && [exists_and_not_null response] } {
# The user wants to send a reply or forward a message.
# Is the requesting user an addressee? If not, abort the script.
db_1row original_message_addressee_p {
select im_message__addressee_p(:original_message_id, :user_id) as original_message_addressee_p
}
if { [string is false $original_message_addressee_p] } { ad_script_abort }
# Obtain the original message data. Note the by 'original' we mean the message to which you are currently
# replying, i.e. the immediate parent not the absolutely original message. In common with standard email
# this package does not keep track of message threads.
db_1row get_original_message {
select m.subject, m.body, m.priority_p, m.sent_timestamptz, p.party_name as original_sender_name, m.sender_user_id as original_sender_user_id, im_to_addressees_horiz_list(m.message_id) as original_addressees
from im_message m, party_names p
where m.sender_user_id = p.party_id
and message_id = :original_message_id
and sent_p = true
and deleted_p = false
}
# Now prepare the message content by indending and seperating the old content
set modified_subject "Re: "
append modified_subject $subject
set temp_body [split $body "\n"]
set body [concat "\n< Begin Reply Here >\n\n> --- Original Message ---\n>From: $original_sender_name\n>To: $original_addressees\n>Sent: $sent_timestamptz\n>\n>Subject: $subject\n>\n>" [join $temp_body "\n>"]]
# If you're wondering why it is because the un-modified subject is needed in the preceeding statement!
set subject $modified_subject
} else {
# The user wants to create a completely new message.
set subject {}
set body {}
set priority_p 0
}
}
template::element create new_message subject \
-datatype text \
-label "Subject" \
-html { size 100 } \
-value $subject
template::element create new_message body \
-widget textarea \
-datatype text \
-label "Body" \
-html { rows 35 cols 100 wrap soft } \
-value $body
# If the message is a reply, blank the priority variable.
if { [info exists response] } {
set priority_p ""
}
template::element create new_message priority_p \
-widget checkbox \
-datatype boolean \
-label "Priority" \
-options { { High t } } \
-value $priority_p
# Conditional on value of 'response' otherwise the template::element call will choke on the empty string.
if { [info exists response] } {
template::element create new_message response \
-widget hidden \
-datatype string \
-label "response" \
-value $response
template::element create new_message original_sender_user_id \
-widget hidden \
-datatype string \
-label "original_sender_user_id" \
-value $original_sender_user_id
template::element create new_message original_message_id \
-widget hidden \
-datatype string \
-label "original_message_id" \
-value $original_message_id
} else {
set response "new"
}
if [template::form is_valid new_message] {
if { $response == "new" } {
form get_values new_message subject body priority_p
} else {
form get_values new_message subject body priority_p response
}
set peeraddr [ad_conn peeraddr]
if [info exists message_id] {
db_dml update_message {
update im_message
set subject = :subject,
body = :body,
priority_p = :priority_p
where message_id = :message_id
and sender_user_id = :user_id
and sent_p = false
and deleted_p = false
}
} else {
if { $response == "reply" } {
# Create a new message that is a reply to the original message. The im_message__new_reply function
# returns the message_id of the new message.
db_1row message_new_reply {
select im_message__new_reply( :user_id, :subject, :body, :priority_p, :original_sender_user_id, :original_message_id) as message_id
}
} else {
# Create new message. The im_message__new_reply function returns the message_id of the new message.
db_1row message_new {
select im_message__new( :user_id, :subject, :body, :priority_p)
}
}
}
ad_returnredirect "./message-display?message_id=$message_id"
}
set title [ad_quotehtml $title]
ad_return_template
intrasite-message/www/message-add-edit.adp 0100600 0000000 0000000 00000000222 10346127300 017570 0 ustar root root @title@@context@
intrasite-message/www/search.tcl 0100600 0000000 0000000 00000016430 10374172426 016000 0 ustar root root ad_page_contract {
Reusable page for searching for a user by email or last_name.
Returns to "target" with user_id_from_search, first_names_from_search,
ast_name_from_search, and email_from_search, and passing along all
form variables listed in "passthrough".
@cvs-id $Id: search.tcl,v 1.4 2002/09/06 21:49:53 jeffd Exp $
@param email search string
@param last_name search string
@param keyword For looking through both email and last_name (optional)
@param target URL to return to
@param passthrough Form variables to pass along from caller
@param limit_to_users_in_group_id Limits search to users in the specified group id. This can be a comma separated list to allow searches within multiple groups. (optional)
@author Jin Choi (jsc@arsdigita.com)
} {
{email ""}
{last_name ""}
keyword:optional
target
{passthrough ""}
{limit_users_in_group_id ""}
{only_authorized_p:integer 1}
message_id:integer,notnull
} -properties {
group_name:onevalue
search_type:onevalue
keyword:onevalue
email:onevalue
last_name:onevalue
only_authorized_p:onevalue
export_authorize:onevalue
passthrough_parameters:onevalue
context:onevalue
}
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
# Check input.
set exception_count 0
set exception_text ""
set context [list [list "./add-remove-addressees?message_id=$message_id" "Find Addressee"] "Search"]
if [info exists keyword] {
# this is an administrator
if { [empty_string_p $keyword] } {
incr exception_count
append exception_text "
You forgot to type a search string!\n"
}
} else {
# from one of the user pages
if { (![info exists email] || [empty_string_p $email]) && \
(![info exists last_name] || [empty_string_p $last_name]) } {
incr exception_count
append exception_text "
You must specify either an email address or last name to search for.\n"
}
if { [info exists email] && [info exists last_name] && \
![empty_string_p $email] && ![empty_string_p $last_name] } {
incr exception_count
append exception_text "
You can only specify either email or last name, not both.\n"
}
if { ![info exists target] || [empty_string_p $target] } {
incr exception_count
append exception_text "
Target was not specified. This shouldn't have happened,
please contact the administrator
and let them know what happened.\n"
}
}
if { $exception_count != 00 } {
ad_return_complaint $exception_count $exception_text
return
}
####
# Input okay. Now start building the SQL
set where_clause [list]
if { [info exists keyword] } {
set search_type "keyword"
set sql_keyword "%[string tolower $keyword]%"
lappend where_clause "(email like :sql_keyword or lower(first_names || ' ' || last_name) like :sql_keyword)"
} elseif { [info exists email] && ![empty_string_p $email] } {
set search_type "email"
set sql_email "%[string tolower $email]%"
lappend where_clause "email like :sql_email"
} else {
set search_type "last"
set sql_last_name "%[string tolower $last_name]%"
lappend where_clause "lower(last_name) like :sql_last_name"
}
if { $only_authorized_p } {
lappend where_clause {member_state = 'approved'}
}
if { ![info exists passthrough] } {
set passthrough_parameters ""
} else {
set passthrough_parameters "[export_entire_form_as_url_vars $passthrough]"
}
if { [exists_and_not_null limit_to_users_in_group_id] } {
set query "select distinct first_names, last_name, email, member_state, email_verified_p, cu.user_id,
(select mode_desc
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cc_users.user_id = ia.addressee_id
and ia.message_id = :message_id) as addressed,
(select mode_id
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cu.user_id = ia.addressee_id
and ia.message_id = :message_id) as mode_id
from cc_users cu, group_member_map gm, membership_rels mr
where cu.user_id = gm.member_id
and cu.member_state <> 'deleted'
and gm.rel_id = mr.rel_id
and gm.group_id = :limit_to_users_in_group_id
and [join $where_clause "\nand "]"
} else {
set query "select user_id, email_verified_p, first_names, last_name, email, member_state,
(select mode_desc
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cc_users.user_id = ia.addressee_id
and ia.message_id = :message_id) as addressed,
(select mode_id
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cc_users.user_id = ia.addressee_id
and ia.message_id = :message_id) as mode_id
from cc_users
where [join $where_clause "\nand "] and cc_users.member_state <> 'deleted'"
}
set i 0
set user_items ""
set rowcount 0
set none_to_add_p 1
db_foreach user_search_admin $query {
incr rowcount
set user_id_from_search $user_id
set first_names_from_search $first_names
set last_name_from_search $last_name
set email_from_search $email
set user_search:[set rowcount](user_id) $user_id
set user_search:[set rowcount](first_names) $first_names
set user_search:[set rowcount](last_name) $last_name
set user_search:[set rowcount](email) $email
set user_search:[set rowcount](export_vars) [export_url_vars user_id_from_search first_names_from_search last_name_from_search email_from_search]
set user_search:[set rowcount](member_state) $member_state
set user_search:[set rowcount](addressed) $addressed
set user_search:[set rowcount](mode_id) $mode_id
if { $member_state != "approved" } {
set user_search:[set rowcount](user_finite_state_links) [join [ad_registration_finite_state_machine_admin_links $member_state $email_verified_p $user_id_from_search "search?[export_url_vars email last_name keyword target passthrough limit_users_in_group_id only_authorized_p]"] " | "]
} else {
set user_search:[set rowcount](user_finite_state_links) ""
}
if { $none_to_add_p == 1} { if { $addressed == "" } { set none_to_add_p 0}}
}
set user_search:rowcount $rowcount
# We are limiting the search to one group - display that group's name
if { [exists_and_not_null limit_to_users_in_group_id] && ![regexp {[^0-9]} $limit_to_users_in_group_id] } {
set group_name [db_string user_group_name_from_id "select group_name from user_groups where group_id = :limit_to_users_in_group_id"]
set title "User search in $group_name"
} else {
set group_name ""
set title "User search"
}
set export_authorize [export_ns_set_vars {url} {only_authorized_p}]
db_multirow address_modes address_modes {
select mode_desc, mode_id from im_address_mode
}
ad_return_template
intrasite-message/www/confirm-addressee.tcl 0100600 0000000 0000000 00000003502 10376146437 020126 0 ustar root root ad_page_contract {
@author Richard Hamilton
@creation-date 2005-11-24
} {
{selected_addressees:integer,multiple}
{confirm_p:boolean 0}
{message_id:integer,notnull}
{address_mode:integer,notnull}
}
set user_id [ad_verify_and_get_user_id]
# Is the requesting user the author? If not - ignore the request.
db_1row message_author_p {
select im_message__author_p(:message_id, :user_id) as message_author_p
}
if { [string is false $message_author_p] } { ad_script_abort }
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
# Extract the user names to match the ids in $selected_addressees
set in_clause [template::util::tcl_to_sql_list $selected_addressees]
db_multirow addressee_names lookup_names "
select first_names||' '||last_name as full_name from cc_users where user_id in ($in_clause)
"
# Determine address mode for addressees to be added.
db_1row get_mode_desc "
select mode_desc from im_address_mode where mode_id = :address_mode
"
if { [string is false $confirm_p] } {
set num_entries [llength $selected_addressees]
if { $num_entries == 0 } {
ad_returnredirect "add-remove-addressees"
return
}
set title "Confirm Addressees [ad_decode $num_entries 1 "Entry" "Entries"]"
set context [list $title]
set yes_url "confirm-addressee?[export_vars { selected_addressees:multiple { confirm_p 1 } {message_id} {address_mode} }]"
set no_url "./complex-search?message_id=$message_id&target=confirm-addressee"
return
}
foreach selected_addressee $selected_addressees {
db_0or1row insert_addressee {
select im_addressee__insert (:message_id, :selected_addressee, :address_mode, :user_id)
}
}
ad_returnredirect "message-display?message_id=$message_id"
ad_script_abort
intrasite-message/www/message-add-edit-postgresql.xql 0100600 0000000 0000000 00000004473 10376203201 022043 0 ustar root root
select subject, body, priority_p
from im_message
where message_id = :message_id
and sender_user_id = :user_id
and sent_p = false
and deleted_p = false
select m.subject, m.body, m.priority_p, m.sent_timestamptz, p.party_name as original_sender_name, m.sender_user_id as original_sender_user_id, im_to_addressees_horiz_list(m.message_id) as original_addressees
from im_message m, party_names p
where m.sender_user_id = p.party_id
and message_id = :original_message_id
and sent_p = true
and deleted_p = false
update im_message
set subject = :subject,
body = :body,
priority_p = :priority_p
where message_id = :message_id
and sender_user_id = :user_id
and sent_p = false
and deleted_p = false
select im_message__new( :user_id, :subject, :body, :priority_p ) as message_id
select 0 from dual
select im_message__sent_p(:message_id) as message_sent_p
select im_message__author_p(:message_id, :user_id) as message_author_p
select im_message__addressee_p(:message_id, :user_id) as message_addressee_p
select im_message__addressee_p(:original_message_id, :user_id) as original_message_addressee_p
select im_message__new_reply( :user_id, :subject, :body, :priority_p, :original_sender_user_id, :original_message_id) as message_id
intrasite-message/www/add-remove-addressees.adp 0100600 0000000 0000000 00000007756 10342063623 020664 0 ustar root root Users@context@
For fluidity of administrations, this page is cached in RAM for 15 minutes. Thus the numbers you see above may be up to 15 minutes out of date.
intrasite-message/www/complex-search.adp 0100600 0000000 0000000 00000005531 10375607673 017437 0 ustar root root Complex User Search@context@
intrasite-message/www/complex-search-postgresql.xql 0100600 0000000 0000000 00000001530 10043766440 021661 0 ustar root root
postgresql7.1
creation_date < now() - (:registration_before_days || ' days')::interval
creation_date >= now() - (:registration_after_days || ' days')::interval
last_visit < now() - (:last_visit_before_days || ' days')::interval
last_visit >= now() - (:last_visit_after_days || ' days')::interval
intrasite-message/www/complex-search.tcl 0100600 0000000 0000000 00000023631 10374172371 017445 0 ustar root root ad_page_contract {
Page for searching for a user by group membership, email,
first_names, last_name, how many days ago they last visited, how
many days ago they registered, and how many times they have
visited.
This page is based on "search.tcl", so in theory it should
reusable but that has not been tested. See "search.tcl" for
details.
@cvs-id $Id: complex-search.tcl,v 1.6.2.3 2003/03/25 09:58:48 lars Exp $
@param email search string (optional)
@param last_name_starts_with search string (optional)
@param first_names search string (optional)
@param registration_before_days search value--users must have registered more than this number of days ago (optional)
@param registration_after_days search value--users must have registered within this number of days (optional)
@param last_visit_before_days search value--users whose last login was more than this number of days ago (optional)
@param last_visit_after_days search value--users whose last login was within this number of days (optional)
@param number_visits_below search value--users who have visited fewer than this many times (optional)
@param number_visits_above search value--users who have visited at least this many times (optional)
@param combine_method the string "and" or "or" that tells where to search for users matching ALL the criteria or ANY of the criteria
@param keyword For looking through both email and last_name (optional)
@param target URL to return to (untested)
@param passthrough Form variables to pass along from caller (untested)
@param limit_to_users_in_group_id Limits search to users in the specified group id. This can be a comma separated list to allow searches within multiple groups. (optional)
@author Mark Thomas (mthomas@arsdigita.com)
} {
{email ""}
{ip ""}
{last_name_starts_with ""}
{first_names ""}
keyword:optional
target
{passthrough ""}
{limit_to_users_in_group_id ""}
{only_authorized_p:integer 1}
{only_needs_approval_p:naturalnum 0}
{registration_before_days:integer -1}
{registration_after_days:integer -1}
{last_visit_before_days:integer -1}
{last_visit_after_days:integer -1}
{number_visits_below:integer -1}
{number_visits_above:integer -1}
{combine_method "all"}
message_id:integer,notnull
} -properties {
group_name:onevalue
keyword:onevalue
email:onevalue
last_name:onevalue
first_name:onevalue
only_authorized_p:onevalue
export_authorize:onevalue
passthrough_parameters:onevalue
combine_method:onevalue
context:onevalue
}
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
# Check input.
set exception_count 0
set exception_text ""
set context [list [list "./add-remove-addressees?message_id=$message_id" "Find Addressee"] "Complex search"]
if { ![info exists target] || [empty_string_p $target] } {
incr exception_count
append exception_text "
Target was not specified. This shouldn't have
happened, please contact the
administrator
and let them know what happened.\n"
}
if { $exception_count != 00 } {
ad_return_complaint $exception_count $exception_text
return
}
if {[string equal $combine_method "any"]} {
set where_conjunction "or"
} else {
set where_conjunction "and"
set combine_method "all"
}
if { ![info exists passthrough] } {
set passthrough_parameters ""
} else {
set passthrough_parameters "[export_entire_form_as_url_vars $passthrough]"
}
####
# Input okay. Now start building the SQL
set where_clause [list]
set rowcount 0
if {[exists_and_not_null limit_to_users_in_group_id] && ![regexp {[^-0-9]} $limit_to_users_in_group_id] } {
set group_name [db_string user_group_name_from_id \
"select group_name from groups where group_id = :limit_to_users_in_group_id"]
incr rowcount
set criteria:[set rowcount](data) \
"Is a member of '$group_name'"
}
if { [exists_and_not_null email] } {
set sql_email "%[string tolower $email]%"
lappend where_clause "email like :sql_email"
incr rowcount
set criteria:[set rowcount](data) "Email contains '$email'"
}
if { [exists_and_not_null ip] } {
lappend where_clause "creation_ip = :ip"
incr rowcount
set criteria:[set rowcount](data) "Creation IP is $ip"
}
if { [exists_and_not_null last_name_starts_with] } {
set sql_last_name_starts_with "[string tolower $last_name_starts_with]%"
lappend where_clause "lower(last_name) like :sql_last_name_starts_with"
incr rowcount
set criteria:[set rowcount](data) "Last name starts with '$last_name_starts_with'"
}
if { [exists_and_not_null first_names] } {
set sql_first_names "%[string tolower $first_names]%"
lappend where_clause "lower(first_names) like :sql_first_names"
incr rowcount
set criteria:[set rowcount](data) "First names contain '$first_names'"
}
if { $only_authorized_p } {
lappend where_clause {member_state = 'approved'}
} elseif { $only_needs_approval_p } {
lappend where_clause {member_state = 'needs approval'}
incr rowcount
set criteria:[set rowcount](data) "Needs approval"
}
if { $registration_before_days >= 0 } {
lappend where_clause [db_map registration_before_days]
incr rowcount
set criteria:[set rowcount](data) \
"Registered more than past $registration_before_days days ago"
}
if { $registration_after_days >= 0 } {
lappend where_clause [db_map registration_after_days]
incr rowcount
set criteria:[set rowcount](data) \
"Registered within the past $registration_after_days days"
}
if { $last_visit_before_days >= 0 } {
lappend where_clause [db_map last_visit_before_days]
incr rowcount
set criteria:[set rowcount](data) \
"Most recent visit was more that $last_visit_before_days days ago"
}
if { $last_visit_after_days >= 0 } {
lappend where_clause [db_map last_visit_after_days]
incr rowcount
set criteria:[set rowcount](data) \
"Visited within the past $last_visit_after_days days"
}
if { $number_visits_below >= 0 } {
lappend where_clause "n_sessions < :number_visits_below"
incr rowcount
set criteria:[set rowcount](data) \
"Has visited fewer than $number_visits_below times"
}
if { $number_visits_above >= 0 } {
lappend where_clause "n_sessions >= :number_visits_above"
incr rowcount
set criteria:[set rowcount](data) \
"Has visited at least $number_visits_above times"
}
set criteria:rowcount $rowcount
if { [exists_and_not_null limit_to_users_in_group_id] } {
set query "select distinct first_names, last_name, email, member_state, email_verified_p, cu.user_id,
(select mode_desc
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cu.user_id = ia.addressee_id
and ia.message_id = :message_id) as addressed,
(select mode_id
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cu.user_id = ia.addressee_id
and ia.message_id = :message_id) as mode_id
from cc_users cu, group_member_map gm
where (cu.user_id = gm.member_id
and gm.group_id = :limit_to_users_in_group_id
and cu.member_state <> 'deleted')"
if {[llength $where_clause] > 0} {
append query \
"\n$where_conjunction [join $where_clause "\n$where_conjunction "]"
}
} else {
set query "select user_id, email_verified_p, first_names, last_name, email, member_state,
(select mode_desc
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cc_users.user_id = ia.addressee_id
and ia.message_id = :message_id) as addressed,
(select mode_id
from im_address_mode am, im_addressees ia
where am.mode_id = ia.address_mode_id
and cc_users.user_id = ia.addressee_id
and ia.message_id = :message_id) as mode_id
from cc_users"
if {[llength $where_clause] > 0} {
append query "\nwhere [join $where_clause "\n$where_conjunction "]"
}
}
append query "\norder by first_names, last_name"
set i 0
set user_items ""
set rowcount 0
set none_to_add_p 1
db_foreach user_search_admin $query {
incr rowcount
set user_id_from_search $user_id
set first_names_from_search $first_names
set last_name_from_search $last_name
set email_from_search $email
set user_search:[set rowcount](user_id) $user_id
set user_search:[set rowcount](first_names) $first_names
set user_search:[set rowcount](last_name) $last_name
set user_search:[set rowcount](email) $email
set user_search:[set rowcount](export_vars) [export_url_vars user_id_from_search first_names_from_search last_name_from_search email_from_search]
set user_search:[set rowcount](member_state) $member_state
set user_search:[set rowcount](addressed) $addressed
set user_search:[set rowcount](mode_id) $mode_id
if { $member_state != "approved" } {
set user_search:[set rowcount](user_finite_state_links) [join [ad_registration_finite_state_machine_admin_links $member_state $email_verified_p $user_id_from_search "complex-search?[export_url_vars email last_name keyword target passthrough limit_users_in_group_id only_authorized_p]"] " | "]
} else {
set user_search:[set rowcount](user_finite_state_links) ""
}
if { $none_to_add_p == 1} { if { $addressed == "" } { set none_to_add_p 0}}
}
set user_search:rowcount $rowcount
set export_authorize [export_ns_set_vars {url} {only_authorized_p}]
db_multirow address_modes address_modes {
select mode_desc, mode_id from im_address_mode
}
ad_return_template
intrasite-message/www/complex-search.xql 0100600 0000000 0000000 00000000613 10373354065 017463 0 ustar root root
select group_name from groups where group_id = :limit_to_users_in_group_id
select mode_desc, mode_id from im_address_mode
where mode_id <> 0
intrasite-message/www/search.adp 0100600 0000000 0000000 00000005021 10375717227 015761 0 ustar root root @title@@context@
intrasite-message/www/add-remove-addressees.tcl 0100600 0000000 0000000 00000023677 10374173636 020715 0 ustar root root # ad_proc ad_admin_users_index_dot_tcl_whole_page {} {
ad_page_contract {
by a bunch of folks including philg@mit.edu and teadams@arsdigita.com
modified by philg on October 30, 1999 to cache the page
(sequentially scanning through users and such was slowing it down)
modified by aure@caltech.edu on February 4, 2000 to make the page more
user friendly
we define this procedure here in the file because we don't care if
it gets reparsed; it is RDBMS load that was slowing stuff down. We also
want programmers to have an easy way to edit this page.
@cvs-id $Id: index.tcl,v 1.2 2002/09/06 21:49:53 jeffd Exp $
@author Multiple
} {
message_id:integer,notnull
} -properties {
context:onevalue
n_users:onevalue
n_deleted_users:onevalue
last_registration:onevalue
groups:onevalue
}
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
set context [list "Find Addressee"]
# XXX This query should be optimized
db_1row users_n_users "select
count(*) as n_users,
sum(decode(member_state,'deleted',1,0)) as n_deleted_users,
max(creation_date) as last_registration
from cc_users
where email not in ('anonymous', 'system')"
set n_users [util_commify_number $n_users]
set n_active_users [expr $n_users - $n_deleted_users]
set last_registration [util_AnsiDatetoPrettyDate $last_registration]
set groups [db_html_select_value_options groups_select {
select groups.group_id,
groups.group_name,
m.num as n_members,
c.num as n_components
from groups,
(select group_id, count(*) as num
from group_member_map group by group_id) m,
(select group_id, count(*) as num
from group_component_map group by group_id) c
where groups.group_id=m.group_id
and groups.group_id = c.group_id
order by group_name
} ]
ad_return_template
# }
# doc_return 200 text/html [util_memoize "ad_admin_users_index_dot_tcl_whole_page"]
# The code below used to be in this file, but was temporarily taken out for ACS 4.0
# set state_list ""
# db_foreach member_states "select count(member_state)
# as num_in_state, member_state
# from cc_users
# group by member_state" {
# set member_state_num($member_state) [util_commify_number $num_in_state]
# }
# if {[ad_parameter RegistrationRequiresApprovalP "" 0] && [info exists member_state_num(need_admin_approv)]} {
# lappend state_list "need_admin_approv ($member_state_num(need_admin_approv))"
# }
# if {[ad_parameter RegistrationRequiresApprovalP "" 0] && [ad_parameter RegistrationRequiresEmailVerificationP "" 0] && [info exists member_state_num(need_email_verification_and_admin_approv)]} {
# lappend state_list "need_email_verification_and_admin_approv ($member_state_num(need_email_verification_and_admin_approv))"
# }
# if {[ad_parameter RegistrationRequiresEmailVerificationP "" 0] && [info exists member_state_num(need_email_verification)]} {
# lappend state_list "need_email_verification ($member_state_num(need_email_verification))"
# }
# if [info exists member_state_num(authorized)] {
# lappend state_list "authorized ($member_state_num(authorized))"
# }
# if [info exists member_state_num(banned)] {
# lappend state_list "banned ($member_state_num(banned))"
# }
# if [info exists member_state_num(deleted)] {
# lappend state_list "deleted ($member_state_num(deleted))"
# }
# append whole_page "
#
Users in state: [join $state_list " | "]
#
# "
# XXX Not in ACS 40, but will be added later
# db_1row user_sessions "
# select
# sum(session_count) as total_sessions,
# sum(repeat_count) as total_repeats
# from session_statistics"
# if [empty_string_p $total_sessions] {
# set total_sessions 0
# }
# if [empty_string_p $total_repeats] {
# set total_repeats 0
# }
# set spam_count [db_string unused "
# select sum(n_sent) from spam_history"]
# if [empty_string_p $spam_count] {
# set spam_count 0
# }
#
intrasite-message/www/remove-addressee.tcl 0100600 0000000 0000000 00000003514 10376146373 017770 0 ustar root root ad_page_contract {
@author Richard Hamilton
@creation-date 2005-11-24
} {
{selected_addressees:integer,multiple}
{confirm_p:boolean 0}
{message_id:integer,notnull}
{address_mode:integer,notnull}
}
set user_id [ad_verify_and_get_user_id]
# Is the requesting user the author? If not - ignore the request.
db_1row message_author_p {
select im_message__author_p(:message_id, :user_id) as message_author_p
}
if { [string is false $message_author_p] } { ad_script_abort }
# Check permissions on the package_id
ad_require_permission [ad_conn package_id] write
# Extract the user names to match the ids in $selected_addressees
set in_clause [template::util::tcl_to_sql_list $selected_addressees]
# Ensure that message has not been sent already
db_1row message_sent_p {
select im_message__sent_p(:message_id) as message_sent_p
}
if { [ string is false $message_sent_p] } {
db_multirow addressee_names lookup_names "
select first_names||' '||last_name as full_name from cc_users where user_id in ($in_clause)
"
if { [string is false $confirm_p] } {
set num_entries [llength $selected_addressees]
if { $num_entries == 0 } {
ad_returnredirect "add-remove-addressees"
return
}
set title "Confirm Removal [ad_decode $num_entries 1 "Entry" "Entries"]"
set context [list $title]
set yes_url "remove-addressee?[export_vars { selected_addressees:multiple { confirm_p 1 } {message_id} {address_mode} }]"
set no_url "./message-display?message_id=$message_id"
return
}
foreach selected_addressee $selected_addressees {
db_1row remove_addressee {
select im_addressee__remove(:message_id, :selected_addressee, :address_mode, :user_id)
}
}
}
ad_returnredirect "message-display?message_id=$message_id"
ad_script_abort
intrasite-message/www/message-move-delete.adp 0100600 0000000 0000000 00000001025 10376117466 020344 0 ustar root root @title@@context@
Are you sure that you want to move the selected message the @num_entries@ selected messages to your '@folder_name@' folder?
Are you sure that you want to delete the selected message the @num_entries@ selected messages.
intrasite-message/www/message-move-delete-postgresql.xql 0100600 0000000 0000000 00000001012 10375722660 022576 0 ustar root root
select im_message__delete(:message_id, :user_id)
select im_message__move(:message_id, :user_id, :new_folder_id)
select folder_name
from im_folder
where folder_id = :new_folder_id
intrasite-message/www/remove-addressee-postgresql.xql 0100600 0000000 0000000 00000000344 10376103552 022201 0 ustar root root
select im_addressee__remove(:message_id, :selected_addressee, :address_mode, :user_id)
intrasite-message/www/message-move-delete.tcl 0100600 0000000 0000000 00000004711 10375724237 020366 0 ustar root root ad_page_contract {
@author Richard Hamilton
@creation-date 2005-11-24
} {
{selected_messages:integer,multiple}
{confirm_p:boolean 0}
{objects_context:optional "In-box"}
{action}
{new_folder_id:optional}
{new_folder_name:optional}
}
# the unique identifier for this package
set package_id [ad_conn package_id]
set user_id [ad_conn user_id]
# Check permissions on the package_id
ad_require_permission $package_id delete
# On the index page the user can select messages with checkboxes and use one of two submit
# buttons - "Delete" or "Move".
if { $action == "Delete"} {
# The Delete action code starts here. Begin by checking whether the user has yet confirmed the request.
if { [string is false $confirm_p] } {
set num_entries [llength $selected_messages]
if { $num_entries == 0 } {
ad_returnredirect "./index?objects_context=$objects_context"
return
}
set title "Confirm Message Delete [ad_decode $num_entries 1 "Entry" "Entries"]"
set context [list $title]
set yes_url "message-move-delete?[export_vars { selected_messages:multiple { confirm_p 1 } {objects_context $objects_context} {action "Delete"} }]"
set no_url "./index?objects_context=$objects_context"
return
}
foreach message_id $selected_messages {
db_1row delete_message {
select im_message__delete (:message_id, :user_id)
}
}
} else {
# The Move action code starts here. Begin by checking whether the user has yet confirmed the request.
if { [string is false $confirm_p] } {
set num_entries [llength $selected_messages]
if { $num_entries == 0 } {
ad_returnredirect "./index?objects_context=$objects_context"
return
}
db_1row lookup_folder_name {
select folder_name
from im_folder
where folder_id = :new_folder_id
}
set title "Confirm Message Move [ad_decode $num_entries 1 "Entry" "Entries"]"
set context [list $title]
set yes_url "message-move-delete?[export_vars { selected_messages:multiple { confirm_p 1 } {objects_context $objects_context} {action "Move"} {new_folder_id $new_folder_id} }]"
set no_url "./index?objects_context=$objects_context"
return
}
foreach message_id $selected_messages {
db_1row move_message {
select im_message__move (:message_id, :user_id, :new_folder_id)
}
}
}
ad_returnredirect "./index?objects_context=$objects_context"
ad_script_abort
intrasite-message/intrasite-message.info 0100600 0000000 0000000 00000002654 10312543100 017466 0 ustar root root
Intrasite MessageIntrasite Messagesffintrasite-messageRichard Shaw HamiltonThis package allows users to send messages to each other securely within the OpenACS instance.WebteamworksThe intention is to support a message system that looks and feels like a standard webmail system but only permits the sending of messages by users to other users of an OpenACS system. The messages never leave the confines of the database. This is particularly useful where the use of the package is restricted to https since it provides quite a secure means of communicating with other users.