-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfoia-ajax-buckets.php
90 lines (70 loc) · 3.14 KB
/
foia-ajax-buckets.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
<?php
if(!empty($_GET)) extract($_GET);
if(!empty($_POST)) extract($_POST);
if(!empty($_COOKIE)) extract($_COOKIE);
$nnusr = '';
$nnusr = $_COOKIE[nnusr];
include('incl-dbconnect.php');
include('incl-auth.php');
$db = new dbLink();
if($type == "newbucket") {
print "bucketarea|";
print "Bucket Name: ";
print "<input type=text size=60 maxlength=23 id=bucket_name>";
print " ";
print "<a href=\"javascript:sndReq('showbuckets','&action=new&bucket_name='+escape(document.getElementById('bucket_name').value))\">Create</a>";
print " <a href=\"javascript:sndReq('showbuckets','')\">Cancel</a>";
print "<script language=javascript>document.getElementById('bucket_name').focus;</script>";
}
if($type == "showbuckets") {
print "bucketarea|";
if($seebucket == '') {
$seebucket = 0; }
if($action == "delete") {
$sql = "DELETE FROM foia.buckets_contents WHERE bucket_id IN(SELECT bucket_id FROM foia.buckets WHERE bucket_owner=\"$nnusr\" AND bucket_id=$bucket_id) ";
$db->run($sql);
$sql = "DELETE FROM foia.buckets WHERE bucket_id = $bucket_id AND bucket_owner = \"$nnusr\" ";
$db->run($sql);
}
if($action == "new") {
$bucket_name = addslashes(urldecode($bucket_name));
$sql = "SELECT bucket_name FROM foia.buckets WHERE bucket_name=\"$bucket_name\" AND bucket_owner=\"$nnusr\" ";
$r = $db->getArray($sql);
if($db->numRows() == 0) {
$sql = "INSERT INTO foia.buckets(bucket_name,bucket_owner) VALUES(\"$bucket_name\", \"$nnusr\") ";
$db->run($sql);
}
}
$sql = "SELECT bucket_id, bucket_name FROM foia.buckets WHERE bucket_owner=\"$nnusr\" ORDER BY bucket_name ";
$result = $db->getArray($sql);
if($db->numRows() == 0) {
print "<b>You have not set up any buckets yet.</b>";
} else {
print "<b>You have set up these buckets to organize your requests:</b> ";
foreach($result as $line) {
//print "<br>$line[bucket_name]";
if($seebucket == $line[bucket_id]) {
print "<br><a href=\"javascript:sndReq('showbuckets','')\">$line[bucket_name]</a>";
} else {
print "<br><a href=\"javascript:sndReq('showbuckets','&seebucket=$line[bucket_id]')\">$line[bucket_name]</a>"; }
print " <span style='font-size:8pt'><a href=\"javascript:deleteBucket($line[bucket_id],$seebucket)\">Delete</a></span>";
if($seebucket == $line[bucket_id]) {
$s = "SELECT requests.title, requests.agency, requests.foia_id FROM foia.requests INNER JOIN foia.buckets_contents ON requests.foia_id = buckets_contents.foia_id WHERE buckets_contents.bucket_id = $seebucket ORDER BY title ASC ";
$r = $db->getArray($s);
print "<span style='font-size:9pt'>";
if($db->numRows() == 0) {
print "<br> No requests are assigned to this bucket.";
} else {
print "<br> " . $db->numRows() . " requests in this bucket.";
foreach($r as $l) {
$title = stripslashes($l[title]);
print "<br> <a href=foiaform.php?type=edit&foia_id=$l[foia_id]>$title</a> ($l[agency])";
}
print "<br>";
}
print "</span>";
}
}
}
}
?>