Skip to content

Commit

Permalink
5.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjpearson committed Jun 9, 2023
1 parent 1da4449 commit 732f538
Show file tree
Hide file tree
Showing 17 changed files with 264 additions and 165 deletions.
41 changes: 22 additions & 19 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ public static function log($mssg, $pid = FALSE) {
CareerDev::log($mssg, $pid);
}

public static function getInstitutions($pid = NULL) {
return CareerDev::getInstitutions($pid);
public static function getInstitutions($pid = NULL, $searchOnly = TRUE) {
return CareerDev::getInstitutions($pid, $searchOnly);
}

public static function getImportHTML() {
Expand Down Expand Up @@ -325,10 +325,10 @@ public static function getImportHTML() {
return $str;
}

public static function getHeader($tokenName = "") {
$pid = CareerDev::getPID();
$token = self::getSetting("token", $pid);
$server = self::getSetting("server", $pid);
public static function getHeader($tokenName = "", $token = "", $server = "", $pid = "") {
$pid = $pid ?: CareerDev::getPID();
$token = $token ?: self::getSetting("token", $pid);
$server = $server?: self::getSetting("server", $pid);

if (!$tokenName) {
$tokenName = self::getSetting("tokenName", $pid);
Expand Down Expand Up @@ -412,22 +412,22 @@ public static function getHeader($tokenName = "") {

$navBar = new NavigationBar();
$navBar->addFALink("home", "Home", CareerDev::getHomeLink());
$navBar->addFAMenu("clinic-medical", "General", CareerDev::getMenu("General"));
$navBar->addFAMenu("clinic-medical", "General", CareerDev::getMenu("General", $pid));
if ($switches->isOnForProject("Grants")) {
$navBar->addMenu("<img src='".CareerDev::link("/img/grant_small.png")."'>Grants", CareerDev::getMenu("Grants"));
}
if ($switches->isOnForProject("Publications")) {
$navBar->addFAMenu("sticky-note", "Pubs", CareerDev::getMenu("Pubs"));
$navBar->addFAMenu("sticky-note", "Pubs", CareerDev::getMenu("Pubs", $pid));
}
$navBar->addFAMenu("table", "View", CareerDev::getMenu("View"));
$navBar->addFAMenu("calculator", "Wrangle", CareerDev::getMenu("Wrangler"));
$navBar->addFAMenu("school", "Scholars", CareerDev::getMenu("Scholars"));
$navBar->addMenu("<img src='".CareerDev::link("/img/redcap_translucent_small.png")."'>REDCap", CareerDev::getMenu("REDCap"));
$navBar->addFAMenu("tachometer-alt", "Dashboards", CareerDev::getMenu("Dashboards"));
$navBar->addFAMenu("filter", "Cohorts / Filters", CareerDev::getMenu("Cohorts"));
$navBar->addFAMenu("chalkboard-teacher", "Mentors", CareerDev::getMenu("Mentors"));
$navBar->addFAMenu("pen", "Resources", CareerDev::getMenu("Resources"));
$navBar->addFAMenu("question-circle", "Help", CareerDev::getMenu("Help"));
$navBar->addFAMenu("table", "View", CareerDev::getMenu("View", $pid));
$navBar->addFAMenu("calculator", "Wrangle", CareerDev::getMenu("Wrangler", $pid));
$navBar->addFAMenu("school", "Scholars", CareerDev::getMenu("Scholars", $pid));
$navBar->addMenu("<img src='".CareerDev::link("/img/redcap_translucent_small.png")."'>REDCap", CareerDev::getMenu("REDCap", $pid));
$navBar->addFAMenu("tachometer-alt", "Dashboards", CareerDev::getMenu("Dashboards", $pid));
$navBar->addFAMenu("filter", "Cohorts / Filters", CareerDev::getMenu("Cohorts", $pid));
$navBar->addFAMenu("chalkboard-teacher", "Mentors", CareerDev::getMenu("Mentors", $pid));
$navBar->addFAMenu("pen", "Resources", CareerDev::getMenu("Resources", $pid));
$navBar->addFAMenu("question-circle", "Help", CareerDev::getMenu("Help", $pid));
$str .= $navBar->getHTML();

return $str;
Expand Down Expand Up @@ -549,11 +549,14 @@ public static function getPids() {
} else if (self::isServer("redcaptest.vanderbilt.edu")) {
# TODO Add test projects with plugin
}
return $pids;
} else {
$module = self::getModule();
return $module->getPids();
$pids = $module->getPids();
}
for ($i = 0; $i < count($pids); $i++) {
$pids[$i] = (string) $pids[$i];
}
return $pids;
}

public static function getActiveSourcePids() {
Expand Down
73 changes: 42 additions & 31 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 "5.7.18";
return "5.8.0";
}

public static function getLockFile($pid) {
Expand Down Expand Up @@ -596,32 +596,41 @@ public static function getInstitutionCount() {
return count(self::getInstitutions());
}

public static function getInstitutions($pid = NULL) {
$shortInst = self::getShortInstitution($pid);
$longInst = self::getInstitution($pid);
public static function getInstitutions($pid = NULL, $searchOnly = TRUE) {
if ($searchOnly) {
$shortInst = self::getShortInstitution($pid);
$longInst = self::getInstitution($pid);

$institutions = array();
if (preg_match("/".strtolower($shortInst)."/", strtolower($longInst))) {
$institutions[] = $shortInst;
$institutions[] = $longInst;
} else {
$institutions[] = $longInst;
}
$institutions = array();
if (preg_match("/".strtolower($shortInst)."/", strtolower($longInst))) {
$institutions[] = $shortInst;
$institutions[] = $longInst;
} else {
$institutions[] = $longInst;
}

$otherInsts = preg_split("/\s*[,\/]\s*/", self::getSetting("other_institutions", $pid));
foreach ($otherInsts as $otherInst) {
if ($otherInst && !in_array($otherInst, $institutions)) {
$institutions[] = $otherInst;
}
}
foreach ($institutions as $i => $institution) {
$institutions[$i] = str_replace("&#039;", "'", $institution);
$institutions[$i] = str_replace("&#39;", "'", $institutions[$i]);
$institutions[$i] = str_replace("&amp;", "&", $institutions[$i]);
$institutions[$i] = str_replace("&quot;", "\"", $institutions[$i]);
}
$otherInsts = preg_split("/\s*[,\/]\s*/", self::getSetting("other_institutions", $pid));
foreach ($otherInsts as $otherInst) {
if ($otherInst && !in_array($otherInst, $institutions)) {
$institutions[] = $otherInst;
}
}
foreach ($institutions as $i => $institution) {
$institutions[$i] = str_replace("&#039;", "'", $institution);
$institutions[$i] = str_replace("&#39;", "'", $institutions[$i]);
$institutions[$i] = str_replace("&amp;", "&", $institutions[$i]);
$institutions[$i] = str_replace("&quot;", "\"", $institutions[$i]);
}

return $institutions;
return $institutions;
} else {
$displayInstitutionList = self::getSetting("display_institutions", $pid);
if (!$displayInstitutionList) {
return self::getInstitutions($pid, TRUE);
} else {
return preg_split("/\s*[,;]\s*/", trim($displayInstitutionList));
}
}
}

public static function isEligible($pid) {
Expand Down Expand Up @@ -821,8 +830,10 @@ public static function getSetting($field, $pid = "") {
}
if (file_exists(self::getCredentialsFile())) {
include(self::getCredentialsFile());
if (isset($info['prod'][$field])) {
if (isset($info['prod'][$field]) && ($pid == NEWMAN_SOCIETY_PROJECT)) {
return $info['prod'][$field];
} else if (isset($info['localhost'][$field]) && ($pid == LOCALHOST_TEST_PROJECT)) {
return $info['localhost'][$field];
}
}
if (($field == "admin_email") || ($field == "adminEmail")) {
Expand Down Expand Up @@ -1036,8 +1047,8 @@ public static function has($instrument, $pid = "") {
return FALSE;
}

public static function getMenu($menuName) {
$pid = self::getPid();
public static function getMenu($menuName, $pid = NULL) {
$pid = $pid ?: self::getPid();
$r = self::getREDCapDir();
if ($menuName == "Grants") {
$ary = [
Expand Down Expand Up @@ -1080,7 +1091,7 @@ public static function getMenu($menuName) {
"REDCap Reports" => $r."/DataExport/index.php",
"Missingness Report<br>(Computationally Expensive)" => self::link("/tablesAndLists/missingness.php"),
];
if (self::has("patent") && $switches->isOnForProject("Patents")) {
if (self::has("patent", $pid) && $switches->isOnForProject("Patents")) {
$ary["Patent Viewer"] = self::link("patents/view.php");
}
return $ary;
Expand All @@ -1090,7 +1101,7 @@ public static function getMenu($menuName) {
$server = self::getSetting("server", $pid);
$switches = new FeatureSwitches($token, $server, $pid);
$ary = [];
if (self::has("mentoring_agreement") && $switches->isOnForProject("Mentee-Mentor")) {
if (self::has("mentoring_agreement", $pid) && $switches->isOnForProject("Mentee-Mentor")) {
$ary["Configure Mentee-Mentor Agreements"] = self::link("/mentor/config.php");
$ary["Add Mentors for Existing Scholars"] = self::link("addMentor.php");
$ary["Mentee-Mentor Agreements Dashboard"] = self::link("/mentor/dashboard.php");
Expand Down Expand Up @@ -1133,7 +1144,7 @@ public static function getMenu($menuName) {
"Dates" => self::link("/dashboard/dates.php"),
"Resources" => self::link("/dashboard/resources.php"),
];
if (self::has("mentoring_agreement")) {
if (self::has("mentoring_agreement", $pid)) {
$ary["Mentee-Mentor Agreements"] = self::link("mentor/dashboard.php");
}
return $ary;
Expand Down Expand Up @@ -1226,7 +1237,7 @@ public static function getMenu($menuName) {
$ary["Lexical Translator"] = self::link("/lexicalTranslator.php");
}
$ary["Position Change Wrangler"] = self::link("/wrangler/positions.php");
if (self::has("patent") && $switches->isOnForProject("Patents")) {
if (self::has("patent", $pid) && $switches->isOnForProject("Patents")) {
$ary["Patent Wrangler"] = self::link("/wrangler/include.php")."&wranglerType=Patents";
}
return $ary;
Expand Down
8 changes: 6 additions & 2 deletions FlightTrackerExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,11 @@ function redcap_every_page_before_render($project_id) {
echo "<script src='".CareerDev::link("/js/jquery.min.js")."'></script>\n";
echo "
<script>
$(document).ready(function() { $('.chklist.round:eq(6)').hide(); });
$(document).ready(function() {
$('.chklist.round:eq(6)')
.hide()
.after('<p>By design, Flight Tracker projects should not move to production status because they need to update their Data Dictionaries without manual review. This must be done in development mode. Therefore, moving to production is disabled.</p>')
});
</script>\n";
} else if (PAGE == "DataEntry/index.php") {
echo "<script src='".CareerDev::link("/js/jquery.min.js")."'></script>\n";
Expand Down Expand Up @@ -1156,7 +1160,7 @@ function hasMentorAgreementRights($project_id, $userid)

function makeHeaders($token, $server, $pid, $tokenName) {
$str = "";
$str .= Application::getHeader($tokenName);
$str .= Application::getHeader($tokenName, $token, $server, $pid);
if (!CareerDev::isFAQ() && CareerDev::isHelpOn()) {
$currPage = CareerDev::getCurrPage();
$str .= "<script>$(document).ready(function() { showHelp('".CareerDev::getHelpLink()."', '".$currPage."'); });</script>";
Expand Down
10 changes: 5 additions & 5 deletions add.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
list($lines, $matchedMentorUids, $newMentorNames) = parsePostForLines($_POST);
$newLines = [];
$originalMentorNames = [];
if (!empty($matchedMentorUids)) {
if (!empty($matchedMentorUids) || Application::isLocalhost()) {
$mentorCol = 13;
for ($i = 0; $i < count($lines); $i++) {
if (isset($newMentorNames[$i])) {
Expand All @@ -35,7 +35,7 @@
}
}
$newUids = getUidsForMentors($newLines);
if (!empty($newUids)) {
if (!empty($newUids) || Application::isLocalhost()) {
echo makeAdjudicationTable($lines, $newUids, $matchedMentorUids, $originalMentorNames);
} else {
commitChanges($token, $server, $lines, $matchedMentorUids, $pid, $createRecordsURI);
Expand Down Expand Up @@ -87,7 +87,7 @@
throw new \Exception("This should never happen.");
}
$mentorUids = getUidsForMentors($lines);
if (!empty($mentorUids)) {
if (!empty($mentorUids) || Application::isLocalhost()) {
echo makeAdjudicationTable($lines, $mentorUids, [], []);
$url = APP_PATH_WEBROOT."ProjectGeneral/keep_alive.php?pid=".$pid;
echo "<script>
Expand Down Expand Up @@ -501,7 +501,7 @@ function makeAdjudicationTable($lines, $mentorUids, $existingUids, $originalMent
$html .= "<script>
$(document).ready(() => {
if ($('.mentorKeep').length > 0) {
$('form#mainForm').prepend('<p class=\"centered\"><button onclick=\"checkAllMentors(); return false;\">Check All for Uploading Unmatched Mentors</button></p>');
$('form#mainForm').prepend('<p class=\"centered\"><button class=\"green\" onclick=\"checkAllMentors(); return false;\">Check All for Uploading Unmatched Mentors</button></p>');
}
});
Expand All @@ -527,7 +527,7 @@ function processMentorName($currMentorName, $currMentorUids, $i, $customLine, $c
$hiddenField = "<input type='hidden' name='originalmentorname___$i' value='$escapedMentorName'>";
$mentorKeep = "mentorkeep___$i";
$html .= "<td class='red'>";
$html .= "<strong>No names in REDCap matched with $currMentorName.</strong><br>Keep mentor? <input type='radio' class='mentorKeep' name='$mentorKeep' id='$mentorKeep' value='1'> <label for='$mentorKeep'> Yes, upload anyways</label><br>Or perhaps there is a nickname and/or a maiden name at play here. Do you want to try adjusting their name?<br>$hiddenField<input type='text' name='newmentorname___$i' value='$escapedMentorName'><br>";
$html .= "<strong>No names in REDCap matched with $currMentorName.</strong><br>Keep mentor? <input type='radio' class='mentorKeep' name='$mentorKeep' id='$mentorKeep' value='1' /> <label for='$mentorKeep'> Yes, upload anyways</label><br>Or perhaps there is a nickname and/or a maiden name at play here. Do you want to try adjusting their name?<br>$hiddenField<input type='text' name='newmentorname___$i' value='$escapedMentorName'><br>";
$html .= "<br>Or try a custom id?<br>".$customLine.$customHidden;
$html .= "</td>";
} else if (count($currMentorUids) == 1) {
Expand Down
17 changes: 11 additions & 6 deletions charts/baseWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ function goToUrl(url) {
}
</script>";
}
if (!isset($_GET['hideHeader'])) {

?>
<!DOCTYPE html>
<title>Flight Tracker for Scholars</title>
<?php
if (!isset($_GET['headers']) || ($_GET['headers'] != "false")) {
echo makeHeaders(Application::getModule(), $token, $server, $pid, $tokenName);
} else {
echo Application::getImportHTML();
}
if (!isset($_GET['headers']) || ($_GET['headers'] != "false")) {
echo makeHeaders(Application::getModule(), $token, $server, $pid, $tokenName);
} else {
echo Application::getImportHTML();
}

?>
<?= CareerDev::makeBackgroundCSSLink() ?>
Expand Down Expand Up @@ -155,4 +156,8 @@ function search(page, div, name) {
}
}

</script>
</script>

<?php

}
9 changes: 5 additions & 4 deletions classes/Consortium.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ public static function findNextMeeting($startTime = NULL) {
}

public static function findNextMeetingTs($startTime = NULL, $weekNum = 1) {
$meetTwiceAMonth = FALSE;
if (!$startTime) {
if (date("Y-m") == "2020-02") {
# start twice a month in 2020-03
$startTime = strtotime("2020-03-01");
} else {
# start twice a month in 2020-03
$startTime = strtotime("2020-03-01");
} else if (in_array(date("Y-m"), ["2023-06", "2023-07"]) && ($weekNum == 1)) {
$startTime = strtotime("2023-08-01");
} else {
$startTime = time();
}
}
Expand Down
10 changes: 2 additions & 8 deletions classes/DataDictionaryManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,7 @@ public static function installMetadataFromFiles($files, $token, $server, $pid, $
}
}
if (!empty($metadata['file'])) {
if ($grantClass == "K") {
$mentorLabel = "Primary mentor during your K/K12 training period";
} else if ($grantClass == "T") {
$mentorLabel = "Primary mentor during your pre-doc/post-doc training period";
} else {
$mentorLabel = "Primary mentor (current)";
}
$mentorLabel = "Primary mentor during your training period";
$fieldLabels = [];
foreach ($metadata as $type => $md) {
$fieldLabels[$type] = self::getLabels($md);
Expand Down Expand Up @@ -1067,7 +1061,7 @@ private static function alterOptionalFields(&$metadata, $pid) {

private static function alterInstitutionFields(&$metadata, $pid) {
if ($pid) {
$institutions = Application::getInstitutions();
$institutions = Application::getInstitutions($pid, FALSE);
if (empty($institutions)) {
$institutions = ["Home Institution"];
}
Expand Down
6 changes: 5 additions & 1 deletion classes/NameMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,11 @@ public static function splitName($name, $parts = 2, $loggingOn = FALSE, $clearOf
}
}
}
return array("", "");
$ary = [];
for ($i = 0; $i < $parts; $i++) {
$ary[] = "";
}
return $ary;
}

public static function clearOfHonorifics($nodes) {
Expand Down
Loading

0 comments on commit 732f538

Please sign in to comment.