fix permissions, table name, icon

This commit is contained in:
Jean-Christian Denis 2022-12-01 23:22:10 +01:00
parent 31a1fc4232
commit bd362a6700
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
11 changed files with 86 additions and 19 deletions

View file

@ -22,9 +22,9 @@ require_once __DIR__ . '/_widgets.php';
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Links shortener'), __('Links shortener'),
dcCore::app()->adminurl->get('admin.plugin.kUtRL'), dcCore::app()->adminurl->get('admin.plugin.kUtRL'),
dcPage::getPF('kUtRL/icon.png'), urldecode(dcPage::getPF('kUtRL/icon.svg')),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.kUtRL')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.kUtRL')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->check(dcAuth::PERMISSION_ADMIN, dcCore::app()->blog->id) dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)
); );
# Admin behaviors # Admin behaviors
@ -69,7 +69,7 @@ class adminKutrl
'url' => dcCore::app()->adminurl->get('admin.plugin.kUtRL'), 'url' => dcCore::app()->adminurl->get('admin.plugin.kUtRL'),
'small-icon' => dcPage::getPF('kUtRL/icon.png'), 'small-icon' => dcPage::getPF('kUtRL/icon.png'),
'large-icon' => dcPage::getPF('kUtRL/icon-b.png'), 'large-icon' => dcPage::getPF('kUtRL/icon-b.png'),
'permissions' => 'admin', 'permissions' => dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]),
] ]
); );
} }
@ -263,7 +263,7 @@ class adminKutrl
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->kUtRL;
if (!$s->kutrl_active if (!$s->kutrl_active
|| !dcCore::app()->auth->check(dcAuth::PERMISSION_ADMIN, dcCore::app()->blog->id)) { || !dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
return null; return null;
} }
@ -290,7 +290,7 @@ class adminKutrl
} }
# No right # No right
if (!dcCore::app()->auth->check(dcAuth::PERMISSION_ADMIN, dcCore::app()->blog->id)) { if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
throw new Exception(__('No enough right')); throw new Exception(__('No enough right'));
} }
@ -313,7 +313,7 @@ class adminKutrl
} }
# No right # No right
if (!dcCore::app()->auth->check(dcAuth::PERMISSION_ADMIN, dcCore::app()->blog->id)) { if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
throw new Exception(__('No enough right')); throw new Exception(__('No enough right'));
} }
@ -337,7 +337,7 @@ class backupKutrl
'kutrl', 'kutrl',
'SELECT kut_id, blog_id, kut_service, kut_type, ' . 'SELECT kut_id, blog_id, kut_service, kut_type, ' .
'kut_hash, kut_url, kut_dt, kut_password, kut_counter ' . 'kut_hash, kut_url, kut_dt, kut_password, kut_counter ' .
'FROM ' . dcCore::app()->prefix . 'kutrl ' . 'FROM ' . dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME . ' ' .
"WHERE blog_id = '" . $blog_id . "' " "WHERE blog_id = '" . $blog_id . "' "
); );
} }
@ -349,7 +349,7 @@ class backupKutrl
public static function importInit($bk) public static function importInit($bk)
{ {
$bk->cur_kutrl = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'kutrl'); $bk->cur_kutrl = dcCore::app()->con->openCursor(dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME);
$bk->kutrl = new kutrlLog(); $bk->kutrl = new kutrlLog();
} }

View file

@ -15,7 +15,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
} }
# Check user perms # Check user perms
dcPage::check(dcAuth::PERMISSION_ADMIN); dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]));
# Settings # Settings
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->kUtRL;

20
_init.php Normal file
View file

