Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 433: Fix some resource searches #434

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public static function getSearchDetails() {


if ($search['resourceNote']) {
$whereAdd[] = "UPPER(RN.noteText) LIKE UPPER('%" . $resource->db->escapeString($search['resourceNote']) . "%')";
$whereAdd[] = "(UPPER(RNA.noteText) LIKE UPPER('%" . $resource->db->escapeString($search['resourceNote']) . "%') AND RNA.tabName <> 'Product') OR (UPPER(RNR.noteText) LIKE UPPER('%" . $resource->db->escapeString($search['resourceNote']) . "%') AND RNR.tabName = 'Product')";
$searchDisplay[] = _("Note contains: ") . $search['resourceNote'];
}

Expand Down Expand Up @@ -659,10 +659,10 @@ public static function getSearchDetails() {
}

if ($search['noteTypeID'] == 'none') {
$whereAdd[] = "(RN.noteTypeID IS NULL) AND (RN.noteText IS NOT NULL)";
$whereAdd[] = "(RNA.noteTypeID IS NULL) AND (RNA.noteText IS NOT NULL) AND (RNR.noteTypeID IS NULL) AND (RNR.noteText IS NOT NULL)";
$searchDisplay[] = _("Note Type: none");
}else if ($search['noteTypeID']) {
$whereAdd[] = "RN.noteTypeID = '" . $resource->db->escapeString($search['noteTypeID']) . "'";
$whereAdd[] = "(RNA.noteTypeID = '" . $resource->db->escapeString($search['noteTypeID']) . "' AND RNA.tabName <> 'Product') OR (RNR.noteTypeID = '" . $resource->db->escapeString($search['noteTypeID']) . "' AND RNR.tabName = 'Product')";
$noteType = new NoteType(new NamedArguments(array('primaryKey' => $search['noteTypeID'])));
$searchDisplay[] = _("Note Type: ") . $noteType->shortName;
}
Expand Down Expand Up @@ -699,19 +699,19 @@ public static function getSearchDetails() {


if ($search['authenticationTypeID'] == 'none') {
$whereAdd[] = "R.authenticationTypeID IS NULL";
$whereAdd[] = "RA.authenticationTypeID IS NULL";
$searchDisplay[] = _("Authentication Type: none");
}else if ($search['authenticationTypeID']) {
$whereAdd[] = "R.authenticationTypeID = '" . $resource->db->escapeString($search['authenticationTypeID']) . "'";
$whereAdd[] = "RA.authenticationTypeID = '" . $resource->db->escapeString($search['authenticationTypeID']) . "'";
$authenticationType = new AuthenticationType(new NamedArguments(array('primaryKey' => $search['authenticationTypeID'])));
$searchDisplay[] = _("Authentication Type: ") . $authenticationType->shortName;
}

if ($search['catalogingStatusID'] == 'none') {
$whereAdd[] = "(R.catalogingStatusID IS NULL)";
$whereAdd[] = "(RA.catalogingStatusID IS NULL)";
$searchDisplay[] = _("Cataloging Status: none");
} else if ($search['catalogingStatusID']) {
$whereAdd[] = "R.catalogingStatusID = '" . $resource->db->escapeString($search['catalogingStatusID']) . "'";
$whereAdd[] = "RA.catalogingStatusID = '" . $resource->db->escapeString($search['catalogingStatusID']) . "'";
$catalogingStatus = new CatalogingStatus(new NamedArguments(array('primaryKey' => $search['catalogingStatusID'])));
$searchDisplay[] = _("Cataloging Status: ") . $catalogingStatus->shortName;
}
Expand Down Expand Up @@ -815,12 +815,13 @@ public function searchQuery($whereAdd, $orderBy = '', $limit = '', $count = fals
LEFT JOIN AcquisitionType AT ON RA.acquisitionTypeID = AT.acquisitionTypeID
LEFT JOIN Status S ON R.statusID = S.statusID
LEFT JOIN User CU ON R.createLoginID = CU.loginID
LEFT JOIN ResourcePurchaseSiteLink RPSL ON R.resourceID = RPSL.resourceID
LEFT JOIN ResourceAuthorizedSiteLink RAUSL ON R.resourceID = RAUSL.resourceID
LEFT JOIN ResourceAdministeringSiteLink RADSL ON R.resourceID = RADSL.resourceID
LEFT JOIN ResourcePayment RPAY ON R.resourceID = RPAY.resourceID
LEFT JOIN ResourceNote RN ON R.resourceID = RN.resourceID
LEFT JOIN ResourceStep RS ON R.resourceID = RS.resourceID
LEFT JOIN ResourcePurchaseSiteLink RPSL ON RA.resourceAcquisitionID = RPSL.resourceAcquisitionID
LEFT JOIN ResourceAuthorizedSiteLink RAUSL ON RA.resourceAcquisitionID = RAUSL.resourceAcquisitionID
LEFT JOIN ResourceAdministeringSiteLink RADSL ON RA.resourceAcquisitionID = RADSL.resourceAcquisitionID
LEFT JOIN ResourceNote RNA ON RA.resourceAcquisitionID = RNA.entityID
LEFT JOIN ResourceNote RNR ON R.resourceID = RNR.entityID
LEFT JOIN ResourcePayment RPAY ON RA.resourceAcquisitionID = RPAY.resourceAcquisitionID
LEFT JOIN ResourceStep RS ON RA.resourceAcquisitionID = RS.resourceAcquisitionID
LEFT JOIN IsbnOrIssn I ON R.resourceID = I.resourceID
");

Expand All @@ -837,7 +838,6 @@ public function searchQuery($whereAdd, $orderBy = '', $limit = '', $count = fals
$additional_joins[] = $join;
}
}

$query = $select . "
FROM Resource R
LEFT JOIN ResourceAcquisition RA ON R.resourceID = RA.resourceID
Expand Down