| |
33 |
33 |
oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {forum_id message_id parent_id subject content html_p user_id} |
| |
34 |
34 |
|
| |
35 |
35 |
db_transaction { |
| |
36 |
36 |
set message_id [package_instantiate_object -extra_vars $extra_vars forums_message] |
| |
37 |
37 |
|
| |
38 |
38 |
get -message_id $message_id -array message |
| |
39 |
39 |
if {[info exists message(state)] && [string equal $message(state) approved]} { |
| |
40 |
40 |
do_notifications -message_id $message_id |
| |
41 |
41 |
} |
| |
42 |
42 |
} on_error { |
| |
43 |
43 |
|
| |
44 |
44 |
db_abort_transaction |
| |
45 |
45 |
|
| |
46 |
46 |
# Check to see if the message with a message_id matching the |
| |
47 |
47 |
# message_id arguement was in the database before calling |
| |
48 |
48 |
# this procedure. If so, the error is due to a double click |
| |
49 |
49 |
# and we should continue without returning an error. |
| |
50 |
50 |
|
| |
51 |
51 |
if {![empty_string_p $original_message_id]} { |
| |
52 |
52 |
# The was a non-null message_id arguement |
| |
53 |
|
if {[db_string message_exists_p " |
| |
54 |
|
select count(message_id) |
| |
55 |
|
from forums_messages |
| |
56 |
|
where message_id = :message_id"]} { |
| |
57 |
|
|
| |
|
53 |
if {[db_string message_exists_p { *SQL* }]} { |
| |
58 |
54 |
return $message_id |
| |
59 |
|
|
| |
|
55 |
} else { |
| |
|
56 |
# OK - it wasn't a simple double-click, so bomb |
| |
|
57 |
ad_return_error \ |
| |
|
58 |
"OACS Internal Error" \ |
| |
|
59 |
"Error in forums::message::new - $errmsg" |
| |
60 |
60 |
} |
| |
61 |
61 |
} |
| |
62 |
62 |
} |
| |
63 |
63 |
|
| |
64 |
64 |
return $message_id |
| |
65 |
65 |
} |
| |
66 |
66 |
|
| |
67 |
67 |
ad_proc -public do_notifications { |
| |
68 |
68 |
{-message_id:required} |
| |
69 |
69 |
} { |
| |
70 |
70 |
# Select all the important information |
| |
71 |
71 |
get -message_id $message_id -array message |
| |
72 |
72 |
|
| |
73 |
73 |
set forum_id $message(forum_id) |
| |
74 |
74 |
set url "[ad_url][db_string select_forums_package_url {}]" |
| |
75 |
75 |
|
| |
76 |
76 |
set new_content "" |
| |
77 |
77 |
append new_content "Forum: <a href=\"${url}forum-view?forum_id=$message(forum_id)\">$message(forum_name)</a><br>\n" |
| |
78 |
78 |
append new_content "Thread: <a href=\"${url}message-view?message_id=$message(root_message_id)\">$message(root_subject)</a><br>\n" |
| |
79 |
79 |
append new_content "Author: <a href=\"mailto:$message(user_email)\">$message(user_name)</a><br>\n" |