Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPoppe committed Dec 14, 2021
1 parent a88d577 commit 9ab3ee1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions REDCapPRO.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class REDCapPRO extends AbstractExternalModule
"green" => "#009000",
"ban" => "tomato"
];
static $MODULE_TOKEN;

static $LOGO_URL = "https://i.imgur.com/5Xq2Vqt.png";
static $LOGO_ALTERNATE_URL = "https://i.imgur.com/fu0t8V1.png";
Expand All @@ -54,7 +53,6 @@ function __construct()
self::$PARTICIPANT = new ParticipantHelper($this);
self::$PROJECT = new ProjectHelper($this, self::$PARTICIPANT);
self::$DAG = new DAG($this);
self::$MODULE_TOKEN = $this->getModuleToken();
}


Expand Down Expand Up @@ -342,7 +340,7 @@ function redcap_module_system_change_version($version, $old_version)
// 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.5";
$critical_version = "0.4.6";
if (
version_compare($new_version_number, $critical_version, ">=") &&
version_compare($old_version_number, $critical_version, "<")
Expand Down Expand Up @@ -739,7 +737,7 @@ public function logError(string $message, \Exception $e)
"error_line" => $e->getLine(),
"error_string" => $e->__toString(),
"redcap_user" => USERID,
"module_token" => self::$MODULE_TOKEN
"module_token" => $this->getModuleToken()
];
if (isset($e->rcpro)) {
$params = array_merge($params, $e->rcpro);
Expand All @@ -765,7 +763,7 @@ public function logForm(string $message, $parameters)
$this->logEvent($message, [
"parameters" => $logParametersString,
"redcap_user" => USERID,
"module_token" => self::$MODULE_TOKEN
"module_token" => $this->getModuleToken()
]);
}

Expand All @@ -779,7 +777,7 @@ public function logForm(string $message, $parameters)
*/
public function logEvent(string $message, $parameters)
{
$parameters["module_token"] = self::$MODULE_TOKEN;
$parameters["module_token"] = $this->getModuleToken();
return $this->log($message, $parameters);
}

Expand Down Expand Up @@ -824,7 +822,7 @@ private function updateLogsWithToken()
$logs = $this->queryLogs("SELECT log_id WHERE module_token IS NULL");
while ($row = $logs->fetch_assoc()) {
$SQL = "INSERT INTO redcap_external_modules_log_parameters (log_id, name, value) VALUES (?, ?, ?)";
$this->query($SQL, [$row["log_id"], "module_token", self::$MODULE_TOKEN]);
$this->query($SQL, [$row["log_id"], "module_token", $this->getModuleToken()]);
}
}

Expand All @@ -841,7 +839,7 @@ public function selectLogs(string $selectStatement, array $params, bool $use_que
{
$verb = stripos($selectStatement, " where ") === false ? " WHERE" : " AND";
$selectStatementValidated = $selectStatement . $verb . " module_token = ?";
array_push($params, self::$MODULE_TOKEN);
array_push($params, $this->getModuleToken());
if ($use_querylogs) {
return $this->queryLogs($selectStatementValidated, $params);
} else {
Expand All @@ -853,7 +851,7 @@ public function countLogsValidated(string $whereClause, array $params)
{
$verb = (empty($whereClause) || trim($whereClause) === "") ? "" : " AND";
$whereClauseValidated = $whereClause . $verb . " module_token = ?";
array_push($params, self::$MODULE_TOKEN);
array_push($params, $this->getModuleToken());
return $this->countLogs($whereClauseValidated, $params);
}

Expand Down

0 comments on commit 9ab3ee1

Please sign in to comment.