Skip to content

Commit

Permalink
6.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjpearson committed Apr 1, 2024
1 parent e6d15e5 commit 9e547c5
Show file tree
Hide file tree
Showing 41 changed files with 487 additions and 195 deletions.
18 changes: 9 additions & 9 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,11 @@ public static function isVanderbilt() {
}

public static function getProjectTitle($pid = NULL) {
if ($pid) {
$token = self::getSetting("token", $pid);
$server = self::getSetting("server", $pid);
} else {
$token = self::getSetting("token");
$server = self::getSetting("server");
if (!$pid) {
$pid = Sanitizer::sanitizePid($_GET['pid'] ?? "");
}
if ($token && $server) {
return Download::projectTitle($token, $server);
if ($pid) {
return Download::projectTitle($pid);
}
return "";
}
Expand Down Expand Up @@ -687,14 +683,18 @@ public static function getExporterFields($metadata) {
return REDCapManagement::screenForFields($metadata, CareerDev::$exporterFields);
}

public static function getServerEmail() {
return $_SERVER['SSL_SERVER_S_DN_Email'] ?? "";
}

public static function isMSTP($pid = NULL) {
if (!$pid) {
$pid = CareerDev::getPid();
}
if (Application::isVanderbilt() && ($pid == 149668)) { // TODO For now
return TRUE;
}
if (Application::isLocalhost() && ($pid == 17)) {
if (Application::isLocalhost() && ($pid == 17) && (self::getServerEmail() == "[email protected]")) {
return TRUE;
}
return FALSE;
Expand Down
11 changes: 9 additions & 2 deletions CareerDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@
use Vanderbilt\CareerDevLibrary\Publications;

# test projects
define("LOCALHOST_TEST_PROJECT", 16);
define("LOCALHOST_TEST_PROJECT", CareerDev::getLocalhostPluginPID());
define("NEWMAN_SOCIETY_PROJECT", 66635);
define("REDCAPTEST_TEST_PROJECT", 761);

class CareerDev {
public static $passedModule = NULL;

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

public static function getLocalhostPluginPid() {
if (Application::getServerEmail() == "[email protected]") {
return 16;
}
return "";
}

public static function getLatestReleaseVersion() {
$module = self::getModule();
$sql = "SELECT `value` FROM redcap_config WHERE field_name = ?";
Expand Down
8 changes: 6 additions & 2 deletions FlightTrackerExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public function searchForMissingEmails($allPids) {
if ($adminEmail && REDCapManagement::isEmailOrEmails($adminEmail)) {
$htmlRows = [];
$htmlRows[] = self::makeEmailCopyHTML($items);
$projectTitle = Download::projectTitle($tokens[$emailPid], $servers[$emailPid]);
$projectTitle = Download::projectTitle($emailPid);
$projectTitleHTML = Links::makeProjectHomeLink($emailPid, $projectTitle);
$introHTML = "<p>For $projectTitleHTML, the following Flight Tracker scholars have been matched. An email exists from the below source projects, but it is blank in yours. Do you want to change them? If so, please click the link to copy. <span style='text-decoration: underline; font-weight: bold;'>Note: A scholar might be matched to more than one possible email.</span></p>";
$html = $introHTML . implode("", $htmlRows);
Expand Down Expand Up @@ -660,7 +660,7 @@ private static function makeEmailCopyHTML($items) {
$sourceInfo = $copyInfo['source'];
$email = $copyInfo['email'];
$sourceName = Download::fullName($sourceInfo['token'], $sourceInfo['server'], $sourceInfo['record']);
$sourceProject = Download::projectTitle($sourceInfo['token'], $sourceInfo['server']);
$sourceProject = Download::projectTitle($sourceInfo['pid']);
$adoptLink = Application::link("copyEmail.php", $destInfo['pid'])."&sourcePid=".$sourceInfo['pid']."&sourceRecord=".$sourceInfo['record']."&destRecord=$destRecord";
$notAdoptLink = Application::link("copyEmail.php", $destInfo['pid'])."&skip=".urlencode($email)."&destRecord=$destRecord";
$itemHTML = "<div style='margin-top: 1em;'>Matched to $sourceName from $sourceProject. The proposed email is <strong>$email</strong>.</div>";
Expand Down Expand Up @@ -1681,6 +1681,10 @@ function redcap_every_page_top($project_id) {
if (preg_match("/online_designer\.php/", $url)) {
$_SESSION['metadata'.$project_id] = [];
$_SESSION['lastMetadata'.$project_id] = 0;
} else if (PAGE == "DataEntry/record_status_dashboard.php") {
include(__DIR__."/hooks/recordStatusDashboardHook.php");
} else if (PAGE == "DataEntry/record_home.php") {
include(__DIR__."/hooks/dataFormHook.php");
}
} else {
if ($this->canRedirectToInstall()) {
Expand Down
2 changes: 1 addition & 1 deletion batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function makeJobRowHTML($setting, $headers, $count, &$cachedTitles) {
foreach ($headers as $header) {
if ($header == "Project Name") {
if ($row['token'] && $row['server']) {
$title = $cachedTitles[$row['pid']] ?? Download::projectTitle($row['token'], $row['server']);
$title = $cachedTitles[$row['pid']] ?? Download::projectTitle($row['pid']);
$cachedTitles[$row['pid']] = $title;
$title = str_replace("Flight Tracker - ", "", $title);
$title = str_replace(" - Flight Tracker", "", $title);
Expand Down
29 changes: 26 additions & 3 deletions charts/grantTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,39 @@

$cohorts = new Cohorts($token, $server, Application::getModule());
$thisLink = Application::link("this");
$thisUrl = explode("?", $thisLink)[0];
$thisUrl = URLManagement::getPage($thisLink);
echo "<h1>$title</h1>";
echo "<form method='GET' action='$thisUrl'>";
echo URLManagement::getParametersAsHiddenInputs($thisLink, ['start', 'end', 'cohort']);
echo "<p class='centered'><label for='start'>Budget Start Date (optional):</label> <input type='date' name='start' /><br/>";
echo "<label for='end'>Budget End Date (optional):</label> <input type='date' name='end' /></p>";
echo "<p class='centered'><input type='radio' name='range' id='start' value='start' checked /><label for='start'> Grant start date must be within this range</label> <input type='radio' name='range' id='within' value='within' checked /><label for='within'> Grant start <strong>and</strong> end date must be within this range</label></p>";
echo "<p class='centered'>".$cohorts->makeCohortSelect("", "", TRUE)."</p>";
echo "<p class='centered'><button>Configure</button></p>";
echo "</form>";

exit;
}

$range = Sanitizer::sanitize($_GET['range'] ?? "");
$oneYear = 365 * 24 * 3600;
$startDate = Sanitizer::sanitizeDate($_GET['start']) ?: date("Y-m-d", 0);
$endDate = Sanitizer::sanitizeDate($_GET['end']) ?: date("Y-m-d", time() + 10 * $oneYear);
$startTs = strtotime($startDate);
$endTs = strtotime($endDate);
$dates = "";
$rangeText = "";
if ($_GET['start']) {
if ($_GET['end']) {
$dates = DateManagement::YMD2MDY($startDate)." - ".DateManagement::YMD2MDY($endDate);
} else {
$dates = "After ".DateManagement::YMD2MDY($startDate);
}
if ($range == "within") {
$rangeText = "(Start &amp; End Dates within Range)";
} else {
$rangeText = "(Start Date within Range)";
}
}

if ($_GET['cohort'] !== "all") {
Expand Down Expand Up @@ -95,8 +103,23 @@
$grantAry = $grants->getGrants($grantType);
foreach ($grantAry as $grant) {
$start = $grant->getVariable("start");
$end = $grant->getVariable("end");
$grantTs = $start ? strtotime($start) : FALSE;
if ($grantTs && ($grantTs >= $startTs) && ($grantTs <= $endTs)) {
$grantEndTs = $end ? strtotime($end) : FALSE;
if (
$grantTs
&& ($grantTs >= $startTs)
&& ($grantTs <= $endTs)
&& (
($range == "start")
|| (
($range == "within")
&& $grantEndTs
&& ($grantEndTs >= $startTs)
&& ($grantEndTs <= $endTs)
)
)
) {
$row = [];
$awardNo = $grant->getNumber();
$row[] = $names[$recordId] ?? "";
Expand Down Expand Up @@ -163,7 +186,7 @@
if ($cohort) {
echo "<h2>Cohort $cohort</h2>";
}
echo $dates ? "<p class='centered'>$dates</p>" : "";
echo $dates ? "<p class='centered'>$dates $rangeText</p>" : "";
echo "<p class='centered'><a href='$thisLink&csv'>Download as CSV</a><br/>";
echo "<a href='$thisLink&json=$myToken&NOAUTH'>Access as a JSON (Dynamically Updated)</a></p>";
echo "<p class='centered max-width'>Note: Budget dates are the dates that we have financial data for. Project dates are the prospective dates of the entire project.</p>";
Expand Down
4 changes: 2 additions & 2 deletions classes/CelebrationsEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ private function getThresholds($frequency) {

private function makeGrantData($name, $thresholdTs) {
$dataByName = [];
$currProjectName = Download::projectTitle($this->token, $this->server);
$currProjectName = Download::projectTitle($this->pid);
$currResources = Download::oneFieldWithInstances($this->token, $this->server, "resources_resource");
$currChoices = DataDictionaryManagement::getChoices($this->metadata);
$currDepartments = Download::oneField($this->token, $this->server, "summary_primary_dept");
Expand Down Expand Up @@ -649,7 +649,7 @@ public function getEmailHTML($frequency, $thresholdDate = NULL) {
}
$this->process();
$ftLogoBase64 = FileManagement::getBase64OfFile(__DIR__."/../img/flight_tracker_logo_medium_white_bg.png", "image/png");
$projectInfo = Links::makeProjectHomeLink($this->pid, Download::projectTitle($this->token, $this->server));
$projectInfo = Links::makeProjectHomeLink($this->pid, Download::projectTitle($this->pid));
if (!Application::isVanderbilt() || ($this->pid !== NEWMAN_SOCIETY_PROJECT)) {
$configureLink = Application::link("index.php", $this->pid)."#Celebrations_Email";
$configureInfo = "<br/>".Links::makeLink($configureLink, "Configure Celebrations Email");
Expand Down
14 changes: 7 additions & 7 deletions classes/Crons.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,9 @@ private static function hasDataForPid($queue, $pid) {
return FALSE;
}

private static function getProjectTitle($token, $server) {
private static function getProjectTitle($pid) {
try {
return Download::projectTitle($token, $server);
return Download::projectTitle($pid);
} catch (\Exception $e) {
if (preg_match("/You do not have permissions to use the API/", $e->getMessage())) {
return "[Project Title Unavailable]";
Expand All @@ -874,7 +874,7 @@ private function sendEmailForProjectIfPossible($pid, $module, $additionalEmailTe
$server = $module->getProjectSetting("server", $pid);
if ($token && $server) {
$adminEmail = $module->getProjectSetting("admin_email", $pid);
$projectTitle = self::getProjectTitle($token, $server);
$projectTitle = self::getProjectTitle($pid);

$text = "";
$hasData = FALSE;
Expand Down Expand Up @@ -1090,7 +1090,7 @@ private static function makeEmailMessage($token, $server, $pid, $completedText,
"getIES" => "ies_grant",
"getERIC" => "eric",
];
$projectTitle = self::getProjectTitle($token, $server);
$projectTitle = self::getProjectTitle($pid);

$html = "<style>
p.header { background-color: #d4d4eb; padding: 10px; }
Expand Down Expand Up @@ -1636,8 +1636,8 @@ public function run($adminEmail = "", $tokenName = "", $additionalEmailText = ""
if (count($toRun) > 0) {
$starts = [];
$ends = [];
$projectTitle = self::getProjectTitle($this->token, $this->server);
$allRecords = Download::recordIds($this->token, $this->server);
$projectTitle = self::getProjectTitle($this->pid);
$allRecords = Download::recordIdsByPid($this->pid);
$text = "";
foreach ($run as $method => $aryOfMessages) {
if (REDCapManagement::isAssoc($aryOfMessages)) {
Expand Down Expand Up @@ -1717,7 +1717,7 @@ public function handle($e, $adminEmail, $cronjob) {
$adminEmail .= ",".Application::getFeedbackEmail();
}

$projectTitle = self::getProjectTitle($this->token, $this->server);
$projectTitle = self::getProjectTitle($this->pid);
$mssg = "";
$mssg .= "Cron: ".$cronjob->getTitle()."<br>";
$mssg .= "PID: ".$this->pid."<br>";
Expand Down
Loading

0 comments on commit 9e547c5

Please sign in to comment.