summaryrefslogtreecommitdiff
path: root/web/cgi/alpine/2.0/conduit/mark.tcl
blob: ffbe443bcdb7b7a828f885147af28d986635f22f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!./tclsh
# $Id: mark.tcl 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $
# ========================================================================
# Copyright 2008 University of Washington
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# ========================================================================

#  mark.tcl
#
#  Purpose:  CGI script generating response to xmlHttpRequest
#
#  Input:    
#            
set mark_args {
  {u	{}	""}
  {mark	{}	""}
}

# inherit global config
source ../alpine.tcl

WPEval $mark_args {
  cgi_body {
    switch -- $mark {
      false {
	set setting 0
      }
      true {
	set setting 1
      }
      default {
      }
    }

    if {[info exists setting]} {
      regsub -all {,} $u { } u
      if {[regexp {^[ 0123456789]*$} $u]} {
	foreach eu $u {
	  if {[catch {WPCmd PEMessage $eu select $setting} result]} {
	    set result "FAILURE: setting $eu to $setting : $result"
	    break
	  }
	}
      } elseif {0 == [string compare $u all]} {
	if {$setting} {
	  set setting all
	} else {
	  set setting none
	}

	if {[catch {WPCmd PEMailbox select $setting} result]} {
	  set result "FAILURE: $result"
	}
      } elseif {0 == [string compare $u searched]} {
	if {$setting} {
	  set setting searched
	} else {
	  set setting unsearched
	}

	if {[catch {WPCmd PEMailbox select $setting} result]} {
	  set result "FAILURE: $result"
	}
      }
    } else {
      set result "FAILURE: Unknown mark value: $mark"
    }

    cgi_puts $result
  }
}