diff --git a/CHANGELOG.md b/CHANGELOG.md index 1983a2b..7b061d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ xxx.xx.xx - Never fix breaking comments or complexe public url - [ ] Add public page of the list of know urls and in/visible status - [ ] Add passworded links +- fix permissions +- fix js load +- add user pref on table cols +- add user pref on filters (dc 2.20) 2021.09.16 - remove deprecated external service diff --git a/_admin.php b/_admin.php index 20eff0b..e34a096 100644 --- a/_admin.php +++ b/_admin.php @@ -25,11 +25,14 @@ $_menu['Plugins']->addItem( $core->adminurl->get('admin.plugin.kUtRL'), dcPage::getPF('kUtRL/icon.png'), preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.kUtRL')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), - $core->auth->check('admin', $core->blog->id)); + $core->auth->check('admin', $core->blog->id) +); # Admin behaviors if ($core->blog->settings->kUtRL->kutrl_active) { $core->addBehavior('adminDashboardFavorites', ['adminKutrl', 'antispamDashboardFavorites']); + $core->addBehavior('adminColumnsLists', ['adminKutrl', 'adminColumnsLists']); + $core->addBehavior('adminSortsLists', ['adminKutrl', 'adminSortsLists']); $core->addBehavior('adminPostHeaders', ['adminKutrl', 'adminPostHeaders']); $core->addBehavior('adminPostFormItems', ['adminKutrl', 'adminPostFormItems']); $core->addBehavior('adminAfterPostUpdate', ['adminKutrl', 'adminAfterPostUpdate']); // update existing short url @@ -49,23 +52,56 @@ $core->addBehavior('importFull', ['backupKutrl', 'importFull']); # Admin behaviors class class adminKutrl { + public static function sortbyCombo() + { + return [ + __('Date') => 'kut_dt', + __('Short URL') => 'kut_hash', + __('Long URL') => 'kut_url', + __('Service') => 'kut_service' + ]; + } + public static function antispamDashboardFavorites(dcCore $core, $favs) { $favs->register( 'kUtRL', [ - 'title' => __('Links shortener'), - 'url' => $core->adminurl->get('admin.plugin.kUtRL'), - 'small-icon' => dcPage::getPF('kUtRL/icon.png'), - 'large-icon' => dcPage::getPF('kUtRL/icon-b.png'), + 'title' => __('Links shortener'), + 'url' => $core->adminurl->get('admin.plugin.kUtRL'), + 'small-icon' => dcPage::getPF('kUtRL/icon.png'), + 'large-icon' => dcPage::getPF('kUtRL/icon-b.png'), 'permissions' => 'admin' ] ); } + public static function adminColumnsLists(dcCore $core, $cols) + { + $cols['kUtRL'] = [ + __('URL shortener'), + [ + 'kut_hash' => [true, __('Hash')], + 'kut_dt' => [true, __('Date')], + 'kut_service' => [true, __('Service')] + ] + ]; + } + + public static function adminSortsLists(dcCore $core, $sorts) + { + $sorts['kUtRL'] = [ + __('URL shortener'), + self::sortbyCombo(), + 'kut_dt', + 'desc', + [__('Links per page'), 30] + ]; + } + public static function adminPostHeaders() { - return dcPage::jsLoad('index.php?pf=kUtRL/js/admin.js'); + return dcPage::jsLoad(dcPage::getPF('kUtRL/js/posts.js')); } public static function adminPostFormItems($main_items, $sidebar_items, $post) diff --git a/inc/lib.kutrl.lst.php b/inc/lib.kutrl.lst.php index 9a4c714..eaf7c25 100644 --- a/inc/lib.kutrl.lst.php +++ b/inc/lib.kutrl.lst.php @@ -28,6 +28,20 @@ class kutrlLinkslist $this->html_next = __('next »'); } + public function userColumns($type, $cols) + { + $cols_user = @$this->core->auth->user_prefs->interface->cols; + if (is_array($cols_user) || $cols_user instanceof ArrayObject) { + if (isset($cols_user[$type])) { + foreach ($cols_user[$type] as $cn => $cd) { + if (!$cd && isset($cols[$cn])) { + unset($cols[$cn]); + } + } + } + } + } + public function display($page, $nb_per_page, $enclose_block, $filter = false) { if ($this->rs->isEmpty()) { @@ -38,59 +52,82 @@ class kutrlLinkslist } } else { $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); - $entries = []; + $links = []; if (isset($_REQUEST['entries'])) { foreach ($_REQUEST['entries'] as $v) { - $entries[(integer) $v] = true; + $links[(integer) $v] = true; } } - $blocks = explode('%s', sprintf($enclose_block, - '
' . __('Hash') . ' | ' . - '' . __('Link') . ' | ' . - '' . __('Date') . ' | ' . - '' . __('Service') . ' | ' . - '
---|