XXI. Topic Reference

The topic and article system is the most extensive and actively used feature of Midgard. Topic records form a hierarchical tree structure in which articles can be stored. Article records can for example represent normal articles or documents, parts of them, calendar entries, news items or organizational units.

The topic records form a tree hierarchy in the Midgard database. Each topic tree is started from a root topic whose up field is zero. The first level of the tree is formed by topis whose up fields point to the root topic, second level of topics with up fields pointing to records in the first level, and so on. One can traverse a tree branch from a given topic $topic to the root topic using the following code:

<ul>
<?php for ($t = mgd_get_topic($topic); $t; $t = mgd_get_topic($t->up) ) ?>
  <li>&(t.name);</li>
<?php endfor; ?>
</ul>

The article records are the leaves of the topic tree. Each article record is linked to a topic by the topic field. There is no way to list all the articles in a database. Instead you can access the articles in a given topic or in the entire subtree starting from the topic.

1. Topic Record Definition

A topic record contains information about a topic, its owner and its parent.

Fields of a topic record

id

The id of the topic record.

up

The id of the parent topic. A zero value in this field indicates that the topic is a toplevel topic.

name

The name of the topic record.

extra

A freeform information field.

owner

The group id of the owner of the topic.

score

An integer value that can be used for sorting.

description

A description of the topic.

revised

Date and time of the last revision of the topic record.

created

Date and time the topic record was created.

revisor

The id of the person that last revised the topic.

creator

The id of the person that created the topic record.

revision

The number of revisions made on the record.

code

A field that can be used to store executable code in.

sitegroup

The id of the sitegroup the record belongs to.

2. Topic Object Definition

This section describes the content of topic objects. Most object parameters map directly to the record fields described above.

The functions listed within the object definition are the object methods that are available for the object. Usage information about those methods can be found in Object Methods.


Class topic {

  var $N;              # Only with mgd_list_XXX functions.
  var $id;
  var $up;
  var $name;
  var $extra;
  var $owner;
  var $score;
  var $description;
  var $revised;
  var $created;
  var $revisor;
  var $creator;
  var $revision;
  var $code;
  var $sitegroup;

  function fetch();    # Only with mgd_list_XXX functions.

  function create();
  function update();
  function delete();

  function createattachment();
  function updateattachment();
  function deleteattachment();
  function getattachment();
  function listattahcments();
  function openattachment();
  function serveattachement();

  function listparameters();
  function parameter();
  function searchparameters();
 
  function getsitegroup();
  function setsitegroup();

}
Table of Contents
mgd_copy_topic — Copy a topic
mgd_create_topic — Create a new topic
mgd_delete_topic — Delete a topic
mgd_delete_topic_tree — Delete a topic tree
mgd_get_topic — Get a topic
mgd_get_topic_by_name — Get a topic by its name
mgd_is_in_topic_tree — Check location within a topic tree
mgd_is_topic_owner — Check topic ownership
mgd_list_topics — List subtopics
mgd_move_topic — Move a topic
mgd_update_topic — Update a topic
mgd_update_topic_score — Change the score of a topic
mgd_walk_topic_tree — Walk a topic tree