@ -0,0 +1,20 @@
<?php
/**
* @brief kUtRL, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
class initkUtRL
{
public const KURL_TABLE_NAME = 'kutrl';
}

View file

@ -27,7 +27,7 @@ if (version_compare($old_version, $new_version, '>=')) {
try { try {
# Table # Table
$t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); $t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$t->kutrl $t->{initkUtRL::KURL_TABLE_NAME}
->kut_id('bigint', 0, false) ->kut_id('bigint', 0, false)
->blog_id('varchar', 32, false) ->blog_id('varchar', 32, false)
->kut_service('varchar', 32, false, "'kUtRL'") ->kut_service('varchar', 32, false, "'kUtRL'")

View file

@ -33,10 +33,12 @@ if (!defined('SHORTEN_SERVICE_ENCODE')) {
# Main class # Main class
$d = __DIR__ . '/inc/'; $d = __DIR__ . '/inc/';
Clearbricks::lib()->autoload(['kUtRL' => $d . 'class.kutrl.php']); Clearbricks::lib()->autoload([
Clearbricks::lib()->autoload(['kutrlService' => $d . 'lib.kutrl.srv.php']); 'kUtRL' => $d . 'class.kutrl.php',
Clearbricks::lib()->autoload(['kutrlLog' => $d . 'lib.kutrl.log.php']); 'kutrlService' => $d . 'lib.kutrl.srv.php',
Clearbricks::lib()->autoload(['kutrlLinkslist' => $d . 'lib.kutrl.lst.php']); 'kutrlLog' => $d . 'lib.kutrl.log.php',
'kutrlLinkslist' => $d . 'lib.kutrl.lst.php',
]);
# Services # Services
Clearbricks::lib()->autoload(['defaultKutrlService' => $d . 'services/class.default.service.php']); Clearbricks::lib()->autoload(['defaultKutrlService' => $d . 'services/class.default.service.php']);

View file

@ -31,7 +31,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'kutrl', initkUtRL::KURL_TABLE_NAME,
/* description */ /* description */
__('delete table') __('delete table')
); );

View file

@ -178,7 +178,7 @@ class widgetKutrl
$rs = dcCore::app()->con->select( $rs = dcCore::app()->con->select(
'SELECT kut_counter, kut_hash ' . 'SELECT kut_counter, kut_hash ' .
'FROM ' . dcCore::app()->prefix . 'kutrl ' . 'FROM ' . dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME . ' ' .
"WHERE blog_id='" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' " . "WHERE blog_id='" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' " .
"AND kut_service = 'local' " . "AND kut_service = 'local' " .
$type . $hide . $more . 'ORDER BY ' . $order . $limit $type . $hide . $more . 'ORDER BY ' . $order . $limit

43
icon.svg Normal file
View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="96px" height="96px" viewBox="0 0 96 96" enable-background="new 0 0 96 96" xml:space="preserve"> <image id="image0" width="96" height="96" x="0" y="0"
href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAABGdBTUEAALGPC/xhBQAAACBjSFJN
AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAC/VBMVEUAAAAXe7sYe7oYerkZ
erkZeroYerkZe7oZe7oZebkZerkZe7oYerkZe7sYe7oYe7oYergYe7kYerkYeroZerkYeroZeroZ
fLsZerkZeroZe7gZe7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ZfL
+MvliK3ADCtXQXV1OFZeg5rX8tPr6IL1+ssNws1sBBatxeO+KdRp85atnngtRiUWbKMLthuug/ie
HQju1FrILkKwmy7YY7jeK9zCPoCxduz9Xtii/fzsgYOquEOk4DB/OMJhOn2OHmPtjziOLYqHj+MJ
2u/BSeF0iu85jfCZs+b3O/iavBbnjF+m84TggnCKIn6SLl4yt9/vsumLfcUouEoIrsHxOt9xA+u4
aUtbr74lfjfjbyPBHUJwF473hJb7WMuDhwmi7TGPIlVkHj8Rhp8+U0lNbPRz6xcvA7w1Ca9ev3lr
Za4t7p3/+w8hHyWvV6Lkf8inv/0PKFGihJ3Posje8yXJNF8pw6KWJErLN1HLd0WgCGQU/Eg0DU0g
akmkCUQtP1VKlCj5M/kFEhn+vsdr4I4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMTEtMjVUMjI6
Mzc6MjMrMDE6MDAPUS+mAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTExLTI1VDIyOjM3OjIzKzAx
OjAwfgyXGgAAAABJRU5ErkJggg==" />
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -20,7 +20,7 @@ class kutrlLog
public function __construct() public function __construct()
{ {
$this->table = dcCore::app()->prefix . 'kutrl'; $this->table = dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME;
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id); $this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
$this->con = dcCore::app()->con; $this->con = dcCore::app()->con;
} }

View file

@ -35,7 +35,7 @@ class dcMiniUrl2kUtRL
public function __construct() public function __construct()
{ {
$this->con = dcCore::app()->con; $this->con = dcCore::app()->con;
$this->k_tb = dcCore::app()->prefix . 'kutrl'; $this->k_tb = dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME;
$this->m_tb = dcCore::app()->prefix . 'miniurl'; $this->m_tb = dcCore::app()->prefix . 'miniurl';
} }

View file

@ -15,7 +15,9 @@ if (!defined('DC_CONTEXT_ADMIN')) {
} }
# Check user perms # Check user perms
dcPage::check(dcAuth::PERMISSION_ADMIN); dcPage::check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]));
$header = ''; $header = '';
$part = $_REQUEST['part'] ?? 'links'; $part = $_REQUEST['part'] ?? 'links';