Skip to content

Commit

Permalink
#22 [Mod] add: change name for EasyURL
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Sep 14, 2023
1 parent 2a4e5c0 commit 3675b3d
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 163 deletions.
52 changes: 26 additions & 26 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@

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

// Load TinyURL environment
if (file_exists('../tinyurl.main.inc.php')) {
require_once __DIR__ . '/../tinyurl.main.inc.php';
} elseif (file_exists('../../tinyurl.main.inc.php')) {
require_once __DIR__ . '/../../tinyurl.main.inc.php';
// 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 tinyurl main fails');
die('Include of easyurl main fails');
}

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

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

// Global variables definitions
global $conf, $db, $langs, $user;
Expand All @@ -50,7 +50,7 @@
$form = new Form($db);

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

/*
Expand All @@ -62,10 +62,10 @@
$signatureTokenYourlsAPI = GETPOST('signature_token_yourls_api');

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

setEventMessage('SavedConfig');
Expand All @@ -79,8 +79,8 @@
* View
*/

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

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

Expand All @@ -89,8 +89,8 @@
print load_fiche_titre($title, $linkback, 'title_setup');

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

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

Expand All @@ -107,30 +107,30 @@

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->TINYURL_URL_YOURLS_API . '"></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->TINYURL_SIGNATURE_TOKEN_YOURLS_API . '"></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('TINYURL_USE_SHA_URL');
print ajax_constantonoff('EASYURL_USE_SHA_URL');
print '</td></tr>';

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

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

print '</table>';
Expand Down
40 changes: 20 additions & 20 deletions class/actions_tinyurl.class.php → class/actions_easyurl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
*/

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

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

/**
* Class ActionsTinyurl
* Class ActionsEasyurl
*/
class ActionsTinyurl
class ActionsEasyurl
{
/**
* @var DoliDB Database handler
Expand Down Expand Up @@ -79,20 +79,20 @@ public function printCommonFooter(array $parameters): int
if ($object->status > $object::STATUS_DRAFT) {
print '<link href="../../custom/saturne/css/saturne.min.css" rel="stylesheet">';

$pictoPath = dol_buildpath('/tinyurl/img/tinyurl_color.png', 1);
$pictoPath = dol_buildpath('/easyurl/img/easyurl_color.png', 1);
$picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule');
$urlTypes = ['payment', 'signature'];
foreach ($urlTypes as $urlType) {
$checkTinyUrlLink = get_tiny_url_link($object, $urlType);
$jQueryElement = '.' . $object->element . '_extras_tiny_url_' . $urlType . '_link';
if ($checkTinyUrlLink == 0 && getDolGlobalInt('TINYURL_MANUAL_GENERATION')) {
$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_tiny_url&url_type=' . $urlType . '&token=' . newToken() . '">';
$output .= img_picto($langs->trans('SetTinyURLLink'), 'fontawesome_fa-redo_fas_#444', 'class="paddingright pictofixedwidth valignmiddle"') . '</a>';
$output .= '</span>' . img_picto($langs->trans('GetTinyURLErrors'), 'fontawesome_fa-exclamation-triangle_fas_#bc9526') . '</span>';
$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_tiny_url_' . $urlType . '_link']) && $checkTinyUrlLink > 0) {
$output = showValueWithClipboardCPButton($object->array_options['options_tiny_url_' . $urlType . '_link'], 0, 'none');
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 . "'"; ?>;
Expand All @@ -106,11 +106,11 @@ public function printCommonFooter(array $parameters): int
if (in_array($parameters['currentcontext'], ['propallist', 'orderlist', 'invoicelist'])) {
print '<link href="../../custom/saturne/css/saturne.min.css" rel="stylesheet">';

$pictoPath = dol_buildpath('/tinyurl/img/tinyurl_color.png', 1);
$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 = 'tiny_url_' . $urlType . '_link'; ?>
$jQueryElement = 'easy_url_' . $urlType . '_link'; ?>

<script>
var objectElement = <?php echo "'" . $jQueryElement . "'"; ?>;
Expand All @@ -136,8 +136,8 @@ public function printCommonFooter(array $parameters): int
public function doActions(array $parameters, $object, string $action): int
{
if (in_array($parameters['currentcontext'], ['propalcard', 'ordercard', 'invoicecard', 'contractcard', 'interventioncard'])) {
if ($action == 'set_tiny_url') {
set_tiny_url_link($object, GETPOST('url_type'));
if ($action == 'set_easy_url') {
set_easy_url_link($object, GETPOST('url_type'));

header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit;
Expand Down
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
Loading

0 comments on commit 3675b3d

Please sign in to comment.