1
# $Id: dosend.tcl 1096 2008-06-30 22:03:35Z hubert@u.washington.edu $
2
# ========================================================================
3
# Copyright 2006 University of Washington
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# ========================================================================
15
# Purpose: CGI script to perform message posting via compose.tcl
20
{cid "Missing Command ID"}
21
{postpost "" "main.tcl"}
31
foreach item $post_vars {
32
if {[catch {cgi_import [lindex $item 0].x}]} {
33
if {[catch {eval WPImport $item} result]} {
34
error [list _action "Impart Variable" $result]
37
set [lindex $item 0] 1
41
if {$cid != [WPCmd PEInfo key]} {
42
error [list _action Postpone "Invalid Operation ID" "Click Back button to try again."]
45
if {[string length $user] && [string length $pass] && [string length $server]} {
46
set cclientname "\{$server\}"
47
catch {WPCmd PESession nocred 0 $cclientname}
48
if {[catch {WPCmd PESession creds 0 $cclientname $user $pass} result]} {
49
WPCmd PEInfo statmsg "Cannot set credentials for $server"
53
if {[catch {WPCmd PEInfo set suspended_composition} msgdata] == 0} {
54
if {[catch {WPCmd PECompose post $msgdata} errstr]} {
55
if {[string compare BADPASSWD [string range $errstr 0 8]] == 0
56
&& [catch {WPCmd PEInfo set suspended_composition $msgdata} errstr] == 0} {
57
set oncancel "page=compose&restore=1&cid=$cid"
58
set conftext "Send Messsage?"
59
set reason "The server used to send this message requires authentication.[cgi_nl][cgi_nl]Enter Username and Password to connect to $server"
60
_cgi_set_uservar params [WPPercentQuote [list [list server $server] [list page dosend] [list postpost $postpost]]]
63
# regurgitate the compose window
64
_cgi_set_uservar style ""
66
set title "Send Error: [cgi_font class=notice "$errstr"]"
67
if {[string length $errstr]} {
68
set notice "Send FAILED: $errstr"
70
set notice "Send FAILED: [WPCmd PEInfo statmsg]"
72
WPCmd PEInfo statmsg "$notice"
74
if {[info exists attachments]} {
75
set a [split $attachments ","]
78
# id file size type/subtype
79
if {[catch {WPCmd PECompose attachinfo $id} result]} {
80
WPCmd PEInfo statmsg $result
82
lappend attachments [list $id [lindex $result 0] [lindex $result 1] [lindex $result 2]]
90
catch {WPCmd PEInfo unset suspended_composition}
91
WPCmd PEInfo statmsg "Message Sent!"
95
WPCmd PEInfo statmsg "Internal Error: $msgdata"
99
source [WPTFScript $src]