~ubuntu-branches/ubuntu/karmic/alpine/karmic

« back to all changes in this revision

Viewing changes to web/cgi/alpine-2.0/conduit/storecontact.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2008-09-23 12:17:56 UTC
  • mfrom: (2.1.8 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080923121756-6u4x8bwq89qlzt32
Tags: 2.00+dfsg-2
Update to package description: note that Alpine is no longer in
alpha. (Closes: #499640)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: storecontact.tcl 1150 2008-08-20 00:27:11Z mikes@u.washington.edu $
 
3
# ========================================================================
 
4
# Copyright 2008 University of Washington
 
5
#
 
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
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# ========================================================================
 
13
 
 
14
#  storecontact.tcl
 
15
#
 
16
#  Purpose:  CGI script to handle saving new/edited contacts
 
17
#
 
18
#  Input: 
 
19
set store_vars {
 
20
  {book         ""      0}
 
21
  {ai           ""      -1}
 
22
  {contactNick  ""      ""}
 
23
  {contactName  ""      ""}
 
24
  {contactEmail ""      ""}
 
25
  {contactFcc   ""      ""}
 
26
  {contactNotes ""      ""}
 
27
}
 
28
 
 
29
#  Output: 
 
30
 
 
31
# inherit global config
 
32
source ../alpine.tcl
 
33
 
 
34
# Import data validate it and get session id
 
35
if {[catch {WPGetInputAndID sessid}]} {
 
36
  return
 
37
}
 
38
 
 
39
# grok parameters
 
40
foreach item $store_vars {
 
41
  if {[catch {eval WPImport $item} errstr]} {
 
42
    lappend errs $errstr
 
43
  }
 
44
}
 
45
 
 
46
if {[string length $contactNick] || [string length $contactName] || [string length $contactEmail]} {
 
47
  set result ""
 
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"
 
52
  } else {
 
53
    lappend status "Contact Added"
 
54
  }
 
55
} else {
 
56
  lappend status "No Contact Added: Must contain Display Name, Address or Nickname"
 
57
}
 
58
 
 
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]\">"
 
63
foreach sm $status {
 
64
  regsub {'} $sm {\'} sm
 
65
  puts stdout "<Result><StatusText>$sm</StatusText></Result>"
 
66
}
 
67
puts stdout "</ResultSet>"