Translate database names (table+columns) to English + Reorganize some columns

This commit is contained in:
Olivier PEREZ 2014-12-30 01:41:25 +01:00
parent dcb711dccc
commit 1ca7502216
12 changed files with 206 additions and 228 deletions

View File

@ -301,15 +301,24 @@ if (!empty($_POST['delete_column'])) {
if (isset($_POST['add_slot'])) {
$smarty->assign('poll_id', $poll_id);
$smarty->assign('admin_poll_id', $admin_poll_id);
$smarty->assign('format', $poll->format);
$smarty->assign('title', _('Poll') . ' - ' . $poll->title);
$smarty->display('add_slot.tpl');
exit;
}
if (isset($_POST['confirm_add_slot'])) {
$newdate = filter_input(INPUT_POST, 'newdate', FILTER_DEFAULT);
$newmoment = filter_input(INPUT_POST, 'newmoment', FILTER_DEFAULT);
if ($poll->format === 'D') {
$newdate = filter_input(INPUT_POST, 'newdate', FILTER_DEFAULT);
$newmoment = filter_input(INPUT_POST, 'newmoment', FILTER_DEFAULT);
if ($adminPollService->addSlot($poll_id, $newdate, $newmoment)) {
$ex = explode('/', $newdate);
$result = $adminPollService->addSlot($poll_id, mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]), $newmoment);
} else {
$newslot = filter_input(INPUT_POST, 'choice', FILTER_DEFAULT);
$result = $adminPollService->addSlot($poll_id,$newslot, null);
}
if ($result) {
$message = new Message('success', _('Column added.'));
} else {
$message = new Message('danger', _('Failed to add the column.'));

View File

@ -34,7 +34,7 @@ class FramaDB {
$result = $this->pdo->query('SHOW TABLES');
$schemas = $result->fetchAll(\PDO::FETCH_COLUMN);
return 0 != count(array_diff($schemas, ['comments', 'sondage', 'sujet_studs', 'user_studs']));
return 0 != count(array_diff($schemas, ['comment', 'poll', 'slot', 'vote']));
}
function prepare($sql) {
@ -66,7 +66,7 @@ class FramaDB {
}
function findPollById($poll_id) {
$prepared = $this->prepare('SELECT * FROM sondage WHERE sondage.poll_id = ?');
$prepared = $this->prepare('SELECT * FROM poll WHERE id = ?');
$prepared->execute([$poll_id]);
$poll = $prepared->fetch();
@ -76,53 +76,53 @@ class FramaDB {
}
function updatePoll($poll) {
$prepared = $this->prepare('UPDATE sondage SET title=?, admin_mail=?, comment=?, active=?, editable=? WHERE poll_id = ?');
$prepared = $this->prepare('UPDATE poll SET title=?, admin_mail=?, comment=?, active=?, editable=? WHERE id = ?');
return $prepared->execute([$poll->title, $poll->admin_mail, $poll->comment, $poll->active, $poll->editable, $poll->poll_id]);
return $prepared->execute([$poll->title, $poll->admin_mail, $poll->comment, $poll->active, $poll->editable, $poll->id]);
}
function allCommentsByPollId($poll_id) {
$prepared = $this->prepare('SELECT * FROM comments WHERE id_sondage = ? ORDER BY id_comment');
$prepared = $this->prepare('SELECT * FROM comment WHERE poll_id = ? ORDER BY id');
$prepared->execute(array($poll_id));
return $prepared->fetchAll();
}
function allUserVotesByPollId($poll_id) {
$prepared = $this->prepare('SELECT * FROM user_studs WHERE id_sondage = ? ORDER BY id_users');
$prepared = $this->prepare('SELECT * FROM vote WHERE poll_id = ? ORDER BY id');
$prepared->execute(array($poll_id));
return $prepared->fetchAll();
}
function allSlotsByPollId($poll_id) {
$prepared = $this->prepare('SELECT * FROM sujet_studs WHERE id_sondage = ? ORDER BY sujet');
$prepared = $this->prepare('SELECT * FROM slot WHERE poll_id = ? ORDER BY title');
$prepared->execute(array($poll_id));
return $prepared->fetchAll();
}
function insertDefaultVote($poll_id, $insert_position) {
$prepared = $this->prepare('UPDATE user_studs SET reponses = CONCAT(SUBSTRING(reponses, 1, ?), "0", SUBSTRING(reponses, ?)) WHERE id_sondage = ?');
$prepared = $this->prepare('UPDATE vote SET choices = CONCAT(SUBSTRING(choices, 1, ?), "0", SUBSTRING(choices, ?)) WHERE poll_id = ?');
return $prepared->execute([$insert_position, $insert_position + 1, $poll_id]);
}
function insertVote($poll_id, $name, $choices) {
$prepared = $this->prepare('INSERT INTO user_studs (id_sondage,nom,reponses) VALUES (?,?,?)');
$prepared = $this->prepare('INSERT INTO vote (poll_id, name, choices) VALUES (?,?,?)');
$prepared->execute([$poll_id, $name, $choices]);
$newVote = new \stdClass();
$newVote->id_sondage = $poll_id;
$newVote->id_users = $this->pdo->lastInsertId();
$newVote->nom = $name;
$newVote->reponse = $choices;
$newVote->poll_id = $poll_id;
$newVote->id = $this->pdo->lastInsertId();
$newVote->name = $name;
$newVote->choices = $choices;
return $newVote;
}
function deleteVote($poll_id, $vote_id) {
$prepared = $this->prepare('DELETE FROM user_studs WHERE id_sondage = ? AND id_users = ?');
$prepared = $this->prepare('DELETE FROM vote WHERE poll_id = ? AND id = ?');
return $prepared->execute([$poll_id, $vote_id]);
}
@ -134,7 +134,7 @@ class FramaDB {
* @return bool|null true if action succeeded.
*/
function deleteVotesByPollId($poll_id) {
$prepared = $this->prepare('DELETE FROM user_studs WHERE id_sondage = ?');
$prepared = $this->prepare('DELETE FROM vote WHERE poll_id = ?');
return $prepared->execute([$poll_id]);
}
@ -147,7 +147,7 @@ class FramaDB {
* @return bool|null true if action succeeded.
*/
function deleteVotesByIndex($poll_id, $index) {
$prepared = $this->prepare('UPDATE user_studs SET reponses = CONCAT(SUBSTR(reponses, 1, ?), SUBSTR(reponses, ?)) WHERE id_sondage = ?');
$prepared = $this->prepare('UPDATE vote SET choices = CONCAT(SUBSTR(choices, 1, ?), SUBSTR(choices, ?)) WHERE poll_id = ?');
return $prepared->execute([$index, $index + 2, $poll_id]);
}
@ -160,7 +160,7 @@ class FramaDB {
* @return mixed Object The slot found, or null
*/
function findSlotByPollIdAndDatetime($poll_id, $datetime) {
$prepared = $this->prepare('SELECT * FROM sujet_studs WHERE id_sondage = ? AND SUBSTRING_INDEX(sujet, \'@\', 1) = ?');
$prepared = $this->prepare('SELECT * FROM slot WHERE poll_id = ? AND SUBSTRING_INDEX(title, \'@\', 1) = ?');
$prepared->execute([$poll_id, $datetime]);
$slot = $prepared->fetch();
@ -173,13 +173,14 @@ class FramaDB {
* Insert a new slot into a given poll.
*
* @param $poll_id int The ID of the poll
* @param $slot mixed The value of the slot
* @param $title mixed The title of the slot
* @param $moments mixed|null The moments joined with ","
* @return bool true if action succeeded
*/
function insertSlot($poll_id, $slot) {
$prepared = $this->prepare('INSERT INTO sujet_studs (id_sondage, sujet) VALUES (?,?)');
function insertSlot($poll_id, $title, $moments) {
$prepared = $this->prepare('INSERT INTO slot (poll_id, title, moments) VALUES (?,?,?)');
return $prepared->execute([$poll_id, $slot]);
return $prepared->execute([$poll_id, $title, $moments]);
}
/**
@ -187,13 +188,13 @@ class FramaDB {
*
* @param $poll_id int The ID of the poll
* @param $datetime int The datetime of the slot to update
* @param $newValue mixed The new value of the entire slot
* @param $newMoments mixed The new moments
* @return bool|null true if action succeeded.
*/
function updateSlot($poll_id, $datetime, $newValue) {
$prepared = $this->prepare('UPDATE sujet_studs SET sujet = ? WHERE id_sondage = ? AND SUBSTRING_INDEX(sujet, \'@\', 1) = ?');
function updateSlot($poll_id, $datetime, $newMoments) {
$prepared = $this->prepare('UPDATE slot SET moments = ? WHERE poll_id = ? AND title = ?');
return $prepared->execute([$newValue, $poll_id, $datetime]);
return $prepared->execute([$newMoments, $poll_id, $datetime]);
}
/**
@ -203,12 +204,13 @@ class FramaDB {
* @param $datetime mixed The datetime of the slot
*/
function deleteSlot($poll_id, $datetime) {
$prepared = $this->prepare('DELETE FROM sujet_studs WHERE id_sondage = ? AND SUBSTRING_INDEX(sujet, \'@\', 1) = ?');
$prepared = $this->prepare('DELETE FROM slot WHERE poll_id = ? AND title = ?');
$prepared->execute([$poll_id, $datetime]);
}
function deleteSlotsByPollId($poll_id) {
$prepared = $this->prepare('DELETE FROM sujet_studs WHERE id_sondage = ?');
$prepared = $this->prepare('DELETE FROM slot WHERE poll_id = ?');
return $prepared->execute([$poll_id]);
}
@ -219,31 +221,32 @@ class FramaDB {
* @return bool|null true if action succeeded.
*/
function deleteCommentsByPollId($poll_id) {
$prepared = $this->prepare('DELETE FROM comments WHERE id_sondage = ?');
$prepared = $this->prepare('DELETE FROM comment WHERE poll_id = ?');
return $prepared->execute([$poll_id]);
}
function updateVote($poll_id, $vote_id, $choices) {
$prepared = $this->prepare('UPDATE user_studs SET reponses = ? WHERE id_sondage = ? AND id_users = ?');
$prepared = $this->prepare('UPDATE vote SET choices = ? WHERE poll_id = ? AND id = ?');
return $prepared->execute([$choices, $poll_id, $vote_id]);
}
function insertComment($poll_id, $name, $comment) {
$prepared = $this->prepare('INSERT INTO comments (id_sondage, usercomment, comment) VALUES (?,?,?)');
$prepared = $this->prepare('INSERT INTO comment (poll_id, name, comment) VALUES (?,?,?)');
return $prepared->execute([$poll_id, $name, $comment]);
}
function deleteComment($poll_id, $comment_id) {
$prepared = $this->prepare('DELETE FROM comments WHERE id_sondage = ? AND id_comment = ?');
$prepared = $this->prepare('DELETE FROM comment WHERE poll_id = ? AND id = ?');
return $prepared->execute([$poll_id, $comment_id]);
}
function deletePollById($poll_id) {
$prepared = $this->prepare('DELETE FROM sondage WHERE poll_id = ?');
$prepared = $this->prepare('DELETE FROM poll WHERE id = ?');
return $prepared->execute([$poll_id]);
}
@ -253,7 +256,7 @@ class FramaDB {
* @return array Array of old polls
*/
public function findOldPolls() {
$prepared = $this->prepare('SELECT * FROM sondage WHERE end_date < NOW() LIMIT 20');
$prepared = $this->prepare('SELECT * FROM poll WHERE end_date < NOW() LIMIT 20');
$prepared->execute([]);
return $prepared->fetchAll();

View File

@ -77,7 +77,7 @@ class AdminPollService {
*/
function deleteEntirePoll($poll_id) {
$poll = $this->connect->findPollById($poll_id);
$this->logService->log('DELETE_POLL', "id:$poll->poll_id, format:$poll->format, admin:$poll->admin_name, mail:$poll->admin_mail");
$this->logService->log('DELETE_POLL', "id:$poll->id, format:$poll->format, admin:$poll->admin_name, mail:$poll->admin_mail");
// Delete the entire poll
$this->connect->deleteVotesByPollId($poll_id);
@ -109,11 +109,10 @@ class AdminPollService {
// Search the index of the slot to delete
foreach ($slots as $aSlot) {
$ex = explode('@', $aSlot->sujet);
$moments = explode(',', $ex[1]);
$moments = explode(',', $aSlot->moments);
foreach ($moments as $rowMoment) {
if ($datetime == $ex[0]) {
if ($datetime == $aSlot->title) {
if ($moment == $rowMoment) {
$indexToDelete = $index;
} else {
@ -128,7 +127,7 @@ class AdminPollService {
$this->connect->beginTransaction();
$this->connect->deleteVotesByIndex($poll_id, $indexToDelete);
if (count($newMoments) > 0) {
$this->connect->updateSlot($poll_id, $datetime, $datetime . '@' . implode(',', $newMoments));
$this->connect->updateSlot($poll_id, $datetime, implode(',', $newMoments));
} else {
$this->connect->deleteSlot($poll_id, $datetime);
}
@ -145,14 +144,11 @@ class AdminPollService {
* </ul>
*
* @param $poll_id int The ID of the poll
* @param $new_date string The date (format: d/m/Y)
* @param $datetime int The datetime
* @param $new_moment string The moment's name
* @return bool true if added
*/
public function addSlot($poll_id, $new_date, $new_moment) {
$ex = explode('/', $new_date);
$datetime = mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]);
public function addSlot($poll_id, $datetime, $new_moment) {
$slots = $this->connect->allSlotsByPollId($poll_id);
$result = $this->findInsertPosition($slots, $datetime, $new_moment);
@ -164,9 +160,7 @@ class AdminPollService {
return false;
} elseif ($result->slot != null) {
$slot = $result->slot;
$joined_moments = explode('@', $slot->sujet)[1];
$moments = explode(',', $joined_moments);
$moments = explode(',', $slot->moments);
// Check if moment already exists (maybe not necessary)
if (in_array($new_moment, $moments)) {
@ -176,10 +170,10 @@ class AdminPollService {
// Update found slot
$moments[] = $new_moment;
sort($moments);
$this->connect->updateSlot($poll_id, $datetime, $datetime . '@' . implode(',', $moments));
$this->connect->updateSlot($poll_id, $datetime, implode(',', $moments));
} else {
$this->connect->insertSlot($poll_id, $datetime . '@' . $new_moment);
$this->connect->insertSlot($poll_id, $datetime, $new_moment);
}
$this->connect->insertDefaultVote($poll_id, $result->insert);
@ -209,9 +203,8 @@ class AdminPollService {
$i = 0;
foreach ($slots as $slot) {
$ex = explode('@', $slot->sujet);
$rowDatetime = $ex[0];
$moments = explode(',', $ex[1]);
$rowDatetime = $slot->title;
$moments = explode(',', $slot->moments);
if ($datetime == $rowDatetime) {
$result->slot = $slot;

View File

@ -78,7 +78,7 @@ class PollService {
function computeBestChoices($votes) {
$result = [];
foreach ($votes as $vote) {
$choices = str_split($vote->reponses);
$choices = str_split($vote->choices);
foreach ($choices as $i => $choice) {
if (empty($result[$i])) {
$result[$i] = 0;
@ -95,10 +95,9 @@ class PollService {
function splitSlots($slots) {
$splitted = array();
foreach ($slots as $slot) {
$ex = explode('@', $slot->sujet);
$obj = new \stdClass();
$obj->day = $ex[0];
$obj->moments = explode(',', $ex[1]);
$obj->day = $slot->title;
$obj->moments = explode(',', $slot->moments);
$splitted[] = $obj;
}
@ -110,9 +109,9 @@ class PollService {
$splitted = array();
foreach ($votes as $vote) {
$obj = new \stdClass();
$obj->id = $vote->id_users;
$obj->name = $vote->nom;
$obj->choices = str_split($vote->reponses);
$obj->id = $vote->id;
$obj->name = $vote->name;
$obj->choices = str_split($vote->choices);
$splitted[] = $obj;
}
@ -134,13 +133,13 @@ class PollService {
$this->connect->beginTransaction();
// TODO Extract this to FramaDB (or repository layer)
$sql = 'INSERT INTO sondage
(poll_id, admin_poll_id, title, comment, admin_name, admin_mail, end_date, format, editable, receiveNewVotes)
$sql = 'INSERT INTO poll
(id, admin_id, title, description, admin_name, admin_mail, end_date, format, editable, receiveNewVotes)
VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?,?,?)';
$prepared = $this->connect->prepare($sql);
$prepared->execute(array($poll_id, $admin_poll_id, $form->title, $form->description, $form->admin_name, $form->admin_mail, $form->end_date, $form->format, $form->editable, $form->receiveNewVotes));
$prepared = $this->connect->prepare('INSERT INTO sujet_studs (id_sondage, sujet) VALUES (?, ?)');
$prepared = $this->connect->prepare('INSERT INTO slot (poll_id, title, moments) VALUES (?, ?, ?)');
foreach ($form->getChoices() as $choice) {
@ -158,16 +157,16 @@ class PollService {
// We execute the insertion
if (empty($joinedSlots)) {
$prepared->execute(array($poll_id, $choice->getName()));
$prepared->execute(array($poll_id, $choice->getName(), null));
} else {
$prepared->execute(array($poll_id, $choice->getName() . '@' . $joinedSlots));
$prepared->execute(array($poll_id, $choice->getName(), $joinedSlots));
}
}
$this->connect->commit();
$this->logService->log('CREATE_POLL', 'id:' . $poll_id . 'title: ' . $form->title . ', format:' . $form->format . ', admin:' . $form->admin_name . ', mail:' . $form->admin_mail);
$this->logService->log('CREATE_POLL', 'id:' . $poll_id . ', title: ' . $form->title . ', format:' . $form->format . ', admin:' . $form->admin_name . ', mail:' . $form->admin_mail);
return [$poll_id, $admin_poll_id];

View File

@ -30,10 +30,10 @@ class PurgeService {
$this->logService->log('EXPIRATION', 'Going to purge ' . $count . ' poll(s)...');
foreach ($oldPolls as $poll) {
if ($this->purgePollById($poll->poll_id)) {
$this->logService->log('EXPIRATION_SUCCESS', 'id: ' . $poll->poll_id . ', title:' . $poll->title . ', format: '.$poll->format . ', admin: ' . $poll->admin_name);
if ($this->purgePollById($poll->id)) {
$this->logService->log('EXPIRATION_SUCCESS', 'id: ' . $poll->id . ', title:' . $poll->title . ', format: '.$poll->format . ', admin: ' . $poll->admin_name);
} else {
$this->logService->log('EXPIRATION_FAILED', 'id: ' . $poll->poll_id . ', title:' . $poll->title . ', format: '.$poll->format . ', admin: ' . $poll->admin_name);
$this->logService->log('EXPIRATION_FAILED', 'id: ' . $poll->id . ', title:' . $poll->title . ', format: '.$poll->format . ', admin: ' . $poll->admin_name);
}
}
}
@ -48,11 +48,19 @@ class PurgeService {
* @return bool true is action succeeded
*/
function purgePollById($poll_id) {
$done = false;
$done |= $this->connect->deleteCommentsByPollId($poll_id);
$done |= $this->connect->deleteVotesByPollId($poll_id);
$done |= $this->connect->deleteSlotsByPollId($poll_id);
$done |= $this->connect->deletePollById($poll_id);
$done = true;
$this->connect->beginTransaction();
$done &= $this->connect->deleteCommentsByPollId($poll_id);
$done &= $this->connect->deleteVotesByPollId($poll_id);
$done &= $this->connect->deleteSlotsByPollId($poll_id);
$done &= $this->connect->deletePollById($poll_id);
if ($done) {
$this->connect->commit();
} else {
$this->connect->rollback();
}
return $done;
}

View File

@ -98,59 +98,6 @@ class Utils
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
/**
* Envoi un courrier avec un codage correct de To et Subject
* Les en-têtes complémentaires ne sont pas gérés
* @deprecated
*/
public static function sendEmail( $to, $subject, $body, $headers='', $param='')
{
mb_internal_encoding('UTF-8');
$subject = mb_encode_mimeheader(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'), 'UTF-8', 'B', "\n", 9);
$encoded_app = mb_encode_mimeheader(NOMAPPLICATION, 'UTF-8', 'B', "\n", 6);
$size_encoded_app = (6 + strlen($encoded_app)) % 75;
$size_admin_email = strlen(ADRESSEMAILADMIN);
if (($size_encoded_app + $size_admin_email + 9) > 74 ) {
$folding = "\n";
} else {
$folding = '';
};
/*
Si $headers ne contient qu'une adresse email, on la considère comme
adresse de reply-to, sinon on met l'adresse de no-reply definie
dans constants.php
*/
if (self::isValidEmail($headers)) {
$replyTo = $headers;
$headers = ''; // on reinitialise $headers
} else {
$replyTo = ADRESSEMAILREPONSEAUTO;
}
$from = sprintf( "From: %s%s <%s>\n", $encoded_app, $folding, ADRESSEMAILADMIN);
if ($headers) {
$headers .= "\n" ;
}
$headers .= $from;
$headers .= "Reply-To: $replyTo\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Auto-Submitted:auto-generated\n";
$headers .= "Return-Path: <>";
$body = html_entity_decode($body, ENT_QUOTES, 'UTF-8')._("\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.");
mail($to, $subject, $body, $headers, $param);
}
/**
* Fonction permettant de générer les URL pour les sondage
* @param string $id L'identifiant du sondage

View File

@ -1,103 +1,113 @@
-- Base de données: `opensondage`
-- --------------------------------------------------------
--
-- Table structure `poll`
--
CREATE TABLE IF NOT EXISTS `poll` (
`id` CHAR(16) NOT NULL,
`admin_id` CHAR(24) NOT NULL,
`title` TEXT NOT NULL,
`description` TEXT,
`admin_name` VARCHAR(64) DEFAULT NULL,
`admin_mail` VARCHAR(128) DEFAULT NULL,
`creation_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`end_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`format` VARCHAR(1) DEFAULT NULL,
`editable` TINYINT(1) DEFAULT '0',
`receiveNewVotes` TINYINT(1) DEFAULT '0',
`active` TINYINT(1) DEFAULT '1',
PRIMARY KEY (`id`)
)
ENGINE =InnoDB
DEFAULT CHARSET =utf8;
-- --------------------------------------------------------
--
-- Structure de la table `comments`
-- Table structure `slot`
--
CREATE TABLE IF NOT EXISTS `comments` (
`id_comment` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_sondage` char(16) NOT NULL,
`comment` text NOT NULL,
`usercomment` text,
PRIMARY KEY (`id_comment`),
KEY `id_sondage` (`id_sondage`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `slot` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`poll_id` CHAR(16) NOT NULL,
`title` TEXT,
`moments` TEXT,
PRIMARY KEY (`id`),
KEY `poll_id` (`poll_id`)
)
ENGINE =InnoDB
DEFAULT CHARSET =utf8;
-- --------------------------------------------------------
--
-- Structure de la table `sondage`
-- Table structure `comment`
--
CREATE TABLE IF NOT EXISTS `sondage` (
`poll_id` char(16) NOT NULL,
`admin_poll_id` char(24) DEFAULT NULL,
`title` text NOT NULL,
`comment` text,
`admin_name` varchar(64) DEFAULT NULL,
`admin_mail` varchar(128) DEFAULT NULL,
`creation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`end_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`format` varchar(1) DEFAULT NULL,
`editable` tinyint(1) DEFAULT '0',
`receiveNewVotes` tinyint(1) DEFAULT '0',
`active` tinyint(1) DEFAULT '1',
`statut` int(11) NOT NULL DEFAULT '1' COMMENT '1 = actif ; 0 = inactif ; ',
UNIQUE KEY `poll_id` (`poll_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `comment` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`poll_id` CHAR(16) NOT NULL,
`name` TEXT,
`comment` TEXT NOT NULL,
PRIMARY KEY (`id`),
KEY `poll_id` (`poll_id`)
)
ENGINE =InnoDB
DEFAULT CHARSET =utf8;
-- --------------------------------------------------------
--
-- Structure de la table `sujet_studs`
-- Table structure `vote`
--
CREATE TABLE IF NOT EXISTS `sujet_studs` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_sondage` char(16) NOT NULL,
`sujet` text,
KEY `id_sondage` (`id_sondage`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `vote` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`poll_id` CHAR(16) NOT NULL,
`name` VARCHAR(64) NOT NULL,
`choices` TEXT NOT NULL,
PRIMARY KEY (`id`),
KEY `poll_id` (`poll_id`)
)
ENGINE =InnoDB
DEFAULT CHARSET =utf8
AUTO_INCREMENT =160284;
-- --------------------------------------------------------
--
-- Structure de la table `user_studs`
-- Data for Name: poll; Type: TABLE DATA;
--
CREATE TABLE IF NOT EXISTS `user_studs` (
`id_users` int(11) unsigned NOT NULL AUTO_INCREMENT,
`nom` varchar(64) NOT NULL,
`id_sondage` char(16) NOT NULL,
`reponses` text NOT NULL,
PRIMARY KEY (`id_users`),
KEY `id_sondage` (`id_sondage`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=160284 ;
INSERT INTO `sondage`
(`id_sondage`, `commentaires`, `mail_admin`, `nom_admin`,
`titre`, `id_sondage_admin`,
`date_fin`, `format`)
INSERT INTO `poll`
(`id`, `description`, `admin_mail`, `admin_name`, `title`, `admin_id`, `end_date`, `format`)
VALUES
('aqg259dth55iuhwm','Repas de Noel du service','Stephanie@retaillard.com','Stephanie',
'Repas de Noel','aqg259dth55iuhwmy9d8jlwk',
FROM_UNIXTIME('1627100361'),'D+');
('aqg259dth55iuhwm', 'Repas de Noel du service', 'Stephanie@retaillard.com', 'Stephanie', 'Repas de Noel',
'aqg259dth55iuhwmy9d8jlwk', FROM_UNIXTIME('1627100361'), 'D');
--
-- Data for Name: sujet_studs; Type: TABLE DATA;
-- Data for Name: slot; Type: TABLE DATA;
--
INSERT INTO `sujet_studs` (`id_sondage`, `sujet`) VALUES
('aqg259dth55iuhwm','1225839600@12h,1225839600@19h,1226012400@12h,1226012400@19h,1226876400@12h,1226876400@19h,1227049200@12h,1227049200@19h,1227826800@12h,1227826800@19h');
INSERT INTO `slot` (`poll_id`, `title`, `moments`) VALUES
('aqg259dth55iuhwm', '1225839600', '12h,19h'),
('aqg259dth55iuhwm', '1226012400', '12h,19h'),
('aqg259dth55iuhwm', '1226876400', '12h,19h'),
('aqg259dth55iuhwm', '1227826800', '12h,19h');
--
-- Data for Name: user_studs; Type: TABLE DATA;
-- Data for Name: vote; Type: TABLE DATA;
--
INSERT INTO `user_studs` (`nom`, `id_sondage`, `reponses`, `id_users`) VALUES
('marcel','aqg259dth55iuhwm','0110111101','933'),
('paul','aqg259dth55iuhwm','1011010111','935'),
('sophie','aqg259dth55iuhwm','1110110000','945'),
('barack','aqg259dth55iuhwm','0110000','948'),
('takashi','aqg259dth55iuhwm','0000110100','951'),
('albert','aqg259dth55iuhwm','1010110','975'),
('alfred','aqg259dth55iuhwm','0110010','1135'),
('marcs','aqg259dth55iuhwm','0100001010','1143'),
('laure','aqg259dth55iuhwm','0011000','1347'),
('benda','aqg259dth55iuhwm','1101101100','1667'),
('Albert','aqg259dth55iuhwm','1111110011','1668');
INSERT INTO `vote` (`name`, `poll_id`, `choices`) VALUES
('marcel', 'aqg259dth55iuhwm', '02202222'),
('paul', 'aqg259dth55iuhwm', '20220202'),
('sophie', 'aqg259dth55iuhwm', '22202200'),
('barack', 'aqg259dth55iuhwm', '02200000'),
('takashi','aqg259dth55iuhwm', '00002202'),
('albert', 'aqg259dth55iuhwm', '20202200'),
('alfred', 'aqg259dth55iuhwm', '02200200'),
('marcs', 'aqg259dth55iuhwm', '02000020'),
('laure', 'aqg259dth55iuhwm', '00220000'),
('benda', 'aqg259dth55iuhwm', '22022022'),
('albert', 'aqg259dth55iuhwm', '22222200');

View File

@ -50,7 +50,7 @@ $mailService = new MailService($config['use_smtp']);
* @param $mailService MailService The mail service
*/
function sendUpdateNotification($poll, $mailService) {
if ($poll->receiveNewVotes && !isset($_SESSION['mail_sent'][$poll->poll_id])) {
if ($poll->receiveNewVotes && !isset($_SESSION['mail_sent'][$poll->id])) {
$subject = '[' . NOMAPPLICATION . '] ' . _('Poll\'s participation') . ' : ' . html_entity_decode($poll->title, ENT_QUOTES, 'UTF-8');
$message = html_entity_decode('"$nom" ', ENT_QUOTES, 'UTF-8') .
@ -60,7 +60,7 @@ function sendUpdateNotification($poll, $mailService) {
$mailService->send($poll->admin_mail, $subject, $message);
$_SESSION["mail_sent"][$poll->poll_id] = true;
$_SESSION["mail_sent"][$poll->id] = true;
}
}

View File

@ -3,24 +3,33 @@
{block name=main}
<form action="{$admin_poll_id|poll_url:true}" method="POST">
<div class="alert alert-info text-center">
<h2>{_("Column's adding")}</h2>
<h2>{_('Column\'s adding')}</h2>
<div class="form-group">
<label for="newdate" class="col-md-4">{_("Day")}</label>
<div class="col-md-8">
<div class="input-group date">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
<input type="text" id="newdate" data-date-format="{_("dd/mm/yyyy")}" aria-describedby="dateformat" name="newdate" class="form-control" placeholder="{_("dd/mm/yyyy")}" />
{if $format === 'D'}
<div class="form-group">
<label for="newdate" class="col-md-4">{_('Day')}</label>
<div class="col-md-8">
<div class="input-group date">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
<input type="text" id="newdate" data-date-format="{_('dd/mm/yyyy')}" aria-describedby="dateformat" name="newdate" class="form-control" placeholder="{_('dd/mm/yyyy')}" />
</div>
<span id="dateformat" class="sr-only">{_('(dd/mm/yyyy)')}</span>
</div>
<span id="dateformat" class="sr-only">{_("(dd/mm/yyyy)")}</span>
</div>
</div>
<div class="form-group">
<label for="newmoment" class="col-md-4">{_("Time")}</label>
<div class="col-md-8">
<input type="text" id="newmoment" name="newmoment" class="form-control" />
<div class="form-group">
<label for="newmoment" class="col-md-4">{_('Time')}</label>
<div class="col-md-8">
<input type="text" id="newmoment" name="newmoment" class="form-control" />
</div>
</div>
</div>
{else}
<div class="form-group">
<label for="choice" class="col-md-4">{_('Choice')}</label>
<div class="col-md-8">
<input type="text" id="choice" name="choice" class="form-control" />
</div>
</div>
{/if}
<div class="form-group">
<button class="btn btn-default" type="submit" name="back">{_('Back to the poll')}</button>
<button type="submit" name="confirm_add_slot" class="btn btn-success">{_('Add a column')}</button>

View File

@ -8,9 +8,9 @@
{foreach $comments as $comment}
<div class="comment">
{if $admin}
<button type="submit" name="delete_comment" value="{$comment->id_comment}" class="btn btn-link" title="{_('Remove the comment')}"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">{_('Remove')}</span></button>
<button type="submit" name="delete_comment" value="{$comment->id}" class="btn btn-link" title="{_('Remove the comment')}"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">{_('Remove')}</span></button>
{/if}
<b>{$comment->usercomment}</b>&nbsp;
<b>{$comment->name}</b>&nbsp;
<span class="comment">{nl2br($comment->comment)}</span>
</div>
{/foreach}

View File

@ -14,7 +14,7 @@
<th role="presentation"></th>
{foreach $slots as $id=>$slot}
<td headers="C{$id}">
<button type="submit" name="delete_column" value="{$slot->sujet}" class="btn btn-link btn-sm" title="{_('Remove the column')} {$slot->sujet}"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">{_('Remove')}</span></button>
<button type="submit" name="delete_column" value="{$slot->id}" class="btn btn-link btn-sm" title="{_('Remove the column')} {$slot->title}"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">{_('Remove')}</span></button>
</td>
{/foreach}
<td>
@ -25,7 +25,7 @@
<tr>
<th role="presentation"></th>
{foreach $slots as $id=>$slot}
<th class="bg-info" id="H{$id}">{$slot->sujet}</th>
<th class="bg-info" id="H{$id}">{$slot->title}</th>
{/foreach}
<th></th>
</tr>
@ -113,19 +113,19 @@
<ul class="list-unstyled choice">
<li class="yes">
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2" />
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{_('Vote yes for')} {$slot->sujet}">
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{_('Vote yes for')} {$slot->title}">
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span>
</label>
</li>
<li class="ifneedbe">
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1" />
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{_('Vote ifneedbe for')} {$slot->sujet}">
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{_('Vote ifneedbe for')} {$slot->title}">
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span>
</label>
</li>
<li class="no">
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0" checked/>
<label class="btn btn-default btn-xs" for="n-choice-{$id}" title="{_('Vote no for')} {$slot->sujet}">
<label class="btn btn-default btn-xs" for="n-choice-{$id}" title="{_('Vote no for')} {$slot->title}">
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">{_('No')}</span>
</label>
</li>
@ -177,7 +177,7 @@
<ul style="list-style:none">
{foreach $slots as $slot}
{if $best_choices[$i] == $max}
<li><strong>{$slot->sujet}</strong></li>
<li><strong>{$slot->title}</strong></li>
{/if}
{$i = $i+1}
{/foreach}

View File

@ -1,5 +1,5 @@
{if !is_array($best_moments) || empty($best_moments)}
{$best_moments = [0]}
{if !is_array($best_choices) || empty($best_choices)}
{$best_choices = [0]}
{/if}
<h3>{_('Votes of the poll')}</h3>
@ -168,11 +168,11 @@
{* Line displaying best moments *}
{$count_bests = 0}
{$max = max($best_moments)}
{$max = max($best_choices)}
{if $max > 0}
<tr id="addition">
<td>{_("Addition")}</td>
{foreach $best_moments as $best_moment}
{foreach $best_choices as $best_moment}
{if $max == $best_moment}
{$count_bests = $count_bests +1}
<td><span class="glyphicon glyphicon-star text-warning"></span><span>{$max}</span></td>
@ -189,7 +189,7 @@
{* Best votes listing *}
{$max = max($best_moments)}
{$max = max($best_choices)}
{if $max > 0}
<div class="row">
{if $count_bests == 1}
@ -207,7 +207,7 @@
<ul style="list-style:none">
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
{if $best_moments[$i] == $max}
{if $best_choices[$i] == $max}
<li><strong>{$slot->day|date_format:$date_format.txt_full} - {$moment}</strong></li>
{/if}
{$i = $i+1}