public static function getPigSearchDetails()
 {
     // A successful mysql_connect must be run before mysql_real_escape_string will function.  Instantiating a resource model will set up the connection
     $resource = new Resource();
     $search = Resource::getSearch();
     $whereAdd = array();
     $searchDisplay = array();
     $config = new Configuration();
     //if name is passed in also search alias, organizations and organization aliases
     if (!empty($search['name'])) {
         $nameQueryString = self::escapeStr(strtoupper($search['name']));
         $nameQueryString = "'%" . str_replace(" ", "%", $nameQueryString) . "%'";
         if ($config->settings->organizationsModule == 'Y') {
             //$dbName = $config->settings->organizationsDatabaseName; //unused
             $whereAdd[] = "((UPPER(R.titleText) LIKE " . $nameQueryString . ") OR (UPPER(A.shortName) LIKE " . $nameQueryString . ") OR (UPPER(O.name) LIKE " . $nameQueryString . ") OR (UPPER(OA.name) LIKE " . $nameQueryString . ") OR (UPPER(RP.titleText) LIKE " . $nameQueryString . ") OR (UPPER(RC.titleText) LIKE " . $nameQueryString . ") OR (UPPER(R.recordSetIdentifier) LIKE " . $nameQueryString . "))";
         } else {
             $whereAdd[] = "((UPPER(R.titleText) LIKE " . $nameQueryString . ") OR (UPPER(A.shortName) LIKE " . $nameQueryString . ") OR (UPPER(O.shortName) LIKE " . $nameQueryString . ") OR (UPPER(RP.titleText) LIKE " . $nameQueryString . ") OR (UPPER(RC.titleText) LIKE " . $nameQueryString . ") OR (UPPER(R.recordSetIdentifier) LIKE " . $nameQueryString . "))";
         }
         $searchDisplay[] = "Name contains: " . $search['name'];
     }
     //if descriptionText is passed
     if (!empty($search['descriptionText'])) {
         $descriptionQueryString = self::escapeStr(strtoupper($search['descriptionText']));
         $descriptionQueryString = "'%" . str_replace(" ", "%", $descriptionQueryString) . "%'";
         $whereAdd[] = "(UPPER(R.descriptionText) LIKE " . $descriptionQueryString . ")";
         $searchDisplay[] = "Description contains: " . $search['descriptionText'];
     }
     //if providerText is passed
     if (!empty($search['providerText'])) {
         $providerQueryString = self::escapeStr(strtoupper($search['providerText']));
         $providerQueryString = "'%" . str_replace(" ", "%", $providerQueryString) . "%'";
         $whereAdd[] = "(UPPER(R.providerText) LIKE " . $providerQueryString . ")";
         $searchDisplay[] = "Provider contains: " . $search['providerText'];
     }
     //get where statements together (and escape single quotes)
     if (!empty($search['resourceID'])) {
         $whereAdd[] = "R.resourceID = '" . self::escapeStr($search['resourceID']) . "'";
         $searchDisplay[] = "Resource ID: " . $search['resourceID'];
     }
     if (!empty($search['resourceISBNOrISSN'])) {
         $resourceISBNOrISSN = self::escapeStr(str_replace("-", "", $search['resourceISBNOrISSN']));
         $whereAdd[] = "REPLACE(R.isbnOrISSN,'-','') = '" . $resourceISBNOrISSN . "'";
         $searchDisplay[] = "ISSN/ISBN: " . $search['resourceISBNOrISSN'];
     }
     if (!empty($search['fund'])) {
         $fund = self::escapeStr(str_replace("-", "", $search['fund']));
         $whereAdd[] = "REPLACE(RPAY.fundName,'-','') = '" . $fund . "'";
         $searchDisplay[] = "Fund: " . $search['fund'];
     }
     if (!empty($search['stepName'])) {
         $status = new Status();
         $completedStatusID = $status->getIDFromName('complete');
         $whereAdd[] = "(R.statusID != {$completedStatusID} AND RS.stepName = '" . self::escapeStr($search['stepName']) . "' AND RS.stepStartDate IS NOT NULL AND RS.stepEndDate IS NULL)";
         $searchDisplay[] = "Routing Step: " . $search['stepName'];
     }
     // Return all results except the records with this statusID
     if (!empty($search['statusID'])) {
         $whereAdd[] = "R.statusID <> '" . self::escapeStr($search['statusID']) . "'";
         $status = new Status(new NamedArguments(array('primaryKey' => $search['statusID'])));
         $searchDisplay[] = "Status: " . $status->shortName;
     }
     if (!empty($search['creatorLoginID'])) {
         $whereAdd[] = "R.createLoginID = '" . self::escapeStr($search['creatorLoginID']) . "'";
         $createUser = new User(new NamedArguments(array('primaryKey' => $search['creatorLoginID'])));
         if ($createUser->firstName) {
             $name = $createUser->lastName . ", " . $createUser->firstName;
         } else {
             $name = $createUser->loginID;
         }
         $searchDisplay[] = "Creator: " . $name;
     }
     if (!empty($search['resourceFormatID'])) {
         $whereAdd[] = "R.resourceFormatID = '" . self::escapeStr($search['resourceFormatID']) . "'";
         $resourceFormat = new ResourceFormat(new NamedArguments(array('primaryKey' => $search['resourceFormatID'])));
         $searchDisplay[] = "Resource Format: " . $resourceFormat->shortName;
     }
     if (!empty($search['acquisitionTypeID'])) {
         $whereAdd[] = "R.acquisitionTypeID = '" . self::escapeStr($search['acquisitionTypeID']) . "'";
         $acquisitionType = new AcquisitionType(new NamedArguments(array('primaryKey' => $search['acquisitionTypeID'])));
         $searchDisplay[] = "Acquisition Type: " . $acquisitionType->shortName;
     }
     if (!empty($search['resourceNote'])) {
         $whereAdd[] = "UPPER(RN.noteText) LIKE UPPER('%" . self::escapeStr($search['resourceNote']) . "%')";
         $searchDisplay[] = "Note contains: " . $search['resourceNote'];
     }
     if (!empty($search['createDateStart'])) {
         $whereAdd[] = "R.createDate >= STR_TO_DATE('" . self::escapeStr($search['createDateStart']) . "','%m/%d/%Y')";
         if (!$search['createDateEnd']) {
             $searchDisplay[] = "Created on or after: " . $search['createDateStart'];
         } else {
             $searchDisplay[] = "Created between: " . $search['createDateStart'] . " and " . $search['createDateEnd'];
         }
     }
     if (!empty($search['createDateEnd'])) {
         $whereAdd[] = "R.createDate <= STR_TO_DATE('" . self::escapeStr($search['createDateEnd']) . "','%m/%d/%Y')";
         if (!$search['createDateStart']) {
             $searchDisplay[] = "Created on or before: " . $search['createDateEnd'];
         }
     }
     if (!empty($search['startWith'])) {
         $whereAdd[] = "TRIM(LEADING 'THE ' FROM UPPER(R.titleText)) LIKE UPPER('" . self::escapeStr($search['startWith']) . "%')";
         $searchDisplay[] = "Starts with: " . $search['startWith'];
     }
     //the following are not-required fields with dropdowns and have "none" as an option
     if (!empty($search['resourceTypeID'])) {
         if ($search['resourceTypeID'] == 'none') {
             $whereAdd[] = "((R.resourceTypeID IS NULL) OR (R.resourceTypeID = '0'))";
             $searchDisplay[] = "Resource Type: none";
         } else {
             $whereAdd[] = "R.resourceTypeID = '" . self::escapeStr($search['resourceTypeID']) . "'";
             $resourceType = new ResourceType(new NamedArguments(array('primaryKey' => $search['resourceTypeID'])));
             $searchDisplay[] = "Resource Type: " . $resourceType->shortName;
         }
     }
     if (!empty($search['generalSubjectID'])) {
         if ($search['generalSubjectID'] == 'none') {
             $whereAdd[] = "((GDLINK.generalSubjectID IS NULL) OR (GDLINK.generalSubjectID = '0'))";
             $searchDisplay[] = "Resource Type: none";
         } else {
             $whereAdd[] = "GDLINK.generalSubjectID = '" . self::escapeStr($search['generalSubjectID']) . "'";
             $generalSubject = new GeneralSubject(new NamedArguments(array('primaryKey' => $search['generalSubjectID'])));
             $searchDisplay[] = "General Subject: " . $generalSubject->shortName;
         }
     }
     if (!empty($search['detailedSubjectID'])) {
         if ($search['detailedSubjectID'] == 'none') {
             $whereAdd[] = "((GDLINK.detailedSubjectID IS NULL) OR (GDLINK.detailedSubjectID = '0') OR (GDLINK.detailedSubjectID = '-1'))";
             $searchDisplay[] = "Resource Type: none";
         } else {
             $whereAdd[] = "GDLINK.detailedSubjectID = '" . self::escapeStr($search['detailedSubjectID']) . "'";
             $detailedSubject = new DetailedSubject(new NamedArguments(array('primaryKey' => $search['detailedSubjectID'])));
             $searchDisplay[] = "Detailed Subject: " . $detailedSubject->shortName;
         }
     }
     if (!empty($search['noteTypeID'])) {
         if ($search['noteTypeID'] == 'none') {
             $whereAdd[] = "(RN.noteTypeID IS NULL) AND (RN.noteText IS NOT NULL)";
             $searchDisplay[] = "Note Type: none";
         } else {
             $whereAdd[] = "RN.noteTypeID = '" . self::escapeStr($search['noteTypeID']) . "'";
             $noteType = new NoteType(new NamedArguments(array('primaryKey' => $search['noteTypeID'])));
             $searchDisplay[] = "Note Type: " . $noteType->shortName;
         }
     }
     if (!empty($search['purchaseSiteID'])) {
         if ($search['purchaseSiteID'] == 'none') {
             $whereAdd[] = "RPSL.purchaseSiteID IS NULL";
             $searchDisplay[] = "Purchase Site: none";
         } else {
             $whereAdd[] = "RPSL.purchaseSiteID = '" . self::escapeStr($search['purchaseSiteID']) . "'";
             $purchaseSite = new PurchaseSite(new NamedArguments(array('primaryKey' => $search['purchaseSiteID'])));
             $searchDisplay[] = "Purchase Site: " . $purchaseSite->shortName;
         }
     }
     if (!empty($search['authorizedSiteID'])) {
         if ($search['authorizedSiteID'] == 'none') {
             $whereAdd[] = "RAUSL.authorizedSiteID IS NULL";
             $searchDisplay[] = "Authorized Site: none";
         } else {
             $whereAdd[] = "RAUSL.authorizedSiteID = '" . self::escapeStr($search['authorizedSiteID']) . "'";
             $authorizedSite = new AuthorizedSite(new NamedArguments(array('primaryKey' => $search['authorizedSiteID'])));
             $searchDisplay[] = "Authorized Site: " . $authorizedSite->shortName;
         }
     }
     if (!empty($search['administeringSiteID'])) {
         if ($search['administeringSiteID'] == 'none') {
             $whereAdd[] = "RADSL.administeringSiteID IS NULL";
             $searchDisplay[] = "Administering Site: none";
         } else {
             $whereAdd[] = "RADSL.administeringSiteID = '" . self::escapeStr($search['administeringSiteID']) . "'";
             $administeringSite = new AdministeringSite(new NamedArguments(array('primaryKey' => $search['administeringSiteID'])));
             $searchDisplay[] = "Administering Site: " . $administeringSite->shortName;
         }
     }
     if (!empty($search['authenticationTypeID'])) {
         if ($search['authenticationTypeID'] == 'none') {
             $whereAdd[] = "R.authenticationTypeID IS NULL";
             $searchDisplay[] = "Authentication Type: none";
         } else {
             $whereAdd[] = "R.authenticationTypeID = '" . self::escapeStr($search['authenticationTypeID']) . "'";
             $authenticationType = new AuthenticationType(new NamedArguments(array('primaryKey' => $search['authenticationTypeID'])));
             $searchDisplay[] = "Authentication Type: " . $authenticationType->shortName;
         }
     }
     if (!empty($search['catalogingStatusID'])) {
         if ($search['catalogingStatusID'] == 'none') {
             $whereAdd[] = "(R.catalogingStatusID IS NULL)";
             $searchDisplay[] = "Cataloging Status: none";
         } else {
             $whereAdd[] = "R.catalogingStatusID = '" . self::escapeStr($search['catalogingStatusID']) . "'";
             $catalogingStatus = new CatalogingStatus(new NamedArguments(array('primaryKey' => $search['catalogingStatusID'])));
             $searchDisplay[] = "Cataloging Status: " . $catalogingStatus->shortName;
         }
     }
     $orderBy = $search['orderBy'];
     $page = $search['page'];
     $recordsPerPage = $search['recordsPerPage'];
     return array("where" => $whereAdd, "page" => $page, "order" => $orderBy, "perPage" => $recordsPerPage, "display" => $searchDisplay);
 }
Esempio n. 2
0
** You should have received a copy of the GNU General Public License along with CORAL.  If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************************************************************
*/
session_start();
include_once 'directory.php';
//print header
$pageTitle = 'Home';
include 'templates/header.php';
//used for creating a "sticky form" for back buttons
//except we don't want it to retain if they press the 'index' button
//check what referring script is
if ($_SESSION['ref_script'] != "resource.php") {
    Resource::resetSearch();
}
$search = Resource::getSearch();
$_SESSION['ref_script'] = $currentPage;
?>

<div style='text-align:left;'>
<table class="headerTable" style="background-image:url('images/header.gif');background-repeat:no-repeat;">
<tr style='vertical-align:top;'>
<td style="width:155px;padding-right:10px;">
  <form method="get" action="ajax_htmldata.php?action=getSearchResources" id="resourceSearchForm">
    <?php 
foreach (array('orderBy', 'page', 'recordsPerPage', 'startWith') as $hidden) {
    echo Html::hidden_search_field_tag($hidden, $search[$hidden]);
}
?>
    
	<table class='noBorder'>