function encryption_settings_form

6.x encryption.module encryption_settings_form()

File

modules/encryption/encryption.module, line 53
This is the main module file for the encryption module.

Code

function encryption_settings_form() {
  $form = array();

  $hash = encryption_get_hash_protocol();
  $cipher = encryption_get_cipher_algorithm();

  if ($hash) {
    $form ["encryption_markup_1"] = array(
      "value" => t("<br><br><b>The hash protocol your system supports is: %hash.</b>  
                    <br>This hash will be used
                    to convert your key (specified below) into a uniform and unique string.  If you ever switch servers,
                    you must ensure the same hash protocol is available and being used, or your
                    encrypted values will not be readable.  You should make a note of which hash protocol
                    your system is using.  See the README.txt file for information on how to specify which
                    protocol to use, if you do not wish to use %hash.<br><br>", array("%hash" => $hash)),
    );
  }
  else {
    // Couldn't find any values for hash!
    fp_add_message(t("This module will NOT work correctly, because no hash protocol could be found!
                      Check your server settings and make sure this page does not display an error before
                      attempting to use this module!"), "error");
    return $form;
  }


  if ($hash) {
    $form ["encryption_markup_2"] = array(
      "value" => t("<b>The cipher algorithm your system supports is: %cipher.</b>  
                    <br>This cipher will be used
                    to actually encrypt and decrypt data.  If you ever switch servers,
                    you must ensure the same cipher is available and being used, or your
                    encrypted values will not be readable.  You should make a note of which cipher algorithm
                    your system is using.  See the README.txt file for information on how to specify which
                    protocol to use, if you do not wish to use %cipher.<br><br>", array("%cipher" => $cipher)),
    );
  }
  else {
    // Couldn't find any values for hash!
    fp_add_message(t("This module will NOT work correctly, because no cipher protocol could be found!
                      Check your server settings and make sure this page does not display an error before
                      attempting to use this module!"), "error");
    return $form;
  }



  $form ['mark_encryption_key_string'] = array(
    'value' => t("<p><b>Encryption Key</b><br>
                    To add an encryption key string, edit your settings.php file and add a variable like so:
                    <br> &nbsp; &nbsp; <code>\$GLOBALS['encryption_key_string'] = 'random text goes here';</code>
                    <br> Make your random text at least 32 characters long.</p>"),
  );

  if (!isset($GLOBALS ['encryption_key_string'])) {
    $form ['mark_encryption_key_string__notice'] = array(
      'value' => t("<br><p><b>NOTE:</b> <u>No encryption key found</u> in your settings.php file.  This module will not function correctly without either
                        a key set in your settings.php file or as a text file below.</p>"),
    );
  }
  else {
    $form ['mark_encryption_key_string__found'] = array(
      'value' => t("<p><b>NOTE:</b> <u>Encryption key WAS found</u> in your settings.php file.  Make sure to store the key in a safe place.  If you lose the key,
                    you will not be able to decrypt encrypted values or files.</p>"),
    );


  }


  $form ["encryption_key_path"] = array(
    "label" => t("Encryption Key File Absolute Path:"),
    "type" => "textfield",
    "maxlength" => 255,
    "value" => variable_get("encryption_key_path", ""),
    "description" => t("If you prefer, you may enter your key string into a file, then store that file somewhere on your server.  Enter
                        the absolute path to the file here.  Ex: /var/misc/key/my-key.txt.  It should be in a location outside of the webroot,
                        which web users couldn't get to by guessing a URL.
                        If you enter anything here, the encryption key above will be ignored.
                        <br><br><b>WARNING: DO NOT CHANGE THE KEY VALUE</b> once you have decided
                        on a key.  Doing so will cause <b>all previously encrypted files or values to be unreadable.</b>"),
  );




  $form ["encryption_files_encryption"] = array(
    "type" => "select",
    "label" => "Encrypt uploaded files?",
    "options" => array("yes" => t("Yes"), "no" => t("No")),
    "value" => variable_get("encryption_files_encryption", "yes"),
    "description" => t("When files are uploaded or attached to a piece of content (for example, an email attachment or text message attachment) 
                        they can be automatically encrypted before being saved to the server.  Do you wish
                        to do this?  If so, the extension \".enc\" will be added to the end of encrypted files.
                        When files are downloaded through the Encryption module, they will be automatically decrypted
                        for the end user.
                        <br><br>
                        Note: this does not affect files uploaded to a student's History tab.  To configure
                        encryption of those files, see the Student Files settings page."),
    "prefix" => "<fieldset><legend>" . t("Encryption Settings") . "</legend>",
    "suffix" => "</fieldset>",
  );




  $form ["encryption_confirm"] = array(
    "label" => "Are you sure you want to save changes?",
    "type" => "textfield",
    "size" => 10,
    "required" => TRUE,
    "description" => t("If you are certain you wish to save changes to this form, enter YES (all caps)."),
  );


  $form ["submit_btn"] = array(
    "type" => "submit",
    "value" => "Submit",
  );


  return $form;
}