Skip to content

Commit

Permalink
6.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjpearson committed Apr 30, 2024
1 parent 40248c5 commit a132343
Show file tree
Hide file tree
Showing 264 changed files with 11,407 additions and 1,444 deletions.
16 changes: 9 additions & 7 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace Vanderbilt\CareerDevLibrary;

use \Vanderbilt\FlightTrackerExternalModule\CareerDev;
use \Vanderbilt\FlightTrackerExternalModule\FlightTrackerExternalModule;

require_once(dirname(__FILE__)."/CareerDev.php");
require_once(dirname(__FILE__)."/FlightTrackerExternalModule.php");

class Application {
public static function getVersion() {
Expand Down Expand Up @@ -68,7 +70,7 @@ public static function has($instrument, $pid = "") {
}

public static function getFlightConnectorURL() {
return "https://redcap.vanderbilt.edu/external_modules/?prefix=flight_connector&page=map&pid=172928&h=5986967536b44df5&NOAUTH";
return "https://redcap.vumc.org/external_modules/?prefix=flight_connector&page=map&pid=172928&h=5986967536b44df5&NOAUTH";
}

public static function getDataTable($pid) {
Expand Down Expand Up @@ -292,7 +294,7 @@ public static function isPluginProject($project_id = "") {
(self::isVanderbilt() && ($project_id == NEWMAN_SOCIETY_PROJECT))
|| (self::isVanderbilt() && $isCopiedPluginProject)
|| (self::isLocalhost() && ($project_id == LOCALHOST_TEST_PROJECT))
|| (self::isServer("redcaptest.vanderbilt.edu") && ($project_id == REDCAPTEST_TEST_PROJECT))
|| (self::isServer(FlightTrackerExternalModule::VANDERBILT_TEST_SERVER) && ($project_id == REDCAPTEST_TEST_PROJECT))
);
}

Expand Down Expand Up @@ -396,7 +398,7 @@ public static function getHeader($tokenName = "", $token = "", $server = "", $pi

$str .= "<header class='topHeaderWrapper'>";
$str .= "<div class='topHeader'>";
$str .= "<div class='topBar' style='float: left; padding-left: 5px;'><a href='https://redcap.vanderbilt.edu/plugins/career_dev/consortium/'><img alt='Flight Tracker for Scholars' src='".self::link("/img/flight_tracker_logo_small.png")."'></a></div>";
$str .= "<div class='topBar' style='float: left; padding-left: 5px;'><a href='https://redcap.vumc.org/plugins/career_dev/consortium/'><img alt='Flight Tracker for Scholars' src='".self::link("/img/flight_tracker_logo_small.png")."'></a></div>";
# logged in and on a record
if (Application::getUsername() && (isset($_GET['id']) || isset($_GET['record']))) {
$records = Download::records($token, $server);
Expand Down Expand Up @@ -589,9 +591,9 @@ public static function getPids() {
}
if (self::isLocalhost()) {
array_unshift($pids, LOCALHOST_TEST_PROJECT);
} else if (self::isServer("redcap.vanderbilt.edu")) {
} else if (self::isServer("redcap.vanderbilt.edu") || self::isServer("redcap.vumc.org")) {
array_unshift($pids, NEWMAN_SOCIETY_PROJECT);
} else if (self::isServer("redcaptest.vanderbilt.edu")) {
} else if (self::isServer(FlightTrackerExternalModule::VANDERBILT_TEST_SERVER)) {
# TODO Add test projects with plugin
}
} else {
Expand Down Expand Up @@ -906,8 +908,8 @@ public static function getScholarPortalLink() {
return self::link("portal/index.php");
}

public static function applySecurityHeaders() {
$serverList = Application::getSetting("safe_servers");
public static function applySecurityHeaders($pid) {
$serverList = Application::getSetting("safe_servers", $pid);
if (!$serverList) {
return;
}
Expand Down
51 changes: 35 additions & 16 deletions CareerDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CareerDev {
public static $passedModule = NULL;

public static function getVersion() {
return "6.10.0";
return "6.10.1";
}

public static function getLocalhostPluginPid() {
Expand Down Expand Up @@ -125,7 +125,7 @@ public static function getSites($all = TRUE) {
"PubMed Central Converter" => "www.ncbi.nlm.nih.gov",
"iCite" => "icite.od.nih.gov",
"ORCID" => "pub.orcid.org",
"Statistics Reporting" => "redcap.vanderbilt.edu",
"Statistics Reporting" => "redcap.vumc.org",
"Altmetric" => "api.altmetric.com",
"Patents View (US Patent Office)" => "api.patentsview.org",
"NSF Grants" => "api.nsf.gov",
Expand Down Expand Up @@ -307,13 +307,28 @@ public static function unsetPid() {
self::$pid = NULL;
}

private static function constructThisURL() {
private static function getProtocol($uri) {
$isHTTPS = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'));
$serverPort = $_SERVER['SERVER_PORT'] ?? 0;
$isSSLPort = $serverPort == 443;
$protocol = ($isHTTPS || $isSSLPort) ? "https://" : "http://";
$host = $_SERVER['HTTP_HOST'] ?? "";
if ($isHTTPS || $isSSLPort) {
return "https://";
} else if (isset($_GET['pid'])) {
$myserver = self::getSetting("server", Sanitizer::sanitizePid($_GET['pid']));
if (preg_match("/^https:/i", $myserver)) {
# assume https because the setup server requests it
# this facilitates unusual REDCap cloud setups where SSL is enabled for the URL
# but the apache server just uses http because a proxy handles the encryption
return "https://";
}
}
return "http://";
}

private static function constructThisURL() {
$uri = $_SERVER['REQUEST_URI'] ?? "";
$protocol = self::getProtocol($uri);
$host = $_SERVER['HTTP_HOST'] ?? "";
return $protocol.$host.$uri;
}

Expand Down Expand Up @@ -446,7 +461,7 @@ public static function parseGetParams($url) {
}

public static function makeLogo() {
return "<a href='https://redcap.vanderbilt.edu/plugins/career_dev/consortium/'><img src='".self::link("img/flight_tracker_logo_medium.png")."' alt='Flight Tracker for Scholars'></a>";
return "<a href='https://redcap.vumc.org/plugins/career_dev/consortium/'><img src='".self::link("img/flight_tracker_logo_medium.png")."' alt='Flight Tracker for Scholars'></a>";
}

public static function link($relativeUrl, $pid = "", $withWebroot = FALSE) {
Expand Down Expand Up @@ -499,10 +514,10 @@ public static function getRootDir($withWebroot = FALSE) {

private static function getThisPageURL($project_id, $isPortalPage) {
if (Application::isPluginProject($project_id)) {
$port = $_SERVER['SERVER_PORT'] ?? "";
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || ($port == 443)) ? "https://" : "http://";
$uri = $_SERVER['REQUEST_URI'] ?? "";
$protocol = self::getProtocol($uri);
$host = $_SERVER['HTTP_HOST'] ?? "";
$fileLocation = explode("?", $_SERVER['REQUEST_URI'] ?? "")[0];
$fileLocation = explode("?", $uri)[0];
$url = $protocol . $host . $fileLocation;
if ($project_id) {
$url .= "?pid=".urlencode($project_id);
Expand Down Expand Up @@ -600,7 +615,7 @@ public static function getModulePageURL($http, $project_id, $isMentorAgreementPa

private static function getREDCapSignupURL() {
if (self::isVanderbilt()) {
return 'https://redcap.vanderbilt.edu/surveys/?s=L4R3NJ8XME';
return 'https://redcap.vumc.org/surveys/?s=L4R3NJ8XME';
} else {
global $homepage_contact_url, $homepage_contact_email;
if ($homepage_contact_url) {
Expand Down Expand Up @@ -727,7 +742,7 @@ public static function getPidFromToken($localToken = "") {
return $pid;
}
}
if ($localToken == $token) {
if ($pid && ($localToken == $token)) {
return $pid;
}
foreach ($info as $key => $row) {
Expand Down Expand Up @@ -881,10 +896,10 @@ public static function getAllSettings($pid = "") {
public static function getSetting($field, $pid = "") {
if (
self::isVanderbilt()
&& ((Application::isServer("redcap.vanderbilt.edu") && ($pid == NEWMAN_SOCIETY_PROJECT))
&& ((Application::isServer("redcap.vumc.org") && ($pid == NEWMAN_SOCIETY_PROJECT))
|| ((Application::isLocalhost() && ($pid == LOCALHOST_TEST_PROJECT))))
) {
# TODO add redcaptest.vanderbilt.edu
# TODO add redcaptest.vumc.org
$module = ExternalModules::getModuleInstance("vanderbilt_plugin-settings");
$items = [$field];
if (!preg_match("/\/plugins\//", $_SERVER['REQUEST_URI'] ?? "")) {
Expand Down Expand Up @@ -1037,7 +1052,7 @@ public static function isVanderbilt() {
if (Application::isLocalhost()) {
return TRUE;
}
return preg_match("/vanderbilt.edu/", SERVER_NAME);
return preg_match("/vanderbilt.edu/", SERVER_NAME) || preg_match("/vumc.org/", SERVER_NAME);
}

public static function getRepeatingFormsAndLabels($metadata = []) {
Expand Down Expand Up @@ -1091,7 +1106,11 @@ public static function isLocalhost() {
}

public static function isTestGroup($pid) {
return (SERVER_NAME == "redcap.vanderbilt.edu") && in_array($pid, [105963, 101785]);
return (
Application::isServer("redcap.vanderbilt.edu")
|| Application::isServer("redcap.vumc.org")
)
&& in_array($pid, [105963, 101785]);
}

public static function duplicateAllSettings($srcPid, $destPid, $defaultSettings = []) {
Expand Down Expand Up @@ -1222,7 +1241,7 @@ public static function getMenu($menuName, $pid = NULL) {
$ary["Import General Data"] = self::link("/import.php");
$ary["Import Positions"] = self::link("/bulkImport.php") . "&positions";
if (self::isVanderbilt() && ($pid == 145767)) {
$ary["LDAP Lookup"] = "https://redcap.vanderbilt.edu/plugins/career_dev/LDAP/ldapLookup.php";
$ary["LDAP Lookup"] = "https://redcap.vumc.org/plugins/career_dev/LDAP/ldapLookup.php";
}

return $ary;
Expand Down
2 changes: 1 addition & 1 deletion CareerDevHelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function getHelp($title, $menu) {
}

public static function getVideoVaultLinkHTML() {
$url = "https://redcap.vanderbilt.edu/plugins/career_dev/help/videos.php";
$url = "https://redcap.vumc.org/plugins/career_dev/help/videos.php";
$videosHTML = Links::makeLink($url, "Flight Tracker Video Vault", TRUE);
return "<p class='smaller nomargin centered' style='font-family: europa, Helvetica, Arial, sans-serif;'>$videosHTML</p>";
}
Expand Down
1 change: 1 addition & 0 deletions FlightTrackerExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class FlightTrackerExternalModule extends AbstractExternalModule
const OLD_LAST_NAMES = "old_last_names";
const FIRST_NAMES = "first_names";
const LAST_NAMES = "last_names";
const VANDERBILT_TEST_SERVER = "redcaptest.vumc.org";

function getPrefix() {
return Application::getPrefix();
Expand Down
20 changes: 12 additions & 8 deletions bulkImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,19 @@
}
echo "</div>\n";
} else {
try {
$feedback = Upload::rows($upload, $token, $server);
if ($feedback['error']) {
echo "<p class='red padded centered max-width'>ERROR! ".$feedback['error']."</p>\n";
} else {
echo "<p class='green padded centered max-width'>Upload successful!</p>\n";
if (!empty($upload)) {
try {
$feedback = Upload::rows($upload, $token, $server);
if (is_array($feedback) && $feedback['error']) {
echo "<p class='red padded centered max-width'>ERROR! ".$feedback['error']."</p>";
} else {
echo "<p class='green padded centered max-width'>Upload successful!</p>";
}
} catch (\Exception $e) {
echo "<p class='red padded centered max-width'>ERROR! ".$e->getMessage()."</p>";
}
} catch (\Exception $e) {
echo "<p class='red padded centered max-width'>ERROR! ".$e->getMessage()."</p>\n";
} else {
echo "<p class='red padded centered max-width'>ERROR! No data have been matched.</p>";
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion classes/CelebrationsEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private function processCitations($redcapData, $warningTs, $currBios, $requested
$journalHandles[] = Sanitizer::sanitizeWithoutChangingQuotes($journalRow['handle']);
}
}
$journalHTML = empty($journalHandles) ? $journalHTML." (<a href='https://redcap.vanderbilt.edu/surveys/?s=D94RMNA3AT94CXTP'>add new journal handle?</a>)" : $journalHTML." (".implode(", ", $journalHandles).")";
$journalHTML = empty($journalHandles) ? $journalHTML." (<a href='https://redcap.vumc.org/surveys/?s=D94RMNA3AT94CXTP'>add new journal handle?</a>)" : $journalHTML." (".implode(", ", $journalHandles).")";
}
$journalHTML .= "</div>";
foreach ($pmidsIdentified[$pmid] as $matchRecordId) {
Expand Down
2 changes: 1 addition & 1 deletion classes/DataDictionaryManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ public static function mergeMetadataAndUploadNew($originalMetadata, $fileMetadat
}

public static function updateAlumniAssociations(&$metadata, $originalMetadata, $pid) {
$alumniURL = "https://redcap.vanderbilt.edu/plugins/career_dev/getAlumniAssociations.php?NOAUTH";
$alumniURL = "https://redcap.vumc.org/plugins/career_dev/getAlumniAssociations.php?NOAUTH";
list($resp, $alumniJSON) = URLManagement::downloadURL($alumniURL, $pid);
$indexedOriginalMetadata = self::indexMetadata($originalMetadata);
$nativeAlumniAssociations = json_decode($alumniJSON ?: "[]", TRUE);
Expand Down
25 changes: 20 additions & 5 deletions classes/DateManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
class DateManagement {
const SEP_REGEX = "[\/\-]";

public static function getEarliestDate($dates) {
if (count($dates) == 0) {
return "";
} else if (count($dates) == 1) {
return $dates[0];
}
$earliestDate = $dates[0];
for ($i = 1; $i < count($dates); $i++) {
$date = $dates[$i];
if (DateManagement::dateCompare($date, "<", $earliestDate)) {
$earliestDate = $date;
}
}
return $earliestDate;
}
public static function getFederalFiscalYear($ts = FALSE) {
if (!$ts) {
$ts = time();
Expand Down Expand Up @@ -47,7 +62,7 @@ public static function getWeekNumInYear($ts = FALSE) {
$dt = new \DateTime();
$dt->setTimestamp($ts);
$dayOfYear = $dt->format("z");
return floor(($dayOfYear - 1) / 7) + 1;
return floor(((int) $dayOfYear - 1) / 7) + 1;
}

public static function getWeekNumInMonth($ts = FALSE) {
Expand All @@ -57,7 +72,7 @@ public static function getWeekNumInMonth($ts = FALSE) {
$dt = new \DateTime();
$dt->setTimestamp($ts);
$dayOfMonth = $dt->format("j");
return floor(($dayOfMonth - 1) / 7) + 1;
return floor(((int) $dayOfMonth - 1) / 7) + 1;
}

public static function isYear($d) {
Expand Down Expand Up @@ -168,9 +183,9 @@ public static function getYearDuration($date1, $date2) {
}

public static function REDCapTsToPHPTs($redcapTs) {
$year = substr($redcapTs, 0, 4);
$month = substr($redcapTs, 4, 2);
$day = substr($redcapTs, 6, 2);
$year = (int) substr($redcapTs, 0, 4);
$month = (int) substr($redcapTs, 4, 2);
$day = (int) substr($redcapTs, 6, 2);
$dt = new \DateTime();
$dt->setDate($year, $month, $day);
return $dt->getTimestamp();
Expand Down
2 changes: 1 addition & 1 deletion classes/Definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getHTML() {
}

public function getCodeBookLink() {
return "Download the Project's CodeBook ".Links::makeLink("https://redcap.vanderbilt.edu/plugins/career_dev/docs/Codebook.docx", "here").".";
return "Download the Project's CodeBook ".Links::makeLink("https://redcap.vumc.org/plugins/career_dev/docs/Codebook.docx", "here").".";
}

public function getSubText() {
Expand Down
Loading

0 comments on commit a132343

Please sign in to comment.