diff --git a/_admin.php b/_admin.php index 342f7b0..c993bcd 100644 --- a/_admin.php +++ b/_admin.php @@ -22,9 +22,9 @@ require_once __DIR__ . '/_widgets.php'; dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('Links shortener'), 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']), - 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 @@ -69,7 +69,7 @@ class adminKutrl 'url' => dcCore::app()->adminurl->get('admin.plugin.kUtRL'), 'small-icon' => dcPage::getPF('kUtRL/icon.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; 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; } @@ -290,7 +290,7 @@ class adminKutrl } # 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')); } @@ -313,7 +313,7 @@ class adminKutrl } # 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')); } @@ -337,7 +337,7 @@ class backupKutrl 'kutrl', 'SELECT kut_id, blog_id, kut_service, kut_type, ' . '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 . "' " ); } @@ -349,7 +349,7 @@ class backupKutrl 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(); } diff --git a/_config.php b/_config.php index 61d3d62..38d2d1d 100644 --- a/_config.php +++ b/_config.php @@ -15,7 +15,7 @@ if (!defined('DC_CONTEXT_ADMIN')) { } # Check user perms -dcPage::check(dcAuth::PERMISSION_ADMIN); +dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN])); # Settings $s = dcCore::app()->blog->settings->kUtRL; diff --git a/_init.php b/_init.php new file mode 100644 index 0000000..cfa2c49 --- /dev/null +++ b/_init.php @@ -0,0 +1,20 @@ +=')) { try { # Table $t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); - $t->kutrl + $t->{initkUtRL::KURL_TABLE_NAME} ->kut_id('bigint', 0, false) ->blog_id('varchar', 32, false) ->kut_service('varchar', 32, false, "'kUtRL'") diff --git a/_prepend.php b/_prepend.php index 0055170..1c9476a 100644 --- a/_prepend.php +++ b/_prepend.php @@ -33,10 +33,12 @@ if (!defined('SHORTEN_SERVICE_ENCODE')) { # Main class $d = __DIR__ . '/inc/'; -Clearbricks::lib()->autoload(['kUtRL' => $d . 'class.kutrl.php']); -Clearbricks::lib()->autoload(['kutrlService' => $d . 'lib.kutrl.srv.php']); -Clearbricks::lib()->autoload(['kutrlLog' => $d . 'lib.kutrl.log.php']); -Clearbricks::lib()->autoload(['kutrlLinkslist' => $d . 'lib.kutrl.lst.php']); +Clearbricks::lib()->autoload([ + 'kUtRL' => $d . 'class.kutrl.php', + 'kutrlService' => $d . 'lib.kutrl.srv.php', + 'kutrlLog' => $d . 'lib.kutrl.log.php', + 'kutrlLinkslist' => $d . 'lib.kutrl.lst.php', +]); # Services Clearbricks::lib()->autoload(['defaultKutrlService' => $d . 'services/class.default.service.php']); diff --git a/_uninstall.php b/_uninstall.php index c949f5c..34054c7 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -31,7 +31,7 @@ $this->addUserAction( /* action */ 'delete', /* ns */ - 'kutrl', + initkUtRL::KURL_TABLE_NAME, /* description */ __('delete table') ); diff --git a/_widgets.php b/_widgets.php index 2daab61..411aa70 100644 --- a/_widgets.php +++ b/_widgets.php @@ -178,7 +178,7 @@ class widgetKutrl $rs = dcCore::app()->con->select( '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) . "' " . "AND kut_service = 'local' " . $type . $hide . $more . 'ORDER BY ' . $order . $limit diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..5ef56df --- /dev/null +++ b/icon.svg @@ -0,0 +1,43 @@ + + + + diff --git a/inc/lib.kutrl.log.php b/inc/lib.kutrl.log.php index 9db3030..1e3fa45 100644 --- a/inc/lib.kutrl.log.php +++ b/inc/lib.kutrl.log.php @@ -20,7 +20,7 @@ class kutrlLog 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->con = dcCore::app()->con; } diff --git a/inc/patch.dcminiurl.php b/inc/patch.dcminiurl.php index f552f7f..9d205ce 100644 --- a/inc/patch.dcminiurl.php +++ b/inc/patch.dcminiurl.php @@ -35,7 +35,7 @@ class dcMiniUrl2kUtRL public function __construct() { $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'; } diff --git a/index.php b/index.php index 4f128e3..149d85d 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,9 @@ if (!defined('DC_CONTEXT_ADMIN')) { } # Check user perms -dcPage::check(dcAuth::PERMISSION_ADMIN); +dcPage::check(dcCore::app()->auth->makePermissions([ + dcAuth::PERMISSION_ADMIN, +])); $header = ''; $part = $_REQUEST['part'] ?? 'links';