--- /tmp/dsg/dolibarr/htdocs/public/opensurvey/github_19.0.3_studs.php +++ /tmp/dsg/dolibarr/htdocs/public/opensurvey/client_studs.php @@ -25,14 +25,2 @@ -if (!defined('NOLOGIN')) { - define("NOLOGIN", 1); // This means this output page does not require to be logged. -} -if (!defined('NOCSRFCHECK')) { - define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -} -if (!defined('NOBROWSERNOTIF')) { - define('NOBROWSERNOTIF', '1'); -} -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} - -// Load Dolibarr environment +define("NOLOGIN", 1); // This means this output page does not require to be logged. +define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. @@ -43,2 +31 @@ -require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; @@ -50 +37,2 @@ -if (GETPOST('sondage')) { +if (GETPOST('sondage')) +{ @@ -63,3 +51 @@ -if (empty($conf->opensurvey->enabled)) { - httponly_accessforbidden('Module Survey not enabled'); -} +if (empty($conf->opensurvey->enabled)) accessforbidden('', 0, 0, 1); @@ -77,4 +63,3 @@ -if (GETPOST('ajoutcomment', 'alpha')) { - if (!$canbemodified) { - httponly_accessforbidden('ErrorForbidden'); - } +if (GETPOST('ajoutcomment', 'alpha')) +{ + if (!$canbemodified) accessforbidden('', 0, 0, 1); @@ -84,4 +69,5 @@ - $comment = GETPOST("comment", 'alphanohtml'); - $comment_user = GETPOST('commentuser', 'alphanohtml'); - - if (!$comment) { + $comment = GETPOST("comment", 'none'); + $comment_user = GETPOST('commentuser', 'nohtml'); + + if (!$comment) + { @@ -91 +77,2 @@ - if (!$comment_user) { + if (!$comment_user) + { @@ -93,4 +80,5 @@ - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors'); - } - - if (!in_array($comment_user, $listofvoters)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); + } + + if (!in_array($comment_user, $listofvoters)) + { @@ -101,34 +89,5 @@ - $user_ip = getUserRemoteIP(); - $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200); - $now = dol_now(); - $minmonthpost = dol_time_plus_duree($now, -1, "m"); - // Calculate nb of post for IP - $nb_post_ip = 0; - if ($nb_post_max > 0) { // Calculate only if there is a limit to check - $sql = "SELECT COUNT(id_comment) as nb_comments"; - $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_comments"; - $sql .= " WHERE ip = '".$db->escape($user_ip)."'"; - $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $i++; - $obj = $db->fetch_object($resql); - $nb_post_ip = $obj->nb_comments; - } - } - } - - if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) { - setEventMessages($langs->trans("AlreadyTooMuchPostOnThisIPAdress"), null, 'errors'); - $error++; - } - - if (!$error) { - $resql = $object->addComment($comment, $comment_user, $user_ip); - - if (!$resql) { - dol_print_error($db); - } + if (!$error) + { + $resql = $object->addComment($comment, $comment_user); + + if (!$resql) dol_print_error($db); @@ -139,4 +98,3 @@ -if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp_x for firefox - if (!$canbemodified) { - httponly_accessforbidden('ErrorForbidden'); - } +if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp_x for firefox +{ + if (!$canbemodified) accessforbidden('', 0, 0, 1); @@ -145 +103,2 @@ - if (GETPOST('nom', 'alphanohtml')) { + if (GETPOST('nom', 'nohtml')) + { @@ -147,2 +106,4 @@ - for ($i = 0; $i < $nbcolonnes; $i++) { - if (GETPOSTISSET("choix".$i) && GETPOST("choix".$i) == '1') { + for ($i = 0; $i < $nbcolonnes; $i++) + { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') + { @@ -150 +111,3 @@ - } elseif (GETPOSTISSET("choix".$i) && GETPOST("choix".$i) == '2') { + } + elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') + { @@ -152 +115,2 @@ - } else { + } + else { // sinon c'est 0 @@ -157,25 +121 @@ - $user_ip = getUserRemoteIP(); - $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200); - $now = dol_now(); - $minmonthpost = dol_time_plus_duree($now, -1, "m"); - // Calculate nb of post for IP - $nb_post_ip = 0; - if ($nb_post_max > 0) { // Calculate only if there is a limit to check - $sql = "SELECT COUNT(id_users) as nb_records"; - $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql .= " WHERE ip = '".$db->escape($user_ip)."'"; - $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $i++; - $obj = $db->fetch_object($resql); - $nb_post_ip = $obj->nb_records; - } - } - } - - - $nom = substr(GETPOST("nom", 'alphanohtml'), 0, 64); + $nom = substr(GETPOST("nom", 'nohtml'), 0, 64); @@ -188,3 +128 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -193,2 +131,2 @@ - - if ($num_rows > 0) { + if ($num_rows > 0) + { @@ -197,7 +135,5 @@ - } elseif ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) { - setEventMessages($langs->trans("AlreadyTooMuchPostOnThisIPAdress"), null, 'errors'); - $error++; - } else { - $now = dol_now(); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, ip, date_creation)'; - $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."', '".$db->escape($user_ip)."', '".$db->idate($now)."')"; + } + else + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; @@ -206 +142,2 @@ - if ($resql) { + if ($resql) + { @@ -211 +148,2 @@ - if ($object->mailsonde) { + if ($object->mailsonde) + { @@ -227,3 +165 @@ - $link = getUrlSondage($numsondage, true); - $link = '<a href="'.$link.'">'.$link.'</a>'; - $body = str_replace('\n', '<br>', $langs->transnoentities('EmailSomeoneVoted', $nom, $link)); + $body = str_replace('\n', '<br>', $langs->transnoentities('EmailSomeoneVoted', $nom, getUrlSondage($numsondage, true))); @@ -232 +168 @@ - $cmailfile = new CMailFile("[".$application."] ".$langs->trans("Poll").': '.$object->title, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body, null, null, null, '', '', 0, -1); + $cmailfile = new CMailFile("[".$application."] ".$langs->trans("Poll").': '.$object->titre, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body, null, null, null, '', '', 0, -1); @@ -236,5 +172,6 @@ - } else { - dol_print_error($db); - } - } - } else { + } + else dol_print_error($db); + } + } + else + { @@ -250,2 +187,4 @@ -for ($i = 0; $i < $nblines; $i++) { - if (GETPOSTISSET('modifierligne'.$i)) { +for ($i = 0; $i < $nblines; $i++) +{ + if (isset($_POST['modifierligne'.$i])) + { @@ -257 +196,2 @@ - if (GETPOSTISSET('validermodifier'.$i)) { + if (isset($_POST['validermodifier'.$i])) + { @@ -263 +203,3 @@ -if ($testmodifier) { +if ($testmodifier) +{ + //var_dump($_POST);exit; @@ -265,2 +207,5 @@ - for ($i = 0; $i < $nbcolonnes; $i++) { - if (GETPOSTISSET("choix".$i) && GETPOST("choix".$i) == '1') { + for ($i = 0; $i < $nbcolonnes; $i++) + { + //var_dump($_POST["choix$i"]); + if (isset($_POST["choix".$i]) && $_POST["choix".$i] == '1') + { @@ -268 +213,3 @@ - } elseif (GETPOSTISSET("choix".$i) && GETPOST("choix".$i) == '2') { + } + elseif (isset($_POST["choix".$i]) && $_POST["choix".$i] == '2') + { @@ -270 +217,2 @@ - } else { + } + else { // sinon c'est 0 @@ -275,5 +223,3 @@ - if (!$canbemodified) { - httponly_accessforbidden('ErrorForbidden'); - } - - $idtomodify = GETPOST("idtomodify".$modifier); + if (!$canbemodified) accessforbidden('', 0, 0, 1); + + $idtomodify = $_POST["idtomodify".$modifier]; @@ -285,3 +231 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -292,4 +236,3 @@ -if ($idcomment) { - if (!$canbemodified) { - httponly_accessforbidden('ErrorForbidden'); - } +if ($idcomment) +{ + if (!$canbemodified) accessforbidden('', 0, 0, 1); @@ -311,3 +254,4 @@ -llxHeaderSurvey($object->title, "", 0, 0, $arrayofjs, $arrayofcss, $numsondage); - -if (empty($object->ref)) { // For survey, id is a hex string +llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss, $numsondage); + +if (empty($object->ref)) // For survey, id is a hex string +{ @@ -326 +270,2 @@ -foreach ($toutsujet as $value) { +foreach ($toutsujet as $value) +{ @@ -328 +273 @@ - $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox')); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); @@ -333 +278 @@ -print '<div class="survey_intro">'; + @@ -335,12 +280,12 @@ -print '<span class="opacitymedium">'.$langs->trans("OpenSurveyHowTo").'</span><br>'; -if (empty($object->allow_spy)) { - print '<span class="opacitymedium">'.$langs->trans("YourVoteIsPrivate").'</span><br>'; -} else { - print $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("YourVoteIsPublic").'</span>', $langs->trans("CanSeeOthersVote")).'<br>'; -} -print '</div>'; -print '<br>'; - -if (empty($object->description)) { - print '<div class="corps">'."\n"; -} else { +print $langs->trans("OpenSurveyHowTo").'<br><br>'; + +print '<div class="corps"> '."\n"; + +//affichage du titre du sondage +$titre = str_replace("\\", "", $object->titre); +print '<strong>'.dol_htmlentities($titre).'</strong><br><br>'."\n"; + +//affichage des commentaires du sondage +if ($object->commentaires) +{ + print dol_htmlentitiesbr($object->commentaires); @@ -348,13 +292,0 @@ -} - -// show title of survey -$titre = str_replace("\\", "", $object->title); -print '<div class="survey_title">'.img_picto('', 'poll', 'class="size15x paddingright"').' <strong>'.dol_htmlentities($titre).'</strong></div>'; - -if (!empty($object->description)) { - print '<br><div class="corps">'."\n"; -} - -// show description of survey -if ($object->description) { - print dol_htmlentitiesbr($object->description); @@ -367 +299 @@ - print '<br><center><div class="quatrevingtpercent center warning">'.$langs->trans('SurveyExpiredInfo').'</div></center>'; + print '<div style="text-align: center"><p>'.$langs->trans('SurveyExpiredInfo').'</p></div>'; @@ -378 +309,0 @@ -print '<div class="div-table-responsive">'; @@ -382 +313,2 @@ -if ($object->format == "D") { +if ($object->format == "D") +{ @@ -390 +322,2 @@ - for ($i = 0; $i < $nbofsujet; $i++) { + for ($i = 0; $i < $nbofsujet; $i++) + { @@ -435 +368 @@ - if ($next && dol_print_date($cur, "%a %d") == dol_print_date($next, "%a %d") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { + if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { @@ -438 +371 @@ - print '<td colspan="'.$colspan.'" class="jour">'.dol_print_date($cur, "%a %d").'</td>'."\n"; + print '<td colspan="'.$colspan.'" class="jour">'.dol_print_date($cur, "%a %e").'</td>'."\n"; @@ -461 +394,3 @@ -} else { +} +else +{ @@ -466 +401,2 @@ - for ($i = 0; isset($toutsujet[$i]); $i++) { + for ($i = 0; isset($toutsujet[$i]); $i++) + { @@ -468 +404 @@ - print '<td class="sujet">'.dol_escape_htmltag($tmp[0]).'</td>'."\n"; + print '<td class="sujet">'.$tmp[0].'</td>'."\n"; @@ -476 +411,0 @@ -$currentusername = ''; @@ -484 +419,2 @@ -if (!$resql) { +if (!$resql) +{ @@ -489 +425,2 @@ -while ($compteur < $num) { +while ($compteur < $num) +{ @@ -505 +442 @@ - print '<td class="nom">'.img_picto($obj->name, 'user', 'class="pictofixedwidth"').dol_htmlentities($obj->name).'</td>'."\n"; + print '<td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n"; @@ -508,2 +445,4 @@ - if (!$testligneamodifier) { - for ($i = 0; $i < $nbcolonnes; $i++) { + if (!$testligneamodifier) + { + for ($i = 0; $i < $nbcolonnes; $i++) + { @@ -513,6 +452,4 @@ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { - if (((string) $car) == "1") { - print '<td class="ok">OK</td>'."\n"; - } else { - print '<td class="non">KO</td>'."\n"; - } + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) + { + if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n"; + else print '<td class="non">KO</td>'."\n"; @@ -520,15 +457,8 @@ - if (!isset($sumfor[$i])) { - $sumfor[$i] = 0; - } - if (((string) $car) == "1") { - $sumfor[$i]++; - } - } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - if (((string) $car) == "1") { - print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n"; - } elseif (((string) $car) == "0") { - print '<td class="non">'.$langs->trans("No").'</td>'."\n"; - } else { - print '<td class="vide"> </td>'."\n"; - } + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (((string) $car) == "1") $sumfor[$i]++; + } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + { + if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n"; + elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n"; + else print '<td class="vide"> </td>'."\n"; @@ -536,21 +466,10 @@ - if (!isset($sumfor[$i])) { - $sumfor[$i] = 0; - } - if (!isset($sumagainst[$i])) { - $sumagainst[$i] = 0; - } - if (((string) $car) == "1") { - $sumfor[$i]++; - } - if (((string) $car) == "0") { - $sumagainst[$i]++; - } - } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - if (((string) $car) == "1") { - print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - } elseif (((string) $car) == "0") { - print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - } else { - print '<td class="vide"> </td>'."\n"; - } + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (((string) $car) == "1") $sumfor[$i]++; + if (((string) $car) == "0") $sumagainst[$i]++; + } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + { + if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + else print '<td class="vide"> </td>'."\n"; @@ -558,18 +477,14 @@ - if (!isset($sumfor[$i])) { - $sumfor[$i] = 0; - } - if (!isset($sumagainst[$i])) { - $sumagainst[$i] = 0; - } - if (((string) $car) == "1") { - $sumfor[$i]++; - } - if (((string) $car) == "0") { - $sumagainst[$i]++; - } - } - } - } else { - //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour saisie - if ($compteur == $ligneamodifier) { - for ($i = 0; $i < $nbcolonnes; $i++) { + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (((string) $car) == "1") $sumfor[$i]++; + if (((string) $car) == "0") $sumagainst[$i]++; + } + } + } + else + { + //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs + if ($compteur == $ligneamodifier) + { + for ($i = 0; $i < $nbcolonnes; $i++) + { @@ -578 +493,2 @@ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) + { @@ -580,3 +496 @@ - if ($car == '1') { - print 'checked'; - } + if ($car == '1') print 'checked'; @@ -585 +499,2 @@ - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + { @@ -589 +504,2 @@ - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + { @@ -595,2 +511,5 @@ - } else { - for ($i = 0; $i < $nbcolonnes; $i++) { + } + else + { + for ($i = 0; $i < $nbcolonnes; $i++) + { @@ -598,6 +517,4 @@ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { - if (((string) $car) == "1") { - print '<td class="ok">OK</td>'."\n"; - } else { - print '<td class="non">KO</td>'."\n"; - } + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) + { + if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n"; + else print '<td class="non">KO</td>'."\n"; @@ -605,6 +522,2 @@ - if (!isset($sumfor[$i])) { - $sumfor[$i] = 0; - } - if (((string) $car) == "1") { - $sumfor[$i]++; - } + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (((string) $car) == "1") $sumfor[$i]++; @@ -612,8 +525,5 @@ - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - if (((string) $car) == "1") { - print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - } elseif (((string) $car) == "0") { - print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - } else { - print '<td class="vide"> </td>'."\n"; - } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + { + if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + else print '<td class="vide"> </td>'."\n"; @@ -621,12 +531,4 @@ - if (!isset($sumfor[$i])) { - $sumfor[$i] = 0; - } - if (!isset($sumagainst[$i])) { - $sumagainst[$i] = 0; - } - if (((string) $car) == "1") { - $sumfor[$i]++; - } - if (((string) $car) == "0") { - $sumagainst[$i]++; - } + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (((string) $car) == "1") $sumfor[$i]++; + if (((string) $car) == "0") $sumagainst[$i]++; @@ -634,8 +536,5 @@ - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - if (((string) $car) == "1") { - print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - } elseif (((string) $car) == "0") { - print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - } else { - print '<td class="vide"> </td>'."\n"; - } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + { + if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + else print '<td class="vide"> </td>'."\n"; @@ -643,12 +542,4 @@ - if (!isset($sumfor[$i])) { - $sumfor[$i] = 0; - } - if (!isset($sumagainst[$i])) { - $sumagainst[$i] = 0; - } - if (((string) $car) == "1") { - $sumfor[$i]++; - } - if (((string) $car) == "0") { - $sumagainst[$i]++; - } + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (((string) $car) == "1") $sumfor[$i]++; + if (((string) $car) == "0") $sumagainst[$i]++; @@ -661,3 +552,3 @@ - if ($compteur != $ligneamodifier && $mod_ok) { - $currentusername = $obj->name; - print '<td class="casevide"><input type="submit" class="button small" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n"; + if ($compteur != $ligneamodifier && $mod_ok) + { + print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n"; @@ -667,3 +558,6 @@ - for ($i = 0; $i < $nblines; $i++) { - if (GETPOSTISSET("modifierligne".$i)) { - if ($compteur == $i) { + for ($i = 0; $i < $nblines; $i++) + { + if (isset($_POST["modifierligne".$i])) + { + if ($compteur == $i) + { @@ -672 +566 @@ - print '<input type="submit" class="button button-save small" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; + print '<input type="submit" class="button" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; @@ -683 +577,2 @@ -if ($ligneamodifier < 0 && (!isset($_SESSION['nom']))) { +if ($ligneamodifier < 0 && (!isset($_SESSION['nom']))) +{ @@ -686 +581,2 @@ - if (isset($_SESSION['nom'])) { + if (isset($_SESSION['nom'])) + { @@ -689 +585 @@ - print '<input type="text" name="nom" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" maxlength="64" class=" minwidth175" value="">'."\n"; + print '<input type="text" name="nom" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" maxlength="64" size="24">'."\n"; @@ -693,2 +589,3 @@ - // show cell form checkbox for a new choice - for ($i = 0; $i < $nbcolonnes; $i++) { + // affichage des cases de formulaire checkbox pour un nouveau choix + for ($i = 0; $i < $nbcolonnes; $i++) + { @@ -696 +593,2 @@ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) + { @@ -698 +596,2 @@ - if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') { + if (isset($_POST['choix'.$i]) && $_POST['choix'.$i] == '1') + { @@ -703 +602,2 @@ - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + { @@ -707 +607,2 @@ - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + { @@ -714,2 +615,2 @@ - // Show button to add a new line into database - print '<td><input type="image" class="borderimp" name="boutonp" value="'.$langs->trans("Vote").'" src="'.img_picto('', 'edit_add', '', false, 1).'"></td>'."\n"; + // Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base + print '<td><input type="image" name="boutonp" value="'.$langs->trans("Vote").'" src="'.dol_buildpath('/opensurvey/img/add-24.png', 1).'"></td>'."\n"; @@ -721,6 +622,8 @@ -for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { - $nbofcheckbox++; - } - if (isset($sumfor[$i])) { - if ($i == 0) { +for ($i = 0; $i < $nbcolonnes; $i++) +{ + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) + $nbofcheckbox++; + if (isset($sumfor[$i])) + { + if ($i == 0) + { @@ -729 +632,2 @@ - if (!isset($meilleurecolonne) || $sumfor[$i] > $meilleurecolonne) { + if (!isset($meilleurecolonne) || $sumfor[$i] > $meilleurecolonne) + { @@ -739 +643,2 @@ - for ($i = 0; $i < $nbcolonnes; $i++) { + for ($i = 0; $i < $nbcolonnes; $i++) + { @@ -742,6 +647,2 @@ - if (empty($showsumfor)) { - $showsumfor = 0; - } - if (empty($showsumagainst)) { - $showsumagainst = 0; - } + if (empty($showsumfor)) $showsumfor = 0; + if (empty($showsumagainst)) $showsumagainst = 0; @@ -750,9 +651,3 @@ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { - print $showsumfor; - } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst; - } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst; - } + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst; @@ -763 +658,2 @@ - if ($nbofcheckbox >= 2) { + if ($nbofcheckbox >= 2) + { @@ -766,3 +662,5 @@ - for ($i = 0; $i < $nbcolonnes; $i++) { - //print 'xx'.(!empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { + for ($i = 0; $i < $nbcolonnes; $i++) + { + //print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) + { @@ -780,2 +677,0 @@ -print '</div>'."\n"; - @@ -791 +687 @@ - $meilleursujet .= ($meilleursujet ? ", " : ""); + $meilleursujet .= ", "; @@ -792,0 +689,2 @@ + $meilleursujetexport = $toutsujet[$i]; + @@ -797 +695 @@ - $meilleursujet .= dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), 'daytext').' ('.dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), '%A').')'; + $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext').' ('.dol_print_date($toutsujet[$i], '%A').')'; @@ -799 +697,3 @@ - } else { + } + else + { @@ -808 +708 @@ - //$meilleursujet = substr($meilleursujet, 1); + $meilleursujet = substr("$meilleursujet", 1); @@ -810,0 +711 @@ + @@ -812 +713,2 @@ - if ($nbofcheckbox >= 2) { + if ($nbofcheckbox >= 2) + { @@ -817 +719 @@ - print '<img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"> '.$langs->trans('TheBestChoice').": <b>".$meilleursujet."</b> - <b>".$meilleurecolonne."</b> ".$vote_str.".\n"; + print '<img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"> '.$langs->trans('TheBestChoice').": <b>".$meilleursujet."</b> ".$langs->trans('with')." <b>$meilleurecolonne </b>".$vote_str.".\n"; @@ -819 +721 @@ - print '<img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"> '.$langs->trans('TheBestChoices').": <b>".$meilleursujet."</b> - <b>".$meilleurecolonne."</b> ".$vote_str.".\n"; + print '<img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"> '.$langs->trans('TheBestChoices').": <b>".$meilleursujet."</b> ".$langs->trans('with')." <b>$meilleurecolonne </b>".$vote_str.".\n"; @@ -832,2 +734,3 @@ -if ($comments) { - print '<br>'.img_picto('', 'note', 'class="pictofixedwidth"').'<span class="bold opacitymedium">'.$langs->trans("CommentsOfVoters").':</span><br>'."\n"; +if ($comments) +{ + print "<br><b>".$langs->trans("CommentsOfVoters").":</b><br>\n"; @@ -840,3 +743 @@ - if (in_array($obj->usercomment, $listofvoters)) { - print '<a href="'.$_SERVER["PHP_SELF"].'?deletecomment='.$obj->id_comment.'&sondage='.$numsondage.'"> '.img_picto('', 'delete.png', '', false, 0, 0, '', 'nomarginleft').'</a> '; - } + if (in_array($obj->usercomment, $listofvoters)) print '<a href="'.$_SERVER["PHP_SELF"].'?deletecomment='.$obj->id_comment.'&sondage='.$numsondage.'"> '.img_picto('', 'delete.png', '', false, 0, 0, '', 'nomarginleft').'</a> '; @@ -844 +745 @@ - print img_picto('', 'user', 'class="pictofixedwidth"').dol_htmlentities($obj->usercomment).':</span> <span class="comment">'.dol_nl2br(dol_htmlentities($obj->comment))."</span></div>"; + print dol_htmlentities($obj->usercomment).':</span> <span class="comment">'.dol_nl2br(dol_htmlentities($obj->comment))."</span></div>"; @@ -849,4 +750,4 @@ -if ($object->allow_comments && $currentusername) { - print '<br><div class="addcomment"><span class="opacitymedium">'.$langs->trans("AddACommentForPoll")."</span><br>\n"; - - print '<textarea name="comment" rows="'.ROWS_2.'" class="quatrevingtpercent">'.dol_escape_htmltag(GETPOST('comment', 'alphanohtml'), 0, 1).'</textarea><br>'."\n"; +if ($object->allow_comments) { + print '<div class="addcomment">'.$langs->trans("AddACommentForPoll")."<br>\n"; + + print '<textarea name="comment" rows="'.ROWS_2.'" class="quatrevingtpercent">'.dol_escape_htmltag(GETPOST('comment', 'none'), 0, 1).'</textarea><br>'."\n"; @@ -854,2 +755,2 @@ - print '<input type="text" name="commentuser" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET('commentuser') ? GETPOST('commentuser', 'alphanohtml') : (empty($_SESSION['nom']) ? $currentusername : $_SESSION['nom'])).'"> '."\n"; - print '<input type="submit" class="button smallpaddingimp" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n"; + print '<input type="text" name="commentuser" maxlength="64" value="'.GETPOST('commentuser', 'nohtml').'"> '."\n"; + print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";