Small cleaning of choix_date.php
This commit is contained in:
parent
514369387b
commit
9017676f70
@ -5,7 +5,7 @@
|
|||||||
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
||||||
*
|
*
|
||||||
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
||||||
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
|
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft https://git.framasoft.org/framasoft/framadate/)
|
||||||
*
|
*
|
||||||
* =============================
|
* =============================
|
||||||
*
|
*
|
||||||
@ -14,7 +14,7 @@
|
|||||||
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
||||||
*
|
*
|
||||||
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft https://git.framasoft.org/framasoft/framadate/)
|
||||||
*/
|
*/
|
||||||
namespace Framadate;
|
namespace Framadate;
|
||||||
|
|
||||||
@ -31,13 +31,13 @@ if (is_readable('bandeaux_local.php')) {
|
|||||||
// Step 1/3 : error if $_SESSION from info_sondage are not valid
|
// Step 1/3 : error if $_SESSION from info_sondage are not valid
|
||||||
if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || (($config['use_smtp']) ? Utils::issetAndNoEmpty('adresse', $_SESSION) === false : false)) {
|
if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || (($config['use_smtp']) ? Utils::issetAndNoEmpty('adresse', $_SESSION) === false : false)) {
|
||||||
|
|
||||||
Utils::print_header ( _("Error!") );
|
Utils::print_header ( _('Error!') );
|
||||||
bandeau_titre(_("Error!"));
|
bandeau_titre(_('Error!'));
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="alert alter-danger">
|
<div class="alert alter-danger">
|
||||||
<h3>' . _("You haven't filled the first section of the poll creation.") . ' !</h3>
|
<h3>' . _('You haven\'t filled the first section of the poll creation.') . ' !</h3>
|
||||||
<p>' . _("Back to the homepage of ") . ' ' . '<a href="' . Utils::get_server_name() . '">' . NOMAPPLICATION . '</a>.</p>
|
<p>' . _('Back to the homepage of ') . ' ' . '<a href="' . Utils::get_server_name() . '">' . NOMAPPLICATION . '</a>.</p>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
bandeau_pied();
|
bandeau_pied();
|
||||||
@ -46,19 +46,19 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
// Step 4 : Data prepare before insert in DB
|
// Step 4 : Data prepare before insert in DB
|
||||||
if (Utils::issetAndNoEmpty('confirmation')) {
|
if (Utils::issetAndNoEmpty('confirmation')) {
|
||||||
$temp_results = array();
|
$temp_results = array();
|
||||||
$choixdate='';
|
$choixdate = '';
|
||||||
if (Utils::issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
if (Utils::issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
||||||
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
|
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); ++$i) {
|
||||||
if(count($_SESSION['horaires'.$i])!=0) {
|
if(count($_SESSION['horaires'.$i])!=0) {
|
||||||
for ($j=0;$j< min(count($_SESSION['horaires'.$i]),12);$j++) {
|
for ($j=0; $j< min(count($_SESSION['horaires'.$i]),12); ++$j) {
|
||||||
if ($_SESSION['horaires'.$i][$j]!="") {
|
if ($_SESSION['horaires'.$i][$j] != '') {
|
||||||
array_push($temp_results, $_SESSION["totalchoixjour"][$i].'@'.$_SESSION['horaires'.$i][$j]);
|
array_push($temp_results, $_SESSION["totalchoixjour"][$i].'@'.$_SESSION['horaires'.$i][$j]);
|
||||||
} else {
|
} else {
|
||||||
array_push($temp_results, $_SESSION["totalchoixjour"][$i]);
|
array_push($temp_results, $_SESSION["totalchoixjour"][$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
array_push($temp_results, $_SESSION["totalchoixjour"][$i]);
|
array_push($temp_results, $_SESSION['totalchoixjour'][$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,23 +67,24 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
// Sort and remove doublons
|
// Sort and remove doublons
|
||||||
$temp_results = array_unique($temp_results);
|
$temp_results = array_unique($temp_results);
|
||||||
sort($temp_results);
|
sort($temp_results);
|
||||||
for ($i=0;$i<count($temp_results);$i++) {
|
for ($i=0; $i < count($temp_results); ++$i) {
|
||||||
if (isset($temp_results[$i])) {
|
if (isset($temp_results[$i])) {
|
||||||
$choixdate.=','.$temp_results[$i];
|
$choixdate .= ','. $temp_results[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION["toutchoix"]=substr($choixdate,1);
|
$_SESSION['toutchoix'] = substr($choixdate, 1);
|
||||||
|
|
||||||
// Expiration date → 6 months after last day if not filled or in bad format
|
// Expiration date → 6 months after last day if not filled or in bad format
|
||||||
$_SESSION["champdatefin"]=end($temp_results)+(86400 * $config['default_poll_duration']);
|
// 86400 = 60*60*24
|
||||||
|
$_SESSION['champdatefin']=end($temp_results)+(86400 * $config['default_poll_duration']);
|
||||||
|
|
||||||
if (Utils::issetAndNoEmpty('champdatefin')) {
|
if (Utils::issetAndNoEmpty('champdatefin')) {
|
||||||
$registredate = explode("/",$_POST["champdatefin"]);
|
$registredate = explode('/', $_POST['champdatefin']);
|
||||||
if (is_array($registredate) == true && count($registredate) == 3) {
|
if (is_array($registredate) == true && count($registredate) == 3) {
|
||||||
$time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]);
|
$time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]);
|
||||||
if ($time > time() + (24*60*60)) {
|
if ($time > time() + 86400) {
|
||||||
$_SESSION["champdatefin"]=$time;
|
$_SESSION['champdatefin'] = $time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,16 +93,20 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (Utils::issetAndNoEmpty('days')) {
|
if (Utils::issetAndNoEmpty('days')) {
|
||||||
if (!isset($_SESSION["totalchoixjour"])) {
|
if (!isset($_SESSION['totalchoixjour'])) {
|
||||||
$_SESSION["totalchoixjour"]=array();
|
$_SESSION['totalchoixjour'] = array();
|
||||||
}
|
}
|
||||||
$k = 0;
|
$k = 0;
|
||||||
for ($i = 0; $i < count($_POST["days"]); $i++) {
|
for ($i = 0; $i < count($_POST['days']); ++$i) {
|
||||||
if (isset($_POST["days"][$i]) && $_POST["days"][$i] !='') {
|
if (isset($_POST['days'][$i]) && $_POST['days'][$i] !='') {
|
||||||
$_SESSION['totalchoixjour'][$k] = mktime(0, 0, 0, substr($_POST["days"][$i],3,2),substr($_POST["days"][$i],0,2),substr($_POST["days"][$i],6,4));
|
$_SESSION['totalchoixjour'][$k] = mktime(
|
||||||
|
0, 0, 0,
|
||||||
|
substr($_POST["days"][$i], 3, 2),
|
||||||
|
substr($_POST['days'][$i], 0, 2),
|
||||||
|
substr($_POST['days'][$i], 6, 4));
|
||||||
|
|
||||||
$l = 0;
|
$l = 0;
|
||||||
for($j = 0; $j < count($_POST['horaires'.$i]); $j++) {
|
for($j = 0; $j < count($_POST['horaires'.$i]); ++$j) {
|
||||||
if (isset($_POST['horaires'.$i][$j]) && $_POST['horaires'.$i][$j] != '') {
|
if (isset($_POST['horaires'.$i][$j]) && $_POST['horaires'.$i][$j] != '') {
|
||||||
$_SESSION['horaires'.$k][$l] = $_POST['horaires'.$i][$j];
|
$_SESSION['horaires'.$k][$l] = $_POST['horaires'.$i][$j];
|
||||||
$l++;
|
$l++;
|
||||||
@ -114,23 +119,26 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//le format du sondage est DATE
|
//le format du sondage est DATE
|
||||||
$_SESSION["formatsondage"] = "D".$_SESSION["studsplus"];
|
$_SESSION['formatsondage'] = 'D'. $_SESSION['studsplus'];
|
||||||
|
|
||||||
// Step 3/3 : Confirm poll creation
|
// Step 3/3 : Confirm poll creation
|
||||||
if (Utils::issetAndNoEmpty('choixheures') && Utils::issetAndNoEmpty('totalchoixjour', $_SESSION)) {
|
if (Utils::issetAndNoEmpty('choixheures') && Utils::issetAndNoEmpty('totalchoixjour', $_SESSION)) {
|
||||||
|
|
||||||
Utils::print_header ( _("Removal date and confirmation (3 on 3)") );
|
Utils::print_header ( _('Removal date and confirmation (3 on 3)') );
|
||||||
bandeau_titre(_("Removal date and confirmation (3 on 3)"));
|
bandeau_titre(_('Removal date and confirmation (3 on 3)'));
|
||||||
|
|
||||||
$temp_array = array_unique($_SESSION["totalchoixjour"]);
|
$temp_array = array_unique($_SESSION['totalchoixjour']);
|
||||||
sort($temp_array);
|
sort($temp_array);
|
||||||
$removal_date=utf8_encode(strftime($date_format['txt_full'], end($temp_array)+ (86400 * $config['default_poll_duration'])));
|
$removal_date = utf8_encode(
|
||||||
|
strftime($date_format['txt_full'],
|
||||||
|
end($temp_array) + (86400 * $config['default_poll_duration']))
|
||||||
|
);
|
||||||
|
|
||||||
// Sumary
|
// Sumary
|
||||||
$summary = '<ul>';
|
$summary = '<ul>';
|
||||||
for ($i=0;$i<count($_SESSION["totalchoixjour"]);$i++) {
|
for ($i=0; $i < count($_SESSION['totalchoixjour']); ++$i) {
|
||||||
$summary .= '<li>'.strftime($date_format['txt_full'], $_SESSION["totalchoixjour"][$i]);
|
$summary .= '<li>'.strftime($date_format['txt_full'], $_SESSION["totalchoixjour"][$i]);
|
||||||
for ($j=0;$j<count($_SESSION['horaires'.$i]);$j++) {
|
for ($j=0; $j < count($_SESSION['horaires'.$i]); ++$j) {
|
||||||
if (isset($_SESSION['horaires'.$i][$j])) {
|
if (isset($_SESSION['horaires'.$i][$j])) {
|
||||||
$summary .= ($j==0) ? ' : ' : ', ';
|
$summary .= ($j==0) ? ' : ' : ', ';
|
||||||
$summary .= $_SESSION['horaires'.$i][$j];
|
$summary .= $_SESSION['horaires'.$i][$j];
|
||||||
@ -146,7 +154,7 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
<div class="col-md-8 col-md-offset-2">
|
<div class="col-md-8 col-md-offset-2">
|
||||||
<h3>'. _("Confirm the creation of your poll") .'</h3>
|
<h3>'. _("Confirm the creation of your poll") .'</h3>
|
||||||
<div class="well summary">
|
<div class="well summary">
|
||||||
<h4>'. _("List of your choices").'</h4>
|
<h4>'. _('List of your choices').'</h4>
|
||||||
'. $summary .'
|
'. $summary .'
|
||||||
</div>
|
</div>
|
||||||
<div class="alert alert-info clearfix">
|
<div class="alert alert-info clearfix">
|
||||||
@ -164,9 +172,9 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
</div>
|
</div>
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
<p>'. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll."). '</p>';
|
<p>'. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll."). '</p>';
|
||||||
if($config['use_smtp']==true){
|
if($config['use_smtp'] == true) {
|
||||||
echo '
|
echo '
|
||||||
<p>' . _("Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.") .'</p>';
|
<p>' . _('Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.') .'</p>';
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
</div>
|
</div>
|
||||||
@ -182,24 +190,24 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
|
|
||||||
// Step 2/3 : Select dates of the poll
|
// Step 2/3 : Select dates of the poll
|
||||||
} else {
|
} else {
|
||||||
Utils::print_header ( _("Poll dates (2 on 3)") );
|
Utils::print_header ( _('Poll dates (2 on 3)') );
|
||||||
bandeau_titre(_("Poll dates (2 on 3)"));
|
bandeau_titre(_('Poll dates (2 on 3)'));
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<form name="formulaire" action="' . Utils::get_server_name() . 'choix_date.php" method="POST" class="form-horizontal" role="form">
|
<form name="formulaire" action="' . Utils::get_server_name() . 'choix_date.php" method="POST" class="form-horizontal" role="form">
|
||||||
<div class="row" id="selected-days">
|
<div class="row" id="selected-days">
|
||||||
<div class="col-md-10 col-md-offset-1">
|
<div class="col-md-10 col-md-offset-1">
|
||||||
<h3>'. _("Choose the dates of your poll") .'</h3>
|
<h3>'. _('Choose the dates of your poll') .'</h3>
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<p>'. _("To schedule an event you need to propose at least two choices (two hours for one day or two days).").'</p>
|
<p>'. _("To schedule an event you need to propose at least two choices (two hours for one day or two days).").'</p>
|
||||||
<p>'. _("You can add or remove additionnal days and hours with the buttons") .' <span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove") .'</span> <span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></p>
|
<p>'. _("You can add or remove additionnal days and hours with the buttons") .' <span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _('Remove') .'</span> <span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></p>
|
||||||
<p>'. _("For each selected day, you can choose, or not, meeting hours (e.g.: \"8h\", \"8:30\", \"8h-10h\", \"evening\", etc.)").'</p>
|
<p>'. _("For each selected day, you can choose, or not, meeting hours (e.g.: \"8h\", \"8:30\", \"8h-10h\", \"evening\", etc.)").'</p>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
// Fields days : 3 by default
|
// Fields days : 3 by default
|
||||||
$nb_days = (isset($_SESSION["totalchoixjour"])) ? count($_SESSION["totalchoixjour"]) : 3;
|
$nb_days = (isset($_SESSION["totalchoixjour"])) ? count($_SESSION["totalchoixjour"]) : 3;
|
||||||
for ($i=0;$i<$nb_days;$i++) {
|
for ($i=0; $i < $nb_days; ++$i) {
|
||||||
$day_value = isset($_SESSION["totalchoixjour"][$i]) ? strftime( "%d/%m/%Y", $_SESSION["totalchoixjour"][$i]) : '';
|
$day_value = isset($_SESSION['totalchoixjour'][$i]) ? strftime( "%d/%m/%Y", $_SESSION['totalchoixjour'][$i]) : '';
|
||||||
echo '
|
echo '
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -213,8 +221,8 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
</legend>'."\n";
|
</legend>'."\n";
|
||||||
|
|
||||||
// Fields hours : 3 by default
|
// Fields hours : 3 by default
|
||||||
for ($j=0;$j<max(count(isset($_SESSION["horaires".$i]) ? $_SESSION["horaires".$i] : 0),3);$j++) {
|
for ($j=0; $j < max(count(isset($_SESSION['horaires'.$i]) ? $_SESSION['horaires'.$i] : 0),3); ++$j) {
|
||||||
$hour_value = isset($_SESSION["horaires".$i][$j]) ? $_SESSION["horaires".$i][$j] : '';
|
$hour_value = isset($_SESSION['horaires'.$i][$j]) ? $_SESSION['horaires'.$i][$j] : '';
|
||||||
echo '
|
echo '
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<label for="d'.$i.'-h'.$j.'" class="sr-only control-label">'. _("Time") .' '. ($j+1) .'</label>
|
<label for="d'.$i.'-h'.$j.'" class="sr-only control-label">'. _("Time") .' '. ($j+1) .'</label>
|
||||||
@ -255,6 +263,5 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
|
|||||||
</form>'."\n";
|
</form>'."\n";
|
||||||
|
|
||||||
bandeau_pied();
|
bandeau_pied();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user