# publiclab/plots2

Switch branches/tags
Nothing to show
e1e57db Aug 12, 2018
4 contributors

### Users who have contributed to this file

108 lines (65 sloc) 5.18 KB

# PublicLab.org's Data Model

This page attempts to explain the database model for the plots2 project.

The following diagram is a rough sketch of how the applications various tables interconnect:

## Content

All user-generated content on PublicLab.org is either a Node, an Answer, or a Comment.

### Nodes

Nodes are a general type with primary key nid, a title, an author uid, and a path, or relative URL starting with "/".

There are several types of nodes, based on their type field:

• Notes, or research notes, of type "note", are single-author, single-revision.
• Wikis, or wiki pages, of type "page", have many revisions, each of which has an author. They have a path like /wiki/title or simply /title (for so-called "root" pages).
• Features, of type "feature", are blocks of content which can be included (hard-coded) throughout the site, but can only be made by admins. Read more about them below.
• Maps, of type "map", are web-map image layers and associated image files, displayed on https://publiclab.org/archive

Nodes may also be redirects, though this use is legacy only. More documentation needed.

Notes (type note) can also be a sub-type called Questions, if they have a tag starting with question: -- which gives them extra features such as the ability to have Answers (see below).

Node status -- a property of Node, can be:

• 0: banned
• 1: normal
• 3: draft
• 4: moderated -- i.e. node created by a first-time poster, and has not yet been "approved"

### Drafts

Drafts are a type of Research notes. They can be used by users to save their research notes without publishing them publically. But, not all users are eligible to create draft. Only users who have successfully published their first-note would be shown option for creating draft. Draft would be visible to co-author and other users can access it using secret link shared by author. Different draft-related privileges are mentioned below in the table:

User Role Draft Creation Draft Editing Draft Publishing
New Contributor No Yes, if co-author made by normal user Yes, if co-author
Normal User Yes Yes, if author or co-author Yes, if author or co-author
Moderator and Admin Yes Yes Yes

Wiki for the Draft Feature: https://publiclab.org/wiki/draft-feature

### Features

Features, mentioned above, are a type of Node. They are used for things like the front page, banners, footer text, and other content that is more infrastructural but change periodically. They are managed at https://publiclab.org/features.

They are typically cached for quick loading, and can be inserted anywhere in the code to create a semi-permanent dynamic content area like a banner, explanatory text, etc. Here's an example for a Feature with the key footer-notice:

<% cache('feature_footer-notice', skip_digest: true) do %>
<%= feature('footer-notice') %>
<% end %>

### Revisions

Revisions are a child model to Nodes via nid, and contain a title and body field, along with an author as a uid field and a vid primary key. Revisions have status in addition to their parent Node status, following the same conventions. Wiki pages default to their latest Revision's title.

Comments belong to Notes via nid, and each have an author via uid; primary key cid. Maps also have comments via nid, and Answers may also have comments, via aid.

Answers are similar to Comments, but are used in Question-type Notes, and may each have Comments of their own. Primary key aid.

## Users

Our primary user type is User. We also maintain a legacy DrupalUsers type, but are in the process of deprecating it. Users and DrupalUsers both have uid fields, which are synced one-to-one, and to fully deprecate DrupalUsers we must migrate these fields over to User.

Users each have a profile at /profile/username, which displays content stored in an associated DrupalProfileValue with fid = 7.

User status -- a property of DrupalUser, can be:

• 0: banned
• 1: normal
• 5: moderated

User role can be:

• basic
• moderator - ability to spam or unspam content, moderate or ban other users, make others into moderators, and lock pages.
• admin - abilities of moderator, plus ability to make other admins, delete wiki pages and notes, make Features

## Tagging

Tags (Tag) are unique tag names with primary key tid, which may be linked to Nodes via NodeTag (database table community_tag) via the latter's nid and tid fields.