LibreCodeCoop / trademark

Allow customization of logos, background and custom CSS
GNU Affero General Public License v3.0
24 stars 9 forks source link

How to update this plugin #6

Closed Windayz closed 5 months ago

Windayz commented 5 months ago

Hello,

I've downloaded the new release, deleted the old plugin folder and added the new one, but GLPI doesn't suggest that I update. What should I do?

Thanks

Windayz commented 5 months ago

You forgot to modify setup.php with the correct version number:

<?php

define('PLUGIN_TRADEMARK_VERSION', '1.4.0');

// Minimal GLPI version, inclusive
define("PLUGIN_TRADEMARK_MIN_GLPI_VERSION", "10.0.0");

// Maximum GLPI version, exclusive
define("PLUGIN_TRADEMARK_MAX_GLPI_VERSION", "10.1.0");

$folder = basename(dirname(__FILE__));

if ($folder !== "trademark") {
   $msg = sprintf("Please, rename the plugin folder \"%s\" to \"trademark\"", $folder);
   Session::addMessageAfterRedirect($msg, true, ERROR);
}

// Init the hooks of the plugins -Needed
function plugin_init_trademark() {
   global $PLUGIN_HOOKS, $CFG_GLPI;
   $PLUGIN_HOOKS['csrf_compliant']['trademark'] = true;

   Plugin::registerClass('PluginTrademarkConfig', ['addtabon' => 'Config']);
   $PLUGIN_HOOKS['config_page']['trademark'] = 'front/config.form.php';

   $plugin = new Plugin();

   if ($plugin->isInstalled('trademark') && $plugin->isActivated('trademark')) {

      $autoload = __DIR__ . '/vendor/autoload.php';
      if (file_exists($autoload)) {
         include_once $autoload;
      };

      Plugin::registerClass('PluginTrademarkConfig', [
         'addtabon' => ['Config']
      ]);

      $PLUGIN_HOOKS['display_login']['trademark'] = "plugin_trademark_display_login";

      // Tip Trick to add version in css output
      $PLUGIN_HOOKS["add_css"]['trademark'] = new PluginTrademarkFileVersion('front/internal.css.php');
      $PLUGIN_HOOKS["add_javascript"]['trademark'] = new PluginTrademarkFileVersion('front/internal.js.php');

      $CFG_GLPI['javascript']['config']['config'][] = 'codemirror';
      $CFG_GLPI['javascript']['config']['config'][] = 'tinymce';
   }
}

// Get the name and the version of the plugin - Needed
function plugin_version_trademark() {
   return [
      'name'           => t_trademark('Trademark'),
      'version'        => PLUGIN_TRADEMARK_VERSION,
      'author'         => '<a href="https://librecode.coop/">LibreCode</a>, <a href="https://github.com/edgardmessias">Edgard</a>',
      'homepage'       => 'https://github.com/librecodecoop/trademark',
      'license'        => 'GPL v2+',
      'minGlpiVersion' => PLUGIN_TRADEMARK_MIN_GLPI_VERSION,
      'requirements'   => [
         'glpi' => [
            'min' => PLUGIN_TRADEMARK_MIN_GLPI_VERSION,
            'max' => PLUGIN_TRADEMARK_MAX_GLPI_VERSION,
         ]
      ]
   ];
}

// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_trademark_check_prerequisites() {
   if (version_compare(GLPI_VERSION, PLUGIN_TRADEMARK_MIN_GLPI_VERSION, 'lt')) {
      echo "This plugin requires GLPI >= " . PLUGIN_TRADEMARK_MIN_GLPI_VERSION;
      return false;
   } else {
      return true;
   }
}

function plugin_trademark_check_config() {
   return true;
}

function t_trademark($str) {
   return __($str, 'trademark');
}
vitormattos commented 5 months ago

Thanks by your report!

vitormattos commented 5 months ago

@Windayz could you check if the new release is ok?

Windayz commented 5 months ago

Yes, everything is ok, thank you :)

vitormattos commented 5 months ago

If you liked this app and others solutions of LibreCode, like LibreSign, fell free to help us to maintain this and other open source softwares making a pontual or recurrent funding here: https://github.com/sponsors/LibreSign We centralized all sponsors at LibreSign project because is our main product now and we wish to have the enouth to be possible dedicate more time to open source projects and help other software engineers. You also can help us making more tests, sending issues, giving stars at this repository and at LibreSign repository, announcing the LibreSign app and by a lot of other ways. Very happy by your contribution! Thanks a lot again!