Skip to content

Commit

Permalink
Merge pull request #24 from Eoxia/develop
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
nicolas-eoxia authored Sep 14, 2023
2 parents bec3c6c + a174ef6 commit 78c0d5a
Show file tree
Hide file tree
Showing 28 changed files with 1,783 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.php]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
17 changes: 17 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Generate Auto Changelog'
on:
push:
branches:
- main
jobs:
master:
name: 'build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Generate Auto Changelog
uses: Evarisk/action-auto-changelog@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
621 changes: 621 additions & 0 deletions COPYING

Large diffs are not rendered by default.

54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# TinyURL
Creation of shortened urls for yourls and Dolibarr
# EasyURL sur [DOLIBARR ERP CRM](https://dolibarr.org)

## Informations

- Numéro du module : 436305
- Dernière mise à jour : 13/09/2023
- Éditeur : [Eoxia](https://eoxia.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

## Version

- Version : 1.0.0
- Compatibilité : Dolibarr 16.0.0 - 18.0.1
- Saturne framework : 1.1.2

## Liens

- Support & Assistance : [Forum dolibarr.fr](https://dolibarr.fr) / Par mail à technique@eoxia.com
- Demo : [Demo EasyURL](https://demodoli.digirisk.com) - ID: demo - Password: demo
- Documentation : [Wiki EasyURL](https://wiki.dolibarr.org/index.php/Module_EasyURL)
- Projet GitHub : [Projet EasyURL](https://github.com/Eoxia/easyurl/projects?query=is%3Aopen)
- Saturne Framework : [Télécharger Saturne](https://dolistore.com/fr/modules/1906-Saturne.html)
- D'autres modules développés par Eoxia disponibles sur [DoliStore.com](https://dolistore.com)

## Fonctionnalités

- Création d'URLs raccourcies pour YOURLS et Dolibarr

## Traductions

- Français
- Anglais

## Installation

### Méthode 1 :

- Depuis le menu "Déployer/Installer un module externe" de Dolibarr :
- Glisser l'archive ZIP 'module_easyurl-X.Y.Z' et cliquer sur "ENVOYER FICHIER"
- Glisser l'archive ZIP 'module_saturne-X.Y.Z' et cliquer sur "ENVOYER FICHIER"
- Activer le module dans la liste des Modules/Applications installés

### Méthode 2 :

- Dans le dossier "dolibarr/htdocs/custom" copier la ligne suivante :
```
git clone -b main https://github.com/Eoxia/easyurl.git easyurl
git clone -b main https://github.com/Evarisk/saturne.git saturne
```
- Activer le module dans la liste des Modules/Applications installés
2 changes: 2 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
141 changes: 141 additions & 0 deletions admin/setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php
/* Copyright (C) 2023 EVARISK <technique@evarisk.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file admin/setup.php
* \ingroup easyurl
* \brief EasyURL setup page
*/

// Load EasyURL environment
if (file_exists('../easyurl.main.inc.php')) {
require_once __DIR__ . '/../easyurl.main.inc.php';
} elseif (file_exists('../../easyurl.main.inc.php')) {
require_once __DIR__ . '/../../easyurl.main.inc.php';
} else {
die('Include of easyurl main fails');
}

// Load Dolibarr libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';

// Load EasyURL libraries
require_once __DIR__ . '/../lib/easyurl.lib.php';

// Global variables definitions
global $conf, $db, $langs, $user;

// Load translation files required by the page
saturne_load_langs(['admin']);

// Get parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');

// Initialize view objects
$form = new Form($db);

// Security check - Protection if external user
$permissionToRead = $user->rights->easyurl->adminpage->read;
saturne_check_access($permissionToRead);

/*
* Actions
*/

if ($action == 'set_config') {
$URLYourlsAPI = GETPOST('url_yourls_api');
$signatureTokenYourlsAPI = GETPOST('signature_token_yourls_api');

if (dol_strlen($URLYourlsAPI) > 0) {
dolibarr_set_const($db, 'EASYURL_URL_YOURLS_API', $URLYourlsAPI, 'chaine', 0, '', $conf->entity);
}
if (dol_strlen($signatureTokenYourlsAPI) > 0) {
dolibarr_set_const($db, 'EASYURL_SIGNATURE_TOKEN_YOURLS_API', $signatureTokenYourlsAPI, 'chaine', 0, '', $conf->entity);
}

setEventMessage('SavedConfig');
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}



/*
* View
*/

$title = $langs->trans('ModuleSetup', 'EasyURL');
$help_url = 'FR:Module_EasyURL';

saturne_header(0,'', $title, $help_url);

// Subheader
$linkback = '<a href="' . ($backtopage ?: DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans('BackToModuleList') . '</a>';
print load_fiche_titre($title, $linkback, 'title_setup');

// Configuration header
$head = easyurl_admin_prepare_head();
print dol_get_fiche_head($head, 'settings', $title, -1, 'easyurl_color@easyurl');

print load_fiche_titre($langs->trans('Config'), '', '');

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="set_config">';

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Parameters') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td>' . $langs->trans('Value') . '</td>';
print '</tr>';

print '<tr class="oddeven"><td><label for="url_yourls_api">' . $langs->trans('URLYourlsAPI') . '</label></td>';
print '<td>' . $langs->trans('URLYourlsAPIDescription') . '</td>';
print '<td><input type="text" name="url_yourls_api" value="' . $conf->global->EASYURL_URL_YOURLS_API . '"></td>';
print '</td></tr>';

print '<tr class="oddeven"><td><label for="signature_token_yourls_api">' . $langs->trans('SignatureTokenYourlsAPI') . '</label></td>';
print '<td>' . $langs->trans('SignatureTokenYourlsAPIDescription') . '</td>';
print '<td><input type="password" name="signature_token_yourls_api" value="' . $conf->global->EASYURL_SIGNATURE_TOKEN_YOURLS_API . '"></td>';
print '</td></tr>';

print '<tr class="oddeven"><td>' . $langs->trans('UseShaUrl') . '</td>';
print '<td>' . $langs->trans('UseShaUrlDescription') . '</td>';
print '<td>';
print ajax_constantonoff('EASYURL_USE_SHA_URL');
print '</td></tr>';

print '<tr class="oddeven"><td>' . $langs->trans('AutomaticEasyUrlGeneration') . '</td>';
print '<td>' . $langs->trans('AutomaticEasyUrlGenerationDescription') . '</td>';
print '<td>';
print ajax_constantonoff('EASYURL_AUTOMATIC_GENERATION');
print '</td></tr>';

print '<tr class="oddeven"><td>' . $langs->trans('ManualEasyUrlGeneration') . '</td>';
print '<td>' . $langs->trans('ManualEasyUrlGenerationDescription') . '</td>';
print '<td>';
print ajax_constantonoff('EASYURL_MANUAL_GENERATION');
print '</td></tr>';

print '</table>';
print $form->buttonsSaveCancel('Save', '');
print '</form>';

$db->close();
llxFooter();
151 changes: 151 additions & 0 deletions class/actions_easyurl.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
/* Copyright (C) 2023 EVARISK <technique@evarisk.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file class/actions_easyurl.class.php
* \ingroup easyurl
* \brief EasyURL hook overload
*/

// Load EasyURL libraries
require_once __DIR__ . '/../lib/easyurl_function.lib.php';

/**
* Class ActionsEasyurl
*/
class ActionsEasyurl
{
/**
* @var DoliDB Database handler
*/
public DoliDB $db;

/**
* @var string Error code (or message)
*/
public string $error = '';

/**
* @var array Errors.
*/
public array $errors = [];

/**
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
*/
public array $results = [];

/**
* @var string String displayed by executeHook() immediately after return
*/
public string $resprints;

/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db)
{
$this->db = $db;
}

/**
* Overloading the printCommonFooter function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @return int 0 < on error, 0 on success, 1 to replace standard code
* @throws Exception
*/
public function printCommonFooter(array $parameters): int
{
global $object, $langs;

if (in_array($parameters['currentcontext'], ['propalcard', 'ordercard', 'invoicecard', 'contractcard', 'interventioncard'])) {
if ($object->status > $object::STATUS_DRAFT) {
$cssPath = dol_buildpath('/saturne/css/saturne.min.css', 1);
print '<link href="' . $cssPath . '" rel="stylesheet">';

$pictoPath = dol_buildpath('/easyurl/img/easyurl_color.png', 1);
$picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule');
$urlTypes = ['payment', 'signature'];
foreach ($urlTypes as $urlType) {
$checkEasyUrlLink = get_easy_url_link($object, $urlType);
$jQueryElement = '.' . $object->element . '_extras_easy_url_' . $urlType . '_link';
if ($checkEasyUrlLink == 0 && getDolGlobalInt('EASYURL_MANUAL_GENERATION')) {
$output = $picto;
$output .= '<a class="reposition editfielda" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=set_easy_url&url_type=' . $urlType . '&token=' . newToken() . '">';
$output .= img_picto($langs->trans('SetEasyURLLink'), 'fontawesome_fa-redo_fas_#444', 'class="paddingright pictofixedwidth valignmiddle"') . '</a>';
$output .= '</span>' . img_picto($langs->trans('GetEasyURLErrors'), 'fontawesome_fa-exclamation-triangle_fas_#bc9526') . '</span>';
}
if (!empty($object->array_options['options_easy_url_' . $urlType . '_link']) && $checkEasyUrlLink > 0) {
$output = showValueWithClipboardCPButton($object->array_options['options_easy_url_' . $urlType . '_link'], 0, 'none');
} ?>
<script>
var objectElement = <?php echo "'" . $jQueryElement . "'"; ?>;
jQuery(objectElement).prepend(<?php echo json_encode($output); ?>);
</script>
<?php
}
}
}

if (in_array($parameters['currentcontext'], ['propallist', 'orderlist', 'invoicelist'])) {
$cssPath = dol_buildpath('/saturne/css/saturne.min.css', 1);
print '<link href="' . $cssPath . '" rel="stylesheet">';

$pictoPath = dol_buildpath('/easyurl/img/easyurl_color.png', 1);
$picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule');
$urlTypes = ['payment', 'signature'];
foreach ($urlTypes as $urlType) {
$jQueryElement = 'easy_url_' . $urlType . '_link'; ?>

<script>
var objectElement = <?php echo "'" . $jQueryElement . "'"; ?>;
var outJS = <?php echo json_encode($picto); ?>;
var cell = $('.liste > tbody > tr.liste_titre').find('th[data-titlekey="' + objectElement + '"]');
cell.prepend(outJS);
</script>
<?php
}
}

return 0; // or return 1 to replace standard code
}

/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object Current object
* @param string $action Current action
* @return int 0 < on error, 0 on success, 1 to replace standard code
*/
public function doActions(array $parameters, $object, string $action): int
{
if (in_array($parameters['currentcontext'], ['propalcard', 'ordercard', 'invoicecard', 'contractcard', 'interventioncard'])) {
if ($action == 'set_easy_url') {
set_easy_url_link($object, GETPOST('url_type'));

header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit;
}
}

return 0; // or return 1 to replace standard code
}
}
2 changes: 2 additions & 0 deletions class/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
2 changes: 2 additions & 0 deletions core/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
2 changes: 2 additions & 0 deletions core/modules/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
Loading

0 comments on commit 78c0d5a

Please sign in to comment.