function encrypt_submissions_check_library_files_exist in Encrypt Submissions 6
Same name and namespace in other branches
- 7 encrypt_submissions.module \encrypt_submissions_check_library_files_exist()
This function will check to see if the jcryption libraries have been installed correctly, and warn the user if they have not.
Depending on the argument, it will let the user know if they HAVE been installed correctly.
4 calls to encrypt_submissions_check_library_files_exist()
- encrypt_submissions_add_form_css_js in ./
encrypt_submissions.module - We will use this function as an #after_build to ensure we always attach our CSS and JS to the page.
- encrypt_submissions_admin_form in ./
encrypt_submissions.module - This is our admin/settings/encrypt-submissions form.
- encrypt_submissions_generate_keypair in ./
encrypt_submissions.module - This function, taken largely from the examples which come with jCryption, is called by AJAX and returns the relavant values needed to encrypt our form. It also places those same values into the SESSION, so we can decrypt it after the form submits.
- encrypt_submissions_init in ./
encrypt_submissions.module
File
- ./
encrypt_submissions.module, line 52
Code
function encrypt_submissions_check_library_files_exist($bool_notify_correct_installation = TRUE) {
$err = "";
$original_location = variable_get("encrypt_submissions_jcryption_location", "");
$jcryption_location = drupal_get_path("module", "encrypt_submissions") . "/jcryption/";
$js_file = "{$jcryption_location}/jquery.jcryption.js";
$php_file = "{$jcryption_location}/jcryption.php";
if (!file_exists($js_file) || !file_exists($php_file)) {
// Attempt to see if we are using libraries API
if (function_exists("libraries_get_path")) {
$jcryption_location = libraries_get_path("jcryption");
$js_file = "{$jcryption_location}/jquery.jcryption.js";
$php_file = "{$jcryption_location}/jcryption.php";
}
}
variable_set("encrypt_submissions_jcryption_location", $jcryption_location);
if ($original_location != $jcryption_location) {
// Make it re-display the message, letting us know we changed something.
unset($_SESSION["es_notified_correct"]);
}
if (!file_exists($js_file)) {
$err .= "<p>" . t("The file jquery.jcryption.js could not be found. It should be named correctly\n and located at: ") . $js_file . "</p>";
}
if (!file_exists($php_file)) {
$err .= "<p>" . t("The file jcryption.php could not be found. It should be named correctly\n and located at: ") . $php_file . "</p>";
}
if ($err) {
drupal_set_message($err, "error");
unset($_SESSION["es_notified_correct"]);
// This is used below, to make sure the message is
// not displayed twice.
}
else {
if ($bool_notify_correct_installation && !isset($_SESSION["es_notified_correct"])) {
drupal_set_message(t("The jCryption library files appear to be installed correctly at {$jcryption_location}."));
$_SESSION["es_notified_correct"] = TRUE;
// This prevents the message from being seen twice.
}
}
}