Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
Overdrive | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
90 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
showMyContentLink | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
42 | |||
showOverdriveAdminLink | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * Overdrive view helper |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2018. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package View_Helpers |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development Wiki |
28 | */ |
29 | |
30 | namespace VuFind\View\Helper\Root; |
31 | |
32 | use VuFind\DigitalContent\OverdriveConnector; |
33 | |
34 | /** |
35 | * Overdrive view helper |
36 | * |
37 | * @category VuFind |
38 | * @package View_Helpers |
39 | * @author Brent Palmer <brent-palmer@icpl.org> |
40 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
41 | * @link https://vufind.org/wiki/development Wiki |
42 | */ |
43 | class Overdrive extends \Laminas\View\Helper\AbstractHelper |
44 | { |
45 | /** |
46 | * Overdrive connector. |
47 | * |
48 | * @var OverdriveConnector |
49 | */ |
50 | protected $connector; |
51 | |
52 | /** |
53 | * Constructor |
54 | * |
55 | * @param OverdriveConnector $connector Overdrive connector |
56 | */ |
57 | public function __construct(OverdriveConnector $connector = null) |
58 | { |
59 | $this->connector = $connector; |
60 | } |
61 | |
62 | /** |
63 | * Is Overdrive content active? |
64 | * |
65 | * @return bool |
66 | */ |
67 | public function showMyContentLink() |
68 | { |
69 | //if not configured at all, connector is null |
70 | if (null === $this->connector) { |
71 | return false; |
72 | } |
73 | $config = $this->connector->getConfig(); |
74 | if ($config->showMyContent == 'always') { |
75 | return true; |
76 | } elseif ($config->showMyContent == 'never') { |
77 | return false; |
78 | } else { |
79 | //assume that it is accessOnly |
80 | $result = $this->connector->getAccess(); |
81 | |
82 | if (!$result->status && $result->code == 'od_account_noaccess') { |
83 | return false; |
84 | } |
85 | return true; |
86 | } |
87 | } |
88 | |
89 | /** |
90 | * Show the Overdrive API Admin Menu Item? |
91 | * |
92 | * @return bool |
93 | */ |
94 | public function showOverdriveAdminLink() |
95 | { |
96 | // If not configured at all, connector is null |
97 | if (null === $this->connector) { |
98 | return false; |
99 | } |
100 | $config = $this->connector->getConfig(); |
101 | return (bool)($config->showOverdriveAdminMenu ?? false); |
102 | } |
103 | } |