Commit 662e89bf authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge remote-tracking branch 'refs/remotes/origin/master' into...

Merge remote-tracking branch 'refs/remotes/origin/master' into origin-dev#72825_contractuel_bdp64__afficher_la_colonne_reserve_par_d_autres
parents fef1114c 0cd609aa
Pipeline #4424 failed with stage
in 29 minutes and 57 seconds
18/06/2018 - v7.12.23
- ticket 76302: mise à jour des traductions Espagnoles et Catalanes
- ticket #76258 : Matomo : correction de la lecture des indentifiants dans le coode d'intégration Javascript qui se trouve dans JS_STAT.
- ticket #75603 : Administration : Les critères de détection des doublons utilisateurs sont désormais paramétrables
07/06/2018 - v7.12.22
- ticket #75970 : Abonné : Pré-inscription Nanook : ajout de contre-mesures antispam
......
......@@ -236,7 +236,10 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'DISABLE_SUGGESTIONS' => Class_AdminVar_Meta::newOnOff($this->_('Désactivation des suggestions d\'achats'))->bePrivate(),
'ENABLE_BOOKMARKABLE_LIBRARIES' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent sélectionner des bibliothèques favorites pour leurs recherche'), ['value' => 1]),
'ENABLE_BOOKMARKABLE_SEARCHES' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent enregister des recherches dans leurs favoris'), ['value' => 0]),
'ENABLE_BOOKMARKABLE_SEARCHES_NOTIFY' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent recevoir les nouveautés de leurs recherches favorites par email'), ['value' => 0])];
'ENABLE_BOOKMARKABLE_SEARCHES_NOTIFY' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent recevoir les nouveautés de leurs recherches favorites par email'), ['value' => 0]),
Class_AdminVar_UserDoubleDetectOn::KEY => Class_AdminVar_Meta::newMultiInput($this->_('Champs servant à la détection des doublons. Champs possibles : %s', (new Class_AdminVar_UserDoubleDetectOn)->knownAsList()),
['validate' => 'ZendAfi_Validate_UserDoubleDetectOn'])->bePrivate(),
];
}
......
......@@ -73,6 +73,6 @@ class Class_AdminVar_JsStat {
public function getPiwikSiteId() {
$script = Class_AdminVar::get('JS_STAT');
preg_match_all("/setSiteId\',([^\]]+)\]\)/i", $script, $matches);
return isset($matches[1][0]) ? trim($matches[1][0]) : '';
return isset($matches[1][0]) ? trim($matches[1][0], " \t\n\r\0\x0B'\"") : '';
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_AdminVar_UserDoubleDetectOn {
use Trait_Translator;
const KEY = 'USER_DOUBLE_DETECT_ON';
protected static $_known = [];
protected $_defaults = ['login', 'idabon', 'ordreabon', 'password'];
public function isKnown($value) {
return in_array($value, array_keys($this->_getKnown()));
}
public function knownAsList() {
$map = $this->_getKnown();
$value = [];
foreach($map as $k => $v)
$value[] = $v . ' : ' . $k;
return '<ul><li>' . implode('</li><li>', $value) . '</li></ul>';
}
public function getCurrent() {
$values = array_filter(explode(';', Class_AdminVar::get(static::KEY)));
if (!$values)
return $this->_defaults;
$values = array_filter($values, [$this, 'isKnown']);
return $values ? $values : $this->_defaults;
}
protected function _getKnown() {
if (static::$_known)
return static::$_known;
return static::$_known = ['nom' => $this->_('Nom'),
'prenom' => $this->_('Prénom'),
'naissance' => $this->_('Date de naissance'),
'id_site' => $this->_('Site de rattachement'),
'login' => $this->_('Login'),
'password' => $this->_('Mot de passe'),
'idabon' => $this->_('Numéro de carte'),
'ordreabon' => $this->_('Numéro d\'ordre sur la carte'),
'mail' => $this->_('Mail'),
'date_debut' => $this->_('Date de début d\'abonnement'),
'date_fin' => $this->_('Date de fin d\'abonnement'),
'id_sigb' => $this->_('Identifiant dans le SIGB'),
'telephone' => $this->_('Téléphone'),
'adresse' => $this->_('Adresse'),
'code_postal' => $this->_('Code postal'),
'ville' => $this->_('Ville'),];
}
}
......@@ -24,10 +24,15 @@ class Class_User_DbDoubleFinder {
const LIMIT_DEDUPE = 10;
public function getRequest($cursor = 0) {
return sprintf('select min(id_user) as id_user, password, login, idabon, ordreabon, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > %s group by idabon, ordreabon, login, password having doublon > 1 order by id_user asc',
$cursor);
$fields = implode(', ', $this->_getFields());
return sprintf('select min(id_user) as id_user, %s, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > %s group by %s having doublon > 1 order by id_user asc',
$fields, $cursor, $fields);
}
protected function _getFields() {
return (new Class_AdminVar_UserDoubleDetectOn)->getCurrent();
}
......@@ -54,10 +59,11 @@ class Class_User_DbDoubleFinder {
public function findDoubleFor($user) {
return $this->_findUsersWithParams($user->getIdabon(),
$user->getLogin(),
$user->getOrdreabon(),
$user->getPassword());
$params = [];
foreach($this->_getFields() as $field)
$params[$field] = $user->callGetterByAttributeName($field);
return Class_Users::findAllBy($params);
}
......@@ -142,18 +148,11 @@ class Class_User_DbDoubleFinder {
protected function _findUsersFromDouble($data) {
return $this->_findUsersWithParams($data['idabon'],
$data['login'],
$data['ordreabon'],
$data['password']);
}
$params = [];
foreach($this->_getFields() as $field)
$params[$field] = $data[$field];
protected function _findUsersWithParams($idabon, $login, $ordreabon, $password) {
return Class_Users::findAllBy(['idabon' => $idabon,
'password' => $password,
'login' => $login,
'ordreabon' => $ordreabon]);
return Class_Users::findAllBy($params);
}
......
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Validate_UserDoubleDetectOn extends Zend_Validate_Abstract {
const NOT_KNOWN = 'notKnown';
protected $_messageTemplates =
[self::NOT_KNOWN => 'Le champ "%field%" n\'est pas parmi les champs possibles'];
protected $_messageVariables = ['field' => '_field'];
protected $_field;
public function isValid($value, $context = null) {
$parts = explode(';', $value);
foreach($parts as $part)
if (!$this->_validOne($part)) {
$this->_error(static::NOT_KNOWN);
return false;
}
return true;
}
protected function _validOne($value) {
if ('' == $value)
return true;
$this->_field = $value;
return (new Class_AdminVar_UserDoubleDetectOn())
->isKnown($value);
}
}
......@@ -81,7 +81,7 @@ class Bokeh_Engine {
function setupConstants() {
defineConstant('BOKEH_MAJOR_VERSION','7.12');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.22');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.23');
defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/');
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -441,14 +441,14 @@ class Admin_IndexControllerAdminvarActionTest extends Admin_AbstractControllerTe
public function setUp() {
parent::setUp();
$disk = Storm_Test_ObjectWrapper::mock()
->whenCalled('diskSpaceInfo')
->answers((new Class_Entity)
->setFree('0 o')
->setUsed('10 Mo')
->setTotal('5 Mo')
->setPercent('150%')
->whenCalledDo('isFull', function(){return true;}));
$disk = $this->mock()
->whenCalled('diskSpaceInfo')
->answers((new Class_Entity)
->setFree('0 o')
->setUsed('10 Mo')
->setTotal('5 Mo')
->setPercent('150%')
->whenCalledDo('isFull', function(){return true;}));
Class_FileManager::setFileSystem($disk);
......
......@@ -99,7 +99,7 @@ class UsersControllerIndexTest extends UsersControllerWithMarcusTestCase {
Zend_Registry::set('sql', $this->mock()
->whenCalled('fetchAll')
->with('select min(id_user) as id_user, password, login, idabon, ordreabon, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > 0 group by idabon, ordreabon, login, password having doublon > 1 order by id_user asc')
->with('select min(id_user) as id_user, login, idabon, ordreabon, password, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > 0 group by login, idabon, ordreabon, password having doublon > 1 order by id_user asc')
->answers([])
->whenCalled('fetchAll')
......@@ -1255,7 +1255,7 @@ abstract class UsersControllerDoubleTestCase extends Admin_AbstractControllerTes
$mock_sql =
$this->mock()
->whenCalled('fetchAll')
->with('select min(id_user) as id_user, password, login, idabon, ordreabon, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > 0 group by idabon, ordreabon, login, password having doublon > 1 order by id_user asc')
->with('select min(id_user) as id_user, login, idabon, ordreabon, password, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > 0 group by login, idabon, ordreabon, password having doublon > 1 order by id_user asc')
->answers([
['id_user' => '25',
'login' => 'Ret',
......@@ -1529,6 +1529,33 @@ class UsersControllerManageDoubleTest extends UsersControllerDoubleTestCase {
class UsersControllerManageDoubleWithCustomCriteriaTest extends UsersControllerDoubleTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::set('USER_DOUBLE_DETECT_ON', 'id_sigb');
Zend_Registry::get('sql')
->whenCalled('fetchAll')
->with('select min(id_user) as id_user, id_sigb, count(*) as doublon from bib_admin_users where role_level = 2 and id_user > 0 group by id_sigb having doublon > 1 order by id_user asc')
->answers([
['id_user' => '25',
'id_sigb' => '5',
'doublon' => '2'],
]);
$this->dispatch('/admin/users/manage-double', true);
}
/** @test */
public function oneDoubleAccountsShouldBeFound() {
$this->assertXPathContentContains('//p', 'Vous avez <b>1</b> comptes abonnés possédant au moins un doublon',$this->_response->getBody());
}
}
class UsersControllerDeleteDoubleEndCursorTest extends Admin_AbstractControllerTestCase {
public function setUp() {
......
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