|
From: mdw c. <myd...@li...> - 2003-03-13 16:56:52
|
MyDynaWeb CVS committal
Author : sukria
Project : mydynaweb
Module : htdocs
Dir : mydynaweb/htdocs/include
Modified Files:
mydynaweb.libs.php gui.inc.php
Log Message:
un cookie est posé lorsque l'on répond à un sondage ainsi on se base egalement dessus pour savoir si on a deja repondu, utile en cas d'adresse IP dynamique'
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/mydynaweb.libs.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- mydynaweb.libs.php 5 Mar 2003 16:54:01 -0000 1.43
+++ mydynaweb.libs.php 13 Mar 2003 16:33:05 -0000 1.44
@@ -51,6 +51,7 @@
*****************************************/
define ("REMOTE_ADDR", $REMOTE_ADDR);
+define ("VOTES", $VOTES);
define("USER_FAM", $fam);
if (! isset($UserLang)) {
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/gui.inc.php,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -3 -r1.61 -r1.62
--- gui.inc.php 6 Mar 2003 09:41:06 -0000 1.61
+++ gui.inc.php 13 Mar 2003 16:33:07 -0000 1.62
@@ -359,10 +359,13 @@
if user IP is not found in the poll_users print the questions ;
if not (the user as already vote for that poll, just display
the results)
+
+ if the optionalm argument $view is set to TRUE, display the results
*/
-function get_poll_box($DBH)
+function get_poll_box($DBH, $view = 0)
{
+ $votes = explode ("-", VOTES);
$BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
$sql = "SELECT pol_title, pol_id,
@@ -385,6 +388,15 @@
// we'll fetch every open polls
while ($row = $rqt->getrow()) {
+ // if the user has a cookie for that poll, don't show the form
+ // only display the results
+ for ($i=0; $i<sizeof($votes); $i++) {
+ if ($votes[$i] == $row['pol_id']) {
+ $view = 1;
+ }
+ }
+
+
// first look if that user (IP ADDR) can vote for that poll
$sql = "SELECT pol_id FROM poll_users
WHERE user_ip_addr = '".REMOTE_ADDR."'
@@ -419,7 +431,7 @@
$date = ($exp[2] . "/" . $exp[1] . "/" . $exp[0]);
// already vote for that poll
- if ($row2['pol_id'] == $row['pol_id'] and $row["pol_id"] != "") {
+ if ($view or ($row2['pol_id'] == $row['pol_id'] and $row["pol_id"] != "")) {
$VALUES['TITLE'] = "<b>" . $row["pol_title"] . "</b>";
$form = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES);
@@ -429,7 +441,7 @@
for ($i=0; $i<7; $i++) {
if (strlen($questions[$i])) {
- $size = ($votes[$i] * 200) / $max;
+ $size = ($votes[$i] * 100) / $max;
if ($size == 0) $size = 5;
$total += $votes[$i];
@@ -451,6 +463,8 @@
$form .= get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
$poll_boxes .= $form;
+ $view = 0;
+ $VALUES = Array();
}
else {
@@ -478,6 +492,8 @@
$poll_boxes .= $form;
$poll_boxes .= "<br>";
+ $view = 0;
+ $VALUES = Array();
}
}
}
|