Skip to content
Snippets Groups Projects
Commit 5fbb3892 authored by Laurent's avatar Laurent
Browse files

hotline#26157: fix RT

parent fe7f6f2e
No related merge requests found
......@@ -20,41 +20,42 @@
*/
class Class_KidilanguesLink {
protected $_user,
$_home_page = 'cfcd208495d565ef66e7dff9f98764da/0';
use Trait_TimeSource;
public static function forUser($user) {
return Class_AdminVar::get('KIDILANGUES_VERSION') == '2'
? new Class_KidilanguesLinkV2($user)
: new self($user);
public static function staticUrl() {
return Class_Url::assemble(['controller' => 'modules',
'action' => 'kidilangues']);
}
public function __construct($user) {
$this->_user = $user;
public function url() {
return call_user_func([$this, 'version' . (Class_AdminVar::get('KIDILANGUES_VERSION') == '2'
? '2'
: '1')]);
}
public function baseUrl() {
return 'http://www.kidilangues.fr/directaccess/biblio';
}
public function version1() {
$params = [];
$params[] = Class_AdminVar::get('KIDILANGUES_ID');
$params[] = md5(Class_AdminVar::get('KIDILANGUES_LOGIN'));
$params[] = $this->kidilanguesEncode(Class_AdminVar::get('KIDILANGUES_PWD'));
$params[] = 'cfcd208495d565ef66e7dff9f98764da/0';
public static function staticUrl() {
return Class_Url::assemble(['controller' => 'modules',
'action' => 'kidilangues']);
return 'http://www.kidilangues.fr/directaccess/biblio/' . implode('/', $params);
}
public function url() {
public function version2() {
$params = [];
$params[] = Class_AdminVar::get('KIDILANGUES_ID');
$params[] = md5(Class_AdminVar::get('KIDILANGUES_LOGIN'));
$params[] = $this->kidilanguesEncode(Class_AdminVar::get('KIDILANGUES_PWD'));
$params[] = $this->_home_page;
$params[] = Class_AdminVar::get('KIDILANGUES_LOGIN');
$params[] = Class_AdminVar::get('KIDILANGUES_PWD');
$params[] = 'cfcd208495d565ef66e7dff9f98764da';
$params[] = $this->kidilanguesEncode($this->getTimeSource()->time());
return $this->baseUrl() . '/' . implode('/', $params);
return 'http://www.kidilangues.fr/directaccess/mediatheque/' . implode('/', $params);
}
......
<?php
/**
* Copyright (c) 2012-2014, 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_KidilanguesLinkV2 {
use Trait_TimeSource;
protected $_user,
$_home_page = 'cfcd208495d565ef66e7dff9f98764da';
public function __construct($user) {
$this->_user = $user;
}
public function baseUrl() {
return 'http://www.kidilangues.fr/directaccess/mediatheque';
}
public static function staticUrl() {
return Class_Url::assemble(['controller' => 'modules',
'action' => 'kidilangues']);
}
public function url() {
$params = [];
$params[] = Class_AdminVar::get('KIDILANGUES_ID');
$params[] = Class_AdminVar::get('KIDILANGUES_LOGIN');
$params[] = Class_AdminVar::get('KIDILANGUES_PWD');
$params[] = $this->_home_page;
$params[] = $this->kidilanguesEncode($this->getTimeSource()->time());
return $this->baseUrl() . '/' . implode('/', $params);
}
public function kidilanguesEncode($data) {
return rtrim(strtr(base64_encode($this->kidilanguesEncrypt($data)), '+/', '-_'), '=');
}
public function kidilanguesEncrypt($data_to_encrypt) {
$key = Class_AdminVar::get('KIDILANGUES_KEY');
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data_to_encrypt, MCRYPT_MODE_CBC, md5($key));
}
}
?>
\ No newline at end of file
......@@ -33,7 +33,7 @@ class Class_Systeme_ModulesMenu_Kidilangues extends Class_Systeme_ModulesMenu_SS
public function urlForUser($user) {
if ($user && $user->hasRightAccesKidilangues() && Class_AdminVar::isKidilanguesEnabled()) {
return Class_KidilanguesLink::forUser($user)->url();
return (new Class_KidilanguesLink())->url();
}
$this->setMessage('Vous n\'avez pas accès à cette ressource.');
return '';
......
......@@ -99,7 +99,7 @@ class ModulesControllerKidilanguesLoggedV2Test extends ModulesControllerKidilang
public function setUp() {
parent::setUp();
Class_KidilanguesLinkV2::setTimeSource(new TimeSourceForTest('2015-10-16 15:22:22'));
Class_KidilanguesLink::setTimeSource(new TimeSourceForTest('2015-10-16 15:22:22'));
Class_AdminVar::set('KIDILANGUES_VERSION', 2);
$this->dispatch('/opac/modules/kidilangues', true);
}
......
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