function encrypt_submissions_form_alter in Encrypt Submissions 7
Same name and namespace in other branches
- 6 encrypt_submissions.module \encrypt_submissions_form_alter()
File
- ./
encrypt_submissions.module, line 214
Code
function encrypt_submissions_form_alter(&$form, &$form_state, $form_id) {
// Let's get the listed form_id's that the administrator entered
// in the config form, and explode them by \n
$listed_form_ids = explode("\n", variable_get("encrypt_submissions_forms", ""));
// Go through and make sure they are trimmed of whitespace.
foreach ($listed_form_ids as $key => $val) {
$listed_form_ids[$key] = trim($val);
}
// Also, get the visibility setting:
$visibility = variable_get("encrypt_submissions_visibility", "only_listed");
if ($visibility == "all_except" && in_array($form_id, $listed_form_ids)) {
// The user specifically said NOT to use this module on this form_id,
// so harmlessly return.
return;
}
else {
if ($visibility == "only_listed" && !in_array($form_id, $listed_form_ids)) {
// The user did not specifically say they wanted this form_id encrypted, so, harmlessly
// return.
return;
}
else {
// If we made it here, it means either the user went out of their way to state
// they wanted the form encrypted, OR, they did not list it as one of the forms
// to exclude. Either way, we should go ahead and attach the jCryption behavior.
// Has the current logged in user been given the permission
// to even use this module? If not, harmlessly return.
if (!user_access("access encrypt submissions")) {
return;
}
// Get the DOM form_id.
$dom_form_id = $form["#id"];
// Add the encryption status div to the bottom of the form.
$encrypt_msg = variable_get("encrypt_submissions_encrypt_msg", "Encrypting...");
$markup = "<span></span>";
if (trim(strtolower($encrypt_msg)) != "none") {
$markup = "<div id='encrypt_submissions_encrypt_msg_{$dom_form_id}'>\n <span id='encrypt_submissions_status_{$dom_form_id}'\n class='encrypt-submissions-status'>{$encrypt_msg} \n </span>\n </div>";
}
$form["encrypt_submissions_status"] = array(
"#type" => "markup",
"#weight" => 999999,
// Trying to make it appear at the very bottom.
"#markup" => $markup,
"#after_build" => array(
"encrypt_submissions_add_form_css_js",
),
);
}
}
}