Subversion Repositories oidplus

Rev

Rev 1064 | Rev 1116 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. // ATTENTION: If you change something, please make sure that the changes
  21. //            are synchronous with OIDplusPageRaAutomatedAJAXCalls
  22.  
  23. namespace ViaThinkSoft\OIDplus;
  24.  
  25. // phpcs:disable PSR1.Files.SideEffects
  26. \defined('INSIDE_OIDPLUS') or die;
  27. // phpcs:enable PSR1.Files.SideEffects
  28.  
  29. class OIDplusPageAdminNostalgia extends OIDplusPagePluginAdmin {
  30.  
  31.         public function gui($id, &$out, &$handled) {
  32.                 if ($id === 'oidplus:nostalgia') {
  33.                         $handled = true;
  34.                         $out['title'] = _L('Nostalgia');
  35.                         $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
  36.  
  37.                         if (!OIDplus::authUtils()->isAdminLoggedIn()) {
  38.                                 $out['icon'] = 'img/error.png';
  39.                                 $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
  40.                                 return;
  41.                         }
  42.  
  43.                         $out['text'] = '<p>'._L('Did you ever wonder what OIDplus would look like if it had been created in the era of MS-DOS, Windows 3.11, or Windows 95? Just download the ZIP files below and have a look!').'</p>';
  44.  
  45.                         if (class_exists('ZipArchive')) {
  46.                                 $out['text'] .= '<ul>';
  47.                                 $out['text'] .= '<li><a href="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'export_dos.php">'._L('Download OIDplus for DOS').'</a>, '._L('including your database* (only OIDs)').'</li>';
  48.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/252/oidplus_dos.zip">'._L('Download OIDplus for DOS').'</a>, '._L('without data').'</li>';
  49.                                 $out['text'] .= '<li><a href="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'export_win.php">'._L('Download OIDplus for Windows 3.11, 95, or later').'</a>, '._L('including your database* (only OIDs)').'</li>';
  50.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/254/oidplus_win311.zip">'._L('Download OIDplus for Windows 3.11').'</a>, '._L('without data').'</li>';
  51.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/253/oidplus_win95.zip">'._L('Download OIDplus for Windows 95 or later').'</a>, '._L('without data').'</li>';
  52.                                 $out['text'] .= '</ul>';
  53.                                 $out['text'] .= '<p>'._L('* Please note that the download might be delayed since your OID database is exported and added to the ZIP file.').'</p>';
  54.                         } else {
  55.                                 $out['text'] .= '<ul>';
  56.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/252/oidplus_dos.zip">'._L('Download OIDplus for DOS').'</a>, '._L('without data').'</li>';
  57.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/254/oidplus_win311.zip">'._L('Download OIDplus for Windows 3.11').'</a>, '._L('without data').'</li>';
  58.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/253/oidplus_win95.zip">'._L('Download OIDplus for Windows 95 or later').'</a>, '._L('without data').'</li>';
  59.                                 $out['text'] .= '</ul>';
  60.                                 $out['text'] .= '<p><font color="red">'._L('The PHP extension "ZipArchive" needs to be installed to create a ZIP archive with an included database. Otherwise, you can just download the plain program without data.').'</font></p>';
  61.                         }
  62.                 }
  63.         }
  64.  
  65.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  66.                 if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
  67.  
  68.                 if (file_exists(__DIR__.'/img/main_icon16.png')) {
  69.                         $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
  70.                 } else {
  71.                         $tree_icon = null; // default icon (folder)
  72.                 }
  73.  
  74.                 $json[] = array(
  75.                         'id' => 'oidplus:nostalgia',
  76.                         'icon' => $tree_icon,
  77.                         'text' => _L('Nostalgia')
  78.                 );
  79.  
  80.                 return true;
  81.         }
  82.  
  83.         public function tree_search($request) {
  84.                 return false;
  85.         }
  86.  
  87.         public function implementsFeature($id) {
  88.                 if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
  89.                 return false;
  90.         }
  91.  
  92.         public function getNotifications($user=null): array {
  93.                 // Interface 1.3.6.1.4.1.37476.2.5.2.3.8
  94.                 $notifications = array();
  95.                 if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
  96.                         if (!class_exists('ZipArchive')) {
  97.                                 $title = _L('Nostalgia');
  98.                                 $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:nostalgia').'>'.htmlentities($title).'</a>', 'Zip'));
  99.                         }
  100.                 }
  101.                 return $notifications;
  102.         }
  103.  
  104. }
  105.