You are here

function lockr_admin_page in Lockr 7.3

1 string reference to 'lockr_admin_page'
lockr_menu in ./lockr.module
Implements hook_menu().

File

./lockr.admin.inc, line 13
Form callbacks for Lockr register form.

Code

function lockr_admin_page() {
  $lc = lockr_client();
  try {
    $info = $lc
      ->getInfo();
  } catch (ConnectException $e) {
    drupal_set_message(t('We are having trouble connecting to the Lockr servers.'), 'error');
    $info = NULL;
  } catch (LockrApiException $e) {
    $info = NULL;
  } catch (\Exception $e) {
    watchdog_exception('lockr', $e);
    drupal_set_message(t('The Lockr service has returned an error. Please try again.'), 'error');
    $info = NULL;
  }
  $content['status'] = [
    '#markup' => lockr_admin_status($info),
  ];
  if ($info) {
    $header_text = t("All systems are a go! Your site is registered, your certificate is valid, and everything seems good on our end. The table below will give you the status of all elements. Should anything look out of the ordinary just let us know on the Slack channel and we'd be happy to help. Happy Keying!");
  }
  else {
    $header_text = t("Welcome to Lockr! You're just a few steps away from storing your keys safe and secure. To make things simple we've laid out a few key elements (pun intended) that the system requires in order to run. Fill out the forms below and once all rows on the table are green, you're good to go! It's that simple! If you'd like assistance in getting up and running be sure to <a href=\"@email\">email us</a> or connect with us on <a href=\"@slack\">Slack</a>.", [
      '@email' => 'mailto:support@lockr.io',
      '@slack' => 'http://slack.lockr.io',
    ]);
  }
  $content['header'] = [
    '#prefix' => '<p>',
    '#markup' => $header_text,
    '#suffix' => '</p>',
  ];
  $partner = lockr_get_partner();
  if ($partner) {
    $content['description'] = [
      '#prefix' => '<p>',
      '#markup' => $partner['description'],
      '#suffix' => '</p>',
    ];
  }
  if (!$info) {
    $content['register'] = drupal_get_form('lockr_admin_register_form');
  }
  elseif ($info['env'] !== 'prod' && !$partner) {
    $content['move_to_prod'] = drupal_get_form('lockr_admin_migrate_form', $info);
  }
  $content['advanced'] = drupal_get_form('lockr_admin_advanced_form');
  return $content;
}