diff --git a/admin/migration.php b/admin/migration.php index 5ed3c7052e973e99ebe64e5816696381ee272cc4..ad58d667ea1272746c24bc84e0dfb2a5cf731dd1 100644 --- a/admin/migration.php +++ b/admin/migration.php @@ -25,6 +25,7 @@ use Framadate\Migration\AddColumn_hidden_In_poll_For_0_9; use Framadate\Migration\Alter_Comment_table_for_name_length; use Framadate\Migration\Alter_Comment_table_adding_date; use Framadate\Migration\Generate_uniqId_for_old_votes; +use Framadate\Migration\AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9; use Framadate\Migration\Migration; use Framadate\Migration\RPadVotes_from_0_8; use Framadate\Utils; @@ -43,7 +44,8 @@ $migrations = [ new Generate_uniqId_for_old_votes(), new RPadVotes_from_0_8(), new Alter_Comment_table_for_name_length(), - new Alter_Comment_table_adding_date() + new Alter_Comment_table_adding_date(), + new AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9(), ]; // --------------------------------------- diff --git a/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php b/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php index dd335f98b30f2c58238505a173d7c9f5fafcdb61..f03356f79a9611abfffe8e54b5e3e79132ccc4f9 100644 --- a/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php +++ b/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php @@ -57,7 +57,7 @@ class AddColumn_hidden_In_poll_For_0_9 implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php b/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php index 865502ae4c6b48f124d49a6030aca8e90f9d9866..850fc63df00299141868347eca0f666ef5093e51 100644 --- a/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php +++ b/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php @@ -57,7 +57,7 @@ class AddColumn_receiveNewComments_For_0_9 implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php b/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php index 440d2de2a157f61b9a97a5db017f7495c84ecff8..0b919857b17ed4a07786a360c8c97aebbd0868c0 100644 --- a/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php +++ b/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php @@ -57,7 +57,7 @@ class AddColumn_uniqId_In_vote_For_0_9 implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php b/app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php new file mode 100644 index 0000000000000000000000000000000000000000..9e6e5cacabcd239f048a73ce367c3c4ed9ab3bb8 --- /dev/null +++ b/app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php @@ -0,0 +1,78 @@ +<?php +/** + * This software is governed by the CeCILL-B license. If a copy of this license + * is not distributed with this file, you can obtain one at + * 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 Framadate/OpenSondate: Framasoft (https://github.com/framasoft) + * + * ============================= + * + * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence + * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur + * 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 Framadate/OpenSondage : Framasoft (https://github.com/framasoft) + */ +namespace Framadate\Migration; + +use Framadate\Utils; + +/** + * This migration adds the fields password_hash and results_publicly_visible on the poll table. + * + * @package Framadate\Migration + * @version 0.9 + */ +class AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9 implements Migration { + + function __construct() { + } + + /** + * This method should describe in english what is the purpose of the migration class. + * + * @return string The description of the migration class + */ + function description() { + return 'Add columns "password_hash" and "results_publicly_visible" in table "vote" for version 0.9'; + } + + /** + * This method could check if the execute method should be called. + * It is called before the execute method. + * + * @param \PDO $pdo The connection to database + * @return bool true is the Migration should be executed. + */ + function preCondition(\PDO $pdo) { + $stmt = $pdo->query('SHOW TABLES'); + $tables = $stmt->fetchAll(\PDO::FETCH_COLUMN); + + // Check if tables of v0.9 are presents + $diff = array_diff([Utils::table('poll'), Utils::table('slot'), Utils::table('vote'), Utils::table('comment')], $tables); + return count($diff) === 0; + } + + /** + * This method is called only one time in the migration page. + * + * @param \PDO $pdo The connection to database + * @return bool true is the execution succeeded + */ + function execute(\PDO $pdo) { + $this->alterPollTable($pdo); + + return true; + } + + private function alterPollTable(\PDO $pdo) { + $pdo->exec(' + ALTER TABLE `' . Utils::table('poll') . '` + ADD `password_hash` VARCHAR(255) NULL DEFAULT NULL , + ADD `results_publicly_visible` TINYINT(1) NULL DEFAULT NULL'); + } + +} diff --git a/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php b/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php index ac985f50a60dfb5e775d08b074580b49afc8da77..01ea83829052ab9e01ec8c0965a3717d2da46e06 100644 --- a/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php +++ b/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php @@ -57,7 +57,7 @@ class From_0_0_to_0_8_Migration implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php b/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php index 4598449832b11f45835b9a6bfe6dcc00b6be70e3..fa7f40cc39e2eb53cadc7e823fd1c71a173af349 100644 --- a/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php +++ b/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php @@ -57,7 +57,7 @@ class From_0_8_to_0_9_Migration implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded