From 70185fa4a9b7b89d1c02288d7dc57167f00da81e Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Thu, 3 May 2018 10:07:39 +0200
Subject: [PATCH] dev #72845 start migration of CVS to digital ressources

---
 FEATURES/72845                           | 10 +++++
 VERSIONS_WIP/72845                       |  1 +
 library/Class/AdminVar.php               |  8 ----
 library/Class/AdminVar/CVS.php           |  2 +-
 library/digital_resources/CVS/Config.php | 52 ++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 9 deletions(-)
 create mode 100644 FEATURES/72845
 create mode 100644 VERSIONS_WIP/72845
 create mode 100644 library/digital_resources/CVS/Config.php

diff --git a/FEATURES/72845 b/FEATURES/72845
new file mode 100644
index 00000000000..ebc79134bbb
--- /dev/null
+++ b/FEATURES/72845
@@ -0,0 +1,10 @@
+        '72845' =>
+            ['Label' => $this->_('[BDP Yonne] : Evolution connecteur CVS'),
+             'Desc' => '',
+             'Image' => '',
+             'Video' => '',
+             'Category' => '',
+             'Right' => function($feature_description, $user) {return true;},
+             'Wiki' => '',
+             'Test' => '',
+             'Date' => '2018-05-03'],
\ No newline at end of file
diff --git a/VERSIONS_WIP/72845 b/VERSIONS_WIP/72845
new file mode 100644
index 00000000000..0060cba219a
--- /dev/null
+++ b/VERSIONS_WIP/72845
@@ -0,0 +1 @@
+ - ticket #72845 : [BDP Yonne] : Evolution connecteur CVS
\ No newline at end of file
diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php
index 7815e958747..0138c44ee33 100644
--- a/library/Class/AdminVar.php
+++ b/library/Class/AdminVar.php
@@ -153,14 +153,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
             'BIBNUM' => Class_AdminVar_Meta::newOnOff($this->_('Activer ou désactiver la bibliothèque numérique'))->bePrivate(),
             'SITO_IN_ALBUMS' => Class_AdminVar_Meta::newOnOff($this->_('Gérer la sitothèque dans la bibliothèque numérique, nécessite l\'activation de la bibliothèque numérique'))->bePrivate(),
 
-            'CVS_BMKEY' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
-            'CVS_BMID' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
-            'CVS_BMLABEL' => Class_AdminVar_Meta::newDefault($this->_('Libellé de regroupement des abonnés'))->bePrivate(),
-            'CVS_SOURCENAME' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
-            'CVS_SOURCEID' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
-            'CVS_SOURCEKEY' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
-            'CVS_SOURCEPASSWORD' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
-            'CVS_LOGINTEST' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
             'NUMILOG_URL' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(),
             'NUMILOG_OAI_URL' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(),
             'NUMILOG_OAI_IDBIB' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(),
diff --git a/library/Class/AdminVar/CVS.php b/library/Class/AdminVar/CVS.php
index 56b22fc7ac0..5d721f51931 100644
--- a/library/Class/AdminVar/CVS.php
+++ b/library/Class/AdminVar/CVS.php
@@ -23,7 +23,7 @@
 class Class_AdminVar_CVS {
   public function isCVSAccessOrDemo($user = null) {
     if (!$user)
-      $user = Class_Users::getLoader()->getIdentity();
+      $user = Class_Users::getIdentity();
 
     if ($user)
       return $user->hasRightAccesCVS();
diff --git a/library/digital_resources/CVS/Config.php b/library/digital_resources/CVS/Config.php
new file mode 100644
index 00000000000..73b8d35c279
--- /dev/null
+++ b/library/digital_resources/CVS/Config.php
@@ -0,0 +1,52 @@
+<?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 CVS_Config extends Class_DigitalResource_Config {
+  public function getConfig() {
+    return ['Introduction' => $this->_('CVS'),
+            'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/CVS',
+            'Url' => '',
+            'Icon' => '',
+            'AdminVars' =>
+            [
+             'BMKEY' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+             'BMID' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+             'BMLABEL' => Class_AdminVar_Meta::newDefault($this->_('Libellé de regroupement des abonnés'))->bePrivate(),
+             'SOURCENAME' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+             'SOURCEID' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+             'SOURCEKEY' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+             'SOURCEPASSWORD' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+             'LOGINTEST' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage CVS'))->bePrivate(),
+            ],
+    ];
+  }
+
+
+  public function isEnabled() {
+    return (('' != $this->getAdminVar('BMKEY'))
+            && ('' != $this->getAdminVar('BMID'))
+            && ('' != $this->getAdminVar('SOURCEPASSWORD'))
+            && ('' != $this->getAdminVar('SOURCEKEY'))
+            && ('' != $this->getAdminVar('SOURCEID'))
+            && ('' != $this->getAdminVar('SOURCENAME')));
+  }
+}
\ No newline at end of file
-- 
GitLab