Index: openacs-4/packages/dotlrn-messages/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-messages/tcl/apm-callback-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-messages/tcl/apm-callback-procs.tcl 31 Aug 2010 21:32:23 -0000 1.1
@@ -0,0 +1,57 @@
+ad_library {
+ Procedures for registering implementations for the
+ dotLRN Messages package.
+
+ @creation-date 2010-01-20
+ @author Pedro Castellanos (pedro@viaro.net)
+}
+
+namespace eval dotlrn_messages {}
+
+ad_proc -public dotlrn_messages::install {} {
+ dotLRN messages package install proc
+} {
+ register_portal_datasource_impl
+}
+
+ad_proc -public dotlrn_messages::uninstall {} {
+ dotLRN messages package uninstall proc
+} {
+ unregister_portal_datasource_impl
+}
+
+ad_proc -public dotlrn_messages::register_portal_datasource_impl {} {
+ Register the service contract implementation for the dotlrn_applet service contract
+} {
+ set spec {
+ name "dotlrn_messages"
+ contract_name "dotlrn_applet"
+ owner "dotlrn-messages"
+ aliases {
+ GetPrettyName dotlrn_messages::get_pretty_name
+ AddApplet dotlrn_messages::add_applet
+ RemoveApplet dotlrn_messages::remove_applet
+ AddAppletToCommunity dotlrn_messages::add_applet_to_community
+ RemoveAppletFromCommunity dotlrn_messages::remove_applet_from_community
+ AddUser dotlrn_messages::add_user
+ RemoveUser dotlrn_messages::remove_user
+ AddUserToCommunity dotlrn_messages::add_user_to_community
+ RemoveUserFromCommunity dotlrn_messages::remove_user_from_community
+ AddPortlet dotlrn_messages::add_portlet
+ RemovePortlet dotlrn_messages::remove_portlet
+ Clone dotlrn_messages::clone
+ ChangeEventHandler dotlrn_messages::change_event_handler
+ }
+ }
+
+ acs_sc::impl::new_from_spec -spec $spec
+}
+
+ad_proc -public dotlrn_messages::unregister_portal_datasource_impl {} {
+ Unregister service contract implementations
+} {
+ acs_sc::impl::delete \
+ -contract_name "dotlrn_applet" \
+ -impl_name "dotlrn_messages"
+}
+
Index: openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs-oracle.xql 31 Aug 2010 21:32:23 -0000 1.1
@@ -0,0 +1,24 @@
+
+
+
+oracle8.1.6
+
+
+
+
+
+ delete from dotlrn_community_applets where applet_id = :applet_id
+
+
+
+
+
+
+
+ delete from dotlrn_applets where applet_id = :applet_id
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs-postgresql.xql 31 Aug 2010 21:32:23 -0000 1.1
@@ -0,0 +1,24 @@
+
+
+
+postgresql7.1
+
+
+
+
+
+ delete from dotlrn_community_applets where applet_id = :applet_id
+
+
+
+
+
+
+
+ delete from dotlrn_applets where applet_id = :applet_id
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-messages/tcl/dotlrn-messages-procs.tcl 31 Aug 2010 21:32:23 -0000 1.1
@@ -0,0 +1,201 @@
+ad_library {
+
+ Procs to set up the dotLRN messages applet
+
+ @author Pedro Castellanos (pedro@viaro.net)
+ @creation-date 2010-01-20
+}
+
+namespace eval dotlrn_messages {}
+
+ad_proc -public dotlrn_messages::applet_key {} {
+ What's my applet key?
+} {
+ return dotlrn_messages
+}
+
+ad_proc -public dotlrn_messages::package_key {} {
+ What package do I deal with?
+} {
+ return "messages"
+}
+
+ad_proc -public dotlrn_messages::my_package_key {} {
+ What package do I deal with?
+} {
+ return "dotlrn-messages"
+}
+
+ad_proc -public dotlrn_messages::get_pretty_name {} {
+ returns the pretty name
+} {
+ return "#messages.messages#"
+}
+
+ad_proc -public dotlrn_messages::add_applet {} {
+ One time init - must be repeatable!
+} {
+ dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [my_package_key]
+}
+
+ad_proc -public dotlrn_messages::remove_applet {} {
+ One time destroy.
+} {
+ set applet_id [dotlrn_applet::get_applet_id_from_key [my_package_key]]
+ db_exec_plsql delete_applet_from_communities { *SQL* }
+ db_exec_plsql delete_applet { *SQL* }
+}
+
+ad_proc -public dotlrn_messages::add_applet_to_community {
+ community_id
+} {
+ Add the messages applet to a specifc dotlrn community
+} {
+ set portal_id [dotlrn_community::get_portal_id -community_id $community_id]
+
+ # create the messages package instance
+ set package_id [dotlrn::instantiate_and_mount $community_id [package_key]]
+
+ # set up the admin portal
+ set admin_portal_id [dotlrn_community::get_admin_portal_id \
+ -community_id $community_id
+ ]
+
+ #messages_admin_portlet::add_self_to_page \
+ #-portal_id $admin_portal_id \
+ #-package_id $package_id
+
+# AR: There will be no portlet, just the admin one
+ set args [ns_set create]
+ ns_set put $args package_id $package_id
+ add_portlet_helper $portal_id $args
+
+ return $package_id
+}
+
+ad_proc -public dotlrn_messages::remove_applet_from_community {
+ community_id
+} {
+ remove the applet from the community
+} {
+ ad_return_complaint 1 "[applet_key] remove_applet_from_community not implimented!"
+}
+
+ad_proc -public dotlrn_messages::add_user {
+ user_id
+} {
+ one time user-specifuc init
+} {
+ # noop
+}
+
+ad_proc -public dotlrn_messages::remove_user {
+ user_id
+} {
+} {
+ # noop
+}
+
+ad_proc -public dotlrn_messages::add_user_to_community {
+ community_id
+ user_id
+} {
+ Add a user to a specifc dotlrn community
+} {
+ set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]]
+ set portal_id [dotlrn::get_portal_id -user_id $user_id]
+
+ # use "append" here since we want to aggregate
+# AR: There will be no portlet, just the admin one
+ set args [ns_set create]
+ ns_set put $args package_id $package_id
+ ns_set put $args param_action append
+ add_portlet_helper $portal_id $args
+}
+
+ad_proc -public dotlrn_messages::remove_user_from_community {
+ community_id
+ user_id
+} {
+ Remove a user from a community
+} {
+ set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]]
+ set portal_id [dotlrn::get_portal_id -user_id $user_id]
+
+# AR: There will be no portlet, just the admin one
+ set args [ns_set create]
+ ns_set put $args package_id $package_id
+
+ remove_portlet $portal_id $args
+}
+
+ad_proc -public dotlrn_messages::add_portlet {
+ portal_id
+} {
+ A helper proc to add the underlying portlet to the given portal.
+
+ @param portal_id
+} {
+ # simple, no type specific stuff, just set some dummy values
+# AR: There will be no portlet, just the admin one
+ set args [ns_set create]
+ ns_set put $args package_id 0
+ ns_set put $args param_action overwrite
+ add_portlet_helper $portal_id $args
+}
+
+ad_proc -public dotlrn_messages::add_portlet_helper {
+ portal_id
+ args
+} {
+ A helper proc to add the underlying portlet to the given portal.
+
+ @param portal_id
+ @param args an ns_set
+} {
+# AR: There will be no portlet, just the admin one
+ messages_portlet::add_self_to_page \
+ -portal_id $portal_id \
+ -package_id [ns_set get $args package_id] \
+ -param_action [ns_set get $args param_action]
+}
+
+ad_proc -public dotlrn_messages::remove_portlet {
+ portal_id
+ args
+} {
+ A helper proc to remove the underlying portlet from the given portal.
+
+ @param portal_id
+ @param args A list of key-value pairs (possibly user_id, community_id, and more)
+} {
+ messages_portlet::remove_self_from_page \
+ -portal_id $portal_id \
+ -package_id [ns_set get $args package_id]
+}
+
+ad_proc -public dotlrn_messages::clone {
+ old_community_id
+ new_community_id
+} {
+ Clone this applet's content from the old community to the new one
+} {
+ ns_log notice "Cloning: [applet_key]"
+ set new_package_id [add_applet_to_community $new_community_id]
+ set old_package_id [dotlrn_community::get_applet_package_id \
+ -community_id $old_community_id \
+ -applet_key [applet_key]
+ ]
+
+ return $new_package_id
+}
+
+ad_proc -public dotlrn_messages::change_event_handler {
+ community_id
+ event
+ old_value
+ new_value
+} {
+ listens for the following events:
+} {
+}
Index: openacs-4/packages/messages/catalog/messages.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/catalog/messages.en_US.ISO-8859-1.xml,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/catalog/messages.en_US.ISO-8859-1.xml 31 Aug 2010 21:30:54 -0000 1.1
@@ -0,0 +1,123 @@
+
+
+
+ Add
+ Add attachment
+ Mark as read
+ Mark as unread
+ At
+ Attachments
+ << Back
+ Back Folders
+ Send this message without text in the body?
+ %user_name% has sent you a message:
+
+-------------------------------------
+
+%subject%
+
+%msg_content%
+
+-------------------------------------
+
+
+You can see from the following link:
+
+http://yourpage.com/%message_url%
+ Cancel
+ Close Window
+ Community
+ Compose Mail
+ Configuration
+ Your message has been sent
+ All messages in the Trash have been deleted forever
+ Create
+ Date
+ Delete
+ Do you want to continue?
+ Discard
+ Drafts
+ To edit the name click on the name of the folder
+ Edit
+ Empty Trash now
+ Folder created successfully
+ Folder name
+ (messages that have been in Trash more than 15 days will be automatically deleted)
+ Folders
+ Folders created
+ Forward
+ From
+ The conversation has been moved to
+ Hide details
+ Important
+ Inbox
+ Insert signature
+ The name of the folder may not be longer than 20 characters
+ Conversations per page
+ me
+ Message
+ Message sent by
+ Messages
+ More actions
+ conversations have been moved to
+ conversations have been marked as read.
+ conversations have been marked as unread.
+ Move to
+ The information be lost. Do you want to continue?
+ This action will affect %total_messages% conversation(s) in Trash. Are you sure you want to continue?
+ The folder is deleted, the messages are moved out to receive. Are sure to continue?
+ Your message has been sent.
+ You must enter valid number in size of folder
+ is an invalid user.
+ Loading
+ The conversation has been marked as read.
+ You must select at least one message
+ fwd
+ Re
+ Messaging system: to send messages to people who belong to this group if you want to send messages to a person belonging to another group, you ought to go to that course/community and send from there.
+ The conversation has been marked as unread.
+ Write the name of the new Folder
+ New Folder
+ Please, write a name of the new folder
+ < Newer
+ Newer
+ << Newest
+ No
+ No members found
+ You don't have any messages here.
+ no subject
+ Normal
+ Of
+ Older >
+ Older
+ Oldest >>
+ You are answering another message.
+ Print
+ %first_row% -- %last_number% Of %total_messages%
+ Recipients
+ Please specify at least one recipient.
+ Reply
+ Reply all
+ Save
+ Save
+ Save sent message
+ Search
+ Send
+ Send to everyone
+ Sending
+ Sent
+ Show details
+ Signature
+ Subject
+ Send message without a subject?
+ %user_name% has sent you a message in the community "%community_name%"
+ Sucsessful create folder
+ To
+ [i] If you know the name and/or last name of the user that sends the message, type it into the text field and will show to users who match the writing in this field
+ Today
+ Trash
+ View messages
+ Write message
+ Writing message to
+ Yes
+
Index: openacs-4/packages/messages/catalog/messages.es_ES.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/catalog/messages.es_ES.ISO-8859-1.xml,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/catalog/messages.es_ES.ISO-8859-1.xml 31 Aug 2010 21:30:54 -0000 1.1
@@ -0,0 +1,123 @@
+
+
+
+ Agregar
+ Adjuntar archivo
+ Marcar como leido
+ Marcar como no le�do
+ de
+ Archivos adjuntos
+ << Regresar
+ Regresar a Carpetas
+ �Deseas enviar este mensaje sin texto?
+ %user_name% te ha enviado un mensaje:
+
+-------------------------------------
+
+%subject%
+
+%msg_content%
+
+-------------------------------------
+
+lo puedes ver en el siguiente enlace:
+
+http://yourpage.com/%message_url%
+
+
+ Cancelar
+ Cerrar Ventana
+ Comunidad
+ Redactar Correo
+ Configuraci�n
+ Tu mensaje ha sido enviado.
+ Todos los mensajes de la papelera se han suprimido definitivamente
+ Crear
+ Fecha
+ Borrar
+ �Desea continuar?
+ Descartar
+ Borradores
+ Para editar el nombre, haga click sobre el nombre del folder.
+ Editar
+ Vaciar la Papelera ahora
+ El folder se ha creado satisfactoriamente
+ Nombre del Folder
+ (los mensajes que se encuentren en la Papelera durante m�s de 15 d�as se suprimir�n autom�ticamente)
+ Carpetas
+ Carpetas creadas
+ Reenviar
+ De
+ La conversaci�n se ha movido a
+ Ocultar Detalles
+ Importante
+ Recibidos
+ Insertar firma
+ El nombre del folder no puede ser mayor a 20 caracteres.
+ Mensajes por p�gina
+ Usuario
+ Mensaje
+ Mensaje enviado por
+ Mensajes
+ M�s acciones
+ conversaciones se han movido a
+ conversaciones se han marcado como le�das.
+ conversaciones se han marcado como no le�das.
+ Mover a
+ La informaci�n se perder�. �Desea continuar?
+ Esta acci�n afectara a %total_messages% conversaci�n(es) en Papelera. �Esta seguro de que deseas continuar?
+ La carpeta se elimina, los mensajes se mover�n a Recibidos. �Est� seguro de continuar?
+ Tu mensaje ha sido enviado.
+ Debe de ingresar n�mero v�lido en mensajes por folder
+ es un usuario no v�lido.
+ Cargando
+ La conversaci�n se ha marcado como le�da.
+ Debe de seleccionar al menos un mensaje
+ Rv
+ Re
+ Sistema de env�o de mensajes: permite enviar mensajes a las personas que pertenecen a este grupo, si deseas enviar mensajes a una persona que pertenece a otro grupo, debeis ir a dicho curso/comunidad y enviar el mensaje desde alli.
+ La conversaci�n se ha marcado como no le�da.
+ Escribir el nombre del nuevo folder
+ Nuevo Folder
+ Por favor, escriba el nombre del nuevo folder
+ < Anterior
+ Anterior
+ << Primera p�gina
+ No
+ No se ha encontrado ning�n miembro.
+ Usted no tiene ning�n mensaje.
+ sin asunto
+ Normal
+ De
+ Siguiente >
+ Posterior
+ �ltima p�gina >>
+ Usted est� respondiendo un mensaje.
+ Imprimir
+ %first_row% -- %last_number% De %total_messages%
+ Destinatarios
+ Especifica al menos un destinatario.
+ Responder
+ Responder a todos
+ Guardados
+ Guardar
+ Guardar mensaje enviado
+ Buscar
+ Enviar
+ Enviar a todos
+ Enviando
+ Enviados
+ Mostrar detalles
+ Firma
+ Asunto
+ �Deseas enviar este mensaje sin asunto?
+ %user_name% te ha enviado un mensaje en la comunidad "%community_name%"
+ Folder creado satisfactoriamente
+ Para
+ [i] Si conoce el nombre y/o apellidos del usuario al que le envia el mensaje, escr�balo en el campo de texto Para y se le mostrar�n aquellos usuarios que coincidan con lo escrito en dicho campo
+ Hoy
+ Papelera
+ Ver mensajes
+ Redactar correo
+ Si
+
Index: openacs-4/packages/messages/sql/oracle/messages-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/sql/oracle/messages-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/sql/oracle/messages-create.sql 31 Aug 2010 21:29:50 -0000 1.1
@@ -0,0 +1,114 @@
+--
+-- Assessment Package
+--
+-- @author pedro@viaro.net
+-- @creation-date 2009-10-30
+--
+
+
+create sequence messages_msg_sequence start with 1;
+--messages
+create table messages_messages (
+ msg_id integer not null
+ constraint messages_messages_msg_id_pk
+ primary key,
+ owner_id integer not null,
+ community_id integer not null,
+ sent_date date default sysdate not null,
+ parent_id integer,
+ mime_type varchar2(200) default 'text/plain',
+ subject varchar2(200),
+ msg_content clob
+);
+
+create index messages_community_id_index on messages_messages(community_id);
+create index messages_parent_id_index on messages_messages(parent_id);
+
+--recipients mail
+
+create table messages_recipients (
+ msg_id integer not null
+ constraint recipients_party_id_fk
+ references messages_messages(msg_id)
+ on delete cascade,
+ party_id integer not null
+ constraint recipients_msg_id_fk
+ references parties(party_id)
+ on delete cascade,
+ constraint messages_recipients_pk primary key (msg_id, party_id)
+);
+
+create table messages_recipients_roles (
+ msg_id integer not null
+ constraint recipients_roles_msg_id_fk
+ references messages_messages(msg_id)
+ on delete cascade,
+ rel_id varchar(100) not null
+ constraint recipients_rel_id_fk
+ references acs_rel_types (rel_type)
+ on delete cascade,
+ constraint messages_recipients_rel_pk primary key (msg_id, rel_id)
+);
+
+--Attachments
+create table messages_attachments (
+ msg_id integer not null
+ constraint messages_attachment_msg_id_fk
+ references messages_messages
+ on delete cascade,
+ attachment_id integer not null,
+ attachment_item_id integer not null,
+ constraint msg_attachment_pk primary key (msg_id,attachment_id)
+);
+
+--user messages to specific folder
+create table messages_user_messages (
+ msg_id integer not null
+ constraint user_messages_msg_id_fk
+ references messages_messages
+ on delete cascade,
+ user_id integer not null
+ constraint user_messages_user_id_fk
+ references users
+ on delete cascade,
+ parent_id integer
+ constraint user_msg_parent_id_fk
+ references messages_messages(msg_id)
+ on delete cascade,
+ folder_id integer default 0,
+ new_p char default 't'
+ check (new_p in ('t','f')),
+ constraint messages_user_messages_pk primary key (msg_id,user_id,folder_id)
+);
+
+create index user_messages_user_id_index on messages_user_messages(user_id);
+
+--user folders
+create sequence messages_folders_sequence start with 5;
+create table messages_folders (
+ user_id integer
+ constraint messages_folders_user_id_fk
+ references users
+ on delete cascade,
+ folder_id integer not null,
+ folder_name varchar(50) not null
+);
+
+insert into messages_folders values(0,0,'#messages.inbox#');
+insert into messages_folders values(0,1,'#messages.sent#');
+insert into messages_folders values(0,2,'#messages.save#');
+insert into messages_folders values(0,3,'#messages.trash#');
+
+
+--message configuration
+create table messages_options (
+ user_id integer
+ constraint messages_options_pk
+ primary key
+ constraint messages_options_user_fk
+ references users,
+ max_messages integer default 50,
+ save_sent_p integer default 1,
+ signature_p integer default 0,
+ signature varchar2(1000) default ''
+);
Index: openacs-4/packages/messages/sql/oracle/messages-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/sql/oracle/messages-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/sql/oracle/messages-drop.sql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,9 @@
+drop sequence messages_msg_sequence;
+drop table messages_recipients
+drop table messages_attachments;
+drop table messages_user_messages;
+drop index messages_user_messages_index;
+drop sequence messages_folders_sequence;
+drop table messages_folders;
+drop table messages_options;
+drop table messages_messages;
\ No newline at end of file
Index: openacs-4/packages/messages/sql/postgresql/messages-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/sql/postgresql/messages-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/sql/postgresql/messages-create.sql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,137 @@
+--
+-- Assessment Package
+--
+-- @author pedro@viaro.net
+-- @creation-date 2009-10-30
+--
+
+
+create sequence messages_msg_sequence start with 1;
+--messages
+create table messages_messages (
+ msg_id integer not null
+ constraint messages_messages_msg_id_pk
+ primary key,
+ owner_id integer not null,
+ community_id integer not null,
+ sent_date timestamp default now() not null,
+ parent_id integer,
+ mime_type varchar(200) default 'text/plain',
+ subject varchar(200),
+ msg_content text
+);
+
+create index messages_community_id_index on messages_messages(community_id);
+create index messages_parent_id_index on messages_messages(parent_id);
+
+--recipients mail
+
+create table messages_recipients (
+ msg_id integer not null
+ constraint recipients_party_id_fk
+ references messages_messages(msg_id)
+ on delete cascade,
+ party_id integer not null
+ constraint recipients_msg_id_fk
+ references parties(party_id)
+ on delete cascade,
+ constraint messages_recipients_pk primary key (msg_id, party_id)
+);
+
+create table messages_recipients_roles (
+ msg_id integer not null
+ constraint recipients_roles_msg_id_fk
+ references messages_messages(msg_id)
+ on delete cascade,
+ rel_id varchar(100) not null
+ constraint recipients_rel_id_fk
+ references acs_rel_types (rel_type)
+ on delete cascade,
+ constraint messages_recipients_rel_pk primary key (msg_id, rel_id)
+);
+
+--Attachments
+create table messages_attachments (
+ msg_id integer not null
+ constraint messages_attachment_msg_id_fk
+ references messages_messages
+ on delete cascade,
+ attachment_id integer not null,
+ attachment_item_id integer not null,
+ constraint msg_attachment_pk primary key (msg_id,attachment_id)
+);
+
+--user messages to specific folder
+create table messages_user_messages (
+ msg_id integer not null
+ constraint user_messages_msg_id_fk
+ references messages_messages
+ on delete cascade,
+ user_id integer not null
+ constraint user_messages_user_id_fk
+ references users
+ on delete cascade,
+ parent_id integer
+ constraint user_msg_parent_id_fk
+ references messages_messages(msg_id)
+ on delete cascade,
+ folder_id integer default 0,
+ new_p char default 't'
+ check (new_p in ('t','f')),
+ constraint messages_user_messages_pk primary key (msg_id,user_id,folder_id)
+);
+
+create index user_messages_user_id_index on messages_user_messages(user_id);
+
+--user folders
+create sequence messages_folders_sequence start with 5;
+create table messages_folders (
+ user_id integer
+ constraint messages_folders_user_id_fk
+ references users
+ on delete cascade,
+ folder_id integer not null,
+ folder_name varchar(50) not null
+);
+
+insert into messages_folders values(0,0,'#messages.inbox#');
+insert into messages_folders values(0,1,'#messages.sent#');
+insert into messages_folders values(0,2,'#messages.save#');
+insert into messages_folders values(0,3,'#messages.trash#');
+
+
+--message configuration
+create table messages_options (
+ user_id integer
+ constraint messages_options_pk
+ primary key
+ constraint messages_options_user_fk
+ references users,
+ max_messages integer default 50,
+ save_sent_p integer default 1,
+ signature_p integer default 0,
+ signature varchar(1000) default ''
+);
+
+
+CREATE FUNCTION concat (text, text) RETURNS text AS $$
+ DECLARE
+ t text;
+ BEGIN
+ IF character_length($1) > 0 THEN
+ t = $1 ||', '|| $2;
+ ELSE
+ t = $2;
+ END IF;
+ RETURN t;
+ END;
+$$ LANGUAGE plpgsql;
+
+
+CREATE AGGREGATE concat (
+ BASETYPE = text,
+ SFUNC = textcat,
+ STYPE = text,
+ INITCOND = ''
+);
+
Index: openacs-4/packages/messages/sql/postgresql/messages-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/sql/postgresql/messages-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/sql/postgresql/messages-drop.sql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,12 @@
+drop sequence messages_msg_sequence;
+drop index messages_community_id_index;
+drop index messages_parent_id_index;
+drop table messages_recipients;
+drop table messages_recipients_roles;
+drop table messages_attachments;
+drop table messages_user_messages;
+drop index user_messages_user_id_index;
+drop sequence messages_folders_sequence;
+drop table messages_folders;
+drop table messages_options;
+drop table messages_messages cascade;
\ No newline at end of file
Index: openacs-4/packages/messages/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/tcl/apm-callback-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/tcl/apm-callback-procs.tcl 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,43 @@
+# /packages/messages/tcl/apm-callback-procs.tcl
+
+ad_library {
+
+ Messages Package APM callbacks library
+
+ Procedures that deal with installing, instantiating, mounting.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-26
+
+}
+
+namespace eval messages {}
+namespace eval messages::apm {}
+
+ad_proc -public messages::apm::package_install {
+
+} {
+ Does the integration whith the notifications package.
+} {
+ db_transaction {
+ #Create the conten types
+ content::type::new -content_type {messages_attachments} -supertype {content_revision} -pretty_name {Message Attachment} -pretty_plural {Message Attachments} -table_name {messages_attachments} -id_column {attachment_id}
+
+ #Create content type attributes for content type messages
+ content::type::attribute::new -content_type {messages_attachments} -attribute_name {attachment_item_id} -datatype {number} -pretty_name {Attachment Item ID} -column_spec {integer}
+ content::type::attribute::new -content_type {messages_attachments} -attribute_name {msg_id} -datatype {number} -pretty_name {Message ID} -column_spec {integer}
+ }
+}
+
+ad_proc -public messages::apm::package_instantiate {
+ -package_id:required
+} {
+
+ Define Message folders
+
+} {
+ # create a content folder
+ set folder_id [content::folder::new -name "messages_attachments_$package_id" -label "messages_attachments_$package_id" -package_id $package_id ]
+ # register the allowed content types for a folder
+ content::folder::register_content_type -folder_id $folder_id -content_type messages_attachments -include_subtypes t
+}
\ No newline at end of file
Index: openacs-4/packages/messages/tcl/messages-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/tcl/messages-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/tcl/messages-procs.tcl 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,285 @@
+ad_library {
+ Procedures in the messages namespace.
+
+ @creation-date 12-28-2009
+ @author pedro@viaro.net
+}
+
+namespace eval messages {}
+
+ad_proc -public messages::send_mail {
+ -contacts_ids
+ -community_id
+ -owner_id
+ -subject
+ {-message_url ""}
+ {-parent_id ""}
+ {-count_attachment 0}
+ {-message ""}
+ {-rel_types ""}
+} {
+ Send mail to diferent users
+} {
+ set community_name [dotlrn_community::get_community_name $community_id]
+ set user_id [ad_conn user_id]
+ set user_name [acs_user::get_element -user_id $user_id -element name]
+ if { ![exists_and_not_null parent_id] } {
+ set parent_id ""
+ }
+ db_transaction {
+ set msg_id [db_nextval messages_msg_sequence]
+ db_dml send_mail {}
+ }
+
+ if { ![empty_string_p $rel_types] } {
+ set rel_types "'[join $rel_types "','"]'"
+ set rel_types_user_ids_list [db_list get_rel_types_user_ids {}]
+ if { [empty_string_p $contacts_ids] } {
+ append contacts_ids_roles [join $rel_types_user_ids_list ","]
+ } else {
+ append contacts_ids_roles "," [join $rel_types_user_ids_list ","]
+ }
+ } else {
+ set contacts_ids_roles ""
+ }
+
+ set party_id_list [lsort -unique [split $contacts_ids ","]]
+ if { ![empty_string_p $contacts_ids_roles] } {
+ set party_id_list_roles [lsort -unique [split $contacts_ids_roles ","]]
+ } else {
+ set party_id_list_roles [list]
+ }
+
+ foreach party_id $party_id_list {
+ set email_user [acs_user::get_element -user_id $party_id -element email]
+ set package_id [dotlrn_community::get_package_id_from_package_key -package_key kernel -community_id 0]
+ set from_addr [parameter::get -parameter "OutgoingSender" -package_id $package_id]
+ ## E-mail notification is disabled by default, to enable just uncomment the following line in every place in this file
+ #acs_mail_lite::send -send_immediately -to_addr $email_user -from_addr $from_addr -subject [encoding convertto iso8859-15 [_ messages.subject_mail]] -body [_ messages.body_mail]
+ db_dml recipients {}
+ db_dml user_messages {}
+ }
+ if { ![empty_string_p $rel_types] } {
+ foreach party_id $party_id_list_roles {
+ if { [lsearch $party_id_list $party_id] == -1 && ![empty_string_p $party_id]} {
+ set email_user [acs_user::get_element -user_id $party_id -element email]
+ set package_id [dotlrn_community::get_package_id_from_package_key -package_key kernel -community_id 0]
+ set from_addr [parameter::get -parameter "OutgoingSender" -package_id $package_id]
+ ## E-mail notification is disabled by default, to enable just uncomment the following line in every place in this file
+ #acs_mail_lite::send -send_immediately -to_addr $email_user -from_addr $from_addr -subject [encoding convertto iso8859-15 [_ messages.subject_mail]] -body [_ messages.body_mail]
+ db_dml user_messages {}
+ }
+ }
+ set rel_types [split $rel_types ","]
+ foreach rel_type $rel_types {
+ db_dml recipients_roles {}
+ }
+
+ }
+ set save_sent_p [db_string get_save_sent {} -default 1]
+
+ if { $save_sent_p } {
+ db_dml sent_message {}
+ }
+ return $msg_id
+ ad_script_abort
+}
+
+ad_proc -public messages::reply_mail {
+ -general_parent_id
+ -contacts_ids
+ -community_id
+ -owner_id
+ -subject
+ {-message_url ""}
+ {-parent_id ""}
+ {-count_attachment 0}
+ {-message ""}
+ {-msg_id_old ""}
+ {-attachment_ids ""}
+ {-rel_types ""}
+} {
+ Send reply, reply-all and forward mail to diferent users
+} {
+ set message [list "$message" "text/html"]
+ set community_name [dotlrn_community::get_community_name $community_id]
+ set user_id [ad_conn user_id]
+ set user_name [acs_user::get_element -user_id $user_id -element name]
+ #set subject [db_string get_subject {}]
+ db_transaction {
+ set msg_id [db_nextval messages_msg_sequence]
+ if { !$general_parent_id } {
+ set lang [string range [lang::conn::locale -package_id [ad_conn package_id]] 0 2]
+ set subject "[_ messages.msg_subject_forward]: $subject"
+ db_dml send_mail_forward {}
+ if { ![empty_string_p $attachment_ids] } {
+ set attachment_ids_clause "and attachment_id in ($attachment_ids)"
+ } else {
+ set attachment_ids_clause ""
+ }
+ set attachment_list [db_list_of_lists get_attachment_id { *SQL*}]
+ foreach attachment $attachment_list {
+ set attachment_id [lindex $attachment 0]
+ set attachment_item_id [lindex $attachment 1]
+ db_dml attachment_files {}
+ }
+ } else {
+ set subject "[_ messages.msg_subject_reply]: $subject"
+ if { [string equal $contacts_ids ""] } {
+ set contacts_ids "$user_id"
+ } else {
+ append contacts_ids ",$user_id"
+ }
+ db_dml send_mail {}
+ }
+ }
+ if { ![empty_string_p $rel_types] } {
+ set rel_types "'[join $rel_types "','"]'"
+ set rel_types_user_ids_list [db_list get_rel_types_user_ids {}]
+ if { [empty_string_p $contacts_ids] } {
+ append contacts_ids_roles [join $rel_types_user_ids_list ","]
+ } else {
+ append contacts_ids_roles "," [join $rel_types_user_ids_list ","]
+ }
+ } else {
+ set contacts_ids_roles ""
+ }
+ set party_id_list [lsort -unique [split $contacts_ids ","]]
+ set party_id_list_roles [lsort -unique [split $contacts_ids_roles ","]]
+ foreach party_id $party_id_list {
+ set email_user [acs_user::get_element -user_id $party_id -element email]
+ set package_id [dotlrn_community::get_package_id_from_package_key -package_key kernel -community_id 0]
+ set from_addr [parameter::get -parameter "OutgoingSender" -package_id $package_id]
+ ## E-mail notification is disabled by default, to enable just uncomment the following line in every place in this file
+ #acs_mail_lite::send -send_immediately -to_addr $email_user -from_addr $from_addr -subject [encoding convertto iso8859-15 [_ messages.subject_mail]] -body [_ messages.body_mail]
+ db_dml recipients {}
+ if { !$general_parent_id } {
+ db_dml user_messages_forward {}
+ } else {
+ db_dml user_messages {}
+ }
+ }
+ if { ![empty_string_p $rel_types] } {
+ foreach party_id $party_id_list_roles {
+ if { [lsearch $party_id_list $party_id] == -1 && ![empty_string_p $party_id]} {
+ set email_user [acs_user::get_element -user_id $party_id -element email]
+ set package_id [dotlrn_community::get_package_id_from_package_key -package_key kernel -community_id 0]
+ set from_addr [parameter::get -parameter "OutgoingSender" -package_id $package_id]
+ ## E-mail notification is disabled by default, to enable just uncomment the following line in every place in this file
+ #acs_mail_lite::send -send_immediately -to_addr $email_user -from_addr $from_addr -subject [encoding convertto iso8859-15 [_ messages.subject_mail]] -body [_ messages.body_mail]
+ if { !$general_parent_id } {
+ db_dml user_messages_forward {}
+ } else {
+ db_dml user_messages {}
+ }
+ }
+ }
+ set rel_types [split $rel_types ","]
+ foreach rel_type $rel_types {
+ db_dml recipients_roles {}
+ }
+ }
+ set party_id [ad_conn user_id]
+ set save_sent_p [db_string get_save_sent {} -default 1]
+ if { $save_sent_p } {
+ if { !$general_parent_id } {
+ db_dml sent_message_forward {}
+ } else {
+ db_dml sent_message {}
+ }
+ }
+ return $msg_id
+ ad_script_abort
+}
+
+ad_proc -public messages::delete_trash_messages {
+
+} {
+ Delete all messages in the thash folder
+} {
+ set folder_id [messages::get_folder_id -folder_name "trash"]
+ set limit_days_in_trash 15
+ db_transaction {
+ db_dml delete_messages {}
+ }
+}
+
+ad_proc -public messages::get_folder_id {
+ -folder_name
+} {
+ Get the folder id to standar folders to users.
+} {
+ switch $folder_name {
+ inbox {
+ return 0
+ }
+ sent {
+ return 1
+ }
+ save {
+ return 2
+ }
+ trash {
+ return 3
+ }
+ }
+}
+
+
+ad_proc -public messages::get_history_conversation {
+ -parent_id
+ -msg_id
+ -user_id
+} {
+ Get the history conversation until the message forward
+} {
+ set blockquote_conversation_begin "
"
+ set blockquote_conversation_end "
"
+ set conversation "
"
+ set count_messages 0
+ append not_folder_ids [messages::get_folder_id -folder_name "sent"] "," \
+ [messages::get_folder_id -folder_name "trash"]
+ db_multirow messages get_history_conversation { *SQL* } {
+ set day_recive [lc_time_fmt $sent_date "%d %b, %Y" ]
+ set ansi_time "$day_recive - $time"
+ set msg_content [template::util::richtext::get_property contents $msg_content]
+ append conversation "$blockquote_conversation_begin
+ El $day_recive, a las $time, [acs_user::get_element -user_id $owner_id -element name] escribio:
+ $msg_content
"
+ incr count_messages
+ }
+ for {set i 0} {$i <= $count_messages} {incr i} {
+ append blockqoute_end $blockquote_conversation_end
+ }
+ append conversation "$blockqoute_end
"
+ return $conversation
+}
+
+ad_proc -public messages::get_community_users_fb {
+ -community_id
+} {
+ Memoize de members of the community
+} {
+ #Recipients are obtained and placed in the form autocomplete style
+ set contacts_list [join [db_list members { *SQL* }] ","]
+ return $contacts_list
+}
+
+ad_proc -public messages::string_truncate_middle {
+ {-ellipsis "..."}
+ {-len "100"}
+ -string
+} {
+ cut middle part of a string in case it is to long copied from xotcl-request-monitor
+} {
+ set string [string trim $string]
+ if {[string length $string]>$len} {
+ set half [expr {($len-2)/2}]
+ set left [string trimright [string range $string 0 $half]]
+ set right [string trimleft [string range $string end-$half end]]
+ return $left$ellipsis$right
+ }
+ return $string
+
+}
+
Index: openacs-4/packages/messages/tcl/messages-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/tcl/messages-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/tcl/messages-procs.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,203 @@
+
+
+
+
+
+
+ insert into messages_messages (msg_id, owner_id, community_id, subject, msg_content)
+ values (:msg_id,:owner_id,:community_id,:subject,:message)
+
+
+
+
+
+ insert into messages_recipients (msg_id, party_id)
+ values (:msg_id,:party_id)
+
+
+
+
+
+ insert into messages_recipients_roles (msg_id, rel_id)
+ values (:msg_id,$rel_type)
+
+
+
+
+
+ insert into messages_user_messages (msg_id, user_id, folder_id, new_p,parent_id)
+ values (:msg_id,:party_id,0,'t',:msg_id)
+
+
+
+
+
+ select save_sent_p
+ from messages_options
+ where user_id = :user_id
+
+
+
+
+
+ insert into messages_user_messages (msg_id, user_id, folder_id, new_p,parent_id)
+ values (:msg_id,:owner_id,1,'t',:msg_id)
+
+
+
+
+
+ update messages_user_messages
+ set new_p = 't'
+ where msg_id = :msg_id
+
+
+
+
+
+ select attachment_id, attachment_item_id
+ from messages_attachments
+ where msg_id = :msg_id_old
+ $attachment_ids_clause
+
+
+
+
+
+ insert into messages_messages (msg_id, owner_id, community_id, subject, msg_content)
+ values (:msg_id,:owner_id,:community_id,:subject,:message)
+
+
+
+
+
+ insert into messages_messages (msg_id, owner_id, community_id, subject, msg_content,parent_id)
+ values (:msg_id,:owner_id,:community_id,:subject,:message,:general_parent_id)
+
+
+
+
+
+ insert into messages_recipients (msg_id, party_id)
+ values ($msg_id,$party_id)
+
+
+
+
+
+ insert into messages_recipients_roles (msg_id, rel_id)
+ values (:msg_id,$rel_type)
+
+
+
+
+
+ insert into messages_user_messages (msg_id, user_id, folder_id, new_p,parent_id)
+ values (:msg_id,:party_id,0,'t',:msg_id)
+
+
+
+
+
+ insert into messages_user_messages (msg_id, user_id, folder_id, new_p,parent_id)
+ values (:msg_id,:owner_id,1,'t',:msg_id)
+
+
+
+
+
+ select save_sent_p
+ from messages_options
+ where user_id = :user_id
+
+
+
+
+
+ insert into messages_attachments values (:msg_id,:attachment_id,:attachment_item_id)
+
+
+
+
+
+ insert into messages_user_messages (msg_id, user_id, folder_id, new_p,parent_id)
+ values (:msg_id,:owner_id,1,'t',:parent_id)
+
+
+
+
+
+ insert into messages_user_messages (msg_id, user_id, folder_id, new_p,parent_id)
+ values (:msg_id,:party_id,0,'t',:parent_id)
+
+
+
+
+
+ delete from messages_user_messages
+ where msg_id in ( select um.msg_id
+ from (select parent_id,msg_id from messages_user_messages where folder_id = :folder_id and msg_id = parent_id) um,
+ (select msg_id,to_char(sent_date, 'DD-MM-YYYY') as sent_date from messages_messages where sent_date < (SELECT sysdate - :limit_days_in_trash FROM dual)) m
+ where um.msg_id = m.msg_id
+ )
+
+
+
+
+
+ select msg_id, user_id from messages_user_messages where folder_id = :folder_id
+
+
+
+
+
+ select subject from messages_messages where msg_id = :msg_id_old
+
+
+
+
+
+ select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and rel_type in ($rel_types)
+
+
+
+
+
+ select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and rel_type in ($rel_types)
+
+
+
+
+
+ select msg_content, owner_id, subject,
+ sent_date, to_char(sent_date, 'HH24:MI:SS') as time
+ from messages_messages
+ where msg_id in (select msg_id
+ from messages_user_messages
+ where user_id = :user_id
+ and folder_id not in ($not_folder_ids)
+ and parent_id = :parent_id)
+ and msg_id <= :msg_id
+ order by msg_id desc
+
+
+
+
+
+
+ select '{name:"'||name.party_name||'", p:"'||name.person_id||'"}'
+ from (select persons.first_names||' '||persons.last_name as party_name, persons.person_id
+ from persons,dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = persons.person_id
+ order by party_name) as name
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/contacts.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/contacts.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/contacts.adp 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,19 @@
+
+
+
+ @contact_name@
+
+
+
+
+
+
+
+
+ @contact.party_name@
+
+
+
+
+
+forward
\ No newline at end of file
Index: openacs-4/packages/messages/www/contacts.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/contacts.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/contacts.tcl 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,27 @@
+ad_page_contract {
+ Update numbers of new messages in the menu
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-17
+ @cvs-id $Id: contacts.tcl,v 1.1 2010/08/31 21:30:45 alvaror Exp $
+} {
+ msg_id
+ {option ""}
+}
+
+set community_id [dotlrn_community::get_community_id]
+
+if { [string equal $option "reply"]} {
+ db_1row owner_info {}
+}
+
+if { [string equal $option "reply_all"]} {
+ #gets all the recipients included in the message
+ db_multirow contact recipient_ids { *SQL* } { }
+}
+
+if { [string equal $option "forward"]} {
+ #when select forward, return only forward because in the javascript,
+ #this option is write nothing in the recipients.
+ set contacts_reply "forward"
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/contacts.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/contacts.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/contacts.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,28 @@
+
+
+
+
+
+ select acs_users_all.first_names||' '||acs_users_all.last_name as contact_name,
+ acs_users_all.party_id as contact_id
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id in (select owner_id from messages_messages where msg_id = :msg_id)
+
+
+
+
+
+ select acs_users_all.first_names||' '||acs_users_all.last_name as party_name,
+ acs_users_all.party_id
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id in (select party_id from messages_recipients where msg_id = :msg_id)
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/create-folder.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/create-folder.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/create-folder.adp 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1 @@
+@response@
\ No newline at end of file
Index: openacs-4/packages/messages/www/create-folder.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/create-folder.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/create-folder.tcl 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,26 @@
+ad_page_contract {
+ Create a New folder.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-17
+ @cvs-id $Id: create-folder.tcl,v 1.1 2010/08/31 21:30:42 alvaror Exp $
+} {
+ folder_name
+}
+
+set user_id [ad_conn user_id]
+set folder_id [db_nextval messages_folders_sequence]
+set folder_name [string trim "$folder_name"]
+#create a new folder but not is create when folder_name is empty or greater than 20 characteres.
+if { [empty_string_p $folder_name] || [string length $folder_name] > 20} {
+ if { [empty_string_p $folder_name] } {
+ set response "[_ messages.new_folder_name_error]"
+ } else {
+ set response "[_ messages.lt_folder_name_error]"
+ }
+} else {
+ db_transaction {
+ db_dml create_new_folder {}
+ }
+ set response [_ messages.sucsessful_create_folder]
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/create-folder.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/create-folder.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/create-folder.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,12 @@
+
+
+
+
+
+ insert into
+ messages_folders (user_id,folder_id,folder_name)
+ values(:user_id,:folder_id,:folder_name)
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/delete-message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/delete-message.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/delete-message.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1 @@
+complete
Index: openacs-4/packages/messages/www/delete-message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/delete-message.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/delete-message.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,17 @@
+ad_page_contract {
+ Delete selected messages in the trash folder
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-24
+ @cvs-id $Id: delete-message.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+ msg_ids
+}
+
+set folder_id [messages::get_folder_id -folder_name "trash"]
+set community_id [dotlrn_community::get_community_id]
+set user_id [ad_conn user_id]
+
+db_transaction {
+ db_dml delete_messages {}
+}
Index: openacs-4/packages/messages/www/delete-message.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/delete-message.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/delete-message.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+ delete from messages_user_messages
+ where folder_id = :folder_id
+ and user_id = :user_id
+ and msg_id in ($msg_ids)
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/empty-trash.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/empty-trash.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/empty-trash.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1 @@
+@folder_id@
\ No newline at end of file
Index: openacs-4/packages/messages/www/empty-trash.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/empty-trash.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/empty-trash.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,16 @@
+ad_page_contract {
+ Empty Trash
+
+ @author pedro@viaro.net
+ @creation-date 2010-01-22
+ @cvs-id $Id: empty-trash.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+
+}
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+set folder_id [messages::get_folder_id -folder_name "trash"]
+db_transaction {
+ db_dml empty_trash {}
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/empty-trash.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/empty-trash.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/empty-trash.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,11 @@
+
+
+
+
+
+ delete from messages_user_messages
+ where folder_id = :folder_id and user_id = :user_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/inbox-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/inbox-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/inbox-oracle.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,52 @@
+
+
+
+ oracle8.1.6
+
+
+
+ select mm.last_msg_id, mm.msg_id, mm.number_conversation, mm.subject, wm_concat(distinct(p.first_names||' '||p.last_name)) as contacts, count(distinct(p.first_names)) as total_contacs, mm.owner_id
+ from persons p,
+ (select max(um.msg_id) as last_msg_id, um.parent_id as msg_id, count(um.msg_id) as number_conversation, m.subject, m.owner_id
+ from (select parent_id,msg_id from messages_user_messages where user_id = :user_id and folder_id = :folder_id) um,
+ (select msg_id,subject,owner_id from messages_messages where community_id = :community_id and msg_id in ($msg_ids)) m
+ where um.parent_id = m.msg_id
+ group by um.parent_id, m.subject, m.owner_id) mm
+ where p.person_id = mm.owner_id
+ group by mm.msg_id, mm.subject, mm.last_msg_id, mm.number_conversation, mm.owner_id
+ order by mm.last_msg_id desc
+
+
+
+
+
+ select distinct(owner_id)
+ from messages_messages
+ where parent_id = :msg_id
+ or msg_id = :msg_id
+ and rownum < 4
+
+
+
+
+
+ select msg_id, last_msg_id
+ from (select paginate.*, rownum rowsub
+ from (select max(m.msg_id) as last_msg_id, m.parent_id as msg_id, count(m.msg_id) as number_conversation
+ from (select msg_id, coalesce(parent_id,msg_id) as parent_id
+ from messages_messages
+ where community_id = :community_id
+ and msg_id in (select parent_id
+ from messages_user_messages
+ where user_id = :user_id
+ and folder_id = :folder_id)) m
+ group by m.parent_id
+ order by last_msg_id desc
+ ) paginate
+ where rownum <= :last_row)
+ where rowsub >= :first_row
+
+
+
+
+
Index: openacs-4/packages/messages/www/inbox-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/inbox-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/inbox-postgresql.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,51 @@
+
+
+ postgresql7.3
+
+
+
+ select mm.last_msg_id, mm.msg_id, mm.number_conversation, mm.subject, ARRAY_TO_STRING(ARRAY(select first_names||' '||last_name from persons where person_id = mm.owner_id),',') as contacts, count(distinct p.first_names) as total_contacs, mm.owner_id
+ from persons p,
+ (select max(um.msg_id) as last_msg_id, um.parent_id as msg_id, count(um.msg_id) as number_conversation, m.subject, m.owner_id
+ from (select parent_id,msg_id from messages_user_messages where user_id = :user_id and folder_id = :folder_id) um,
+ (select msg_id,subject,owner_id from messages_messages where community_id = :community_id and msg_id in ($msg_ids)) m
+ where um.parent_id = m.msg_id
+ group by um.parent_id, m.subject, m.owner_id) mm
+ where p.person_id = mm.owner_id
+ group by mm.msg_id, mm.subject, mm.last_msg_id, mm.number_conversation, mm.owner_id
+ order by mm.last_msg_id desc
+
+
+
+
+
+ select distinct(owner_id)
+ from messages_messages
+ where parent_id = :msg_id
+ or msg_id = :msg_id
+ LIMIT 4
+
+
+
+
+
+ select messages.msg_id, messages.last_msg_id
+ from (select paginate.*
+ from (select max(m.msg_id) as last_msg_id, m.parent_id as msg_id, count(m.msg_id) as number_conversation
+ from (select msg_id, coalesce(parent_id,msg_id) as parent_id
+ from messages_messages
+ where community_id = :community_id
+ and msg_id in (select parent_id
+ from messages_user_messages
+ where user_id = :user_id
+ and folder_id = :folder_id)) m
+ group by m.parent_id
+ order by last_msg_id desc
+ ) paginate
+ LIMIT :last_row) messages
+ OFFSET :first_row - 1
+
+
+
+
+
Index: openacs-4/packages/messages/www/inbox.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/inbox.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/inbox.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/inbox.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/inbox.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/inbox.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,201 @@
+ad_page_contract {
+ Inbox Page
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-11
+ @cvs-id $Id: inbox.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+ {folder_id ""}
+ {page_number ""}
+}
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+if {[empty_string_p $page_number]} {
+ set page_number 1
+}
+
+if {[empty_string_p $folder_id]} {
+ set folder_id 0
+}
+
+#####################################################################
+#get the total messages and calculate how many pages have in folder show
+#First and last row are calculate based on the total messages show per page
+set total_messages [db_string get_total_messages {} -default 0]
+set show_messages [db_string get_max_show_msg {} -default 25]
+#Round to the next integer because the las page include some messages.
+set total_pages [expr ceil([expr [expr $total_messages + 0.0] / [expr $show_messages + 0.0]])]
+set oldest_page [expr $total_pages - 1]
+set count_messages 0
+if { $page_number != 1} {
+ set first_row [expr [expr [expr $page_number - 1] * $show_messages] + 1]
+ set last_row [expr [expr $first_row + $show_messages] - 1]
+} else {
+ set first_row [expr [expr $page_number - 1] * $show_messages]
+ set last_row [expr $first_row + $show_messages]
+ set first_row [expr $first_row + 1]
+}
+######################################################################
+
+set elements [list msg_ids \
+ [list label { } \
+ display_template {} \
+ sub_class {narrow} \
+ html { align center }] \
+ ]
+
+lappend elements contacts \
+ [list html { align left style "font-size: smaller; width:20%"} \
+ label [_ messages.from] \
+ display_template { \
+ @messages.contacts@ \
+ (@messages.number_conversation@) \
+ @messages.contacts@ (@messages.number_conversation@)} \
+ ] \
+ rel_type \
+ [list html { align left style "font-size: smaller; width:5%;"} \
+ label "" \
+ display_template { \
+ @messages.rel_type@ } \
+ ] \
+ attachmet_mail \
+ [list html { align center style "font-size: smaller; width:3%"} \
+ label "" \
+ display_template { \
+ \
+ } \
+ ] \
+ subject_mail \
+ [list html { align left style "font-size: smaller; width:62%"} \
+ label [_ messages.subject] \
+ display_template { \
+ @messages.subject_mail@ \
+ @messages.subject_mail@} \
+ ] \
+ date \
+ [list html { align left style "font-size: smaller;width:12%"} \
+ label [_ messages.date] \
+ display_template { \
+ @messages.date@ \
+ @messages.date@} \
+ ]
+
+template::list::create \
+ -name messages \
+ -multirow messages \
+ -main_class "list-table" \
+ -html { width=100% } \
+ -orderby_name orderby \
+ -no_data "[_ messages.no_messages_found]" \
+ -elements $elements
+
+
+set msg_id_list [list]
+set last_msg_ids_list [list]
+db_foreach get_msg_ids { *SQL* } {
+ set last_msg_ids_array($msg_id) $last_msg_id
+ lappend last_msg_ids_list $last_msg_id
+ lappend msg_id_list $msg_id
+}
+
+set msg_ids [join $msg_id_list ","]
+set last_msg_ids [join $last_msg_ids_list ","]
+
+if { [empty_string_p $msg_ids] } {
+ set msg_ids 0
+}
+
+if { [empty_string_p $last_msg_ids] } {
+ set last_msg_ids 0
+}
+
+db_foreach get_attachment_p { } {
+ set get_attachment_array($parent_id) $count_attachment
+}
+
+db_foreach get_new_p {} {
+ set new_p_array($parent_id) $new_p
+}
+
+db_foreach get_msg_info {} {
+ set msg_content_array($parent_id) $msg_content
+ set date_sent_array($parent_id) $sent_date_ansi
+}
+
+##Roles: se estable los roles que existen y se obtienen lo usuarios y sus roles
+set roles [dotlrn_community::get_roles -community_id $community_id]
+set rel_types [list]
+foreach role $roles {
+ lappend rel_types [lindex $role 0]
+}
+set rel_types [join $rel_types "','"]
+set rel_type_case "case "
+foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ if { [string equal $rel_type "dotlrn_student_rel"] } {
+ append rel_type_case "when rel_type = '$rel_type' then '' "
+ } else {
+ append rel_type_case "when rel_type = '$rel_type' then '$pretty_name' "
+ }
+}
+append rel_type_case " end"
+
+###
+
+foreach msg_id $msg_id_list {
+ set contacts_ids [db_list get_contacts {}]
+ set owner_id [db_string get_owner_id {}]
+ set member_ids_rel_type($owner_id) [db_string get_members_ids_rel_type {}]
+ if { [llength $contacts_ids] > 1} {
+ set contacts ""
+ foreach contact_id $contacts_ids {
+ append contacts [db_string get_name {}] ","
+ }
+ set contacts [string range $contacts 0 end-1]
+ set msg_contacts($msg_id) $contacts
+ }
+}
+
+db_multirow -extend { rel_type subject_mail date attachment_p new_p} messages get_messages { *SQL* } {
+ if { [info exists get_attachment_array($msg_id)]} {
+ set attachment_p $get_attachment_array($msg_id)
+ } else {
+ set attachment_p 0
+ }
+ if { [info exists member_ids_rel_type($owner_id)]} {
+ set rel_type [lang::util::localize $member_ids_rel_type($owner_id)]
+ } else {
+ set rel_type ""
+ }
+
+ if { [info exists msg_contacts($msg_id)]} {
+ set contacts $msg_contacts($msg_id)
+ }
+ set msg_content $msg_content_array($msg_id)
+ set sent_date_ansi $date_sent_array($msg_id)
+ set content [ad_html_to_text [template::util::richtext::get_property contents $msg_content]]
+ if { [empty_string_p $subject] } {
+ set subject "[_ messages.no_subject] "
+ }
+ append subject_mail $subject "-" [string_truncate -len 80 -ellipsis "..." " $content"]
+ set cur_time [clock format [clock seconds] -format "%Y %m %d"]
+ set sent_time_seconds [clock format [clock scan $sent_date_ansi] -format "%Y %m %d"]
+ #compare the sent date whith the current date and display the message according to the date.
+ if { [lindex $cur_time 0] > [lindex $sent_time_seconds 0]} {
+ set date [lc_time_fmt $sent_date_ansi "%D"]
+ } else {
+ if {[lindex $cur_time 1] >= [lindex $sent_time_seconds 1] && [lindex $cur_time 2] == [lindex $sent_time_seconds 2]} {
+ set date [_ messages.today]
+ } else {
+ set date [lc_time_fmt $sent_date_ansi "%d,%b,%Y %H:%M"]
+ }
+ }
+ if { [info exists new_p_array($msg_id)]} {
+ set new_p $new_p_array($msg_id)
+ } else {
+ set new_p 0
+ }
+ incr count_messages
+}
+
+set last_number [expr [expr $count_messages + $first_row] - 1]
Index: openacs-4/packages/messages/www/inbox.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/inbox.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/inbox.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,96 @@
+
+
+
+
+
+ select acs_users_all.last_name||' '||acs_users_all.first_names
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id = :party_id
+
+
+
+
+
+ select coalesce(parent_id,msg_id) as parent_id, msg_content, to_char(sent_date, 'YYYY-MM-DD HH24:MI:SS') as sent_date_ansi
+ from messages_messages
+ where msg_id in ($last_msg_ids)
+
+
+
+
+
+ select count(um.msg_id) as total
+ from (select distinct(mum.parent_id) as msg_id
+ from (select * from messages_user_messages where user_id = :user_id) as mum
+ where user_id = :user_id
+ and msg_id in (select msg_id
+ from messages_messages
+ where community_id = :community_id)
+ and folder_id = :folder_id) um
+
+
+
+
+
+ select max_messages
+ from messages_options
+ where user_id = :user_id
+
+
+
+
+
+ select um.parent_id, count(*) as count_attachment
+ from messages_attachments ma,
+ (select msg_id, parent_id
+ from messages_user_messages
+ where user_id = :user_id
+ and folder_id = :folder_id
+ and parent_id in ($msg_ids)
+ ) um
+ where ma.msg_id = um.msg_id
+ group by um.parent_id
+
+
+
+
+
+ select parent_id, new_p
+ from messages_user_messages
+ where parent_id in ($last_msg_ids)
+ and folder_id = :folder_id
+ and user_id = :user_id
+
+
+
+
+
+ select owner_id
+ from messages_messages
+ where msg_id = :msg_id
+ and community_id = :community_id
+
+
+
+
+
+ select $rel_type_case as rel_type
+ from acs_rels map
+ where map.object_id_one = :community_id
+ and map.rel_type in ('$rel_types')
+ and object_id_two = :owner_id
+
+
+
+
+
+ select first_names
+ from persons
+ where person_id = :contact_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/index.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/index.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1 @@
+redirect
\ No newline at end of file
Index: openacs-4/packages/messages/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/index.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/index.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,11 @@
+ad_page_contract {
+ Redirect to messages
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-17
+ @cvs-id $Id: index.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+
+}
+
+ad_returnredirect "messages"
\ No newline at end of file
Index: openacs-4/packages/messages/www/members-rol.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/members-rol.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/members-rol.adp 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+
+
Index: openacs-4/packages/messages/www/members-rol.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/members-rol.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/members-rol.tcl 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,59 @@
+ad_page_contract {
+ Inbox Page
+
+ @author pedro@viaro.net
+ @creation-date 2010-05-17
+ @cvs-id $Id: members-rol.tcl,v 1.1 2010/08/31 21:30:45 alvaror Exp $
+} {
+ {rel_type ""}
+ {data_search ""}
+}
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+
+
+if { [exists_and_not_null data_search] && ![string equal $data_search "none"]} {
+ set data_search_list [string trim [split $data_search " "]]
+ set count 0
+ foreach data_search $data_search_list {
+ set sql_keyword "%[string tolower $data_search]%"
+ if { $count == 0 } {
+ append where_clause_user "lower(first_names || ' ' || last_name) like '$sql_keyword'"
+ } else {
+ append where_clause_user " or lower(first_names || ' ' || last_name) like '$sql_keyword'"
+ }
+ incr count
+ }
+ set where_clause_user "and ($where_clause_user)"
+} else {
+ set where_clause_user ""
+ set search_clause ""
+}
+
+set elements [list msg_ids \
+ [list label { } \
+ display_template {} \
+ sub_class {narrow} \
+ html { align center }] \
+ ]
+
+lappend elements party_name \
+ [list html { align left style "font-size: smaller; width:95%"} \
+ label [_ messages.from] \
+ display_template { @members.party_name@} \
+ ]
+
+
+
+template::list::create \
+ -name members \
+ -multirow members \
+ -main_class "list-table" \
+ -html { width=100% } \
+ -orderby_name orderby \
+ -no_data "[_ messages.no_members_found]" \
+ -elements $elements
+
+set rowscount 0
+db_multirow -extend { } members get_members { *SQL* } { incr rowscount}
Index: openacs-4/packages/messages/www/members-rol.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/members-rol.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/members-rol.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,19 @@
+
+
+
+
+
+ select p.first_names||' '||p.last_name as party_name,
+ p.person_id
+ from persons p,
+ acs_rels map
+ where map.object_id_one = :community_id
+ and map.object_id_two = p.person_id
+ and map.rel_type = :rel_type
+ $where_clause_user
+ order by party_name
+
+
+
+
+
Index: openacs-4/packages/messages/www/message-option.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/message-option.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/message-option.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,42 @@
+
+@page_title;noquote@
+@context;noquote@
+
+
+
+
+
+
#messages.name_new_folder#
+
+
+
+
+
+
+
+ #messages.folders_created#
#messages.edit_folder#
+
+
+
+
+
+
+ @folder.folder_name@
+
+
+
+
+
+
+ #messages.delete#
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/message-option.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/message-option.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/message-option.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,87 @@
+ad_page_contract {
+ Message Options
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-13
+ @cvs-id $Id: message-option.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+ {return_url "messages"}
+}
+
+set page_title "[_ messages.configuration]"
+set context [list "[_ messages.configuration]"]
+set owner_id [ad_conn user_id]
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+set save_sent_p 1
+set signature_p 0
+set signature ""
+set max_messages "25"
+
+append folders_id_standar [messages::get_folder_id -folder_name "inbox"] ","\
+ [messages::get_folder_id -folder_name "sent"] ","\
+ [messages::get_folder_id -folder_name "save"] ","\
+ [messages::get_folder_id -folder_name "trash"]
+
+db_multirow -extend { folder_p } folder get_folders_data { *SQL* } { }
+
+if { ![db_0or1row select_options {} ] } {
+ db_dml create_options {}
+}
+
+set signature [ad_html_to_text $signature]
+
+if { [empty_string_p $signature] } {
+ set signature ""
+} else {
+ set signature [string trim $signature]
+}
+
+ad_form -name options_mail -cancel_url "messages" -form {
+ {max_messages:naturalnum {label "[_ messages.max_show_messages]:"}
+ {html {size 3}} {value $max_messages}
+ }
+ {save_sent_p:text(radio) {label "[_ messages.save_sent_message]:"}
+ {options {{[_ messages.yes] 1} {[_ messages.no] 0}}} {value $save_sent_p}
+ }
+ {signature_p:text(radio) {label "[_ messages.insert_signature]:"}
+ {options {{[_ messages.yes] 1} {No 0}}} {value $signature_p}
+ }
+ {signature_text:richtext(richtext),optional,nospell {label "[_ messages.signature]:"}
+ {options {editor xinha }}
+ {value "$signature"} {html {id "signature" cols 80 rows 3 onload "loadEditors('advancedMessagesEditor'); return false;"}}
+ }
+} -on_submit {
+ set signature [string trim [ad_convert_to_html $signature_text]]
+ db_dml update_options {}
+} -after_submit {
+ ad_returnredirect "$return_url"
+ ad_script_abort
+}
+
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yahoo/yahoo-min.js" -order "-3"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yahoo-dom-event/yahoo-dom-event.js" -order "-1"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/element/element-beta-min.js" -order "-2"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/event/event-min.js" -order "-4"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dom/dom-min.js" -order "-5"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/button/button-beta-min.js" -order "-7"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/utilities/utilities.js" -order "-8"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/connection/connection-min.js" -order "-9"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/button/button-min.js"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dragdrop/dragdrop-min.js"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/container/container-min.js"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yuiloader/yuiloader-min.js"
+template::head::add_javascript -src "/resources/messages/folder-new.js"
+template::head::add_css -href "/resources/ajaxhelper/yui/button/assets/skins/sam/button.css" -order "-3"
+template::head::add_css -href "/resources/ajaxhelper/yui/container/assets/skins/sam/container.css" -order "-4"
+template::head::add_css -href "/resources/ajaxhelper/yui/fonts/fonts-min.css"
+template::head::add_css -href "/resources/ajaxhelper/yui/button/assets/skins/sam/button.css"
+template::head::add_css -href "/resources/ajaxhelper/yui/assets/skins/sam/container.css"
+template::head::add_javascript -src "/resources/messages/messages.js" -order "3"
+template::head::add_javascript -src "/resources/messages/message-option.js" -order "4"
+
+
+set ::acs_blank_master(xinha) 1
+set ::acs_blank_master(xinha.plugins) "'OacsFs'"
+set ::acs_blank_master(xinha.options) ""
+set ::acs_blank_master__htmlareas ""
\ No newline at end of file
Index: openacs-4/packages/messages/www/message-option.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/message-option.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/message-option.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,37 @@
+
+
+
+
+
+ select folder_id, folder_name
+ from messages_folders
+ where user_id = :user_id
+ or user_id = 0
+ and folder_id not in ($folders_id_standar)
+ order by folder_id asc
+
+
+
+
+
+ select max_messages, save_sent_p, signature_p, signature
+ from messages_options
+ where user_id = :user_id
+
+
+
+
+
+ insert into messages_options values (:user_id,25,:save_sent_p,:signature_p,:signature)
+
+
+
+
+
+ update messages_options
+ set max_messages = :max_messages,save_sent_p = :save_sent_p, signature_p = :signature_p, signature = :signature
+ where user_id = :user_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/messages-actions.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages-actions.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages-actions.adp 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/messages-folders.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages-folders.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages-folders.adp 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,153 @@
+
+
+
+
+
+
+
+
+
+
Type the name of a member
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/messages/www/messages-folders.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages-folders.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages-folders.tcl 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,26 @@
+ad_page_contract {
+ General page, list inbox, sent, draft, trash.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-12
+ @cvs-id $Id: messages-folders.tcl,v 1.1 2010/08/31 21:30:44 alvaror Exp $
+} {
+ {community_id ""}
+ {page_number ""}
+}
+
+set page_title "[_ messages.folders]"
+set context [list $page_title]
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+
+set contacts_list [util_memoize [list messages::get_community_users_fb -community_id $community_id] 86400]
+
+db_multirow -extend { color total_new_msg} folders get_folders_user { *SQL* } {
+ if { $folder_id == 0 } {
+ set color "#C0C0C0"
+ } else {
+ set color "#FFFFFF"
+ }
+}
+
Index: openacs-4/packages/messages/www/messages-folders.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages-folders.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages-folders.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+ select folder_id, folder_name
+ from messages_folders
+ where (user_id = :user_id
+ or user_id = 0)
+ order by folder_id asc
+
+
+
+
Index: openacs-4/packages/messages/www/messages.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages.adp 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,43 @@
+
+@page_title;noquote@
+@context;noquote@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/messages.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages.tcl 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,55 @@
+ad_page_contract {
+ General page, list inbox, sent, draft, trash.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-12
+ @cvs-id $Id: messages.tcl,v 1.1 2010/08/31 21:30:45 alvaror Exp $
+} {
+ {community_id ""}
+ {page_number ""}
+}
+
+set page_title "[_ messages.folders]"
+set context [list $page_title]
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+
+set ::acs_blank_master(xinha) 1
+set ::acs_blank_master(xinha.plugins) "'OacsFs'"
+set ::acs_blank_master(xinha.options) ""
+set ::acs_blank_master__htmlareas ""
+
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yahoo-dom-event/yahoo-dom-event.js" -order "-1"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yahoo/yahoo-min.js" -order "-14"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/element/element-beta-min.js" -order "-13"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/event/event-min.js" -order "-15"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dom/dom-min.js" -order "-16"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/button/button-beta-min.js" -order "-17"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/utilities/utilities.js" -order "-18"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/history/history-beta-min.js" -order "-19"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/button/button-min.js" -order "-2"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dragdrop/dragdrop-min.js" -order "2"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/container/container-min.js" -order "3"
+template::head::add_javascript -src "/resources/messages/prototype.js" -order "4"
+template::head::add_javascript -src "/resources/messages/effects.js" -order "5"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dragdrop/dragdrop.js" -order "6"
+template::head::add_javascript -src "/resources/messages/controls.js" -order "7"
+template::head::add_javascript -src "/resources/messages/builder.js" -order "8"
+template::head::add_javascript -src "/resources/messages/application.js" -order "9"
+template::head::add_javascript -src "/resources/messages/messages.js" -order "10"
+template::head::add_javascript -src "/resources/messages/dispatcher.js"
+template::head::add_javascript -src "/resources/messages/dispatcher-min.js"
+template::head::add_javascript -src "/resources/messages/menu.js" -order "11"
+template::head::add_javascript -src "/resources/messages/delete-dialog.js" -order "12"
+template::head::add_javascript -src "/resources/messages/message-attachment.js" -order "13"
+template::head::add_css -href "/resources/messages/menu.css" -order "-2"
+template::head::add_css -href "/resources/ajaxhelper/yui/fonts/fonts-min.css" -order "-3"
+template::head::add_css -href "/resources/ajaxhelper/yui/button/assets/skins/sam/button.css" -order "-4"
+template::head::add_css -href "/resources/ajaxhelper/yui/container/assets/skins/sam/container.css" -order "-5"
+template::head::add_css -href "/resources/messages/messages.css" -order "-6"
+template::head::add_css -href "/resources/messages/send.css" -order "1"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/connection/connection-min.js"
+
+
+
+
Index: openacs-4/packages/messages/www/messages.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/messages.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/messages.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+ select folder_id, folder_name
+ from messages_folders
+ where (user_id = :user_id
+ or user_id = 0)
+ order by folder_id asc
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/more-actions.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/more-actions.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/more-actions.adp 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1 @@
+@option_select@
\ No newline at end of file
Index: openacs-4/packages/messages/www/more-actions.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/more-actions.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/more-actions.tcl 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,16 @@
+ad_page_contract {
+ Update numbers of new messages in the menu
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-24
+ @cvs-id $Id: more-actions.tcl,v 1.1 2010/08/31 21:30:45 alvaror Exp $
+} {
+ msg_ids
+ option_select
+}
+
+set community_id [dotlrn_community::get_community_id]
+set user_id [ad_conn user_id]
+db_transaction {
+ db_dml update_status_msg {}
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/more-actions.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/more-actions.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/more-actions.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,12 @@
+
+
+
+
+
+ update messages_user_messages
+ set new_p = :option_select
+ where parent_id in ($msg_ids) and user_id = :user_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/move-to.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/move-to.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/move-to.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1 @@
+@folder_id;noquote@
\ No newline at end of file
Index: openacs-4/packages/messages/www/move-to.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/move-to.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/move-to.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,17 @@
+ad_page_contract {
+ General page, list inbox, sent, draft, trash.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-13
+ @cvs-id $Id: move-to.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+ {msg_ids ""}
+ {folder_id ""}
+}
+
+set user_id [ad_conn user_id]
+set folder_id_sent [messages::get_folder_id -folder_name "sent"]
+set community_id [dotlrn_community::get_community_id]
+db_transaction {
+ db_dml update_folder {}
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/move-to.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/move-to.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/move-to.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,11 @@
+
+
+
+
+ update messages_user_messages set folder_id = :folder_id
+ where parent_id in ($msg_ids)
+ and user_id = :user_id
+ and folder_id != :folder_id_sent
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/new-folder.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/new-folder.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/new-folder.adp 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/print-message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/print-message.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/print-message.adp 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,31 @@
+
+
+@page_title;noquote@
+@context;noquote@
+
+
+ #messages.close_window#
+ @owner_name@
+
+
+ @subject@
+
+ #messages.messages#:@print:rowcount@
+
+
+
+
+ @print.contact_names@
+
+
+ @print.ansi_time@
+
+
+ @print.content;noquote@
+
+
+
+
+
Index: openacs-4/packages/messages/www/print-message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/print-message.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/print-message.tcl 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,40 @@
+ad_page_contract {
+ Print the messages.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-13
+ @cvs-id $Id: print-message.tcl,v 1.1 2010/08/31 21:30:42 alvaror Exp $
+} {
+ {msg_id ""}
+}
+
+set page_title "[_ messages.print]"
+set context [list $page_title]
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+set contact_names [db_list_of_lists get_contact_names {}]
+
+foreach contact $contact_names {
+ if { [lsearch -exact $contact $user_id] } {
+ set owner_name "[lindex $contact 0] <[lindex $contact 2]>"
+ break
+ }
+}
+
+db_0or1row data_msg { *SQL* }
+
+set data_msg [db_list_of_lists get_data_msg {}]
+set total_msg [llength $data_msg]
+
+db_multirow -extend { contact_names ansi_time content} print get_data_msg { *SQL* } {
+ set contact_list [db_list_of_lists get_contacts {}]
+ set contact_names [list]
+ foreach party_id $contact_list {
+ set contact_name [acs_user::get_element -user_id $party_id -element first_names]
+ lappend contact_names $contact_name
+ }
+ set contact_names [join $contact_names ","]
+ set day_recive [lc_time_fmt $sent_date "%d %b, %Y" ]
+ set ansi_time "$day_recive - $time"
+ set content [template::util::richtext::get_property content $msg_content]
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/print-message.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/print-message.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/print-message.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,56 @@
+
+
+
+
+
+ select acs_users_all.last_name||' '||acs_users_all.first_names as party_name,
+ acs_users_all.party_id, acs_users_all.email
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id = :user_id
+
+
+
+
+
+ select subject
+ from messages_messages
+ where msg_id = :msg_id
+
+
+
+
+
+ select msg_content, owner_id, community_id,parent_id,
+ sent_date, to_char(sent_date, 'HH24:MI:SS') as time,msg_id
+ from messages_messages
+ where msg_id in (select msg_id
+ from messages_user_messages
+ where user_id = :user_id
+ and parent_id = :msg_id)
+ order by msg_id asc
+
+
+
+
+
+ select party_id
+ from messages_recipients
+ where msg_id = :msg_id
+
+
+
+
+
+ select acs_users_all.last_name||' '||acs_users_all.first_names, acs_users_all.email
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id = :party_id
+
+
+
+
Index: openacs-4/packages/messages/www/read-message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read-message.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read-message.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,36 @@
+false
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/read-message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read-message.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read-message.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,62 @@
+ad_page_contract {
+ Read the messages.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-13
+ @cvs-id $Id: read-message.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+ {msg_id ""}
+ {folder_id ""}
+ {page_number ""}
+ {total_messages ""}
+}
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+set parents_ids [db_list_of_lists get_parents_ids {}]
+set get_max_messages [db_string get_max_messages {} -default 25]
+set permition_read [db_string exist_msg {} -default 0]
+
+if { $permition_read == 0 } {
+ set permition_read_p "f"
+} else {
+ set permition_read_p "t"
+}
+
+###########################################
+#get message ids around the message view
+#and set range messages, before or after message display acording to message view.
+set msg_before [expr [lsearch $parents_ids $msg_id] - 2]
+set msg_after [expr [lsearch $parents_ids $msg_id] + 2]
+set parents_ids [lrange $parents_ids $msg_before $msg_after]
+set newer_msg_id [lindex $parents_ids [expr [lsearch $parents_ids $msg_id] - 1]]
+############################################
+if {[empty_string_p $newer_msg_id]} {
+ set newer_msg_id "-1"
+}
+set newest_msg_id [lindex $parents_ids [expr [lsearch $parents_ids $msg_id] - 2]]
+if {[empty_string_p $newest_msg_id]} {
+ set newest_msg_id "-1"
+}
+set older_msg_id [lindex $parents_ids [expr [lsearch $parents_ids $msg_id] + 1]]
+if {[empty_string_p $older_msg_id]} {
+ set older_msg_id "-1"
+}
+set oldest_msg_id [lindex $parents_ids [expr [lsearch $parents_ids $msg_id] + 2]]
+if {[empty_string_p $oldest_msg_id]} {
+ set oldest_msg_id "-1"
+}
+
+set number_total_pages [expr [expr ceil([expr [expr $total_messages + 0.0] / [expr $get_max_messages + 0.0]])] - 1]
+
+if { !$number_total_pages } {
+ set new_page_number 1
+} else {
+ set new_page_number [expr [format %0.0f [expr ceil([lsearch $parents_ids $msg_id]/ $get_max_messages)]] + 1]
+}
+
+db_0or1row data_msg { *SQL* }
+
+if { [empty_string_p $subject] } {
+ set subject "[_ messages.no_subject] "
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/read-message.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read-message.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read-message.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,81 @@
+
+
+
+
+
+ select subject, owner_id
+ from messages_messages
+ where msg_id = :msg_id
+ and community_id = :community_id
+
+
+
+
+
+ select messages.msg_id
+ from (select max(m.msg_id) as last_msg_id, m.parent_id as msg_id, count(m.msg_id) as number_conversation
+ from (select msg_id, coalesce(parent_id,msg_id) as parent_id
+ from messages_messages
+ where community_id = :community_id
+ and msg_id in (select parent_id
+ from messages_user_messages
+ where user_id = :user_id
+ and folder_id = :folder_id)) m
+ group by m.parent_id
+ order by last_msg_id desc) messages
+
+
+
+
+
+ select max_messages
+ from messages_options
+ where user_id = :user_id
+
+
+
+
+
+ select attachment_id
+ from messages_attachments
+ where msg_id in (select msg_id from messages_messages where community_id = :community_id and parent_id = :msg_id or msg_id = :msg_id)
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type,
+ crr.title
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
+
+ select count(*)
+ from messages_user_messages
+ where user_id = :user_id
+ and parent_id = :msg_id
+
+
+
+
+
+ select $rel_type_case as rel_type
+ from acs_rels
+ where object_id_one = :community_id
+ and object_id_two = :owner_id
+
+
+
+
+
+
Index: openacs-4/packages/messages/www/read-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read-oracle.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,41 @@
+
+
+
+ oracle8.1.6
+
+
+
+ select msg_content, owner_id, community_id,parent_id, subject,
+ sent_date, to_char(sent_date, 'HH24:MI:SS') as time, msg_id
+ from messages_messages
+ where msg_id in ($msg_ids)
+ order by msg_id asc
+
+
+
+
+
+ select msg_id,wm_concat(party_id) as contacts
+ from messages_recipients
+ where msg_id in ($msg_ids)
+ group by msg_id
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type,
+ crr.filename
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
Index: openacs-4/packages/messages/www/read-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read-postgresql.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,48 @@
+
+
+ postgresql7.3
+
+
+
+ select msg_id, concat(distinct(party_id)||',') as contacts
+ from messages_recipients
+ where msg_id in ($msg_ids)
+ group by msg_id
+
+
+
+
+
+ select msg_id, concat(distinct(rel_id)||',') as contacts
+ from messages_recipients_roles
+ where msg_id in ($msg_ids)
+ group by msg_id
+
+
+
+
+
+ select msg_content, owner_id, community_id,parent_id, subject,
+ to_char(sent_date, 'YYYY-MM-DD HH24:MI:SS') as sent_date, to_char(sent_date, 'HH24:MI:SS') as time, msg_id
+ from messages_messages
+ where msg_id in ($msg_ids)
+ order by msg_id asc
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
Index: openacs-4/packages/messages/www/read.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read.adp 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+ #messages.msg_has_been_sent#
+
+
+
+
+
+
+
+ #messages.from#:
+ @messages.name_user@
+
+ #messages.message_sent_by#: @messages.rel_type_user@
+
+
+ #messages.to# @messages.first_name_contacts@
+
+
+
+
+ #messages.to#: @messages.contact_names;noquote@
+ #messages.date#: @messages.ansi_time@
+ #messages.subject#: @messages.subject@
+
+
+
+
+ @messages.msg_content;noquote@
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/messages/www/read.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read.tcl 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,131 @@
+ad_page_contract {
+ Read the messages.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-13
+ @cvs-id $Id: read.tcl,v 1.1 2010/08/31 21:30:45 alvaror Exp $
+} {
+ {msg_id ""}
+}
+
+set general_parent_id $msg_id
+set community_id [dotlrn_community::get_community_id]
+set user_id [ad_conn user_id]
+set color "#C0C0C0"
+set msg_id_list [list]
+db_dml update_status {}
+
+db_foreach get_msg_ids {} {
+ lappend msg_id_list $msg_id
+}
+
+if { [llength $msg_id_list] > 0 } {
+ set msg_ids [join $msg_id_list ","]
+} else {
+ set msg_ids ""
+}
+
+db_foreach get_contacts_ids {} {
+ set contacts_ids_array($msg_id) $contacts
+}
+
+db_foreach get_contacts_ids_roles {} {
+ set contacts_ids_array_roles($msg_id) $contacts
+}
+
+##Roles: se estable los roles que existen y se obtienen lo usuarios y sus roles
+set roles [dotlrn_community::get_roles -community_id $community_id]
+set rel_types [list]
+foreach role $roles {
+ lappend rel_types [lindex $role 0]
+}
+set rel_types [join $rel_types "','"]
+set rel_type_case "case "
+foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ append rel_type_case "when rel_type = '$rel_type' then '$pretty_name' "
+}
+append rel_type_case " end"
+###
+
+db_multirow -extend { rel_type_user to first_name_contacts name_user total_recipients contact_names download_file ansi_time } messages get_messages_info { *SQL* } {
+ ##Roles: se estable los roles que existen y se obtienen lo usuarios y sus roles
+ set rel_type_user [lang::util::localize [db_string get_members_ids_rel_type {}]]
+
+ ###
+ set name_user [acs_user::get_element -user_id $owner_id -element name]
+ set download_file ""
+ set attachment [db_list_of_lists get_attachment_id {}]
+
+ if { [llength $attachment] != 0} {
+ foreach attachment_info $attachment {
+ set attachment_id [lindex $attachment_info 0]
+ set attachment_item_id [lindex $attachment_info 1]
+ db_1row get_sol_info { *SQL* }
+ set position [string first . "$content" 1]
+ if { $position == "-1" } {
+ set position [string length $content]
+ }
+ append download_file " \
+ [messages::string_truncate_middle -len 15 -string $title]
"
+ }
+
+ } else {
+ set download_file ""
+ }
+
+ set contact_names ""
+ set first_name_contacts ""
+ if { [array exists contacts_ids_array] != -1 } {
+ if { [lsearch [array name contacts_ids_array] $msg_id] == -1 } {
+ set contact_list ""
+ } else {
+ set contact_list [split $contacts_ids_array($msg_id) ","]
+ }
+ } else {
+ set contact_list ""
+ }
+
+
+ set total_recipients [llength $contact_list]
+ set name_to_p 0
+ foreach party_id $contact_list {
+ if { ![empty_string_p $party_id] } {
+ set name [acs_user::get_element -user_id $party_id -element name]
+ if {$party_id == $owner_id} {
+ append contact_names $name ",
"
+ } else {
+ set name_to_p 1
+ append first_name_contacts [string range $name 0 [expr [string first " " $name 0] - 1]] ", "
+ append contact_names $name ",
"
+ }
+ }
+ }
+ set rel_types [db_list get_rel_types {}]
+ set rel_types_checked [join $rel_types ","]
+ foreach rel_type $rel_types {
+ set pretty_name [dotlrn_community::get_role_pretty_plural -rel_type $rel_type]
+ append first_name_contacts $pretty_name ", "
+ append contact_names $pretty_name ",
"
+ }
+ if { $name_to_p } {
+ set to [string tolower [_ messages.to] 0 1]
+ } else {
+ set to ""
+ }
+ set first_name_contacts [string range $first_name_contacts 0 [expr [string length $first_name_contacts] - 3]]
+ set contact_names [string range $contact_names 0 [expr [string length $contact_names] - 60]]
+ set cur_time [clock format [clock seconds] -format "%Y %m %d"]
+ set sent_time_seconds [clock format [clock scan $sent_date] -format "%Y %m %d"]]
+ set day_recive [lc_time_fmt $sent_date "%d %b, %Y" ]
+ set ansi_time "$day_recive - $time"
+ set msg_content [template::util::richtext::get_property contents $msg_content]
+ if { [lindex $cur_time 0] > [lindex $sent_time_seconds 0]} {
+ set date [lc_time_fmt $sent_date "%D"]
+ } else {
+ if { ([lindex $cur_time 1] >= [lindex $sent_time_seconds 1]) && ([lindex $cur_time 2] == [lindex $sent_time_seconds 2] ) } {
+ set date [_ messages.today]
+ } else {
+ set date [lc_time_fmt $sent_date "%d %b" ]
+ }
+ }
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/read.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/read.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/read.xql 31 Aug 2010 21:30:45 -0000 1.1
@@ -0,0 +1,95 @@
+
+
+
+
+
+ select distinct(msg_id)
+ from messages_user_messages
+ where user_id = :user_id
+ and parent_id = :msg_id
+
+
+
+
+
+ select count(party_id)
+ from messages_recipients
+ where msg_id = :msg_id
+
+
+
+
+
+ update messages_user_messages
+ set new_p = 'f'
+ where parent_id = :msg_id
+ and user_id = :user_id
+ and new_p != 'f'
+
+
+
+
+
+ select acs_users_all.last_name||' '||acs_users_all.first_names
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id = :party_id
+
+
+
+
+
+ select attachment_id, attachment_item_id
+ from messages_attachments
+ where msg_id = :msg_id
+
+
+
+
+
+ select rel_id
+ from messages_recipients_roles
+ where msg_id = :msg_id
+
+
+
+
+
+ select msg_content, owner_id, community_id,parent_id, subject,
+ to_char(sent_date, 'YYYY-MM-DD HH24:MI:SS') as sent_date, to_char(sent_date, 'HH24:MI:SS') as time, msg_id
+ from messages_messages
+ where msg_id in ($msg_ids)
+ order by msg_id asc
+
+
+
+
+
+ select msg_id,wm_concat(party_id) as contacts
+ from messages_recipients
+ where msg_id in ($msg_ids)
+ group by msg_id
+
+
+
+
+
+ select msg_id, wm_concat(distinct(rel_id)) as contacts
+ from messages_recipients_roles
+ where msg_id in ($msg_ids)
+ group by msg_id
+
+
+
+
+
+ select $rel_type_case as rel_type
+ from acs_rels
+ where object_id_one = :community_id
+ and object_id_two = :owner_id
+
+
+
+
Index: openacs-4/packages/messages/www/search-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/search-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/search-oracle.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,53 @@
+
+
+
+ oracle8.1.6
+
+
+
+ select msg_id, last_msg_id
+ from (select paginate.*, rownum rowsub
+ from ( select max(msg_id) as last_msg_id, parent_id as msg_id, folder_id, count(msg_id) as number_conversation
+ from messages_user_messages
+ where user_id = :user_id
+ and msg_id in (select msg_id
+ from messages_messages
+ where community_id = :community_id
+ and (owner_id in (select person_id
+ from persons
+ $where_clause_user)
+ or msg_id in (select msg_id
+ from messages_recipients
+ where party_id in (select person_id
+ from persons
+ $where_clause_user))
+ $search_clause))
+ group by parent_id, folder_id
+ order by last_msg_id desc
+ ) paginate
+ where rownum <= :last_row)
+ where rowsub >= :first_row
+
+
+
+
+
+
+ select mm.last_msg_id, mm.msg_id, mm.number_conversation, mm.subject, wm_concat(distinct(p.first_names)) as contacts, mm.folder_id
+ from persons p,
+ (select max(um.msg_id) as last_msg_id, um.parent_id as msg_id, count(um.msg_id) as number_conversation, m.subject, m.owner_id, um.folder_id
+ from (select parent_id,msg_id, folder_id
+ from messages_user_messages
+ where user_id = :user_id) um,
+ (select msg_id,subject,owner_id
+ from messages_messages
+ where community_id = :community_id
+ and msg_id in ($msg_ids)) m
+ where um.parent_id = m.msg_id
+ group by um.parent_id, m.subject, m.owner_id, um.folder_id) mm
+ where p.person_id = mm.owner_id
+ group by mm.msg_id, mm.subject, mm.last_msg_id, mm.number_conversation, mm.folder_id
+ order by mm.last_msg_id desc
+
+
+
Index: openacs-4/packages/messages/www/search-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/search-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/search-postgresql.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,54 @@
+
+
+ postgresql7.3
+
+
+
+ select msg_id, last_msg_id
+ from (select paginate.*
+ from ( select max(msg_id) as last_msg_id, parent_id as msg_id, folder_id, count(msg_id) as number_conversation
+ from messages_user_messages
+ where user_id = :user_id
+ and msg_id in (select msg_id
+ from messages_messages
+ where community_id = :community_id
+ and (owner_id in (select person_id
+ from persons
+ $where_clause_user)
+ or msg_id in (select msg_id
+ from messages_recipients
+ where party_id in (select person_id
+ from persons
+ $where_clause_user))
+ $search_clause))
+ group by parent_id, folder_id
+ order by last_msg_id desc
+ ) paginate
+ LIMIT :last_row) messages
+ OFFSET :first_row - 1
+
+
+
+
+
+ select mm.last_msg_id, mm.msg_id, mm.number_conversation, mm.subject, concat(distinct(p.first_names)||',') as contacts, mm.folder_id
+ from persons p,
+ (select max(um.msg_id) as last_msg_id, um.parent_id as msg_id, count(um.msg_id) as number_conversation, m.subject, m.owner_id, um.folder_id
+ from (select parent_id,msg_id, folder_id
+ from messages_user_messages
+ where user_id = :user_id) um,
+ (select msg_id,subject,owner_id
+ from messages_messages
+ where community_id = :community_id
+ and msg_id in ($msg_ids)) m
+ where um.parent_id = m.msg_id
+ group by um.parent_id, m.subject, m.owner_id, um.folder_id) mm
+ where p.person_id = mm.owner_id
+ group by mm.msg_id, mm.subject, mm.last_msg_id, mm.number_conversation, mm.folder_id
+ order by mm.last_msg_id desc
+
+
+
+
+
+
Index: openacs-4/packages/messages/www/search.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/search.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/search.adp 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/messages/www/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/search.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/search.tcl 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,176 @@
+ad_page_contract {
+ Inbox Page
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-11
+ @cvs-id $Id: search.tcl,v 1.1 2010/08/31 21:30:44 alvaror Exp $
+} {
+ {page_number ""}
+ {data_search ""}
+}
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+
+if {[empty_string_p $page_number]} {
+ set page_number 1
+}
+
+if { [exists_and_not_null data_search] } {
+ set data_search_list [string trim [split $data_search " "]]
+ set count 0
+ foreach data_search $data_search_list {
+ set sql_keyword "%[string tolower $data_search]%"
+ if { $count == 0 } {
+ append where_clause_user "lower(first_names || ' ' || last_name) like '$sql_keyword'"
+ } else {
+ append where_clause_user " or lower(first_names || ' ' || last_name) like '$sql_keyword'"
+ }
+ incr count
+ append search_clause "or lower(msg_content) like '%'||lower('$data_search')||'%'"
+ append search_clause " or lower(subject) like '%'||lower('$data_search')||'%'"
+ }
+ set where_clause_user "where $where_clause_user"
+} else {
+ set where_clause_user ""
+ set search_clause ""
+}
+
+#####################################################################
+#get the total messages and calculate how many pages have in folder show
+#First and last row are calculate based on the total messages show per page
+set total_messages [db_string get_total_messages {}]
+set show_messages [db_string get_max_show_msg {} -default 25]
+#Round to the next integer because the las page include some messages.
+set total_pages [expr ceil([expr [expr $total_messages + 0.0] / [expr $show_messages + 0.0]])]
+set oldest_page [expr $total_pages - 1]
+set count_messages 0
+if { $page_number != 1} {
+ set first_row [expr [expr [expr $page_number - 1] * $show_messages] + 1]
+ set last_row [expr [expr $first_row + $show_messages] - 1]
+} else {
+ set first_row [expr [expr $page_number - 1] * $show_messages]
+ set last_row [expr $first_row + $show_messages]
+ set first_row [expr $first_row + 1]
+}
+######################################################################
+
+set elements [list msg_ids \
+ [list label { } \
+ display_template {} \
+ sub_class {narrow} \
+ html { align center }] \
+ ]
+
+lappend elements contacts \
+ [list html { align left style "font-size: smaller; width:20%"} \
+ label [_ messages.from] \
+ display_template { \
+ @messages.contacts@ \
+ (@messages.number_conversation@) \
+ @messages.contacts@ (@messages.number_conversation@)} \
+ ] \
+ folder_id \
+ [list html { align center style "font-size: smaller; width:5%"} \
+ label "" \
+ display_template { }] \
+ attachmet_mail \
+ [list html { align center style "font-size: smaller; width:5%"} \
+ label "" \
+ display_template { \
+ \
+ } \
+ ] \
+ subject_mail \
+ [list html { align left style "font-size: smaller; width:65%"} \
+ label [_ messages.subject] \
+ display_template { \
+ @messages.subject_mail@ \
+ @messages.subject_mail@} \
+ ] \
+ date \
+ [list html { align left style "font-size: smaller;width:10%"} \
+ label [_ messages.date] \
+ display_template { \
+ @messages.date@ \
+ @messages.date@} \
+ ]
+
+
+template::list::create \
+ -name messages \
+ -multirow messages \
+ -main_class "list-table" \
+ -html { width=100% } \
+ -orderby_name orderby \
+ -no_data "[_ messages.no_messages_found]" \
+ -elements $elements
+
+set msg_id_list [list]
+set last_msg_ids_list [list]
+db_foreach get_msg_ids {} {
+ set last_msg_ids_array($msg_id) $last_msg_id
+ lappend last_msg_ids_list $last_msg_id
+ lappend msg_id_list $msg_id
+}
+
+set msg_ids [join $msg_id_list ","]
+set last_msg_ids [join $last_msg_ids_list ","]
+
+if { ![exists_and_not_null $msg_ids] } {
+ set folder_id 0
+}
+
+if { [empty_string_p $msg_ids] } {
+ set msg_ids 0
+}
+
+if { [empty_string_p $last_msg_ids] } {
+ set last_msg_ids 0
+}
+
+db_foreach get_attachment_p { } {
+ set get_attachment_array($parent_id) $count_attachment
+}
+
+db_foreach get_new_p {} {
+ set new_p_array($parent_id) $new_p
+}
+
+db_foreach get_msg_info {} {
+ set msg_content_array($parent_id) $msg_content
+ set date_sent_array($parent_id) $sent_date_ansi
+}
+
+db_multirow -extend { subject_mail date attachment_p new_p folder_name} messages get_messages { *SQL* } {
+ set folder_name [db_string get_folder_name {}]
+ if { [info exists get_attachment_array($msg_id)]} {
+ set attachment_p $get_attachment_array($msg_id)
+ } else {
+ set attachment_p 0
+ }
+ set msg_content $msg_content_array($msg_id)
+ set sent_date_ansi $date_sent_array($msg_id)
+ set content [ad_html_to_text [template::util::richtext::get_property contents $msg_content]]
+ append subject_mail $subject "-" [string_truncate -len 80 -ellipsis "..." " $content"]
+ set cur_time [clock format [clock seconds] -format "%Y %m %d"]
+ set sent_time_seconds [clock format [clock scan $sent_date_ansi] -format "%Y %m %d"]
+ #compare the sent date whith the current date and display the message according to the date.
+ if { [lindex $cur_time 0] > [lindex $sent_time_seconds 0]} {
+ set date [lc_time_fmt $sent_date_ansi "%D"]
+ } else {
+ if {[lindex $cur_time 1] >= [lindex $sent_time_seconds 1] && [lindex $cur_time 2] == [lindex $sent_time_seconds 2]} {
+ set date [_ messages.today]
+ } else {
+ set date [lc_time_fmt $sent_date_ansi "%d,%b,%Y %H:%M"]
+ }
+ }
+ if { [info exists new_p_array($msg_id)]} {
+ set new_p $new_p_array($msg_id)
+ } else {
+ set new_p 0
+ }
+ incr count_messages
+}
+
+set last_number [expr [expr $count_messages + $first_row] - 1]
\ No newline at end of file
Index: openacs-4/packages/messages/www/search.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/search.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/search.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,93 @@
+
+
+
+
+
+ select acs_users_all.last_name||' '||acs_users_all.first_names
+ from acs_users_all,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = acs_users_all.user_id
+ and acs_users_all.user_id = :party_id
+
+
+
+
+
+ select coalesce(parent_id,msg_id) as parent_id, msg_content, to_char(sent_date, 'YYYY-MM-DD HH24:MI:SS') as sent_date_ansi
+ from messages_messages
+ where msg_id in ($last_msg_ids)
+
+
+
+
+
+ select count(*)
+ from (select parent_id, folder_id
+ from messages_user_messages
+ where user_id = :user_id
+ and msg_id in (select msg_id
+ from messages_messages
+ where community_id = :community_id
+ and (owner_id in (select person_id
+ from persons
+ $where_clause_user)
+ or msg_id in (select msg_id
+ from messages_recipients
+ where party_id in (select person_id
+ from persons
+ $where_clause_user))
+ $search_clause))
+ group by parent_id,folder_id) as messages
+
+
+
+
+
+ select max_messages
+ from messages_options
+ where user_id = :user_id
+
+
+
+
+
+ select um.parent_id, count(*) as count_attachment
+ from messages_attachments ma,
+ (select msg_id, parent_id
+ from messages_user_messages
+ where user_id = :user_id
+ and parent_id in ($msg_ids)
+ ) um
+ where ma.msg_id = um.msg_id
+ group by um.parent_id
+
+
+
+
+
+ select parent_id, new_p
+ from messages_user_messages
+ where msg_id in ($last_msg_ids)
+ and user_id = :user_id
+
+
+
+
+
+ select owner_id
+ from messages_messages
+ where msg_id = :msg_id
+ and community_id = :community_id
+
+
+
+
+
+ select folder_name
+ from messages_folders
+ where folder_id = :folder_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/send-mail-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-mail-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-mail-oracle.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,49 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ update cr_revisions
+ set filename = :file_name,
+ mime_type = :mime_type,
+ content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ update cr_revisions
+ set content = empty_blob(),
+ filename = :filename
+ where revision_id = :revision_id
+ returning content into :1
+
+
+
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type
+ crr.filename
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
+
Index: openacs-4/packages/messages/www/send-mail-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-mail-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-mail-postgresql.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,45 @@
+
+
+
+ postgresql7.3
+
+
+
+
+ update cr_revisions
+ set content = :file_name,
+ mime_type = :mime_type,
+ content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ update cr_revisions
+ set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]]
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/send-mail.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-mail.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-mail.adp 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1 @@
+@msg_id;noquote@
\ No newline at end of file
Index: openacs-4/packages/messages/www/send-mail.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-mail.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-mail.tcl 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,114 @@
+ad_page_contract {
+ Page send mail
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-11
+ @cvs-id $Id: send-mail.tcl,v 1.1 2010/08/31 21:30:44 alvaror Exp $
+} {
+ {msg_id ""}
+ {subject ""}
+ {parent_id ""}
+ {contacts_ids ""}
+ {total_attachment 0}
+ {reply ""}
+ {content_msg ""}
+ {message:html ""}
+ {attachment_item_id ""}
+ {general_parent_id ""}
+ {msg_id_old ""}
+ {rel_types:multiple "" }
+ {attachment_ids ""}
+}
+
+set community_id [dotlrn_community::get_community_id]
+set owner_id [ad_conn user_id]
+set community_name [dotlrn_community::get_community_name $community_id]
+set contact_info ""
+set rel_types_html ""
+set fs_package_id [dotlrn_community::get_package_id_from_package_key -package_key file-storage -community_id $community_id]
+set fs_folder_id [fs::get_root_folder -package_id $fs_package_id]
+set attachment_item_id ""
+set package_id [ad_conn package_id]
+set admin_p [permission::permission_p -party_id $owner_id -object_id $package_id -privilege admin]
+
+if { $admin_p } {
+ set roles [dotlrn_community::get_roles -community_id $community_id]
+ foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ append rel_types_html " [lang::util::localize $pretty_plural] "
+ }
+ append rel_types_html " [_ messages.send_to_all]"
+}
+
+ad_form -html { enctype multipart/form-data } -name compose_message -form { }
+
+ad_form -extend -name compose_message -form {
+
+} -on_submit {
+ set count_attachment [expr $total_attachment + 1]
+ if { ![exists_and_not_null parent_id] } {
+ set parent_id ""
+ }
+ set base_url [dotlrn_community::get_community_url $community_id]
+ set message_url [export_vars -base "${base_url}messages/messages"]
+ set msg_id [messages::reply_mail -parent_id $parent_id -count_attachment $count_attachment \
+ -contacts_ids $contacts_ids -community_id $community_id \
+ -owner_id $owner_id -subject $subject -message $message -general_parent_id $general_parent_id \
+ -message_url $message_url -msg_id_old $msg_id_old -attachment_ids $attachment_ids -rel_types $rel_types]
+
+ for {set x 1} {$x < $count_attachment} {incr x} {
+ set name_attachment "upload_file_${x}"
+ ad_form -extend -name compose_message -form {
+ {upload_file_$x:file,optional
+ {label ""}
+ }
+ }
+ set upload_file [set $name_attachment]
+ if { ![empty_string_p $upload_file] } {
+ db_transaction {
+ set attachment_item_id ""
+ if { ![regexp {[^//\\]+$} $upload_file filename] } {
+ # no match
+ set filename $upload_file
+ }
+ set community_id [dotlrn_community::get_community_id]
+ set package_id [dotlrn_community::get_package_id_from_package_key -package_key messages -community_id $community_id]
+ set title [template::util::file::get_property filename $upload_file]
+ set item_name "[clock seconds]-${title}"
+ set mime_type [cr_filename_to_mime_type -create $title]
+ set folder_id [content::item::get_id -item_path "messages_attachments_${package_id}" -resolve_index f]
+ set creation_user [ad_conn user_id]
+ set creation_ip [ad_conn peeraddr]
+ # set storage_type to its default value according to a db constraint
+ set storage_type file
+ set attachment_item_id [content::item::new \
+ -parent_id $folder_id \
+ -name $item_name \
+ -context_id $package_id \
+ -content_type messages_attachments \
+ -mime_type $mime_type \
+ -storage_type $storage_type \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip]
+
+ set revision_id [content::revision::new -item_id $attachment_item_id \
+ -mime_type $mime_type \
+ -title $title \
+ -content_type messages_attachments \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -attributes [list [list msg_id $msg_id]\
+ [list attachment_item_id $attachment_item_id] \
+ ] ]
+
+ content::item::set_live_revision -revision_id $revision_id
+ if { ![empty_string_p $upload_file] } {
+ set tmp_file [template::util::file::get_property tmp_filename $upload_file]
+ set content_length [file size $tmp_file]
+ # create the new item
+ set file_name [cr_create_content_file $attachment_item_id $revision_id $tmp_file]
+ db_dml set_file_content { *SQL* }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/send-mail.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-mail.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-mail.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ update cr_revisions
+ set content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/send-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-oracle.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,49 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ update cr_revisions
+ set filename = :file_name,
+ mime_type = :mime_type,
+ content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ update cr_revisions
+ set content = empty_blob(),
+ filename = :filename
+ where revision_id = :revision_id
+ returning content into :1
+
+
+
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type
+ crr.filename
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
+
Index: openacs-4/packages/messages/www/send-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send-postgresql.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,45 @@
+
+
+
+ postgresql7.3
+
+
+
+
+ update cr_revisions
+ set content = :file_name,
+ mime_type = :mime_type,
+ content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ update cr_revisions
+ set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]]
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ select crr.title as content,
+ crr.title,
+ crr.item_id,
+ cri.storage_type,
+ crr.revision_id,
+ crr.content_length,
+ crr.mime_type
+ from cr_items cri, cr_revisions crr
+ where crr.revision_id = :attachment_id
+ and crr.item_id = cri.item_id
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/send.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,150 @@
+
+
+
+
+
+ @page_title;noquote@
+ @context;noquote@
+
+
+
+
+ #messages.back_folders#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@history_conversation;noquote@
+@signature;noquote@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/send.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,216 @@
+ad_page_contract {
+ Send the message with attachment to users in the community.
+
+} {
+ {msg_id "" }
+ {subject ""}
+ {contacts_ids ""}
+ {total_attachment 0}
+ {reply ""}
+ {reply_p 0}
+ {general_parent_id ""}
+ {rel_types:multiple "" }
+ {reply_option ""}
+}
+
+set page_title "[_ messages.messages]"
+set context [list "[_ messages.compose_mail]"]
+set community_id [dotlrn_community::get_community_id]
+set rel_types_html ""
+set owner_id [ad_conn user_id]
+set package_id [ad_conn package_id]
+set admin_p [permission::permission_p -party_id $owner_id -object_id $package_id -privilege admin]
+#Set file javascript to members functions
+if { $reply_p == 1 } {
+ set action_send "send-mail"
+ #when send message reply
+ set member_js "show_members_rol_index"
+} else {
+ set action_send "send"
+ #When send a new message
+ set member_js "show_members_rol"
+}
+
+set roles [dotlrn_community::get_roles -community_id $community_id]
+if { $admin_p } {
+ foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ if {![string equal $rel_type "dotlrn_student_rel"]} {
+ append rel_types_html "
[lang::util::localize $pretty_plural] |"
+ } else {
+ append rel_types_html "
[lang::util::localize $pretty_plural] |"
+ }
+ }
+ append rel_types_html "
[_ messages.send_to_all]"
+} else {
+ foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ if {[string equal $rel_type "dotlrn_ca_rel"] || [string equal $rel_type "dotlrn_instructor_rel"] } {
+ if {![string equal $rel_type "dotlrn_student_rel"]} {
+ append rel_types_html "
[lang::util::localize $pretty_plural] |"
+ } else {
+ append rel_types_html "
[lang::util::localize $pretty_plural] |"
+ }
+ }
+ }
+}
+
+if {![exists_and_not_null show_master_p]} {
+ set show_master_p 1
+ set reply_send 0
+} else {
+ set reply_send 1
+}
+
+if {![exists_and_not_null option]} {
+ set option ""
+}
+
+set community_id [dotlrn_community::get_community_id]
+if { !$reply_p } {
+ set contacts_list [util_memoize [list messages::get_community_users_fb -community_id $community_id] 86400]
+}
+
+set signature_p [db_string signature_p {} -default 0]
+
+if { $signature_p } {
+ set signature [db_string get_signature {}]
+ set signature [ad_html_to_text [lindex $signature 0]]
+ set signature "
--
$signature
"
+} else {
+ set signature ""
+}
+
+if { [empty_string_p $signature] } {
+ set signature ""
+} else {
+ set signature [string trim $signature]
+}
+
+set attachment [db_list_of_lists get_attachment_id {}]
+if { [llength $attachment] != 0} {
+ foreach attachment_info $attachment {
+ set attachment_id [lindex $attachment_info 0]
+ set attachment_item_id [lindex $attachment_info 1]
+ db_1row get_sol_info { *SQL* }
+ set position [string first . "$content" 1]
+ if { $position == "-1" } {
+ set position [string length $content]
+ }
+ append download_file "
[string range $title 0 [expr $position - 1]]
"
+ }
+} else {
+ set download_file ""
+}
+
+set fs_package_id [dotlrn_community::get_package_id_from_package_key -package_key file-storage -community_id $community_id]
+set fs_folder_id [fs::get_root_folder -package_id $fs_package_id]
+set attachment_item_id ""
+
+set history_conversation [messages::get_history_conversation -parent_id $general_parent_id -msg_id $msg_id -user_id $owner_id]
+set content_message_conversation "
$history_conversation $signature"
+
+if { ![string equal $reply_option "forward"] } {
+ set content_message_conversation "
$signature"
+}
+
+ad_form -html { enctype multipart/form-data } -export { signature } -name compose_message -form {
+ {message:richtext(richtext),optional,nospell {label ""} {options {width "99%"}} {value "[list \"$content_message_conversation\" \"text/html\"]"}
+ {html {id "comments" rows 25 cols 50 onload "loadEditors('advancedMessagesEditor'); return false;"}}
+ }
+} -on_submit {
+ set count_attachment [expr $total_attachment + 1]
+ if { ![exists_and_not_null parent_id] } {
+ set parent_id ""
+ }
+
+ set base_url [dotlrn_community::get_community_url $community_id]
+ set message_url [export_vars -base "${base_url}messages/messages"]
+ set msg_id [messages::send_mail -parent_id $parent_id -count_attachment $count_attachment \
+ -contacts_ids $contacts_ids -community_id $community_id \
+ -owner_id $owner_id -subject $subject -message $message -message_url $message_url -rel_types $rel_types]
+
+ for {set x 1} {$x < $count_attachment} {incr x} {
+ set name_attachment "upload_file_${x}"
+ ad_form -extend -name compose_message -form {
+ {upload_file_$x:file,optional
+ {label ""}
+ }
+ }
+ set upload_file [set $name_attachment]
+ if { ![empty_string_p $upload_file] } {
+ db_transaction {
+ set attachment_item_id ""
+ if { ![regexp {[^//\\]+$} $upload_file filename] } {
+ # no match
+ set filename ${x}_$upload_file
+ }
+ set community_id [dotlrn_community::get_community_id]
+ set package_id [dotlrn_community::get_package_id_from_package_key -package_key messages -community_id $community_id]
+ set title [template::util::file::get_property filename $upload_file]
+ set item_id [db_nextval acs_object_id_seq]
+ set item_name "${item_id}-${title}"
+ set mime_type [cr_filename_to_mime_type -create $title]
+ set folder_id [content::item::get_id -item_path "messages_attachments_${package_id}" -resolve_index f]
+ set creation_user [ad_conn user_id]
+ set creation_ip [ad_conn peeraddr]
+ # set storage_type to its default value according to a db constraint
+ set storage_type file
+ set attachment_item_id [content::item::new \
+ -item_id $item_id \
+ -parent_id $folder_id \
+ -name $item_name \
+ -context_id $package_id \
+ -content_type messages_attachments \
+ -mime_type $mime_type \
+ -storage_type $storage_type \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip]
+
+ set revision_id [content::revision::new -item_id $attachment_item_id \
+ -mime_type $mime_type \
+ -title $title \
+ -content_type messages_attachments \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -attributes [list [list msg_id $msg_id]\
+ [list attachment_item_id $attachment_item_id] \
+ ] ]
+
+ content::item::set_live_revision -revision_id $revision_id
+ if { ![empty_string_p $upload_file] } {
+ set tmp_file [template::util::file::get_property tmp_filename $upload_file]
+ set content_length [file size $tmp_file]
+ # create the new item
+ set file_name [cr_create_content_file $attachment_item_id $revision_id $tmp_file]
+ db_dml set_file_content { *SQL* }
+ }
+ }
+ }
+ }
+} -after_submit {
+ ad_returnredirect "messages"
+ ad_script_abort
+}
+
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yahoo-dom-event/yahoo-dom-event.js" -order "-1"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/yahoo/yahoo-min.js" -order "-14"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/element/element-beta-min.js" -order "-13"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/event/event-min.js" -order "-15"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dom/dom-min.js" -order "-16"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/button/button-beta-min.js" -order "-17"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/utilities/utilities.js" -order "-18"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/history/history-beta-min.js" -order "-19"
+template::head::add_javascript -src "/resources/messages/prototype.js" -order "2"
+template::head::add_javascript -src "/resources/messages/effects.js" -order "3"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/dragdrop/dragdrop.js" -order "4"
+template::head::add_javascript -src "/resources/messages/controls.js" -order "5"
+template::head::add_javascript -src "/resources/messages/builder.js" -order "7"
+template::head::add_javascript -src "/resources/messages/application.js" -order "8"
+template::head::add_javascript -src "/resources/messages/messages.js" -order "10"
+template::head::add_javascript -src "/resources/messages/message-attachment.js" -order "11"
+template::head::add_css -href "/resources/messages/send.css"
+template::head::add_javascript -src "/resources/ajaxhelper/yui/container/container-min.js"
+template::head::add_css -href "/resources/ajaxhelper/yui/fonts/fonts-min.css"
+template::head::add_css -href "/resources/ajaxhelper/yui/button/assets/skins/sam/button.css"
+template::head::add_css -href "/resources/ajaxhelper/yui/container/assets/skins/sam/container.css"
+
+template::head::add_javascript -src "/resources/ajaxhelper/yui/connection/connection-min.js"
\ No newline at end of file
Index: openacs-4/packages/messages/www/send.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/send.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/send.xql 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+ select persons.first_names||' '||persons.last_name as party_name,
+ persons.person_id
+ from persons,
+ dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = persons.person_id
+ order by party_name
+
+
+
+
+
+ select signature_p
+ from messages_options
+ where user_id = :owner_id
+
+
+
+
+
+ select signature
+ from messages_options
+ where user_id = :owner_id
+
+
+
+
+
+
+ select attachment_id, attachment_item_id
+ from messages_attachments
+ where msg_id = :msg_id
+
+
+
+
+
+ update cr_revisions
+ set content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
+
+
+ update cr_revisions
+ set title = :title,
+ mime_type = :mime_type,
+ content_length = :content_length
+ where revision_id = :revision_id
+
+
+
+
+
Index: openacs-4/packages/messages/www/test.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/test.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/test.adp 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,2 @@
+
+@contacts_list@
Index: openacs-4/packages/messages/www/test.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/test.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/test.tcl 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,26 @@
+ad_page_contract {
+ General page, list inbox, sent, draft, trash.
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-12
+ @cvs-id $Id: test.tcl,v 1.1 2010/08/31 21:30:42 alvaror Exp $
+} {
+ {community_id ""}
+ {page_number ""}
+}
+
+set page_title "[_ messages.folders]"
+set context [list $page_title]
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+
+set count_members [db_string count_members {}]
+
+for {set i 0} { $i < $count_members} {set i [expr $i + 1500] } {
+ ns_log notice ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ciclo for $i"
+ set limit [expr $i + 1500]
+ append contacts_list [join [db_list members { *SQL* }] ","]
+}
+
+ns_log notice ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> count_members $count_members"
+
Index: openacs-4/packages/messages/www/test.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/test.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/test.xql 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,45 @@
+
+
+
+
+
+ select folder_id, folder_name
+ from messages_folders
+ where (user_id = :user_id
+ or user_id = 0)
+ order by folder_id asc
+
+
+
+
+
+ select concat('{n:"'||to_clob(party_name)||'", p:"'||to_clob(person_id)||'"}') as contact
+ from (select persons.first_names||' '||persons.last_name as party_name, persons.person_id
+ from persons,dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = persons.person_id and rownum <= $limit and rownum > $i
+ order by party_name)
+
+
+
+
+
+ select '{n:"'||party_name||'", p:"'||person_id||'"}' as contact
+ from (select persons.first_names||' '||persons.last_name as party_name, persons.person_id
+ from persons,dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = persons.person_id and rownum > 1500
+ order by party_name)
+
+
+
+
+
+ select count(*)
+ from persons,dotlrn_member_rels_approved
+ where dotlrn_member_rels_approved.community_id = :community_id
+ and dotlrn_member_rels_approved.user_id = persons.person_id
+
+
+
+
Index: openacs-4/packages/messages/www/update-name.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/update-name.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/update-name.adp 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1 @@
+@folder_id;noquote@
\ No newline at end of file
Index: openacs-4/packages/messages/www/update-name.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/update-name.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/update-name.tcl 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,24 @@
+ad_page_contract {
+ Update the folder name
+
+ @author pedro@viaro.net
+ @creation-date 2010-01-19
+ @cvs-id $Id: update-name.tcl,v 1.1 2010/08/31 21:30:43 alvaror Exp $
+} {
+ {name ""}
+ {delete "f"}
+ folder_id
+}
+
+set user_id [ad_conn user_id]
+set folder_id_inbox [messages::get_folder_id -folder_name "inbox"]
+if { [string equal $delete "t"] } {
+ db_transaction {
+ db_dml update_messages { *SQL* }
+ db_dml delete_folder { *SQL* }
+ }
+} elseif {![empty_string_p $name]} {
+ db_transaction {
+ db_dml update_name { *SQL* }
+ }
+}
\ No newline at end of file
Index: openacs-4/packages/messages/www/update-name.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/update-name.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/update-name.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,23 @@
+
+
+
+
+
+ update messages_folders set folder_name = :name where folder_id = :folder_id
+
+
+
+
+
+ delete from messages_folders where folder_id = :folder_id
+
+
+
+
+
+ update messages_user_messages set folder_id = :folder_id_inbox
+ where folder_id = :folder_id and user_id = :user_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/update-numbers.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/update-numbers.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/update-numbers.adp 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1 @@
+@numbers;noquote@
\ No newline at end of file
Index: openacs-4/packages/messages/www/update-numbers.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/update-numbers.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/update-numbers.tcl 31 Aug 2010 21:30:42 -0000 1.1
@@ -0,0 +1,28 @@
+ad_page_contract {
+ Update numbers of new messages in the menu
+
+ @author pedro@viaro.net
+ @creation-date 2009-11-17
+ @cvs-id $Id: update-numbers.tcl,v 1.1 2010/08/31 21:30:42 alvaror Exp $
+} {
+
+}
+
+append not_folder_ids [messages::get_folder_id -folder_name "sent"] "," \
+ [messages::get_folder_id -folder_name "trash"]
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+set folders_info [db_list_of_lists count_new_messages {}]
+set numbers [list]
+foreach folder $folders_info {
+ lappend numbers [lindex $folder 0]
+ lappend numbers [lindex $folder 1]
+ lappend numbers [lindex $folder 2]
+}
+
+if { [llength $numbers] } {
+ set numbers [join $numbers ","]
+} else {
+ set numbers " "
+}
Index: openacs-4/packages/messages/www/update-numbers.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/update-numbers.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/update-numbers.xql 31 Aug 2010 21:30:43 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+
+
+
+ select count (case when um.new_p = 't' then 1 end ) as new_t, um.folder_id,
+ count (um.new_p) as total
+ from (select distinct(parent_id) as msg_id,folder_id,new_p
+ from messages_user_messages
+ where user_id = :user_id
+ and msg_id in (select msg_id
+ from messages_messages
+ where community_id = :community_id)
+ and folder_id not in ($not_folder_ids)) um
+ group by um.folder_id
+ order by folder_id
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/xinha-master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/xinha-master.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/xinha-master.adp 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+xinha_editors = null;
+xinha_init = null;
+xinha_config = null;
+xinha_plugins = [@xinha_plugins@];
+Xinha.loadPlugins(xinha_plugins,null);
+xinha_editors = xinha_editors ? xinha_editors :[ @htmlarea_ids@ ];
+xinha_config = xinha_config ? xinha_config() : new Xinha.Config();
+@xinha_params@
+@xinha_options@
+xinha_editors =
+Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
+Xinha.startEditors(xinha_editors);
+
+
+@htmlarea_ids@
+
\ No newline at end of file
Index: openacs-4/packages/messages/www/xinha-master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/xinha-master.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/xinha-master.tcl 31 Aug 2010 21:30:44 -0000 1.1
@@ -0,0 +1,11 @@
+ set ::xinha_dir /resources/acs-templating/xinha-nightly/
+ set ::xinha_lang [lang::conn::language]
+
+ # We could add site wide Xinha configurations (.js code) into xinha_params
+ set xinha_params ""
+
+ # Per call configuration
+ set xinha_plugins $::acs_blank_master(xinha.plugins)
+ set xinha_options $::acs_blank_master(xinha.options)
+ # HTML ids of the textareas used for Xinha
+ set htmlarea_ids '[join $::acs_blank_master__htmlareas "','"]'
Index: openacs-4/packages/messages/www/resources/Delete16-on.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/Delete16-on.gif,v
diff -u -N
Binary files differ
Index: openacs-4/packages/messages/www/resources/add.png
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/add.png,v
diff -u -N
Binary files differ
Index: openacs-4/packages/messages/www/resources/application.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/application.js,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/resources/application.js 31 Aug 2010 21:30:54 -0000 1.1
@@ -0,0 +1,338 @@
+validate_party_id = function(party_id) {
+ var regexparty_id = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
+ return regexparty_id.test(party_id);
+
+}
+
+Autocompleter.LocalAdvanced = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ this.wrapper = $(this.element.parentNode);
+
+ if (!this.element.hacks) {
+ this.element.should_use_borderless_hack = Prototype.Browser.WebKit;
+ this.element.should_use_shadow_hack = Prototype.Browser.IE || Prototype.Browser.Opera;
+ this.element.hacks = true;
+ }
+ if (this.element.should_use_borderless_hack || this.element.should_use_shadow_hack) { this.wrapper.addClassName('tokenizer_input_borderless'); }
+
+ this.options.onShow = function(element,update) {
+ Position.clone(element.parentNode.parentNode, update, {
+ setHeight: false,
+ setWidth: false,
+ offsetTop: element.parentNode.parentNode.offsetHeight
+ });
+ update.show();
+
+ }
+ this.options.onHide = function(element, update){ update.hide() };
+
+
+ },
+getUpdatedChoices: function() {
+ this.updateChoices(this.options.selector(this));
+
+ },
+
+onBlur: function($super, event) {
+ $super();
+ //move itself back to the end on blur
+ if (this.wrapper.nextSiblings().length > 0) {
+ this.wrapper.nextSiblings().last().insert({
+ after: this.wrapper
+ });
+
+ }
+
+ },
+set_input_size: function(size) {
+ size = size || 20;
+ this.element.setStyle({width: size + "px"});
+},
+onKeyPress: function(event) {
+ //dynamically resize the input field
+ var new_size = 20 + (this.element.value.length * 7);
+ if (new_size <= 340) {
+ this.set_input_size(new_size);
+ } else {
+ this.set_input_size(340);
+ }
+ //active is when there's suggesitons found
+ if (this.active)
+ switch (event.keyCode) {
+ case Event.KEY_TAB:
+ case Event.KEY_RETURN:
+ this.selectEntry();
+ Event.stop(event);
+ case Event.KEY_ESC:
+ this.hide();
+ this.active = false;
+ Event.stop(event);
+ return;
+ case Event.KEY_LEFT:
+ case Event.KEY_RIGHT:
+ return;
+ case Event.KEY_UP:
+ this.markPrevious();
+ this.render();
+ Event.stop(event);
+ return;
+ case Event.KEY_DOWN:
+ this.markNext();
+ this.render();
+ Event.stop(event);
+ return;
+
+ }
+ else {
+ if (event.keyCode == Event.KEY_TAB || event.keyCode == Event.KEY_RETURN ||
+ (Prototype.Browser.WebKit > 0 && event.keyCode == 0) || event.keyCode == 44 /* , comma */ || event.keyCode == 188 ) {
+ var party_id_addr = this.element.value.strip().sub(',', '')
+ //recognise party_id format
+ if (validate_party_id(party_id_addr)) {
+ addparty_idToList(party_id_addr);
+ Event.stop(event);
+ }
+ this.element.value = "";
+ this.set_input_size();
+ return false;
+
+ }
+ switch (event.keyCode) {
+ //jump left to token
+ case Event.KEY_LEFT:
+ case Event.KEY_BACKSPACE:
+ if (this.element.value == "" && typeof this.wrapper.previous().token != "undefined") {
+ this.wrapper.previous().token.select();
+
+ }
+ return;
+ //jump right to token
+ case Event.KEY_RIGHT:
+ if (this.element.value == "" && this.wrapper.next() && typeof this.wrapper.next().token != "undefined") {
+ this.wrapper.next().token.select();
+
+ }
+
+ }
+
+ }
+
+ this.changed = true;
+ this.hasFocus = true;
+
+ if (this.observer) clearTimeout(this.observer);
+ this.observer =
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency * 1000);
+
+ },
+
+setOptions: function(options) {
+ this.options = Object.extend({
+ choices: 10,
+ partialSearch: true,
+ partialChars: 2,
+ ignoreCase: true,
+ fullSearch: false,
+ selector: function(instance) {
+ var ret = [];
+ // Beginning matches
+ var partial = [];
+ // Inside matches
+ var entry = instance.getToken();
+ var count = 0;
+
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices; i++) {
+
+ var elem = instance.options.array[i];
+ var elem_name = elem[instance.options.search_field];
+ var foundPos = instance.options.ignoreCase ?
+ elem_name.toLowerCase().indexOf(entry.toLowerCase()) :
+ elem_name.indexOf(entry);
+
+ while (foundPos != -1) {
+
+ if (foundPos == 0 && elem_name.length != entry.length) {
+ var value = "" + elem_name.substr(0, entry.length) + "" + elem_name.substr(entry.length);
+ ret.push(
+ "" + "" + value + "
"
+ + "" + elem.p + "
" + ""
+ );
+ break;
+
+ } else if (entry.length >= instance.options.partialChars && instance.options.partialSearch && foundPos != -1) {
+ if (instance.options.fullSearch || /\s/.test(elem_name.substr(foundPos - 1, 1))) {
+ var value = elem_name.substr(0, foundPos) + "" +
+ elem_name.substr(foundPos, entry.length) + "" + elem_name.substr(
+ foundPos + entry.length)
+
+ partial.push(
+ "" + "" + value + "
"
+ + "" + elem.p + "
" + ""
+ );
+ break;
+
+ }
+
+ }
+ foundPos = instance.options.ignoreCase ?
+ elem_name.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ elem_name.indexOf(entry, foundPos + 1);
+
+
+ }
+
+ }
+ if (partial.length)
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
+ return "";
+
+ }
+
+ },
+ options || {});
+
+ }
+
+});
+HiddenInput = Class.create({
+ initialize: function(element, auto_complete) {
+ this.element = $(element);
+ this.auto_complete = auto_complete;
+ this.token;
+ Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
+
+ },
+ onKeyPress: function(event) {
+ if (this.token.selected) {
+ switch (event.keyCode) {
+ case Event.KEY_LEFT:
+ this.token.element.insert({
+ before:
+ this.auto_complete.wrapper
+ })
+ this.token.deselect();
+ this.auto_complete.element.focus();
+ return false;
+ case Event.KEY_RIGHT:
+ this.token.element.insert({
+ after:
+ this.auto_complete.wrapper
+ })
+ this.token.deselect();
+ this.auto_complete.element.focus();
+ return false;
+ case Event.KEY_BACKSPACE:
+ case Event.KEY_DELETE:
+ this.token.element.remove();
+ this.auto_complete.element.focus();
+ return false;
+
+ }
+
+ }
+
+ }
+
+
+})
+ Token = Class.create({
+ initialize: function(element, hidden_input) {
+ this.element = $(element);
+ this.hidden_input = hidden_input;
+ this.element.token = this;
+ this.selected = false;
+ Event.observe(document, 'click', this.onclick.bindAsEventListener(this));
+
+ },
+ select: function() {
+ this.hidden_input.token = this;
+ this.hidden_input.element.activate();
+ this.selected = true;
+ this.element.addClassName('token_selected');
+
+ },
+ deselect: function() {
+ this.hidden_input.token = "undefined";
+ this.selected = false;
+ this.element.removeClassName('token_selected')
+
+ },
+ onclick: function(event) {
+ if (this.detect(event) && !this.selected) {
+ this.select();
+
+ } else {
+ this.deselect();
+
+ }
+
+ },
+ detect: function(e) {
+ //find the event object
+ var eventTarget = e.target ? e.target: e.srcElement;
+ var token = eventTarget.token;
+ var candidate = eventTarget;
+ while (token == null && candidate.parentNode) {
+ candidate = candidate.parentNode;
+ token = candidate.token;
+
+ }
+ return token != null && token.element == this.element;
+
+ }
+
+});
+
+
+addContactToList = function(item) {
+ $('autocomplete_input').value = "";
+ var token = Builder.node('a', {
+ "class": 'token',
+ href: "#",
+ tabindex: "-1"
+ },
+ Builder.node('span',
+ Builder.node('span',
+ Builder.node('span',
+ Builder.node('span', {},
+ [Builder.node('input', { type: "hidden", name: "ids[]",
+ value: item.lastChild.innerHTML
+ }),
+ contacts[Element.readAttribute(item,'value')].name,
+ Builder.node('span',{"class":'x',onmouseout:"this.className='x'",onmouseover:"this.className='x_hover'",
+ onclick:"this.parentNode.parentNode.parentNode.parentNode.parentNode.remove(true); return false;"}," ")
+ ]
+ )
+ )
+ )
+ )
+ );
+ $(token).down(4).next().innerHTML = " ";
+ new Token(token,hidden_input);
+ $('autocomplete_display').insert({before:token});
+}
+addparty_idToList = function(party_id) {
+/* $('autocomplete_input').value = "";*/
+ var token = Builder.node('a',{"class":'token',href:"#",tabindex:"-1"},
+ Builder.node('span',
+ Builder.node('span',
+ Builder.node('span',
+ Builder.node('span',{},[
+ Builder.node('input',{type:"hidden",name:"party_ids[]",value: party_id} ) ,
+ party_id,
+ Builder.node('span',{"class":'x',onmouseout:"this.className='x'",onmouseover:"this.className='x_hover'",
+ onclick:"this.parentNode.parentNode.parentNode.parentNode.parentNode.remove(true); return false;"}," ")
+ ]
+ )
+ )
+ )
+ )
+ );
+ $(token).down(4).next().innerHTML = " ";
+ new Token(token,hidden_input);
+ $('autocomplete_display').insert({before:token});
+}
+
Index: openacs-4/packages/messages/www/resources/arrow_down.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/arrow_down.gif,v
diff -u -N
Binary files differ
Index: openacs-4/packages/messages/www/resources/arrow_down.png
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/arrow_down.png,v
diff -u -N
Binary files differ
Index: openacs-4/packages/messages/www/resources/attachment.png
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/attachment.png,v
diff -u -N
Binary files differ
Index: openacs-4/packages/messages/www/resources/before_arr.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/before_arr.gif,v
diff -u -N
Binary files differ
Index: openacs-4/packages/messages/www/resources/builder.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/builder.js,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/resources/builder.js 31 Aug 2010 21:30:50 -0000 1.1
@@ -0,0 +1,129 @@
+var Builder = {
+ NODEMAP: {
+ AREA: 'map',
+ CAPTION: 'table',
+ COL: 'table',
+ COLGROUP: 'table',
+ LEGEND: 'fieldset',
+ OPTGROUP: 'select',
+ OPTION: 'select',
+ PARAM: 'object',
+ TBODY: 'table',
+ TD: 'table',
+ TFOOT: 'table',
+ TH: 'table',
+ THEAD: 'table',
+ TR: 'table'
+ },
+ // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
+ // due to a Firefox bug
+ node: function(elementName) {
+ elementName = elementName.toUpperCase();
+
+ // try innerHTML approach
+ var parentTag = this.NODEMAP[elementName] || 'div';
+ var parentElement = document.createElement(parentTag);
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+ parentElement.innerHTML = "<" + elementName + ">" + elementName + ">";
+ } catch(e) {}
+ var element = parentElement.firstChild || null;
+
+ // see if browser added wrapping tags
+ if(element && (element.tagName.toUpperCase() != elementName))
+ element = element.getElementsByTagName(elementName)[0];
+
+ // fallback to createElement approach
+ if(!element) element = document.createElement(elementName);
+
+ // abort if nothing could be created
+ if(!element) return;
+
+ // attributes (or text)
+ if(arguments[1])
+ if(this._isStringOrNumber(arguments[1]) ||
+ (arguments[1] instanceof Array) ||
+ arguments[1].tagName) {
+ this._children(element, arguments[1]);
+ } else {
+ var attrs = this._attributes(arguments[1]);
+ if(attrs.length) {
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+ parentElement.innerHTML = "<" +elementName + " " +
+ attrs + ">" + elementName + ">";
+ } catch(e) {}
+ element = parentElement.firstChild || null;
+ // workaround firefox 1.0.X bug
+ if(!element) {
+ element = document.createElement(elementName);
+ for(attr in arguments[1])
+ element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
+ }
+ if(element.tagName.toUpperCase() != elementName)
+ element = parentElement.getElementsByTagName(elementName)[0];
+ }
+ }
+
+ // text, or array of children
+ if(arguments[2])
+ this._children(element, arguments[2]);
+
+ return element;
+ },
+ _text: function(text) {
+ return document.createTextNode(text);
+ },
+
+ ATTR_MAP: {
+ 'className': 'class',
+ 'htmlFor': 'for'
+ },
+
+ _attributes: function(attributes) {
+ var attrs = [];
+ for(attribute in attributes)
+ attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'"') + '"');
+ return attrs.join(" ");
+ },
+ _children: function(element, children) {
+ if(children.tagName) {
+ element.appendChild(children);
+ return;
+ }
+ if(typeof children=='object') { // array can hold nodes and text
+ children.flatten().each( function(e) {
+ if(typeof e=='object')
+ element.appendChild(e);
+ else
+ if(Builder._isStringOrNumber(e))
+ element.appendChild(Builder._text(e));
+ });
+ } else
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
+ },
+ _isStringOrNumber: function(param) {
+ return(typeof param=='string' || typeof param=='number');
+ },
+ build: function(html) {
+ var element = this.node('div');
+ $(element).update(html.strip());
+ return element.down();
+ },
+ dump: function(scope) {
+ if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
+
+ var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
+ "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
+ "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
+
+ tags.each( function(tag){
+ scope[tag] = function() {
+ return Builder.node.apply(Builder, [tag].concat($A(arguments)));
+ };
+ });
+ }
+};
Index: openacs-4/packages/messages/www/resources/controls.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/controls.js,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/resources/controls.js 31 Aug 2010 21:30:50 -0000 1.1
@@ -0,0 +1,926 @@
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = { };
+Autocompleter.Base = Class.create({
+ baseInitialize: function(element, update, options) {
+ element = $(element);
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
+ this.entryCount = 0;
+ this.oldElementValue = this.element.value;
+ if(this.setOptions)
+ this.setOptions(options);
+ else
+ this.options = options || { };
+
+ this.options.paramName = this.options.paramName || this.element.name;
+ this.options.tokens = this.options.tokens || [];
+ this.options.frequency = this.options.frequency || 0.4;
+ this.options.minChars = this.options.minChars || 1;
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
+ if(!$(update).getStyle('position') || $(update).getStyle('position')=='absolute') {
+ $(update).setStyle({position : 'absolute'});
+ Position.clone(element, update, {
+ setHeight: false,
+ offsetTop: element.offsetHeight
+ });
+ }
+ Effect.Appear(update,{duration:0.15});
+ };
+ this.options.onHide = this.options.onHide ||
+ function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+ if(typeof(this.options.tokens) == 'string')
+ this.options.tokens = new Array(this.options.tokens);
+ // Force carriage returns as token delimiters anyway
+ if (!this.options.tokens.include('\n'))
+ this.options.tokens.push('\n');
+
+ this.observer = null;
+
+ this.element.setAttribute('autocomplete','off');
+
+ Element.hide(this.update);
+
+ Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
+ },
+
+ show: function() {
+ if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+ if(!this.iefix &&
+ (Prototype.Browser.IE) &&
+ (Element.getStyle(this.update, 'position')=='absolute')) {
+ new Insertion.After(this.update,
+ '');
+ this.iefix = $(this.update.id+'_iefix');
+ }
+ if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+ },
+
+ fixIEOverlapping: function() {
+ Position.clone(this.update, this.iefix, {setTop:(!this.update.getStyle("height"))});
+ $(this.iefix).setStyle({zIndex : 1});
+ this.update.setStyle({zIndex:2});
+ Element.show(this.iefix);
+ },
+
+ hide: function() {
+ this.stopIndicator();
+ if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
+ if(this.iefix) Element.hide(this.iefix);
+ },
+
+ startIndicator: function() {
+ if(this.options.indicator) Element.show(this.options.indicator);
+ },
+
+ stopIndicator: function() {
+ if(this.options.indicator) Element.hide(this.options.indicator);
+ },
+
+ onKeyPress: function(event) {
+ if(this.active)
+ switch(event.keyCode) {
+ case Event.KEY_TAB:
+ case Event.KEY_RETURN:
+ this.selectEntry();
+ Event.stop(event);
+ case Event.KEY_ESC:
+ this.hide();
+ this.active = false;
+ Event.stop(event);
+ return;
+ case Event.KEY_LEFT:
+ case Event.KEY_RIGHT:
+ return;
+ case Event.KEY_UP:
+ this.markPrevious();
+ this.render();
+ Event.stop(event);
+ return;
+ case Event.KEY_DOWN:
+ this.markNext();
+ this.render();
+ Event.stop(event);
+ return;
+ }
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
+
+ this.changed = true;
+ this.hasFocus = true;
+
+ if(this.observer) clearTimeout(this.observer);
+ this.observer =
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
+ },
+
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
+ onHover: function(event) {
+ var element = Event.findElement(event, 'LI');
+ if(this.index != element.autocompleteIndex)
+ {
+ this.index = element.autocompleteIndex;
+ this.render();
+ }
+ Event.stop(event);
+ },
+
+ onClick: function(event) {
+ var element = Event.findElement(event, 'LI');
+ this.index = element.autocompleteIndex;
+ this.selectEntry();
+ this.hide();
+ },
+
+ onBlur: function(event) {
+ // needed to make click events working
+ setTimeout(this.hide.bind(this), 250);
+ this.hasFocus = false;
+ this.active = false;
+ },
+
+ render: function() {
+ if(this.entryCount > 0) {
+ for (var i = 0; i < this.entryCount; i++)
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
+ Element.removeClassName(this.getEntry(i),"selected");
+ if(this.hasFocus) {
+ this.show();
+ this.active = true;
+ }
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ markPrevious: function() {
+ if(this.index > 0) this.index--;
+ else this.index = this.entryCount-1;
+ this.getEntry(this.index).scrollIntoView(true);
+ },
+
+ markNext: function() {
+ if(this.index < this.entryCount-1) this.index++;
+ else this.index = 0;
+ this.getEntry(this.index).scrollIntoView(false);
+ },
+
+ getEntry: function(index) {
+ return this.update.firstChild.childNodes[index];
+ },
+
+ getCurrentEntry: function() {
+ return this.getEntry(this.index);
+ },
+
+ selectEntry: function() {
+ this.active = false;
+ this.updateElement(this.getCurrentEntry());
+ },
+
+ updateElement: function(selectedElement) {
+ if (this.options.updateElement) {
+ this.options.updateElement(selectedElement);
+ return;
+ }
+ var value = '';
+ if (this.options.select) {
+ var nodes = $(selectedElement).select('.' + this.options.select) || [];
+ if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
+ } else
+ value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+
+ var bounds = this.getTokenBounds();
+ if (bounds[0] != -1) {
+ var newValue = this.element.value.substr(0, bounds[0]);
+ var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
+ if (whitespace)
+ newValue += whitespace[0];
+ this.element.value = newValue + value + this.element.value.substr(bounds[1]);
+ } else {
+ this.element.value = value;
+ }
+ this.oldElementValue = this.element.value;
+ this.element.focus();
+
+ if (this.options.afterUpdateElement)
+ this.options.afterUpdateElement(this.element, selectedElement);
+ },
+
+ updateChoices: function(choices) {
+ if(!this.changed && this.hasFocus) {
+ this.update.innerHTML = choices;
+ Element.cleanWhitespace(this.update);
+ Element.cleanWhitespace(this.update.down());
+
+ if(this.update.firstChild && this.update.down().childNodes) {
+ this.entryCount =
+ this.update.down().childNodes.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ } else {
+ this.entryCount = 0;
+ }
+
+ this.stopIndicator();
+ this.index = 0;
+
+ if(this.entryCount==1 && this.options.autoSelect) {
+ this.selectEntry();
+ this.hide();
+ } else {
+ this.render();
+ }
+ }
+ },
+
+ addObservers: function(element) {
+ Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
+ Event.observe(element, "click", this.onClick.bindAsEventListener(this));
+ },
+
+ onObserverEvent: function() {
+ this.changed = false;
+ this.tokenBounds = null;
+ if(this.getToken().length>=this.options.minChars) {
+ this.getUpdatedChoices();
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ this.oldElementValue = this.element.value;
+ },
+
+ getToken: function() {
+ var bounds = this.getTokenBounds();
+ return this.element.value.substring(bounds[0], bounds[1]).strip();
+ },
+
+ getTokenBounds: function() {
+ if (null != this.tokenBounds) return this.tokenBounds;
+ var value = this.element.value;
+ if (value.strip().empty()) return [-1, 0];
+ var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
+ var offset = (diff == this.oldElementValue.length ? 1 : 0);
+ var prevTokenPos = -1, nextTokenPos = value.length;
+ var tp;
+ for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
+ tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
+ if (tp > prevTokenPos) prevTokenPos = tp;
+ tp = value.indexOf(this.options.tokens[index], diff + offset);
+ if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
+ }
+ return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
+ }
+});
+
+Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
+ var boundary = Math.min(newS.length, oldS.length);
+ for (var index = 0; index < boundary; ++index)
+ if (newS[index] != oldS[index])
+ return index;
+ return boundary;
+};
+
+Ajax.Autocompleter = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, url, options) {
+ this.baseInitialize(element, update, options);
+ this.options.asynchronous = true;
+ this.options.onComplete = this.onComplete.bind(this);
+ this.options.defaultParams = this.options.parameters || null;
+ this.url = url;
+ },
+
+ getUpdatedChoices: function() {
+ this.startIndicator();
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
+ encodeURIComponent(this.getToken());
+
+ this.options.parameters = this.options.callback ?
+ this.options.callback(this.element, entry) : entry;
+
+ if(this.options.defaultParams)
+ this.options.parameters += '&' + this.options.defaultParams;
+
+ new Ajax.Request(this.url, this.options);
+ },
+
+ onComplete: function(request) {
+ this.updateChoices(request.responseText);
+ }
+});
+
+// The local array autocompleter. Used when you'd prefer to
+// inject an array of autocompletion options into the page, rather
+// than sending out Ajax queries, which can be quite slow sometimes.
+//
+// The constructor takes four parameters. The first two are, as usual,
+// the id of the monitored textbox, and id of the autocompletion menu.
+// The third is the array you want to autocomplete from, and the fourth
+// is the options block.
+//
+// Extra local autocompletion options:
+// - choices - How many autocompletion choices to offer
+//
+// - partialSearch - If false, the autocompleter will match entered
+// text only at the beginning of strings in the
+// autocomplete array. Defaults to true, which will
+// match text at the beginning of any *word* in the
+// strings in the autocomplete array. If you want to
+// search anywhere in the string, additionally set
+// the option fullSearch to true (default: off).
+//
+// - fullSsearch - Search anywhere in autocomplete array strings.
+//
+// - partialChars - How many characters to enter before triggering
+// a partial match (unlike minChars, which defines
+// how many characters are required to do any match
+// at all). Defaults to 2.
+//
+// - ignoreCase - Whether to ignore case when autocompleting.
+// Defaults to true.
+//
+// It's possible to pass in a custom function as the 'selector'
+// option, if you prefer to write your own autocompletion logic.
+// In that case, the other options above will not apply unless
+// you support them.
+
+Autocompleter.Local = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ },
+
+ getUpdatedChoices: function() {
+ this.updateChoices(this.options.selector(this));
+ },
+
+ setOptions: function(options) {
+ this.options = Object.extend({
+ choices: 10,
+ partialSearch: true,
+ partialChars: 2,
+ ignoreCase: true,
+ fullSearch: false,
+ selector: function(instance) {
+ var ret = []; // Beginning matches
+ var partial = []; // Inside matches
+ var entry = instance.getToken();
+ var count = 0;
+
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
+
+ var elem = instance.options.array[i];
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ elem.indexOf(entry);
+
+ while (foundPos != -1) {
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("" + elem.substr(0, entry.length) + "" +
+ elem.substr(entry.length) + "");
+ break;
+ } else if (entry.length >= instance.options.partialChars &&
+ instance.options.partialSearch && foundPos != -1) {
+ if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
+ partial.push("" + elem.substr(0, foundPos) + "" +
+ elem.substr(foundPos, entry.length) + "" + elem.substr(
+ foundPos + entry.length) + "");
+ break;
+ }
+ }
+
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ elem.indexOf(entry, foundPos + 1);
+
+ }
+ }
+ if (partial.length)
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
+ return "";
+ }
+ }, options || { });
+ }
+});
+
+// AJAX in-place editor and collection editor
+// Full rewrite by Christophe Porteneuve (April 2007).
+
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+ setTimeout(function() {
+ Field.activate(field);
+ }, 1);
+};
+
+Ajax.InPlaceEditor = Class.create({
+ initialize: function(element, url, options) {
+ this.url = url;
+ this.element = element = $(element);
+ this.prepareOptions();
+ this._controls = { };
+ arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
+ Object.extend(this.options, options || { });
+ if (!this.options.formId && this.element.id) {
+ this.options.formId = this.element.id + '-inplaceeditor';
+ if ($(this.options.formId))
+ this.options.formId = '';
+ }
+ if (this.options.externalControl)
+ this.options.externalControl = $(this.options.externalControl);
+ if (!this.options.externalControl)
+ this.options.externalControlOnly = false;
+ this._originalBackground = this.element.getStyle('background-color') || 'transparent';
+ this.element.title = this.options.clickToEditText;
+ this._boundCancelHandler = this.handleFormCancellation.bind(this);
+ this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
+ this._boundFailureHandler = this.handleAJAXFailure.bind(this);
+ this._boundSubmitHandler = this.handleFormSubmission.bind(this);
+ this._boundWrapperHandler = this.wrapUp.bind(this);
+ this.registerListeners();
+ },
+ checkForEscapeOrReturn: function(e) {
+ if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
+ if (Event.KEY_ESC == e.keyCode)
+ this.handleFormCancellation(e);
+ else if (Event.KEY_RETURN == e.keyCode)
+ this.handleFormSubmission(e);
+ },
+ createControl: function(mode, handler, extraClasses) {
+ var control = this.options[mode + 'Control'];
+ var text = this.options[mode + 'Text'];
+ if ('button' == control) {
+ var btn = document.createElement('input');
+ btn.type = 'submit';
+ btn.value = text;
+ btn.className = 'editor_' + mode + '_button';
+ if ('cancel' == mode)
+ btn.onclick = this._boundCancelHandler;
+ this._form.appendChild(btn);
+ this._controls[mode] = btn;
+ } else if ('link' == control) {
+ var link = document.createElement('a');
+ link.href = '#';
+ link.appendChild(document.createTextNode(text));
+ link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
+ link.className = 'editor_' + mode + '_link';
+ if (extraClasses)
+ link.className += ' ' + extraClasses;
+ this._form.appendChild(link);
+ this._controls[mode] = link;
+ }
+ },
+ createEditField: function() {
+ var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
+ var fld;
+ if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
+ fld = document.createElement('input');
+ fld.type = 'text';
+ var size = this.options.size || this.options.cols || 0;
+ if (0 < size) fld.size = size;
+ } else {
+ fld = document.createElement('textarea');
+ fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
+ fld.cols = this.options.cols || 40;
+ }
+ fld.name = this.options.paramName;
+ fld.value = text; // No HTML breaks conversion anymore
+ fld.className = 'editor_field';
+ if (this.options.submitOnBlur)
+ fld.onblur = this._boundSubmitHandler;
+ this._controls.editor = fld;
+ if (this.options.loadTextURL)
+ this.loadExternalText();
+ this._form.appendChild(this._controls.editor);
+ },
+ createForm: function() {
+ var ipe = this;
+ function addText(mode, condition) {
+ var text = ipe.options['text' + mode + 'Controls'];
+ if (!text || condition === false) return;
+ ipe._form.appendChild(document.createTextNode(text));
+ };
+ this._form = $(document.createElement('form'));
+ this._form.id = this.options.formId;
+ this._form.addClassName(this.options.formClassName);
+ this._form.onsubmit = this._boundSubmitHandler;
+ this.createEditField();
+ if ('textarea' == this._controls.editor.tagName.toLowerCase())
+ this._form.appendChild(document.createElement('br'));
+ if (this.options.onFormCustomization)
+ this.options.onFormCustomization(this, this._form);
+ addText('Before', this.options.okControl || this.options.cancelControl);
+ this.createControl('ok', this._boundSubmitHandler);
+ addText('Between', this.options.okControl && this.options.cancelControl);
+ this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');
+ addText('After', this.options.okControl || this.options.cancelControl);
+ },
+ destroy: function() {
+ if (this._oldInnerHTML)
+ this.element.innerHTML = this._oldInnerHTML;
+ this.leaveEditMode();
+ this.unregisterListeners();
+ },
+ enterEditMode: function(e) {
+ if (this._saving || this._editing) return;
+ this._editing = true;
+ this.triggerCallback('onEnterEditMode');
+ if (this.options.externalControl)
+ this.options.externalControl.hide();
+ this.element.hide();
+ this.createForm();
+ this.element.parentNode.insertBefore(this._form, this.element);
+ if (!this.options.loadTextURL)
+ this.postProcessEditField();
+ if (e) Event.stop(e);
+ },
+ enterHover: function(e) {
+ if (this.options.hoverClassName)
+ this.element.addClassName(this.options.hoverClassName);
+ if (this._saving) return;
+ this.triggerCallback('onEnterHover');
+ },
+ getText: function() {
+ return this.element.innerHTML;
+ },
+ handleAJAXFailure: function(transport) {
+ this.triggerCallback('onFailure', transport);
+ if (this._oldInnerHTML) {
+ this.element.innerHTML = this._oldInnerHTML;
+ this._oldInnerHTML = null;
+ }
+ },
+ handleFormCancellation: function(e) {
+ this.wrapUp();
+ if (e) Event.stop(e);
+ },
+ handleFormSubmission: function(e) {
+ var form = this._form;
+ var value = $F(this._controls.editor);
+ this.prepareSubmission();
+ var params = this.options.callback(form, value) || '';
+ if (Object.isString(params))
+ params = params.toQueryParams();
+ params.editorId = this.element.id;
+ if (this.options.htmlResponse) {
+ var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: params,
+ onComplete: this._boundWrapperHandler,
+ onFailure: this._boundFailureHandler
+ });
+ new Ajax.Updater({ success: this.element }, this.url, options);
+ } else {
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: params,
+ onComplete: this._boundWrapperHandler,
+ onFailure: this._boundFailureHandler
+ });
+ new Ajax.Request(this.url, options);
+ }
+ if (e) Event.stop(e);
+ },
+ leaveEditMode: function() {
+ this.element.removeClassName(this.options.savingClassName);
+ this.removeForm();
+ this.leaveHover();
+ this.element.setStyle({backgroundColor : this._originalBackground});
+ this.element.show();
+ if (this.options.externalControl)
+ this.options.externalControl.show();
+ this._saving = false;
+ this._editing = false;
+ this._oldInnerHTML = null;
+ this.triggerCallback('onLeaveEditMode');
+ },
+ leaveHover: function(e) {
+ if (this.options.hoverClassName)
+ this.element.removeClassName(this.options.hoverClassName);
+ if (this._saving) return;
+ this.triggerCallback('onLeaveHover');
+ },
+ loadExternalText: function() {
+ this._form.addClassName(this.options.loadingClassName);
+ this._controls.editor.disabled = true;
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: 'editorId=' + encodeURIComponent(this.element.id),
+ onComplete: Prototype.emptyFunction,
+ onSuccess: function(transport) {
+ this._form.removeClassName(this.options.loadingClassName);
+ var text = transport.responseText;
+ if (this.options.stripLoadedTextTags)
+ text = text.stripTags();
+ this._controls.editor.value = text;
+ this._controls.editor.disabled = false;
+ this.postProcessEditField();
+ }.bind(this),
+ onFailure: this._boundFailureHandler
+ });
+ new Ajax.Request(this.options.loadTextURL, options);
+ },
+ postProcessEditField: function() {
+ var fpc = this.options.fieldPostCreation;
+ if (fpc)
+ $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();
+ },
+ prepareOptions: function() {
+ this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
+ Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
+ [this._extraDefaultOptions].flatten().compact().each(function(defs) {
+ Object.extend(this.options, defs);
+ }.bind(this));
+ },
+ prepareSubmission: function() {
+ this._saving = true;
+ this.removeForm();
+ this.leaveHover();
+ this.showSaving();
+ },
+ registerListeners: function() {
+ this._listeners = { };
+ var listener;
+ $H(Ajax.InPlaceEditor.Listeners).each(function(pair) {
+ listener = this[pair.value].bind(this);
+ this._listeners[pair.key] = listener;
+ if (!this.options.externalControlOnly)
+ this.element.observe(pair.key, listener);
+ if (this.options.externalControl)
+ this.options.externalControl.observe(pair.key, listener);
+ }.bind(this));
+ },
+ removeForm: function() {
+ if (!this._form) return;
+ this._form.remove();
+ this._form = null;
+ this._controls = { };
+ },
+ showSaving: function() {
+ this._oldInnerHTML = this.element.innerHTML;
+ this.element.innerHTML = this.options.savingText;
+ this.element.addClassName(this.options.savingClassName);
+ this.element.setStyle({backgroundColor: this._originalBackground});
+ this.element.show();
+ },
+ triggerCallback: function(cbName, arg) {
+ if ('function' == typeof this.options[cbName]) {
+ this.options[cbName](this, arg);
+ }
+ },
+ unregisterListeners: function() {
+ $H(this._listeners).each(function(pair) {
+ if (!this.options.externalControlOnly)
+ this.element.stopObserving(pair.key, pair.value);
+ if (this.options.externalControl)
+ this.options.externalControl.stopObserving(pair.key, pair.value);
+ }.bind(this));
+ },
+ wrapUp: function(transport) {
+ this.leaveEditMode();
+ // Can't use triggerCallback due to backward compatibility: requires
+ // binding + direct element
+ this._boundComplete(transport, this.element);
+ }
+});
+
+Object.extend(Ajax.InPlaceEditor.prototype, {
+ dispose: Ajax.InPlaceEditor.prototype.destroy
+});
+
+Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
+ initialize: function($super, element, url, options) {
+ this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
+ $super(element, url, options);
+ },
+
+ createEditField: function() {
+ var list = document.createElement('select');
+ list.name = this.options.paramName;
+ list.size = 1;
+ this._controls.editor = list;
+ this._collection = this.options.collection || [];
+ if (this.options.loadCollectionURL)
+ this.loadCollection();
+ else
+ this.checkForExternalText();
+ this._form.appendChild(this._controls.editor);
+ },
+
+ loadCollection: function() {
+ this._form.addClassName(this.options.loadingClassName);
+ this.showLoadingText(this.options.loadingCollectionText);
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: 'editorId=' + encodeURIComponent(this.element.id),
+ onComplete: Prototype.emptyFunction,
+ onSuccess: function(transport) {
+ var js = transport.responseText.strip();
+ if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
+ throw('Server returned an invalid collection representation.');
+ this._collection = eval(js);
+ this.checkForExternalText();
+ }.bind(this),
+ onFailure: this.onFailure
+ });
+ new Ajax.Request(this.options.loadCollectionURL, options);
+ },
+
+ showLoadingText: function(text) {
+ this._controls.editor.disabled = true;
+ var tempOption = this._controls.editor.firstChild;
+ if (!tempOption) {
+ tempOption = document.createElement('option');
+ tempOption.value = '';
+ this._controls.editor.appendChild(tempOption);
+ tempOption.selected = true;
+ }
+ tempOption.update((text || '').stripScripts().stripTags());
+ },
+
+ checkForExternalText: function() {
+ this._text = this.getText();
+ if (this.options.loadTextURL)
+ this.loadExternalText();
+ else
+ this.buildOptionList();
+ },
+
+ loadExternalText: function() {
+ this.showLoadingText(this.options.loadingText);
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: 'editorId=' + encodeURIComponent(this.element.id),
+ onComplete: Prototype.emptyFunction,
+ onSuccess: function(transport) {
+ this._text = transport.responseText.strip();
+ this.buildOptionList();
+ }.bind(this),
+ onFailure: this.onFailure
+ });
+ new Ajax.Request(this.options.loadTextURL, options);
+ },
+
+ buildOptionList: function() {
+ this._form.removeClassName(this.options.loadingClassName);
+ this._collection = this._collection.map(function(entry) {
+ return 2 === entry.length ? entry : [entry, entry].flatten();
+ });
+ var marker = ('value' in this.options) ? this.options.value : this._text;
+ var textFound = this._collection.any(function(entry) {
+ return entry[0] == marker;
+ }.bind(this));
+ this._controls.editor.update('');
+ var option;
+ this._collection.each(function(entry, index) {
+ option = document.createElement('option');
+ option.value = entry[0];
+ option.selected = textFound ? entry[0] == marker : 0 == index;
+ option.appendChild(document.createTextNode(entry[1]));
+ this._controls.editor.appendChild(option);
+ }.bind(this));
+ this._controls.editor.disabled = false;
+ Field.scrollFreeActivate(this._controls.editor);
+ }
+});
+
+//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! ****
+//**** This only exists for a while, in order to let ****
+//**** users adapt to the new API. Read up on the new ****
+//**** API and convert your code to it ASAP! ****
+
+Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {
+ if (!options) return;
+ function fallback(name, expr) {
+ if (name in options || expr === undefined) return;
+ options[name] = expr;
+ };
+ fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :
+ options.cancelLink == options.cancelButton == false ? false : undefined)));
+ fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :
+ options.okLink == options.okButton == false ? false : undefined)));
+ fallback('highlightColor', options.highlightcolor);
+ fallback('highlightEndColor', options.highlightendcolor);
+};
+
+Object.extend(Ajax.InPlaceEditor, {
+ DefaultOptions: {
+ ajaxOptions: { },
+ autoRows: 3, // Use when multi-line w/ rows == 1
+ cancelControl: 'link', // 'link'|'button'|false
+ cancelText: 'cancel',
+ clickToEditText: 'Click to edit',
+ externalControl: null, // id|elt
+ externalControlOnly: false,
+ fieldPostCreation: 'activate', // 'activate'|'focus'|false
+ formClassName: 'inplaceeditor-form',
+ formId: null, // id|elt
+ highlightColor: '#ffff99',
+ highlightEndColor: '#ffffff',
+ hoverClassName: '',
+ htmlResponse: true,
+ loadingClassName: 'inplaceeditor-loading',
+ loadingText: 'Loading...',
+ okControl: 'button', // 'link'|'button'|false
+ okText: 'ok',
+ paramName: 'value',
+ rows: 1, // If 1 and multi-line, uses autoRows
+ savingClassName: 'inplaceeditor-saving',
+ savingText: 'Saving...',
+ size: 0,
+ stripLoadedTextTags: false,
+ submitOnBlur: false,
+ textAfterControls: '',
+ textBeforeControls: '',
+ textBetweenControls: ''
+ },
+ DefaultCallbacks: {
+ callback: function(form) {
+ return Form.serialize(form);
+ },
+ onComplete: function(transport, element) {
+ // For backward compatibility, this one is bound to the IPE, and passes
+ // the element directly. It was too often customized, so we don't break it.
+ new Effect.Highlight(element, {
+ startcolor: this.options.highlightColor, keepBackgroundImage: true });
+ },
+ onEnterEditMode: null,
+ onEnterHover: function(ipe) {
+ $(ipe.element).setStyle({backgroundColor : ipe.options.highlightColor});
+ if (ipe._effect)
+ ipe._effect.cancel();
+ },
+ onFailure: function(transport, ipe) {
+ alert('Error communication with the server: ' + transport.responseText.stripTags());
+ },
+ onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
+ onLeaveEditMode: null,
+ onLeaveHover: function(ipe) {
+ ipe._effect = new Effect.Highlight(ipe.element, {
+ startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
+ restorecolor: ipe._originalBackground, keepBackgroundImage: true
+ });
+ }
+ },
+ Listeners: {
+ click: 'enterEditMode',
+ keydown: 'checkForEscapeOrReturn',
+ mouseover: 'enterHover',
+ mouseout: 'leaveHover'
+ }
+});
+
+Ajax.InPlaceCollectionEditor.DefaultOptions = {
+ loadingCollectionText: 'Loading options...'
+};
+
+// Delayed observer, like Form.Element.Observer,
+// but waits for delay after last key input
+// Ideal for live-search fields
+
+Form.Element.DelayedObserver = Class.create({
+ initialize: function(element, delay, callback) {
+ this.delay = delay || 0.5;
+ this.element = $(element);
+ this.callback = callback;
+ this.timer = null;
+ this.lastValue = $F(this.element);
+ Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
+ },
+ delayedListener: function(event) {
+ if(this.lastValue == $F(this.element)) return;
+ if(this.timer) clearTimeout(this.timer);
+ this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
+ this.lastValue = $F(this.element);
+ },
+ onTimerEvent: function() {
+ this.timer = null;
+ this.callback(this.element, $F(this.element));
+ }
+});
Index: openacs-4/packages/messages/www/resources/delete-dialog.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/delete-dialog.js,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/resources/delete-dialog.js 31 Aug 2010 21:30:50 -0000 1.1
@@ -0,0 +1,57 @@
+//----------------- dialog delete
+
+YAHOO.namespace("delete_msg.container");
+function init_delete() {
+ // Define various event handlers for Dialog
+ var handleYes = function() {
+ document.getElementById('msg_system').style.display = 'none';
+ var formObject = document.getElementsByName('messages_list');
+ var form = formObject[0];
+ var elements = form.elements;
+ var break_p = 0;
+ for ( var i = 0; i < elements.length ; i++){
+ if (elements[i].name == 'subject_id' && elements[i].checked) {
+ break_p = 1;
+ break;
+ }
+ }
+ if (break_p) {
+ document.getElementById('msg_action_p').value = 't';
+ move_to(3);
+ this.hide();
+ } else {
+ document.getElementById('msg_action_p').value = 'f';
+ document.getElementById('msg_action').style.display = '';
+ document.getElementById('msg_actions').innerHTML = document.getElementById('msg_select_msg').value;
+ var folder_id_state = document.getElementById('folder_id').value;
+ if (document.getElementById('folder_id_state') != null ) {
+ var folder_id_state = document.getElementById('folder_id_state').value;
+ }
+ get_messages_folder('more_actions');
+ this.hide();
+ }
+ };
+ var handleNo = function() {
+ document.getElementById('msg_system').style.display = 'none';
+ this.hide();
+ };
+
+ // Instantiate the Dialog
+ YAHOO.delete_msg.container.delete_dialog = new YAHOO.widget.SimpleDialog("delete_dialog",
+ { modal: true,
+ visible: false,
+ fixedcenter: true,
+ constraintoviewport: true,
+ iframe: true,
+ close: false,
+ width: "300px",
+ text: document.getElementById('delete_confirm').value,
+ buttons: [ { text:document.getElementById('msg_yes').value, handler:handleYes, isDefault:true },
+ { text:"No", handler:handleNo } ]
+ } );
+ // Render the Dialog
+ YAHOO.delete_msg.container.delete_dialog.render("container");
+ YAHOO.util.Event.addListener("show_delete", "click", YAHOO.delete_msg.container.delete_dialog.show, null,YAHOO.delete_msg.container.delete_dialog);
+}
+
+YAHOO.util.Event.addListener(window, "load", init_delete);
\ No newline at end of file
Index: openacs-4/packages/messages/www/resources/dispatcher-min.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/messages/www/resources/dispatcher-min.js,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/messages/www/resources/dispatcher-min.js 31 Aug 2010 21:30:52 -0000 1.1
@@ -0,0 +1,8 @@
+/*
+Copyright (c) 2008, Bubbling Library Team. All rights reserved.
+Portions Copyright (c) 2008, Yahoo!, Inc. All rights reserved.
+Code licensed under the BSD License:
+http://www.bubbling-library.com/eng/licence
+version: 2.1
+*/
+YAHOO.namespace("plugin");(function(){var I=YAHOO.util.Connect,D=YAHOO.lang,F=YAHOO.util.Event,H=YAHOO.util.Dom,E=YAHOO.util.Dom.get;var N={LOADING:1,DISPATCHED:2,ERROR:3,EMPTY:4,proxy:"/dispatcher.php?uri=",CSSNODE:1,JSNODE:2};var L=/