Commit 64c3cc0e authored by Patrick Barroca's avatar Patrick Barroca 😠
Browse files

Merge branch 'hotline' into 'master'

Hotline

See merge request !3390
parents ccd057eb 1a8571c0
Pipeline #9320 passed with stage
in 81 minutes and 45 seconds
06/02/2020 - v8.0.41
- ticket #105040 : Articles / Formulaires : Correction de la détection des robot pour des formulaires ayant des noms d'input contenant des espaces, des tirets bas et des crochets droits
- ticket #105091 : Performance : Correction de la perte de performance suite à la livraison des nouveaux groupes dynamiques
03/02/2020 - v8.0.40
- ticket #101015 : Articles / Formulaires : Amélioration de la détection des robots
......
......@@ -56,7 +56,14 @@ class FormulaireController extends ZendAfi_Controller_Action {
$article->getContenu(),
$all_inputs);
if (array_diff(array_keys($post), $all_inputs[1]))
$clean_input = array_map(function($input)
{
return str_replace(['.',' ','['],
'_',
$input);
},
$all_inputs[1]);
if (array_diff(array_keys($post), $clean_input))
return true;
return false;
......
......@@ -22,6 +22,17 @@
class UserGroupLoader extends Storm_Model_Loader {
use Trait_MemoryCleaner;
protected $_dynamics_of_user_cache = [];
public function save($model) {
$result = parent::save($model);
if ($model->isDynamic())
$this->_dynamics_of_user_cache = [];
return $result;
}
public function getUsersIdsOf($group) {
$ids = [];
......@@ -99,6 +110,23 @@ class UserGroupLoader extends Storm_Model_Loader {
public function findAllDynamics() {
return Class_UserGroup::findAllBy(['group_type' => Class_UserGroup::TYPE_DYNAMIC]);
}
public function findAllDynamicsOf($user) {
if ($user->isNew())
return $this->_realFindAllDynamicsOf($user);
$key = $user->getId();
return array_key_exists($key, $this->_dynamics_of_user_cache)
? $this->_dynamics_of_user_cache[$key]
: ($this->_dynamics_of_user_cache[$key] = $this->_realFindAllDynamicsOf($user));
}
protected function _realFindAllDynamicsOf($user) {
return array_filter(Class_UserGroup::findAllDynamics(),
function($group) use($user) { return $group->hasUser($user); });
}
}
......
......@@ -827,8 +827,7 @@ class Class_Users extends Storm_Model_Abstract {
public function getDynamicUserGroups() {
return array_filter(Class_UserGroup::findAllDynamics(),
function($group) { return $group->hasUser($this); });
return Class_UserGroup::findAllDynamicsOf($this);
}
......
......@@ -81,7 +81,7 @@ class Bokeh_Engine {
function setupConstants() {
defineConstant('BOKEH_MAJOR_VERSION','8.0');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.40');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.41');
defineConstant('BOKEH_REMOTE_FILES', 'https://git.afi-sa.net/afi/opacce/');
......
......@@ -28,6 +28,8 @@ abstract class AbstractAbonneControllerFicheTest extends AbstractControllerTestC
$this->fixture('Class_Bib', ['id' => 1]);
$this->fixture('Class_Bib', ['id' => 2]);
$this->onLoaderOfModel('Class_UserGroup');
$this->marcus = $this->fixture('Class_Users',
['id' => 10,
'login' => 'MC',
......@@ -121,11 +123,18 @@ class AbonneControllerFicheAsAbonneTest extends AbstractAbonneControllerFicheTes
$this->assertXPathContentContains('//div[@class="abonneTitre"]//span[@data-name="last-name"]', 'Miller');
}
/** @test */
public function LoansHistoryShouldNotBeDisplayed() {
$this->assertNotXPathContentContains('//a', 'Voir mon historique de prêts');
}
// @see http://forge.afi-sa.fr/issues/105091
/** @test */
public function callToFindAllDynamicsShouldBeDoneOnlyOnce() {
$this->assertEquals(1, Class_UserGroup::methodCallCount('findAllDynamics'));
}
}
......
......@@ -31,6 +31,10 @@ abstract class FormulaireControllerPostActionTestCase extends AbstractController
'contenu' => '<form action="/formulaire/add/id_article/45" method="POST" name="Nous écrire">'
. '<p>Votre nom<input name="nom" type="text" /></p>'
. '<p>Votre prénom<input name="prenom" type="text" /></p>'
. '<p><input name="Dejeuner" required="required" type="radio" value="libre">Libre</p>'
. '<p><input name="Dejeuner" required="required" type="radio" value="Restaurant">Restaurant avec le groupe (sur réservation)</p>'
. '<p><input name="option1" type="checkbox" value="wifi">Wifi</p>'
. '<p><input name="option2" type="checkbox" value="piscine">Piscine</p>'
. '</form>']);
$this->fixture('Class_Formulaire',
['id' => 1,
......@@ -237,6 +241,107 @@ class FormulaireControllerPostAsBotTest extends FormulaireControllerPostActionTe
$this->assertRedirectTo('/');
}
/** @test */
public function withValidDataShouldCreateANewForm() {
$this->postDispatch('/formulaire/add/id_article/45',
['nom' => 'Tinguette' ,
'prenom' => 'Quentin',
'Dejeuner' => 'libre',
'option1' => 'cafe',
'option2' => 'wifi',
'website' => ''],
true);
$this->assertNotRedirectTo('/');
}
}
class FormulaireControllerPostActionDebugTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_Article::newInstanceWithId(45, ['titre' => 'Contactez nous',
'contenu' => '<form action="/arthur/formulaire/add/id_article/1618" method="POST">
<p><input name="Inscription Journée Bokeh 2 avril Talence" type="hidden" value="Inscription Journée Bokeh 2 avril Talence" />Nom, Pr&eacute;nom<br />
<input data-tc-id="w-0.29026469748912975" name="Nom, Prénom" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse mail<br />
<input data-tc-id="w-0.07789243529520828" name="Mail" required="required" tc-textcontent="true" type="email" /></p>
<p>Etablissement<br />
<input data-tc-id="w-0.0005608611335192748" name="Etablissement" required="required" tc-textcontent="true" type="text" /></p>
<p>SIGB (Nanook, Koha, PNB, Orph&eacute;e NX etc....)<br />
<input data-tc-id="w-0.8095451597979981" name="SIGB" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse de votre portail Bokeh (url en http/s)<br />
<input data-tc-id="w-0.20741370069209997" name="Site Web" tc-textcontent="true" type="url" /></p>
<p>D&eacute;jeuner</p>
<p><input data-tc-id="w-0.4082287663760651" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="libre" />Libre</p>
<p><input data-tc-id="w-0.46758368222915037" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="Restaurant" />Restaurant avec le groupe (sur r&eacute;servation)</p>
<p>&nbsp;</p>
<p><input data-tc-id="w-0.42382856730050433" tc-textcontent="true" type="submit" value="Envoyer" /></p>
<input autocomplete="off" data-spambots="true" data-tc-id="w-0.997230006041362" name="website" tc-textcontent="true" type="text" />&nbsp;</form>
<form action="/arthur/formulaire/add/id_article/1618" method="POST">
<p><input name="Inscription Journée Bokeh 2 avril Talence" type="hidden" value="Inscription Journée Bokeh 2 avril Talence" />Nom, Pr&eacute;nom<br />
<input data-tc-id="w-0.29026469748912975" name="Nom, Prénom" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse mail<br />
<input data-tc-id="w-0.07789243529520828" name="Mail" required="required" tc-textcontent="true" type="email" /></p>
<p>Etablissement<br />
<input data-tc-id="w-0.0005608611335192748" name="Etablissement" required="required" tc-textcontent="true" type="text" /></p>
<p>SIGB (Nanook, Koha, PNB, Orph&eacute;e NX etc....)<br />
<input data-tc-id="w-0.8095451597979981" name="SIGB" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse de votre portail Bokeh (url en http/s)<br />
<input data-tc-id="w-0.20741370069209997" name="Site Web" tc-textcontent="true" type="url" /></p>
<p>D&eacute;jeuner</p>
<p><input data-tc-id="w-0.4082287663760651" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="libre" />Libre</p>
<p><input data-tc-id="w-0.46758368222915037" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="Restaurant" />Restaurant avec le groupe (sur r&eacute;servation)</p>
<p>&nbsp;</p>
<p><input data-tc-id="w-0.42382856730050433" tc-textcontent="true" type="submit" value="Envoyer" /></p>
<input autocomplete="off" data-spambots="true" data-tc-id="w-0.997230006041362" name="website" tc-textcontent="true" type="text" />&nbsp;</form>
']);
$this->postDispatch('/formulaire/add/id_article/45',
[
'Inscription_Journée_Bokeh_2_avril_Talence' => 'Inscription Journée Bokeh 2 avril Talence',
'Nom,_Prénom' => 'Suzuki',
'Mail' => 'arthur.suzuki@free.fr',
'Etablissement' => 'AFI',
'SIGB' => 'koha',
'Site_Web' => 'http://sandbox.afi-sa.fr/arthur/cms/articleview/id/1618',
'Dejeuner' => 'libre',
'website' => ''
],
true);
}
/** @test */
public function responseShouldNotRedirect() {
$this->assertNotRedirectTo('/');
}
}
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment