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

added the files in /www/

parent 1e8de7ac
# /packages/intranet-forum/www/intranet/forum/forum-action.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Purpose: Takes commands from the /intranet/projects/view
page and saves changes, deletes tasks and scans for Trados
files.
@param return_url the url to return to
@param group_id group id
@author frank.bergmann@project-open.com
} {
submit
action
topic_id:array,optional
{return_url ""}
}
set user_id [ad_maybe_redirect_for_registration]
set page_body "<PRE>\n"
if {$return_url == ""} {
set return_url "/intranet/forum/"
}
set topic_list [array names topic_id]
ns_log Notice "forum-action: topic_list=$topic_list"
if {0 == [llength $topic_list]} {
ad_returnredirect $return_url
}
# Make sure the respective im_forum_topic_user_map entries exist:
foreach topic_insert_id $topic_list {
if { [catch {
db_dml insert_forum_topic_map "insert into im_forum_topic_user_map
(topic_id, user_id) values ($topic_insert_id, $user_id)"
} err_msg] } {
# nothing - probably existed before
}
}
# Convert the list of selected topics into a
# "topic_id in (1,2,3,4...)" clause
#
set topic_in_clause "and topic_id in ("
append topic_in_clause [join $topic_list ", "]
append topic_in_clause ")\n"
ns_log Notice "forum-action: topic_in_clause=$topic_in_clause"
switch $submit {
"Apply" {
switch $action {
move_to_deleted {
set sql "
update im_forum_topic_user_map
set folder_id = 1
where
user_id=:user_id
$topic_in_clause"
db_dml mark_topics $sql
}
move_to_inbox {
set sql "
update im_forum_topic_user_map
set folder_id = 0
where user_id=:user_id
$topic_in_clause"
db_dml mark_topics $sql
}
mark_as_read {
set sql "
update im_forum_topic_user_map
set read_p = 't'
where user_id=:user_id
$topic_in_clause"
db_dml mark_topics $sql
}
mark_as_unread {
set sql "
update im_forum_topic_user_map
set read_p = 'f'
where user_id=:user_id
$topic_in_clause"
db_dml mark_topics $sql
}
default {
ad_return_complaint 1 "<li>Unknown value for action: '$action'"
}
}
ad_returnredirect $return_url
}
default {
ad_return_complaint 1 "<li>Unknown value for submit: '$submit'"
}
}
......@@ -143,10 +143,22 @@ set export_var_list [list forum_group_id forum_start_idx forum_order_by forum_ho
set restrict_to_asignee_id 0
set restrict_to_new_topics 0
set forum_content [im_forum_component $current_user_id $forum_group_id $current_url $return_url $export_var_list $forum_view_name $forum_order_by $forum_mine_p $forum_topic_type_id $forum_status_id $restrict_to_asignee_id $forum_how_many $forum_start_idx $restrict_to_new_topics $forum_folder]
# set forum_content [im_forum_component $current_user_id $forum_group_id $current_url $return_url $export_var_list $forum_view_name $forum_order_by $forum_mine_p $forum_topic_type_id $forum_status_id $restrict_to_asignee_id $forum_how_many $forum_start_idx $restrict_to_new_topics $forum_folder]
#ad_proc im_forum_component {user_id group_id current_page_url return_url export_var_list {view_name "forum_list_short"} {forum_order_by "priority"} {restrict_to_mine_p f} {restrict_to_topic_type_id 0} {restrict_to_topic_status_id 0} {restrict_to_asignee_id 0} {max_entries_per_page 0} {start_idx 1} {restrict_to_new_topics 0} {restrict_to_folder 0} }
set forum_content [im_forum_component \
-user_id $user_id \
-object_id 0 \
-current_page_url $current_url \
-return_url $return_url \
-export_var_list [list forum_start_idx forum_order_by forum_how_many forum_view_name] \
-forum_type home \
-view_name [im_opt_val forum_view_name] \
-forum_order_by [im_opt_val forum_order_by] \
-restrict_to_mine_p t \
-restrict_to_new_topics 1 \
]
# ---------------------------------------------------------------
# Join all parts together
......
# /packages/intranet-forum/www/intranet/forum/new-system-error.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Creates a new system error from a "Report this error" button.
Works as an inteface between the request procesor generating
the incident and the forum module that works differntly then
the old ACS ticket tracker.
So there are several difficulties:
- This page is publicly accessible, so it may be used for
denial of service attacks by flooding the system with
incidents
- We have to route the incidents to
@author frank.bergmann@project-open.com
} {
error_url:trim
error_info:trim
error_first_names:trim
error_last_name:trim
error_user_email:trim
core_version:trim
system_url:trim
publisher_name
}
ns_log Notice "new-system-incident: error_url=$error_url"
ns_log Notice "new-system-incident: error_info=$error_info"
ns_log Notice "new-system-incident: error_first_names=$error_first_names"
ns_log Notice "new-system-incident: error_last_name=$error_last_name"
ns_log Notice "new-system-incident: error_user_email=$error_user_email"
ns_log Notice "new-system-incident: core_version=$core_version"
# Maximum number of incidents per day per IP address
# Designed to avoid denial or service attacks
set max_dayily_incidents 3
# -----------------------------------------------------------------
# Lookup user_id or create entry
# -----------------------------------------------------------------
# Keep in mind that the email and other data might be completely fake.
ns_log Notice "Check if the user already has an account: $error_user_email"
set error_user_id [db_string user_id "select party_id from parties where lower(email) = lower(:error_user_email)" -default 0]
if {0 != $error_user_id} {
# The user already exists:
# Make sure there are no more then $max_incidents today from the same IP
# ToDo: Implement !!!
} else {
# Doesn't exist yet - let's create it
ns_log Notice "new-system-incident: creating new user '$error_user_email'"
array set creation_info [auth::create_user \
-email $error_user_email \
-url $error_url \
-verify_password_confirm \
-first_names $error_first_names \
-last_name $error_last_name \
-screen_name "$error_first_names $error_last_name" \
-username "$error_first_names $error_last_name" \
-password $error_first_names \
-password_confirm $error_first_names \
]
ns_log Notice "new-system-incident: checking for '$error_user_email' after creation"
set error_user_id [db_string user_id "select party_id from parties where lower(email) = lower(:error_user_email)" -default 0]
}
if {!$error_user_id} {
# create user didn't succeed...
# ToDo!!!
ad_return_complaint 1 "<li>Error accepted"
return
}
# -----------------------------------------------------------------
# Create an incident (without mail alert)
# -----------------------------------------------------------------
set topic_id [db_nextval "im_forum_topics_seq"]
set parent_id ""
set owner_id $error_user_id
set scope "group"
set subject $error_url
set message $error_info
set priority 3
set asignee_id ""
set due [db_string tomorrow "select sysdate+1 from dual"]
# 1102 is "Incident"
set topic_type_id 1102
# 1202 is "Open"
set topic_status_id 1202
db_transaction {
db_dml topic_insert "
INSERT INTO im_forum_topics (
topic_id, group_id, parent_id, topic_type_id, topic_status_id,
posting_date, owner_id, scope, subject, message, priority,
asignee_id, due_date
) VALUES (
:topic_id, :report_group_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" "
<LI>There was an error adding your ticket to our system.<br>
Please send an email to <A href=\"mailto:[ad_parameter "SystemOwner" "" ""]\">
our webmaster</a>, thanks."
}
set page_body "
<H1>Incident Received</H1>
Your incident hast been received.<br>
You will be notified as soon as possible.
"
doc_return 200 text/html [im_return_template]
# /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 ""}
}
# ------------------------------------------------------------------
# Procedures
# ------------------------------------------------------------------
ad_proc -public im_forum_topic_alert_user {
$topic_id
$owner_id
$asignee_id
$topic_status_id
$old_topic_status_id
} {
Returns 1/0 to indicate whether the specific user wants to be
informed about a specific event
} {
return 1
}
# ------------------------------------------------------------------
# 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 topic name"
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 [im_name_from_user_id(user_id)]]
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/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 SystemUrl]"
append msg_url "/intranet-forum/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
# 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 SystemUrl]"
append msg_url "/intranet-forum/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_url $msg_subject $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 SystemUrl]"
append msg_url "/intranet-forum/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_url $msg_subject $message
}
}
db_release_unused_handles
ad_returnredirect $return_url
This diff is collapsed.
# /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]
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