-
Notifications
You must be signed in to change notification settings - Fork 1
/
arrangewishes.php
195 lines (169 loc) · 6.93 KB
/
arrangewishes.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/commons/init.php';
$wiki = 'To-do List';
// confirm the session...
require_once 'commons/dbconnect.php';
require_once 'commons/rpgfunctions.php';
require_once 'commons/sessions.php';
require_once 'commons/grammar.php';
require_once 'commons/formatting.php';
require_once 'commons/todolistlib.php';
$tag = trim($_GET['tag']);
if(strlen($tag) > 0)
{
$data = $database->FetchSingle('
SELECT COUNT(*) AS c
FROM psypets_ideachart
LEFT JOIN psypets_ideachart_tags ON psypets_ideachart.idnum=psypets_ideachart_tags.ideaid
WHERE psypets_ideachart_tags.tag=' . quote_smart($tag) . '
');
$num_items = $data['c'];
$num_pages = ceil($num_items / 20);
$page = (int)$_GET['page'];
if($page < 1 || $page > $num_pages)
$page = 1;
$ideas = $database->FetchMultipleBy(
'
SELECT psypets_ideachart.*
FROM psypets_ideachart
LEFT JOIN psypets_ideachart_tags ON psypets_ideachart.idnum=psypets_ideachart_tags.ideaid
WHERE psypets_ideachart_tags.tag=' . quote_smart($tag) . '
ORDER BY psypets_ideachart.idnum DESC
LIMIT ' . (($page - 1) * 20) . ',20
',
'idnum'
);
$pages = paginate($num_pages, $page, '?tag=' . $tag . '&page=%s');
}
else
{
$data = $database->FetchSingle('
SELECT COUNT(*) AS c
FROM psypets_ideachart
');
$num_items = $data['c'];
$num_pages = ceil($num_items / 20);
$page = (int)$_GET['page'];
if($page < 1 || $page > $num_pages)
$page = 1;
$ideas = $database->FetchMultipleBy(
'
SELECT *
FROM psypets_ideachart
ORDER BY idnum DESC
LIMIT ' . (($page - 1) * 20) . ',20
',
'idnum'
);
$pages = paginate($num_pages, $page, '?page=%s');
}
$command = 'SELECT ideaid,votes FROM psypets_ideavotes WHERE residentid=' . $user['idnum'];
$my_votes = $database->FetchMultipleBy($command, 'ideaid', 'fetching my votes');
foreach($ideas as $id=>$wish)
{
$votes[$id] = (int)$my_votes[$id]['votes'];
$these_tags = $database->FetchMultiple(
'SELECT * FROM psypets_ideachart_tags WHERE ideaid=' . $id
);
foreach($these_tags as $this_tag)
$tags[$id][] = '<a href="?tag=' . urlencode($this_tag['tag']) . '">' . $this_tag['tag'] . '</a>';
}
if($user['wishlistupdate'] == 'yes')
{
$command = 'UPDATE monster_users SET wishlistupdate=\'no\' WHERE idnum=' . $user['idnum'] . ' LIMIT 1';
$database->FetchNone($command, 'removing wish list notification icon, because that is what we do here');
$user['wishlistupdate'] = 'no';
}
$is_manager = ($user['admin']['managewishlist'] == 'yes');
$tag_cloud = $database->FetchMultiple('
SELECT tag,COUNT(idnum) AS weight
FROM psypets_ideachart_tags
GROUP BY tag
ORDER BY tag ASC
');
foreach($tag_cloud as $this_tag)
$weights[] = $this_tag['weight'];
$tag_max = max($weights);
$tag_min = min($weights);
$tag_range = $tag_max - $tag_min + 1;
include 'commons/html.php';
?>
<head>
<title><?= $SETTINGS['site_name'] ?> > To-do List <?= (strlen($tag) > 0 ? '(' . $tag . ')' : '') ?> > Your Vote</title>
<?php include "commons/head.php"; ?>
<script type="text/javascript" src="//<?= $SETTINGS['static_domain'] ?>/js/todolist.js"></script>
</head>
<body>
<?php include 'commons/header_2.php'; ?>
<h4>To-do List <?= (strlen($tag) > 0 ? '(' . $tag . ')' : '') ?> > Your Vote</h4>
<p>I (<?= User::Link($SETTINGS['author_resident_name']) ?>) use the To-do List to keep track of changes I want to make. Feel free to leave you opinion on a change; I'll try to focus my efforts on changes which recieve a lot of positive review, and may think twice or ask your opinions about those which receive largely negative review.</p>
<?php
if($is_manager)
echo '<ul><li><a href="/admin/todo_totals.php">Manage To-do List</a></li></ul>';
?>
<ul class="tabbed">
<li class="activetab"><a href="/arrangewishes.php">Your Vote</a></li>
<li><a href="/todolist_completed.php">Completed Items</a></li>
</ul>
<div style="margin-left:10px; width:200px; padding:5px; border-left: 1px dashed #666; float: right; text-align: center;">
<h5>Fluffy Tag Cloud</h5>
<?php
foreach($tag_cloud as $tag)
{
$size = (int)(($tag['weight'] - $tag_min) * 20 / $tag_range) + 10;
echo '<span style="font-size:' . $size . 'px; vertical-align:middle;"><a href="?tag=' . urlencode($tag['tag']) . '">' . $tag['tag'] . '</a></span> ';
}
?>
</div>
<?php
if(count($ideas) > 0)
{
?>
<p><i>(Newest items are displayed first.)</i></p>
<?= $pages ?>
<table>
<tr class="titlerow">
<th class="centered" style="width:100px;">Vote</th>
<th>Item</th>
<th></th>
</tr>
<?php
$rowclass = begin_row_class();
foreach($votes as $id=>$vote)
{
if($ideas[$id]['postdate'] > $now - 3 * 24 * 60 * 60)
$new = ' <i style="color:red;">new!</i>';
else
$new = '';
$vote = array(
-2 => ($vote == -2 ? '<img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/grr.png" alt="super bad!" class="inlineimage" />' : '<a href="#" onclick="todo_vote(' . $id . ', -2); return false;"><img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/grr.png" alt="super bad!" class="transparent_image inlineimage" /></a>'),
-1 => ($vote == -1 ? '<img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/mmf.gif" alt="no, thank you." class="inlineimage" />' : '<a href="#" onclick="todo_vote(' . $id . ', -1); return false;"><img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/mmf.gif" alt="no, thank you." class="transparent_image inlineimage" /></a>'),
0 => ($vote == 0 ? '<img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/neutral.png" alt="whatever." class="inlineimage" />' : '<a href="#" onclick="todo_vote(' . $id . ', 0); return false;"><img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/neutral.png" alt="whatever." class="transparent_image inlineimage" /></a>'),
1 => ($vote == 1 ? '<img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/hee.gif" alt="yes, please." class="inlineimage" />' : '<a href="#" onclick="todo_vote(' . $id . ', 1); return false;"><img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/hee.gif" alt="yes, please." class="transparent_image inlineimage" /></a>'),
2 => ($vote == 2 ? '<img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/yeah.gif" alt="want!" class="inlineimage" />' : '<a href="#" onclick="todo_vote(' . $id . ', 2); return false;"><img src="//' . $SETTINGS['static_domain'] . '/gfx/emote/yeah.gif" alt="want!" class="transparent_image inlineimage" /></a>'),
);
echo '
<tr class="' . $rowclass . '">
<td><div id="vote' . $id . '" class="centered">
' . $vote[2] . ' ' . $vote[1] . ' ' . $vote[0] . ' ' . $vote[-1] . ' ' . $vote[-2] . '
</div></td>
<td>
' . $ideas[$id]['sdesc'] . $new . '<br />
<i class="size8">' . implode(', ', $tags[$id]) . '</i>
</td>
<td><nobr>(<a href="/tododetails.php?id=' . $id . '">read more...</a>)</nobr></td>
</tr>
';
$rowclass = alt_row_class($rowclass);
}
?>
</table>
<?= $pages ?>
<?php
}
else
echo '<p>There are no To-do List entries.</p>';
?>
<?php include 'commons/footer_2.php'; ?>
</body>
</html>