type .'" role="alert">';
+ echo '
';
echo Utils::htmlEscape($message->message);
- echo ''. $message->type .'';
+ echo '' . $message->type . '';
echo '
';
}
?>
@@ -209,7 +207,7 @@ usort($messages, 'compareCheckMessage');
= __('Check', 'Check again') ?>
= __('Check', 'Continue the installation') ?>
assign('error', $error);
diff --git a/admin/migration.php b/admin/migration.php
index 0077751..93cb189 100644
--- a/admin/migration.php
+++ b/admin/migration.php
@@ -17,15 +17,15 @@
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
-use Framadate\Migration\From_0_0_to_0_8_Migration;
-use Framadate\Migration\From_0_8_to_0_9_Migration;
+use Framadate\Migration\AddColumn_hidden_In_poll_For_0_9;
use Framadate\Migration\AddColumn_receiveNewComments_For_0_9;
use Framadate\Migration\AddColumn_uniqId_In_vote_For_0_9;
-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\Alter_Comment_table_adding_date;
+use Framadate\Migration\Alter_Comment_table_for_name_length;
+use Framadate\Migration\From_0_0_to_0_8_Migration;
+use Framadate\Migration\From_0_8_to_0_9_Migration;
+use Framadate\Migration\Generate_uniqId_for_old_votes;
use Framadate\Migration\Increase_pollId_size;
use Framadate\Migration\Migration;
use Framadate\Migration\RPadVotes_from_0_8;
@@ -56,7 +56,7 @@ $tables = $connect->allTables();
$pdo = $connect->getPDO();
$prefixedMigrationTable = Utils::table(MIGRATION_TABLE);
-if (!in_array($prefixedMigrationTable, $tables)) {
+if (!in_array($prefixedMigrationTable, $tables, true)) {
$pdo->exec('
CREATE TABLE IF NOT EXISTS `' . $prefixedMigrationTable . '` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -104,7 +104,6 @@ foreach ($migrations as $migration) {
} else {
$countSkipped++;
}
-
}
$countTotal = $countSucceeded + $countFailed + $countSkipped;
diff --git a/adminstuds.php b/adminstuds.php
index e92d624..a6f22ef 100644
--- a/adminstuds.php
+++ b/adminstuds.php
@@ -21,13 +21,13 @@ use Framadate\Exception\AlreadyExistsException;
use Framadate\Exception\ConcurrentEditionException;
use Framadate\Exception\MomentAlreadyExistsException;
use Framadate\Message;
+use Framadate\Security\PasswordHasher;
use Framadate\Services\AdminPollService;
use Framadate\Services\InputService;
use Framadate\Services\LogService;
use Framadate\Services\MailService;
-use Framadate\Services\PollService;
use Framadate\Services\NotificationService;
-use Framadate\Security\PasswordHasher;
+use Framadate\Services\PollService;
use Framadate\Utils;
include_once __DIR__ . '/app/inc/init.php';
@@ -79,25 +79,25 @@ if (isset($_POST['update_poll_info'])) {
'rules', 'expiration_date', 'name', 'hidden', 'removePassword', 'password']);
// Update the right poll field
- if ($field == 'title') {
+ if ($field === 'title') {
$title = $inputService->filterTitle($_POST['title']);
if ($title) {
$poll->title = $title;
$updated = true;
}
- } elseif ($field == 'admin_mail') {
+ } elseif ($field === 'admin_mail') {
$admin_mail = $inputService->filterMail($_POST['admin_mail']);
if ($admin_mail) {
$poll->admin_mail = $admin_mail;
$updated = true;
}
- } elseif ($field == 'description') {
+ } elseif ($field === 'description') {
$description = $inputService->filterDescription($_POST['description']);
if ($description) {
$poll->description = $description;
$updated = true;
}
- } elseif ($field == 'rules') {
+ } elseif ($field === 'rules') {
$rules = strip_tags($_POST['rules']);
switch ($rules) {
case 0:
@@ -121,39 +121,39 @@ if (isset($_POST['update_poll_info'])) {
$updated = true;
break;
}
- } elseif ($field == 'expiration_date') {
+ } elseif ($field === 'expiration_date') {
$expiration_date = $inputService->filterDate($_POST['expiration_date']);
if ($expiration_date) {
$poll->end_date = $expiration_date;
$updated = true;
}
- } elseif ($field == 'name') {
+ } elseif ($field === 'name') {
$admin_name = $inputService->filterName($_POST['name']);
if ($admin_name) {
$poll->admin_name = $admin_name;
$updated = true;
}
- } elseif ($field == 'hidden') {
+ } elseif ($field === 'hidden') {
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
- if ($hidden != $poll->hidden) {
+ if ($hidden !== $poll->hidden) {
$poll->hidden = $hidden;
$updated = true;
}
- } elseif ($field == 'removePassword') {
+ } elseif ($field === 'removePassword') {
$removePassword = isset($_POST['removePassword']) ? $inputService->filterBoolean($_POST['removePassword']) : false;
if ($removePassword) {
$poll->results_publicly_visible = false;
$poll->password_hash = null;
$updated = true;
}
- } elseif ($field == 'password') {
+ } elseif ($field === 'password') {
$password = isset($_POST['password']) ? $_POST['password'] : null;
$resultsPubliclyVisible = isset($_POST['resultsPubliclyVisible']) ? $inputService->filterBoolean($_POST['resultsPubliclyVisible']) : false;
if (!empty($password)) {
$poll->password_hash = PasswordHasher::hash($password);
$updated = true;
}
- if ($resultsPubliclyVisible != $poll->results_publicly_visible) {
+ if ($resultsPubliclyVisible !== $poll->results_publicly_visible) {
$poll->results_publicly_visible = $resultsPubliclyVisible;
$updated = true;
}
@@ -190,11 +190,11 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
if (empty($editedVote)) {
$message = new Message('danger', __('Error', 'Something is going wrong...'));
}
- if (count($choices) != count($_POST['choices'])) {
+ if (count($choices) !== count($_POST['choices'])) {
$message = new Message('danger', __('Error', 'There is a problem with your choices'));
}
- if ($message == null) {
+ if ($message === null) {
// Update vote
try {
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices, $slots_hash);
@@ -212,14 +212,14 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
$choices = $inputService->filterArray($_POST['choices'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => CHOICE_REGEX]]);
$slots_hash = $inputService->filterMD5($_POST['control']);
- if ($name == null) {
+ if ($name === null) {
$message = new Message('danger', __('Error', 'The name is invalid.'));
}
- if (count($choices) != count($_POST['choices'])) {
+ if (count($choices) !== count($_POST['choices'])) {
$message = new Message('danger', __('Error', 'There is a problem with your choices'));
}
- if ($message == null) {
+ if ($message === null) {
// Add vote
try {
$result = $pollService->addVote($poll_id, $name, $choices, $slots_hash);
@@ -401,7 +401,6 @@ $slots = $pollService->allSlotsByPoll($poll);
$votes = $pollService->allVotesByPollId($poll_id);
$comments = $pollService->allCommentsByPollId($poll_id);
-
// Assign data to template
$smarty->assign('poll_id', $poll_id);
$smarty->assign('admin_poll_id', $admin_poll_id);
diff --git a/app/classes/Framadate/Choice.php b/app/classes/Framadate/Choice.php
index eb98cee..e583e26 100644
--- a/app/classes/Framadate/Choice.php
+++ b/app/classes/Framadate/Choice.php
@@ -33,7 +33,7 @@ class Choice
public function __construct($name='')
{
$this->name = $name;
- $this->slots = array();
+ $this->slots = [];
}
public function addSlot($slot)
@@ -55,5 +55,4 @@ class Choice
{
return strcmp($a->name, $b->name);
}
-
}
diff --git a/app/classes/Framadate/Editable.php b/app/classes/Framadate/Editable.php
index 367948c..c2314c3 100644
--- a/app/classes/Framadate/Editable.php
+++ b/app/classes/Framadate/Editable.php
@@ -19,7 +19,6 @@
namespace Framadate;
-
/**
* Class Editable
*
diff --git a/app/classes/Framadate/Exception/AlreadyExistsException.php b/app/classes/Framadate/Exception/AlreadyExistsException.php
index 510b798..86e73aa 100644
--- a/app/classes/Framadate/Exception/AlreadyExistsException.php
+++ b/app/classes/Framadate/Exception/AlreadyExistsException.php
@@ -2,8 +2,6 @@
namespace Framadate\Exception;
class AlreadyExistsException extends \Exception {
-
function __construct() {
}
-
}
diff --git a/app/classes/Framadate/Exception/ConcurrentEditionException.php b/app/classes/Framadate/Exception/ConcurrentEditionException.php
index 94f5a67..70748b1 100644
--- a/app/classes/Framadate/Exception/ConcurrentEditionException.php
+++ b/app/classes/Framadate/Exception/ConcurrentEditionException.php
@@ -2,8 +2,6 @@
namespace Framadate\Exception;
class ConcurrentEditionException extends \Exception {
-
function __construct() {
}
-
}
diff --git a/app/classes/Framadate/Exception/MomentAlreadyExistsException.php b/app/classes/Framadate/Exception/MomentAlreadyExistsException.php
index 11723e9..287afd6 100644
--- a/app/classes/Framadate/Exception/MomentAlreadyExistsException.php
+++ b/app/classes/Framadate/Exception/MomentAlreadyExistsException.php
@@ -2,8 +2,6 @@
namespace Framadate\Exception;
class MomentAlreadyExistsException extends \Exception {
-
function __construct() {
}
-
}
diff --git a/app/classes/Framadate/Form.php b/app/classes/Framadate/Form.php
index bc2ae8c..f1ad031 100644
--- a/app/classes/Framadate/Form.php
+++ b/app/classes/Framadate/Form.php
@@ -20,7 +20,6 @@ namespace Framadate;
class Form
{
-
public $title;
public $id;
public $description;
@@ -87,7 +86,7 @@ class Form
}
public function clearChoices() {
- $this->choices = array();
+ $this->choices = [];
}
public function addChoice(Choice $choice)
@@ -102,7 +101,6 @@ class Form
public function sortChoices()
{
- usort($this->choices, array('Framadate\Choice', 'compare'));
+ usort($this->choices, ['Framadate\Choice', 'compare']);
}
-
}
diff --git a/app/classes/Framadate/Message.php b/app/classes/Framadate/Message.php
index 7fa74c0..d8530d6 100644
--- a/app/classes/Framadate/Message.php
+++ b/app/classes/Framadate/Message.php
@@ -18,8 +18,7 @@
*/
namespace Framadate;
-class Message {
-
+class Message {
var $type;
var $message;
var $link;
@@ -27,14 +26,13 @@ class Message {
var $linkIcon;
var $includeTemplate;
- function __construct($type, $message, $link=null, $linkTitle=null, $linkIcon=null, $includeTemplate=null) {
+ function __construct($type, $message, $link=null, $linkTitle=null, $linkIcon=null, $includeTemplate=null) {
$this->type = $type;
$this->message = $message;
$this->link = $link;
$this->linkTitle = $linkTitle;
$this->linkIcon = $linkIcon;
- $this->includeTemplate = $includeTemplate;
- }
-
+ $this->includeTemplate = $includeTemplate;
+ }
}
\ No newline at end of file
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 4d5ceb2..f8c3eac 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
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 0.9
*/
class AddColumn_hidden_In_poll_For_0_9 implements Migration {
-
function __construct() {
}
@@ -73,5 +72,4 @@ class AddColumn_hidden_In_poll_For_0_9 implements Migration {
ALTER TABLE `' . Utils::table('poll') . '`
ADD `hidden` TINYINT( 1 ) NOT NULL DEFAULT "0"');
}
-
}
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 6d53919..9863e26 100644
--- a/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php
+++ b/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 0.9
*/
class AddColumn_receiveNewComments_For_0_9 implements Migration {
-
function __construct() {
}
@@ -74,5 +73,4 @@ ALTER TABLE `' . Utils::table('poll') . '`
ADD `receiveNewComments` TINYINT(1) DEFAULT \'0\'
AFTER `receiveNewVotes`');
}
-
}
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 f1abe28..2da2e49 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
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 0.9
*/
class AddColumn_uniqId_In_vote_For_0_9 implements Migration {
-
function __construct() {
}
@@ -75,5 +74,4 @@ class AddColumn_uniqId_In_vote_For_0_9 implements Migration {
AFTER `id`,
ADD INDEX (`uniqId`) ;');
}
-
}
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
index 476549d..93893a1 100644
--- 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
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 0.9
*/
class AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9 implements Migration {
-
function __construct() {
}
@@ -74,5 +73,4 @@ class AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9 impl
ADD `password_hash` VARCHAR(255) NULL DEFAULT NULL ,
ADD `results_publicly_visible` TINYINT(1) NULL DEFAULT NULL');
}
-
}
diff --git a/app/classes/Framadate/Migration/Alter_Comment_table_adding_date.php b/app/classes/Framadate/Migration/Alter_Comment_table_adding_date.php
index b6b3bf0..afc57a9 100644
--- a/app/classes/Framadate/Migration/Alter_Comment_table_adding_date.php
+++ b/app/classes/Framadate/Migration/Alter_Comment_table_adding_date.php
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 1.0
*/
class Alter_Comment_table_adding_date implements Migration {
-
function __construct() {
}
@@ -68,5 +67,4 @@ class Alter_Comment_table_adding_date implements Migration {
ALTER TABLE `' . Utils::table('comment') . '`
ADD `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;');
}
-
}
diff --git a/app/classes/Framadate/Migration/Alter_Comment_table_for_name_length.php b/app/classes/Framadate/Migration/Alter_Comment_table_for_name_length.php
index dd487fd..1844c81 100644
--- a/app/classes/Framadate/Migration/Alter_Comment_table_for_name_length.php
+++ b/app/classes/Framadate/Migration/Alter_Comment_table_for_name_length.php
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 1.0
*/
class Alter_Comment_table_for_name_length implements Migration {
-
function __construct() {
}
@@ -68,5 +67,4 @@ class Alter_Comment_table_for_name_length implements Migration {
ALTER TABLE `' . Utils::table('comment') . '`
CHANGE `name` `name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci 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 b30d2bb..4dd1e12 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
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 0.8
*/
class From_0_0_to_0_8_Migration implements Migration {
-
function __construct() {
}
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 5f8b7d7..c8f1096 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
@@ -27,7 +27,6 @@ use Framadate\Utils;
* @version 0.9
*/
class From_0_8_to_0_9_Migration implements Migration {
-
function __construct() {
}
@@ -265,14 +264,14 @@ VALUE (?,?,?)');
$slots[] = $slot;
} else { // Date poll
$values = explode('@', $atomicSlot);
- if ($lastSlot == null || $lastSlot->title !== $values[0]) {
+ if ($lastSlot === null || $lastSlot->title !== $values[0]) {
$lastSlot = new \stdClass();
$lastSlot->poll_id = $sujet->id_sondage;
$lastSlot->title = $values[0];
- $lastSlot->moments = count($values) == 2 ? $values[1] : '-';
+ $lastSlot->moments = count($values) === 2 ? $values[1] : '-';
$slots[] = $lastSlot;
} else {
- $lastSlot->moments .= ',' . (count($values) == 2 ? $values[1] : '-');
+ $lastSlot->moments .= ',' . (count($values) === 2 ? $values[1] : '-');
}
}
}
diff --git a/app/classes/Framadate/Migration/Generate_uniqId_for_old_votes.php b/app/classes/Framadate/Migration/Generate_uniqId_for_old_votes.php
index cfe2cd8..fb81466 100644
--- a/app/classes/Framadate/Migration/Generate_uniqId_for_old_votes.php
+++ b/app/classes/Framadate/Migration/Generate_uniqId_for_old_votes.php
@@ -28,7 +28,6 @@ use Framadate\Utils;
* @version 0.9
*/
class Generate_uniqId_for_old_votes implements Migration {
-
function __construct() {
}
@@ -52,7 +51,6 @@ class Generate_uniqId_for_old_votes implements Migration {
* @return bool true is the execution succeeded
*/
function execute(\PDO $pdo) {
-
$pdo->beginTransaction();
$this->generateUniqIdsForEmptyOnes($pdo);
$pdo->commit();
@@ -79,5 +77,4 @@ UPDATE `' . Utils::table('vote') . '`
]);
}
}
-
}
diff --git a/app/classes/Framadate/Migration/Increase_pollId_size.php b/app/classes/Framadate/Migration/Increase_pollId_size.php
index 071988c..37eec25 100644
--- a/app/classes/Framadate/Migration/Increase_pollId_size.php
+++ b/app/classes/Framadate/Migration/Increase_pollId_size.php
@@ -4,7 +4,6 @@ namespace Framadate\Migration;
use Framadate\Utils;
class Increase_pollId_size implements Migration {
-
function __construct() {
}
diff --git a/app/classes/Framadate/Migration/Migration.php b/app/classes/Framadate/Migration/Migration.php
index 3138cae..c4bed57 100644
--- a/app/classes/Framadate/Migration/Migration.php
+++ b/app/classes/Framadate/Migration/Migration.php
@@ -19,7 +19,6 @@
namespace Framadate\Migration;
interface Migration {
-
/**
* This method should describe in english what is the purpose of the migration class.
*
@@ -43,6 +42,5 @@ interface Migration {
* @return bool true if the execution succeeded
*/
function execute(\PDO $pdo);
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Migration/RPadVotes_from_0_8.php b/app/classes/Framadate/Migration/RPadVotes_from_0_8.php
index 33ccdc9..52599eb 100644
--- a/app/classes/Framadate/Migration/RPadVotes_from_0_8.php
+++ b/app/classes/Framadate/Migration/RPadVotes_from_0_8.php
@@ -28,7 +28,6 @@ use Framadate\Utils;
* @version 0.9
*/
class RPadVotes_from_0_8 implements Migration {
-
function description() {
return 'RPad votes from version 0.8.';
}
@@ -43,7 +42,6 @@ class RPadVotes_from_0_8 implements Migration {
}
function execute(\PDO $pdo) {
-
$pdo->beginTransaction();
$this->rpadVotes($pdo);
$pdo->commit();
@@ -52,13 +50,13 @@ class RPadVotes_from_0_8 implements Migration {
}
private function rpadVotes($pdo) {
- $pdo->exec('UPDATE '. Utils::table('vote') .' fv
+ $pdo->exec('UPDATE ' . Utils::table('vote') . ' fv
INNER JOIN (
SELECT v.id, RPAD(v.choices, inn.slots_count, \'0\') new_choices
- FROM '. Utils::table('vote') .' v
+ FROM ' . Utils::table('vote') . ' v
INNER JOIN
(SELECT s.poll_id, SUM(IFNULL(LENGTH(s.moments) - LENGTH(REPLACE(s.moments, \',\', \'\')) + 1, 1)) slots_count
- FROM '. Utils::table('slot') .' s
+ FROM ' . Utils::table('slot') . ' s
GROUP BY s.poll_id
ORDER BY s.poll_id) inn ON inn.poll_id = v.poll_id
WHERE LENGTH(v.choices) != inn.slots_count
diff --git a/app/classes/Framadate/Repositories/AbstractRepository.php b/app/classes/Framadate/Repositories/AbstractRepository.php
index 736436f..28a8b2f 100644
--- a/app/classes/Framadate/Repositories/AbstractRepository.php
+++ b/app/classes/Framadate/Repositories/AbstractRepository.php
@@ -4,7 +4,6 @@ namespace Framadate\Repositories;
use Framadate\FramaDB;
abstract class AbstractRepository {
-
/**
* @var FramaDB
*/
@@ -41,5 +40,4 @@ abstract class AbstractRepository {
function lastInsertId() {
return $this->connect->lastInsertId();
}
-
}
diff --git a/app/classes/Framadate/Repositories/CommentRepository.php b/app/classes/Framadate/Repositories/CommentRepository.php
index 4fb5fd9..262ed0a 100644
--- a/app/classes/Framadate/Repositories/CommentRepository.php
+++ b/app/classes/Framadate/Repositories/CommentRepository.php
@@ -5,14 +5,13 @@ use Framadate\FramaDB;
use Framadate\Utils;
class CommentRepository extends AbstractRepository {
-
function __construct(FramaDB $connect) {
parent::__construct($connect);
}
function findAllByPollId($poll_id) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('comment') . '` WHERE poll_id = ? ORDER BY id');
- $prepared->execute(array($poll_id));
+ $prepared->execute([$poll_id]);
return $prepared->fetchAll();
}
@@ -51,9 +50,8 @@ class CommentRepository extends AbstractRepository {
public function exists($poll_id, $name, $comment) {
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('comment') . '` WHERE poll_id = ? AND name = ? AND comment = ?');
- $prepared->execute(array($poll_id, $name, $comment));
+ $prepared->execute([$poll_id, $name, $comment]);
return $prepared->rowCount() > 0;
}
-
}
diff --git a/app/classes/Framadate/Repositories/PollRepository.php b/app/classes/Framadate/Repositories/PollRepository.php
index 3fb3a84..4f5e62e 100644
--- a/app/classes/Framadate/Repositories/PollRepository.php
+++ b/app/classes/Framadate/Repositories/PollRepository.php
@@ -6,7 +6,6 @@ use Framadate\Utils;
use PDO;
class PollRepository extends AbstractRepository {
-
function __construct(FramaDB $connect) {
parent::__construct($connect);
}
@@ -16,13 +15,13 @@ class PollRepository extends AbstractRepository {
(id, admin_id, title, description, admin_name, admin_mail, end_date, format, editable, receiveNewVotes, receiveNewComments, hidden, password_hash, results_publicly_visible)
VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?,?,?,?,?,?,?)';
$prepared = $this->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>=0 && $form->editable<=2) ? $form->editable : 0, $form->receiveNewVotes ? 1 : 0, $form->receiveNewComments ? 1 : 0, $form->hidden ? 1 : 0, $form->password_hash, $form->results_publicly_visible ? 1 : 0));
+ $prepared->execute([$poll_id, $admin_poll_id, $form->title, $form->description, $form->admin_name, $form->admin_mail, $form->end_date, $form->format, ($form->editable>=0 && $form->editable<=2) ? $form->editable : 0, $form->receiveNewVotes ? 1 : 0, $form->receiveNewComments ? 1 : 0, $form->hidden ? 1 : 0, $form->password_hash, $form->results_publicly_visible ? 1 : 0]);
}
function findById($poll_id) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE id = ?');
- $prepared->execute(array($poll_id));
+ $prepared->execute([$poll_id]);
$poll = $prepared->fetch();
$prepared->closeCursor();
@@ -32,7 +31,7 @@ class PollRepository extends AbstractRepository {
public function findByAdminId($admin_poll_id) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE admin_id = ?');
- $prepared->execute(array($admin_poll_id));
+ $prepared->execute([$admin_poll_id]);
$poll = $prepared->fetch();
$prepared->closeCursor();
@@ -42,7 +41,7 @@ class PollRepository extends AbstractRepository {
public function existsById($poll_id) {
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE id = ?');
- $prepared->execute(array($poll_id));
+ $prepared->execute([$poll_id]);
return $prepared->rowCount() > 0;
}
@@ -50,7 +49,7 @@ class PollRepository extends AbstractRepository {
public function existsByAdminId($admin_poll_id) {
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE admin_id = ?');
- $prepared->execute(array($admin_poll_id));
+ $prepared->execute([$admin_poll_id]);
return $prepared->rowCount() > 0;
}
@@ -124,7 +123,7 @@ SELECT p.*,
*/
public function findAllByAdminMail($mail) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE admin_mail = :admin_mail');
- $prepared->execute(array('admin_mail' => $mail));
+ $prepared->execute(['admin_mail' => $mail]);
return $prepared->fetchAll();
}
@@ -145,9 +144,9 @@ SELECT count(1) nb
AND (:name = "" OR p.admin_name LIKE :name)
ORDER BY p.title ASC');
- $poll = $search == null ? '' : $search['poll'] . '%';
- $title = $search == null ? '' : '%' . $search['title'] . '%';
- $name = $search == null ? '' : '%' . $search['name'] . '%';
+ $poll = $search === null ? '' : $search['poll'] . '%';
+ $title = $search === null ? '' : '%' . $search['title'] . '%';
+ $name = $search === null ? '' : '%' . $search['name'] . '%';
$prepared->bindParam(':id', $poll, PDO::PARAM_STR);
$prepared->bindParam(':title', $title, PDO::PARAM_STR);
$prepared->bindParam(':name', $name, PDO::PARAM_STR);
@@ -162,5 +161,4 @@ SELECT count(1) nb
return $count->nb;
}
-
}
diff --git a/app/classes/Framadate/Repositories/RepositoryFactory.php b/app/classes/Framadate/Repositories/RepositoryFactory.php
index c650197..1ebef18 100644
--- a/app/classes/Framadate/Repositories/RepositoryFactory.php
+++ b/app/classes/Framadate/Repositories/RepositoryFactory.php
@@ -21,7 +21,6 @@ namespace Framadate\Repositories;
use Framadate\FramaDB;
class RepositoryFactory {
-
private static $connect;
private static $pollRepository;
@@ -40,7 +39,7 @@ class RepositoryFactory {
* @return PollRepository The singleton of PollRepository
*/
static function pollRepository() {
- if (self::$pollRepository == null) {
+ if (self::$pollRepository === null) {
self::$pollRepository = new PollRepository(self::$connect);
}
@@ -51,7 +50,7 @@ class RepositoryFactory {
* @return SlotRepository The singleton of SlotRepository
*/
static function slotRepository() {
- if (self::$slotRepository == null) {
+ if (self::$slotRepository === null) {
self::$slotRepository = new SlotRepository(self::$connect);
}
@@ -62,7 +61,7 @@ class RepositoryFactory {
* @return VoteRepository The singleton of VoteRepository
*/
static function voteRepository() {
- if (self::$voteRepository == null) {
+ if (self::$voteRepository === null) {
self::$voteRepository = new VoteRepository(self::$connect);
}
@@ -73,11 +72,10 @@ class RepositoryFactory {
* @return CommentRepository The singleton of CommentRepository
*/
static function commentRepository() {
- if (self::$commentRepository == null) {
+ if (self::$commentRepository === null) {
self::$commentRepository = new CommentRepository(self::$connect);
}
return self::$commentRepository;
}
-
}
diff --git a/app/classes/Framadate/Repositories/SlotRepository.php b/app/classes/Framadate/Repositories/SlotRepository.php
index 003c028..4c9c40f 100644
--- a/app/classes/Framadate/Repositories/SlotRepository.php
+++ b/app/classes/Framadate/Repositories/SlotRepository.php
@@ -22,7 +22,6 @@ use Framadate\FramaDB;
use Framadate\Utils;
class SlotRepository extends AbstractRepository {
-
function __construct(FramaDB $connect) {
parent::__construct($connect);
}
@@ -37,7 +36,6 @@ class SlotRepository extends AbstractRepository {
$prepared = $this->prepare('INSERT INTO `' . Utils::table('slot') . '` (poll_id, title, moments) VALUES (?, ?, ?)');
foreach ($choices as $choice) {
-
// We prepared the slots (joined by comas)
$joinedSlots = '';
$first = true;
@@ -52,17 +50,16 @@ class SlotRepository extends AbstractRepository {
// We execute the insertion
if (empty($joinedSlots)) {
- $prepared->execute(array($poll_id, $choice->getName(), null));
+ $prepared->execute([$poll_id, $choice->getName(), null]);
} else {
- $prepared->execute(array($poll_id, $choice->getName(), $joinedSlots));
+ $prepared->execute([$poll_id, $choice->getName(), $joinedSlots]);
}
-
}
}
function listByPollId($poll_id) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('slot') . '` WHERE poll_id = ? ORDER BY id');
- $prepared->execute(array($poll_id));
+ $prepared->execute([$poll_id]);
return $prepared->fetchAll();
}
@@ -128,5 +125,4 @@ class SlotRepository extends AbstractRepository {
return $prepared->execute([$poll_id]);
}
-
}
diff --git a/app/classes/Framadate/Repositories/VoteRepository.php b/app/classes/Framadate/Repositories/VoteRepository.php
index efd7b36..1a74f5a 100644
--- a/app/classes/Framadate/Repositories/VoteRepository.php
+++ b/app/classes/Framadate/Repositories/VoteRepository.php
@@ -5,14 +5,13 @@ use Framadate\FramaDB;
use Framadate\Utils;
class VoteRepository extends AbstractRepository {
-
function __construct(FramaDB $connect) {
parent::__construct($connect);
}
function allUserVotesByPollId($poll_id) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('vote') . '` WHERE poll_id = ? ORDER BY id');
- $prepared->execute(array($poll_id));
+ $prepared->execute([$poll_id]);
return $prepared->fetchAll();
}
@@ -83,8 +82,7 @@ class VoteRepository extends AbstractRepository {
*/
public function existsByPollIdAndName($poll_id, $name) {
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('vote') . '` WHERE poll_id = ? AND name = ?');
- $prepared->execute(array($poll_id, $name));
+ $prepared->execute([$poll_id, $name]);
return $prepared->rowCount() > 0;
}
-
}
diff --git a/app/classes/Framadate/Security/PasswordHasher.php b/app/classes/Framadate/Security/PasswordHasher.php
index 4d1156f..ba46a24 100644
--- a/app/classes/Framadate/Security/PasswordHasher.php
+++ b/app/classes/Framadate/Security/PasswordHasher.php
@@ -11,7 +11,6 @@ namespace Framadate\Security;
* @package Framadate\Security
*/
class PasswordHasher {
-
/**
* Hash a password
*
diff --git a/app/classes/Framadate/Security/Token.php b/app/classes/Framadate/Security/Token.php
index ec66347..5998f2e 100644
--- a/app/classes/Framadate/Security/Token.php
+++ b/app/classes/Framadate/Security/Token.php
@@ -2,7 +2,6 @@
namespace Framadate\Security;
class Token {
-
const DEFAULT_LENGTH = 64;
private $time;
private $value;
@@ -15,10 +14,6 @@ class Token {
$this->value = $this->generate();
}
- private function generate() {
- return self::getToken($this->length);
- }
-
public function getTime() {
return $this->time;
}
@@ -71,6 +66,10 @@ class Token {
return $token;
}
+ private function generate() {
+ return self::getToken($this->length);
+ }
+
/**
* @author http://us1.php.net/manual/en/function.openssl-random-pseudo-bytes.php#104322
*/
@@ -87,6 +86,5 @@ class Token {
} while ($rnd >= $range);
return $min + $rnd;
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php
index 2e3f3af..0f76150 100644
--- a/app/classes/Framadate/Services/AdminPollService.php
+++ b/app/classes/Framadate/Services/AdminPollService.php
@@ -12,7 +12,6 @@ use Framadate\Utils;
* @package Framadate\Services
*/
class AdminPollService {
-
private $connect;
private $pollService;
private $logService;
@@ -36,9 +35,8 @@ class AdminPollService {
global $config;
if ($poll->end_date > $poll->creation_date) {
return $this->pollRepository->update($poll);
- } else {
+ }
return false;
- }
}
/**
@@ -120,9 +118,9 @@ class AdminPollService {
$slots = $this->pollService->allSlotsByPoll($poll);
// We can't delete the last slot
- if ($poll->format == 'D' && count($slots) === 1 && strpos($slots[0]->moments, ',') === false) {
+ if ($poll->format === 'D' && count($slots) === 1 && strpos($slots[0]->moments, ',') === false) {
return false;
- } elseif ($poll->format == 'A' && count($slots) === 1) {
+ } elseif ($poll->format === 'A' && count($slots) === 1) {
return false;
}
@@ -135,8 +133,8 @@ class AdminPollService {
$moments = explode(',', $aSlot->moments);
foreach ($moments as $rowMoment) {
- if ($datetime == $aSlot->title) {
- if ($moment == $rowMoment) {
+ if ($datetime === $aSlot->title) {
+ if ($moment === $rowMoment) {
$indexToDelete = $index;
} else {
$newMoments[] = $rowMoment;
@@ -173,7 +171,7 @@ class AdminPollService {
// Search the index of the slot to delete
foreach ($slots as $aSlot) {
- if ($slot_title == $aSlot->title) {
+ if ($slot_title === $aSlot->title) {
$indexToDelete = $index;
}
$index++;
@@ -209,19 +207,18 @@ class AdminPollService {
// Begin transaction
$this->connect->beginTransaction();
- if ($result->slot != null) {
+ if ($result->slot !== null) {
$slot = $result->slot;
$moments = explode(',', $slot->moments);
// Check if moment already exists (maybe not necessary)
- if (in_array($new_moment, $moments)) {
+ if (in_array($new_moment, $moments, true)) {
throw new MomentAlreadyExistsException();
}
// Update found slot
$moments[] = $new_moment;
$this->slotRepository->update($poll_id, $datetime, implode(',', $moments));
-
} else {
$this->slotRepository->insert($poll_id, $datetime, $new_moment);
}
@@ -230,7 +227,6 @@ class AdminPollService {
// Commit transaction
$this->connect->commit();
-
}
/**
@@ -252,12 +248,11 @@ class AdminPollService {
$titles = array_map(function ($slot) {
return $slot->title;
}, $slots);
- if (in_array($title, $titles)) {
+ if (in_array($title, $titles, true)) {
// The moment already exists
throw new MomentAlreadyExistsException();
}
-
// Begin transaction
$this->connect->beginTransaction();
@@ -268,7 +263,6 @@ class AdminPollService {
// Commit transaction
$this->connect->commit();
-
}
/**
@@ -293,7 +287,7 @@ class AdminPollService {
$rowDatetime = $slot->title;
$moments = explode(',', $slot->moments);
- if ($datetime == $rowDatetime) {
+ if ($datetime === $rowDatetime) {
// Here we have to insert at the end of a slot
$result->insert += count($moments);
$result->slot = $slot;
@@ -301,13 +295,11 @@ class AdminPollService {
} elseif ($datetime < $rowDatetime) {
// We have to insert before this slot
break;
- } else {
+ }
$result->insert += count($moments);
- }
}
return $result;
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php
index 2846163..23f6e00 100644
--- a/app/classes/Framadate/Services/InputService.php
+++ b/app/classes/Framadate/Services/InputService.php
@@ -23,7 +23,6 @@ use DateTime;
* This class helps to clean all inputs from the users or external services.
*/
class InputService {
-
function __construct() {}
/**
@@ -112,5 +111,4 @@ class InputService {
return null;
}
-
}
diff --git a/app/classes/Framadate/Services/InstallService.php b/app/classes/Framadate/Services/InstallService.php
index abc825d..13672fa 100644
--- a/app/classes/Framadate/Services/InstallService.php
+++ b/app/classes/Framadate/Services/InstallService.php
@@ -24,8 +24,7 @@ use Smarty;
* This class helps to clean all inputs from the users or external services.
*/
class InstallService {
-
- private $fields = array(
+ private $fields = [
// General
'appName' => 'Framadate',
'appMail' => '',
@@ -39,7 +38,7 @@ class InstallService {
'dbPassword' => '',
'dbPrefix' => 'fd_',
'migrationTable' => 'framadate_migration'
- );
+ ];
function __construct() {}
@@ -101,10 +100,10 @@ class InstallService {
* @return array
*/
function ok() {
- return array(
+ return [
'status' => 'OK',
'msg' => __f('Installation', 'Ended', Utils::get_server_name())
- );
+ ];
}
/**
@@ -112,14 +111,13 @@ class InstallService {
* @return array
*/
function error($msg) {
- return array(
+ return [
'status' => 'ERROR',
'code' => $msg
- );
+ ];
}
public function getFields() {
return $this->fields;
}
-
}
diff --git a/app/classes/Framadate/Services/LogService.php b/app/classes/Framadate/Services/LogService.php
index 4f68463..9242df1 100644
--- a/app/classes/Framadate/Services/LogService.php
+++ b/app/classes/Framadate/Services/LogService.php
@@ -7,7 +7,6 @@ namespace Framadate\Services;
* @package Framadate\Services
*/
class LogService {
-
function __construct() {
}
@@ -20,6 +19,5 @@ class LogService {
function log($tag, $message) {
error_log(date('Ymd His') . ' [' . $tag . '] ' . $message . "\n", 3, ROOT_DIR . LOG_FILE);
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/MailService.php b/app/classes/Framadate/Services/MailService.php
index b7c60dc..b78325b 100644
--- a/app/classes/Framadate/Services/MailService.php
+++ b/app/classes/Framadate/Services/MailService.php
@@ -4,13 +4,12 @@ namespace Framadate\Services;
use PHPMailer;
class MailService {
-
- private $smtp_allowed;
-
const DELAY_BEFORE_RESEND = 300;
const MAILSERVICE_KEY = 'mailservice';
+ private $smtp_allowed;
+
private $logService;
function __construct($smtp_allowed) {
@@ -23,7 +22,7 @@ class MailService {
}
function send($to, $subject, $body, $msgKey = null) {
- if ($this->smtp_allowed == true && $this->canSendMsg($msgKey)) {
+ if ($this->smtp_allowed === true && $this->canSendMsg($msgKey)) {
$mail = new PHPMailer(true);
$mail->isSMTP();
@@ -62,7 +61,7 @@ class MailService {
}
function canSendMsg($msgKey) {
- if ($msgKey == null) {
+ if ($msgKey === null) {
return true;
}
@@ -71,6 +70,5 @@ class MailService {
}
return !isset($_SESSION[self::MAILSERVICE_KEY][$msgKey]) || time() - $_SESSION[self::MAILSERVICE_KEY][$msgKey] > self::DELAY_BEFORE_RESEND;
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/NotificationService.php b/app/classes/Framadate/Services/NotificationService.php
index e59c5c1..8ed321f 100644
--- a/app/classes/Framadate/Services/NotificationService.php
+++ b/app/classes/Framadate/Services/NotificationService.php
@@ -3,13 +3,11 @@
namespace Framadate\Services;
+use \stdClass;
use Framadate\Services\MailService;
use Framadate\Utils;
-use \stdClass;
-
class NotificationService {
-
const UPDATE_VOTE = 1;
const ADD_VOTE = 2;
const ADD_COMMENT = 3;
@@ -34,12 +32,11 @@ class NotificationService {
$_SESSION['mail_sent'] = [];
}
- $isVoteAndCanSendIt = ($type == self::UPDATE_VOTE || $type == self::ADD_VOTE) && $poll->receiveNewVotes;
- $isCommentAndCanSendIt = $type == self::ADD_COMMENT && $poll->receiveNewComments;
- $isOtherType = $type != self::UPDATE_VOTE && $type != self::ADD_VOTE && $type != self::ADD_COMMENT;
+ $isVoteAndCanSendIt = ($type === self::UPDATE_VOTE || $type === self::ADD_VOTE) && $poll->receiveNewVotes;
+ $isCommentAndCanSendIt = $type === self::ADD_COMMENT && $poll->receiveNewComments;
+ $isOtherType = $type !== self::UPDATE_VOTE && $type !== self::ADD_VOTE && $type !== self::ADD_COMMENT;
if ($isVoteAndCanSendIt || $isCommentAndCanSendIt || $isOtherType) {
-
if (self::isParticipation($type)) {
$translationString = 'Poll\'s participation: %s';
} else {
@@ -48,7 +45,6 @@ class NotificationService {
$subject = '[' . NOMAPPLICATION . '] ' . __f('Mail', $translationString, $poll->title);
-
$message = '';
$urlSondage = Utils::getUrlSondage($poll->admin_id, true);
@@ -76,7 +72,6 @@ class NotificationService {
case self::DELETED_POLL:
$message = __f('Mail', 'Someone just delete your poll %s.', Utils::htmlEscape($poll->title)) . "\n\n";
break;
-
}
$messageTypeKey = $type . '-' . $poll->id;
@@ -88,5 +83,4 @@ class NotificationService {
{
return $type >= self::UPDATE_POLL;
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php
index 9abd075..43efd42 100644
--- a/app/classes/Framadate/Services/PollService.php
+++ b/app/classes/Framadate/Services/PollService.php
@@ -27,7 +27,6 @@ use Framadate\Security\Token;
use Framadate\Utils;
class PollService {
-
private $connect;
private $logService;
@@ -77,7 +76,7 @@ class PollService {
function allSlotsByPoll($poll) {
$slots = $this->slotRepository->listByPollId($poll->id);
- if ($poll->format == 'D') {
+ if ($poll->format === 'D') {
$this->sortSlorts($slots);
}
return $slots;
@@ -114,9 +113,8 @@ class PollService {
function addComment($poll_id, $name, $comment) {
if ($this->commentRepository->exists($poll_id, $name, $comment)) {
return true;
- } else {
+ }
return $this->commentRepository->insert($poll_id, $name, $comment);
- }
}
/**
@@ -131,13 +129,11 @@ class PollService {
$poll_id = $this->random(16);
} while ($this->pollRepository->existsById($poll_id));
$admin_poll_id = $poll_id . $this->random(8);
-
} else { // User have choosen the poll id
$poll_id = $form->id;
do {
$admin_poll_id = $this->random(24);
} while ($this->pollRepository->existsByAdminId($admin_poll_id));
-
}
// Insert poll + slots
@@ -148,7 +144,7 @@ class PollService {
$this->logService->log('CREATE_POLL', 'id:' . $poll_id . ', title: ' . $form->title . ', format:' . $form->format . ', admin:' . $form->admin_name . ', mail:' . $form->admin_mail);
- return array($poll_id, $admin_poll_id);
+ return [$poll_id, $admin_poll_id];
}
public function findAllByAdminMail($mail) {
@@ -164,10 +160,10 @@ class PollService {
$result['inb'][$i] = 0;
$result['y'][$i] = 0;
}
- if ($choice == 1) {
+ if ($choice === 1) {
$result['inb'][$i]++;
}
- if ($choice == 2) {
+ if ($choice === 2) {
$result['y'][$i]++;
}
}
@@ -177,7 +173,7 @@ class PollService {
}
function splitSlots($slots) {
- $splitted = array();
+ $splitted = [];
foreach ($slots as $slot) {
$obj = new \stdClass();
$obj->day = $slot->title;
@@ -200,7 +196,7 @@ class PollService {
}
function splitVotes($votes) {
- $splitted = array();
+ $splitted = [];
foreach ($votes as $vote) {
$obj = new \stdClass();
$obj->id = $vote->id;
@@ -214,10 +210,6 @@ class PollService {
return $splitted;
}
- private function random($length) {
- return Token::getToken($length);
- }
-
/**
* @return int The max timestamp allowed for expiry date
*/
@@ -233,6 +225,20 @@ class PollService {
return time() + 86400;
}
+ /**
+ * @return mixed
+ */
+ public function sortSlorts(&$slots) {
+ uasort($slots, function ($a, $b) {
+ return $a->title > $b->title;
+ });
+ return $slots;
+ }
+
+ private function random($length) {
+ return Token::getToken($length);
+ }
+
/**
* This method checks if the hash send by the user is the same as the computed hash.
*
@@ -246,15 +252,4 @@ class PollService {
throw new ConcurrentEditionException();
}
}
-
- /**
- * @return mixed
- */
- public function sortSlorts(&$slots) {
- uasort($slots, function ($a, $b) {
- return $a->title > $b->title;
- });
- return $slots;
- }
-
}
diff --git a/app/classes/Framadate/Services/PurgeService.php b/app/classes/Framadate/Services/PurgeService.php
index c901173..7b59b7a 100644
--- a/app/classes/Framadate/Services/PurgeService.php
+++ b/app/classes/Framadate/Services/PurgeService.php
@@ -9,7 +9,6 @@ use Framadate\Repositories\RepositoryFactory;
* @package Framadate\Services
*/
class PurgeService {
-
private $logService;
private $pollRepository;
private $slotRepository;
@@ -38,9 +37,9 @@ class PurgeService {
foreach ($oldPolls as $poll) {
if ($this->purgePollById($poll->id)) {
- $this->logService->log('EXPIRATION_SUCCESS', 'id: ' . $poll->id . ', title:' . $poll->title . ', format: '.$poll->format . ', admin: ' . $poll->admin_name);
+ $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->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);
}
}
}
@@ -71,6 +70,5 @@ class PurgeService {
return $done;
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/SecurityService.php b/app/classes/Framadate/Services/SecurityService.php
index a4b6f33..f641052 100644
--- a/app/classes/Framadate/Services/SecurityService.php
+++ b/app/classes/Framadate/Services/SecurityService.php
@@ -1,11 +1,10 @@
id]) ? $_SESSION['poll_security'][$poll->id] : null;
if (!empty($currentPassword) && PasswordHasher::verify($currentPassword, $poll->password_hash)) {
return true;
- } else {
+ }
unset($_SESSION['poll_security'][$poll->id]);
return false;
- }
}
/**
@@ -86,9 +84,8 @@ class SecurityService {
private function ensureSessionPollSecurityIsCreated() {
if (!isset($_SESSION['poll_security'])) {
- $_SESSION['poll_security'] = array();
+ $_SESSION['poll_security'] = [];
}
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/SessionService.php b/app/classes/Framadate/Services/SessionService.php
index 34e6461..8620951 100644
--- a/app/classes/Framadate/Services/SessionService.php
+++ b/app/classes/Framadate/Services/SessionService.php
@@ -3,9 +3,7 @@
namespace Framadate\Services;
-
class SessionService {
-
/**
* Get value of $key in $section, or $defaultValue
*
@@ -59,8 +57,7 @@ class SessionService {
private function initSectionIfNeeded($section) {
if (!isset($_SESSION[$section])) {
- $_SESSION[$section] = array();
+ $_SESSION[$section] = [];
}
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Services/SuperAdminService.php b/app/classes/Framadate/Services/SuperAdminService.php
index 51863a9..ecc3b5c 100644
--- a/app/classes/Framadate/Services/SuperAdminService.php
+++ b/app/classes/Framadate/Services/SuperAdminService.php
@@ -9,7 +9,6 @@ use Framadate\Repositories\RepositoryFactory;
* @package Framadate\Services
*/
class SuperAdminService {
-
private $pollRepository;
function __construct() {
@@ -30,9 +29,7 @@ class SuperAdminService {
$count = $this->pollRepository->count($search);
$total = $this->pollRepository->count();
-
return ['polls' => $polls, 'count' => $count, 'total' => $total];
}
-
}
\ No newline at end of file
diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php
index 038dd85..409ace3 100644
--- a/app/classes/Framadate/Utils.php
+++ b/app/classes/Framadate/Utils.php
@@ -24,7 +24,7 @@ class Utils {
*/
public static function get_server_name() {
$scheme = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) ? 'https' : 'http';
- $port = in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '' : ':' . $_SERVER['SERVER_PORT'];
+ $port = in_array($_SERVER['SERVER_PORT'], [80, 443], true) ? '' : ':' . $_SERVER['SERVER_PORT'];
$dirname = dirname($_SERVER['SCRIPT_NAME']);
$dirname = $dirname === '\\' ? '/' : $dirname . '/';
$dirname = str_replace('/admin', '', $dirname);
@@ -61,7 +61,7 @@ class Utils {
';
- if ('en' != $locale) {
+ if ('en' !== $locale) {
echo '
';
}
@@ -86,7 +86,7 @@ class Utils {
*/
public static function getUrlSondage($id, $admin = false, $vote_id = '', $action = null, $action_value = null) {
// URL-Encode $action_value
- $action_value = $action_value == null ? null : Utils::base64url_encode($action_value);
+ $action_value = $action_value === null ? null : Utils::base64url_encode($action_value);
if (URL_PROPRE) {
if ($admin === true) {
@@ -94,10 +94,10 @@ class Utils {
} else {
$url = self::get_server_name() . $id;
}
- if ($vote_id != '') {
+ if ($vote_id !== '') {
$url .= '/vote/' . $vote_id . "#edit";
- } elseif ($action != null) {
- if ($action_value != null) {
+ } elseif ($action !== null) {
+ if ($action_value !== null) {
$url .= '/action/' . $action . '/' . $action_value;
} else {
$url .= '/action/' . $action;
@@ -109,10 +109,10 @@ class Utils {
} else {
$url = self::get_server_name() . 'studs.php?poll=' . $id;
}
- if ($vote_id != '') {
+ if ($vote_id !== '') {
$url .= '&vote=' . $vote_id . "#edit";
- } elseif ($action != null) {
- if ($action_value != null) {
+ } elseif ($action !== null) {
+ if ($action_value !== null) {
$url .= '&' . $action . "=" . $action_value;
} else {
$url .= '&' . $action . "=";
@@ -142,26 +142,18 @@ class Utils {
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $md, $md_a_img); // Markdown [![alt](src)](href)
preg_match_all('/!\[(.*?)\]\((.*?)\)/', $md, $md_img); // Markdown ![alt](src)
preg_match_all('/\[(.*?)\]\((.*?)\)/', $md, $md_a); // Markdown [text](href)
- if (isset($md_a_img[2][0]) && $md_a_img[2][0] != '' && isset($md_a_img[3][0]) && $md_a_img[3][0] != '') { // [![alt](src)](href)
-
+ if (isset($md_a_img[2][0]) && $md_a_img[2][0] !== '' && isset($md_a_img[3][0]) && $md_a_img[3][0] !== '') { // [![alt](src)](href)
$text = self::htmlEscape($md_a_img[1][0]);
$html = '
';
-
- } elseif (isset($md_img[2][0]) && $md_img[2][0] != '') { // ![alt](src)
-
+ } elseif (isset($md_img[2][0]) && $md_img[2][0] !== '') { // ![alt](src)
$text = self::htmlEscape($md_img[1][0]);
$html = '
';
-
- } elseif (isset($md_a[2][0]) && $md_a[2][0] != '') { // [text](href)
-
+ } elseif (isset($md_a[2][0]) && $md_a[2][0] !== '') { // [text](href)
$text = self::htmlEscape($md_a[1][0]);
$html = '
' . $text . '';
-
} else { // text only
-
$text = self::htmlEscape($md);
$html = $text;
-
}
return $clear ? $text : $html;
@@ -200,6 +192,6 @@ class Utils {
}
public static function base64url_decode($input) {
- return base64_decode(str_pad(strtr($input, '-_', '+/'), strlen($input) % 4, '=', STR_PAD_RIGHT));
+ return base64_decode(str_pad(strtr($input, '-_', '+/'), strlen($input) % 4, '=', STR_PAD_RIGHT), true);
}
}
diff --git a/app/inc/i18n.php b/app/inc/i18n.php
index 40d3f45..c2ddd1c 100644
--- a/app/inc/i18n.php
+++ b/app/inc/i18n.php
@@ -23,7 +23,7 @@ $i18n->setDefaultLang(DEFAULT_LANGUAGE);
$i18n->setPath(__DIR__ . '/../../locale');
// Change langauge when user asked for it
-if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES))) {
+if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES), true)) {
$_SESSION['lang'] = $_POST['lang'];
}
@@ -38,7 +38,7 @@ $date_format['txt_day'] = __('Date', 'DAY');
$date_format['txt_date'] = __('Date', 'DATE');
$date_format['txt_month_year'] = __('Date', 'MONTH_YEAR');
$date_format['txt_datetime_short'] = __('Date', 'DATETIME');
-if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { //%e can't be used on Windows platform, use %#d instead
+if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { //%e can't be used on Windows platform, use %#d instead
foreach ($date_format as $k => $v) {
$date_format[$k] = preg_replace('#(?assign('date_format', $date_format);
if (isset($_SERVER['FRAMADATE_DEVMODE']) && $_SERVER['FRAMADATE_DEVMODE']) {
$smarty->force_compile = true;
$smarty->compile_check = true;
-
} else {
$smarty->force_compile = false;
$smarty->compile_check = false;
}
-
function smarty_function_poll_url($params, Smarty_Internal_Template $template) {
$poll_id = filter_var($params['id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
$admin = (isset($params['admin']) && $params['admin']) ? true : false;
diff --git a/app/tests/Framadate/FramaTestCase.php b/app/tests/Framadate/FramaTestCase.php
index b2f6e14..eba5b69 100644
--- a/app/tests/Framadate/FramaTestCase.php
+++ b/app/tests/Framadate/FramaTestCase.php
@@ -2,9 +2,8 @@
namespace Framadate;
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
-
protected function getTestResourcePath($resourcepath) {
- return __DIR__ . '/../resources/'.$resourcepath;
+ return __DIR__ . '/../resources/' . $resourcepath;
}
protected function readTestResource($resourcepath) {
@@ -19,5 +18,4 @@ abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
$params = array_slice(func_get_args(), 2); // get all the parameters after $methodName
return $reflectionMethod->invokeArgs($object, $params);
}
-
}
diff --git a/app/tests/Framadate/Services/MailServiceUnitTest.php b/app/tests/Framadate/Services/MailServiceUnitTest.php
index b4045f2..0ffdb39 100644
--- a/app/tests/Framadate/Services/MailServiceUnitTest.php
+++ b/app/tests/Framadate/Services/MailServiceUnitTest.php
@@ -18,7 +18,7 @@ class MailServiceUnitTest extends FramaTestCase {
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
// Then
- $this->assertEquals(true, $canSendMsg);
+ $this->assertSame(true, $canSendMsg);
}
/**
@@ -33,7 +33,6 @@ class MailServiceUnitTest extends FramaTestCase {
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
// Then
- $this->assertEquals(false, $canSendMsg);
+ $this->assertSame(false, $canSendMsg);
}
-
}
diff --git a/app/tests/bootstrap.php b/app/tests/bootstrap.php
index 9d4b65e..a5685d4 100644
--- a/app/tests/bootstrap.php
+++ b/app/tests/bootstrap.php
@@ -1,3 +1,3 @@
addPsr4('Framadate\\', __DIR__.'/Framadate');
+$loader->addPsr4('Framadate\\', __DIR__ . '/Framadate');
diff --git a/bandeaux.php b/bandeaux.php
index b8ae74c..2d90953 100644
--- a/bandeaux.php
+++ b/bandeaux.php
@@ -24,22 +24,22 @@ include_once __DIR__ . '/app/inc/init.php';
function bandeau_titre($titre)
{
global $ALLOWED_LANGUAGES;
- $img = ( IMAGE_TITRE ) ? '
' : '';
+ $img = ( IMAGE_TITRE ) ? '
' : '';
echo '
';
@@ -47,12 +47,11 @@ function bandeau_titre($titre)
global $connect;
$tables = $connect->allTables();
$diff = array_diff([Utils::table('comment'), Utils::table('poll'), Utils::table('slot'), Utils::table('vote')], $tables);
- if (0 != count($diff)) {
- echo ''. __('Error', 'Framadate is not properly installed, please check the "INSTALL" to setup the database before continuing.') .'
';
+ if (0 !== count($diff)) {
+ echo '' . __('Error', 'Framadate is not properly installed, please check the "INSTALL" to setup the database before continuing.') . '
';
bandeau_pied();
die();
}
-
}
function liste_lang()
@@ -62,10 +61,10 @@ function liste_lang()
$str = '';
foreach ($ALLOWED_LANGUAGES as $k => $v ) {
- if (substr($k,0,2)==$locale) {
- $str .= '' . "\n" ;
+ if (substr($k,0,2)===$locale) {
+ $str .= '' . "\n" ;
} else {
- $str .= '' . "\n" ;
+ $str .= '' . "\n" ;
}
}
@@ -78,5 +77,5 @@ function bandeau_pied()