# Global Namespace

## Elentra ME

Elentra has many moving parts, and understanding what's available to you as a developer will go a long way to learning Elentra.

**Objects**

* [$db](/technical/developers/global-namespace.md#usddb-object)
* [$ENTRADA\_ACL](/technical/developers/global-namespace.md#usdentrada_acl-object)
* [$ENTRADA\_CACHE](/technical/developers/global-namespace.md#usdentrada_cache-object)
* [$ENTRADA\_ROUTER](/technical/developers/global-namespace.md#usdentrada_router-object)
* [$ENTRADA\_SETTINGS](/technical/developers/global-namespace.md#usdentrada_settings-object)
* [$ENTRADA\_TEMPLATE](/technical/developers/global-namespace.md#usdentrada_template-object)
* [$ENTRADA\_USER](/technical/developers/global-namespace.md#usdentrada_user-object)
* [$translate](/technical/developers/global-namespace.md#usdtranslate-object)

**Arrays**

* [$ONLOAD](/technical/developers/global-namespace.md#usdonload-array)
* [$JQUERY](/technical/developers/global-namespace.md#usdjquery-array)
* [$HEAD](/technical/developers/global-namespace.md#usdhead-array)
* [$BREADCRUMB](/technical/developers/global-namespace.md#usdbreadcrumb-array)
* [$AGENT\_CONTACTS](/technical/developers/global-namespace.md#usdagent_contacts-array)
* [$MODULES](/technical/developers/global-namespace.md#usdmodules-array)
* [$ADMINISTRATION](/technical/developers/global-namespace.md#usdadministration-array)

**Variables**

* [$SECTION](/technical/developers/global-namespace.md#usdsection-variable)
* [$ACTION](/technical/developers/global-namespace.md#usdaction-variable)
* [$MODULE](/technical/developers/global-namespace.md#usdmodule-variable)

#### $db (Object) <a href="#db-object" id="db-object"></a>

Available: All Elentra versions

The `$db` object allows you to access the active Elentra database connection. Elentra uses the [ADOdb](http://adodb.sourceforge.net/docs-adodb.htm) library to accomplish this.

While it is possible to use SQL directly in your code, it is currently considered best practice to access the database through the appropriate model (e.g. `Model_Events::get($id)`).

Example Usage (Select):

```
$query = "SELECT * FROM `events` WHERE `event_id` = ?";
$event = $db->GetRow($query, array($event_id));
if ($event) {
  echo "<h1>" . $event["event_title"] . "</h1>";
}
```

Example Usage (Insert):

```
$processed = array(
  "event_title" = clean_input($_POST["event_title"], array("nohtml"));
);

if ($db->AutoExecute("events", $processed, "INSERT")) {
  // Event inserted.
}
```

Example Usage (Update):

```
$processed = array(
  "course_active" = 0;
);

if ($db->AutoExecute("courses", $processed, "UPDATE", "course_id = " . (int) $id)) {
  // Course updated.
}
```

#### $ENTRADA\_ACL (Object) <a href="#entrada_acl-object" id="entrada_acl-object"></a>

Available: Elentra 1.2+

The `$ENTRADA_ACL` object allows you to check whether or not a user has access to do something. The \[Elentra ACL] is fairly complex, so time should be taken to properly understand how it works.

Example Usage:

```
if ($ENTRADA_ACL->amIAllowed("event", "create", false)) {
  echo "<a href=\"".ENTRADA_RELATIVE."/admin/events?section=add"\" class=\"btn\">Add Event</a>";
}
```

Entrada 1.6.1: `www-root/core/library/Entrada/authentication/entrada_acl.inc.php`&#x20;

Entrada 1.7.0: `www-root/core/library/Entrada/Acl.php`

#### $ENTRADA\_CACHE (Object) <a href="#entrada_cache-object" id="entrada_cache-object"></a>

Available: Elentra 1.2+

Using `$ENTRADA_CACHE` allows you to easily save and load contents from cache. It extends [Zend\_Cache](http://framework.zend.com/manual/1.12/en/zend.cache.introduction.html).

Example Usage:

```
if (!$ENTRADA_CACHE->test("my-cache-key")) {
  $cached_data = "Please cache and use this.";

  $ENTRADA_CACHE->save($cached_data, "my-cache-key");
} else {
  $cached_data = $ENTRADA_CACHE->load("my-cache-key");
}

echo $cached_data;

```

#### $ENTRADA\_ROUTER (Object) <a href="#entrada_router-object" id="entrada_router-object"></a>

`$ENTRADA_ROUTER`

#### $ENTRADA\_SETTINGS (Object) <a href="#entrada_settings-object" id="entrada_settings-object"></a>

`$ENTRADA_SETTINGS`

#### $ENTRADA\_TEMPLATE (Object) <a href="#entrada_template-object" id="entrada_template-object"></a>

`$ENTRADA_TEMPLATE`

#### $ENTRADA\_USER (Object) <a href="#entrada_user-object" id="entrada_user-object"></a>

Available: Unknown

The $ENTRADA\_USER object provides details for the currently logged in user.

Example Usage:

```
/* Create the $ENTRADA_USER object based on the proxy_id of a user who has successfully logged in. */
$ENTRADA_USER = User::get($proxy_id);

/* Get the logged in user's proxy_id. */
$ENTRADA_USER->getID();

/* Get the logged in user's active proxy id (useful in situations where you expect user masking to occur) but will return the actual proxy_id of the user if masking is not being used. */
$ENTRADA_USER->getActiveId();

/* Get the logged in user's active organisation id */
$ENTRADA_USER->getActiveOrganisation();
```

Entrada 1.6.1: `www-root/core/library/Models/users/User.class.php`

#### $translate (Object) <a href="#translate-object" id="translate-object"></a>

Available: Elentra 1.3+

Whenever you need to output text on a page you should do so like `$translate->_("Your String");`. Elentra uses Zend\_Translate to support multiple front-end languages, and when you wrap your language strings with the magic `_()` method your text can be replaced with the correct language.

Example Usage:

```
<div class="control-group">
  <label class="control-label"><?php echo $translate->_("Course Name"); ?></label>
  ...
</div>
```

#### $ONLOAD (Array) <a href="#onload-array" id="onload-array"></a>

Available: All Elentra versions

The `$ONLOAD` array allows you to record JavaScript that you would like to run after the DOM load is complete. The elements added to this array during run-time are dynamically added to the bottom of your HTML document within a `jQuery(document).ready(function() { ... });` block.

Example Usage:

```
$ONLOAD[] = "jQuery('#username').focus()";
```

#### $JQUERY (Array) <a href="#jquery-array" id="jquery-array"></a>

Available: All Elentra versions

The `$JQUERY` array allows you to manually include additional jQuery libraries in the correct location (i.e. after the main jQuery library, but before other dependencies) between the current page's `<head></head>` tags. The elements added to this array during run-time replace the `%JQUERY%` placeholder from the active template's `header.tpl.php` file.

Example Usage:

```
$JQUERY[] = "<script src=\"".ENTRADA_RELATIVE."/javascript/jquery/jquery.moment.min.js?release=".html_encode(APPLICATION_VERSION)."\"></script>\n";
```

#### $HEAD (Array) <a href="#head-array" id="head-array"></a>

Available: All Elentra versions

The `$HEAD` array allows you to include additional content between the current page's `<head></head>` tags. The elements added to this array during run-time replace the `%HEAD%` placeholder from the active template's `header.tpl.php` file.

Example Usage:

```
$HEAD[] = "<script src=\"" . ENTRADA_URL . "/javascript/AutoCompleteList.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>";
```

#### $BREADCRUMB (Array) <a href="#breadcrumb-array" id="breadcrumb-array"></a>

Available: All Elentra versions

The `$BREADCRUMB` array is a multidimensional array that is used to automatically generate a page's breadcrumb trail. You simply add arrays to the `$BREADCRUMB` array that contain a `url` and `title`key.

Example Usage:

```
$BREADCRUMB[] = array("url" => ENTRADA_RELATIVE . "/admin/example", "title" => $translate->_("Example Title"));
$BREADCRUMB[] = array("url" => ENTRADA_RELATIVE . "/admin/example/add", "title" => $translate->_("Add"));
```

Result:

```
/ [Example Title](/admin/example) / [Add](/admin/example/add)
```

#### $AGENT\_CONTACTS (Array) <a href="#agent_contacts-array" id="agent_contacts-array"></a>

`$AGENT_CONTACTS`

#### $MODULES (Array) <a href="#modules-array" id="modules-array"></a>

`$MODULES`

#### $ADMINISTRATION (Array) <a href="#administration-array" id="administration-array"></a>

`$ADMINISTRATION`

#### $SECTION (Variable) <a href="#section-variable" id="section-variable"></a>

`$SECTION`

#### $ACTION (Variable) <a href="#action-variable" id="action-variable"></a>

`$ACTION`

#### $MODULE (Variable) <a href="#module-variable" id="module-variable"></a>

`$MODULE`

## Elentra CPD

@todo

## Communities

Elentra has many moving parts, and understanding what's available to you as a developer will go a long way to learning Elentra. This page covers the global namespace for the Community system.

**Variables**

* [$COMMUNITY\_ID](https://docs.entrada.org/developer/namespace/#community-id-variable)
* [$COMMUNITY\_URL](https://docs.entrada.org/developer/namespace/#community-url-variable)
* [$COMMUNITY\_TEMPLATE](https://docs.entrada.org/developer/namespace/#community-template-variable)
* [$COMMUNITY\_THEME](https://docs.entrada.org/developer/namespace/#community-theme-variable)
* [$LOGGED\_IN](https://docs.entrada.org/developer/namespace/#logged-in-variable)
* [$COMMUNITY\_MEMBER\_SINCE](https://docs.entrada.org/developer/namespace/#member-since-variable)
* [$COMMUNITY\_MEMBER](https://docs.entrada.org/developer/namespace/#community-member-variable)
* [$COMMUNITY\_ADMIN](https://docs.entrada.org/developer/namespace/#community-admin-variable)

#### $COMMUNITY\_ID (Variable) <a href="#community_id-variable" id="community_id-variable"></a>

Available: All Entrada versions

The `$COMMUNITY_ID` variable will return the `communities.community_id` of the community that is currently being accessed by the user.

Example Usage:

```
echo "You are visiting community ID " . $COMMUNITY_ID . "!";
```

#### $COMMUNITY\_URL (Variable) <a href="#community_url-variable" id="community_url-variable"></a>

Available: All Entrada versions

The `$COMMUNITY_URL` variable will return the full URL of this community.

#### $COMMUNITY\_TEMPLATE (Variable) <a href="#community_template-variable" id="community_template-variable"></a>

Available: All Entrada versions

#### $COMMUNITY\_THEME (Variable) <a href="#community_theme-variable" id="community_theme-variable"></a>

Available: All Entrada versions

#### $LOGGED\_IN (Variable) <a href="#logged_in-variable" id="logged_in-variable"></a>

Available: All Entrada versions

#### $COMMUNITY\_MEMBER\_SINCE (Variable) <a href="#community_member_since-variable" id="community_member_since-variable"></a>

Available: All Entrada versions

#### $COMMUNITY\_MEMBER (Variable) <a href="#community_member-variable" id="community_member-variable"></a>

Available: All Entrada versions

#### $COMMUNITY\_ADMIN (Variable) <a href="#community_admin-variable" id="community_admin-variable"></a>

Available: All Entrada versions


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.elentra.org/technical/developers/global-namespace.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
