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
|
vendor
|
||||||
cache/
|
cache/
|
||||||
tpl_c/
|
tpl_c/
|
||||||
|
.php_cs.cache
|
||||||
|
|
||||||
# Temp files
|
# Temp files
|
||||||
*~
|
*~
|
||||||
|
@ -11,7 +11,9 @@ pages:
|
|||||||
script:
|
script:
|
||||||
- latesttag=$(git describe --tags)
|
- latesttag=$(git describe --tags)
|
||||||
- git checkout ${latesttag}
|
- 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
|
- mkdir tpl_c
|
||||||
- zip -r latest.zip .
|
- zip -r latest.zip .
|
||||||
- mkdir .public
|
- mkdir .public
|
||||||
@ -22,7 +24,7 @@ pages:
|
|||||||
- public
|
- public
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
funky:
|
funky:
|
||||||
stage: funky
|
stage: funky
|
||||||
before_script:
|
before_script:
|
||||||
|
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 STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||||
*/
|
*/
|
||||||
use Framadate\Services\LogService;
|
use Framadate\Message;
|
||||||
use Framadate\Services\PollService;
|
|
||||||
use Framadate\Services\InputService;
|
use Framadate\Services\InputService;
|
||||||
|
use Framadate\Services\LogService;
|
||||||
use Framadate\Services\MailService;
|
use Framadate\Services\MailService;
|
||||||
use Framadate\Services\NotificationService;
|
use Framadate\Services\NotificationService;
|
||||||
|
use Framadate\Services\PollService;
|
||||||
use Framadate\Services\SecurityService;
|
use Framadate\Services\SecurityService;
|
||||||
use Framadate\Message;
|
|
||||||
|
|
||||||
include_once __DIR__ . '/../app/inc/init.php';
|
include_once __DIR__ . '/../app/inc/init.php';
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ $poll_id = null;
|
|||||||
$poll = null;
|
$poll = null;
|
||||||
$message = null;
|
$message = null;
|
||||||
$result = false;
|
$result = false;
|
||||||
$comments = array();
|
$comments = [];
|
||||||
$is_admin = false;
|
$is_admin = false;
|
||||||
|
|
||||||
/* Services */
|
/* Services */
|
||||||
@ -57,7 +57,7 @@ if (!empty($_POST['poll'])) {
|
|||||||
if (!empty($_POST['poll_admin'])) {
|
if (!empty($_POST['poll_admin'])) {
|
||||||
$admin_poll_id = filter_input(INPUT_POST, 'poll_admin', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
$admin_poll_id = filter_input(INPUT_POST, 'poll_admin', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||||
if (strlen($admin_poll_id) === 24) {
|
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']);
|
$name = $inputService->filterName($_POST['name']);
|
||||||
$comment = $inputService->filterComment($_POST['comment']);
|
$comment = $inputService->filterComment($_POST['comment']);
|
||||||
|
|
||||||
if ($name == null) {
|
if ($name === null) {
|
||||||
$message = new Message('danger', __('Error', 'The name is invalid.'));
|
$message = new Message('danger', __('Error', 'The name is invalid.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($message == null) {
|
if ($message === null) {
|
||||||
// Add comment
|
// Add comment
|
||||||
$result = $pollService->addComment($poll_id, $name, $comment);
|
$result = $pollService->addComment($poll_id, $name, $comment);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@ -90,6 +90,6 @@ $smarty->error_reporting = E_ALL & ~E_NOTICE;
|
|||||||
$smarty->assign('comments', $comments);
|
$smarty->assign('comments', $comments);
|
||||||
$comments_html = $smarty->fetch('part/comments_list.tpl');
|
$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);
|
echo json_encode($response);
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* 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\Message;
|
||||||
|
use Framadate\Services\LogService;
|
||||||
|
use Framadate\Services\MailService;
|
||||||
|
use Framadate\Services\PollService;
|
||||||
|
use Framadate\Services\SessionService;
|
||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
include_once __DIR__ . '/../app/inc/init.php';
|
include_once __DIR__ . '/../app/inc/init.php';
|
||||||
@ -45,7 +45,7 @@ if (!empty($_POST['poll'])) {
|
|||||||
$token = $sessionService->get("Common", SESSION_EDIT_LINK_TOKEN);
|
$token = $sessionService->get("Common", SESSION_EDIT_LINK_TOKEN);
|
||||||
$token_form_value = empty($_POST['token']) ? null : $_POST['token'];
|
$token_form_value = empty($_POST['token']) ? null : $_POST['token'];
|
||||||
$editedVoteUniqueId = filter_input(INPUT_POST, 'editedVoteUniqueId', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
$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)) {
|
|| !$token->check($token_form_value) || is_null($editedVoteUniqueId)) {
|
||||||
$message = new Message('error', __('Error', 'Something is going wrong...'));
|
$message = new Message('error', __('Error', 'Something is going wrong...'));
|
||||||
}
|
}
|
||||||
@ -69,7 +69,6 @@ if (is_null($message)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (is_null($message)) {
|
if (is_null($message)) {
|
||||||
$url = Utils::getUrlSondage($poll_id, false, $editedVoteUniqueId);
|
$url = Utils::getUrlSondage($poll_id, false, $editedVoteUniqueId);
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ if (is_null($message)) {
|
|||||||
$smarty->assign('editedVoteUniqueId', $editedVoteUniqueId);
|
$smarty->assign('editedVoteUniqueId', $editedVoteUniqueId);
|
||||||
$body = $smarty->fetch('mail/remember_edit_link.tpl');
|
$body = $smarty->fetch('mail/remember_edit_link.tpl');
|
||||||
|
|
||||||
$subject = '[' . NOMAPPLICATION . ']['.__('EditLink', 'REMINDER').'] '.__f('EditLink', 'Edit link for poll "%s"', $poll->title);
|
$subject = '[' . NOMAPPLICATION . '][' . __('EditLink', 'REMINDER') . '] ' . __f('EditLink', 'Edit link for poll "%s"', $poll->title);
|
||||||
|
|
||||||
//$mailService->send($email, $subject, $body);
|
//$mailService->send($email, $subject, $body);
|
||||||
$sessionService->remove("Common", SESSION_EDIT_LINK_TOKEN);
|
$sessionService->remove("Common", SESSION_EDIT_LINK_TOKEN);
|
||||||
@ -90,7 +89,6 @@ if (is_null($message)) {
|
|||||||
|
|
||||||
$smarty->error_reporting = E_ALL & ~E_NOTICE;
|
$smarty->error_reporting = E_ALL & ~E_NOTICE;
|
||||||
|
|
||||||
$response = array('result' => $result, 'message' => $message);
|
$response = ['result' => $result, 'message' => $message];
|
||||||
|
|
||||||
|
|
||||||
echo json_encode($response);
|
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/autoload.php';
|
||||||
require_once ROOT_DIR . 'vendor/o80/i18n/src/shortcuts.php';
|
require_once ROOT_DIR . 'vendor/o80/i18n/src/shortcuts.php';
|
||||||
require_once ROOT_DIR . 'app/inc/constants.php';
|
require_once ROOT_DIR . 'app/inc/constants.php';
|
||||||
if (session_id() == '') {
|
if (session_id() === '') {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
$ALLOWED_LANGUAGES = [
|
$ALLOWED_LANGUAGES = [
|
||||||
@ -59,27 +59,26 @@ require_once ROOT_DIR . 'app/inc/i18n.php';
|
|||||||
*/
|
*/
|
||||||
function compareCheckMessage(Message $a, Message $b)
|
function compareCheckMessage(Message $a, Message $b)
|
||||||
{
|
{
|
||||||
$values = array(
|
$values = [
|
||||||
'danger' => 0,
|
'danger' => 0,
|
||||||
'warning' => 1,
|
'warning' => 1,
|
||||||
'info' => 2,
|
'info' => 2,
|
||||||
'success' => 3
|
'success' => 3
|
||||||
);
|
];
|
||||||
$vA = $values[$a->type];
|
$vA = $values[$a->type];
|
||||||
$vB = $values[$b->type];
|
$vB = $values[$b->type];
|
||||||
|
|
||||||
if ($vA == $vB) {
|
if ($vA === $vB) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return ($vA < $vB) ? -1 : 1;
|
return ($vA < $vB) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vars
|
* Vars
|
||||||
*/
|
*/
|
||||||
$messages = array();
|
$messages = [];
|
||||||
$inc_directory = ROOT_DIR. 'app/inc/';
|
$inc_directory = ROOT_DIR . 'app/inc/';
|
||||||
$conf_filename = $inc_directory . 'config.php';
|
$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.'));
|
$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
|
// The percentage of steps needed to be ready to launch the application
|
||||||
$errors = 0;
|
$errors = 0;
|
||||||
$warnings = 0;
|
$warnings = 0;
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
if ($message->type == 'danger') {
|
if ($message->type === 'danger') {
|
||||||
$errors++;
|
$errors++;
|
||||||
} else if ($message->type == 'warning') {
|
} else if ($message->type === 'warning') {
|
||||||
$warnings++;
|
$warnings++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +173,7 @@ usort($messages, 'compareCheckMessage');
|
|||||||
<div class="input-group input-group-sm pull-right col-xs-12 col-sm-2">
|
<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')?>" >
|
<select name="lang" class="form-control" title="<?=__('Language selector', 'Select the language')?>" >
|
||||||
<?php foreach ($ALLOWED_LANGUAGES as $lang_key => $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 } ?>
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
@ -197,9 +195,9 @@ usort($messages, 'compareCheckMessage');
|
|||||||
<div>
|
<div>
|
||||||
<?php
|
<?php
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
echo '<div class="alert alert-'. $message->type .'" role="alert">';
|
echo '<div class="alert alert-' . $message->type . '" role="alert">';
|
||||||
echo Utils::htmlEscape($message->message);
|
echo Utils::htmlEscape($message->message);
|
||||||
echo '<span class="sr-only">'. $message->type .'</span>';
|
echo '<span class="sr-only">' . $message->type . '</span>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -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>
|
<a class="btn btn-info" role="button" href=""><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> <?= __('Check', 'Check again') ?></a>
|
||||||
<?php
|
<?php
|
||||||
if (!is_file($conf_filename)) {
|
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>
|
<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
|
<?php
|
||||||
|
@ -37,9 +37,8 @@ if (!empty($_POST)) {
|
|||||||
if ($result['status'] === 'OK') {
|
if ($result['status'] === 'OK') {
|
||||||
header(('Location: ' . Utils::get_server_name() . 'admin/migration.php'));
|
header(('Location: ' . Utils::get_server_name() . 'admin/migration.php'));
|
||||||
exit;
|
exit;
|
||||||
} else {
|
}
|
||||||
$error = __('Error', $result['code']);
|
$error = __('Error', $result['code']);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty->assign('error', $error);
|
$smarty->assign('error', $error);
|
||||||
|
@ -17,15 +17,15 @@
|
|||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Framadate\Migration\From_0_0_to_0_8_Migration;
|
use Framadate\Migration\AddColumn_hidden_In_poll_For_0_9;
|
||||||
use Framadate\Migration\From_0_8_to_0_9_Migration;
|
|
||||||
use Framadate\Migration\AddColumn_receiveNewComments_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_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\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\Increase_pollId_size;
|
||||||
use Framadate\Migration\Migration;
|
use Framadate\Migration\Migration;
|
||||||
use Framadate\Migration\RPadVotes_from_0_8;
|
use Framadate\Migration\RPadVotes_from_0_8;
|
||||||
@ -56,7 +56,7 @@ $tables = $connect->allTables();
|
|||||||
$pdo = $connect->getPDO();
|
$pdo = $connect->getPDO();
|
||||||
$prefixedMigrationTable = Utils::table(MIGRATION_TABLE);
|
$prefixedMigrationTable = Utils::table(MIGRATION_TABLE);
|
||||||
|
|
||||||
if (!in_array($prefixedMigrationTable, $tables)) {
|
if (!in_array($prefixedMigrationTable, $tables, true)) {
|
||||||
$pdo->exec('
|
$pdo->exec('
|
||||||
CREATE TABLE IF NOT EXISTS `' . $prefixedMigrationTable . '` (
|
CREATE TABLE IF NOT EXISTS `' . $prefixedMigrationTable . '` (
|
||||||
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
@ -104,7 +104,6 @@ foreach ($migrations as $migration) {
|
|||||||
} else {
|
} else {
|
||||||
$countSkipped++;
|
$countSkipped++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$countTotal = $countSucceeded + $countFailed + $countSkipped;
|
$countTotal = $countSucceeded + $countFailed + $countSkipped;
|
||||||
|
@ -21,13 +21,13 @@ use Framadate\Exception\AlreadyExistsException;
|
|||||||
use Framadate\Exception\ConcurrentEditionException;
|
use Framadate\Exception\ConcurrentEditionException;
|
||||||
use Framadate\Exception\MomentAlreadyExistsException;
|
use Framadate\Exception\MomentAlreadyExistsException;
|
||||||
use Framadate\Message;
|
use Framadate\Message;
|
||||||
|
use Framadate\Security\PasswordHasher;
|
||||||
use Framadate\Services\AdminPollService;
|
use Framadate\Services\AdminPollService;
|
||||||
use Framadate\Services\InputService;
|
use Framadate\Services\InputService;
|
||||||
use Framadate\Services\LogService;
|
use Framadate\Services\LogService;
|
||||||
use Framadate\Services\MailService;
|
use Framadate\Services\MailService;
|
||||||
use Framadate\Services\PollService;
|
|
||||||
use Framadate\Services\NotificationService;
|
use Framadate\Services\NotificationService;
|
||||||
use Framadate\Security\PasswordHasher;
|
use Framadate\Services\PollService;
|
||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
include_once __DIR__ . '/app/inc/init.php';
|
include_once __DIR__ . '/app/inc/init.php';
|
||||||
@ -79,25 +79,25 @@ if (isset($_POST['update_poll_info'])) {
|
|||||||
'rules', 'expiration_date', 'name', 'hidden', 'removePassword', 'password']);
|
'rules', 'expiration_date', 'name', 'hidden', 'removePassword', 'password']);
|
||||||
|
|
||||||
// Update the right poll field
|
// Update the right poll field
|
||||||
if ($field == 'title') {
|
if ($field === 'title') {
|
||||||
$title = $inputService->filterTitle($_POST['title']);
|
$title = $inputService->filterTitle($_POST['title']);
|
||||||
if ($title) {
|
if ($title) {
|
||||||
$poll->title = $title;
|
$poll->title = $title;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'admin_mail') {
|
} elseif ($field === 'admin_mail') {
|
||||||
$admin_mail = $inputService->filterMail($_POST['admin_mail']);
|
$admin_mail = $inputService->filterMail($_POST['admin_mail']);
|
||||||
if ($admin_mail) {
|
if ($admin_mail) {
|
||||||
$poll->admin_mail = $admin_mail;
|
$poll->admin_mail = $admin_mail;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'description') {
|
} elseif ($field === 'description') {
|
||||||
$description = $inputService->filterDescription($_POST['description']);
|
$description = $inputService->filterDescription($_POST['description']);
|
||||||
if ($description) {
|
if ($description) {
|
||||||
$poll->description = $description;
|
$poll->description = $description;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'rules') {
|
} elseif ($field === 'rules') {
|
||||||
$rules = strip_tags($_POST['rules']);
|
$rules = strip_tags($_POST['rules']);
|
||||||
switch ($rules) {
|
switch ($rules) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -121,39 +121,39 @@ if (isset($_POST['update_poll_info'])) {
|
|||||||
$updated = true;
|
$updated = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'expiration_date') {
|
} elseif ($field === 'expiration_date') {
|
||||||
$expiration_date = $inputService->filterDate($_POST['expiration_date']);
|
$expiration_date = $inputService->filterDate($_POST['expiration_date']);
|
||||||
if ($expiration_date) {
|
if ($expiration_date) {
|
||||||
$poll->end_date = $expiration_date;
|
$poll->end_date = $expiration_date;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'name') {
|
} elseif ($field === 'name') {
|
||||||
$admin_name = $inputService->filterName($_POST['name']);
|
$admin_name = $inputService->filterName($_POST['name']);
|
||||||
if ($admin_name) {
|
if ($admin_name) {
|
||||||
$poll->admin_name = $admin_name;
|
$poll->admin_name = $admin_name;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'hidden') {
|
} elseif ($field === 'hidden') {
|
||||||
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
|
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
|
||||||
if ($hidden != $poll->hidden) {
|
if ($hidden !== $poll->hidden) {
|
||||||
$poll->hidden = $hidden;
|
$poll->hidden = $hidden;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'removePassword') {
|
} elseif ($field === 'removePassword') {
|
||||||
$removePassword = isset($_POST['removePassword']) ? $inputService->filterBoolean($_POST['removePassword']) : false;
|
$removePassword = isset($_POST['removePassword']) ? $inputService->filterBoolean($_POST['removePassword']) : false;
|
||||||
if ($removePassword) {
|
if ($removePassword) {
|
||||||
$poll->results_publicly_visible = false;
|
$poll->results_publicly_visible = false;
|
||||||
$poll->password_hash = null;
|
$poll->password_hash = null;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
} elseif ($field == 'password') {
|
} elseif ($field === 'password') {
|
||||||
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
||||||
$resultsPubliclyVisible = isset($_POST['resultsPubliclyVisible']) ? $inputService->filterBoolean($_POST['resultsPubliclyVisible']) : false;
|
$resultsPubliclyVisible = isset($_POST['resultsPubliclyVisible']) ? $inputService->filterBoolean($_POST['resultsPubliclyVisible']) : false;
|
||||||
if (!empty($password)) {
|
if (!empty($password)) {
|
||||||
$poll->password_hash = PasswordHasher::hash($password);
|
$poll->password_hash = PasswordHasher::hash($password);
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
if ($resultsPubliclyVisible != $poll->results_publicly_visible) {
|
if ($resultsPubliclyVisible !== $poll->results_publicly_visible) {
|
||||||
$poll->results_publicly_visible = $resultsPubliclyVisible;
|
$poll->results_publicly_visible = $resultsPubliclyVisible;
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
@ -190,11 +190,11 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
|
|||||||
if (empty($editedVote)) {
|
if (empty($editedVote)) {
|
||||||
$message = new Message('danger', __('Error', 'Something is going wrong...'));
|
$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'));
|
$message = new Message('danger', __('Error', 'There is a problem with your choices'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($message == null) {
|
if ($message === null) {
|
||||||
// Update vote
|
// Update vote
|
||||||
try {
|
try {
|
||||||
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices, $slots_hash);
|
$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]]);
|
$choices = $inputService->filterArray($_POST['choices'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => CHOICE_REGEX]]);
|
||||||
$slots_hash = $inputService->filterMD5($_POST['control']);
|
$slots_hash = $inputService->filterMD5($_POST['control']);
|
||||||
|
|
||||||
if ($name == null) {
|
if ($name === null) {
|
||||||
$message = new Message('danger', __('Error', 'The name is invalid.'));
|
$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'));
|
$message = new Message('danger', __('Error', 'There is a problem with your choices'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($message == null) {
|
if ($message === null) {
|
||||||
// Add vote
|
// Add vote
|
||||||
try {
|
try {
|
||||||
$result = $pollService->addVote($poll_id, $name, $choices, $slots_hash);
|
$result = $pollService->addVote($poll_id, $name, $choices, $slots_hash);
|
||||||
@ -401,7 +401,6 @@ $slots = $pollService->allSlotsByPoll($poll);
|
|||||||
$votes = $pollService->allVotesByPollId($poll_id);
|
$votes = $pollService->allVotesByPollId($poll_id);
|
||||||
$comments = $pollService->allCommentsByPollId($poll_id);
|
$comments = $pollService->allCommentsByPollId($poll_id);
|
||||||
|
|
||||||
|
|
||||||
// Assign data to template
|
// Assign data to template
|
||||||
$smarty->assign('poll_id', $poll_id);
|
$smarty->assign('poll_id', $poll_id);
|
||||||
$smarty->assign('admin_poll_id', $admin_poll_id);
|
$smarty->assign('admin_poll_id', $admin_poll_id);
|
||||||
|
@ -33,7 +33,7 @@ class Choice
|
|||||||
public function __construct($name='')
|
public function __construct($name='')
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->slots = array();
|
$this->slots = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSlot($slot)
|
public function addSlot($slot)
|
||||||
@ -55,5 +55,4 @@ class Choice
|
|||||||
{
|
{
|
||||||
return strcmp($a->name, $b->name);
|
return strcmp($a->name, $b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
namespace Framadate;
|
namespace Framadate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Editable
|
* Class Editable
|
||||||
*
|
*
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
namespace Framadate\Exception;
|
namespace Framadate\Exception;
|
||||||
|
|
||||||
class AlreadyExistsException extends \Exception {
|
class AlreadyExistsException extends \Exception {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
namespace Framadate\Exception;
|
namespace Framadate\Exception;
|
||||||
|
|
||||||
class ConcurrentEditionException extends \Exception {
|
class ConcurrentEditionException extends \Exception {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
namespace Framadate\Exception;
|
namespace Framadate\Exception;
|
||||||
|
|
||||||
class MomentAlreadyExistsException extends \Exception {
|
class MomentAlreadyExistsException extends \Exception {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ namespace Framadate;
|
|||||||
|
|
||||||
class Form
|
class Form
|
||||||
{
|
{
|
||||||
|
|
||||||
public $title;
|
public $title;
|
||||||
public $id;
|
public $id;
|
||||||
public $description;
|
public $description;
|
||||||
@ -87,7 +86,7 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function clearChoices() {
|
public function clearChoices() {
|
||||||
$this->choices = array();
|
$this->choices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addChoice(Choice $choice)
|
public function addChoice(Choice $choice)
|
||||||
@ -102,7 +101,6 @@ class Form
|
|||||||
|
|
||||||
public function sortChoices()
|
public function sortChoices()
|
||||||
{
|
{
|
||||||
usort($this->choices, array('Framadate\Choice', 'compare'));
|
usort($this->choices, ['Framadate\Choice', 'compare']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace Framadate;
|
namespace Framadate;
|
||||||
|
|
||||||
class Message {
|
class Message {
|
||||||
|
|
||||||
var $type;
|
var $type;
|
||||||
var $message;
|
var $message;
|
||||||
var $link;
|
var $link;
|
||||||
@ -27,14 +26,13 @@ class Message {
|
|||||||
var $linkIcon;
|
var $linkIcon;
|
||||||
var $includeTemplate;
|
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->type = $type;
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
$this->link = $link;
|
$this->link = $link;
|
||||||
$this->linkTitle = $linkTitle;
|
$this->linkTitle = $linkTitle;
|
||||||
$this->linkIcon = $linkIcon;
|
$this->linkIcon = $linkIcon;
|
||||||
$this->includeTemplate = $includeTemplate;
|
$this->includeTemplate = $includeTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 0.9
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class AddColumn_hidden_In_poll_For_0_9 implements Migration {
|
class AddColumn_hidden_In_poll_For_0_9 implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,5 +72,4 @@ class AddColumn_hidden_In_poll_For_0_9 implements Migration {
|
|||||||
ALTER TABLE `' . Utils::table('poll') . '`
|
ALTER TABLE `' . Utils::table('poll') . '`
|
||||||
ADD `hidden` TINYINT( 1 ) NOT NULL DEFAULT "0"');
|
ADD `hidden` TINYINT( 1 ) NOT NULL DEFAULT "0"');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 0.9
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class AddColumn_receiveNewComments_For_0_9 implements Migration {
|
class AddColumn_receiveNewComments_For_0_9 implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,5 +73,4 @@ ALTER TABLE `' . Utils::table('poll') . '`
|
|||||||
ADD `receiveNewComments` TINYINT(1) DEFAULT \'0\'
|
ADD `receiveNewComments` TINYINT(1) DEFAULT \'0\'
|
||||||
AFTER `receiveNewVotes`');
|
AFTER `receiveNewVotes`');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 0.9
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class AddColumn_uniqId_In_vote_For_0_9 implements Migration {
|
class AddColumn_uniqId_In_vote_For_0_9 implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,5 +74,4 @@ class AddColumn_uniqId_In_vote_For_0_9 implements Migration {
|
|||||||
AFTER `id`,
|
AFTER `id`,
|
||||||
ADD INDEX (`uniqId`) ;');
|
ADD INDEX (`uniqId`) ;');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 0.9
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9 implements Migration {
|
class AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9 implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
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 `password_hash` VARCHAR(255) NULL DEFAULT NULL ,
|
||||||
ADD `results_publicly_visible` TINYINT(1) NULL DEFAULT NULL');
|
ADD `results_publicly_visible` TINYINT(1) NULL DEFAULT NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
class Alter_Comment_table_adding_date implements Migration {
|
class Alter_Comment_table_adding_date implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,5 +67,4 @@ class Alter_Comment_table_adding_date implements Migration {
|
|||||||
ALTER TABLE `' . Utils::table('comment') . '`
|
ALTER TABLE `' . Utils::table('comment') . '`
|
||||||
ADD `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;');
|
ADD `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
class Alter_Comment_table_for_name_length implements Migration {
|
class Alter_Comment_table_for_name_length implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,5 +67,4 @@ class Alter_Comment_table_for_name_length implements Migration {
|
|||||||
ALTER TABLE `' . Utils::table('comment') . '`
|
ALTER TABLE `' . Utils::table('comment') . '`
|
||||||
CHANGE `name` `name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;');
|
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
|
* @version 0.8
|
||||||
*/
|
*/
|
||||||
class From_0_0_to_0_8_Migration implements Migration {
|
class From_0_0_to_0_8_Migration implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ use Framadate\Utils;
|
|||||||
* @version 0.9
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class From_0_8_to_0_9_Migration implements Migration {
|
class From_0_8_to_0_9_Migration implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,14 +264,14 @@ VALUE (?,?,?)');
|
|||||||
$slots[] = $slot;
|
$slots[] = $slot;
|
||||||
} else { // Date poll
|
} else { // Date poll
|
||||||
$values = explode('@', $atomicSlot);
|
$values = explode('@', $atomicSlot);
|
||||||
if ($lastSlot == null || $lastSlot->title !== $values[0]) {
|
if ($lastSlot === null || $lastSlot->title !== $values[0]) {
|
||||||
$lastSlot = new \stdClass();
|
$lastSlot = new \stdClass();
|
||||||
$lastSlot->poll_id = $sujet->id_sondage;
|
$lastSlot->poll_id = $sujet->id_sondage;
|
||||||
$lastSlot->title = $values[0];
|
$lastSlot->title = $values[0];
|
||||||
$lastSlot->moments = count($values) == 2 ? $values[1] : '-';
|
$lastSlot->moments = count($values) === 2 ? $values[1] : '-';
|
||||||
$slots[] = $lastSlot;
|
$slots[] = $lastSlot;
|
||||||
} else {
|
} 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
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class Generate_uniqId_for_old_votes implements Migration {
|
class Generate_uniqId_for_old_votes implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ class Generate_uniqId_for_old_votes implements Migration {
|
|||||||
* @return bool true is the execution succeeded
|
* @return bool true is the execution succeeded
|
||||||
*/
|
*/
|
||||||
function execute(\PDO $pdo) {
|
function execute(\PDO $pdo) {
|
||||||
|
|
||||||
$pdo->beginTransaction();
|
$pdo->beginTransaction();
|
||||||
$this->generateUniqIdsForEmptyOnes($pdo);
|
$this->generateUniqIdsForEmptyOnes($pdo);
|
||||||
$pdo->commit();
|
$pdo->commit();
|
||||||
@ -79,5 +77,4 @@ UPDATE `' . Utils::table('vote') . '`
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ namespace Framadate\Migration;
|
|||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
class Increase_pollId_size implements Migration {
|
class Increase_pollId_size implements Migration {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
namespace Framadate\Migration;
|
namespace Framadate\Migration;
|
||||||
|
|
||||||
interface Migration {
|
interface Migration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should describe in english what is the purpose of the migration class.
|
* 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
|
* @return bool true if the execution succeeded
|
||||||
*/
|
*/
|
||||||
function execute(\PDO $pdo);
|
function execute(\PDO $pdo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,6 @@ use Framadate\Utils;
|
|||||||
* @version 0.9
|
* @version 0.9
|
||||||
*/
|
*/
|
||||||
class RPadVotes_from_0_8 implements Migration {
|
class RPadVotes_from_0_8 implements Migration {
|
||||||
|
|
||||||
function description() {
|
function description() {
|
||||||
return 'RPad votes from version 0.8.';
|
return 'RPad votes from version 0.8.';
|
||||||
}
|
}
|
||||||
@ -43,7 +42,6 @@ class RPadVotes_from_0_8 implements Migration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function execute(\PDO $pdo) {
|
function execute(\PDO $pdo) {
|
||||||
|
|
||||||
$pdo->beginTransaction();
|
$pdo->beginTransaction();
|
||||||
$this->rpadVotes($pdo);
|
$this->rpadVotes($pdo);
|
||||||
$pdo->commit();
|
$pdo->commit();
|
||||||
@ -52,13 +50,13 @@ class RPadVotes_from_0_8 implements Migration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function rpadVotes($pdo) {
|
private function rpadVotes($pdo) {
|
||||||
$pdo->exec('UPDATE '. Utils::table('vote') .' fv
|
$pdo->exec('UPDATE ' . Utils::table('vote') . ' fv
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT v.id, RPAD(v.choices, inn.slots_count, \'0\') new_choices
|
SELECT v.id, RPAD(v.choices, inn.slots_count, \'0\') new_choices
|
||||||
FROM '. Utils::table('vote') .' v
|
FROM ' . Utils::table('vote') . ' v
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
(SELECT s.poll_id, SUM(IFNULL(LENGTH(s.moments) - LENGTH(REPLACE(s.moments, \',\', \'\')) + 1, 1)) slots_count
|
(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
|
GROUP BY s.poll_id
|
||||||
ORDER BY s.poll_id) inn ON inn.poll_id = v.poll_id
|
ORDER BY s.poll_id) inn ON inn.poll_id = v.poll_id
|
||||||
WHERE LENGTH(v.choices) != inn.slots_count
|
WHERE LENGTH(v.choices) != inn.slots_count
|
||||||
|
@ -4,7 +4,6 @@ namespace Framadate\Repositories;
|
|||||||
use Framadate\FramaDB;
|
use Framadate\FramaDB;
|
||||||
|
|
||||||
abstract class AbstractRepository {
|
abstract class AbstractRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FramaDB
|
* @var FramaDB
|
||||||
*/
|
*/
|
||||||
@ -41,5 +40,4 @@ abstract class AbstractRepository {
|
|||||||
function lastInsertId() {
|
function lastInsertId() {
|
||||||
return $this->connect->lastInsertId();
|
return $this->connect->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,13 @@ use Framadate\FramaDB;
|
|||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
class CommentRepository extends AbstractRepository {
|
class CommentRepository extends AbstractRepository {
|
||||||
|
|
||||||
function __construct(FramaDB $connect) {
|
function __construct(FramaDB $connect) {
|
||||||
parent::__construct($connect);
|
parent::__construct($connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findAllByPollId($poll_id) {
|
function findAllByPollId($poll_id) {
|
||||||
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('comment') . '` WHERE poll_id = ? ORDER BY 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();
|
return $prepared->fetchAll();
|
||||||
}
|
}
|
||||||
@ -51,9 +50,8 @@ class CommentRepository extends AbstractRepository {
|
|||||||
|
|
||||||
public function exists($poll_id, $name, $comment) {
|
public function exists($poll_id, $name, $comment) {
|
||||||
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('comment') . '` WHERE poll_id = ? AND name = ? AND 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;
|
return $prepared->rowCount() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ use Framadate\Utils;
|
|||||||
use PDO;
|
use PDO;
|
||||||
|
|
||||||
class PollRepository extends AbstractRepository {
|
class PollRepository extends AbstractRepository {
|
||||||
|
|
||||||
function __construct(FramaDB $connect) {
|
function __construct(FramaDB $connect) {
|
||||||
parent::__construct($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)
|
(id, admin_id, title, description, admin_name, admin_mail, end_date, format, editable, receiveNewVotes, receiveNewComments, hidden, password_hash, results_publicly_visible)
|
||||||
VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?,?,?,?,?,?,?)';
|
VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?,?,?,?,?,?,?)';
|
||||||
$prepared = $this->prepare($sql);
|
$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) {
|
function findById($poll_id) {
|
||||||
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE id = ?');
|
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE id = ?');
|
||||||
|
|
||||||
$prepared->execute(array($poll_id));
|
$prepared->execute([$poll_id]);
|
||||||
$poll = $prepared->fetch();
|
$poll = $prepared->fetch();
|
||||||
$prepared->closeCursor();
|
$prepared->closeCursor();
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ class PollRepository extends AbstractRepository {
|
|||||||
public function findByAdminId($admin_poll_id) {
|
public function findByAdminId($admin_poll_id) {
|
||||||
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE admin_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();
|
$poll = $prepared->fetch();
|
||||||
$prepared->closeCursor();
|
$prepared->closeCursor();
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ class PollRepository extends AbstractRepository {
|
|||||||
public function existsById($poll_id) {
|
public function existsById($poll_id) {
|
||||||
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE 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;
|
return $prepared->rowCount() > 0;
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ class PollRepository extends AbstractRepository {
|
|||||||
public function existsByAdminId($admin_poll_id) {
|
public function existsByAdminId($admin_poll_id) {
|
||||||
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE admin_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;
|
return $prepared->rowCount() > 0;
|
||||||
}
|
}
|
||||||
@ -124,7 +123,7 @@ SELECT p.*,
|
|||||||
*/
|
*/
|
||||||
public function findAllByAdminMail($mail) {
|
public function findAllByAdminMail($mail) {
|
||||||
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE admin_mail = :admin_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();
|
return $prepared->fetchAll();
|
||||||
}
|
}
|
||||||
@ -145,9 +144,9 @@ SELECT count(1) nb
|
|||||||
AND (:name = "" OR p.admin_name LIKE :name)
|
AND (:name = "" OR p.admin_name LIKE :name)
|
||||||
ORDER BY p.title ASC');
|
ORDER BY p.title ASC');
|
||||||
|
|
||||||
$poll = $search == null ? '' : $search['poll'] . '%';
|
$poll = $search === null ? '' : $search['poll'] . '%';
|
||||||
$title = $search == null ? '' : '%' . $search['title'] . '%';
|
$title = $search === null ? '' : '%' . $search['title'] . '%';
|
||||||
$name = $search == null ? '' : '%' . $search['name'] . '%';
|
$name = $search === null ? '' : '%' . $search['name'] . '%';
|
||||||
$prepared->bindParam(':id', $poll, PDO::PARAM_STR);
|
$prepared->bindParam(':id', $poll, PDO::PARAM_STR);
|
||||||
$prepared->bindParam(':title', $title, PDO::PARAM_STR);
|
$prepared->bindParam(':title', $title, PDO::PARAM_STR);
|
||||||
$prepared->bindParam(':name', $name, PDO::PARAM_STR);
|
$prepared->bindParam(':name', $name, PDO::PARAM_STR);
|
||||||
@ -162,5 +161,4 @@ SELECT count(1) nb
|
|||||||
|
|
||||||
return $count->nb;
|
return $count->nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ namespace Framadate\Repositories;
|
|||||||
use Framadate\FramaDB;
|
use Framadate\FramaDB;
|
||||||
|
|
||||||
class RepositoryFactory {
|
class RepositoryFactory {
|
||||||
|
|
||||||
private static $connect;
|
private static $connect;
|
||||||
|
|
||||||
private static $pollRepository;
|
private static $pollRepository;
|
||||||
@ -40,7 +39,7 @@ class RepositoryFactory {
|
|||||||
* @return PollRepository The singleton of PollRepository
|
* @return PollRepository The singleton of PollRepository
|
||||||
*/
|
*/
|
||||||
static function pollRepository() {
|
static function pollRepository() {
|
||||||
if (self::$pollRepository == null) {
|
if (self::$pollRepository === null) {
|
||||||
self::$pollRepository = new PollRepository(self::$connect);
|
self::$pollRepository = new PollRepository(self::$connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ class RepositoryFactory {
|
|||||||
* @return SlotRepository The singleton of SlotRepository
|
* @return SlotRepository The singleton of SlotRepository
|
||||||
*/
|
*/
|
||||||
static function slotRepository() {
|
static function slotRepository() {
|
||||||
if (self::$slotRepository == null) {
|
if (self::$slotRepository === null) {
|
||||||
self::$slotRepository = new SlotRepository(self::$connect);
|
self::$slotRepository = new SlotRepository(self::$connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ class RepositoryFactory {
|
|||||||
* @return VoteRepository The singleton of VoteRepository
|
* @return VoteRepository The singleton of VoteRepository
|
||||||
*/
|
*/
|
||||||
static function voteRepository() {
|
static function voteRepository() {
|
||||||
if (self::$voteRepository == null) {
|
if (self::$voteRepository === null) {
|
||||||
self::$voteRepository = new VoteRepository(self::$connect);
|
self::$voteRepository = new VoteRepository(self::$connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +72,10 @@ class RepositoryFactory {
|
|||||||
* @return CommentRepository The singleton of CommentRepository
|
* @return CommentRepository The singleton of CommentRepository
|
||||||
*/
|
*/
|
||||||
static function commentRepository() {
|
static function commentRepository() {
|
||||||
if (self::$commentRepository == null) {
|
if (self::$commentRepository === null) {
|
||||||
self::$commentRepository = new CommentRepository(self::$connect);
|
self::$commentRepository = new CommentRepository(self::$connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$commentRepository;
|
return self::$commentRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ use Framadate\FramaDB;
|
|||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
class SlotRepository extends AbstractRepository {
|
class SlotRepository extends AbstractRepository {
|
||||||
|
|
||||||
function __construct(FramaDB $connect) {
|
function __construct(FramaDB $connect) {
|
||||||
parent::__construct($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 (?, ?, ?)');
|
$prepared = $this->prepare('INSERT INTO `' . Utils::table('slot') . '` (poll_id, title, moments) VALUES (?, ?, ?)');
|
||||||
|
|
||||||
foreach ($choices as $choice) {
|
foreach ($choices as $choice) {
|
||||||
|
|
||||||
// We prepared the slots (joined by comas)
|
// We prepared the slots (joined by comas)
|
||||||
$joinedSlots = '';
|
$joinedSlots = '';
|
||||||
$first = true;
|
$first = true;
|
||||||
@ -52,17 +50,16 @@ class SlotRepository extends AbstractRepository {
|
|||||||
|
|
||||||
// We execute the insertion
|
// We execute the insertion
|
||||||
if (empty($joinedSlots)) {
|
if (empty($joinedSlots)) {
|
||||||
$prepared->execute(array($poll_id, $choice->getName(), null));
|
$prepared->execute([$poll_id, $choice->getName(), null]);
|
||||||
} else {
|
} else {
|
||||||
$prepared->execute(array($poll_id, $choice->getName(), $joinedSlots));
|
$prepared->execute([$poll_id, $choice->getName(), $joinedSlots]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function listByPollId($poll_id) {
|
function listByPollId($poll_id) {
|
||||||
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('slot') . '` WHERE poll_id = ? ORDER BY 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();
|
return $prepared->fetchAll();
|
||||||
}
|
}
|
||||||
@ -128,5 +125,4 @@ class SlotRepository extends AbstractRepository {
|
|||||||
|
|
||||||
return $prepared->execute([$poll_id]);
|
return $prepared->execute([$poll_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,13 @@ use Framadate\FramaDB;
|
|||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
class VoteRepository extends AbstractRepository {
|
class VoteRepository extends AbstractRepository {
|
||||||
|
|
||||||
function __construct(FramaDB $connect) {
|
function __construct(FramaDB $connect) {
|
||||||
parent::__construct($connect);
|
parent::__construct($connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
function allUserVotesByPollId($poll_id) {
|
function allUserVotesByPollId($poll_id) {
|
||||||
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('vote') . '` WHERE poll_id = ? ORDER BY 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();
|
return $prepared->fetchAll();
|
||||||
}
|
}
|
||||||
@ -83,8 +82,7 @@ class VoteRepository extends AbstractRepository {
|
|||||||
*/
|
*/
|
||||||
public function existsByPollIdAndName($poll_id, $name) {
|
public function existsByPollIdAndName($poll_id, $name) {
|
||||||
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('vote') . '` WHERE poll_id = ? AND 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;
|
return $prepared->rowCount() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ namespace Framadate\Security;
|
|||||||
* @package Framadate\Security
|
* @package Framadate\Security
|
||||||
*/
|
*/
|
||||||
class PasswordHasher {
|
class PasswordHasher {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash a password
|
* Hash a password
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
namespace Framadate\Security;
|
namespace Framadate\Security;
|
||||||
|
|
||||||
class Token {
|
class Token {
|
||||||
|
|
||||||
const DEFAULT_LENGTH = 64;
|
const DEFAULT_LENGTH = 64;
|
||||||
private $time;
|
private $time;
|
||||||
private $value;
|
private $value;
|
||||||
@ -15,10 +14,6 @@ class Token {
|
|||||||
$this->value = $this->generate();
|
$this->value = $this->generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate() {
|
|
||||||
return self::getToken($this->length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTime() {
|
public function getTime() {
|
||||||
return $this->time;
|
return $this->time;
|
||||||
}
|
}
|
||||||
@ -71,6 +66,10 @@ class Token {
|
|||||||
return $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
|
* @author http://us1.php.net/manual/en/function.openssl-random-pseudo-bytes.php#104322
|
||||||
*/
|
*/
|
||||||
@ -87,6 +86,5 @@ class Token {
|
|||||||
} while ($rnd >= $range);
|
} while ($rnd >= $range);
|
||||||
return $min + $rnd;
|
return $min + $rnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,6 @@ use Framadate\Utils;
|
|||||||
* @package Framadate\Services
|
* @package Framadate\Services
|
||||||
*/
|
*/
|
||||||
class AdminPollService {
|
class AdminPollService {
|
||||||
|
|
||||||
private $connect;
|
private $connect;
|
||||||
private $pollService;
|
private $pollService;
|
||||||
private $logService;
|
private $logService;
|
||||||
@ -36,9 +35,8 @@ class AdminPollService {
|
|||||||
global $config;
|
global $config;
|
||||||
if ($poll->end_date > $poll->creation_date) {
|
if ($poll->end_date > $poll->creation_date) {
|
||||||
return $this->pollRepository->update($poll);
|
return $this->pollRepository->update($poll);
|
||||||
} else {
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,9 +118,9 @@ class AdminPollService {
|
|||||||
$slots = $this->pollService->allSlotsByPoll($poll);
|
$slots = $this->pollService->allSlotsByPoll($poll);
|
||||||
|
|
||||||
// We can't delete the last slot
|
// 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;
|
return false;
|
||||||
} elseif ($poll->format == 'A' && count($slots) === 1) {
|
} elseif ($poll->format === 'A' && count($slots) === 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +133,8 @@ class AdminPollService {
|
|||||||
$moments = explode(',', $aSlot->moments);
|
$moments = explode(',', $aSlot->moments);
|
||||||
|
|
||||||
foreach ($moments as $rowMoment) {
|
foreach ($moments as $rowMoment) {
|
||||||
if ($datetime == $aSlot->title) {
|
if ($datetime === $aSlot->title) {
|
||||||
if ($moment == $rowMoment) {
|
if ($moment === $rowMoment) {
|
||||||
$indexToDelete = $index;
|
$indexToDelete = $index;
|
||||||
} else {
|
} else {
|
||||||
$newMoments[] = $rowMoment;
|
$newMoments[] = $rowMoment;
|
||||||
@ -173,7 +171,7 @@ class AdminPollService {
|
|||||||
|
|
||||||
// Search the index of the slot to delete
|
// Search the index of the slot to delete
|
||||||
foreach ($slots as $aSlot) {
|
foreach ($slots as $aSlot) {
|
||||||
if ($slot_title == $aSlot->title) {
|
if ($slot_title === $aSlot->title) {
|
||||||
$indexToDelete = $index;
|
$indexToDelete = $index;
|
||||||
}
|
}
|
||||||
$index++;
|
$index++;
|
||||||
@ -209,19 +207,18 @@ class AdminPollService {
|
|||||||
// Begin transaction
|
// Begin transaction
|
||||||
$this->connect->beginTransaction();
|
$this->connect->beginTransaction();
|
||||||
|
|
||||||
if ($result->slot != null) {
|
if ($result->slot !== null) {
|
||||||
$slot = $result->slot;
|
$slot = $result->slot;
|
||||||
$moments = explode(',', $slot->moments);
|
$moments = explode(',', $slot->moments);
|
||||||
|
|
||||||
// Check if moment already exists (maybe not necessary)
|
// Check if moment already exists (maybe not necessary)
|
||||||
if (in_array($new_moment, $moments)) {
|
if (in_array($new_moment, $moments, true)) {
|
||||||
throw new MomentAlreadyExistsException();
|
throw new MomentAlreadyExistsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update found slot
|
// Update found slot
|
||||||
$moments[] = $new_moment;
|
$moments[] = $new_moment;
|
||||||
$this->slotRepository->update($poll_id, $datetime, implode(',', $moments));
|
$this->slotRepository->update($poll_id, $datetime, implode(',', $moments));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->slotRepository->insert($poll_id, $datetime, $new_moment);
|
$this->slotRepository->insert($poll_id, $datetime, $new_moment);
|
||||||
}
|
}
|
||||||
@ -230,7 +227,6 @@ class AdminPollService {
|
|||||||
|
|
||||||
// Commit transaction
|
// Commit transaction
|
||||||
$this->connect->commit();
|
$this->connect->commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,12 +248,11 @@ class AdminPollService {
|
|||||||
$titles = array_map(function ($slot) {
|
$titles = array_map(function ($slot) {
|
||||||
return $slot->title;
|
return $slot->title;
|
||||||
}, $slots);
|
}, $slots);
|
||||||
if (in_array($title, $titles)) {
|
if (in_array($title, $titles, true)) {
|
||||||
// The moment already exists
|
// The moment already exists
|
||||||
throw new MomentAlreadyExistsException();
|
throw new MomentAlreadyExistsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Begin transaction
|
// Begin transaction
|
||||||
$this->connect->beginTransaction();
|
$this->connect->beginTransaction();
|
||||||
|
|
||||||
@ -268,7 +263,6 @@ class AdminPollService {
|
|||||||
|
|
||||||
// Commit transaction
|
// Commit transaction
|
||||||
$this->connect->commit();
|
$this->connect->commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,7 +287,7 @@ class AdminPollService {
|
|||||||
$rowDatetime = $slot->title;
|
$rowDatetime = $slot->title;
|
||||||
$moments = explode(',', $slot->moments);
|
$moments = explode(',', $slot->moments);
|
||||||
|
|
||||||
if ($datetime == $rowDatetime) {
|
if ($datetime === $rowDatetime) {
|
||||||
// Here we have to insert at the end of a slot
|
// Here we have to insert at the end of a slot
|
||||||
$result->insert += count($moments);
|
$result->insert += count($moments);
|
||||||
$result->slot = $slot;
|
$result->slot = $slot;
|
||||||
@ -301,13 +295,11 @@ class AdminPollService {
|
|||||||
} elseif ($datetime < $rowDatetime) {
|
} elseif ($datetime < $rowDatetime) {
|
||||||
// We have to insert before this slot
|
// We have to insert before this slot
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
$result->insert += count($moments);
|
$result->insert += count($moments);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,6 @@ use DateTime;
|
|||||||
* This class helps to clean all inputs from the users or external services.
|
* This class helps to clean all inputs from the users or external services.
|
||||||
*/
|
*/
|
||||||
class InputService {
|
class InputService {
|
||||||
|
|
||||||
function __construct() {}
|
function __construct() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,5 +111,4 @@ class InputService {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,7 @@ use Smarty;
|
|||||||
* This class helps to clean all inputs from the users or external services.
|
* This class helps to clean all inputs from the users or external services.
|
||||||
*/
|
*/
|
||||||
class InstallService {
|
class InstallService {
|
||||||
|
private $fields = [
|
||||||
private $fields = array(
|
|
||||||
// General
|
// General
|
||||||
'appName' => 'Framadate',
|
'appName' => 'Framadate',
|
||||||
'appMail' => '',
|
'appMail' => '',
|
||||||
@ -39,7 +38,7 @@ class InstallService {
|
|||||||
'dbPassword' => '',
|
'dbPassword' => '',
|
||||||
'dbPrefix' => 'fd_',
|
'dbPrefix' => 'fd_',
|
||||||
'migrationTable' => 'framadate_migration'
|
'migrationTable' => 'framadate_migration'
|
||||||
);
|
];
|
||||||
|
|
||||||
function __construct() {}
|
function __construct() {}
|
||||||
|
|
||||||
@ -101,10 +100,10 @@ class InstallService {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ok() {
|
function ok() {
|
||||||
return array(
|
return [
|
||||||
'status' => 'OK',
|
'status' => 'OK',
|
||||||
'msg' => __f('Installation', 'Ended', Utils::get_server_name())
|
'msg' => __f('Installation', 'Ended', Utils::get_server_name())
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,14 +111,13 @@ class InstallService {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function error($msg) {
|
function error($msg) {
|
||||||
return array(
|
return [
|
||||||
'status' => 'ERROR',
|
'status' => 'ERROR',
|
||||||
'code' => $msg
|
'code' => $msg
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFields() {
|
public function getFields() {
|
||||||
return $this->fields;
|
return $this->fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ namespace Framadate\Services;
|
|||||||
* @package Framadate\Services
|
* @package Framadate\Services
|
||||||
*/
|
*/
|
||||||
class LogService {
|
class LogService {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,6 +19,5 @@ class LogService {
|
|||||||
function log($tag, $message) {
|
function log($tag, $message) {
|
||||||
error_log(date('Ymd His') . ' [' . $tag . '] ' . $message . "\n", 3, ROOT_DIR . LOG_FILE);
|
error_log(date('Ymd His') . ' [' . $tag . '] ' . $message . "\n", 3, ROOT_DIR . LOG_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,13 +4,12 @@ namespace Framadate\Services;
|
|||||||
use PHPMailer;
|
use PHPMailer;
|
||||||
|
|
||||||
class MailService {
|
class MailService {
|
||||||
|
|
||||||
private $smtp_allowed;
|
|
||||||
|
|
||||||
const DELAY_BEFORE_RESEND = 300;
|
const DELAY_BEFORE_RESEND = 300;
|
||||||
|
|
||||||
const MAILSERVICE_KEY = 'mailservice';
|
const MAILSERVICE_KEY = 'mailservice';
|
||||||
|
|
||||||
|
private $smtp_allowed;
|
||||||
|
|
||||||
private $logService;
|
private $logService;
|
||||||
|
|
||||||
function __construct($smtp_allowed) {
|
function __construct($smtp_allowed) {
|
||||||
@ -23,7 +22,7 @@ class MailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send($to, $subject, $body, $msgKey = null) {
|
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 = new PHPMailer(true);
|
||||||
$mail->isSMTP();
|
$mail->isSMTP();
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ class MailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function canSendMsg($msgKey) {
|
function canSendMsg($msgKey) {
|
||||||
if ($msgKey == null) {
|
if ($msgKey === null) {
|
||||||
return true;
|
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;
|
return !isset($_SESSION[self::MAILSERVICE_KEY][$msgKey]) || time() - $_SESSION[self::MAILSERVICE_KEY][$msgKey] > self::DELAY_BEFORE_RESEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,13 +3,11 @@
|
|||||||
|
|
||||||
namespace Framadate\Services;
|
namespace Framadate\Services;
|
||||||
|
|
||||||
|
use \stdClass;
|
||||||
use Framadate\Services\MailService;
|
use Framadate\Services\MailService;
|
||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
use \stdClass;
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationService {
|
class NotificationService {
|
||||||
|
|
||||||
const UPDATE_VOTE = 1;
|
const UPDATE_VOTE = 1;
|
||||||
const ADD_VOTE = 2;
|
const ADD_VOTE = 2;
|
||||||
const ADD_COMMENT = 3;
|
const ADD_COMMENT = 3;
|
||||||
@ -34,12 +32,11 @@ class NotificationService {
|
|||||||
$_SESSION['mail_sent'] = [];
|
$_SESSION['mail_sent'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$isVoteAndCanSendIt = ($type == self::UPDATE_VOTE || $type == self::ADD_VOTE) && $poll->receiveNewVotes;
|
$isVoteAndCanSendIt = ($type === self::UPDATE_VOTE || $type === self::ADD_VOTE) && $poll->receiveNewVotes;
|
||||||
$isCommentAndCanSendIt = $type == self::ADD_COMMENT && $poll->receiveNewComments;
|
$isCommentAndCanSendIt = $type === self::ADD_COMMENT && $poll->receiveNewComments;
|
||||||
$isOtherType = $type != self::UPDATE_VOTE && $type != self::ADD_VOTE && $type != self::ADD_COMMENT;
|
$isOtherType = $type !== self::UPDATE_VOTE && $type !== self::ADD_VOTE && $type !== self::ADD_COMMENT;
|
||||||
|
|
||||||
if ($isVoteAndCanSendIt || $isCommentAndCanSendIt || $isOtherType) {
|
if ($isVoteAndCanSendIt || $isCommentAndCanSendIt || $isOtherType) {
|
||||||
|
|
||||||
if (self::isParticipation($type)) {
|
if (self::isParticipation($type)) {
|
||||||
$translationString = 'Poll\'s participation: %s';
|
$translationString = 'Poll\'s participation: %s';
|
||||||
} else {
|
} else {
|
||||||
@ -48,7 +45,6 @@ class NotificationService {
|
|||||||
|
|
||||||
$subject = '[' . NOMAPPLICATION . '] ' . __f('Mail', $translationString, $poll->title);
|
$subject = '[' . NOMAPPLICATION . '] ' . __f('Mail', $translationString, $poll->title);
|
||||||
|
|
||||||
|
|
||||||
$message = '';
|
$message = '';
|
||||||
|
|
||||||
$urlSondage = Utils::getUrlSondage($poll->admin_id, true);
|
$urlSondage = Utils::getUrlSondage($poll->admin_id, true);
|
||||||
@ -76,7 +72,6 @@ class NotificationService {
|
|||||||
case self::DELETED_POLL:
|
case self::DELETED_POLL:
|
||||||
$message = __f('Mail', 'Someone just delete your poll %s.', Utils::htmlEscape($poll->title)) . "\n\n";
|
$message = __f('Mail', 'Someone just delete your poll %s.', Utils::htmlEscape($poll->title)) . "\n\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$messageTypeKey = $type . '-' . $poll->id;
|
$messageTypeKey = $type . '-' . $poll->id;
|
||||||
@ -88,5 +83,4 @@ class NotificationService {
|
|||||||
{
|
{
|
||||||
return $type >= self::UPDATE_POLL;
|
return $type >= self::UPDATE_POLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -27,7 +27,6 @@ use Framadate\Security\Token;
|
|||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
|
|
||||||
class PollService {
|
class PollService {
|
||||||
|
|
||||||
private $connect;
|
private $connect;
|
||||||
private $logService;
|
private $logService;
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ class PollService {
|
|||||||
|
|
||||||
function allSlotsByPoll($poll) {
|
function allSlotsByPoll($poll) {
|
||||||
$slots = $this->slotRepository->listByPollId($poll->id);
|
$slots = $this->slotRepository->listByPollId($poll->id);
|
||||||
if ($poll->format == 'D') {
|
if ($poll->format === 'D') {
|
||||||
$this->sortSlorts($slots);
|
$this->sortSlorts($slots);
|
||||||
}
|
}
|
||||||
return $slots;
|
return $slots;
|
||||||
@ -114,9 +113,8 @@ class PollService {
|
|||||||
function addComment($poll_id, $name, $comment) {
|
function addComment($poll_id, $name, $comment) {
|
||||||
if ($this->commentRepository->exists($poll_id, $name, $comment)) {
|
if ($this->commentRepository->exists($poll_id, $name, $comment)) {
|
||||||
return true;
|
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);
|
$poll_id = $this->random(16);
|
||||||
} while ($this->pollRepository->existsById($poll_id));
|
} while ($this->pollRepository->existsById($poll_id));
|
||||||
$admin_poll_id = $poll_id . $this->random(8);
|
$admin_poll_id = $poll_id . $this->random(8);
|
||||||
|
|
||||||
} else { // User have choosen the poll id
|
} else { // User have choosen the poll id
|
||||||
$poll_id = $form->id;
|
$poll_id = $form->id;
|
||||||
do {
|
do {
|
||||||
$admin_poll_id = $this->random(24);
|
$admin_poll_id = $this->random(24);
|
||||||
} while ($this->pollRepository->existsByAdminId($admin_poll_id));
|
} while ($this->pollRepository->existsByAdminId($admin_poll_id));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert poll + slots
|
// 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);
|
$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) {
|
public function findAllByAdminMail($mail) {
|
||||||
@ -164,10 +160,10 @@ class PollService {
|
|||||||
$result['inb'][$i] = 0;
|
$result['inb'][$i] = 0;
|
||||||
$result['y'][$i] = 0;
|
$result['y'][$i] = 0;
|
||||||
}
|
}
|
||||||
if ($choice == 1) {
|
if ($choice === 1) {
|
||||||
$result['inb'][$i]++;
|
$result['inb'][$i]++;
|
||||||
}
|
}
|
||||||
if ($choice == 2) {
|
if ($choice === 2) {
|
||||||
$result['y'][$i]++;
|
$result['y'][$i]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,7 +173,7 @@ class PollService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function splitSlots($slots) {
|
function splitSlots($slots) {
|
||||||
$splitted = array();
|
$splitted = [];
|
||||||
foreach ($slots as $slot) {
|
foreach ($slots as $slot) {
|
||||||
$obj = new \stdClass();
|
$obj = new \stdClass();
|
||||||
$obj->day = $slot->title;
|
$obj->day = $slot->title;
|
||||||
@ -200,7 +196,7 @@ class PollService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function splitVotes($votes) {
|
function splitVotes($votes) {
|
||||||
$splitted = array();
|
$splitted = [];
|
||||||
foreach ($votes as $vote) {
|
foreach ($votes as $vote) {
|
||||||
$obj = new \stdClass();
|
$obj = new \stdClass();
|
||||||
$obj->id = $vote->id;
|
$obj->id = $vote->id;
|
||||||
@ -214,10 +210,6 @@ class PollService {
|
|||||||
return $splitted;
|
return $splitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function random($length) {
|
|
||||||
return Token::getToken($length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int The max timestamp allowed for expiry date
|
* @return int The max timestamp allowed for expiry date
|
||||||
*/
|
*/
|
||||||
@ -233,6 +225,20 @@ class PollService {
|
|||||||
return time() + 86400;
|
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.
|
* 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();
|
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
|
* @package Framadate\Services
|
||||||
*/
|
*/
|
||||||
class PurgeService {
|
class PurgeService {
|
||||||
|
|
||||||
private $logService;
|
private $logService;
|
||||||
private $pollRepository;
|
private $pollRepository;
|
||||||
private $slotRepository;
|
private $slotRepository;
|
||||||
@ -38,9 +37,9 @@ class PurgeService {
|
|||||||
|
|
||||||
foreach ($oldPolls as $poll) {
|
foreach ($oldPolls as $poll) {
|
||||||
if ($this->purgePollById($poll->id)) {
|
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 {
|
} 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;
|
return $done;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Framadate\Services;
|
namespace Framadate\Services;
|
||||||
|
|
||||||
use Framadate\Security\Token;
|
|
||||||
use Framadate\Security\PasswordHasher;
|
use Framadate\Security\PasswordHasher;
|
||||||
|
use Framadate\Security\Token;
|
||||||
|
|
||||||
class SecurityService {
|
class SecurityService {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +64,9 @@ class SecurityService {
|
|||||||
$currentPassword = isset($_SESSION['poll_security'][$poll->id]) ? $_SESSION['poll_security'][$poll->id] : null;
|
$currentPassword = isset($_SESSION['poll_security'][$poll->id]) ? $_SESSION['poll_security'][$poll->id] : null;
|
||||||
if (!empty($currentPassword) && PasswordHasher::verify($currentPassword, $poll->password_hash)) {
|
if (!empty($currentPassword) && PasswordHasher::verify($currentPassword, $poll->password_hash)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
unset($_SESSION['poll_security'][$poll->id]);
|
unset($_SESSION['poll_security'][$poll->id]);
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,9 +84,8 @@ class SecurityService {
|
|||||||
|
|
||||||
private function ensureSessionPollSecurityIsCreated() {
|
private function ensureSessionPollSecurityIsCreated() {
|
||||||
if (!isset($_SESSION['poll_security'])) {
|
if (!isset($_SESSION['poll_security'])) {
|
||||||
$_SESSION['poll_security'] = array();
|
$_SESSION['poll_security'] = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,9 +3,7 @@
|
|||||||
|
|
||||||
namespace Framadate\Services;
|
namespace Framadate\Services;
|
||||||
|
|
||||||
|
|
||||||
class SessionService {
|
class SessionService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get value of $key in $section, or $defaultValue
|
* Get value of $key in $section, or $defaultValue
|
||||||
*
|
*
|
||||||
@ -59,8 +57,7 @@ class SessionService {
|
|||||||
|
|
||||||
private function initSectionIfNeeded($section) {
|
private function initSectionIfNeeded($section) {
|
||||||
if (!isset($_SESSION[$section])) {
|
if (!isset($_SESSION[$section])) {
|
||||||
$_SESSION[$section] = array();
|
$_SESSION[$section] = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -9,7 +9,6 @@ use Framadate\Repositories\RepositoryFactory;
|
|||||||
* @package Framadate\Services
|
* @package Framadate\Services
|
||||||
*/
|
*/
|
||||||
class SuperAdminService {
|
class SuperAdminService {
|
||||||
|
|
||||||
private $pollRepository;
|
private $pollRepository;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
@ -30,9 +29,7 @@ class SuperAdminService {
|
|||||||
$count = $this->pollRepository->count($search);
|
$count = $this->pollRepository->count($search);
|
||||||
$total = $this->pollRepository->count();
|
$total = $this->pollRepository->count();
|
||||||
|
|
||||||
|
|
||||||
return ['polls' => $polls, 'count' => $count, 'total' => $total];
|
return ['polls' => $polls, 'count' => $count, 'total' => $total];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ class Utils {
|
|||||||
*/
|
*/
|
||||||
public static function get_server_name() {
|
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';
|
$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($_SERVER['SCRIPT_NAME']);
|
||||||
$dirname = $dirname === '\\' ? '/' : $dirname . '/';
|
$dirname = $dirname === '\\' ? '/' : $dirname . '/';
|
||||||
$dirname = str_replace('/admin', '', $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/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.min.js"></script>
|
||||||
<script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap-datepicker.js"></script>';
|
<script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap-datepicker.js"></script>';
|
||||||
if ('en' != $locale) {
|
if ('en' !== $locale) {
|
||||||
echo '
|
echo '
|
||||||
<script type="text/javascript" src="' . self::get_server_name() . 'js/locales/bootstrap-datepicker.' . $locale . '.js"></script>';
|
<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) {
|
public static function getUrlSondage($id, $admin = false, $vote_id = '', $action = null, $action_value = null) {
|
||||||
// URL-Encode $action_value
|
// 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 (URL_PROPRE) {
|
||||||
if ($admin === true) {
|
if ($admin === true) {
|
||||||
@ -94,10 +94,10 @@ class Utils {
|
|||||||
} else {
|
} else {
|
||||||
$url = self::get_server_name() . $id;
|
$url = self::get_server_name() . $id;
|
||||||
}
|
}
|
||||||
if ($vote_id != '') {
|
if ($vote_id !== '') {
|
||||||
$url .= '/vote/' . $vote_id . "#edit";
|
$url .= '/vote/' . $vote_id . "#edit";
|
||||||
} elseif ($action != null) {
|
} elseif ($action !== null) {
|
||||||
if ($action_value != null) {
|
if ($action_value !== null) {
|
||||||
$url .= '/action/' . $action . '/' . $action_value;
|
$url .= '/action/' . $action . '/' . $action_value;
|
||||||
} else {
|
} else {
|
||||||
$url .= '/action/' . $action;
|
$url .= '/action/' . $action;
|
||||||
@ -109,10 +109,10 @@ class Utils {
|
|||||||
} else {
|
} else {
|
||||||
$url = self::get_server_name() . 'studs.php?poll=' . $id;
|
$url = self::get_server_name() . 'studs.php?poll=' . $id;
|
||||||
}
|
}
|
||||||
if ($vote_id != '') {
|
if ($vote_id !== '') {
|
||||||
$url .= '&vote=' . $vote_id . "#edit";
|
$url .= '&vote=' . $vote_id . "#edit";
|
||||||
} elseif ($action != null) {
|
} elseif ($action !== null) {
|
||||||
if ($action_value != null) {
|
if ($action_value !== null) {
|
||||||
$url .= '&' . $action . "=" . $action_value;
|
$url .= '&' . $action . "=" . $action_value;
|
||||||
} else {
|
} else {
|
||||||
$url .= '&' . $action . "=";
|
$url .= '&' . $action . "=";
|
||||||
@ -142,26 +142,18 @@ class Utils {
|
|||||||
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $md, $md_a_img); // Markdown [![alt](src)](href)
|
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_img); // Markdown ![alt](src)
|
||||||
preg_match_all('/\[(.*?)\]\((.*?)\)/', $md, $md_a); // Markdown [text](href)
|
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]);
|
$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>';
|
$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]);
|
$text = self::htmlEscape($md_img[1][0]);
|
||||||
$html = '<img src="' . self::htmlEscape($md_img[2][0]) . '" class="img-responsive" alt="' . $text . '" title="' . $text . '" />';
|
$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]);
|
$text = self::htmlEscape($md_a[1][0]);
|
||||||
$html = '<a href="' . $md_a[2][0] . '">' . $text . '</a>';
|
$html = '<a href="' . $md_a[2][0] . '">' . $text . '</a>';
|
||||||
|
|
||||||
} else { // text only
|
} else { // text only
|
||||||
|
|
||||||
$text = self::htmlEscape($md);
|
$text = self::htmlEscape($md);
|
||||||
$html = $text;
|
$html = $text;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $clear ? $text : $html;
|
return $clear ? $text : $html;
|
||||||
@ -200,6 +192,6 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function base64url_decode($input) {
|
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');
|
$i18n->setPath(__DIR__ . '/../../locale');
|
||||||
|
|
||||||
// Change langauge when user asked for it
|
// 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'];
|
$_SESSION['lang'] = $_POST['lang'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ $date_format['txt_day'] = __('Date', 'DAY');
|
|||||||
$date_format['txt_date'] = __('Date', 'DATE');
|
$date_format['txt_date'] = __('Date', 'DATE');
|
||||||
$date_format['txt_month_year'] = __('Date', 'MONTH_YEAR');
|
$date_format['txt_month_year'] = __('Date', 'MONTH_YEAR');
|
||||||
$date_format['txt_datetime_short'] = __('Date', 'DATETIME');
|
$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) {
|
foreach ($date_format as $k => $v) {
|
||||||
$date_format[$k] = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $v); //replace %e by %#d for windows
|
$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/autoload.php';
|
||||||
require_once __DIR__ . '/../../vendor/o80/i18n/src/shortcuts.php';
|
require_once __DIR__ . '/../../vendor/o80/i18n/src/shortcuts.php';
|
||||||
|
|
||||||
if (session_id() == '') {
|
if (session_id() === '') {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ini_get('date.timezone') == '') {
|
if (ini_get('date.timezone') === '') {
|
||||||
date_default_timezone_set('Europe/Paris');
|
date_default_timezone_set('Europe/Paris');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,11 @@ $smarty->assign('date_format', $date_format);
|
|||||||
if (isset($_SERVER['FRAMADATE_DEVMODE']) && $_SERVER['FRAMADATE_DEVMODE']) {
|
if (isset($_SERVER['FRAMADATE_DEVMODE']) && $_SERVER['FRAMADATE_DEVMODE']) {
|
||||||
$smarty->force_compile = true;
|
$smarty->force_compile = true;
|
||||||
$smarty->compile_check = true;
|
$smarty->compile_check = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$smarty->force_compile = false;
|
$smarty->force_compile = false;
|
||||||
$smarty->compile_check = false;
|
$smarty->compile_check = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function smarty_function_poll_url($params, Smarty_Internal_Template $template) {
|
function smarty_function_poll_url($params, Smarty_Internal_Template $template) {
|
||||||
$poll_id = filter_var($params['id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
$poll_id = filter_var($params['id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||||
$admin = (isset($params['admin']) && $params['admin']) ? true : false;
|
$admin = (isset($params['admin']) && $params['admin']) ? true : false;
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
namespace Framadate;
|
namespace Framadate;
|
||||||
|
|
||||||
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
|
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
protected function getTestResourcePath($resourcepath) {
|
protected function getTestResourcePath($resourcepath) {
|
||||||
return __DIR__ . '/../resources/'.$resourcepath;
|
return __DIR__ . '/../resources/' . $resourcepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function readTestResource($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
|
$params = array_slice(func_get_args(), 2); // get all the parameters after $methodName
|
||||||
return $reflectionMethod->invokeArgs($object, $params);
|
return $reflectionMethod->invokeArgs($object, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class MailServiceUnitTest extends FramaTestCase {
|
|||||||
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
|
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
$this->assertEquals(true, $canSendMsg);
|
$this->assertSame(true, $canSendMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +33,6 @@ class MailServiceUnitTest extends FramaTestCase {
|
|||||||
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
|
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
$this->assertEquals(false, $canSendMsg);
|
$this->assertSame(false, $canSendMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
$loader = require __DIR__ . '/../../vendor/autoload.php';
|
$loader = require __DIR__ . '/../../vendor/autoload.php';
|
||||||
$loader->addPsr4('Framadate\\', __DIR__.'/Framadate');
|
$loader->addPsr4('Framadate\\', __DIR__ . '/Framadate');
|
||||||
|
21
bandeaux.php
21
bandeaux.php
@ -24,22 +24,22 @@ include_once __DIR__ . '/app/inc/init.php';
|
|||||||
function bandeau_titre($titre)
|
function bandeau_titre($titre)
|
||||||
{
|
{
|
||||||
global $ALLOWED_LANGUAGES;
|
global $ALLOWED_LANGUAGES;
|
||||||
$img = ( IMAGE_TITRE ) ? '<img src="'. Utils::get_server_name(). IMAGE_TITRE. '" alt="'.NOMAPPLICATION.'" class="img-responsive">' : '';
|
$img = ( IMAGE_TITRE ) ? '<img src="' . Utils::get_server_name() . IMAGE_TITRE . '" alt="' . NOMAPPLICATION . '" class="img-responsive">' : '';
|
||||||
echo '
|
echo '
|
||||||
<header role="banner">';
|
<header role="banner">';
|
||||||
if(count($ALLOWED_LANGUAGES) > 1){
|
if(count($ALLOWED_LANGUAGES) > 1){
|
||||||
echo '<form method="post" action="" class="hidden-print">
|
echo '<form method="post" action="" class="hidden-print">
|
||||||
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
|
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
|
||||||
<select name="lang" class="form-control" title="'. __('Language selector', 'Select the language') .'" >' . liste_lang() . '</select>
|
<select name="lang" class="form-control" title="' . __('Language selector', 'Select the language') . '" >' . liste_lang() . '</select>
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
<button type="submit" class="btn btn-default btn-sm" title="'. __('Language selector', 'Change the language') .'">OK</button>
|
<button type="submit" class="btn btn-default btn-sm" title="' . __('Language selector', 'Change the language') . '">OK</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</form>';
|
</form>';
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
<h1><a href="' . Utils::get_server_name() . '" title="' . __('Generic', 'Home') . ' - ' . NOMAPPLICATION . '">' . $img . '</a></h1>
|
<h1><a href="' . Utils::get_server_name() . '" title="' . __('Generic', 'Home') . ' - ' . NOMAPPLICATION . '">' . $img . '</a></h1>
|
||||||
<h2 class="lead"><i>'. $titre .'</i></h2>
|
<h2 class="lead"><i>' . $titre . '</i></h2>
|
||||||
<hr class="trait" role="presentation" />
|
<hr class="trait" role="presentation" />
|
||||||
</header>
|
</header>
|
||||||
<main role="main">';
|
<main role="main">';
|
||||||
@ -47,12 +47,11 @@ function bandeau_titre($titre)
|
|||||||
global $connect;
|
global $connect;
|
||||||
$tables = $connect->allTables();
|
$tables = $connect->allTables();
|
||||||
$diff = array_diff([Utils::table('comment'), Utils::table('poll'), Utils::table('slot'), Utils::table('vote')], $tables);
|
$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>';
|
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();
|
bandeau_pied();
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function liste_lang()
|
function liste_lang()
|
||||||
@ -62,10 +61,10 @@ function liste_lang()
|
|||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
foreach ($ALLOWED_LANGUAGES as $k => $v ) {
|
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" ;
|
$str .= '<option lang="' . substr($k,0,2) . '" selected value="' . $k . '">' . $v . '</option>' . "\n" ;
|
||||||
} else {
|
} else {
|
||||||
$str .= '<option lang="'.substr($k,0,2).'" value="' . $k . '">' . $v . '</option>' . "\n" ;
|
$str .= '<option lang="' . substr($k,0,2) . '" value="' . $k . '">' . $v . '</option>' . "\n" ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,5 +77,5 @@ function bandeau_pied()
|
|||||||
</main>
|
</main>
|
||||||
</div> <!-- .container -->
|
</div> <!-- .container -->
|
||||||
</body>
|
</body>
|
||||||
</html>'."\n";
|
</html>' . "\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($good));
|
||||||
var_dump(array_keys($test));
|
var_dump(array_keys($test));
|
||||||
} else {
|
} else {
|
||||||
echo 'All sections are in two langs.' . "\n";
|
echo 'All sections are in two langs.' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$diff = [];
|
||||||
$diff = array();
|
|
||||||
|
|
||||||
foreach ($good as $sectionName => $section) {
|
foreach ($good as $sectionName => $section) {
|
||||||
$diffSection = false;
|
$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_good'] = array_keys($good[$sectionName]);
|
||||||
$diff[$sectionName]['order_test'] = array_keys($test[$sectionName]);
|
$diff[$sectionName]['order_test'] = array_keys($test[$sectionName]);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.7"
|
"phpunit/phpunit": "^5.7",
|
||||||
|
"friendsofphp/php-cs-fixer": "~2.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"autoload": {
|
"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 STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||||
*/
|
*/
|
||||||
|
use Framadate\Choice;
|
||||||
use Framadate\Services\LogService;
|
use Framadate\Services\LogService;
|
||||||
use Framadate\Services\PollService;
|
|
||||||
use Framadate\Services\MailService;
|
use Framadate\Services\MailService;
|
||||||
|
use Framadate\Services\PollService;
|
||||||
use Framadate\Services\PurgeService;
|
use Framadate\Services\PurgeService;
|
||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
use Framadate\Choice;
|
|
||||||
|
|
||||||
include_once __DIR__ . '/app/inc/init.php';
|
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
|
// 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)) {
|
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('title', __('Error', 'Error!'));
|
||||||
$smarty->assign('error', __('Error', 'You haven\'t filled the first section of the poll creation.'));
|
$smarty->assign('error', __('Error', 'You haven\'t filled the first section of the poll creation.'));
|
||||||
$smarty->display('error.tpl');
|
$smarty->display('error.tpl');
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
// Min/Max archive date
|
// Min/Max archive date
|
||||||
$min_expiry_time = $pollService->minExpiryDate();
|
$min_expiry_time = $pollService->minExpiryDate();
|
||||||
$max_expiry_time = $pollService->maxExpiryDate();
|
$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
|
// Step 4 : Data prepare before insert in DB
|
||||||
if (isset($_POST['confirmation'])) {
|
if (isset($_POST['confirmation'])) {
|
||||||
|
|
||||||
// Define expiration date
|
// Define expiration date
|
||||||
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
||||||
|
|
||||||
if (!empty($enddate)) {
|
if (!empty($enddate)) {
|
||||||
$registredate = explode('/', $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]);
|
$time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
|
||||||
|
|
||||||
if ($time < $min_expiry_time) {
|
if ($time < $min_expiry_time) {
|
||||||
@ -89,7 +86,6 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
|||||||
$poll_id = $ids[0];
|
$poll_id = $ids[0];
|
||||||
$admin_poll_id = $ids[1];
|
$admin_poll_id = $ids[1];
|
||||||
|
|
||||||
|
|
||||||
// Send confirmation by mail if enabled
|
// Send confirmation by mail if enabled
|
||||||
if ($config['use_smtp'] === true) {
|
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.");
|
$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
|
// Redirect to poll administration
|
||||||
header('Location:' . Utils::getUrlSondage($admin_poll_id, true));
|
header('Location:' . Utils::getUrlSondage($admin_poll_id, true));
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
} // Step 3/4 : Confirm poll creation and choose a removal date
|
} // Step 3/4 : Confirm poll creation and choose a removal date
|
||||||
else if (isset($_POST['fin_sondage_autre'])) {
|
else if (isset($_POST['fin_sondage_autre'])) {
|
||||||
|
|
||||||
// Store choices in $_SESSION
|
// Store choices in $_SESSION
|
||||||
if (isset($_POST['choices'])) {
|
if (isset($_POST['choices'])) {
|
||||||
$_SESSION['form']->clearChoices();
|
$_SESSION['form']->clearChoices();
|
||||||
@ -137,30 +131,21 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
|||||||
// Summary
|
// Summary
|
||||||
$summary = '<ol>';
|
$summary = '<ol>';
|
||||||
foreach ($_SESSION['form']->getChoices() as $i=>$choice) {
|
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_a_img); // Markdown [![alt](src)](href)
|
||||||
preg_match_all('/!\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_img); // Markdown ![alt](src)
|
preg_match_all('/!\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_img); // Markdown ![alt](src)
|
||||||
preg_match_all('/\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_a); // Markdown [text](href)
|
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)
|
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_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>';
|
$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)
|
||||||
} 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_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 . '" />';
|
$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)
|
||||||
} 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_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>';
|
$li_subject_html = '<a href="' . $md_a[2][0] . '">' . $li_subject_text . '</a>';
|
||||||
|
|
||||||
} else { // text only
|
} else { // text only
|
||||||
|
|
||||||
$li_subject_text = stripslashes($choice->getName());
|
$li_subject_text = stripslashes($choice->getName());
|
||||||
$li_subject_html = $li_subject_text;
|
$li_subject_html = $li_subject_text;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$summary .= '<li>' . $li_subject_html . '</li>' . "\n";
|
$summary .= '<li>' . $li_subject_html . '</li>' . "\n";
|
||||||
@ -262,6 +247,5 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
|||||||
' . "\n";
|
' . "\n";
|
||||||
|
|
||||||
bandeau_pied();
|
bandeau_pied();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -66,7 +66,6 @@ switch ($step) {
|
|||||||
$smarty->display('error.tpl');
|
$smarty->display('error.tpl');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// Step 2/4 : Select dates of the poll
|
// Step 2/4 : Select dates of the poll
|
||||||
|
|
||||||
@ -95,7 +94,6 @@ switch ($step) {
|
|||||||
$smarty->display('create_date_poll_step_2.tpl');
|
$smarty->display('create_date_poll_step_2.tpl');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Step 3/4 : Confirm poll creation
|
// Step 3/4 : Confirm poll creation
|
||||||
|
|
||||||
@ -121,7 +119,7 @@ switch ($step) {
|
|||||||
$_SESSION['form']->clearChoices();
|
$_SESSION['form']->clearChoices();
|
||||||
|
|
||||||
// Reorder moments to deal with suppressed dates
|
// Reorder moments to deal with suppressed dates
|
||||||
$moments = array();
|
$moments = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while(count($moments) < count($_POST['days'])) {
|
while(count($moments) < count($_POST['days'])) {
|
||||||
if (!empty($_POST['horaires' . $i])) {
|
if (!empty($_POST['horaires' . $i])) {
|
||||||
@ -130,7 +128,6 @@ switch ($step) {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for ($i = 0; $i < count($_POST['days']); $i++) {
|
for ($i = 0; $i < count($_POST['days']); $i++) {
|
||||||
$day = $_POST['days'][$i];
|
$day = $_POST['days'][$i];
|
||||||
|
|
||||||
@ -178,18 +175,16 @@ switch ($step) {
|
|||||||
$smarty->display('create_classic_poll_step3.tpl');
|
$smarty->display('create_classic_poll_step3.tpl');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
// Step 4 : Data prepare before insert in DB
|
// Step 4 : Data prepare before insert in DB
|
||||||
|
|
||||||
// Define expiration date
|
// Define expiration date
|
||||||
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
||||||
|
|
||||||
|
|
||||||
if (!empty($enddate)) {
|
if (!empty($enddate)) {
|
||||||
$registredate = explode('/', $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]);
|
$time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
|
||||||
|
|
||||||
if ($time < $min_expiry_time) {
|
if ($time < $min_expiry_time) {
|
||||||
@ -212,7 +207,6 @@ switch ($step) {
|
|||||||
$poll_id = $ids[0];
|
$poll_id = $ids[0];
|
||||||
$admin_poll_id = $ids[1];
|
$admin_poll_id = $ids[1];
|
||||||
|
|
||||||
|
|
||||||
// Send confirmation by mail if enabled
|
// Send confirmation by mail if enabled
|
||||||
if ($config['use_smtp'] === true) {
|
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.");
|
$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';
|
const GO_TO_STEP_2 = 'gotostep2';
|
||||||
|
|
||||||
|
|
||||||
/* Services */
|
/* Services */
|
||||||
/*----------*/
|
/*----------*/
|
||||||
|
|
||||||
@ -42,8 +41,8 @@ if (!isset($_SESSION['form'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Type de sondage
|
// Type de sondage
|
||||||
if (isset($_GET['type']) && $_GET['type'] == 'date' ||
|
if (isset($_GET['type']) && $_GET['type'] === 'date' ||
|
||||||
isset($_POST['type']) && $_POST['type'] == 'date'
|
isset($_POST['type']) && $_POST['type'] === 'date'
|
||||||
) {
|
) {
|
||||||
$poll_type = 'date';
|
$poll_type = 'date';
|
||||||
$_SESSION['form']->choix_sondage = $poll_type;
|
$_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) {
|
if ($goToStep2) {
|
||||||
$title = $inputService->filterTitle($_POST['title']);
|
$title = $inputService->filterTitle($_POST['title']);
|
||||||
$use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false;
|
$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']);
|
$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']);
|
$description = $inputService->filterDescription($_POST['description']);
|
||||||
$editable = $inputService->filterEditable($_POST['editable']);
|
$editable = $inputService->filterEditable($_POST['editable']);
|
||||||
$receiveNewVotes = isset($_POST['receiveNewVotes']) ? $inputService->filterBoolean($_POST['receiveNewVotes']) : false;
|
$receiveNewVotes = isset($_POST['receiveNewVotes']) ? $inputService->filterBoolean($_POST['receiveNewVotes']) : false;
|
||||||
@ -92,8 +91,7 @@ if ($goToStep2) {
|
|||||||
$_SESSION['form']->use_password = ($use_password !== null);
|
$_SESSION['form']->use_password = ($use_password !== null);
|
||||||
$_SESSION['form']->results_publicly_visible = ($results_publicly_visible !== null);
|
$_SESSION['form']->results_publicly_visible = ($results_publicly_visible !== null);
|
||||||
|
|
||||||
|
if ($config['use_smtp'] === true) {
|
||||||
if ($config['use_smtp'] == true) {
|
|
||||||
if (empty($mail)) {
|
if (empty($mail)) {
|
||||||
$error_on_mail = true;
|
$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
|
// 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;
|
$email_OK = $mail && !$error_on_mail;
|
||||||
} else {
|
} else {
|
||||||
$email_OK = true;
|
$email_OK = true;
|
||||||
@ -130,7 +128,7 @@ if ($goToStep2) {
|
|||||||
if ($use_password) {
|
if ($use_password) {
|
||||||
if (empty($password)) {
|
if (empty($password)) {
|
||||||
$error_on_password = true;
|
$error_on_password = true;
|
||||||
} else if ($password != $password_repeat) {
|
} else if ($password !== $password_repeat) {
|
||||||
$error_on_password_repeat = true;
|
$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
|
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
|
&& !$error_on_password && !$error_on_password_repeat
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// If no errors, we hash the password if needed
|
// If no errors, we hash the password if needed
|
||||||
if ($_SESSION['form']->use_password) {
|
if ($_SESSION['form']->use_password) {
|
||||||
$_SESSION['form']->password_hash = PasswordHasher::hash($password);
|
$_SESSION['form']->password_hash = PasswordHasher::hash($password);
|
||||||
@ -147,16 +144,15 @@ if ($goToStep2) {
|
|||||||
$_SESSION['form']->results_publicly_visible = null;
|
$_SESSION['form']->results_publicly_visible = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($goToStep2 == 'date') {
|
if ($goToStep2 === 'date') {
|
||||||
header('Location:create_date_poll.php');
|
header('Location:create_date_poll.php');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($goToStep2 == 'classic') {
|
if ($goToStep2 === 'classic') {
|
||||||
header('Location:create_classic_poll.php');
|
header('Location:create_classic_poll.php');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Title Erreur !
|
// Title Erreur !
|
||||||
$title = __('Error', 'Error!') . ' - ' . __('Step 1', 'Poll creation (1 on 3)');
|
$title = __('Error', 'Error!') . ' - ' . __('Step 1', 'Poll creation (1 on 3)');
|
||||||
@ -167,43 +163,43 @@ if ($goToStep2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare error messages
|
// Prepare error messages
|
||||||
$errors = array(
|
$errors = [
|
||||||
'title' => array(
|
'title' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
),
|
],
|
||||||
'customized_url' => array(
|
'customized_url' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
),
|
],
|
||||||
'description' => array(
|
'description' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
),
|
],
|
||||||
'name' => array(
|
'name' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
),
|
],
|
||||||
'email' => array(
|
'email' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
),
|
],
|
||||||
'password' => array(
|
'password' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
),
|
],
|
||||||
'password_repeat' => array(
|
'password_repeat' => [
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
'aria' => '',
|
'aria' => '',
|
||||||
'class' => ''
|
'class' => ''
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
if (!empty($_POST[GO_TO_STEP_2])) {
|
if (!empty($_POST[GO_TO_STEP_2])) {
|
||||||
if (empty($_POST['title'])) {
|
if (empty($_POST['title'])) {
|
||||||
|
@ -43,7 +43,7 @@ if (!empty($_POST['mail'])) {
|
|||||||
$smarty->assign('polls', $polls);
|
$smarty->assign('polls', $polls);
|
||||||
$body = $smarty->fetch('mail/find_polls.tpl');
|
$body = $smarty->fetch('mail/find_polls.tpl');
|
||||||
|
|
||||||
$mailService->send($mail, __('FindPolls', 'List of your polls').' - '.NOMAPPLICATION, $body, 'SEND_POLLS');
|
$mailService->send($mail, __('FindPolls', 'List of your polls') . ' - ' . NOMAPPLICATION, $body, 'SEND_POLLS');
|
||||||
$message = new Message('success', __('FindPolls', 'Polls sent'));
|
$message = new Message('success', __('FindPolls', 'Polls sent'));
|
||||||
} else {
|
} else {
|
||||||
$message = new Message('warning', __('Error', 'No polls found'));
|
$message = new Message('warning', __('Error', 'No polls found'));
|
||||||
@ -53,7 +53,6 @@ if (!empty($_POST['mail'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$smarty->assign('title', __('Homepage', 'Where are my polls'));
|
$smarty->assign('title', __('Homepage', 'Where are my polls'));
|
||||||
$smarty->assign('message', $message);
|
$smarty->assign('message', $message);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ function rcopy($src, $dst) {
|
|||||||
@mkdir($dst);
|
@mkdir($dst);
|
||||||
$copied = true;
|
$copied = true;
|
||||||
while (false !== ($file = readdir($dir))) {
|
while (false !== ($file = readdir($dir))) {
|
||||||
if (($file != '.') && ($file != '..')) {
|
if (($file !== '.') && ($file !== '..')) {
|
||||||
if (is_dir($src . '/' . $file)) {
|
if (is_dir($src . '/' . $file)) {
|
||||||
$copied &= rcopy($src . '/' . $file, $dst . '/' . $file);
|
$copied &= rcopy($src . '/' . $file, $dst . '/' . $file);
|
||||||
} else {
|
} else {
|
||||||
@ -47,7 +47,7 @@ function rcopy($src, $dst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rrmdir($dir) {
|
function rrmdir($dir) {
|
||||||
$files = array_diff(scandir($dir), array('.', '..'));
|
$files = array_diff(scandir($dir), ['.', '..']);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
(is_dir("$dir/$file")) ? rrmdir("$dir/$file") : unlink("$dir/$file");
|
(is_dir("$dir/$file")) ? rrmdir("$dir/$file") : unlink("$dir/$file");
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ function zip($source, $destination) {
|
|||||||
if (is_dir($source)) {
|
if (is_dir($source)) {
|
||||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
|
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (in_array(basename($file), array('.', '..'))) {
|
if (in_array(basename($file), ['.', '..'], true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$file = realpath($file);
|
$file = realpath($file);
|
||||||
@ -155,15 +155,15 @@ i($result->autoload, 'autoload');
|
|||||||
// Copy assets
|
// Copy assets
|
||||||
|
|
||||||
d('# Assets');
|
d('# Assets');
|
||||||
copyFiles(array('css', 'fonts', 'images', 'js'), $result);
|
copyFiles(['css', 'fonts', 'images', 'js'], $result);
|
||||||
|
|
||||||
// Copy sources
|
// Copy sources
|
||||||
|
|
||||||
d('# Source directories');
|
d('# Source directories');
|
||||||
copyFiles(array('admin', 'app', 'locale', 'tpl'), $result);
|
copyFiles(['admin', 'app', 'locale', 'tpl'], $result);
|
||||||
|
|
||||||
d('# Source files');
|
d('# Source files');
|
||||||
$files = array(
|
$files = [
|
||||||
'adminstuds.php',
|
'adminstuds.php',
|
||||||
'bandeaux.php',
|
'bandeaux.php',
|
||||||
'create_classic_poll.php',
|
'create_classic_poll.php',
|
||||||
@ -181,7 +181,7 @@ $files = array(
|
|||||||
'README.md',
|
'README.md',
|
||||||
'robots.txt',
|
'robots.txt',
|
||||||
'studs.php'
|
'studs.php'
|
||||||
);
|
];
|
||||||
copyFiles($files, $result);
|
copyFiles($files, $result);
|
||||||
|
|
||||||
// Zip Dist
|
// 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 STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||||
*/
|
*/
|
||||||
|
use Framadate\Editable;
|
||||||
use Framadate\Exception\AlreadyExistsException;
|
use Framadate\Exception\AlreadyExistsException;
|
||||||
use Framadate\Exception\ConcurrentEditionException;
|
use Framadate\Exception\ConcurrentEditionException;
|
||||||
use Framadate\Services\LogService;
|
use Framadate\Message;
|
||||||
use Framadate\Services\PollService;
|
use Framadate\Security\Token;
|
||||||
use Framadate\Services\InputService;
|
use Framadate\Services\InputService;
|
||||||
|
use Framadate\Services\LogService;
|
||||||
use Framadate\Services\MailService;
|
use Framadate\Services\MailService;
|
||||||
use Framadate\Services\NotificationService;
|
use Framadate\Services\NotificationService;
|
||||||
|
use Framadate\Services\PollService;
|
||||||
use Framadate\Services\SecurityService;
|
use Framadate\Services\SecurityService;
|
||||||
use Framadate\Services\SessionService;
|
use Framadate\Services\SessionService;
|
||||||
use Framadate\Message;
|
|
||||||
use Framadate\Utils;
|
use Framadate\Utils;
|
||||||
use Framadate\Editable;
|
|
||||||
use Framadate\Security\Token;
|
|
||||||
|
|
||||||
include_once __DIR__ . '/app/inc/init.php';
|
include_once __DIR__ . '/app/inc/init.php';
|
||||||
|
|
||||||
@ -37,7 +37,6 @@ include_once __DIR__ . '/app/inc/init.php';
|
|||||||
|
|
||||||
const USER_REMEMBER_VOTES_KEY = 'UserVotes';
|
const USER_REMEMBER_VOTES_KEY = 'UserVotes';
|
||||||
|
|
||||||
|
|
||||||
/* Variables */
|
/* Variables */
|
||||||
/* --------- */
|
/* --------- */
|
||||||
|
|
||||||
@ -47,9 +46,9 @@ $message = null;
|
|||||||
$editingVoteId = 0;
|
$editingVoteId = 0;
|
||||||
$accessGranted = true;
|
$accessGranted = true;
|
||||||
$resultPubliclyVisible = true;
|
$resultPubliclyVisible = true;
|
||||||
$slots = array();
|
$slots = [];
|
||||||
$votes = array();
|
$votes = [];
|
||||||
$comments = array();
|
$comments = [];
|
||||||
|
|
||||||
/* Services */
|
/* Services */
|
||||||
/*----------*/
|
/*----------*/
|
||||||
@ -62,7 +61,6 @@ $notificationService = new NotificationService($mailService);
|
|||||||
$securityService = new SecurityService();
|
$securityService = new SecurityService();
|
||||||
$sessionService = new SessionService();
|
$sessionService = new SessionService();
|
||||||
|
|
||||||
|
|
||||||
/* PAGE */
|
/* PAGE */
|
||||||
/* ---- */
|
/* ---- */
|
||||||
|
|
||||||
@ -84,7 +82,6 @@ $editedVoteUniqueId = $sessionService->get(USER_REMEMBER_VOTES_KEY, $poll_id, ''
|
|||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
if (!is_null($poll->password_hash)) {
|
if (!is_null($poll->password_hash)) {
|
||||||
|
|
||||||
// If we came from password submission
|
// If we came from password submission
|
||||||
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
||||||
if (!empty($password)) {
|
if (!empty($password)) {
|
||||||
@ -107,7 +104,6 @@ if (!is_null($poll->password_hash)) {
|
|||||||
|
|
||||||
// We allow actions only if access is granted
|
// We allow actions only if access is granted
|
||||||
if ($accessGranted) {
|
if ($accessGranted) {
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// A vote is going to be edited
|
// A vote is going to be edited
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
@ -129,16 +125,16 @@ if ($accessGranted) {
|
|||||||
if (empty($editedVote)) {
|
if (empty($editedVote)) {
|
||||||
$message = new Message('danger', __('Error', 'Something is going wrong...'));
|
$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'));
|
$message = new Message('danger', __('Error', 'There is a problem with your choices'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($message == null) {
|
if ($message === null) {
|
||||||
// Update vote
|
// Update vote
|
||||||
try {
|
try {
|
||||||
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices, $slots_hash);
|
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices, $slots_hash);
|
||||||
if ($result) {
|
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]]);
|
$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);
|
$message = getMessageForOwnVoteEditableVote($sessionService, $smarty, $editedVoteUniqueId, $config['use_smtp'], $poll_id, $name);
|
||||||
} else {
|
} else {
|
||||||
@ -157,19 +153,19 @@ if ($accessGranted) {
|
|||||||
$choices = $inputService->filterArray($_POST['choices'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => CHOICE_REGEX]]);
|
$choices = $inputService->filterArray($_POST['choices'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => CHOICE_REGEX]]);
|
||||||
$slots_hash = $inputService->filterMD5($_POST['control']);
|
$slots_hash = $inputService->filterMD5($_POST['control']);
|
||||||
|
|
||||||
if ($name == null) {
|
if ($name === null) {
|
||||||
$message = new Message('danger', __('Error', 'The name is invalid.'));
|
$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'));
|
$message = new Message('danger', __('Error', 'There is a problem with your choices'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($message == null) {
|
if ($message === null) {
|
||||||
// Add vote
|
// Add vote
|
||||||
try {
|
try {
|
||||||
$result = $pollService->addVote($poll_id, $name, $choices, $slots_hash);
|
$result = $pollService->addVote($poll_id, $name, $choices, $slots_hash);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
if ($poll->editable === Editable::EDITABLE_BY_OWN) {
|
||||||
$editedVoteUniqueId = $result->uniqId;
|
$editedVoteUniqueId = $result->uniqId;
|
||||||
$message = getMessageForOwnVoteEditableVote($sessionService, $smarty, $editedVoteUniqueId, $config['use_smtp'], $poll_id, $name);
|
$message = getMessageForOwnVoteEditableVote($sessionService, $smarty, $editedVoteUniqueId, $config['use_smtp'], $poll_id, $name);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user