Commit 265b14b9 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch 'dev#52054_s91_contractuelaspiration_des_notices_de_musicme' into 'master'

Dev#52054 s91 contractuelaspiration des notices de musicme

See merge request !2425
parents 89c6f03f 22f1bf34
'52054' =>
['Label' => $this->_('Recherche fédérée pour MusicMe'),
'Desc' => $this->_('Moissonnage des notices de musicMe'),
'Image' => '',
'Video' => 'https://www.youtube.com/watch?v=xxMHIK31ZPc',
'Category' => 'Bibliothèque numérique',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => 'http://wiki.bokeh-library-portal.org/index.php?title=MusicMe',
'Test' => '',
'Date' => '2017-11-14'],
\ No newline at end of file
- ticket #52054 : Aspiration des notices de MusicMe
\ No newline at end of file
......@@ -738,7 +738,7 @@ class Auth_Strategy_Logged extends Auth_Strategy_Abstract{
class Auth_Strategy_Cas_Abstract extends Auth_Strategy_Abstract{
public function urlServiceCas() {
if ($url_musicme = $this->redirectMusicMe())
if ($url_musicme = $this->redirectMusicme())
return $url_musicme;
$ticket = (new Class_CasTicket())->getTicketForCurrentUser();
......@@ -755,10 +755,10 @@ class Auth_Strategy_Cas_Abstract extends Auth_Strategy_Abstract{
}
public function redirectMusicMe() {
public function redirectMusicme() {
if (strpos($this->controller->getCasServerUrl(),'musicme') !== false) {
$musicme = new Class_Systeme_ModulesMenu_MusicMe();
return $musicme->getDynamiqueUrl();
$module_menu = Class_DigitalResource::getInstance()->getModuleMenuFor('Musicme');
return $module_menu->getDynamiqueUrl();
}
return false;
......
......@@ -41,7 +41,7 @@ class CasServerController extends ZendAfi_Controller_Action {
}
public function returnValidMusicMeResponse($user) {
public function returnValidMusicmeResponse($user) {
$this->getResponse()->setHeader('Content-Type', 'application/xml;charset=utf-8');
$this->getResponse()->setBody( '<User>
<ID>'.$user->getId().'</ID>
......@@ -54,7 +54,7 @@ class CasServerController extends ZendAfi_Controller_Action {
}
public function returnMusicMeFailureTicketResponse($error,$ticket=null) {
public function returnMusicmeFailureTicketResponse($error,$ticket=null) {
$this->getResponse()->setHeader('Content-Type', 'application/xml;charset=utf-8');
$xml="<User />";
$this->getResponse()->setBody($xml);
......@@ -77,13 +77,13 @@ class CasServerController extends ZendAfi_Controller_Action {
$ticket=$this->_request->getParam('ticket');
if (strlen($ticket)<1 || strlen($bibid)<1) {
return $this->returnMusicMeFailureTicketResponse('INVALID_REQUEST');
return $this->returnMusicmeFailureTicketResponse('INVALID_REQUEST');
}
if ($user = (new Class_CasTicket())->userForTicket($ticket))
return $this->returnValidMusicMeResponse($user);
return $this->returnValidMusicmeResponse($user);
return $this->returnMusicMeFailureTicketResponse('INVALID_TICKET',$ticket);
return $this->returnMusicmeFailureTicketResponse('INVALID_TICKET',$ticket);
}
......
......@@ -31,7 +31,6 @@ class ModulesController extends ZendAfi_Controller_Action {
'orthodidacte' => 'Orthodidacte',
'cite-de-la-musique' => 'CiteDeLaMusique',
'artevod' => 'ArteVOD',
'musicme' => 'MusicMe',
'numilog' => 'Numilog'];
$action = $this->_request->getActionName();
......@@ -41,11 +40,12 @@ class ModulesController extends ZendAfi_Controller_Action {
$digital_resource = Class_DigitalResource::getInstance();
if ($digital_resource->getPluginsSSOActions()->includes($action))
if ($digital_resource->getPluginsSSOActions()->includes($action)) {
$this->_forward($action,
'index',
$digital_resource->getModuleNameForAction($action),
$this->_request->getParams());
}
}
......
<?php
(new Class_Migration_DigitalResource_Musicme())->run();
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try{
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$adapter->query('update album set url_origine = "http://www.lasourisquiraconte.com" where type_doc_id="LaSourisQuiRaconte" and url_origine is null');
$adapter->query('update album set url_origine = "http://skilleos.com/sigb/sso/" where type_doc_id="Skilleos" and url_origine is null');
$adapter->query('update album set url_origine = "http://www.lekiosk.com/" where type_doc_id="Lekiosk" and url_origine is null');
} catch(Exception $e) {}
?>
\ No newline at end of file
......@@ -158,9 +158,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'NUMERIQUE_PREMIUM_URL' => Class_AdminVar_Meta::newDefault('')->bePrivate(),
'MUSICME_URL' => Class_AdminVar_Meta::newDefault('')->bePrivate(),
'MUSICME_BIB_ID' => Class_AdminVar_Meta::newDefault('')->bePrivate(),
'JAMENDO_CLIENT_ID' => Class_AdminVar_Meta::newDefault($this->_('ID client Jamendo')),
'SOUNDCLOUD_CLIENT_ID' => Class_AdminVar_Meta::newDefault($this->_('ID client SoundCloud')),
......@@ -754,14 +751,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
/**
* @return bool
*/
public function isMusicMeEnabled() {
return ('' != Class_AdminVar::get('MUSICME_URL'));
}
/**
* @return bool
*/
......
<?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
*/
abstract class Class_Migration_DigitalResource_Abstract {
use Trait_MemoryCleaner;
protected $_found_in_profil = false;
public function run() {
$this
->renameAdminVars()
->renameMenusKeys()
->upgradePermissions()
->renameBatches();
}
protected function renameAdminVars() {
foreach($this->_getAdminVarMapping() as $old => $new)
$this->_renameAdminVar($old, $new);
Class_AdminVar::clearCache();
return $this;
}
protected function _renameAdminVar($old, $new) {
if(!$old_var = Class_AdminVar::find($old))
return $this;
$old_var->delete();
Class_AdminVar::set($new, $old_var->getValeur());
Class_AdminVar::clearCache();
return $this;
}
protected function upgradePermissions() {
foreach(Class_UserGroup::findAll() as $group)
$this->replacePermission($group);
$this->_cleanMemory();
return $this;
}
protected function replacePermission($group) {
$old_rights = $group->getRightsToken();
if((pow(2, $this->_getOldRightToken()) & $old_rights) === pow(2, $this->_getOldRightToken())) {
$group
->setRights($group->getRights())
->save();
$permission = $this->_getConfig()
->getPermission();
$permission->permitTo($group, new Class_Entity());
}
return $group;
}
protected function renameMenusKeys() {
foreach(Class_Profil::findTopProfils() as $profil)
$this->searchAndRename($profil);
$this->_cleanMemory();
return $this;
}
protected function searchAndRename($profil) {
$this->_found_in_profil = false;
$cfg_menu = $profil->getCfgMenusAsArray();
$cfg_menu = $this->recursiveSearchAndRename($this->_getOldMenuName(), $this->_getConfig()->getName(), $cfg_menu);
if($this->_found_in_profil)
$profil
->setCfgMenus($cfg_menu)
->save();
return $profil;
}
protected function recursiveSearchAndRename($search, $replace, $subject){
foreach($subject as $key => $value) {
if($search === $value){
$this->_found_in_profil = true;
$subject[$key] = $replace;
return $subject;
}
if(is_array($value))
$subject[$key] = $this->recursiveSearchAndRename($search, $replace, $value);
}
return $subject;
}
protected function renameBatches() {
if(!$batch = Class_Batch::findFirstBy(['type' => $this->_getOldBatchName()]))
return;
$batch->setType($this->_getConfig()->getName())->save();
return $this;
}
abstract protected function _getOldRightToken();
abstract protected function _getAdminVarMapping();
abstract protected function _getConfig();
abstract protected function _getOldMenuName();
abstract protected function _getOldBatchName();
}
\ No newline at end of file
......@@ -20,108 +20,29 @@
*/
class Class_Migration_DigitalResource_Assimil {
use Trait_MemoryCleaner;
class Class_Migration_DigitalResource_Assimil extends Class_Migration_DigitalResource_Abstract {
const OLD_ASSIMIL_RIGHT_TOKEN = 30;
protected $_found_assimil_in_profil = false;
public function run() {
$this
->renameAdminVar()
->renameMenusKeys()
->upgradePermissions()
->renameBatches();
protected function _getOldRightToken() {
return 30;
}
protected function renameAdminVar() {
if(!$old_var = Class_AdminVAr::find('ASSIMIL'))
return $this;
if(!Class_AdminVAr::set('Assimil_Assimil', $old_var->getValeur()))
return $this;
$old_var->delete();
Class_AdminVar::clearCache();
return $this;
protected function _getAdminVarMapping() {
return ['ASSIMIL' => 'Assimil_Assimil'];
}
protected function renameBatches() {
if(!$batch = Class_Batch::findFirstBy(['type' => 'ASSIMIL']))
return;
$batch->setType(Assimil_Config::getName())->save();
return $this;
protected function _getConfig() {
return Assimil_Config::getInstance();
}
protected function upgradePermissions() {
foreach(Class_UserGroup::findAll() as $group)
$this->replacePermission($group);
$this->_cleanMemory();
return $this;
protected function _getOldMenuName() {
return 'ASSIMIL';
}
protected function replacePermission($group) {
$old_rights = $group->getRightsToken();
$permissions = [];
if((pow(2, static::OLD_ASSIMIL_RIGHT_TOKEN) & $old_rights) === pow(2, static::OLD_ASSIMIL_RIGHT_TOKEN))
$permissions[] = Assimil_Config::getInstance()->getPermission();
$group
->setRights($group->getRights())
->save();
(new Storm_Model_Collection($permissions))
->eachDo(function($permission) use ($group)
{
$permission->permitTo($group, new Class_Entity());
});
return $group;
protected function _getOldBatchName() {
return 'ASSIMIL';
}
protected function renameMenusKeys() {
foreach(Class_Profil::findAll() as $profil)
$this->searchAndRename($profil);
$this->_cleanMemory();
return $this;
}
protected function searchAndRename($profil) {
$this->_found_assimil_in_profil = false;
$cfg_menu = $profil->getCfgMenusAsArray();
$cfg_menu = $this->recursiveSearchAndRename('ASSIMIL', Assimil_Config::getName(), $cfg_menu);
if($this->_found_assimil_in_profil)
$profil
->setCfgMenus($cfg_menu)
->save();
return $profil;
}
protected function recursiveSearchAndRename($search, $replace, $subject){
foreach($subject as $key => $value) {
if($search === $value){
$this->_found_assimil_in_profil = true;
$subject[$key] = $replace;
return $subject;
}
if(is_array($value))
$subject[$key] = $this->recursiveSearchAndRename($search, $replace, $value);
}
return $subject;
}
}
\ No newline at end of file
......@@ -20,100 +20,30 @@
*/
class Class_Migration_DigitalResource_LeKiosk {
use Trait_MemoryCleaner;
class Class_Migration_DigitalResource_LeKiosk extends Class_Migration_DigitalResource_Abstract {
const OLD_LEKIOSK_RIGHT_TOKEN = 21;
protected $_found_lekiosk_in_profil = false;
public function run() {
$this
->renameAdminVars()
->renameMenusKeys()
->upgradePermissions();
}
protected function renameAdminVars() {
foreach(['LEKIOSK_ID' => 'Lekiosk_ID',
'LEKIOSK_SSO_MODE' => 'Lekiosk_SSO_MODE'] as $old => $new)
$this->_renameAdminVar($old, $new);
Class_AdminVar::clearCache();
return $this;
}
protected function _renameAdminVar($old, $new) {
if(!$old_var = Class_AdminVAr::find($old))
return $this;
$old_var->delete();
Class_AdminVAr::set($new, $old_var->getValeur());
return $this;
}
protected function upgradePermissions() {
foreach(Class_UserGroup::findAll() as $group)
$this->replacePermission($group);
$this->_cleanMemory();
return $this;
protected function _getOldRightToken() {
return 21;
}
protected function replacePermission($group) {
$old_rights = $group->getRightsToken();
if((pow(2, static::OLD_LEKIOSK_RIGHT_TOKEN) & $old_rights) === pow(2, static::OLD_LEKIOSK_RIGHT_TOKEN)) {
$group
->setRights($group->getRights())
->save();
$permission = Lekiosk_Config::getInstance()
->getPermission();
$permission->permitTo($group, new Class_Entity());
}
return $group;
protected function _getAdminVarMapping() {
return ['LEKIOSK_ID' => 'Lekiosk_ID',
'LEKIOSK_SSO_MODE' => 'Lekiosk_SSO_MODE'];
}
protected function renameMenusKeys() {
foreach(Class_Profil::findTopProfils() as $profil)
$this->searchAndRename($profil);
$this->_cleanMemory();
return $this;
protected function _getConfig() {
return Lekiosk_Config::getInstance();
}
protected function searchAndRename($profil) {
$this->_found_lekiosk_in_profil = false;
$cfg_menu = $profil->getCfgMenusAsArray();
$cfg_menu = $this->recursiveSearchAndRename('LEKIOSK', Lekiosk_Config::getName(), $cfg_menu);
if($this->_found_lekiosk_in_profil)
$profil
->setCfgMenus($cfg_menu)
->save();
return $profil;
protected function _getOldMenuName() {
return 'LEKIOSK';
}
protected function recursiveSearchAndRename($search, $replace, $subject){
foreach($subject as $key => $value) {
if($search === $value){
$this->_found_lekiosk_in_profil = true;
$subject[$key] = $replace;
return $subject;
}
if(is_array($value))
$subject[$key] = $this->recursiveSearchAndRename($search, $replace, $value);
}
return $subject;
protected function _getOldBatchName() {
return 'LEKIOSK';
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
* 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
......@@ -19,35 +19,32 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Systeme_ModulesMenu_MusicMe extends Class_Systeme_ModulesMenu_SSOAbstract {
protected
$_group = Class_Systeme_ModulesMenu::GROUP_MENU_ABONNES,
$_type_module = 'MusicMe',
$_url = ['controller' => 'modules',
'action' => 'musicme'];
class Class_Migration_DigitalResource_Musicme extends Class_Migration_DigitalResource_Abstract {
public function __construct() {
parent::__construct();
$this->_libelle = $this->_('Lien vers MusicMe');
protected function _getOldRightToken() {
return 7;
}
public function urlForUser($user) {
if (!$user->hasRightAccesMusicMe())
return '';
protected function _getAdminVarMapping() {
return ['MUSICME_URL' => 'Musicme_URL',
'MUSICME_BIB_ID' => 'Musicme_BIB_ID'];
}
protected function _getConfig() {
return Musicme_Config::getInstance();
}
$musicme_link=Class_MusicMeLink::forUser($user);
$url=$musicme_link->url();
if (!strlen($url)>0)
$this->setMessage($musicme_link->getMessage());
return $url;
protected function _getOldMenuName() {
return 'MUSICME';
}
public function isVisibleForProfil($profil) {
return Class_AdminVar::isMusicMeEnabled();
protected function _getOldBatchName() {
return 'MUSICME';
}
}
\ No newline at end of file
......@@ -119,7 +119,6 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
"NUMILOG" => new Class_Systeme_ModulesMenu_Numilog(),
"ARTEVOD" => new Class_Systeme_ModulesMenu_ArteVOD(),
"ORTHODIDACTE" => new Class_Systeme_ModulesMenu_Orthodidacte(),
"MUSICME" => new Class_Systeme_ModulesMenu_MusicMe(),
"MYCOW" => new Class_Systeme_ModulesMenu_MyCow(),
"PLANETNEMO" => new Class_Systeme_ModulesMenu_PlanetNemo(),
"KIDLILANGUES" => new Class_Systeme_ModulesMenu_Kidilangues(),
......
......@@ -136,7 +136,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
const RIGHT_ACCES_CVS = 4;
const RIGHT_ACCES_VODECLIC = 5;
const RIGHT_ACCES_TOUTAPPRENDRE = 6;
const RIGHT_ACCES_MUSICME = 7;
const RIGHT_ACCES_NUMERIQUEPREMIUM = 20;
const RIGHT_ACCES_CYBERLIBRIS = 22;
const RIGHT_ACCES_MYCOW = 24;
......@@ -183,7 +182,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
self::RIGHT_ACCES_VODECLIC => 'Bibliothèque numérique: accéder à Vodéclic',
self::RIGHT_ACCES_TOUTAPPRENDRE => 'Bibliothèque numérique: accéder à Tout Apprendre',
self::RIGHT_ACCES_NUMERIQUEPREMIUM => 'Bibliothèque numérique: accéder à Numérique Premium',
self::RIGHT_ACCES_MUSICME => 'Bibliothèque numérique: accéder à Music Me',
self::RIGHT_ACCES_MYCOW => 'Bibliothèque numérique: accéder à MyCOW.EU',
self::RIGHT_ACCES_PLANETNEMO => 'Bibliothèque numérique: accéder à planetnemo.fr',
self::RIGHT_ACCES_KIDILANGUES => 'Bibliothèque numérique: accéder à Kidilangues',
......@@ -235,7 +233,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
'Numilog' => [Class_UserGroup::RIGHT_ACCES_NUMILOG],
'Vodeclic' => [Class_UserGroup::RIGHT_ACCES_VODECLIC],
'ToutApprendre' => [Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE],
'MusicMe' => [Class_UserGroup::RIGHT_ACCES_MUSICME],
'NumeriquePremium' => [Class_UserGroup::RIGHT_ACCES_NUMERIQUEPREMIUM],
'MyCow' => [Class_UserGroup::RIGHT_ACCES_MYCOW],
'Kidilangues' => [Class_UserGroup::RIGHT_ACCES_KIDILANGUES],
......