-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreaterule.php
115 lines (110 loc) · 3.74 KB
/
createrule.php
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
###############################################################################
# $Id$
# UI to saverule.php
###############################################################################
require_once dirname(__FILE__).'/common.php';
$isUpdate = isset($_GET["ruleid"]);
$fields = array("dept", "position", "addlist", "notificationlist");
if ($isUpdate) {
$ruleid = $_GET["ruleid"];
$sql = "SELECT " . join(", ", $fields) . " FROM emailrules WHERE ruleid = " . ((int) $ruleid);
$mdb2->setLimit(1);
$res =& $mdb2->query($sql);
if(PEAR::isError($res)) {
error_log($res->getDebugInfo());
fatal("Could not get information for $ruleid: ".$res->getMessage());
}
foreach ($fields as $field) {
$res->bindColumn($field, $$field);
}
$row = $res->fetchRow();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php if ($isUpdate) { ?>
<title>The Tech Mailing List Rule Modification Page</title>
<?php } else { ?>
<title>The Tech Mailing List Rule Addition Page</title>
<?php } ?>
</head>
<body style='margin:15px auto;padding:5px 20px;width:860px;'>
<h1 align="center">The Tech</h1>
<?php if ($isUpdate) { ?>
<h2 align="center">Email List Rule Modification Page</h2>
<?php } else { ?>
<h2 align="center">Email List Rule Creation Page</h2>
<?php } ?>
<form method="post" action="./saverule.php">
Department: <select onchange="updateTitles()" name="dept">
<option <?=isset($dept)?"":"selected"?>></option>
<?php foreach (getDepartments() as $department) { ?>
<option value="<?=$department?>"<?=($dept==$department)?" selected":""?>><?=$department?></option>
<?php } ?>
</select>
Position:
<select name="position">
<?php
if(isset($dept)) {
print("DEPT SET");
} else {
print("DEPT UNSET");
}
?>
<option <?=isset($position)?"":" selected " ?>></option>
<option value="*" <?=($position==="*")?"selected":""?>>Any position.</option>
<?php if(isset($dept)) { foreach (getDepartmentTitles($dept) as $title) { ?>
<option value="<?=$title?>"<?=($position==$title)?" selected":""?>><?=$title?></option>
<?php } } else { ?>
<!-- This will be filled in with JavaScript -->
<?php } ?>
</select>
<br />
Mailing list to subscribe staffer to:
<input type="text" name="addlist" value="<?php print($addlist)?>" />
</input>
(e.g., tech-talk)
<br />
Mailing list to notify:
<input type="text" name="notificationlist" value="<?php print($notificationlist)?>" />
(e.g., tech-talk-owner)
<br />
<?php if ($isUpdate) { ?>
<input type="hidden" name="ruleid" value="<?=($_GET['ruleid'])?>">
<?php } ?>
<p align="center">
<input style="margin-right:10%" type="reset" value="Reset">
<input type="submit" value="Submit" name="submit">
<input style="margin-left:10%" type="submit" value="Delete!" name="delete">
</p>
<br>
</form>
<form method="get" action="./">
<input style="width:50%;margin-left:25%;margin-right:25%" type="submit" value="Cancel">
</form>
</body>
<script type="text/javascript" language="javascript">
var displayNameModified = false;
var athenaUserModified = false;
function updateTitles() {
var url = "./json.php?0=getDepartmentTitles&1=";
url += document.getElementsByName("dept")[0].value;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else { // IE6 and IE 5
alert("Get rid of your stanky old shit. http://www.getfirefox.com/");
return false;
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
var titles = JSON.parse(xmlhttp.responseText);
var html = '<option value="*">Any position.</option>';
for (t in titles) {
html += "<option value='" + titles[t] + "'>" + titles[t] + "</option>\n";
}
document.getElementsByName("position")[0].innerHTML = html;
}
</script>
</html>