Repository navigation
Open
Milestone
Description
Current state
- Core has no tagging. Nothing in the schema or classes lets a user label projects, tasks, files or other records with free-form tags.
- Modules that want tags (the Cards module first) would each have to build their own tables, autocomplete, filtering and admin. Tags couldn't be shared across modules.
Intended solution
Schema
tagstag_idtag_namevarchar(64)tag_slugvarchar(64), unique: lower-cased, trimmed, inner whitespace collapsedtag_colorchar(7), nulltag_created,tag_creator
tag_linkstag_idlink_modulevarchar(40)link_itemintlink_created,link_creator- Primary key
(tag_id, link_module, link_item); index(link_module, link_item)
API
A CTag object plus a small w2p_Core_Tags service:
forItems($module, array $ids): tags for many items in one query (no N+1 on list views and boards).setTags($module, $id, array $names): diffs against current tags, creates missing tags, and returns['added' => [...], 'removed' => [...]]so callers can log changes.itemsTagged($module, array $tagIds, $match = 'any'|'all'): for filtering lists.suggest($prefix, $limit = 10): autocomplete.- Admin:
rename(),merge($fromId, $intoId),delete()(removes its links), usage counts per module.
UI
- A shared helper renders tag chips and a tag input (autocomplete from
suggest()), so every module looks the same. - System Admin → Tags page: rename, merge, delete, usage counts.
hook_searchsupport, so Smart Search finds items by tag.
Rules
- One vocabulary for all modules. "Q4 launch" is the same tag on a card, a project or a file. Tags aren't scoped per module or per project.
- Uniqueness by slug. "Q4 Launch", "q4 launch" and "Q4 launch" are one tag. The first spelling used is the display name until an admin renames it.
- Who can tag: anyone who can edit an item can add or remove its tags, including creating a new tag by typing it. Renaming, merging and deleting tags is admin-only (System Admin rights).
- Visibility follows the item. Seeing that an item has a tag requires view rights on the item. Tag names themselves aren't secret: the autocomplete shows all names.
- Renames apply everywhere. Modules that log tag changes (e.g. an activity feed) should record the tag name at the time of the change, not just the ID.
- Cleanup on delete. When any tagged object is deleted, its
tag_linksrows are removed. This uses the shared dispatcher from Let modules subscribe to other modules' object events (global event dispatcher) #526 (a core listener onpostDeleteEventfor any resource). Ahook_cronsweep removes links whose item no longer exists, as a backstop. - Unused tags are kept. A tag with no links stays in the vocabulary until an admin deletes it, so autocomplete doesn't lose it.
- Limits: at most 64 characters per tag, and a sensible cap per item (e.g. 20) enforced in
setTags().
Acceptance
- Two modules tag their own items with the same tag and
itemsTagged()finds each. - Loading tags for 200 items takes one query.
- Deleting an item removes its links.
- Merge moves every link to the surviving tag without duplicates.
Context
First consumer: the Cards module (caseysoftware/modules-cards), whose board groups and filters cards by tag.
Metadata
Metadata
Assignees
Labels
No labels
Activity