Skip to content

Commit

Permalink
Eoxia#80 [PublicShortener] add: perm to assign
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Feb 12, 2025
1 parent 389a20c commit 7b96b02
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions core/modules/modEasyURL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ public function __construct($db)
$this->rights[$r][4] = 'shortener';
$this->rights[$r][5] = 'delete';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1);
$this->rights[$r][1] = $langs->transnoentities('AssignShorteners');
$this->rights[$r][4] = 'shortener';
$this->rights[$r][5] = 'assign';
$r++;

/* ADMINPAGE PANEL ACCESS PERMISSIONS */
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1);
Expand Down
3 changes: 3 additions & 0 deletions langs/fr_FR/easyurl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ ExportError = Erreur lors de la génération de l'URL
# Shortener - Raccourcissement d'URL
#

# Right - Droit
AssignShorteners = Affecter les raccourcissements d'URLs

# Data - Donnée
Shortener = Raccourcissement d'URL
TheShortener = le raccourcissement d'URL
Expand Down
17 changes: 8 additions & 9 deletions public/shortener/public_shortener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', 1);
}
if (!defined('NOLOGIN')) { // This means this output page does not require to be logged.
define('NOLOGIN', 1);
}
if (!defined('NOCSRFCHECK')) { // We accept to go on this page from external website.
define('NOCSRFCHECK', 1);
}
Expand Down Expand Up @@ -60,7 +57,7 @@
require_once __DIR__ . '/../../lib/easyurl_function.lib.php';

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

// Load translation files required by the page
saturne_load_langs();
Expand All @@ -72,7 +69,6 @@
// Initialize technical objects
$object = new Shortener($db);
$productLot = new ProductLot($db);
$user = new User($db);

$hookmanager->initHooks(['publicshortener', 'saturnepublicinterface']); // Note that conf->hooks_modules contains array

Expand All @@ -82,6 +78,8 @@

$conf->setEntityValues($db, $entity);

$permissionToAssign = $user->hasRight('easyurl', 'shortener', 'assign');

/*
* Actions
*/
Expand All @@ -93,7 +91,7 @@
}

if (empty($resHook)) {
if ($action == 'assign_qrcode') {
if ($action == 'assign_qrcode' && $permissionToAssign) {
$fkElementID = GETPOSTINT('fk_element');
$shortenerID = GETPOSTINT('shortener');

Expand Down Expand Up @@ -130,7 +128,7 @@
}

/*
* View
* View
*/

$title = $langs->trans('PublicInterfaceObject', $langs->transnoentities('OfAssignShortener')) . '</a>';
Expand Down Expand Up @@ -178,8 +176,9 @@
print Form::selectarray('shortener', $shortenerArrays, '', $langs->transnoentities('NumQRCode'));
?>
</div>

<button type="submit" class="wpeo-button" style="background: var(--butactionbg); border-color: var(--butactionbg);"><?php echo $langs->transnoentities('Assign'); ?></button>
<?php if ($permissionToAssign) : ?>
<button type="submit" class="wpeo-button" style="background: var(--butactionbg); border-color: var(--butactionbg);"><?php echo $langs->transnoentities('Assign'); ?></button>
<?php endif; ?>
</div>
</div>
<?php else :
Expand Down

0 comments on commit 7b96b02

Please sign in to comment.