Skip to content

MelisUserTabs

Back-office UX utility that persists and restores the set of tabs a user has open across sessions. Package melisplatform/melis-user-tabs.

Purpose

MelisUserTabs is a small back-office utility that integrates with the MelisCore admin shell tab system. It tracks which tools a user has open as tabs, persists that set per user, and reopens those tabs on the next login. It also powers the Close all tabs control in the BO header. There is no dedicated left-menu tool — it operates entirely in the background.

Enable it

Add to config/melis.module.load.php:

php
return [
    'MelisUserTabs',
];

Requires melisplatform/melis-core ^5.2.

Key services

Service aliasRole
MelisUserTabsServiceSaves and restores open tabs; handles translation-key round-trip
MelisUserTabsTableLow-level access to melis_user_tabs_open

MelisUserTabsService — method reference

getUserTabsOpenByUserId($userId) Loads the user's row, unserializes tabs_list, and translates each tab's melisTitle into the current user's language before returning the array. Events: user_tabs_open_get_user_tabs_by_user_id_start / user_tabs_open_get_user_tabs_by_use_rid_end (note: the "end" event name carries a verbatim typo — use_rid).

saveOpenTabs($userTabsOpen) JSON-decodes each entry in $userTabsOpen['tabOpen'], reverse-translates the title to its translation key (not the localized string) for every parent tab (a tab is a parent when it has no melisparameter), serializes the set, and inserts or updates the single per-user row. Events: user_tabs_open_save_open_tabs_start / user_tabs_open_save_open_tabs_end.

getTranslationByText($text) Reverse lookup — localized string to translation key — used internally by saveOpenTabs.

Design intent — store keys, localize on read. Titles are persisted as translation keys and converted to text only when read back. This ensures restored tabs are labeled correctly if the user switches language between sessions.

Backoffice

MelisUserTabs hooks into meliscore_header — it is not a standalone tool.

Controller actions (MelisUserTabsController)

Route: /melis/MelisUserTabs/[:controller[/:action]]

ActionReturnsRole
saveOpenTabsAction()JsonModelReceives the POSTed tabOpen set and delegates to MelisUserTabsService::saveOpenTabs()
getUserTabsOpenedAction()JsonModelReturns the current user's saved tabs via getUserTabsOpenByUserId() so the shell can reopen them
closeAllButtonAction()ViewModelRenders the Close all tabs button

Opening a tab programmatically

Use MelisCore's JS helper — MelisUserTabs will persist it automatically:

js
melisHelper.tabOpen(title, icon, zoneId, melisKey, parameters);

Database tables

TableHolds
melis_user_tabs_openOne row per back-office user; tabs_list stores the open-tab set as a PHP-serialized array

Schema

ColumnMeaning
tabs_idPrimary key
tabs_user_idBack-office user (usr_id)
tabs_listPHP-serialized array of tab objects (melisTitle, melisKey, optional melisparameter, …)

tabs_list is an internal representation written and read only by MelisUserTabsService. Do not feed it untrusted data.

Example

php
// Read the saved open tabs for a given user
$userTabsService = $this->getServiceManager()->get('MelisUserTabsService');
$tabs = $userTabsService->getUserTabsOpenByUserId($userId);
// $tabs is an array of tab objects with localized melisTitle values

Key files

ConcernPath
Header hook + JS asset wiringvendor/melisplatform/melis-user-tabs/config/app.interface.php
Route, service & table aliasesvendor/melisplatform/melis-user-tabs/config/module.config.php
Controllervendor/melisplatform/melis-user-tabs/src/Controller/MelisUserTabsController.php
Servicevendor/melisplatform/melis-user-tabs/src/Service/MelisUserTabsService.php
Table gatewayvendor/melisplatform/melis-user-tabs/src/Model/Tables/MelisUserTabsTable.php
Front-end trackervendor/melisplatform/melis-user-tabs/public/js/melis-user-tabs.js

See also: MelisCore