Skip to content

Commit

Permalink
#31 [Config] add: modif config EASYURL_DEFAULT_ORIGINAL_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Nov 13, 2023
1 parent 7f14353 commit 8d760e2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 38 deletions.
6 changes: 1 addition & 5 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,13 @@
if (dol_strlen($signatureTokenYourlsAPI) > 0) {
dolibarr_set_const($db, 'EASYURL_SIGNATURE_TOKEN_YOURLS_API', $signatureTokenYourlsAPI, 'chaine', 0, '', $conf->entity);
}
if (dol_strlen($defaultOriginalURL) > 0) {
dolibarr_set_const($db, 'EASYURL_DEFAULT_ORIGINAL_URL', $defaultOriginalURL, 'chaine', 0, '', $conf->entity);
}
dolibarr_set_const($db, 'EASYURL_DEFAULT_ORIGINAL_URL', $defaultOriginalURL, 'chaine', 0, '', $conf->entity);

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



/*
* View
*/
Expand Down
3 changes: 3 additions & 0 deletions core/modules/modEasyURL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ public function __construct($db)
$i++ => ['EASYURL_SHOW_PATCH_NOTE', 'integer', 1, '', 0, 'current'],
$i++ => ['EASYURL_ADVANCED_TRIGGER', 'integer', 1, '', 0, 'current'],

// CONST SHORTENER
$i++ => ['EASYURL_SHORTENER_ADDON', 'chaine', 'mod_shortener_standard', '', 0, 'current'],

// CONST DOLIBARR
$i++ => ['CONTRACT_ALLOW_ONLINESIGN', 'integer', 1, '', 0, 'current'],
$i => ['FICHINTER_ALLOW_ONLINE_SIGN', 'integer', 1, '', 0, 'current']
Expand Down
3 changes: 2 additions & 1 deletion langs/fr_FR/easyurl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ GenerateUrlManagement = Gestion de la génération des raccourci
NbUrl = Nombre d'URL
NbUrlDescription = Cette option permet de choisir le nombre d'URL à générée
OriginalUrl = URL d'origine
OriginalUrlDescription = Cette option permet de choisir l'URL d'origine <br> (par défaut si aucune URL n'est renseignée alors l'URL par défaut est utilisée)
OriginalUrlDescription = Cette option permet de choisir l'URL d'origine <br> (par défaut si aucune URL n'est renseignée alors l'URL par défaut est <b>%s</b>)
OriginalUrlDescription = Cette option permet de choisir l'URL d'origine <br> (par défaut si aucune URL n'est renseignée alors l'URL par défaut est <b>%s</b>)
UrlParameters = Paramètre d'URL supplémentaire
UrlParametersDescription = Cette option permet d'ajouter des paramètres d'URLs supplémentaires <br> (exemple : un tiret/une valeur)
UrlMethode = Méthode d'API URL
Expand Down
5 changes: 5 additions & 0 deletions lib/easyurl.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function easyurl_admin_prepare_head(): array
$h = 0;
$head = [];

$head[$h][0] = dol_buildpath('/saturne/admin/object.php', 1) . '?module_name=EasyURL&object_type=shortener';
$head[$h][1] = $conf->browser->layout != 'phone' ? '<i class="fas fa-link pictofixedwidth"></i>' . $langs->trans('Shortener') : '<i class="fas fa-link"></i>';
$head[$h][2] = 'shortener';
$h++;

$head[$h][0] = dol_buildpath('/easyurl/admin/setup.php', 1);
$head[$h][1] = $conf->browser->layout != 'phone' ? '<i class="fas fa-cog pictofixedwidth"></i>' . $langs->trans('ModuleSettings') : '<i class="fas fa-cog"></i>';
$head[$h][2] = 'settings';
Expand Down
74 changes: 42 additions & 32 deletions view/easyurltools.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,35 @@

