root/ip/tags/release_1_3_0_53/adm/admin_voting.php
| 111 | 163 | ||
|---|---|---|---|
152 | )); | 152 | )); |
153 | 153 | ||
154 | // Assign Username array | 154 | // Assign Username array |
155 | $sql = "SELECT DISTINCT u.user_id, u.username" . | 155 | $sql = "SELECT DISTINCT u.user_id, u.username, u.user_active, u.user_color |
156 | " FROM " . USERS_TABLE . " AS u , " . VOTE_USERS_TABLE . " AS vv" . | 156 | FROM " . USERS_TABLE . " AS u , " . VOTE_USERS_TABLE . " AS vv |
157 | " WHERE u.user_id = vv.vote_user_id"; | 157 | WHERE u.user_id = vv.vote_user_id"; |
158 | 158 | ||
159 | if(!($result = $db->sql_query($sql))) | 159 | if(!($result = $db->sql_query($sql))) |
160 | { | 160 | { |
161 | message_die(GENERAL_ERROR, 'Could not query users.', '', __LINE__, __FILE__, $sql); | 161 | message_die(GENERAL_ERROR, 'Could not query users.', '', __LINE__, __FILE__, $sql); |
162 | } | 162 | } |
163 | 163 | ||
164 | $users_arr[] = array(); | ||
164 | while ($row = $db->sql_fetchrow($result)) | 165 | while ($row = $db->sql_fetchrow($result)) |
165 | { | 166 | { |
166 | $user_id = $row['user_id']; | 167 | $user_id = $row['user_id']; |
167 | $username = $row['username']; | 168 | $username = $row['username']; |
168 | $user_arr[$user_id] = $username; | 169 | $user_arr[$user_id] = $username; |
170 | $users_arr[$user_id]['user_id'] = $row['user_id']; | ||
171 | $users_arr[$user_id]['username'] = $row['username']; | ||
172 | $users_arr[$user_id]['user_active'] = $row['user_active']; | ||
173 | $users_arr[$user_id]['user_color'] = $row['user_color']; | ||
169 | } | 174 | } |
170 | 175 | ||
171 | // Assign poll options array | 176 | // Assign poll options array |
172 | $sql = "SELECT *" . | 177 | $sql = "SELECT * |
173 | " FROM ". VOTE_RESULTS_TABLE . | 178 | FROM " . VOTE_RESULTS_TABLE . " |
174 | " ORDER BY vote_id"; | 179 | ORDER BY vote_id"; |
175 | 180 | ||
176 | if(!($result = $db->sql_query($sql))) | 181 | if(!($result = $db->sql_query($sql))) |
177 | { | 182 | { |
... | ... | ||
184 | $vote_option_id = $row['vote_option_id']; | 189 | $vote_option_id = $row['vote_option_id']; |
185 | $vote_option_text = $row['vote_option_text']; | 190 | $vote_option_text = $row['vote_option_text']; |
186 | $vote_result = $row['vote_result']; | 191 | $vote_result = $row['vote_result']; |
187 | $option_arr[$vote_id][$vote_option_id]["text"] = $vote_option_text; | 192 | $option_arr[$vote_id][$vote_option_id]['text'] = $vote_option_text; |
188 | $option_arr[$vote_id][$vote_option_id]["result"] = $vote_result; | 193 | $option_arr[$vote_id][$vote_option_id]['result'] = $vote_result; |
189 | } | 194 | } |
190 | 195 | ||
191 | // Assign individual vote results | 196 | // Assign individual vote results |
192 | $sql = "SELECT vote_id, vote_user_id, vote_cast" . | 197 | $sql = "SELECT vote_id, vote_user_id, vote_cast |
193 | " FROM ". VOTE_USERS_TABLE . | 198 | FROM " . VOTE_USERS_TABLE . " |
194 | " ORDER BY vote_id"; | 199 | ORDER BY vote_id"; |
195 | 200 | ||
196 | if(!($result = $db->sql_query($sql))) | 201 | if(!($result = $db->sql_query($sql))) |
197 | { | 202 | { |
... | ... | ||
207 | } | 212 | } |
208 | 213 | ||
209 | 214 | ||
210 | $sql ="SELECT *" . | 215 | $sql ="SELECT * |
211 | " FROM ". VOTE_DESC_TABLE . | 216 | FROM " . VOTE_DESC_TABLE . " |
212 | " ORDER BY " . $order_by; | 217 | ORDER BY " . $order_by; |
213 | 218 | ||
214 | if(!($result = $db->sql_query($sql))) | 219 | if(!($result = $db->sql_query($sql))) |
215 | { | 220 | { |
... | ... | ||
222 | 227 | ||
223 | while ($row = $db->sql_fetchrow($result)) | 228 | while ($row = $db->sql_fetchrow($result)) |
224 | { | 229 | { |
225 | $topic_row_color = (($i % 2) == 0) ? "row1" : "row2"; | 230 | $topic_row_color = (($i % 2) == 0) ? 'row1' : 'row2'; |
226 | $vote_id = $row['vote_id']; | 231 | $vote_id = $row['vote_id']; |
227 | $vote_text = $row['vote_text']; | 232 | $vote_text = $row['vote_text']; |
228 | $topic_id = $row['topic_id']; | 233 | $topic_id = $row['topic_id']; |
... | ... | ||
232 | 237 | ||
233 | if (time() < $vote_end) | 238 | if (time() < $vote_end) |
234 | { | 239 | { |
235 | $vote_duration = (date ("m/d/y",$vote_start)) . " - " . (date ("m/d/y",$vote_end)) . "(ongoing)"; | 240 | $vote_duration = (date ('Y/m/d', $vote_start)) . " - " . (date ('Y/m/d', $vote_end)) . " (ongoing)"; |
236 | } | 241 | } |
237 | elseif ($vote_length == 0) | 242 | elseif ($vote_length == 0) |
238 | { | 243 | { |
239 | $vote_duration = (date ("m/d/y",$vote_start)) . " - " . "Infinite .." ; | 244 | $vote_duration = (date ('Y/m/d', $vote_start)) . " - " . "Infinite..." ; |
240 | } | 245 | } |
241 | else | 246 | else |
242 | { | 247 | { |
243 | $vote_duration = (date ("m/d/y",$vote_start)) . " - " . (date ("m/d/y",$vote_end)) . "(completed)" ; | 248 | $vote_duration = (date ('Y/m/d', $vote_start)) . " - " . (date ('Y/m/d', $vote_end)) . " (completed)" ; |
244 | } | 249 | } |
245 | 250 | ||
246 | $user = ""; | 251 | $user = ''; |
247 | $users = ""; | 252 | $users = ''; |
248 | $user_option_arr = ""; | 253 | $user_option_arr = ''; |
249 | 254 | ||
250 | if (count($voter_arr[$vote_id]) > 0) | 255 | if (count($voter_arr[$vote_id]) > 0) |
251 | { | 256 | { |
252 | foreach($voter_arr[$vote_id] as $user_id => $option_id) | 257 | foreach($voter_arr[$vote_id] as $user_id => $option_id) |
253 | { | 258 | { |
254 | $user .= $user_arr[$user_id].", "; | 259 | $current_username = colorize_username($users_arr[$user_id]['user_id'], $users_arr[$user_id]['username'], $users_arr[$user_id]['user_color'], $users_arr[$user_id]['user_active']); |
255 | $user_option_arr[$option_id] .= $user_arr[$user_id].", "; | 260 | $user .= $current_username . ', '; |
261 | $user_option_arr[$option_id] .= $current_username . ', '; | ||
256 | } | 262 | } |
257 | $user = substr($user, "0", strrpos($user, ", ")); | 263 | $user = substr($user, '0', strrpos($user, ', ')); |
258 | } | 264 | } |
259 | 265 | ||
260 | $template->assign_block_vars('votes', array( | 266 | $template->assign_block_vars('votes', array( |
261 | 'COLOR' => $topic_row_color, | 267 | 'COLOR' => $topic_row_color, |
262 | 'LINK' => IP_ROOT_PATH . VIEWTOPIC_MG . '?t=' . $topic_id, | 268 | 'LINK' => IP_ROOT_PATH . VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id, |
263 | 'DESCRIPTION' => $vote_text, | 269 | 'DESCRIPTION' => $vote_text, |
264 | 'USER' => $user, | 270 | 'USER' => $user, |
265 | 'ENDDATE' => $vote_end, | 271 | 'ENDDATE' => $vote_end, |
... | ... | ||
275 | $option_text = $elem['text']; | 281 | $option_text = $elem['text']; |
276 | $option_result = $elem['result']; | 282 | $option_result = $elem['result']; |
277 | $user = $user_option_arr[$vote_option_id]; | 283 | $user = $user_option_arr[$vote_option_id]; |
278 | $user = substr($user, "0", strrpos($user, ", ")); | 284 | $user = substr($user, '0', strrpos($user, ', ')); |
279 | 285 | ||
280 | $template->assign_block_vars('votes.detail', array( | 286 | $template->assign_block_vars('votes.detail', array( |
281 | 'OPTION' => $option_text, | 287 | 'OPTION' => $option_text, |
282 | 'RESULT' => $option_result, | 288 | 'RESULT' => $option_result, |
283 | 'USER' => $user | 289 | 'USER' => $user |
284 | )); | 290 | ) |
291 | ); | ||
285 | } | 292 | } |
286 | } | 293 | } |
287 | 294 | ||
... | ... | ||
290 | } | 297 | } |
291 | 298 | ||
292 | // Pagination routine | 299 | // Pagination routine |
293 | // | ||
294 | $sql = "SELECT count(*) AS total" . | 300 | $sql = "SELECT count(*) AS total" . |
295 | " FROM " . VOTE_DESC_TABLE . | 301 | " FROM " . VOTE_DESC_TABLE . |
296 | " WHERE vote_id > 0"; | 302 | " WHERE vote_id > 0"; |
... | ... | ||
314 | ) | 320 | ) |
315 | ); | 321 | ); |
316 | 322 | ||
317 | // I'm the boss...need the info... | ||
318 | // | ||
319 | $template->pparse('pollbody'); | 323 | $template->pparse('pollbody'); |
320 | 324 | ||
321 | include('./page_footer_admin.' . PHP_EXT); | 325 | include('./page_footer_admin.' . PHP_EXT); |
Download diff