Skip to content
Jeff Johns edited this page Feb 4, 2014 · 4 revisions
Controller Extends Path
Labels Plain_Controller /application/controllers/labels.php

Request Types

Type Accessible
XMLHttpRequest Yes
API Yes
Web View No

This controller handles all requests to get, update, add and read indivdual labels. This is not accessible for a web view. Only accessible for API and XMLHttpRequest requests.

Methods

__construct - Public

Called automatically which in turn calls the parent constructor. Also does the following:

  • Redirects if logged out
  • Redirects if web view
  • Loads the labels model

activate - Public

Sets a label to active. You must own the label. If activating a system-level you must be an admin.

URL: /label/activate/LABEL_ID

add - Public

Adds a new label to the system. There a different variables per type of label. They are listed below.

Normal Labels (Admins only)

Query Parameters
Param Type Default Required Description
name string N/A Yes The name of the label.
active integer 1 No Set to 1 for active and 0 for inactive.

Example

URL: /label/add
Query: name=testing&active=0

Smart Labels

Query Parameters
Param Type Default Required Description
admin integer 0 No 1 to create the system level label, 0 for personal. Must be an admin to even use this flag.
label_id integer N/A Yes The label's id to apply when this rule is met.
url string N/A Yes The URL to extract the domain from for the smart label.
active integer 1 No Set to 1 for active and 0 for inactive.

Example

URL: /label/add
Query: url=http://www.testing.com&admin=1&label_id=7

deactivate - Public

Sets a label to inactive. You must own the label. If activating a system-level you must be an admin.

URL: /label/deactivate/LABEL_ID

edit - Public

Edits an existing label.

Normal Labels (Admins only)

Query Parameters
Param Type Default Required Description
name string N/A No The name of the label.
active integer 1 No Set to 1 for active and 0 for inactive.

Example

URL: /label/edit/LABEL_ID
Query: active=0

Smart Labels

Query Parameters
Param Type Default Required Description
admin integer 0 No 1 to create the system level label, 0 for personal. Must be an admin to even use this flag.
label_id integer N/A Yes The label's id to apply when this rule is met.
url string N/A Yes The URL to extract the domain from for the smart label.
active integer 1 No Set to 1 for active and 0 for inactive.

Example

URL: /label/edit/LABEL_ID
Query: label_id=5

index - Public

Returns a list of labels 30 at a time. You can get labels in a few different ways:

All Labels: /labels(/PAGE)?
Normal Labels: /labels/normal(/PAGE)? (admin accounts only)
Smart Labels: /labels/smart(/PAGE)? (admin accounts will get the system ones and their personal smart labels)

info - Public

Get all the information for a particular label. You must own the label to have access to the information. Only users with the admin flag set will be able to read the system level labels.

URL: /label/info/LABEL_ID

toggle - Private

Used internally to toggle the active state of a label.

Normal Labels (Admins only)

Arguments
Argument Type Default Required Description
label_id integer N/A Yes The label id.
active integer 0 No Set to 1 for active, 0 for inactive.

Example

// inactive
self::toggle($label_id);

// active
self::toggle($label_id, 1);