From b5f8871216a6acad2a5ca4cde873696c924350ec Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@git-test.afi-sa.fr> Date: Mon, 3 Jun 2013 16:06:32 +0000 Subject: [PATCH] =?UTF-8?q?Numilog=20:=20creation=20d'un=20lien=20pour=20a?= =?UTF-8?q?cceder=20=C3=A0=20Numilog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 + library/Class/NumilogLink.php | 60 +++++++++++++++++++ library/Class/Systeme/ModulesMenu/Numilog.php | 54 +++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 library/Class/NumilogLink.php create mode 100644 library/Class/Systeme/ModulesMenu/Numilog.php diff --git a/.gitattributes b/.gitattributes index bcec236feab..6dd8476e178 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2283,6 +2283,7 @@ library/Class/Notice/RubriqueFacette.php -text library/Class/NoticeHtml.php -text library/Class/NoticeOAI.php -text library/Class/NoticeUnimarc.php -text +library/Class/NumilogLink.php -text library/Class/OpdsCatalog.php -text library/Class/OrgFileParser.php -text library/Class/Ouverture.php -text @@ -2389,6 +2390,7 @@ library/Class/Systeme/ModulesMenu/LastNews.php -text library/Class/Systeme/ModulesMenu/Menu.php -text library/Class/Systeme/ModulesMenu/News.php -text library/Class/Systeme/ModulesMenu/Null.php -text +library/Class/Systeme/ModulesMenu/Numilog.php -text library/Class/Systeme/ModulesMenu/Paniers.php -text library/Class/Systeme/ModulesMenu/Profil.php -text library/Class/Systeme/ModulesMenu/RechercheAvancee.php -text diff --git a/library/Class/NumilogLink.php b/library/Class/NumilogLink.php new file mode 100644 index 00000000000..4dd996ea568 --- /dev/null +++ b/library/Class/NumilogLink.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class Class_NumilogLink extends Class_WebService_Abstract { + use Trait_TimeSource; + + const CVS_SOURCEXPIRATIONTIME = 30; + + protected $_user; + + public static function forUser($user) { + return new self($user); + } + + + public function __construct($user) { + $this->_user = $user; + } + + + public function baseUrl() { + return Class_AdminVar::get('NUMILOG_URL'); + } + + + + function getTicket() { + return md5(Zend_Session::getId()); + } + + + + function getNumilogLnk($lnk){ + if ($this->_user) + $url = $this->getBaseUrl().'?ticket='.$this->getTicket(); + else + return $this->getBaseUrl(); + } + +} + +?> \ No newline at end of file diff --git a/library/Class/Systeme/ModulesMenu/Numilog.php b/library/Class/Systeme/ModulesMenu/Numilog.php new file mode 100644 index 00000000000..dfbdc2a33c8 --- /dev/null +++ b/library/Class/Systeme/ModulesMenu/Numilog.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +class Class_Systeme_ModulesMenu_Numilog extends Class_Systeme_ModulesMenu_Null { + /** @var string */ + protected $_group = Class_Systeme_ModulesMenu::GROUP_MENU_ABONNES; + + /** @var string */ + protected $_type_module = 'Numilog'; + + /** @var string */ + protected $_libelle = 'Lien vers Numilog'; + + + public function getNumilogUrlForUser($user) { + if ($user->isAbonne() && $user->isAbonnementValid()) + return Class_NumilogLink::forUser($user)->url(); + return Class_AdminVar::get('NUMILOG_URL'); + } + + public function getUrl($preferences=[]) { + return ($user = Class_Users::getIdentity()) + ? $this->getNumilogUrlForUser($user) + : Class_AdminVar::get('NUMILOG_URL'); + } + + + public function shouldOpenInNewWindow($preferences) { + return null != Class_Users::getIdentity(); + } + + + public function isVisibleForProfil($profil) { + return Class_AdminVar::isNumilogEnabled(); + } +} +?> \ No newline at end of file -- GitLab