/** * Retrieve individual subscriptions matching a particular journal ID. * @param $journalId int * @param $status int * @param $searchField int * @param $searchMatch string "is" or "contains" or "startsWith" * @param $search String to look in $searchField for * @param $dateField int * @param $dateFrom String date to search from * @param $dateTo String date to search to * @return object DAOResultFactory containing matching IndividualSubscriptions */ function &getSubscriptionsByJournalId($journalId, $status = null, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null) { $params = array($journalId); $searchSql = parent::_generateSearchSQL($status, $searchField, $searchMatch, $search, $dateField, $dateFrom, $dateTo, $params); $sql = 'SELECT s.* FROM subscriptions s, subscription_types st, users u WHERE s.type_id = st.type_id AND st.institutional = 0 AND s.user_id = u.user_id AND s.journal_id = ?'; $result =& $this->retrieveRange($sql . ' ' . $searchSql . ' ORDER BY u.last_name ASC, s.subscription_id', count($params) === 1 ? array_shift($params) : $params, $rangeInfo); $returner = new DAOResultFactory($result, $this, '_returnSubscriptionFromRow'); return $returner; }
/** * Internal function to return an InstitutionalSubscription object from a row. * @param $row array * @return InstitutionalSubscription */ function _fromRow($row) { $institutionalSubscription = parent::_fromRow($row); $institutionalSubscription->setInstitutionName($row['institution_name']); $institutionalSubscription->setInstitutionMailingAddress($row['mailing_address']); $institutionalSubscription->setDomain($row['domain']); $ipResult = $this->retrieve('SELECT ip_string FROM institutional_subscription_ip WHERE subscription_id = ? ORDER BY institutional_subscription_ip_id ASC', $institutionalSubscription->getId()); $ipRanges = array(); while (!$ipResult->EOF) { $ipRow = $ipResult->GetRowAssoc(false); $ipRanges[] = $ipRow['ip_string']; $ipResult->MoveNext(); } $institutionalSubscription->setIPRanges($ipRanges); $ipResult->Close(); HookRegistry::call('InstitutionalSubscriptionDAO::_fromRow', array(&$institutionalSubscription, &$row)); return $institutionalSubscription; }