From 51cce60625c33b88e15a2335112b74c39d987a7c Mon Sep 17 00:00:00 2001 From: David Heskett <100443436+dheskettmgb@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:51:23 -0400 Subject: [PATCH 1/5] Add feature for custom logo and text branding for users views of sign up pages and emails. --- REDCapPRO.php | 74 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/REDCapPRO.php b/REDCapPRO.php index e8d8c97..75bfef2 100644 --- a/REDCapPRO.php +++ b/REDCapPRO.php @@ -148,6 +148,9 @@ class REDCapPRO extends AbstractExternalModule public $LOGO_URL = "https://i.imgur.com/5Xq2Vqt.png"; public $LOGO_ALTERNATE_URL = "https://i.imgur.com/fu0t8V1.png"; + public $customLogoImage = null; // custom logo image on create password page + public $customLogoText = ''; // custom logo text for branding + //////////////\\\\\\\\\\\\\\ ///// REDCAP HOOKS \\\\\ //////////////\\\\\\\\\\\\\\ @@ -476,6 +479,29 @@ public function redcap_module_link_check_display($project_id, $link) return null; } + public function redcap_module_system_change_version($version, $old_version) + { + $this->logEvent("Module Version Changed", [ + "version" => $version, + "old_version" => $old_version, + "redcap_user" => $this->safeGetUsername() + ]); + + $new_version_number = explode('v', $version)[1]; + $old_version_number = explode('v', $old_version)[1]; + + // If upgrading from a previous version to version 0.4.5, + // assume all existing logs are genuine, create module token, + // and add the token to all existing logs. + $critical_version = "0.4.6"; + if ( + version_compare($new_version_number, $critical_version, ">=") && + version_compare($old_version_number, $critical_version, "<") + ) { + $this->updateLogsWithToken(); + } + } + //////////////////\\\\\\\\\\\\\\\\\\\ ///// EMAIL-RELATED METHODS \\\\\ @@ -542,7 +568,7 @@ public function sendEmailUpdateEmail(string $username, string $new_email, string $old_email_clean = \REDCap::escapeHtml($old_email); $new_email_clean = \REDCap::escapeHtml($new_email); $body = "
" . $this->tt("email_update_greeting") . "
" . $this->tt("email_update_message1") . " ${username}
" . $this->tt("email_new_participant_greeting", [ $fname, $lname ]) . "
" . $this->tt("email_new_participant_message1") . "
" . $this->tt("email_new_participant_message2") . " ${username}
@@ -645,7 +671,7 @@ public function sendPasswordResetEmail($rcpro_participant_id, $selfInitiated = f
$subject = $this->tt("email_password_reset_subject");
$from = $settings->getEmailFromAddress();
$body = "
" . $this->tt("email_password_reset_greeting") . "
" . $this->tt("email_password_reset_message1") . "
" . $this->tt("email_password_reset_message2") . "
@@ -710,7 +736,7 @@ public function sendUsernameEmail(string $email, string $username)
$subject = $this->tt("email_username_subject");
$from = $settings->getEmailFromAddress();
$body = "
" . $this->tt("email_username_greeting") . "
" . $this->tt("email_username_message1") . " ${username}
" . $this->tt("email_username_message2") . "
" . $this->tt('mfa_email2') . "
" . $this->tt('mfa_email3') . " ${token}
" . $this->tt('mfa_email4') . "
" . $this->tt("email_authenticator_app_mfa_info_greeting") . "
" . $this->tt("email_authenticator_app_mfa_info_message1") . "
" . $this->tt("email_authenticator_app_mfa_info_message2") . "
@@ -821,7 +847,7 @@ public function sendAutoEnrollNotificationEmail(string $email, $project_id)
$subject = "REDCapPRO Auto-Enrollment";
$from = $settings->getEmailFromAddress();
$body = "
This is a notification that a participant has been automatically enrolled in your project.
Project ID: " . $project_id . "
Project Title: " . $this->framework->getProject($project_id)->getTitle() . "
@@ -1197,4 +1223,36 @@ public function getProjectlessUrl(string $path, bool $noAuth, bool $useApiEndpoi $_GET['pid'] = $pid; return $result; } -} \ No newline at end of file + + /** + * baseLogoImage - allow custom logo switch to work for email. either use regular image or for custom remove the standard image. + */ + public function baseLogoImage(): string + { + $image = "= $module->getUrl('images/customlogo.png') ?>
+
+