# COPR Ligenix's spec file for glpi-plugin-moreticket
#
# Copyright (c) 2023-2023 Jean-Marc Liger 
#
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
%global pluginname moreticket
%global glpi_min   9.5
%global glpi_max   9.6


Name:           glpi-plugin-%{pluginname}
Version:        1.6.1
Release:        1%{?dist}
Summary:        GLPI Plugin which allows to add 4 new options on a ticket
Summary(fr):    Extension GLPI qui permet d'ajouter 4 nouvelles options sur un ticket

License:        GPLv2
URL:            https://github.com/InfotelGLPI/%{pluginname}
  
Source0:        https://github.com/InfotelGLPI/%{pluginname}/releases/download/v%{version}/glpi-%{pluginname}-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  gettext

%if 0%{?fedora} || 0%{?rhel} >= 8
Requires:      (glpi >= %{glpi_min} with glpi < %{glpi_max})
%else
Requires:       glpi >= %{glpi_min}
Requires:       glpi <  %{glpi_max}
%endif


%description
This plugin allows to add 4 new options on a GLPI ticket
- When creating a ticket, when selecting the "Solved" or "Closed" status, the ticket offers you to fill in the solution of the ticket,
- When creating and modifying a ticket, when selecting the "Pending" status, you will be able to define types of waiting, the reason for the pending and a report date,
- A new area will be available to add information following the closure of the ticket,
- When creating and modifying a ticket, when selecting the urgency depending on the settings made in the configuration of the plugin, you can define a justification.


%description -l fr
Cette extension permet d'ajouter 4 nouvelles options sur un ticket GLPI
- A la création d'un ticket, lors de la sélection du statut "Résolu" ou "Clos", le ticket vous proposera de remplir la solution du ticket,
- A la création et à la modification d'un ticket, lors de la sélection du statut "En attente", vous pourrez définir des types d'attente, la raison de la mise en attente ainsi qu'une date de report,
- Une nouvelle zone sera disponible pour ajouter des informations suite à la clôture du ticket,
- A la création et à la modification d'un ticket, lors de la sélection de l'urgence en fonction du paramètrage effectué dans la configuration du plugin, vous pourrez définir une justification.


%prep
%setup -q -c 

# display compatibility check
grep 'min' %{pluginname}/setup.php

# remove unused files
rm     %{pluginname}/composer.{json,lock}
rm     %{pluginname}/.atoum.php
rm -rf %{pluginname}/{.gitattributes,.gitignore,.github}

# move doc files
mkdir docs
mv %{pluginname}/README.md docs/

# protect sql files
cat >httpd <<EOF
<Directory /usr/share/glpi/plugins/%{pluginname}/sql>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order Allow,Deny
        Deny from all
    </IfModule>
</Directory>
EOF

# create link to LICENSE for standard doc folder
ln -s %{_datadir}/glpi/plugins/%{pluginname}/LICENSE LICENSE


%build
# regenerate the locales
for po in %{pluginname}/locales/*.po
do
   msgfmt $po -o $(dirname $po)/$(basename $po .po).mo
done


%install
mkdir -p %{buildroot}/%{_datadir}/glpi/plugins
cp -ar %{pluginname} %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}

# ===== apache =====
mkdir -p %{buildroot}/%{_sysconfdir}/httpd/conf.d/
install --mode 644 httpd %{buildroot}/%{_sysconfdir}/httpd/conf.d/%{name}.conf

for i in %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}/locales/*
do
  lang=$(basename $i)
  echo "%lang(${lang:0:2}) %{_datadir}/glpi/plugins/%{pluginname}/locales/${lang}"
done | tee %{name}.lang


%files -f %{name}.lang
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc docs/*
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
%dir %{_datadir}/glpi/plugins/%{pluginname}
%dir %{_datadir}/glpi/plugins/%{pluginname}/locales
# LICENSE file required by installation process
%{_datadir}/glpi/plugins/%{pluginname}/LICENSE
%{_datadir}/glpi/plugins/%{pluginname}/*.php
%{_datadir}/glpi/plugins/%{pluginname}/ajax
%{_datadir}/glpi/plugins/%{pluginname}/css
%{_datadir}/glpi/plugins/%{pluginname}/front
%{_datadir}/glpi/plugins/%{pluginname}/inc
%{_datadir}/glpi/plugins/%{pluginname}/scripts
%{_datadir}/glpi/plugins/%{pluginname}/sql


%changelog
* Thu May 04 2023 Jean-Marc Liger <ligenix@iscp.fr> - 1.6.1-1
- Version 1.6.1 for GLPI 9.5.x
- Initial RPM based on Remi Collet previous GLPI plugins spec files