|
From: mdw c. <myd...@li...> - 2003-03-05 16:54:37
|
MyDynaWeb CVS committal
Author : sukria
Project : mydynaweb
Module : htdocs
Dir : mydynaweb/htdocs/include
Modified Files:
gui.inc.php mydynaweb.libs.php templates.inc.php
Log Message:
premiere version des sondages
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/gui.inc.php,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -3 -r1.58 -r1.59
--- gui.inc.php 14 Feb 2003 08:31:13 -0000 1.58
+++ gui.inc.php 5 Mar 2003 16:54:00 -0000 1.59
@@ -354,6 +354,90 @@
}
+/*
+ print a box with the current poll.
+ 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)
+*/
+
+function get_poll_box($DBH)
+{
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
+
+ $sql = "SELECT pol_title, pol_id,
+ pol_question_1_str, pol_question_1_num,
+ pol_question_2_str, pol_question_2_num,
+ pol_question_3_str, pol_question_3_num,
+ pol_question_4_str, pol_question_4_num,
+ pol_question_5_str, pol_question_5_num,
+ pol_question_6_str, pol_question_6_num,
+ pol_question_7_str, pol_question_7_num,
+ pol_date_creation
+ FROM poll
+ WHERE pol_is_open=1
+ ORDER BY pol_date_creation DESC
+ LIMIT 1";
+ $rqt = new query($DBH);
+ $rqt->query($DBH, $sql) or send_sql_error($PHP_SELF, $sql, $rqt->error());
+ $row = $rqt->getrow();
+
+ // 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."'";
+ $rqt = new query($DBH);
+ $rqt->query($DBH, $sql) or send_sql_error($PHP_SELF, $sql, $rqt->error());
+ $row2 = $rqt->getrow();
+
+ if ($row2['pol_id'] == $row['pol_id'] and $row["pol_id"] != "") {
+ // already vote for that poll
+ return ("results");
+ }
+
+
+ $VALUES['TITLE'] = translate("POLL",$DBH);
+ $VALUES['TITLE'] .= "<br><b>" . $row["pol_title"] . "</b>";
+ $form = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES);
+
+ $questions[0] = $row["pol_question_1_str"];
+ $questions[1] = $row["pol_question_2_str"];
+ $questions[2] = $row["pol_question_3_str"];
+ $questions[3] = $row["pol_question_4_str"];
+ $questions[4] = $row["pol_question_5_str"];
+ $questions[5] = $row["pol_question_6_str"];
+ $questions[6] = $row["pol_question_7_str"];
+
+ $votes[0] = $row["pol_question_1_num"];
+ $votes[1] = $row["pol_question_2_num"];
+ $votes[2] = $row["pol_question_3_num"];
+ $votes[3] = $row["pol_question_4_num"];
+ $votes[4] = $row["pol_question_5_num"];
+ $votes[5] = $row["pol_question_6_num"];
+ $votes[6] = $row["pol_question_7_num"];
+
+ $form .= "<FORM name='poll' action='poll.php' method='GET'>\n";
+ $form .= "<INPUT type='hidden' name='pol_id' value='".$row["pol_id"]."'>\n";
+
+ for ($i=0; $i<7; $i++) {
+ if (strlen($questions[$i])) {
+ $VALUES["CONTENT"] = "<input type='radio' name='poll' value='$i'>" . $questions[$i] . "<br>\n";
+ $form .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
+ }
+ else {
+ break;
+ }
+ }
+
+ if ($i == 0) {
+ return "";
+ }
+
+ $VALUES["CONTENT"] = "<INPUT type='submit' value='".translate ("CONFIRM", $DBH)."'>\n</form>";
+ $form .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
+
+
+ $form .= get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
+ return($form);
+}
function get_searchengine($seek, $DBH)
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/mydynaweb.libs.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- mydynaweb.libs.php 27 Dec 2002 11:52:56 -0000 1.42
+++ mydynaweb.libs.php 5 Mar 2003 16:54:01 -0000 1.43
@@ -50,6 +50,8 @@
*****************************************/
+define ("REMOTE_ADDR", $REMOTE_ADDR);
+
define("USER_FAM", $fam);
if (! isset($UserLang)) {
$UserLang = DEFAULT_LANG;
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/templates.inc.php,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- templates.inc.php 14 Feb 2003 08:31:14 -0000 1.37
+++ templates.inc.php 5 Mar 2003 16:54:02 -0000 1.38
@@ -28,6 +28,7 @@
}
$VALUES["TOPICS_BOX"] = get_topics_htmlbox($DBH);
+ $VALUES["POLL"] = get_poll_box($DBH);
$VALUES['LAYER'] = get_layer($DBH, $hash_layer);
$VALUES['SPONSORS'] = get_sponsors($DBH, $hash_box);
$VALUES['STATBOX'] = get_global_stats_box($DBH, $hash_box);
|