Commit 2ea26ac6 authored by Frank Bergmann's avatar Frank Bergmann

- committing changes after merge with b2-0

parent e62444c2
Pipeline #259 failed with stages
......@@ -8,17 +8,18 @@
<singleton-p>t</singleton-p>
<auto-mount>intranet-forum</auto-mount>
<version name="2.0.1" url="http://openacs.org/repository/download/apm/intranet-forum-2.0.1.apm">
<version name="2.1.1" url="http://openacs.org/repository/download/apm/intranet-forum-2.1.1.apm">
<owner url="mailto:fraber@fraber.de">Frank Bergmann</owner>
<vendor url="http://www.project-open.com/">Project/Open</vendor>
<provides url="intranet-forum" version="2.0.1"/>
<requires url="intranet-core" version="2.0.0"/>
<provides url="intranet-forum" version="2.1.1"/>
<requires url="intranet-core" version="2.1.0"/>
<callbacks>
</callbacks>
<parameters>
<!-- No version parameters -->
<parameter datatype="number" min_n_values="1" max_n_values="1" name="SubscribeAllMembersToNewItemsP" default="1" description="SubscribeAllMembersToNewItemsP"/>
</parameters>
</version>
......
......@@ -733,26 +733,32 @@ insert into im_views (view_id, view_name, visible_for) values (45, 'forum_list_c
-- ForumList for home page
--
delete from im_view_columns where column_id >= 4000 and column_id < 4099;
insert into im_view_columns values (4000,40,NULL,'P',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4000,40,NULL,'P',
'$priority','','',2,'');
insert into im_view_columns values (4002,40,NULL,'Type',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4002,40,NULL,'Type',
'"<a href=/intranet-forum/view?[export_url_vars topic_id return_url]>\
[im_gif $topic_type]</a>"',
'','',4,'');
insert into im_view_columns values (4003,40,NULL,'Object',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4003,40,NULL,'Object',
'"<a href=$object_view_url$object_id>$object_name</a>"',
'','',5,'');
insert into im_view_columns values (4004,40,NULL,'Subject',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4004,40,NULL,'Subject',
'"<a href=/intranet-forum/view?[export_url_vars topic_id return_url]>\
$subject</a>"','','',6,'');
insert into im_view_columns values (4006,40,NULL,'Due',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4006,40,NULL,'Due',
'$due_date','','',8,'');
insert into im_view_columns values (4010,40,NULL,
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4010,40,NULL,
'"[im_gif help "Select topics here for processing"]"',
'"<input type=checkbox name=topic_id.$topic_id>"',
'','',12,'');
......@@ -764,30 +770,37 @@ commit;
-- ForumList for ProjectViewPage or CustomerViewPage
--
delete from im_view_columns where column_id >= 4100 and column_id < 4199;
insert into im_view_columns values (4100,41,NULL,'P',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4100,41,NULL,'P',
'$priority','','',2,'');
insert into im_view_columns values (4102,41,NULL,'Type',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4102,41,NULL,'Type',
'"<a href=/intranet-forum/view?[export_url_vars topic_id return_url]>\
[im_gif $topic_type]</a>"',
'','',4,'');
insert into im_view_columns values (4104,41,NULL,'Subject',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4104,41,NULL,'Subject',
'"<a href=/intranet-forum/view?[export_url_vars topic_id return_url]>\
$subject</a>"','','',6,'');
insert into im_view_columns values (4106,41,NULL,'Due',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4106,41,NULL,'Due',
'$due_date','','',8,'');
insert into im_view_columns values (4107,41,NULL,'Own',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4107,41,NULL,'Own',
'"<a href=/intranet/users/view?user_id=$owner_id>$owner_initials</a>"',
'','',9,'');
insert into im_view_columns values (4108,41,NULL,'Ass',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4108,41,NULL,'Ass',
'"<a href=/intranet/users/view?user_id=$asignee_id>$asignee_initials</a>"',
'','',10,'');
insert into im_view_columns values (4110,41,NULL,
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4110,41,NULL,
'"[im_gif help "Select topics here for processing"]"',
'"<input type=checkbox name=topic_id.$topic_id>"',
'','',12,'');
......@@ -798,45 +811,56 @@ commit;
-- ForumList for the forum index page (all projects with a lot of space)
--
delete from im_view_columns where column_id >= 4200 and column_id < 4299;
insert into im_view_columns values (4200,42,NULL,'P',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4200,42,NULL,'P',
'$priority','','',2,'');
insert into im_view_columns values (4201,42,NULL,'Object',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4201,42,NULL,'Object',
'"<a href=$object_view_url$object_id>$object_name</a>"',
'','',3,'');
insert into im_view_columns values (4202,42,NULL,'Type',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4202,42,NULL,'Type',
'"<a href=/intranet-forum/view?[export_url_vars topic_id return_url]>\
[im_gif $topic_type]</a>"',
'','',4,'');
insert into im_view_columns values (4204,42,NULL,'Subject',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4204,42,NULL,'Subject',
'"<a href=/intranet-forum/view?[export_url_vars topic_id return_url]>\
$subject</A>"','','',6,'');
insert into im_view_columns values (4206,42,NULL,'Due',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4206,42,NULL,'Due',
'$due_date','','',8,'');
insert into im_view_columns values (4207,42,NULL,'Own',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4207,42,NULL,'Own',
'"<a href=/intranet/users/view?user_id=$owner_id>$owner_initials</a>"',
'','',9,'');
insert into im_view_columns values (4208,42,NULL,'Ass',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4208,42,NULL,'Ass',
'"<a href=/intranet/users/view?user_id=$asignee_id>$asignee_initials</a>"',
'','',10,'');
insert into im_view_columns values (4209,42,NULL,'Status',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4209,42,NULL,'Status',
'$topic_status','','',11,'');
insert into im_view_columns values (42010,42,NULL,'Read',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (42010,42,NULL,'Read',
'$read','','',12,'');
insert into im_view_columns values (4210,42,NULL,
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4210,42,NULL,
'"[im_gif help "Select topics here for processing"]"',
'"<input type=checkbox name=topic_id.$topic_id>"',
'','',13,'');
insert into im_view_columns values (4212,42,NULL,'Folder',
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (4212,42,NULL,'Folder',
'$folder_name','','',14,'');
commit;
......
......@@ -29,6 +29,21 @@ ad_proc -public im_topic_type_id_incident { } { return 1104 }
ad_proc -public im_topic_type_id_reply { } { return 1190 }
ad_proc -public im_package_forum_id {} {
Returns the package id of the intranet-forum module
} {
return [util_memoize "im_package_forum_id_helper"]
}
ad_proc -private im_package_forum_id_helper {} {
return [db_string im_package_core_id {
select package_id from apm_packages
where package_key = 'intranet-forum'
} -default 0]
}
ad_proc -public im_forum_is_task_or_incident { topic_type_id } {
Returns 1 if it's a "Task" or "Incident"
} {
......@@ -346,6 +361,7 @@ ad_proc -public im_forum_render_tind {
subject message
posting_date due_date
priority scope
receive_updates
return_url
} {
Render the rows of a single TIND
......@@ -489,6 +505,15 @@ ad_proc -public im_forum_render_tind {
</td>
</tr>"
incr ctr
# Show whether the user has subscribed to updates
append tind_html "
<tr $bgcolor([expr $ctr % 2])>
<td>Receive updates</td>
<td>$receive_updates
</td>
</tr>"
incr ctr
}
# Only allow plain text messages
......@@ -584,7 +609,11 @@ where
append thread_html "
<td colspan=$colspan_level>
<table border=0 cellpadding=0 bgcolor=#E0E0E0>"
append thread_html " [im_forum_render_tind $topic_id 0 $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $object_id $object_name $object_admin $subject $message $posting_date $due_date $priority $scope $return_url]
# don't show received updates for everything but the main message
set receive_updates ""
append thread_html " [im_forum_render_tind $topic_id 0 $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $object_id $object_name $object_admin $subject $message $posting_date $due_date $priority $scope $receive_updates $return_url]
</table>
</td>
......@@ -940,7 +969,7 @@ $order_by_clause"
append table_body_html "
<tr><td colspan=$colspan>&nbsp;</td></tr>
<tr><td class=rowtitle colspan=$colspan>
<A href=/intranet/projects/view?group_id=$object_id>
<A href=/intranet/projects/view?project_id=$object_id>
$object_name
</A>
</td></tr>\n"
......@@ -974,7 +1003,8 @@ $order_by_clause"
# This means that there are rows that we decided not to return
# Include a link to go to the next page
set next_start_idx [expr $end_idx + 1]
set next_page_html "($remaining_items more) <A href=$current_page_url?$pass_through_vars_html&start_idx=$next_start_idx>&gt;&gt;</a>"
set forum_max_entries_per_page [expr 10*$max_entries_per_page]
set next_page_html "($remaining_items more) <A href=\"/intranet-forum/index?forum_object_id=$object_id&forum_max_entries_per_page=$forum_max_entries_per_page\">&gt;&gt;</a>"
} else {
set next_page_html ""
}
......
......@@ -135,7 +135,7 @@ set page_body "
<table cellspacing=1 border=0 cellpadding=1>
[im_forum_render_tind $topic_id $parent_id $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $object_id $object_name $object_admin $subject $message $posting_date $due_date $priority $scope $return_url]
[im_forum_render_tind $topic_id $parent_id $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $object_id $object_name $object_admin $subject $message $posting_date $due_date $priority $scope $receive_updates $return_url]
<tr><td colspan=2>&nbsp;</td></tr>
$table_body
......
......@@ -23,6 +23,7 @@ ad_page_contract {
@author frank.bergmann@project-open.com
} {
{ forum_object_id 0 }
{ forum_order_by "Project" }
{ forum_view_name "forum_list_forum" }
{ forum_mine_p "f" }
......@@ -32,6 +33,7 @@ ad_page_contract {
{ forum_start_idx:integer "1" }
{ forum_how_many 0 }
{ forum_folder 0 }
{ forum_max_entries_per_page 0 }
}
# ---------------------------------------------------------------
......@@ -139,7 +141,7 @@ set restrict_to_new_topics 0
set forum_content [im_forum_component \
-user_id $user_id \
-object_id 0 \
-object_id $forum_object_id \
-forum_type home \
-current_page_url $current_url \
-return_url $return_url \
......@@ -149,6 +151,7 @@ set forum_content [im_forum_component \
-restrict_to_mine_p $forum_mine_p \
-restrict_to_folder $forum_folder \
-restrict_to_new_topics 0 \
-max_entries_per_page $forum_max_entries_per_page \
]
# ---------------------------------------------------------------
......
......@@ -140,22 +140,26 @@ if {[string equal $actions "save"]} {
if {!$exists_p} {
# Create an empty entry -
# Details are added at the insert below
db_transaction {
db_dml topic_insert "
insert into im_forum_topics (
topic_id, object_id, topic_type_id, topic_status_id, owner_id, subject
) values (
:topic_id, :object_id, :topic_type_id, :topic_status_id, :owner_id, :subject
)"
} on_error {
db_dml topic_insert {
insert into im_forum_topics (
topic_id, object_id, topic_type_id,
topic_status_id, owner_id, subject
) values (
:topic_id, :object_id, :topic_type_id,
:topic_status_id, :owner_id, :subject
)
}
} on_error {
ad_return_error "Error adding a new topic" "
The database rejected the addition of discussion topic
\"$subject\". Here the error message: <pre>$errmsg\n</pre>\n"
return
}
}
}
# update the information
db_transaction {
db_dml topic_update "
......@@ -180,7 +184,6 @@ where topic_id=:topic_id"
return
}
# im_forum_topics_user_map may or may not exist for every user.
# So we create a record just in case, even if the SQL fails.
db_transaction {
......@@ -192,6 +195,7 @@ where topic_id=:topic_id"
# nothing - may already exist...
}
# Now let's update the existing entry
db_transaction {
db_dml im_forum_topic_user_map_update "
......@@ -211,6 +215,89 @@ where
}
# ---------------------------------------------------------------------
# New Message: Subscribe all current project members
# ---------------------------------------------------------------------
# Only if we are creating a new message...
ns_log Notice "/intranet-forum/new-2: action_type=$action_type"
if {[string equal $action_type "new_message"]} {
# .. and only if the parameter is enabled...
if {[ad_parameter -package_id [im_package_forum_id] SubscribeAllMembersToNewItemsP "" "0"]} {
ns_log Notice "/intranet-forum/new-2: subscribing all project members to the new message"
# Select the list of all project members allowed to see
# see the new TIND.
#
set object_member_sql "
select
p.party_id as user_id
from
acs_rels r,
parties p,
(select m.member_id as user_id,
1 as p
from group_distinct_member_map m
where m.group_id = [im_customer_group_id]
) customers,
(select m.member_id as user_id,
1 as p
from group_distinct_member_map m
where m.group_id = [im_employee_group_id]
) employees,
-- get the members and admins of object_id
( select 1 as member_p,
decode (m.object_role_id,
1301, 1,
1302, 1,
1303, 1,
0
) as admin_p,
r.object_id_two as user_id
from acs_rels r,
im_biz_object_members m
where r.object_id_one = :object_id
and r.rel_id = m.rel_id
) o_mem
where
r.object_id_one = :object_id
and r.object_id_two = p.party_id
and p.party_id = customers.user_id(+)
and p.party_id = employees.user_id(+)
and o_mem.user_id = p.party_id
and 1 = im_forum_permission(
p.party_id,
:user_id,
:asignee_id,
:object_id,
:scope,
o_mem.member_p,
o_mem.admin_p,
employees.p,
customers.p
)"
db_foreach subscribe_object_members $object_member_sql {
ns_log Notice "intranet-forum/new-2: subscribe user\#$user_id to message\#$topic_id in object\#$object_id"
# im_forum_topics_user_map may or may not exist for every user.
# So we create a record just in case, even if the SQL fails.
db_transaction {
db_dml im_forum_topic_user_map_insert "
insert into im_forum_topic_user_map
(topic_id, user_id, read_p, folder_id, receive_updates) values
(:topic_id, :user_id, :read_p, :folder_id, 'all')
"
} on_error {
# nothing - may already exist...
}
}
}
}
# ---------------------------------------------------------------------
# Assign the ticket to a new user
# ---------------------------------------------------------------------
......@@ -324,13 +411,14 @@ where topic_id=:topic_id"
# Alert about changes
# ---------------------------------------------------------------------
set msg_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemURL "" ""]/intranet-forum/view?topic_id=$topic_id"
set msg_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemURL "" ""]intranet-forum/view?topic_id=$topic_id"
set importance 0
db_1row subject_message "
select
t.subject,
t.message,
t.parent_id,
im_category_from_id(t.topic_type_id) as topic_type
from
im_forum_topics t
......@@ -338,59 +426,114 @@ where
t.topic_id = :topic_id
"
# Check for the root-parent message in order to determine
# whethter the user has subscribed to it or not.
set ctr 0
while {"" != $parent_id && 0 != $parent_id && $ctr < 10} {
ns_log Notice "intranet-forum/new-2: looking up parent $parent_id of topic $topic_id"
# avoid infinite loops...
incr ctr
set lookup_parent_sql "
select
t.topic_id,
t.parent_id
from
im_forum_topics t
where
t.topic_id = :parent_id
"
db_0or1row lookup_parent $lookup_parent_sql
}
# Determine whether the update was "important" or not
# 0=none, 1=non-important, 2=important
#
switch $actions {
"accept" {
set action_type_found 0
switch $action_type {
"new_message" {
set action_type_found 1
set importance 2
set subject "New $topic_type: $subject"
set message "
A new $topic_type has been created.
Please visit the link above for details.\n"
}
"edit_message" {
set action_type_found 1
set importance 1
set subject "Changed $topic_type: $subject"
set message "
A $topic_type has been modified.
Please visit the link above for details.\n"
}
"reply_message" {
set action_type_found 1
set importance 1
set subject "Accepted $topic_type: $subject"
set subject "Reply to $topic_type: $subject"
set message "
A $topic_type reply has been created.
Please visit the link above for details.\n"
}
}
if {!$action_type_found} {
switch $actions {
"accept" {
set importance 1
set subject "Accepted $topic_type: $subject"
set message "
The $topic_type has been accepted by the asignee.
Please visit the link above for details.
"
}
"reject" {
set importance 2
set subject "Rejected $topic_type: $subject"
set message "
}
"reject" {
set importance 2
set subject "Rejected $topic_type: $subject"
set message "
The $topic_type has been rejected by the asignee.
Please visit the link above for details.
"
}
"clarify" {
set importance 2
set subject "$topic_type needs clarification: $subject"
set message "
}
"clarify" {
set importance 2
set subject "$topic_type needs clarification: $subject"
set message "
The asignee of the $topic_type needs clarification.
Please visit the link above for details.
"
}
"save" {
set importance 1
set subject "Modified $topic_type: $subject"
set message "
}
"save" {
set importance 1
set subject "Modified $topic_type: $subject"
set message "
The $topic_type has been modified or replied to.
Please visit the link above for details.
"
}
"close" {
set importance 2
set subject "Closed $topic_type: $subject"
set message "
}
"close" {
set importance 2
set subject "Closed $topic_type: $subject"
set message "
The $topic_type has been closed.
Please visit the link above for details.
"
}
"assign" {
set importance 1
set subject "Assigned $topic_type: $subject"
set message "
}
"assign" {
set importance 1
set subject "Assigned $topic_type: $subject"
set message "
The $topic_type has been assigned to a new asignee.
Please visit the link above for details.
"
}
}
}
......
# /packages/intranet-forum/www/intranet-forum/forum/new-tind-2.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
process a new topic form submission
@param receive_updates:
all, none, major (=issue resolved, task done)
@param actions:
accept, reject, clarify, close
@action_type:
new_message, edit_message, undefined, reply_message
@author frank.bergmann@project-open.com
} {
action_type
{actions ""}
{comments:trim ""}
owner_id:integer
old_asignee_id:integer
object_id:integer
topic_id:integer
parent_id:integer
{topic_type_id 0}
{topic_status_id 0}
{old_topic_status_id 0}
{scope "pm"}
{subject:trim}
{message:trim}
{priority "5"}
{asignee_id ""}
{due_date:array,date ""}
{receive_updates "major"}
{read_p "f"}
{folder_id "0"}
return_url
{submit_save ""}
{submit_close ""}
{submit_accept ""}
{submit_reject ""}
{submit_clarify ""}
}
# ------------------------------------------------------------------
# Security, Parameters & Default
# ------------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set exception_text ""
set exception_count 0
if { ![info exists subject] || $subject == "" } {
append exception_text "<li>You must enter a subject line"
incr exception_count
}
if { [info exists subject] && [string match {*\"*} $subject] } {
append exception_text "<li>Your topic name cannot include string quotes. It makes life too difficult for this collection of software."
incr exception_count
}
# check for not null start date
if { [info exists due_date(date) ] } {
set due $due_date(date)
} else {
set due ""
}
if { $exception_count> 0 } {
ad_return_complaint $exception_count $exception_text
return 0
}
# Only incidents and tasks have priority, status, asignees and
# due_dates
#
set task_or_incident_p 0
if {$topic_type_id == 1102 || $topic_type_id == 1104} {
set task_or_incident_p 1
}
if {"" != $comments} {
set user_name [db_string get_user_name "select im_name_from_user_id(:user_id) from dual"]
set today_date [db_string get_today_date "select sysdate from dual"]
append message "\n\n\[Comment from $user_name on $today_date\]:\n$comments"
}
# ---------------------------------------------------------------------
# Reply to the topic
# ---------------------------------------------------------------------
if {[string equal $actions "reply"]} {
ad_returnredirect "/intranet-forum/new-tind"
}
# ------------------------------------------------------------------
# Save the im_forum_topics record
# ------------------------------------------------------------------
if {[string equal $action_type "new_message"] || [string equal $action_type "reply_message"]} {
# We are creating a new item
db_transaction {
db_dml topic_insert "
insert into im_forum_topics (
topic_id, object_id, parent_id, topic_type_id, topic_status_id,
posting_date, owner_id, scope, subject, message, priority,
asignee_id, due_date
) values (
:topic_id, :object_id, :parent_id, :topic_type_id, :topic_status_id,
sysdate, :owner_id, :scope, :subject, :message, :priority,
:asignee_id, :due
)"
} on_error {
ad_return_error "Error adding a new topic" "
The database rejected the addition of discussion topic
\"$subject\". Here the error message: <pre>$errmsg\n</pre>\n"
}
} else {
# We are modifying an existing item
db_transaction {
db_dml topic_update "
update im_forum_topics set
object_id=:object_id,
parent_id=:parent_id,
topic_type_id=:topic_type_id,
topic_status_id=:topic_status_id,
posting_date=sysdate,
owner_id=:owner_id,
scope=:scope,
subject=:subject,
message=:message,
priority=:priority,
asignee_id=:asignee_id,
due_date=:due
where topic_id=:topic_id"
} on_error {
ad_return_error "Error modifying a topic" "
The database rejected the modification of a of discussion topic
\"$subject\". Here the error message: <pre>$errmsg\n</pre>\n"
}
}
# ---------------------------------------------------------------------
# Save the im_forum_topic_user_map record
# ---------------------------------------------------------------------
# im_forum_topics_user_map may or may not exist for every user.
# So we create a record just in case, even if the SQL fails.
db_transaction {
db_dml im_forum_topic_user_map_insert "
insert into im_forum_topic_user_map
(topic_id, user_id, read_p, folder_id, receive_updates) values
(:topic_id, :user_id, :read_p, :folder_id, :receive_updates)"
} on_error {
# nothing - may already exist...
}
# Now let's update the existing entry
db_transaction {
db_dml im_forum_topic_user_map_update "
update im_forum_topic_user_map set
read_p=:read_p,
folder_id=:folder_id,
receive_updates=:receive_updates
where
topic_id=:topic_id
and user_id=:user_id"
} on_error {
ad_return_error "Error modifying a im_forum_topic_user_map" "
The database rejected the modification of a of discussion topic
\"$subject\". Here the error message: <pre>$errmsg\n</pre>\n"
}
# ---------------------------------------------------------------------
# Alert about asignee_changes
# ---------------------------------------------------------------------
ns_log Notice "new-tind-2: asignee_id=$asignee_id, old_asignee_id=$old_asignee_id"
# Inform the asignee that he has got a new task/incident
#
if {$asignee_id != $old_asignee_id} {
# Always send a mail to a new asignee
#
set msg_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemUrl "" ""]"
append msg_url "/intranet-forum/view?topic_id=$topic_id"
set topic_type [db_string topic_type "select category from im_categories where category_id=:topic_type_id"]
set msg_subject "New $topic_type: $subject"
# im_send_alert $asignee_id "hourly" $msg_url $msg_subject $message
###!!! ToDo: enable alerts
# Inform the owner about the change except if it iss a client
# or if it is someone who
}
# ---------------------------------------------------------------------
# Close the ticket
# ---------------------------------------------------------------------
if {[string equal $actions "close"]} {
# ToDo: Security Check
# Close the existing ticket.
set topic_status_id [im_topic_status_id_closed]
db_transaction {
db_dml topic_close "
update im_forum_topics set topic_status_id = :topic_status_id
where topic_id=:topic_id"
} on_error {
ad_return_error "Error modifying a topic" "
Error closing \"$subject\": <pre>$errmsg\n</pre>\n"
}
# Send a mail to all subscribed users
#
set stakeholder_sql "
select user_id
from im_forum_topic_user_map m
where m.topic_id=:topic_id
and receive_updates <> 'none'
"
db_foreach update_stakeholders $stakeholder_sql {
set msg_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemUrl "" ""]"
append msg_url "/intranet-forum/view?topic_id=$topic_id"
set topic_type [db_string topic_type "select category from im_categories where category_id=:topic_type_id"]
set msg_subject "Closed $topic_type: $subject"
im_send_alert $asignee_id "hourly" $msg_subject "msg_url\n\n$message"
}
}
# ---------------------------------------------------------------------
# Accept the ticket
# ---------------------------------------------------------------------
if {[string equal $actions "accept"]} {
# ToDo: Security Check
# Set the status to "accepted"
set topic_status_id [im_topic_status_id_accepted]
db_transaction {
db_dml topic_close "
update im_forum_topics set topic_status_id = :topic_status_id
where topic_id=:topic_id"
} on_error {
ad_return_error "Error modifying a topic" "
Error closing \"$subject\": <pre>$errmsg\n</pre>\n"
}
# Send email notifications only to "all changes".
#
set stakeholder_sql "
select user_id
from im_forum_topic_user_map m
where m.topic_id=:topic_id
and receive_updates='all'
"
db_foreach update_stakeholders $stakeholder_sql {
set msg_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemUrl "" ""]"
append msg_url "/intranet-forum/view?topic_id=$topic_id"
set topic_type [db_string topic_type "select category from im_categories where category_id=:topic_type_id"]
set msg_subject "Accepted $topic_type: $subject"
im_send_alert $asignee_id "hourly" $msg_subject "$msg_url\n\n$message"
}
}
db_release_unused_handles
ad_returnredirect $return_url
This diff is collapsed.
......@@ -297,8 +297,6 @@ incr ctr
# don't have a group (project) assigned. So we have to do
# that here:
set project_status_open [im_project_status_open]
if {$object_id == 0} {
append table_body "
<tr $bgcolor([expr $ctr % 2])>
......
# /packages/intranet-forum/www/intranet/forum/view-tind.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Create a new Task, Incident, News or Discussion (TIND)
@param topic_id: Message to refer to
@param display_style:
topic = full topic (subject+message), no subtopics
thread = complete tree of subjects
topic_thread = full topic plus subtopics subjects
full = topic+all subtopics
@author frank.bergmann@project-open.com
} {
topic_id:integer
{display_style "all"}
{return_url ""}
}
# -------------- Security, Parameters & Default --------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
set user_is_wheel_p [ad_user_group_member [im_wheel_group_id] $user_id]
if {"" == $return_url} {
set return_url [im_url_with_query]
}
set page_title "View Topic"
set context_bar [ad_context_bar [list /intranet-forum/ Forum] $page_title]
# -------------- Get the tree --------------------------
set topic_sql "
select
t.*,
ug.group_name,
tr.indent_level,
(10-tr.indent_level) as colspan_level,
ftc.category as topic_type,
fts.category as topic_status,
ou.first_names||' '||ou.last_name as owner_name,
au.first_names||' '||au.last_name as asignee_name
from
(select
topic_id,
(level-1) as indent_level
from
im_forum_topics t
start with
topic_id=:topic_id
connect by
parent_id = PRIOR topic_id
) tr,
im_forum_topics t,
users ou,
users au,
user_groups ug,
im_categories ftc,
im_categories fts
where
tr.topic_id = t.topic_id
and t.owner_id=ou.user_id
and ug.group_id=t.group_id
and t.asignee_id=au.user_id(+)
and t.topic_type_id=ftc.category_id(+)
and t.topic_status_id=fts.category_id(+)
"
# -------------- Setup the outer table with indents-----------------------
append page_body "
<br>
[im_forum_navbar "/intranet/projects/index" [list]]"
# outer table with 10 columns for indenting
append page_body "
<table cellspacing=0 border=0 cellpadding=3>
<tr>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
<td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </td>
</tr>
"
# -------------- Render all TIND elements -----------------------
set msg_ctr 1
db_foreach get_topic $topic_sql {
# position table within the outer indent-table
append page_body "<tr>"
if {$indent_level > 0} {
append page_body "<td colspan=$indent_level>&nbsp;</td>"
}
append page_body "
<td colspan=$colspan_level>
<table border=0 cellpadding=0 bgcolor=#E0E0E0>"
if {$msg_ctr == 1} { append page_body "
<tr><td class=rowtitle colspan=2 align=center>
$topic_type</td></tr>"
}
append page_body " [im_forum_render_tind $topic_id $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $group_id $group_name $subject $message $posting_date $due_date $priority $scope]
</table>
</td>
</tr>
"
incr msg_ctr
}
append page_body "</table>\n"
doc_return 200 text/html [im_return_template]
......@@ -131,7 +131,7 @@ set ctr 1
# Render the message
# ------------------------------------------------------------------
append table_body [im_forum_render_tind $topic_id $parent_id $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $object_id $object_name $object_admin $subject $message $posting_date $due_date $priority $scope $return_url]
append table_body [im_forum_render_tind $topic_id $parent_id $topic_type_id $topic_type $topic_status_id $topic_status $owner_id $asignee_id $owner_name $asignee_name $user_id $object_id $object_name $object_admin $subject $message $posting_date $due_date $priority $scope $receive_updates $return_url]
# -------------- Action Area -----------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment