From d2d31da457c1250257dc77067d097ad2754737b2 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Tue, 14 Aug 2018 11:09:08 +0200
Subject: [PATCH] hotline #78216 first commit migration tout apprendre to
 digital resource plugin

---
 cosmogramme/sql/patch/patch_351.php           |   2 +
 library/Class/DigitalResource.php             |   9 +
 .../DigitalResource/ToutApprendre.php         |  50 ++++++
 .../Systeme/ModulesMenu/ToutApprendre.php     |   3 -
 library/Class/UserGroup.php                   |   3 -
 library/Class/Users.php                       |   5 -
 .../WebService/BibNumerique/ToutApprendre.php |   4 +-
 .../View/Helper/TagCoursToutApprendre.php     |   6 +-
 .../digital_resources/ToutApprendre/Batch.php |  23 +++
 .../ToutApprendre/Config.php                  |  70 ++++++++
 .../ToutApprendre/ModuleMenu.php              |  23 +++
 .../ToutApprendre/Service.php                 |  23 +++
 .../ToutApprendre/Service/Album.php           |  46 +++++
 .../ToutApprendre/Service/Parser.php          |  51 ++++++
 .../ToutApprendre/View/Helper/Album.php       |  23 +++
 .../controllers/IndexController.php           |  23 +++
 .../ToutApprendre/images/icon.png             | Bin 0 -> 3619 bytes
 .../ToutApprendre/tests/ToutApprendreTest.php | 162 ++++++++++++++++++
 tests/db/UpgradeDBTest.php                    |  12 +-
 .../DigitalResource/ToutApprendreTest.php     | 156 +++++++++++++++++
 .../Systeme/ModulesMenu/ToutApprendreTest.php |   2 +-
 .../View/Helper/TagCoursToutApprendreTest.php |  28 ++-
 22 files changed, 689 insertions(+), 35 deletions(-)
 create mode 100644 cosmogramme/sql/patch/patch_351.php
 create mode 100644 library/Class/Migration/DigitalResource/ToutApprendre.php
 create mode 100644 library/digital_resources/ToutApprendre/Batch.php
 create mode 100644 library/digital_resources/ToutApprendre/Config.php
 create mode 100644 library/digital_resources/ToutApprendre/ModuleMenu.php
 create mode 100644 library/digital_resources/ToutApprendre/Service.php
 create mode 100644 library/digital_resources/ToutApprendre/Service/Album.php
 create mode 100644 library/digital_resources/ToutApprendre/Service/Parser.php
 create mode 100644 library/digital_resources/ToutApprendre/View/Helper/Album.php
 create mode 100644 library/digital_resources/ToutApprendre/controllers/IndexController.php
 create mode 100644 library/digital_resources/ToutApprendre/images/icon.png
 create mode 100644 library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php
 create mode 100644 tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php

diff --git a/cosmogramme/sql/patch/patch_351.php b/cosmogramme/sql/patch/patch_351.php
new file mode 100644
index 00000000000..538e8da8610
--- /dev/null
+++ b/cosmogramme/sql/patch/patch_351.php
@@ -0,0 +1,2 @@
+<?php
+(new Class_Migration_DigitalResource_ToutApprendre())->run();
\ No newline at end of file
diff --git a/library/Class/DigitalResource.php b/library/Class/DigitalResource.php
index ff24075ae7b..defe972d875 100644
--- a/library/Class/DigitalResource.php
+++ b/library/Class/DigitalResource.php
@@ -108,6 +108,15 @@ class Class_DigitalResource extends Class_Entity {
   }
 
 
+  public function getSsoActionForPlugin($name) {
+    return $this->getPlugins()
+                ->detect(function($config) use ($name)
+                         {
+                           return ($name == $config->getName()) ? $config->getSsoAction() : '';
+                         });
+  }
+
+
   public function getPluginsDescription() {
     return $this->pluginsByName(function($config)
                                 {
diff --git a/library/Class/Migration/DigitalResource/ToutApprendre.php b/library/Class/Migration/DigitalResource/ToutApprendre.php
new file mode 100644
index 00000000000..791b760519e
--- /dev/null
+++ b/library/Class/Migration/DigitalResource/ToutApprendre.php
@@ -0,0 +1,50 @@
+<?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_Migration_DigitalResource_ToutApprendre extends Class_Migration_DigitalResource_Abstract {
+
+
+  protected function _getOldRightToken() {
+    return 6;
+  }
+
+
+  protected function _getAdminVarMapping() {
+    return ['TOUTAPPRENDRE_BIB_ID' => 'ToutApprendre_BIB_ID',
+            'TOUTAPPRENDRE_KEY' => 'ToutApprendre_KEY'];
+  }
+
+
+  protected function _getConfig() {
+    return ToutApprendre_Config::getInstance();
+  }
+
+
+  protected function _getOldMenuName() {
+    return 'TOUTAPPRENDRE';
+  }
+
+
+  protected function _getOldBatchName() {
+    return 'MOISSONNAGE_TOUTAPPRENDRE';
+  }
+}
\ No newline at end of file
diff --git a/library/Class/Systeme/ModulesMenu/ToutApprendre.php b/library/Class/Systeme/ModulesMenu/ToutApprendre.php
index 84038b6e364..c26a790cd23 100644
--- a/library/Class/Systeme/ModulesMenu/ToutApprendre.php
+++ b/library/Class/Systeme/ModulesMenu/ToutApprendre.php
@@ -34,9 +34,6 @@ class Class_Systeme_ModulesMenu_ToutApprendre extends Class_Systeme_ModulesMenu_
 
 
   public function urlForUser($user) {
-    if (!$user->hasRightAccesToutApprendre())
-      return '';
-
     return Class_ToutApprendreLink::forUser($user)->url();
   }
 
diff --git a/library/Class/UserGroup.php b/library/Class/UserGroup.php
index 8607c8185ff..0f88f7d6038 100644
--- a/library/Class/UserGroup.php
+++ b/library/Class/UserGroup.php
@@ -136,7 +136,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
   const RIGHT_ACCES_ARTEVOD = 2;
   const RIGHT_ACCES_NUMILOG = 3;
   const RIGHT_ACCES_VODECLIC = 5;
-  const RIGHT_ACCES_TOUTAPPRENDRE = 6;
   const RIGHT_ACCES_NUMERIQUEPREMIUM = 20;
   const RIGHT_ACCES_CYBERLIBRIS = 22;
   const RIGHT_ACCES_MYCOW = 24;
@@ -179,7 +178,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
      self::RIGHT_ACCES_NUMILOG => 'Bibliothèque numérique: accéder à Numilog',
      self::RIGHT_ACCES_CYBERLIBRIS => 'Bibliothèque numérique: accéder à Cyberlibris',
      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_MYCOW => 'Bibliothèque numérique: accéder à MyCOW.EU',
      self::RIGHT_ACCES_PLANETNEMO => 'Bibliothèque numérique: accéder à planetnemo.fr',
@@ -229,7 +227,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
                 'ArteVod' => [Class_UserGroup::RIGHT_ACCES_ARTEVOD],
                 'Numilog' => [Class_UserGroup::RIGHT_ACCES_NUMILOG],
                 'Vodeclic' => [Class_UserGroup::RIGHT_ACCES_VODECLIC],
-                'ToutApprendre' => [Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE],
                 'NumeriquePremium' => [Class_UserGroup::RIGHT_ACCES_NUMERIQUEPREMIUM],
                 'MyCow' => [Class_UserGroup::RIGHT_ACCES_MYCOW],
                 'Kidilangues' => [Class_UserGroup::RIGHT_ACCES_KIDILANGUES],
diff --git a/library/Class/Users.php b/library/Class/Users.php
index 579dcf6c681..8ab61505e43 100644
--- a/library/Class/Users.php
+++ b/library/Class/Users.php
@@ -917,11 +917,6 @@ class Class_Users extends Storm_Model_Abstract {
   }
 
 
-  public function hasRightAccesToutApprendre() {
-    return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE);
-  }
-
-
   public function hasRightAccessCyberlibris() {
     return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCES_CYBERLIBRIS);
   }
diff --git a/library/Class/WebService/BibNumerique/ToutApprendre.php b/library/Class/WebService/BibNumerique/ToutApprendre.php
index 81542e0e199..621492a5f97 100644
--- a/library/Class/WebService/BibNumerique/ToutApprendre.php
+++ b/library/Class/WebService/BibNumerique/ToutApprendre.php
@@ -94,6 +94,4 @@ class Class_WebService_BibNumerique_ToutApprendre extends Class_WebService_BibNu
   public function getName() {
     return 'Tout Apprendre';
   }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/TagCoursToutApprendre.php b/library/ZendAfi/View/Helper/TagCoursToutApprendre.php
index 3350176712c..7088a0334a2 100644
--- a/library/ZendAfi/View/Helper/TagCoursToutApprendre.php
+++ b/library/ZendAfi/View/Helper/TagCoursToutApprendre.php
@@ -44,8 +44,6 @@ class ZendAfi_View_Helper_TagCoursToutApprendre extends ZendAfi_View_Helper_TagR
 
 
   function hasRightAccesRessourcesNumeriques($user) {
-    return $user->hasRightAccesToutApprendre();
+    return true;
   }
-
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/Batch.php b/library/digital_resources/ToutApprendre/Batch.php
new file mode 100644
index 00000000000..08a8d1c58dc
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/Batch.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendre_Batch extends Class_DigitalResource_Batch {}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/Config.php b/library/digital_resources/ToutApprendre/Config.php
new file mode 100644
index 00000000000..10295fc1309
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/Config.php
@@ -0,0 +1,70 @@
+<?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 ToutApprendre_Config extends Class_DigitalResource_Config {
+  public function getConfig() {
+    return ['Introduction' => $this->_('ToutApprendre'),
+            'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/ToutApprendre',
+            'Url' => '',
+            'Icon' => '',
+
+            'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource ToutApprendre'),
+            'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'),
+
+            'SsoAction' => true,
+
+            'MenuLabel' => $this->_('Lien vers ToutApprendre'),
+            'ModuleMenu' => $this->withNameSpace('ModuleMenu'),
+
+            'Service' => $this->withNameSpace('Service'),
+            'Batch' => $this->withNameSpace('Batch'),
+
+            'DocTypeLabel' => $this->_('Cours en ligne Tout Apprendre'),
+
+            'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme ToutApprendre'),
+                                                                         ['value' => 'http://biblio.toutapprendre.com/ws/wsUrl.aspx'])->bePrivate(),
+                            'HARVEST_URL' => Class_AdminVar_Meta::newDefault($this->_('URL du catalogue de la plateforme ToutApprendre'),
+                                                                             ['value' => 'http://biblio.toutapprendre.com/cours/catalogue.aspx'])->bePrivate()]
+    ];
+  }
+
+
+  public function isEnabled() {
+    return '' != $this->getAdminVar('SSO_URL');
+  }
+
+
+  public function getSsoUrl($user) {
+    if(!$user)
+      return '';
+
+    return $this->getAdminVar('SSO_URL');
+  }
+
+
+  public function getAlbumSsoUrl($user, $album) {
+    if(!$album)
+      return '';
+
+    return $this->getAdminVar('SSO_URL');
+  }
+}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/ModuleMenu.php b/library/digital_resources/ToutApprendre/ModuleMenu.php
new file mode 100644
index 00000000000..3002d4c9acc
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/ModuleMenu.php
@@ -0,0 +1,23 @@
+<?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 ToutApprendre_ModuleMenu extends Class_DigitalResource_ModuleMenu {}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/Service.php b/library/digital_resources/ToutApprendre/Service.php
new file mode 100644
index 00000000000..5786adf3a44
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/Service.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendre_Service extends Class_DigitalResource_Service {}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/Service/Album.php b/library/digital_resources/ToutApprendre/Service/Album.php
new file mode 100644
index 00000000000..b28e238f5a7
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/Service/Album.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendre_Service_Album extends Class_WebService_BibNumerique_RessourceNumerique {
+
+
+  public function getBaseUrl() {
+    return ToutApprendre_Config::getInstance()->getAdminVar('SSO_URL');
+  }
+
+
+  protected function getTypeDoc() {
+    return ToutApprendre_Config::getInstance()->getDocType();
+  }
+
+  public function fillAlbum($album) {
+    $album
+      ->setTypeDocId($this->getTypeDoc());
+
+    return $this;
+  }
+
+
+  public function getRessourceCategorieLibelle() {
+    return ToutApprendre_Config::getInstance()->getDocTypeLabel();
+  }
+}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/Service/Parser.php b/library/digital_resources/ToutApprendre/Service/Parser.php
new file mode 100644
index 00000000000..cd4a026a36a
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/Service/Parser.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendre_Service_Parser {
+
+  protected
+    $_albums = [],
+    $_current_album;
+
+
+  public function parseXML($xml) {
+    $this->_parser = new Class_WebService_FasterXMLParser();
+    $this->_parser->setElementHandler($this);
+    $this->_parser->parse($xml);
+    return $this;
+  }
+
+
+  public function startAlbum($attributes) {
+    $this->_current_album = new ToutApprendre_Service_Album();
+  }
+
+
+  public function endAlbum() {
+    $this->_albums[] = $this->_current_album;
+  }
+
+
+  public function getAlbums() {
+    return $this->_albums;
+  }
+}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/View/Helper/Album.php b/library/digital_resources/ToutApprendre/View/Helper/Album.php
new file mode 100644
index 00000000000..3381965f0c0
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/View/Helper/Album.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendre_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/controllers/IndexController.php b/library/digital_resources/ToutApprendre/controllers/IndexController.php
new file mode 100644
index 00000000000..4c3b2100aeb
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/controllers/IndexController.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendre_Plugin_IndexController extends Class_DigitalResource_Controller {}
\ No newline at end of file
diff --git a/library/digital_resources/ToutApprendre/images/icon.png b/library/digital_resources/ToutApprendre/images/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..fa0a161f006f5f2adb42e80b53ae706d9975ddc3
GIT binary patch
literal 3619
zcmb7{S5y<q7KTG_MnHP^s7ObpcccXi#UMqhD9spp?<7Q2kN}DxRZ0|)KoBWLS^$Me
zuTm30bHG68MF=I_c%SdfeVCaw|Jt)=&#X1Gzd!kol{t`8loJ2|0B_zfwV{ude;Ye1
zz1I&PPo(QBH%*OfBMa6FA%Xl}qWBn0zi04#&!x+m$<Hq&iZ{6!O)&k-W9mv|adl*Q
zvu)ZNqTRy75@bdkHI@Aq#@oderX+p+xi))4wsW>~uM^Y}bAkT?@5AHc)n~q;m&f#X
ztPT%w#FN;AxI|Cd*pMM{<LFO_Y)UE5*C_xN@RXN98TP;w#^o-|yTB+6V*Y=m_H5>3
z&MX1yqfs(XwTq2KOy0%aWwC}`Vq3J%guQi98~AoiJ{qzI>{6qy^3Vfi7x0wEYk>@n
z?Idsorq{aA8NFQ21Z*M`oJ_*(;<qC==lek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7S(##t-4p)<<-iZ=

literal 0
HcmV?d00001

diff --git a/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php
new file mode 100644
index 00000000000..4fec32da70b
--- /dev/null
+++ b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php
@@ -0,0 +1,162 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, 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 ToutApprendreActivatedTestCase extends AbstractControllerTestCase {
+  protected
+    $_storm_default_to_volatile = true,
+    $_user;
+
+  public function setUp() {
+    parent::setUp();
+    Class_AdminVar::set('ToutApprendre_SSO_URL', 'https://test.org/api/bokeh/login');
+
+    $group = $this->fixture('Class_UserGroup',
+                            ['id' => 1,
+                             'libelle' => 'Digital resources']);
+
+    $this->_user = $this->fixture('Class_Users',
+                                  ['id' => 1,
+                                   'login' => 'Tom',
+                                   'password' => 'pwd'])
+                        ->setUserGroups([$group]);
+
+    $this->fixture('Class_Permission',
+                   ['id' => 1,
+                    'code' => 'ToutApprendre'])
+         ->permitTo($group,  new Class_Entity());
+  }
+}
+
+
+
+class ToutApprendreSsoTest extends ToutApprendreActivatedTestCase {
+
+  public function setUp() {
+    parent::setUp();
+    ZendAfi_Auth::getInstance()->logUser($this->_user);
+    $this->dispatch('/opac/modules/' . Class_DigitalResource::getSsoActionForPlugin('ToutApprendre'), true);
+  }
+
+
+  /** @test */
+  public function shouldRedirectToResource() {
+    $this->assertXPathContentContains('//script' , 'document.location.href="PLACEHOLDER', $this->_response->getBody());
+  }
+
+
+  /** @test */
+  public function scriptShouldContainsCheckUrl() {
+    $this->assertXPathContentContains('//script[contains(text(), "&check_url=")]' , '/ToutApprendre_Plugin/auth/validate');
+  }
+}
+
+
+
+
+class ToutApprendreDashboardUnactivatedTest extends Admin_AbstractControllerTestCase {
+  protected $_storm_default_to_volatile = true;
+
+
+  public function setUp() {
+    parent::setUp();
+    $this->dispatch('/ToutApprendre_Plugin', true);
+  }
+
+
+  /** @test */
+  public function shouldDisplayDeactivated() {
+    $this->assertXPathContentContains('//button', 'Désactivé');
+  }
+
+
+  /** @test */
+  public function ssoUrlShoudlBeDisplay() {
+    $this->assertXPathContentContains('//table', 'ToutApprendre_SSO_URL');
+  }
+}
+
+
+
+
+class ToutApprendreDashboardActivatedTest extends ToutApprendreActivatedTestCase {
+  protected $_storm_default_to_volatile = true;
+
+
+  public function setUp() {
+    parent::setUp();
+
+    $album = $this->fixture('Class_Album',
+               ['id' => 20,
+                'titre' => '10 moutons',
+                'type_doc_id' => 'ToutApprendre'
+               ]);
+
+    ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users',
+                                                        ['id' => 2,
+                                                         'login' => 'admin',
+                                                         'password' => 'admin',
+                                                         'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN]));
+    $this->dispatch('/ToutApprendre_Plugin', true);
+  }
+
+
+  /** @test */
+  public function shouldDisplayActivated() {
+    $this->assertXPathContentContains('//button', 'Activé');
+  }
+
+
+  /** @test */
+  public function urlSsoTitleBeDisplay() {
+    $this->assertXPathContentContains('//h4', 'URL SSO générée par /modules/story-play-r pour l\'utilisateur "ToutApprendre_test_user"');
+  }
+
+
+  /** @test */
+  public function testSsoValidateUrlMessageShoudlBeDisplay() {
+    $this->assertXPathContentContains('//h4', 'URL de validation du ticket de connexion générée pour l\'utilisateur "ToutApprendre_test_user"');
+  }
+
+
+  /** @test */
+  public function testSsoValidateUrlShoudlBeDisplay() {
+    $this->assertXPathContentContains('//pre', '/ToutApprendre_Plugin/auth/validate?sessionid=ST-');
+  }
+
+
+  /** @test */
+  public function sourceImageShouldBeValid() {
+    $this->assertXPathContentContains('//pre','Image source : https://preprod');
+  }
+
+
+  /** @test */
+  public function vignetteShouldBePresent() {
+    $this->assertXPath("//img[contains(@src,'userfiles/album/20/thumb_20_large_10Moutons.jpeg')]");
+  }
+
+
+  /** @test */
+  public function doctypeImageUrlShouldBePresent() {
+    $this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/ToutApprendre")]');
+  }
+}
diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php
index 06bbc4e9fb7..9ed143f8816 100644
--- a/tests/db/UpgradeDBTest.php
+++ b/tests/db/UpgradeDBTest.php
@@ -2165,4 +2165,14 @@ class UpgradeDB_350_Test extends UpgradeDBTestCase {
   public function fieldShouldBe($field, $type) {
     $this->assertFieldType('template_settings', $field, $type);
   }
-}
\ No newline at end of file
+}
+
+
+
+
+class UpgradeDB_351_Test extends UpgradeDBTestCase {
+  public function prepare() {}
+
+  /** @test */
+  public function placeholderForToutApprendreMigrationPatch() {}
+}
diff --git a/tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php b/tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php
new file mode 100644
index 00000000000..4a646a7585f
--- /dev/null
+++ b/tests/library/Class/Migration/DigitalResource/ToutApprendreTest.php
@@ -0,0 +1,156 @@
+<?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_Migration_DigitialResource_ToutApprendreTest extends ModelTestCase {
+  protected
+    $_storm_default_to_volatile = true,
+    $_migration;
+
+  public function setUp() {
+    parent::setUp();
+    Class_DigitalResource::resetInstance();
+
+    $cfg_menus = ['H' => ['libelle' => 'Menu horizontal',
+                          'picto' => 'vide.gif',
+                          'menus' => [
+                                      ['type_menu' => 'MENU',
+                                       'libelle' => 'Pratique',
+                                       'picto' => 'bookmark.png',
+                                       'preferences' => [],
+                                       'sous_menus' => [
+                                                        ['type_menu' => 'ACCUEIL',
+                                                         'libelle' => 'Accueil',
+                                                         'picto' => 'vide.gif',
+                                                         'preferences' => [],
+                                                         'sous_menus' => ''],
+
+                                                        ['type_menu' => 'TOUTAPPRENDRE',
+                                                         'libelle' => 'Lien vers ToutApprendre',
+                                                         'preferences' => [],
+                                                         'picto' => 'vide.gif'] ]]]]];
+
+    $cfg_menus_without_toutapprendre = ['H' => ['libelle' => 'Menu horizontal',
+                                                'picto' => 'vide.gif',
+                                                'menus' => [
+                                                            ['type_menu' => 'MENU',
+                                                             'libelle' => 'Pratique',
+                                                             'picto' => 'bookmark.png',
+                                                             'preferences' => [],
+                                                             'sous_menus' => [
+                                                                              ['type_menu' => 'ACCUEIL',
+                                                                               'libelle' => 'Accueil',
+                                                                               'picto' => 'vide.gif',
+                                                                               'preferences' => [],
+                                                                               'sous_menus' => ''] ]]]]];
+
+
+    $profil_adulte = $this->fixture('Class_Profil',
+                                    ['id' => 22,
+                                     'parent_id' => null])
+                          ->setBrowser('opac')
+                          ->setLibelle('Profil Adulte')
+                          ->setCfgMenus($cfg_menus);
+
+    $profil_without_toutapprendre = $this->fixture('Class_Profil',
+                                                   ['id' => 23,
+                                                    'rewrite_url' => 'adulte'])
+                                         ->setBrowser('opac')
+                                         ->setLibelle('Profil Adulte')
+                                         ->setCfgMenus($cfg_menus_without_toutapprendre);
+
+
+    Class_Profil::setCurrentProfil($profil_adulte);
+
+    $this->fixture('Class_UserGroup',
+                   ['id' => 2,
+                    'libelle' => 'team ONE',
+                    'rights_token' => pow(2, 6)]);
+
+    $this->fixture('Class_AdminVar',
+                   ['id' => 'TOUTAPPRENDRE_URL',
+                    'valeur' => 'http://mediathequefr.ToutApprendre.com/']);
+
+    $this->fixture('Class_AdminVar',
+                   ['id' => 'TOUTAPPRENDRE_BIB_ID',
+                    'valeur' => '2100']);
+
+    $this->fixture('Class_AdminVar',
+                   ['id' => 'TOUTAPPRENDRE_KEY',
+                    'valeur' => '1111']);
+
+    $this->_migration = (new Class_Migration_DigitalResource_ToutApprendre())
+      ->setMemoryCleaner(function(){})
+      ->run();
+  }
+
+
+  public function tearDown() {
+    Class_DigitalResource::resetInstance();
+    parent::tearDown();
+  }
+
+
+  /** @test */
+  public function adminVarToutApprendreSsoUrlShoudBeCreated() {
+    $this->assertEquals('http://biblio.toutapprendre.com/ws/wsUrl.aspx', Class_AdminVar::getValueOrDefault('ToutApprendre_SSO_URL'));
+  }
+
+
+  /** @test */
+  public function adminVarToutApprendreHarvestUrlShoudBeCreated() {
+    $this->assertEquals('http://biblio.toutapprendre.com/cours/catalogue.aspx', Class_AdminVar::getValueOrDefault('ToutApprendre_HARVEST_URL'));
+  }
+
+
+  /** @test */
+  public function adminVarToutApprendreBibIdShoudBeUpdated() {
+    $this->assertNotNull(Class_AdminVar::findFirstBy(['clef' => 'ToutApprendre_BIB_ID',
+                                                      'valeur' => '2100']));
+  }
+
+
+  /** @test */
+  public function adminVarToutApprendreKeyShoudBeUpdated() {
+    $this->assertNotNull(Class_AdminVar::findFirstBy(['clef' => 'ToutApprendre_KEY',
+                                                      'valeur' => '1111']));
+  }
+
+
+  /** @test */
+  public function profilMenuWithAssimilShouldContainsToutApprendre() {
+    $this->assertEquals('ToutApprendre', Class_Profil::find(22)->getCfgMenusAsArray()['H']['menus'][0]['sous_menus'][1]['type_menu']);
+  }
+
+
+  /** @test */
+  public function teamOneShouldHavePermissionOnToutApprendre() {
+    if (!$permissions = Class_UserGroup::find(2)->getPermissions())
+      return $this->fail();
+    $this->assertEquals('ToutApprendre', array_shift($permissions)->getCode());
+  }
+
+
+  /** @test */
+  public function teamOneRightsShouldBeCleaned() {
+    $this->assertEmpty(Class_UserGroup::find(2)->getRightsToken());
+  }
+}
diff --git a/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php b/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php
index dc1690d7b69..d23fff9d43f 100644
--- a/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php
+++ b/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php
@@ -35,7 +35,7 @@ class Class_Systeme_ModulesMenu_ToutApprendreTest extends Storm_Test_ModelTestCa
       'user_groups' => [$this->fixture('Class_UserGroup', [
         'id' => 20,
         'libelle' => 'ToutApprendre'
-      ])->addRight(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE)]
+      ])]
     ])->beAbonneSIGB();
     ZendAfi_Auth::getInstance()->logUser($this->user);
     Zend_Registry::get('translate')->setLocale('fr');
diff --git a/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php b/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php
index 1e4fa14d6d3..d56e03a5e11 100644
--- a/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php
+++ b/tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php
@@ -16,7 +16,7 @@
  *
  * 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 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
 require_once('ViewHelperTestCase.php');
@@ -53,11 +53,9 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
       ->answers([]);
 
     $this->group_multimedia = $this->fixture('Class_UserGroup',
-                                             ['id' => 20, 
-                                           'libelle' => 'Numerique'])
-      ->addRight(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE);
+                                             ['id' => 20,
+                                           'libelle' => 'Numerique']);
 
-    
     $this->_album = Class_Album::getLoader()
       ->newInstanceWithId(33)
       ->setTitre('Petit cours d\'autodefense intellectuelle')
@@ -66,7 +64,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
                         ->newInstanceWithId('8')
                         ->setIdOrigine('889')
                         ->setTitre('Pourquoi étudier la pensée critique ?'),
-                        
+
                         '1' => Class_AlbumRessource::getLoader()
                         ->newInstanceWithId('9')
                         ->setIdOrigine('890')
@@ -76,9 +74,9 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
                         ->newInstanceWithId('10')
                         ->setIdOrigine('891')
                         ->setTitre('Deux expériences de psychologie sociale'),
-                       
 
-                        
+
+
                         ]);
     $view = new ZendAfi_Controller_Action_Helper_View();
     $this->_helper = new ZendAfi_View_Helper_TagCoursToutApprendre();
@@ -92,8 +90,8 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
       ->setUserGroups([$this->group_multimedia])
       ->setDateFin('2023-09-12')
       ->beAbonneSIGB();
-  
-    $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), 
+
+    $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album),
                                       '//a[contains(@href, "&pkl=891")][@target="_blank"]',
                                       'psychologie sociale');
 
@@ -109,7 +107,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
       ->setDateFin('2003-09-12')
       ->beAbonneSIGB();
 
-    $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), 
+    $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album),
                           '//a[contains(@href, "&pkl=891")]');
 
   }
@@ -122,7 +120,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
       ->setDateFin('2023-09-12')
       ->beAbonneSIGB();
 
-    $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), 
+    $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album),
                           '//a[contains(@href, "&pkl=891")]');
 
   }
@@ -131,7 +129,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
   /** @test */
   public function withCurrentUserNotAbonneShouldNotDisplayLinkToutApprendre() {
     $this->_normand->beInvite();
-    $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album), 
+    $this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album),
                           '//a[contains(@href, "&pkl=891")]');
   }
 
@@ -140,7 +138,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
   public function withCurrentUserNotAbonneToutApprendreShouldDisplayErrorMessage() {
     $this->_normand->beInvite();
 
-    $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), 
+    $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album),
                                       '//p', 'abonnement valide');
   }
 
@@ -149,7 +147,7 @@ class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
   public function withNoCurrentUserForToutApprendreShouldDisplayErrorMessage() {
     ZendAfi_Auth::getInstance()->getStorage()->clear();
 
-    $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album), 
+    $this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album),
                                       '//p', 'abonnement valide');
   }
 
-- 
GitLab