From: Banana Date: Sat, 17 Dec 2022 17:40:58 +0000 (+0100) Subject: fixed #14 X-Git-Tag: v1.4~5 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=5d2d0597d46f592b3d68366f68e164869019a9cf;p=bibliotheca-php.git fixed #14 --- diff --git a/CHANGELOG b/CHANGELOG index d0ae83b..ad867af 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Made it more visible where to drop the fields in manage fields view for a collection. * Added a note about some options in collections manage view. * Improved breakpoint behavior + * After already selected a collection the add and tags manage action has this collection already set. 1.3 - Rrajigar Mine 2022-10-08 * Fixed install sql file. diff --git a/documentation/setup/bibliotheca.sql b/documentation/setup/bibliotheca.sql index c1c4585..4641ae7 100644 --- a/documentation/setup/bibliotheca.sql +++ b/documentation/setup/bibliotheca.sql @@ -75,6 +75,7 @@ CREATE TABLE `#REPLACEME#_menu` ( `id` int UNSIGNED NOT NULL, `text` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `action` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `contextaction` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `icon` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `owner` int NOT NULL DEFAULT '0', `group` int NOT NULL DEFAULT '0', @@ -87,24 +88,25 @@ CREATE TABLE `#REPLACEME#_menu` ( -- Dumping data for table `#REPLACEME#_menu` -- -INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES -(1, 'Dashboard', '', 'home', 1, 1, 'rw-r--r--', 0, 'show'), -(2, 'Collections', 'collections', 'database', 1, 1, 'rw-r--r--', 1, 'show'), -(3, 'Tags', 'tags', 'tag', 1, 1, 'rw-r--r--', 2, 'show'), -(4, 'Add', 'manageentry', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'), -(6, 'Tags', 'managetags', 'tag', 1, 2, 'rw-rw----', 2, 'manage'), -(7, 'Collections', 'managecolletions', 'database', 1, 2, 'rw-rw----', 3, 'manage'), -(8, 'Users', 'manageusers', 'users', 1, 1, 'rw-------', 4, 'manage'), -(9, 'Login', 'auth', '', 1, 1, 'rw-r--r--', 0, ''), -(10, 'Collection fields', 'managecollectionfields', '', 1, 2, 'rw-rw----', 0, ''), -(11, 'Entry', 'entry', '', 1, 1, 'rw-r--r--', 0, ''), -(12, 'Search', 'search', '', 1, 1, 'rw-r--r--', 0, ''), -(14, 'Tool', 'tool', '', 1, 2, 'rw-rw----', 0, ''), -(15, 'Advanced search', 'advancedsearch', '', 1, 1, 'rw-r--r--', 0, ''), -(16, 'Profile', 'profile', 'user', 1, 2, 'rw-rw----', 6, 'manage'), -(17, 'Groups', 'managegroups', 'users', 1, 1, 'rw-------', 5, 'manage'), -(18, 'Bulkedit', 'bulkedit', '', 1, 2, 'rw-rw----', 0, ''), -(19, 'System Information', 'sysinfo', 'info', 1, 1, 'rw-------', 3, 'show'); +INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `contextaction`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES +(1, 'Dashboard', '', 'home', '', 1, 1, 'rw-r--r--', 0, 'show'), +(2, 'Collections', 'collections', '', 'database', 1, 1, 'rw-r--r--', 1, 'show'), +(3, 'Tags', 'tags', '', 'tag', 1, 1, 'rw-r--r--', 2, 'show'), +(4, 'Add', 'manageentry', 'collection', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'), +(6, 'Tags', 'managetags', 'collection', 'tag', 1, 2, 'rw-rw----', 2, 'manage'), +(7, 'Collections', 'managecolletions', '', 'database', 1, 2, 'rw-rw----', 3, 'manage'), +(8, 'Users', 'manageusers', '', 'users', 1, 1, 'rw-------', 4, 'manage'), +(9, 'Login', 'auth', '', '', 1, 1, 'rw-r--r--', 0, ''), +(10, 'Collection fields', 'managecollectionfields', '', '', 1, 2, 'rw-rw----', 0, ''), +(11, 'Entry', 'entry', '', '', 1, 1, 'rw-r--r--', 0, ''), +(12, 'Search', 'search', '', '', 1, 1, 'rw-r--r--', 0, ''), +(14, 'Tool', 'tool', '', '', 1, 2, 'rw-rw----', 0, ''), +(15, 'Advanced search', 'advancedsearch', '', '', 1, 1, 'rw-r--r--', 0, ''), +(16, 'Profile', 'profile', '', 'user', 1, 2, 'rw-rw----', 6, 'manage'), +(17, 'Groups', 'managegroups', '', 'users', 1, 1, 'rw-------', 5, 'manage'), +(18, 'Bulkedit', 'bulkedit', '', '', 1, 2, 'rw-rw----', 0, ''), +(19, 'System Information', 'sysinfo', '', 'info', 1, 1, 'rw-------', 3, 'show'); + -- -------------------------------------------------------- diff --git a/upgrade/from-version-1.3.tx b/upgrade/from-version-1.3.tx index 301b8e4..a4de8f3 100644 --- a/upgrade/from-version-1.3.tx +++ b/upgrade/from-version-1.3.tx @@ -1,3 +1,6 @@ # DB changes. Run each line against your bibliotheca DB. # Replace #REPLACEME# with your table prefix. Default is bib -ALTER TABLE `#REPLACEME#_collection` ADD `defaultSortOrder` VARCHAR(4) CHARACTER SET utf8mb4_unicode_ci COLLATE utf8mb4_bin NOT NULL AFTER `defaultSortField`; +ALTER TABLE `#REPLACEME#_collection` ADD `defaultSortOrder` VARCHAR(4) NOT NULL AFTER `defaultSortField`; +ALTER TABLE `#REPLACEME#_menu` ADD `contextaction` VARCHAR(64) NOT NULL AFTER `action`; +UPDATE `#REPLACEME#_menu` SET `contextaction` = 'collection' WHERE `bib_menu`.`id` = 4; +UPDATE `#REPLACEME#_menu` SET `contextaction` = 'collection' WHERE `bib_menu`.`id` = 6; diff --git a/webclient/index.php b/webclient/index.php index 3c2423a..b6fb565 100644 --- a/webclient/index.php +++ b/webclient/index.php @@ -80,7 +80,6 @@ $DB->query("SET collation_connection = 'utf8mb4_unicode_ci'"); $Doomguy = new Doomguy($DB); # menu Object $Gorenest = new GoreNest($DB,$Doomguy); -$Gorenest->loadMenu(); $_requestMode = false; if(isset($_GET['p']) && !empty($_GET['p'])) { diff --git a/webclient/lib/gorenest.class.php b/webclient/lib/gorenest.class.php index f6791c0..35e90ad 100644 --- a/webclient/lib/gorenest.class.php +++ b/webclient/lib/gorenest.class.php @@ -59,6 +59,34 @@ class GoreNest { public function __construct(mysqli $db, Doomguy $user) { $this->_DB = $db; $this->_User = $user; + $this->_loadMenu(); + } + + /** + * Get the menu data for given area and category. + * This shows only entries which have a category set. + * No category can be used for hidden entries. + * + * @param string $category + * @param bool $reload + * @param array $_contextActions + * @return array + */ + public function get(string $category, bool $reload = false, array $_contextActions = array()): array { + $ret = array(); + + if(empty($category)) return $ret; + + if($reload === false && isset($this->_menuData[$category])) { + return $this->_updateContextActions($this->_menuData[$category], $_contextActions); + } + + $this->_loadMenu(); + if(isset($this->_menuData[$category])) { + $ret = $this->_menuData[$category]; + } + + return $this->_updateContextActions($ret, $_contextActions); } /** @@ -66,11 +94,11 @@ class GoreNest { * * @return void */ - public function loadMenu(): void { + private function _loadMenu(): void { # reset the menu $this->_menuData = array(); - $queryStr = "SELECT id, text, action, icon, category + $queryStr = "SELECT id, text, action, icon, category, contextaction FROM `".DB_PREFIX."_menu` WHERE ".$this->_User->getSQLRightsString()." ORDER BY position"; @@ -79,8 +107,8 @@ class GoreNest { $query = $this->_DB->query($queryStr); if($query !== false && $query->num_rows > 0) { while(($result = $query->fetch_assoc()) != false) { - $this->_menuData[$result['category']][$result['id']] = $result; $this->_allowedPageRequests[$result['action']] = $result['action']; + $this->_menuData[$result['category']][$result['id']] = $result; } } } @@ -90,37 +118,30 @@ class GoreNest { } /** - * Get the menu data for given area and category. - * This shows only entries which have a category set. - * No category can be used for hidden entries. + * Return allowed page requests * - * @param string $category - * @param bool $reload * @return array */ - public function get(string $category, bool $reload = false): array { - $ret = array(); - - if(empty($category)) return $ret; - - if($reload === false && isset($this->_menuData[$category])) { - return $this->_menuData[$category]; - } - - $this->loadMenu(); - if(isset($this->_menuData[$category])) { - $ret = $this->_menuData[$category]; - } - - return $ret; + public function allowedPageRequests(): array { + return $this->_allowedPageRequests; } /** - * Return allowed page requests + * Check if there is the need to modify the action value based on contextaction column + * and $_contextActions array * + * @param array $_menuData + * @param array $_contextActions * @return array */ - public function allowedPageRequests(): array { - return $this->_allowedPageRequests; + private function _updateContextActions(array $_menuData, array $_contextActions): array { + if(!empty($_contextActions)) { + foreach($_menuData as $id=>$data) { + if(isset($_contextActions[$data['contextaction']])) { + $_menuData[$id]['action'] = $data['action'].'&'.$data['contextaction'].'='.$_contextActions[$data['contextaction']]; + } + } + } + return $_menuData; } } diff --git a/webclient/lib/summoner.class.php b/webclient/lib/summoner.class.php index 11521d1..983fcd5 100644 --- a/webclient/lib/summoner.class.php +++ b/webclient/lib/summoner.class.php @@ -507,7 +507,7 @@ class Summoner { * @param array $modify * @return string */ - static function createFromParameterLinkQuery(array $array, $modify=array()): string { + static function createFromParameterLinkQuery(array $array, array $modify = array()): string { $ret = ''; if(!empty($modify)) { diff --git a/webclient/setup/bibliotheca.sql.default b/webclient/setup/bibliotheca.sql.default index c1c4585..8f88a22 100644 --- a/webclient/setup/bibliotheca.sql.default +++ b/webclient/setup/bibliotheca.sql.default @@ -75,6 +75,7 @@ CREATE TABLE `#REPLACEME#_menu` ( `id` int UNSIGNED NOT NULL, `text` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `action` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `contextaction` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `icon` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `owner` int NOT NULL DEFAULT '0', `group` int NOT NULL DEFAULT '0', @@ -87,24 +88,24 @@ CREATE TABLE `#REPLACEME#_menu` ( -- Dumping data for table `#REPLACEME#_menu` -- -INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES -(1, 'Dashboard', '', 'home', 1, 1, 'rw-r--r--', 0, 'show'), -(2, 'Collections', 'collections', 'database', 1, 1, 'rw-r--r--', 1, 'show'), -(3, 'Tags', 'tags', 'tag', 1, 1, 'rw-r--r--', 2, 'show'), -(4, 'Add', 'manageentry', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'), -(6, 'Tags', 'managetags', 'tag', 1, 2, 'rw-rw----', 2, 'manage'), -(7, 'Collections', 'managecolletions', 'database', 1, 2, 'rw-rw----', 3, 'manage'), -(8, 'Users', 'manageusers', 'users', 1, 1, 'rw-------', 4, 'manage'), -(9, 'Login', 'auth', '', 1, 1, 'rw-r--r--', 0, ''), -(10, 'Collection fields', 'managecollectionfields', '', 1, 2, 'rw-rw----', 0, ''), -(11, 'Entry', 'entry', '', 1, 1, 'rw-r--r--', 0, ''), -(12, 'Search', 'search', '', 1, 1, 'rw-r--r--', 0, ''), -(14, 'Tool', 'tool', '', 1, 2, 'rw-rw----', 0, ''), -(15, 'Advanced search', 'advancedsearch', '', 1, 1, 'rw-r--r--', 0, ''), -(16, 'Profile', 'profile', 'user', 1, 2, 'rw-rw----', 6, 'manage'), -(17, 'Groups', 'managegroups', 'users', 1, 1, 'rw-------', 5, 'manage'), -(18, 'Bulkedit', 'bulkedit', '', 1, 2, 'rw-rw----', 0, ''), -(19, 'System Information', 'sysinfo', 'info', 1, 1, 'rw-------', 3, 'show'); +INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `contextaction`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES +(1, 'Dashboard', '', 'home', '', 1, 1, 'rw-r--r--', 0, 'show'), +(2, 'Collections', 'collections', '', 'database', 1, 1, 'rw-r--r--', 1, 'show'), +(3, 'Tags', 'tags', '', 'tag', 1, 1, 'rw-r--r--', 2, 'show'), +(4, 'Add', 'manageentry', 'collection', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'), +(6, 'Tags', 'managetags', 'collection', 'tag', 1, 2, 'rw-rw----', 2, 'manage'), +(7, 'Collections', 'managecolletions', '', 'database', 1, 2, 'rw-rw----', 3, 'manage'), +(8, 'Users', 'manageusers', '', 'users', 1, 1, 'rw-------', 4, 'manage'), +(9, 'Login', 'auth', '', '', 1, 1, 'rw-r--r--', 0, ''), +(10, 'Collection fields', 'managecollectionfields', '', '', 1, 2, 'rw-rw----', 0, ''), +(11, 'Entry', 'entry', '', '', 1, 1, 'rw-r--r--', 0, ''), +(12, 'Search', 'search', '', '', 1, 1, 'rw-r--r--', 0, ''), +(14, 'Tool', 'tool', '', '', 1, 2, 'rw-rw----', 0, ''), +(15, 'Advanced search', 'advancedsearch', '', '', 1, 1, 'rw-r--r--', 0, ''), +(16, 'Profile', 'profile', '', 'user', 1, 2, 'rw-rw----', 6, 'manage'), +(17, 'Groups', 'managegroups', '', 'users', 1, 1, 'rw-------', 5, 'manage'), +(18, 'Bulkedit', 'bulkedit', '', '', 1, 2, 'rw-rw----', 0, ''), +(19, 'System Information', 'sysinfo', '', 'info', 1, 1, 'rw-------', 3, 'show'); -- -------------------------------------------------------- diff --git a/webclient/view/default/system/menu.php b/webclient/view/default/system/menu.php index 42eeb2e..20257cd 100644 --- a/webclient/view/default/system/menu.php +++ b/webclient/view/default/system/menu.php @@ -16,8 +16,16 @@ * limitations under the License. */ +## optional context action +# the key has to match the column contextaction of the menuentry +# $_collection comes from the $Viewscript +$_contextActions = array(); +if(!empty($_collection)) { + $_contextActions['collection'] = $_collection; +} + $_menuShow = $Gorenest->get('show'); -$_menuManage = $Gorenest->get('manage'); +$_menuManage = $Gorenest->get('manage', false, $_contextActions); ?>