Keyword management

Monday 22 November 2004 Mathieu Lutfy

Keywords will have two different functions: to provide a way to customize internal elements such as the types of follow-ups and contacts, and to allow authors to attach keywords on cases, clients, organisations and authors.

The difference between "system" and "user" keywords is that "system" keywords usually have a special treatement/code and storage in the database, where as "user" keywords are stored in associative tables (ex: lcm_keyword_case, lcm_keyword_client, etc.).

System keywords, in short, use an existent system to allow the system to be custmized by administrators.

Structure in the database

- lcm_keyword_group

  • id_group (bigint): numeric primary key
  • name (varchar(255)) [varchar]: short unique word used as a key
  • title (text): human readable title/name
  • description (text): description of the keyword group
  • type (enum: case, followup, client, org, author, system) [1]
  • policy (enum: optional, recommended, mandatory) [2]
  • quantity (enum: one, many): can many keywords from one group be attached to a case/client/org/.. ?
  • suggest (text): suggest a default keyword in group (from ’name’) [3]
  • ac_admin (enum: Y,N): can the admin modify the keyword? [4]
  • ac_author (enum: Y,N): can authors use the keyword group? [5]

- lcm_keyword

  • id_keyword (bigint): numeric primary key
  • id_group (bigint): a keyword is always part of a group
  • name (varchar(255)) [varchar]: short unique word used as a key
  • title (text): human readable title/name
  • description (text): description of the keyword
  • ac_author (enum: Y,N): can authors use the keyword?

Question: Should there be an ac_admin on the keyword to allow the admin to delete a keyword? This concerns mostly system keywords. The admin can add new system keywords, but should not be allowed to delete the default keywords (ex: contact->e-mail, followup->*, etc.). To restrict admins from deleting keywords currently in use should limit this problem.

Functions

I was never good at giving names to functions.. :-)

- get_keyword_group($name or $id)

Returns a named array with the expected associated SQL query, but might also cache the data.

- get_keywords_in_group($name)

Returns an array with a list of keywords who are part of the given group.

- get_kwg_all($type = 'all,system,user')

Returns an array with a list of keyword groups. The type refers to the application of the keyword group: system defined, user defined or both.

- get_kwg_for($type = 'case,client,org,author', $author = true)

Returns an array with a list of keyword groups which can apply to the provided type.

- get_kw_attached($type = 'case,client,org,author', $id)

Returns an array with a list of keywords which are attached to the provided id of type. For example, to list keywords attached to a given case, the function will be called as $list = get_keywords('case', $id_case);

Default system keyword groups

When it is installed or upgrade, LCM will create a list of default system keywords which will not be modifiable. The admin user will be able to add keywords in the created keyword groups, but not to remove them.

- Follow-ups:

  • assignment
  • suspension
  • delay
  • conclusion
  • consultation (default)
  • correspondance
  • travel
  • other

Strange fact: Since every follow-up has only one keyword "follow-up" attached, the value is stored inside the follow-up row itself, not in an associative keyword-followup table.

- Contact Type:

  • email_main
  • email_alternate
  • phone_home
  • phone_office
  • phone_mobile
  • address_main

Same as with the follow-ups, the ID of contact type keywords is stored in the lcm_contact table itself.

Default user keyword groups

LCM will also create "user" keyword groups that the administrator will be able to deactivate.

- Type of case:

  • (will be left empty)

Creation of default keyword groups

The creation of the default keyword groups is automatic and triggered by the installation or upgrade systems.

- See: inc_keywords_default.php

Hiding system keywords: If administrators do not wish to use some keywords of the system kwg, they can "hide" individual keywords by removing their ac_author.

Footnotes:

[varchar] : We create a unique index on this field since it can be used as a key.

[1] For example, "Follow-up types" and "contact types" are system keyword groups).

[2] If recommended, the author is reminded to attach a keyword, but it is not mandatory.

[3] For example: In keyword group ’follow-ups’, the suggested default value should be ’consultation’.

[4] If Y, the admin will be allowed to modify the ’title’ and ’description’ — maybe other elements, we will see..

[5] If N, only administrators can associate they keyword to elements.

To send a message Private area Registering with the site xml ?