Merge branch 'php-cs-fixer' into 'master'
Run php-cs-fixer with a custom config. This may break a lot of things See merge request framasoft/framadate!209
This commit is contained in:
commit
1e8d3a1bf0
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ app/inc/config.php
|
||||
vendor
|
||||
cache/
|
||||
tpl_c/
|
||||
.php_cs.cache
|
||||
|
||||
# Temp files
|
||||
*~
|
||||
|
@ -11,7 +11,9 @@ pages:
|
||||
script:
|
||||
- latesttag=$(git describe --tags)
|
||||
- git checkout ${latesttag}
|
||||
- php composer.phar install
|
||||
- php composer.phar install -o --no-interaction --no-progress --prefer-dist
|
||||
- php vendor/bin/php-cs-fixer fix --verbose --dry-run
|
||||
- vendor/bin/phpunit --bootstrap app/tests/bootstrap.php --debug app/tests
|
||||
- mkdir tpl_c
|
||||
- zip -r latest.zip .
|
||||
- mkdir .public
|
||||
|
45
.php_cs
Normal file
45
.php_cs
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short'
|
||||
],
|
||||
'combine_consecutive_unsets' => true,
|
||||
'heredoc_to_nowdoc' => true,
|
||||
'no_extra_consecutive_blank_lines' => [
|
||||
'break',
|
||||
'continue',
|
||||
'extra',
|
||||
'return',
|
||||
'throw',
|
||||
'use',
|
||||
'parenthesis_brace_block',
|
||||
'square_brace_block',
|
||||
'curly_brace_block'
|
||||
],
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'ordered_class_elements' => true,
|
||||
'ordered_imports' => true,
|
||||
'php_unit_strict' => true,
|
||||
'phpdoc_order' => true,
|
||||
// 'psr4' => true,
|
||||
'strict_comparison' => true,
|
||||
'strict_param' => true,
|
||||
'concat_space' => [
|
||||
'spacing' => 'one'
|
||||
],
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->exclude([
|
||||
'vendor',
|
||||
'var',
|
||||
'web'
|
||||
])
|
||||
->in(__DIR__)
|
||||
)
|
||||
;
|
@ -16,13 +16,13 @@
|
||||
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Message;
|
||||
use Framadate\Services\InputService;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\MailService;
|
||||
use Framadate\Services\NotificationService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\SecurityService;
|
||||
use Framadate\Message;
|
||||
|
||||
include_once __DIR__ . '/../app/inc/init.php';
|
||||
|
||||
@ -33,7 +33,7 @@ $poll_id = null;
|
||||
$poll = null;
|
||||
$message = null;
|
||||
$result = false;
|
||||
$comments = array();
|
||||
$comments = [];
|
||||
$is_admin = false;
|
||||
|
||||
/* Services */
|
||||
@ -57,7 +57,7 @@ if (!empty($_POST['poll'])) {
|
||||
if (!empty($_POST['poll_admin'])) {
|
||||
$admin_poll_id = filter_input(INPUT_POST, 'poll_admin', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||
if (strlen($admin_poll_id) === 24) {
|
||||
$is_admin = ($pollService->findByAdminId($admin_poll_id) != null);
|
||||
$is_admin = ($pollService->findByAdminId($admin_poll_id) !== null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,11 +69,11 @@ if (!$poll) {
|
||||
$name = $inputService->filterName($_POST['name']);
|
||||
$comment = $inputService->filterComment($_POST['comment']);
|
||||
|
||||
if ($name == null) {
|
||||
if ($name === null) {
|
||||
$message = new Message('danger', __('Error', 'The name is invalid.'));
|
||||
}
|
||||
|
||||
if ($message == null) {
|
||||
if ($message === null) {
|
||||
// Add comment
|
||||
$result = $pollService->addComment($poll_id, $name, $comment);
|
||||
if ($result) {
|
||||
@ -90,6 +90,6 @@ $smarty->error_reporting = E_ALL & ~E_NOTICE;
|
||||
$smarty->assign('comments', $comments);
|
||||
$comments_html = $smarty->fetch('part/comments_list.tpl');
|
||||
|
||||
$response = array('result' => $result, 'message' => $message, 'comments' => $comments_html);
|
||||
$response = ['result' => $result, 'message' => $message, 'comments' => $comments_html];
|
||||
|
||||
echo json_encode($response);
|
||||
|
@ -17,11 +17,11 @@
|
||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
|
||||
use Framadate\Services\SessionService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\MailService;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Message;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\MailService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\SessionService;
|
||||
use Framadate\Utils;
|
||||
|
||||
include_once __DIR__ . '/../app/inc/init.php';
|
||||
@ -45,7 +45,7 @@ if (!empty($_POST['poll'])) {
|
||||
$token = $sessionService->get("Common", SESSION_EDIT_LINK_TOKEN);
|
||||
$token_form_value = empty($_POST['token']) ? null : $_POST['token'];
|
||||
$editedVoteUniqueId = filter_input(INPUT_POST, 'editedVoteUniqueId', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||
if (is_null($poll) || $config['use_smtp'] == false || is_null($token) || is_null($token_form_value)
|
||||
if (is_null($poll) || $config['use_smtp'] === false || is_null($token) || is_null($token_form_value)
|
||||
|| !$token->check($token_form_value) || is_null($editedVoteUniqueId)) {
|
||||
$message = new Message('error', __('Error', 'Something is going wrong...'));
|
||||
}
|
||||
@ -69,7 +69,6 @@ if (is_null($message)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_null($message)) {
|
||||
$url = Utils::getUrlSondage($poll_id, false, $editedVoteUniqueId);
|
||||
|
||||
@ -90,7 +89,6 @@ if (is_null($message)) {
|
||||
|
||||
$smarty->error_reporting = E_ALL & ~E_NOTICE;
|
||||
|
||||
$response = array('result' => $result, 'message' => $message);
|
||||
|
||||
$response = ['result' => $result, 'message' => $message];
|
||||
|
||||
echo json_encode($response);
|
@ -35,7 +35,7 @@ if (!file_exists(ROOT_DIR . 'vendor/autoload.php') || !file_exists(ROOT_DIR . 'v
|
||||
require_once ROOT_DIR . 'vendor/autoload.php';
|
||||
require_once ROOT_DIR . 'vendor/o80/i18n/src/shortcuts.php';
|
||||
require_once ROOT_DIR . 'app/inc/constants.php';
|
||||
if (session_id() == '') {
|
||||
if (session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
$ALLOWED_LANGUAGES = [
|
||||
@ -59,26 +59,25 @@ require_once ROOT_DIR . 'app/inc/i18n.php';
|
||||
*/
|
||||
function compareCheckMessage(Message $a, Message $b)
|
||||
{
|
||||
$values = array(
|
||||
$values = [
|
||||
'danger' => 0,
|
||||
'warning' => 1,
|
||||
'info' => 2,
|
||||
'success' => 3
|
||||
);
|
||||
];
|
||||
$vA = $values[$a->type];
|
||||
$vB = $values[$b->type];
|
||||
|
||||
if ($vA == $vB) {
|
||||
if ($vA === $vB) {
|
||||
return 0;
|
||||
}
|
||||
return ($vA < $vB) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Vars
|
||||
*/
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
$inc_directory = ROOT_DIR . 'app/inc/';
|
||||
$conf_filename = $inc_directory . 'config.php';
|
||||
|
||||
@ -133,14 +132,13 @@ if (!empty($timezone)) {
|
||||
$messages[] = new Message('warning', __('Check','Consider setting the date.timezone in php.ini.'));
|
||||
}
|
||||
|
||||
|
||||
// The percentage of steps needed to be ready to launch the application
|
||||
$errors = 0;
|
||||
$warnings = 0;
|
||||
foreach ($messages as $message) {
|
||||
if ($message->type == 'danger') {
|
||||
if ($message->type === 'danger') {
|
||||
$errors++;
|
||||
} else if ($message->type == 'warning') {
|
||||
} else if ($message->type === 'warning') {
|
||||
$warnings++;
|
||||
}
|
||||
}
|
||||
@ -175,7 +173,7 @@ usort($messages, 'compareCheckMessage');
|
||||
<div class="input-group input-group-sm pull-right col-xs-12 col-sm-2">
|
||||
<select name="lang" class="form-control" title="<?=__('Language selector', 'Select the language')?>" >
|
||||
<?php foreach ($ALLOWED_LANGUAGES as $lang_key => $language) { ?>
|
||||
<option lang="fr" <?php if (substr($lang_key, 0, 2)==$locale) { echo 'selected';} ?> value="<?=substr($lang_key, 0, 2)?>"><?=$language?></option>
|
||||
<option lang="fr" <?php if (substr($lang_key, 0, 2)===$locale) { echo 'selected';} ?> value="<?=substr($lang_key, 0, 2)?>"><?=$language?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
@ -209,7 +207,7 @@ usort($messages, 'compareCheckMessage');
|
||||
<a class="btn btn-info" role="button" href=""><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> <?= __('Check', 'Check again') ?></a>
|
||||
<?php
|
||||
if (!is_file($conf_filename)) {
|
||||
if ($errors == 0) {
|
||||
if ($errors === 0) {
|
||||
?>
|
||||
<a class="btn btn-primary" role="button" href="<?= Utils::get_server_name() . 'admin/install.php' ?>"><span class=" glyphicon glyphicon-arrow-right" aria-hidden="true"></span> <?= __('Check', 'Continue the installation') ?></a>
|
||||
<?php
|
||||
|
@ -37,9 +37,8 @@ if (!empty($_POST)) {
|
||||
if ($result['status'] === 'OK') {
|
||||
header(('Location: ' . Utils::get_server_name() . 'admin/migration.php'));
|
||||
exit;
|
||||
} else {
|
||||
$error = __('Error', $result['code']);
|
||||
}
|
||||
$error = __('Error', $result['code']);
|
||||
}
|
||||
|
||||
$smarty->assign('error', $error);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
namespace Framadate;
|
||||
|
||||
|
||||
/**
|
||||
* Class Editable
|
||||
*
|
||||
|
@ -2,8 +2,6 @@
|
||||
namespace Framadate\Exception;
|
||||
|
||||
class AlreadyExistsException extends \Exception {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
namespace Framadate\Exception;
|
||||
|
||||
class ConcurrentEditionException extends \Exception {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
namespace Framadate\Exception;
|
||||
|
||||
class MomentAlreadyExistsException extends \Exception {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
namespace Framadate;
|
||||
|
||||
class Message {
|
||||
|
||||
var $type;
|
||||
var $message;
|
||||
var $link;
|
||||
@ -35,6 +34,5 @@ class Message {
|
||||
$this->linkIcon = $linkIcon;
|
||||
$this->includeTemplate = $includeTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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"');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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`');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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`) ;');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 ;');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 ;');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
||||
* @version 0.8
|
||||
*/
|
||||
class From_0_0_to_0_8_Migration implements Migration {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
|
@ -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] : '-');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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') . '`
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace Framadate\Migration;
|
||||
use Framadate\Utils;
|
||||
|
||||
class Increase_pollId_size implements Migration {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ namespace Framadate\Security;
|
||||
* @package Framadate\Security
|
||||
*/
|
||||
class PasswordHasher {
|
||||
|
||||
/**
|
||||
* Hash a password
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
$result->insert += count($moments);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ use Framadate\Repositories\RepositoryFactory;
|
||||
* @package Framadate\Services
|
||||
*/
|
||||
class PurgeService {
|
||||
|
||||
private $logService;
|
||||
private $pollRepository;
|
||||
private $slotRepository;
|
||||
@ -71,6 +70,5 @@ class PurgeService {
|
||||
|
||||
return $done;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
namespace Framadate\Services;
|
||||
|
||||
use Framadate\Security\Token;
|
||||
use Framadate\Security\PasswordHasher;
|
||||
use Framadate\Security\Token;
|
||||
|
||||
class SecurityService {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
@ -65,11 +64,10 @@ class SecurityService {
|
||||
$currentPassword = isset($_SESSION['poll_security'][$poll->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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit to the session a poll password
|
||||
@ -86,9 +84,8 @@ class SecurityService {
|
||||
|
||||
private function ensureSessionPollSecurityIsCreated() {
|
||||
if (!isset($_SESSION['poll_security'])) {
|
||||
$_SESSION['poll_security'] = array();
|
||||
$_SESSION['poll_security'] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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] = [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 {
|
||||
<script type="text/javascript" src="' . self::get_server_name() . 'js/jquery-1.11.1.min.js"></script>
|
||||
<script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap-datepicker.js"></script>';
|
||||
if ('en' != $locale) {
|
||||
if ('en' !== $locale) {
|
||||
echo '
|
||||
<script type="text/javascript" src="' . self::get_server_name() . 'js/locales/bootstrap-datepicker.' . $locale . '.js"></script>';
|
||||
}
|
||||
@ -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 = '<a href="' . self::htmlEscape($md_a_img[3][0]) . '"><img src="' . self::htmlEscape($md_a_img[2][0]) . '" class="img-responsive" alt="' . $text . '" title="' . $text . '" /></a>';
|
||||
|
||||
} 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 = '<img src="' . self::htmlEscape($md_img[2][0]) . '" class="img-responsive" alt="' . $text . '" title="' . $text . '" />';
|
||||
|
||||
} 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 = '<a href="' . $md_a[2][0] . '">' . $text . '</a>';
|
||||
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
@ -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('#(?<!%)((?:%%)*)%e#', '\1%#d', $v); //replace %e by %#d for windows
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ use Framadate\Repositories\RepositoryFactory;
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../../vendor/o80/i18n/src/shortcuts.php';
|
||||
|
||||
if (session_id() == '') {
|
||||
if (session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
|
||||
if (ini_get('date.timezone') == '') {
|
||||
if (ini_get('date.timezone') === '') {
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,11 @@ $smarty->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;
|
||||
|
@ -2,7 +2,6 @@
|
||||
namespace Framadate;
|
||||
|
||||
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
protected function getTestResourcePath($resourcepath) {
|
||||
return __DIR__ . '/../resources/' . $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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)) {
|
||||
if (0 !== count($diff)) {
|
||||
echo '<div class="alert alert-danger">' . __('Error', 'Framadate is not properly installed, please check the "INSTALL" to setup the database before continuing.') . '</div>';
|
||||
bandeau_pied();
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function liste_lang()
|
||||
@ -62,7 +61,7 @@ function liste_lang()
|
||||
$str = '';
|
||||
|
||||
foreach ($ALLOWED_LANGUAGES as $k => $v ) {
|
||||
if (substr($k,0,2)==$locale) {
|
||||
if (substr($k,0,2)===$locale) {
|
||||
$str .= '<option lang="' . substr($k,0,2) . '" selected value="' . $k . '">' . $v . '</option>' . "\n" ;
|
||||
} else {
|
||||
$str .= '<option lang="' . substr($k,0,2) . '" value="' . $k . '">' . $v . '</option>' . "\n" ;
|
||||
|
@ -28,15 +28,14 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$diffSection and array_keys($good)!=array_keys($test)) {
|
||||
if (!$diffSection and array_keys($good)!==array_keys($test)) {
|
||||
var_dump(array_keys($good));
|
||||
var_dump(array_keys($test));
|
||||
} else {
|
||||
echo 'All sections are in two langs.' . "\n";
|
||||
}
|
||||
|
||||
|
||||
$diff = array();
|
||||
$diff = [];
|
||||
|
||||
foreach ($good as $sectionName => $section) {
|
||||
$diffSection = false;
|
||||
@ -47,7 +46,7 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$diffSection and array_keys($good[$sectionName]) != array_keys($test[$sectionName])) {
|
||||
if (!$diffSection and array_keys($good[$sectionName]) !== array_keys($test[$sectionName])) {
|
||||
$diff[$sectionName]['order_good'] = array_keys($good[$sectionName]);
|
||||
$diff[$sectionName]['order_test'] = array_keys($test[$sectionName]);
|
||||
}
|
||||
|
@ -64,7 +64,8 @@
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7"
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"friendsofphp/php-cs-fixer": "~2.0"
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
|
1077
composer.lock
generated
1077
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -16,12 +16,12 @@
|
||||
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
use Framadate\Choice;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\MailService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\PurgeService;
|
||||
use Framadate\Utils;
|
||||
use Framadate\Choice;
|
||||
|
||||
include_once __DIR__ . '/app/inc/init.php';
|
||||
|
||||
@ -40,13 +40,11 @@ if (is_file('bandeaux_local.php')) {
|
||||
|
||||
// Step 1/4 : error if $_SESSION from info_sondage are not valid
|
||||
if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (($config['use_smtp']) ? empty($_SESSION['form']->admin_mail) : false)) {
|
||||
|
||||
$smarty->assign('title', __('Error', 'Error!'));
|
||||
$smarty->assign('error', __('Error', 'You haven\'t filled the first section of the poll creation.'));
|
||||
$smarty->display('error.tpl');
|
||||
exit;
|
||||
|
||||
} else {
|
||||
}
|
||||
// Min/Max archive date
|
||||
$min_expiry_time = $pollService->minExpiryDate();
|
||||
$max_expiry_time = $pollService->maxExpiryDate();
|
||||
@ -59,14 +57,13 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
|
||||
// Step 4 : Data prepare before insert in DB
|
||||
if (isset($_POST['confirmation'])) {
|
||||
|
||||
// Define expiration date
|
||||
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
||||
|
||||
if (!empty($enddate)) {
|
||||
$registredate = explode('/', $enddate);
|
||||
|
||||
if (is_array($registredate) && count($registredate) == 3) {
|
||||
if (is_array($registredate) && count($registredate) === 3) {
|
||||
$time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
|
||||
|
||||
if ($time < $min_expiry_time) {
|
||||
@ -89,7 +86,6 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
$poll_id = $ids[0];
|
||||
$admin_poll_id = $ids[1];
|
||||
|
||||
|
||||
// Send confirmation by mail if enabled
|
||||
if ($config['use_smtp'] === true) {
|
||||
$message = __('Mail', "This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.");
|
||||
@ -115,10 +111,8 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
// Redirect to poll administration
|
||||
header('Location:' . Utils::getUrlSondage($admin_poll_id, true));
|
||||
exit;
|
||||
|
||||
} // Step 3/4 : Confirm poll creation and choose a removal date
|
||||
else if (isset($_POST['fin_sondage_autre'])) {
|
||||
|
||||
// Store choices in $_SESSION
|
||||
if (isset($_POST['choices'])) {
|
||||
$_SESSION['form']->clearChoices();
|
||||
@ -137,30 +131,21 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
// Summary
|
||||
$summary = '<ol>';
|
||||
foreach ($_SESSION['form']->getChoices() as $i=>$choice) {
|
||||
|
||||
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $choice->getName(), $md_a_img); // Markdown [![alt](src)](href)
|
||||
preg_match_all('/!\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_img); // Markdown ![alt](src)
|
||||
preg_match_all('/\[(.*?)\]\((.*?)\)/', $choice->getName(), $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)
|
||||
|
||||
$li_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0] != '') ? stripslashes($md_a_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1);
|
||||
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)
|
||||
$li_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0] !== '') ? stripslashes($md_a_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1);
|
||||
$li_subject_html = '<a href="' . $md_a_img[3][0] . '"><img src="' . $md_a_img[2][0] . '" class="img-responsive" alt="' . $li_subject_text . '" /></a>';
|
||||
|
||||
} elseif (isset($md_img[2][0]) && $md_img[2][0] != '') { // ![alt](src)
|
||||
|
||||
$li_subject_text = (isset($md_img[1][0]) && $md_img[1][0] != '') ? stripslashes($md_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1);
|
||||
} elseif (isset($md_img[2][0]) && $md_img[2][0] !== '') { // ![alt](src)
|
||||
$li_subject_text = (isset($md_img[1][0]) && $md_img[1][0] !== '') ? stripslashes($md_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1);
|
||||
$li_subject_html = '<img src="' . $md_img[2][0] . '" class="img-responsive" alt="' . $li_subject_text . '" />';
|
||||
|
||||
} elseif (isset($md_a[2][0]) && $md_a[2][0] != '') { // [text](href)
|
||||
|
||||
$li_subject_text = (isset($md_a[1][0]) && $md_a[1][0] != '') ? stripslashes($md_a[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1);
|
||||
} elseif (isset($md_a[2][0]) && $md_a[2][0] !== '') { // [text](href)
|
||||
$li_subject_text = (isset($md_a[1][0]) && $md_a[1][0] !== '') ? stripslashes($md_a[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1);
|
||||
$li_subject_html = '<a href="' . $md_a[2][0] . '">' . $li_subject_text . '</a>';
|
||||
|
||||
} else { // text only
|
||||
|
||||
$li_subject_text = stripslashes($choice->getName());
|
||||
$li_subject_html = $li_subject_text;
|
||||
|
||||
}
|
||||
|
||||
$summary .= '<li>' . $li_subject_html . '</li>' . "\n";
|
||||
@ -262,6 +247,5 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
' . "\n";
|
||||
|
||||
bandeau_pied();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,6 @@ switch ($step) {
|
||||
$smarty->display('error.tpl');
|
||||
exit;
|
||||
|
||||
|
||||
case 2:
|
||||
// Step 2/4 : Select dates of the poll
|
||||
|
||||
@ -95,7 +94,6 @@ switch ($step) {
|
||||
$smarty->display('create_date_poll_step_2.tpl');
|
||||
exit;
|
||||
|
||||
|
||||
case 3:
|
||||
// Step 3/4 : Confirm poll creation
|
||||
|
||||
@ -121,7 +119,7 @@ switch ($step) {
|
||||
$_SESSION['form']->clearChoices();
|
||||
|
||||
// Reorder moments to deal with suppressed dates
|
||||
$moments = array();
|
||||
$moments = [];
|
||||
$i = 0;
|
||||
while(count($moments) < count($_POST['days'])) {
|
||||
if (!empty($_POST['horaires' . $i])) {
|
||||
@ -130,7 +128,6 @@ switch ($step) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
for ($i = 0; $i < count($_POST['days']); $i++) {
|
||||
$day = $_POST['days'][$i];
|
||||
|
||||
@ -178,18 +175,16 @@ switch ($step) {
|
||||
$smarty->display('create_classic_poll_step3.tpl');
|
||||
exit;
|
||||
|
||||
|
||||
case 4:
|
||||
// Step 4 : Data prepare before insert in DB
|
||||
|
||||
// Define expiration date
|
||||
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
||||
|
||||
|
||||
if (!empty($enddate)) {
|
||||
$registredate = explode('/', $enddate);
|
||||
|
||||
if (is_array($registredate) && count($registredate) == 3) {
|
||||
if (is_array($registredate) && count($registredate) === 3) {
|
||||
$time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
|
||||
|
||||
if ($time < $min_expiry_time) {
|
||||
@ -212,7 +207,6 @@ switch ($step) {
|
||||
$poll_id = $ids[0];
|
||||
$admin_poll_id = $ids[1];
|
||||
|
||||
|
||||
// Send confirmation by mail if enabled
|
||||
if ($config['use_smtp'] === true) {
|
||||
$message = __('Mail', "This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.");
|
||||
|
@ -27,7 +27,6 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
|
||||
const GO_TO_STEP_2 = 'gotostep2';
|
||||
|
||||
|
||||
/* Services */
|
||||
/*----------*/
|
||||
|
||||
@ -42,8 +41,8 @@ if (!isset($_SESSION['form'])) {
|
||||
}
|
||||
|
||||
// Type de sondage
|
||||
if (isset($_GET['type']) && $_GET['type'] == 'date' ||
|
||||
isset($_POST['type']) && $_POST['type'] == 'date'
|
||||
if (isset($_GET['type']) && $_GET['type'] === 'date' ||
|
||||
isset($_POST['type']) && $_POST['type'] === 'date'
|
||||
) {
|
||||
$poll_type = 'date';
|
||||
$_SESSION['form']->choix_sondage = $poll_type;
|
||||
@ -57,9 +56,9 @@ $goToStep2 = filter_input(INPUT_POST, GO_TO_STEP_2, FILTER_VALIDATE_REGEXP, ['op
|
||||
if ($goToStep2) {
|
||||
$title = $inputService->filterTitle($_POST['title']);
|
||||
$use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false;
|
||||
$customized_url = $use_customized_url == true ? $inputService->filterId($_POST['customized_url']) : null;
|
||||
$customized_url = $use_customized_url === true ? $inputService->filterId($_POST['customized_url']) : null;
|
||||
$name = $inputService->filterName($_POST['name']);
|
||||
$mail = $config['use_smtp'] == true ? $inputService->filterMail($_POST['mail']) : null;
|
||||
$mail = $config['use_smtp'] === true ? $inputService->filterMail($_POST['mail']) : null;
|
||||
$description = $inputService->filterDescription($_POST['description']);
|
||||
$editable = $inputService->filterEditable($_POST['editable']);
|
||||
$receiveNewVotes = isset($_POST['receiveNewVotes']) ? $inputService->filterBoolean($_POST['receiveNewVotes']) : false;
|
||||
@ -92,8 +91,7 @@ if ($goToStep2) {
|
||||
$_SESSION['form']->use_password = ($use_password !== null);
|
||||
$_SESSION['form']->results_publicly_visible = ($results_publicly_visible !== null);
|
||||
|
||||
|
||||
if ($config['use_smtp'] == true) {
|
||||
if ($config['use_smtp'] === true) {
|
||||
if (empty($mail)) {
|
||||
$error_on_mail = true;
|
||||
}
|
||||
@ -121,7 +119,7 @@ if ($goToStep2) {
|
||||
}
|
||||
|
||||
// Si pas d'erreur dans l'adresse alors on change de page vers date ou autre
|
||||
if ($config['use_smtp'] == true) {
|
||||
if ($config['use_smtp'] === true) {
|
||||
$email_OK = $mail && !$error_on_mail;
|
||||
} else {
|
||||
$email_OK = true;
|
||||
@ -130,7 +128,7 @@ if ($goToStep2) {
|
||||
if ($use_password) {
|
||||
if (empty($password)) {
|
||||
$error_on_password = true;
|
||||
} else if ($password != $password_repeat) {
|
||||
} else if ($password !== $password_repeat) {
|
||||
$error_on_password_repeat = true;
|
||||
}
|
||||
}
|
||||
@ -138,7 +136,6 @@ if ($goToStep2) {
|
||||
if ($title && $name && $email_OK && !$error_on_title && !$error_on_customized_url && !$error_on_description && !$error_on_name
|
||||
&& !$error_on_password && !$error_on_password_repeat
|
||||
) {
|
||||
|
||||
// If no errors, we hash the password if needed
|
||||
if ($_SESSION['form']->use_password) {
|
||||
$_SESSION['form']->password_hash = PasswordHasher::hash($password);
|
||||
@ -147,16 +144,15 @@ if ($goToStep2) {
|
||||
$_SESSION['form']->results_publicly_visible = null;
|
||||
}
|
||||
|
||||
if ($goToStep2 == 'date') {
|
||||
if ($goToStep2 === 'date') {
|
||||
header('Location:create_date_poll.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($goToStep2 == 'classic') {
|
||||
if ($goToStep2 === 'classic') {
|
||||
header('Location:create_classic_poll.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
// Title Erreur !
|
||||
$title = __('Error', 'Error!') . ' - ' . __('Step 1', 'Poll creation (1 on 3)');
|
||||
@ -167,43 +163,43 @@ if ($goToStep2) {
|
||||
}
|
||||
|
||||
// Prepare error messages
|
||||
$errors = array(
|
||||
'title' => array(
|
||||
$errors = [
|
||||
'title' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
),
|
||||
'customized_url' => array(
|
||||
],
|
||||
'customized_url' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
),
|
||||
'description' => array(
|
||||
],
|
||||
'description' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
),
|
||||
'name' => array(
|
||||
],
|
||||
'name' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
),
|
||||
'email' => array(
|
||||
],
|
||||
'email' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
),
|
||||
'password' => array(
|
||||
],
|
||||
'password' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
),
|
||||
'password_repeat' => array(
|
||||
],
|
||||
'password_repeat' => [
|
||||
'msg' => '',
|
||||
'aria' => '',
|
||||
'class' => ''
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
|
||||
if (!empty($_POST[GO_TO_STEP_2])) {
|
||||
if (empty($_POST['title'])) {
|
||||
|
@ -53,7 +53,6 @@ if (!empty($_POST['mail'])) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign('title', __('Homepage', 'Where are my polls'));
|
||||
$smarty->assign('message', $message);
|
||||
|
||||
|
@ -34,7 +34,7 @@ function rcopy($src, $dst) {
|
||||
@mkdir($dst);
|
||||
$copied = true;
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
if (($file !== '.') && ($file !== '..')) {
|
||||
if (is_dir($src . '/' . $file)) {
|
||||
$copied &= rcopy($src . '/' . $file, $dst . '/' . $file);
|
||||
} else {
|
||||
@ -47,7 +47,7 @@ function rcopy($src, $dst) {
|
||||
}
|
||||
|
||||
function rrmdir($dir) {
|
||||
$files = array_diff(scandir($dir), array('.', '..'));
|
||||
$files = array_diff(scandir($dir), ['.', '..']);
|
||||
foreach ($files as $file) {
|
||||
(is_dir("$dir/$file")) ? rrmdir("$dir/$file") : unlink("$dir/$file");
|
||||
}
|
||||
@ -83,7 +83,7 @@ function zip($source, $destination) {
|
||||
if (is_dir($source)) {
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($files as $file) {
|
||||
if (in_array(basename($file), array('.', '..'))) {
|
||||
if (in_array(basename($file), ['.', '..'], true)) {
|
||||
continue;
|
||||
}
|
||||
$file = realpath($file);
|
||||
@ -155,15 +155,15 @@ i($result->autoload, 'autoload');
|
||||
// Copy assets
|
||||
|
||||
d('# Assets');
|
||||
copyFiles(array('css', 'fonts', 'images', 'js'), $result);
|
||||
copyFiles(['css', 'fonts', 'images', 'js'], $result);
|
||||
|
||||
// Copy sources
|
||||
|
||||
d('# Source directories');
|
||||
copyFiles(array('admin', 'app', 'locale', 'tpl'), $result);
|
||||
copyFiles(['admin', 'app', 'locale', 'tpl'], $result);
|
||||
|
||||
d('# Source files');
|
||||
$files = array(
|
||||
$files = [
|
||||
'adminstuds.php',
|
||||
'bandeaux.php',
|
||||
'create_classic_poll.php',
|
||||
@ -181,7 +181,7 @@ $files = array(
|
||||
'README.md',
|
||||
'robots.txt',
|
||||
'studs.php'
|
||||
);
|
||||
];
|
||||
copyFiles($files, $result);
|
||||
|
||||
// Zip Dist
|
||||
|
34
studs.php
34
studs.php
@ -16,19 +16,19 @@
|
||||
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
use Framadate\Editable;
|
||||
use Framadate\Exception\AlreadyExistsException;
|
||||
use Framadate\Exception\ConcurrentEditionException;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Message;
|
||||
use Framadate\Security\Token;
|
||||
use Framadate\Services\InputService;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\MailService;
|
||||
use Framadate\Services\NotificationService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\SecurityService;
|
||||
use Framadate\Services\SessionService;
|
||||
use Framadate\Message;
|
||||
use Framadate\Utils;
|
||||
use Framadate\Editable;
|
||||
use Framadate\Security\Token;
|
||||
|
||||
include_once __DIR__ . '/app/inc/init.php';
|
||||
|
||||
@ -37,7 +37,6 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
|
||||
const USER_REMEMBER_VOTES_KEY = 'UserVotes';
|
||||
|
||||
|
||||
/* Variables */
|
||||
/* --------- */
|
||||
|
||||
@ -47,9 +46,9 @@ $message = null;
|
||||
$editingVoteId = 0;
|
||||
$accessGranted = true;
|
||||
$resultPubliclyVisible = true;
|
||||
$slots = array();
|
||||
$votes = array();
|
||||
$comments = array();
|
||||
$slots = [];
|
||||
$votes = [];
|
||||
$comments = [];
|
||||
|
||||
/* Services */
|
||||
/*----------*/
|
||||
@ -62,7 +61,6 @@ $notificationService = new NotificationService($mailService);
|
||||
$securityService = new SecurityService();
|
||||
$sessionService = new SessionService();
|
||||
|
||||
|
||||
/* PAGE */
|
||||
/* ---- */
|
||||
|
||||
@ -84,7 +82,6 @@ $editedVoteUniqueId = $sessionService->get(USER_REMEMBER_VOTES_KEY, $poll_id, ''
|
||||
// -------------------------------
|
||||
|
||||
if (!is_null($poll->password_hash)) {
|
||||
|
||||
// If we came from password submission
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
||||
if (!empty($password)) {
|
||||
@ -107,7 +104,6 @@ if (!is_null($poll->password_hash)) {
|
||||
|
||||
// We allow actions only if access is granted
|
||||
if ($accessGranted) {
|
||||
|
||||
// -------------------------------
|
||||
// A vote is going to be edited
|
||||
// -------------------------------
|
||||
@ -129,16 +125,16 @@ if ($accessGranted) {
|
||||
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);
|
||||
if ($result) {
|
||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
||||
if ($poll->editable === Editable::EDITABLE_BY_OWN) {
|
||||
$editedVoteUniqueId = filter_input(INPUT_POST, 'edited_vote', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||
$message = getMessageForOwnVoteEditableVote($sessionService, $smarty, $editedVoteUniqueId, $config['use_smtp'], $poll_id, $name);
|
||||
} else {
|
||||
@ -157,19 +153,19 @@ if ($accessGranted) {
|
||||
$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);
|
||||
if ($result) {
|
||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
||||
if ($poll->editable === Editable::EDITABLE_BY_OWN) {
|
||||
$editedVoteUniqueId = $result->uniqId;
|
||||
$message = getMessageForOwnVoteEditableVote($sessionService, $smarty, $editedVoteUniqueId, $config['use_smtp'], $poll_id, $name);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user