';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
print '
'.$opensurvey_static->getLibStatut(5).'
'."\n";
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
@@ -426,14 +476,17 @@ while ($i < min($num, $limit))
print $hookmanager->resPrint;
// Action column
print '
';
- if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- {
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
print '';
}
print '
';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
print ''."\n";
$i++;
@@ -444,10 +497,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
-if ($num == 0)
-{
+if ($num == 0) {
$colspan = 8;
- foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
print '
'.$langs->trans("NoRecordFound").'
';
}
@@ -463,10 +519,11 @@ print '
'."\n";
print ''."\n";
-if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
-{
+if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$hidegeneratedfilelistifempty = 1;
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
+ $hidegeneratedfilelistifempty = 0;
+ }
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php
index ea07900ba67..cea5cdbcbee 100644
--- a/htdocs/opensurvey/results.php
+++ b/htdocs/opensurvey/results.php
@@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
// Security check
-if (!$user->rights->opensurvey->read) accessforbidden();
+if (!$user->rights->opensurvey->read) {
+ accessforbidden();
+}
// Init vars
@@ -40,7 +42,9 @@ $numsondage = GETPOST("id");
$object = new Opensurveysondage($db);
$result = $object->fetch(0, $numsondage);
-if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage);
+if ($result <= 0) {
+ dol_print_error('', 'Failed to get survey id '.$numsondage);
+}
$nblines = $object->fetch_lines();
@@ -58,20 +62,15 @@ if (GETPOST('retoursondage')) {
$nbcolonnes = substr_count($object->sujet, ',') + 1;
// Add vote
-if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp.x for firefox
-{
- if (GETPOST('nom'))
- {
+if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp.x for firefox
+ if (GETPOST('nom')) {
$erreur_prenom = false;
$nouveauchoix = '';
- for ($i = 0; $i < $nbcolonnes; $i++)
- {
- if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
- {
+ for ($i = 0; $i < $nbcolonnes; $i++) {
+ if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') {
$nouveauchoix .= "1";
- } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
- {
+ } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') {
$nouveauchoix .= "2";
} else { // sinon c'est 0
$nouveauchoix .= "0";
@@ -87,15 +86,16 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout
$sql .= ' ORDER BY id_users';
$resql = $db->query($sql);
$num_rows = $db->num_rows($resql);
- if ($num_rows > 0)
- {
+ if ($num_rows > 0) {
setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors');
$error++;
} 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)."')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
}
@@ -104,35 +104,30 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout
$testmodifier = false;
$testligneamodifier = false;
$ligneamodifier = -1;
-for ($i = 0; $i < $nblines; $i++)
-{
- if (isset($_POST['modifierligne'.$i]))
- {
+for ($i = 0; $i < $nblines; $i++) {
+ if (isset($_POST['modifierligne'.$i])) {
$ligneamodifier = $i;
$testligneamodifier = true;
}
//test pour voir si une ligne est a modifier
- if (isset($_POST['validermodifier'.$i]))
- {
+ if (isset($_POST['validermodifier'.$i])) {
$modifier = $i;
$testmodifier = true;
}
}
-if ($testmodifier)
-{
+if ($testmodifier) {
// Security check
- if (!$user->rights->opensurvey->write) accessforbidden();
+ if (!$user->rights->opensurvey->write) {
+ accessforbidden();
+ }
$nouveauchoix = '';
- for ($i = 0; $i < $nbcolonnes; $i++)
- {
+ for ($i = 0; $i < $nbcolonnes; $i++) {
//var_dump($_POST["choix$i"]);
- if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
- {
+ if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') {
$nouveauchoix .= "1";
- } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
- {
+ } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') {
$nouveauchoix .= "2";
} else { // sinon c'est 0
$nouveauchoix .= "0";
@@ -145,14 +140,17 @@ if ($testmodifier)
$sql .= " WHERE id_users = '".$db->escape($idtomodify)."'";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
// Add column (not for date)
-if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A")
-{
+if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") {
// Security check
- if (!$user->rights->opensurvey->write) accessforbidden();
+ if (!$user->rights->opensurvey->write) {
+ accessforbidden();
+ }
$nouveauxsujets = $object->sujet;
@@ -165,17 +163,19 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format =
$sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'";
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
- else {
+ if (!$resql) {
+ dol_print_error($db);
+ } else {
header('Location: results.php?id='.$object->id_sondage);
}
}
// Add column (with format date)
-if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
-{
+if (isset($_POST["ajoutercolonne"]) && $object->format == "D") {
// Security check
- if (!$user->rights->opensurvey->write) accessforbidden();
+ if (!$user->rights->opensurvey->write) {
+ accessforbidden();
+ }
$nouveauxsujets = $object->sujet;
@@ -223,8 +223,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
$cleinsertion = count($datesbase);
} else {
$nbdatesbase = count($datesbase);
- for ($i = 0; $i < $nbdatesbase; $i++)
- {
+ for ($i = 0; $i < $nbdatesbase; $i++) {
$j = $i + 1;
if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
$cleinsertion = $j;
@@ -244,14 +243,14 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
$dateinsertion = substr("$dateinsertion", 1);
// update with new topics into database
- if (isset($erreur_ajout_date) && empty($erreur_ajout_date))
- {
+ if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
$sql .= " SET sujet = '".$db->escape($dateinsertion)."'";
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
- else {
+ if (!$resql) {
+ dol_print_error($db);
+ } else {
header('Location: results.php?id='.$object->id_sondage);
}
}
@@ -263,12 +262,12 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
}
// Delete line
-for ($i = 0; $i < $nblines; $i++)
-{
- if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) // effacelignei for chrome, effacelignei_x for firefox
- {
- // Security check
- if (!$user->rights->opensurvey->write) accessforbidden();
+for ($i = 0; $i < $nblines; $i++) {
+ if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox
+ // Security check
+ if (!$user->rights->opensurvey->write) {
+ accessforbidden();
+ }
$compteur = 0;
@@ -278,14 +277,14 @@ for ($i = 0; $i < $nblines; $i++)
$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
$num = $db->num_rows($resql);
- while ($compteur < $num)
- {
+ while ($compteur < $num) {
$obj = $db->fetch_object($resql);
- if ($compteur == $i)
- {
+ if ($compteur == $i) {
$sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs';
$sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users);
$resql2 = $db->query($sql2);
@@ -297,13 +296,13 @@ for ($i = 0; $i < $nblines; $i++)
}
// Delete column
-for ($i = 0; $i < $nbcolonnes; $i++)
-{
+for ($i = 0; $i < $nbcolonnes; $i++) {
if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x"))
- && $nbcolonnes > 1) // effacecolonnei for chrome, effacecolonnei_x for firefox
- {
- // Security check
- if (!$user->rights->opensurvey->write) accessforbidden();
+ && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox
+ // Security check
+ if (!$user->rights->opensurvey->write) {
+ accessforbidden();
+ }
$db->begin();
@@ -312,12 +311,12 @@ for ($i = 0; $i < $nbcolonnes; $i++)
$nouveauxsujets = '';
//parcours de tous les sujets actuels
- while (isset($toutsujet[$j]))
- {
+ while (isset($toutsujet[$j])) {
//si le sujet n'est pas celui qui a été effacé alors on concatene
- if ($i != $j)
- {
- if (!empty($nouveauxsujets)) $nouveauxsujets .= ',';
+ if ($i != $j) {
+ if (!empty($nouveauxsujets)) {
+ $nouveauxsujets .= ',';
+ }
$nouveauxsujets .= $toutsujet[$j];
}
@@ -328,7 +327,9 @@ for ($i = 0; $i < $nbcolonnes; $i++)
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
$sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
// Clean current answer to remove deleted columns
$compteur = 0;
@@ -337,22 +338,19 @@ for ($i = 0; $i < $nbcolonnes; $i++)
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
dol_syslog('sql='.$sql);
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
- while ($compteur < $num)
- {
+ while ($compteur < $num) {
$obj = $db->fetch_object($resql);
$newcar = '';
$ensemblereponses = $obj->reponses;
// parcours de toutes les réponses actuelles
- for ($j = 0; $j < $nbcolonnes; $j++)
- {
+ for ($j = 0; $j < $nbcolonnes; $j++) {
$car = substr($ensemblereponses, $j, 1);
//si les reponses ne concerne pas la colonne effacée, on concatene
if ($i != $j) {
@@ -389,8 +387,7 @@ if ($object->fk_user_creat) {
}
$result = $object->fetch(0, $numsondage);
-if ($result <= 0)
-{
+if ($result <= 0) {
dol_print_error($db, $object->error);
exit;
}
@@ -405,8 +402,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
// Define format of choices
$toutsujet = explode(",", $object->sujet);
$listofanswers = array();
-foreach ($toutsujet as $value)
-{
+foreach ($toutsujet as $value) {
$tmp = explode('@', $value);
$listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox'));
}
@@ -452,10 +448,13 @@ print '';
// Expire date
print '