You are here

lockr.admin.inc in Lockr 7

Same filename and directory in other branches
  1. 7.3 lockr.admin.inc
  2. 7.2 lockr.admin.inc

File

lockr.admin.inc
View source
<?php

/**
 * @file
 * Form callbacks for Lockr register form.
 */
require_once __DIR__ . '/include/advanced_form.inc';
require_once __DIR__ . '/include/register_form.inc';
require_once __DIR__ . '/include/request_form.inc';

/**
 * Form constructor for Lockr registration form.
 *
 * @ingroup forms
 */
function lockr_admin_form($form, &$form_state) {
  $form = array();
  list($exists) = lockr_check_registration();
  $partner = lockr_get_partner();
  $request_sent = (bool) variable_get('lockr_request');
  $register_form = !$exists && (bool) $partner || $request_sent;
  $advanced_open = !$exists && !$partner;
  $request_form = !$exists && !$partner && !$request_sent;
  if ($partner) {
    $desc = $partner['description'];
  }
  elseif ($request_sent) {
    $desc = t('Thank you for your request for a custom cert! ' . 'A member from our development team will be generating ' . 'that cert and getting back to you shortly.');
  }
  else {
    $desc = t('Thank you for your interest in Lockr! ' . 'Our system is detecting that your website is not currently hosted by a supported provider. ' . 'To help us better prioritize our integrations, ' . 'please provide your current hosting provider and email in the fields below. ' . 'We will be sure to notify you when Lockr is integrated with your hosting provider. ' . 'In the meantime, a custom certificate to use Lockr will be generated and ' . 'sent to the email you provided.');
  }
  $form['description'] = array(
    '#prefix' => '<p>',
    '#markup' => $desc,
    '#suffix' => '</p>',
  );
  if ($register_form) {
    $form['register'] = lockr_admin_register_form($form_state);
  }
  else {
    if ($exists) {
      $form['registered'] = array(
        '#title' => t("You're already registered"),
        '#prefix' => '<p>',
        '#markup' => t("This site is already registered with the Lockr Key Management Service. " . "There's nothing left for you do to here, " . 'your keys entered in the key settings are already protected. ' . 'If you registered with the wrong account, you can ' . 'click <a href="@link" target="_blank">here</a> to go to Lockr and manage your sites.', array(
          '@link' => 'http://lockr.io/user/login',
        )),
        '#suffix' => '</p>',
      );
    }
  }
  if ($request_form) {
    $form['request'] = lockr_admin_request_form();
  }
  else {
    if ($request_sent) {
      $form['resend_request'] = array(
        '#type' => 'submit',
        '#value' => t('Resend request link'),
        '#submit' => array(
          'lockr_admin_resend_submit',
        ),
      );
    }
  }
  $form['advanced'] = lockr_admin_advanced_form($advanced_open);
  return $form;
}

/**
 * Reset the lockr_request variable to allow resending.
 */
function lockr_admin_resend_submit($form, &$form_state) {
  variable_del('lockr_request');
}

Functions

Namesort descending Description
lockr_admin_form Form constructor for Lockr registration form.
lockr_admin_resend_submit Reset the lockr_request variable to allow resending.