Skip to content

Commit

Permalink
fix: disable any OPACUserCSS from koha (self-reg)
Browse files Browse the repository at this point in the history
If a library has previously used the koha opac before switching to Aspen and have CSS customisations, these can interfere with some of the page scraping in Aspen and cause things to malfunction

This patch adds the optional flag to remove any css customisations on page load to the urls used in the web scraping process for self-reg
  • Loading branch information
Jacobomara901 committed Jun 4, 2024
1 parent 9ef7594 commit 0945a1c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/web/Drivers/Koha.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function updatePatronInfo($patron, $canUpdateContactInfo, $fromMasquerade = fals
$loginResult = $this->loginToKohaOpac($patron);
if ($loginResult['success']) {

$updatePage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl');
$updatePage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1');
//Get the csr token
$csr_token = '';
if (preg_match('%<input type="hidden" name="csrf_token" value="(.*?)" />%s', $updatePage, $matches)) {
Expand Down Expand Up @@ -367,7 +367,7 @@ function updatePatronInfo($patron, $canUpdateContactInfo, $fromMasquerade = fals
$postVariables['resendEmail'] = strip_tags($_REQUEST['resendEmail']);
}

$postResults = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl', $postVariables);
$postResults = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1', $postVariables);

$messageInformation = [];
if (preg_match('%<div class="alert alert-danger">(.*?)</div>%s', $postResults, $messageInformation)) {
Expand Down Expand Up @@ -4476,7 +4476,7 @@ function selfRegister(): array {

if ($this->getKohaVersion() < 20.05) {
$catalogUrl = $this->accountProfile->vendorOpacUrl;
$selfRegPage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl');
$selfRegPage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1');
$captcha = '';
$captchaDigest = '';
$captchaInfo = [];
Expand Down Expand Up @@ -4540,7 +4540,7 @@ function selfRegister(): array {
$postFields['action'] = 'create';
$headers = ['Content-Type: application/x-www-form-urlencoded'];
$this->opacCurlWrapper->addCustomHeaders($headers, false);
$selfRegPageResponse = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl', $postFields);
$selfRegPageResponse = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1', $postFields);

$matches = [];
if (preg_match('%<h1>Registration Complete!</h1>.*?<span id="patron-userid">(.*?)</span>.*?<span id="patron-password">(.*?)</span>.*?<span id="patron-cardnumber">(.*?)</span>%s', $selfRegPageResponse, $matches)) {
Expand Down

0 comments on commit 0945a1c

Please sign in to comment.