You are here

function _hosting_get_platforms in Hosting 7.4

Same name and namespace in other branches
  1. 5 platform/hosting_platform.module \_hosting_get_platforms()
  2. 6.2 platform/hosting_platform.module \_hosting_get_platforms()
  3. 7.3 platform/hosting_platform.module \_hosting_get_platforms()

Helper function to get platforms that haven't been deleted.

@todo Convert this to an EntityFieldQuery with conditions & tags (for JOINs). Tags will be unnecessary in D8 as JOINs are natively supported. See hosting_get_site_by_url() for an example of how to do this.

Parameters

int $web_server: Node ID of the server hosting this platform. Default 0 indicates any web_server.

boolean $enabled_only: Set to TRUE to return only enabled platforms. Defaults to FALSE.

Return value

The list of platforms.

5 calls to _hosting_get_platforms()
hosting_client_node_access_records in client/hosting_client.access.inc
Implements hook_node_access_records().
hosting_package_update_5 in package/hosting_package.install
Implements hook_update_N().
hosting_platform_hosting_summary in platform/hosting_platform.module
Implements hook_hosting_summary().
hosting_site_form in site/hosting_site.form.inc
Implements hook_form().
hosting_ssl_get_platforms in web_server/ssl/hosting_ssl.module
Return a list of platforms on SSL enabled servers.

File

platform/hosting_platform.module, line 256
Platform node type definition.

Code

function _hosting_get_platforms($web_server = 0, $enabled_only = FALSE) {
  $return = array();

  // Set the query parameters.
  $parameters = array(
    ':type' => 'platform',
    ':nstatus' => 1,
    //@todo: remove magic number?
    ':hstatus' => HOSTING_PLATFORM_DELETED,
    ':web_server' => $web_server,
  );

  // Add another filter to return only enabled sites is requested.
  $enabled_text = $enabled_only ? "AND h.status <> :disabled" : '';
  if ($enabled_only) {
    $parameters[':disabled'] = HOSTING_PLATFORM_LOCKED;
  }
  $result = db_query("SELECT n.nid, n.title\n                      FROM {node} n\n                      LEFT JOIN {hosting_platform} h\n                      ON n.nid = h.nid\n                      WHERE n.type = :type\n                      AND n.status = :nstatus\n                      AND h.status <> :hstatus\n                      AND (h.web_server = :web_server OR :web_server = 0)\n                      {$enabled_text}\n                      ORDER BY n.title\n                     ", $parameters);
  while ($platform = $result
    ->fetch()) {
    $return[$platform->nid] = $platform->title;
  }
  return $return;
}