2
# $Id: storecontact.tcl 1150 2008-08-20 00:27:11Z mikes@u.washington.edu $
3
# ========================================================================
4
# Copyright 2008 University of Washington
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# ========================================================================
16
# Purpose: CGI script to handle saving new/edited contacts
31
# inherit global config
34
# Import data validate it and get session id
35
if {[catch {WPGetInputAndID sessid}]} {
40
foreach item $store_vars {
41
if {[catch {eval WPImport $item} errstr]} {
46
if {[string length $contactNick] || [string length $contactName] || [string length $contactEmail]} {
48
if {[catch {WPCmd PEAddress edit $book $contactNick $ai $contactName $contactEmail $contactFcc $contactNotes 1} result]} {
49
lappend status "Address Set Failure: $result"
50
} elseif {[string length $result]} {
51
lappend status "$result"
53
lappend status "Contact Added"
56
lappend status "No Contact Added: Must contain Display Name, Address or Nickname"
59
# return response text
60
puts stdout "Content-type: text/xml; charset=\"UTF-8\"\n"
61
puts stdout {<?xml version="1.0" encoding="UTF-8"?>}
62
puts stdout "<ResultSet totalResultsAvailable=\"[llength $status]\">"
64
regsub {'} $sm {\'} sm
65
puts stdout "<Result><StatusText>$sm</StatusText></Result>"
67
puts stdout "</ResultSet>"