You are here

function hosting_letsencrypt_get_sites in Aegir HTTPS 7.3

Fetch HTTPS-enabled site IDs using Let's Encrypt certificates.

@todo Ensure sites are using the Let's Encrypt service.

Parameters

bool $queue_only: Only return items that have not been verified in the last 4 weeks.

int $limit: The maximum number of items to return.

2 calls to hosting_letsencrypt_get_sites()
hosting_letsencrypt_hosting_queues in submodules/letsencrypt/hosting_letsencrypt.module
Implements hook_hosting_queues().
hosting_lets_encrypt_queue in submodules/letsencrypt/hosting_letsencrypt.module
Implements hosting_QUEUE_TYPE_queue().

File

submodules/letsencrypt/hosting_letsencrypt.module, line 79
LetsEncrypt certificate generation service.

Code

function hosting_letsencrypt_get_sites($queue_only = FALSE, $limit = 0) {
  $sites = array();
  $https = array(
    HOSTING_HTTPS_ENABLED,
    HOSTING_HTTPS_REQUIRED,
  );
  $enabled = HOSTING_SITE_ENABLED;
  $query = db_select('hosting_site', 's');
  $query
    ->join('hosting_https_site', 'h', 's.nid = h.nid');
  $query
    ->fields('s', array(
    'nid',
  ))
    ->condition('h.https_enabled', $https, 'IN')
    ->condition('s.status', $enabled)
    ->orderBy('s.verified', 'ASC');
  if ($queue_only) {
    $query
      ->condition('s.verified', time() - 86400 * 7 * 2, '<=');
  }
  if ($limit) {
    $query
      ->range(0, $limit);
  }
  $result = $query
    ->execute()
    ->fetchAll();
  foreach ($result as $item) {
    $sites[] = $item->nid;
  }
  return $sites;
}