if ($action == 'generate_url' && $permissionToAdd) {
$error = 0;
$urlMethode = GETPOST('url_methode');
$NbUrl = GETPOST('nb_url');
$originalUrl = GETPOST('original_url');
$urlParameters = GETPOST('url_parameters');
$urlMethode = GETPOST('url_methode');
for ($i = 1; $i <= $NbUrl; $i++) {
$shortener = new Shortener($db);
$shortener->ref = $shortener->getNextNumRef();
if (dol_strlen($originalUrl) > 0) {
$shortener->original_url = $originalUrl . $urlParameters;
if ((dol_strlen($urlParameters) > 0) || dol_strlen(getDolGlobalString('EASYURL_DEFAULT_ORIGINAL_URL')) > 0) {
for ($i = 1; $i <= $NbUrl; $i++) {
$shortener = new Shortener($db);
$shortener->ref = $shortener->getNextNumRef();
if (dol_strlen($originalUrl) > 0) {
$shortener->original_url = $originalUrl . $urlParameters;
}
$shortener->methode = $urlMethode;

$shortener->create($user);

// UrlType : none because we want mass generation url (all can be use but need to change this code)
$result = set_easy_url_link($shortener, 'none', $urlMethode);
if (!empty($result) && is_object($result)) {
setEventMessage($result->message, 'errors');
$error++;
}
}
$shortener->methode = $urlMethode;

$shortener->create($user);

// UrlType : none because we want mass generation url (all can be use but need to change this code)
$result = set_easy_url_link($shortener, 'none', $urlMethode);
if (!empty($result) && is_object($result)) {
setEventMessage($result->message, 'errors');
$error++;
if ($error == 0) {
setEventMessage($langs->trans('GenerateUrlSuccess', $i - 1));
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
}
if ($error == 0) {
setEventMessage($langs->trans('GenerateUrlSuccess', $i - 1));
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
} else {
setEventMessage($langs->trans('UrlParametersFail'));
}
}

Expand All @@ -94,9 +98,15 @@

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

print load_fiche_titre($title, '', 'wrench');
print load_fiche_titre($title, '', 'wrench'); ?>

<div class="wpeo-notice notice-info">
<div class="notice-content">
<div class="notice-title"><strong><?php echo $langs->trans('SocietyObjectContactNotDefinedTitle', $conf->global->EASYCRM_ALREADY_CHECK_OBJECT_CONTACT); ?></strong></div>
</div>
</div>

print load_fiche_titre($langs->trans('GenerateUrlManagement'), '', '');
<?php print load_fiche_titre($langs->trans('GenerateUrlManagement'), '', '');

print '<form name="generate-url-from" id="generate-url-from" action="' . $_SERVER['PHP_SELF'] . '" method="POST">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
Expand All @@ -109,13 +119,22 @@
print '<td>' . $langs->trans('Value') . '</td>';
print '</tr>';

$urlMethode = ['yourls' => 'YOURLS', 'wordpress' => 'WordPress'];
print '<tr class="oddeven"><td>';
print $langs->trans('UrlMethode');
print '</td><td>';
print $langs->trans('UrlMethodeDescription');
print '<td>';
print $form::selectarray('url_methode', $urlMethode, 'yourls');
print '</td></tr>';

print '<tr class="oddeven"><td><label for="nb_url">' . $langs->trans('NbUrl') . '</label></td>';
print '<td>' . $langs->trans('NbUrlDescription') . '</td>';
print '<td><input type="number" name="nb_url" min="0"></td>';
print '</tr>';

print '<tr class="oddeven"><td><label for="original_url">' . $langs->trans('OriginalUrl') . '</label></td>';
print '<td>' . $langs->trans('OriginalUrlDescription') . '</td>';
print '<td>' . $langs->trans('OriginalUrlDescription', getDolGlobalString('EASYURL_DEFAULT_ORIGINAL_URL')) . '</td>';
print '<td><input type="text" name="original_url"></td>';
print '</tr>';

Expand All @@ -124,15 +143,6 @@
print '<td><input type="text" name="url_parameters"></td>';
print '</tr>';

$urlMethode = ['yourls' => 'YOURLS', 'wordpress' => 'WordPress'];
print '<tr class="oddeven"><td>';
print $langs->trans('UrlMethode');
print '</td><td>';
print $langs->trans('UrlMethodeDescription');
print '<td>';
print $form::selectarray('url_methode', $urlMethode, 'yourls');
print '</td></tr>';

print '</table>';
print $form->buttonsSaveCancel('Generate', '');
print '</form>';
Expand Down

0 comments on commit 8d760e2

Please sign in to comment.