00001 <?php
00002
00016
00017
00018
00019 import('subscription.Subscription');
00020 import('subscription.SubscriptionType');
00021
00022 define('SUBSCRIPTION_DATE_START', 0x01);
00023 define('SUBSCRIPTION_DATE_END', 0x02);
00024 define('SUBSCRIPTION_DATE_BOTH', 0x03);
00025
00026 define('SUBSCRIPTION_USER', 0x01);
00027 define('SUBSCRIPTION_MEMBERSHIP', 0x02);
00028 define('SUBSCRIPTION_DOMAIN', 0x03);
00029 define('SUBSCRIPTION_IP_RANGE', 0x04);
00030
00031 class SubscriptionDAO extends DAO {
00037 function &getSubscription($subscriptionId) {
00038 $result = &$this->retrieve(
00039 'SELECT * FROM subscriptions WHERE subscription_id = ?', $subscriptionId
00040 );
00041
00042 $returner = null;
00043 if ($result->RecordCount() != 0) {
00044 $returner = &$this->_returnSubscriptionFromRow($result->GetRowAssoc(false));
00045 }
00046
00047 $result->Close();
00048 unset($result);
00049
00050 return $returner;
00051 }
00052
00058 function getSubscriptionJournalId($subscriptionId) {
00059 $result = &$this->retrieve(
00060 'SELECT journal_id FROM subscriptions WHERE subscription_id = ?', $subscriptionId
00061 );
00062
00063 $returner = isset($result->fields[0]) ? $result->fields[0] : false;
00064
00065 $result->Close();
00066 unset($result);
00067
00068 return $returner;
00069 }
00070
00077 function getSubscriptionIdByUser($userId, $journalId) {
00078 $result = &$this->retrieve(
00079 'SELECT subscription_id
00080 FROM subscriptions
00081 WHERE user_id = ?
00082 AND journal_id = ?',
00083 array(
00084 $userId,
00085 $journalId
00086 )
00087 );
00088
00089 $returner = isset($result->fields[0]) ? $result->fields[0] : false;
00090
00091 $result->Close();
00092 unset($result);
00093
00094 return $returner;
00095 }
00096
00103 function subscriptionExistsByUser($userId, $journalId) {
00104 $result = &$this->retrieve(
00105 'SELECT COUNT(*)
00106 FROM subscriptions
00107 WHERE user_id = ?
00108 AND journal_id = ?',
00109 array(
00110 $userId,
00111 $journalId
00112 )
00113 );
00114
00115 $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
00116
00117 $result->Close();
00118 unset($result);
00119
00120 return $returner;
00121 }
00122
00128 function &_returnSubscriptionFromRow(&$row) {
00129 $subscription = &new Subscription();
00130 $subscription->setSubscriptionId($row['subscription_id']);
00131 $subscription->setJournalId($row['journal_id']);
00132 $subscription->setUserId($row['user_id']);
00133 $subscription->setTypeId($row['type_id']);
00134 $subscription->setDateStart($this->dateFromDB($row['date_start']));
00135 $subscription->setDateEnd($this->dateFromDB($row['date_end']));
00136 $subscription->setMembership($row['membership']);
00137 $subscription->setDomain($row['domain']);
00138 $subscription->setIPRange($row['ip_range']);
00139
00140 HookRegistry::call('SubscriptionDAO::_returnSubscriptionFromRow', array(&$subscription, &$row));
00141
00142 return $subscription;
00143 }
00144
00149 function _generateUserNameSearchSQL($search, $searchMatch, $prefix, &$params) {
00150 $first_last = $this->_dataSource->Concat($prefix.'first_name', '\' \'', $prefix.'last_name');
00151 $first_middle_last = $this->_dataSource->Concat($prefix.'first_name', '\' \'', $prefix.'middle_name', '\' \'', $prefix.'last_name');
00152 $last_comma_first = $this->_dataSource->Concat($prefix.'last_name', '\', \'', $prefix.'first_name');
00153 $last_comma_first_middle = $this->_dataSource->Concat($prefix.'last_name', '\', \'', $prefix.'first_name', '\' \'', $prefix.'middle_name');
00154 if ($searchMatch === 'is') {
00155 $searchSql = " AND (LOWER({$prefix}last_name) = LOWER(?) OR LOWER($first_last) = LOWER(?) OR LOWER($first_middle_last) = LOWER(?) OR LOWER($last_comma_first) = LOWER(?) OR LOWER($last_comma_first_middle) = LOWER(?))";
00156 } else {
00157 $searchSql = " AND (LOWER({$prefix}last_name) LIKE LOWER(?) OR LOWER($first_last) LIKE LOWER(?) OR LOWER($first_middle_last) LIKE LOWER(?) OR LOWER($last_comma_first) LIKE LOWER(?) OR LOWER($last_comma_first_middle) LIKE LOWER(?))";
00158 $search = '%' . $search . '%';
00159 }
00160 $params[] = $params[] = $params[] = $params[] = $params[] = $search;
00161 return $searchSql;
00162 }
00163
00169 function insertSubscription(&$subscription) {
00170 $returner = $this->update(
00171 sprintf('INSERT INTO subscriptions
00172 (journal_id, user_id, type_id, date_start, date_end, membership, domain, ip_range)
00173 VALUES
00174 (?, ?, ?, %s, %s, ?, ?, ?)',
00175 $this->dateToDB($subscription->getDateStart()), $this->dateToDB($subscription->getDateEnd())),
00176 array(
00177 $subscription->getJournalId(),
00178 $subscription->getUserId(),
00179 $subscription->getTypeId(),
00180 $subscription->getMembership(),
00181 $subscription->getDomain(),
00182 $subscription->getIPRange()
00183 )
00184 );
00185
00186 $subscriptionId = $this->getInsertSubscriptionId();
00187 $subscription->setSubscriptionId($subscriptionId);
00188
00189 if ($returner) {
00190 $this->insertSubscriptionIPRange($subscriptionId, $subscription->getIPRange());
00191 }
00192
00193 return $subscriptionId;
00194 }
00195
00201 function updateSubscription(&$subscription) {
00202 $subscriptionId = $subscription->getSubscriptionId();
00203
00204 $returner = $this->update(
00205 sprintf('UPDATE subscriptions
00206 SET
00207 journal_id = ?,
00208 user_id = ?,
00209 type_id = ?,
00210 date_start = %s,
00211 date_end = %s,
00212 membership = ?,
00213 domain = ?,
00214 ip_range = ?
00215 WHERE subscription_id = ?',
00216 $this->dateToDB($subscription->getDateStart()), $this->dateToDB($subscription->getDateEnd())),
00217 array(
00218 $subscription->getJournalId(),
00219 $subscription->getUserId(),
00220 $subscription->getTypeId(),
00221 $subscription->getMembership(),
00222 $subscription->getDomain(),
00223 $subscription->getIPRange(),
00224 $subscriptionId
00225 )
00226 );
00227
00228 if ($returner) {
00229 $this->deleteSubscriptionIPRangeBySubscriptionId($subscriptionId);
00230 $this->insertSubscriptionIPRange($subscriptionId, $subscription->getIPRange());
00231 }
00232
00233 return $returner;
00234 }
00235
00242 function renewSubscription(&$subscription){
00243 $subscriptionTypeDAO =& DAORegistry::getDAO('SubscriptionTypeDAO');
00244 $subscriptionType =& $subscriptionTypeDAO->getSubscriptionType($subscription->getTypeId());
00245
00246 $duration = $subscriptionType->getDuration();
00247 $dateEnd = strtotime($subscription->getDateEnd());
00248
00249
00250 $time = time();
00251 if ($dateEnd < $time ) $dateEnd = $time;
00252
00253 $subscription->setDateEnd($this->dateToDB(mktime(0, 0, 0, date("m", $dateEnd)+$duration, date("d", $dateEnd), date("Y", $dateEnd))));
00254 $this->updateSubscription($subscription);
00255 }
00256
00262 function deleteSubscriptionById($subscriptionId) {
00263 $this->deleteSubscriptionIPRangeBySubscriptionId($subscriptionId);
00264
00265 return $this->update(
00266 'DELETE FROM subscriptions WHERE subscription_id = ?', $subscriptionId
00267 );
00268 }
00269
00275 function deleteSubscriptionsByJournal($journalId) {
00276 $result = &$this->retrieve(
00277 'SELECT subscription_id
00278 FROM subscriptions
00279 WHERE journal_id = ?',
00280 $journalId
00281 );
00282
00283 if ($result->RecordCount() != 0) {
00284 while (!$result->EOF) {
00285 $subscriptionId = $result->fields[0];
00286 $this->deleteSubscriptionIPRangeBySubscriptionId($subscriptionId);
00287 $result->moveNext();
00288 }
00289 }
00290
00291 $result->Close();
00292 unset($result);
00293
00294 return $this->update(
00295 'DELETE FROM subscriptions WHERE journal_id = ?', $journalId
00296 );
00297 }
00298
00304 function deleteSubscriptionsByUserId($userId) {
00305 $result = &$this->retrieve(
00306 'SELECT subscription_id
00307 FROM subscriptions
00308 WHERE user_id = ?',
00309 $userId
00310 );
00311
00312 if ($result->RecordCount() != 0) {
00313 while (!$result->EOF) {
00314 $subscriptionId = $result->fields[0];
00315 $this->deleteSubscriptionIPRangeBySubscriptionId($subscriptionId);
00316 $result->moveNext();
00317 }
00318 }
00319
00320 $result->Close();
00321 unset($result);
00322
00323 return $this->update(
00324 'DELETE FROM subscriptions WHERE user_id = ?', $userId
00325 );
00326 }
00327
00333 function deleteSubscriptionByTypeId($subscriptionTypeId) {
00334 $result = &$this->retrieve(
00335 'SELECT subscription_id
00336 FROM subscriptions
00337 WHERE type_id = ?',
00338 $subscriptionTypeId
00339 );
00340
00341 if ($result->RecordCount() != 0) {
00342 while (!$result->EOF) {
00343 $subscriptionId = $result->fields[0];
00344 $this->deleteSubscriptionIPRangeBySubscriptionId($subscriptionId);
00345 $result->moveNext();
00346 }
00347 }
00348
00349 $result->Close();
00350 unset($result);
00351
00352 return $this->update(
00353 'DELETE FROM subscriptions WHERE type_id = ?', $subscriptionTypeId
00354 );
00355 }
00356
00361 function &getSubscriptions($rangeInfo = null) {
00362 $result = &$this->retrieveRange(
00363 'SELECT s.* FROM subscriptions s, users u WHERE s.user_id = u.user_id ORDER BY u.last_name ASC, s.subscription_id', false, $rangeInfo
00364 );
00365
00366 $returner = &new DAOResultFactory($result, $this, '_returnSubscriptionFromRow');
00367
00368 return $returner;
00369 }
00370
00382 function &getSubscriptionsByJournalId($journalId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null) {
00383
00384 $params = array($journalId);
00385 $searchSql = '';
00386
00387 if (!empty($search)) switch ($searchField) {
00388 case SUBSCRIPTION_USER:
00389 $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'u.', $params);
00390 break;
00391 case SUBSCRIPTION_MEMBERSHIP:
00392 if ($searchMatch === 'is') {
00393 $searchSql = ' AND LOWER(s.membership) = LOWER(?)';
00394 } else {
00395 $searchSql = ' AND LOWER(s.membership) LIKE LOWER(?)';
00396 $search = '%' . $search . '%';
00397 }
00398 $params[] = $search;
00399 break;
00400 case SUBSCRIPTION_DOMAIN:
00401 if ($searchMatch === 'is') {
00402 $searchSql = ' AND LOWER(s.domain) = LOWER(?)';
00403 } else {
00404 $searchSql = ' AND LOWER(s.domain) LIKE LOWER(?)';
00405 $search = '%' . $search . '%';
00406 }
00407 $params[] = $search;
00408 break;
00409 case SUBSCRIPTION_IP_RANGE:
00410 if ($searchMatch === 'is') {
00411 $searchSql = ' AND LOWER(s.ip_range) = LOWER(?)';
00412 } else {
00413 $searchSql = ' AND LOWER(s.ip_range) LIKE LOWER(?)';
00414 $search = '%' . $search . '%';
00415 }
00416 $params[] = $search;
00417 break;
00418 }
00419
00420 if (!empty($dateFrom) || !empty($dateTo)) switch($dateField) {
00421 case SUBSCRIPTION_DATE_START:
00422 if (!empty($dateFrom)) {
00423 $searchSql .= ' AND s.date_start >= ' . $this->datetimeToDB($dateFrom);
00424 }
00425 if (!empty($dateTo)) {
00426 $searchSql .= ' AND s.date_start <= ' . $this->datetimeToDB($dateTo);
00427 }
00428 break;
00429 case SUBSCRIPTION_DATE_END:
00430 if (!empty($dateFrom)) {
00431 $searchSql .= ' AND s.date_end >= ' . $this->datetimeToDB($dateFrom);
00432 }
00433 if (!empty($dateTo)) {
00434 $searchSql .= ' AND s.date_end <= ' . $this->datetimeToDB($dateTo);
00435 }
00436 break;
00437 }
00438
00439 $sql = 'SELECT s.*
00440 FROM
00441 subscriptions s,
00442 users u
00443 WHERE s.user_id = u.user_id
00444 AND journal_id = ?';
00445
00446 $result = &$this->retrieveRange(
00447 $sql . ' ' . $searchSql . ' ORDER BY u.last_name ASC, s.subscription_id',
00448 count($params)===1?array_shift($params):$params,
00449 $rangeInfo
00450 );
00451
00452 $returner = &new DAOResultFactory($result, $this, '_returnSubscriptionFromRow');
00453
00454 return $returner;
00455 }
00456
00463 function &getSubscriptionsByDateEnd($dateEnd, $journalId, $rangeInfo = null) {
00464 $dateEnd = explode('-', $dateEnd);
00465
00466 $result = &$this->retrieveRange(
00467 'SELECT s.*
00468 FROM subscriptions s,
00469 users u
00470 WHERE u.user_id = s.user_id AND
00471 EXTRACT(YEAR FROM date_end) = ? AND
00472 EXTRACT(MONTH FROM date_end) = ? AND
00473 EXTRACT(DAY FROM date_end) = ? AND
00474 journal_id = ?
00475 ORDER BY u.last_name ASC, s.subscription_id',
00476 array(
00477 $dateEnd[0],
00478 $dateEnd[1],
00479 $dateEnd[2],
00480 $journalId
00481 ), $rangeInfo
00482 );
00483
00484 $returner = &new DAOResultFactory($result, $this, '_returnSubscriptionFromRow');
00485
00486 return $returner;
00487 }
00488
00495 function insertSubscriptionIPRange($subscriptionId, $IP) {
00496 if (empty($IP)) {
00497 return true;
00498 }
00499
00500 if (empty($subscriptionId)) {
00501 return false;
00502 }
00503
00504
00505 $ipRanges = explode(SUBSCRIPTION_IP_RANGE_SEPERATOR, $IP);
00506
00507 $returner = true;
00508
00509 while (list(, $curIPString) = each($ipRanges)) {
00510 $ipStart = null;
00511 $ipEnd = null;
00512
00513
00514 if (strpos($curIPString, SUBSCRIPTION_IP_RANGE_RANGE) === false) {
00515
00516
00517 if (strpos($curIPString, SUBSCRIPTION_IP_RANGE_WILDCARD) === false) {
00518
00519
00520 if (strpos($curIPString, '/') === false) {
00521 $ipStart = sprintf("%u", ip2long(trim($curIPString)));
00522
00523
00524 } else {
00525 list($curIPString, $cidrBits) = explode('/', trim($curIPString));
00526
00527 if ($cidrBits == 0) {
00528 $cidrMask = 0;
00529 } else {
00530 $cidrMask = (0xffffffff << (32 - $cidrBits));
00531 }
00532
00533 $ipStart = sprintf('%u', ip2long($curIPString) & $cidrMask);
00534
00535 if ($cidrBits != 32) {
00536 $ipEnd = sprintf('%u', ip2long($curIPString) | (~$cidrMask & 0xffffffff));
00537 }
00538 }
00539
00540
00541 } else {
00542 $ipStart = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '0', trim($curIPString))));
00543 $ipEnd = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '255', trim($curIPString))));
00544 }
00545
00546
00547 } else {
00548 list($ipStart, $ipEnd) = explode(SUBSCRIPTION_IP_RANGE_RANGE, $curIPString);
00549
00550
00551 $ipStart = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '0', trim($ipStart))));
00552 $ipEnd = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '255', trim($ipEnd))));
00553 }
00554
00555
00556 if (($ipStart != null) && ($returner)) {
00557 $returner = $this->update(
00558 sprintf('INSERT INTO subscription_ip
00559 (subscription_id, ip_start, ip_end)
00560 VALUES
00561 (?, ?, ?)'),
00562 array(
00563 $subscriptionId,
00564 $ipStart,
00565 $ipEnd
00566 )
00567 );
00568 } else {
00569 $returner = false;
00570 break;
00571 }
00572
00573 }
00574
00575 return $returner;
00576 }
00577
00583 function deleteSubscriptionIPRangeBySubscriptionId($subscriptionId) {
00584 return $this->update(
00585 'DELETE FROM subscription_ip WHERE subscription_id = ?', $subscriptionId
00586 );
00587 }
00588
00599 function isValidSubscription($domain, $IP, $userId, $journalId, $check = SUBSCRIPTION_DATE_BOTH, $checkDate = null) {
00600 $valid = false;
00601
00602 if ($userId != null) {
00603 $valid = $this->isValidSubscriptionByUser($userId, $journalId, $check, $checkDate);
00604 if ($valid !== false) { return $valid; }
00605 }
00606
00607 if ($domain != null) {
00608 $valid = $this->isValidSubscriptionByDomain($domain, $journalId, $check, $checkDate);
00609 if ($valid !== false) { return $valid; }
00610 }
00611
00612 if ($IP != null) {
00613 $valid = $this->isValidSubscriptionByIP($IP, $journalId, $check, $checkDate);
00614 if ($valid !== false) { return $valid; }
00615 }
00616
00617 return false;
00618 }
00619
00628 function isValidSubscriptionByUser($userId, $journalId, $check = SUBSCRIPTION_DATE_BOTH, $checkDate = null) {
00629 $today = $this->dateToDB(Core::getCurrentDate());
00630
00631 if ($checkDate == null) {
00632 $checkDate = $today;
00633 } else {
00634 $checkDate = $this->dateToDB($checkDate);
00635 }
00636
00637 switch($check) {
00638 case SUBSCRIPTION_DATE_START:
00639 $sqlDate = sprintf('AND %s >= date_start AND %s >= date_start', $checkDate, $today);
00640 break;
00641 case SUBSCRIPTION_DATE_END:
00642 $sqlDate = sprintf('AND %s <= date_end AND %s >= date_start', $checkDate, $today);
00643 break;
00644 default:
00645 $sqlDate = sprintf('AND %s >= date_start AND %s <= date_end', $checkDate, $checkDate);
00646 }
00647
00648 $result = &$this->retrieve(
00649 sprintf('SELECT subscription_id
00650 FROM subscriptions, subscription_types
00651 WHERE subscriptions.user_id = ?
00652 AND subscriptions.journal_id = ? '
00653 . $sqlDate .
00654 ' AND subscriptions.type_id = subscription_types.type_id
00655 AND (subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE .' OR subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . ')'),
00656 array(
00657 $userId,
00658 $journalId
00659 ));
00660
00661 if ($result->RecordCount() != 0) {
00662 $returner = $result->fields[0];
00663 } else {
00664 $returner = false;
00665 }
00666
00667 $result->Close();
00668 unset($result);
00669
00670 return $returner;
00671 }
00672
00681 function isValidSubscriptionByDomain($domain, $journalId, $check = SUBSCRIPTION_DATE_BOTH, $checkDate = null) {
00682 $today = $this->dateToDB(Core::getCurrentDate());
00683
00684 if ($checkDate == null) {
00685 $checkDate = $today;
00686 } else {
00687 $checkDate = $this->dateToDB($checkDate);
00688 }
00689
00690 switch($check) {
00691 case SUBSCRIPTION_DATE_START:
00692 $sqlDate = sprintf('AND %s >= date_start AND %s >= date_start', $checkDate, $today);
00693 break;
00694 case SUBSCRIPTION_DATE_END:
00695 $sqlDate = sprintf('AND %s <= date_end AND %s >= date_start', $checkDate, $today);
00696 break;
00697 default:
00698 $sqlDate = sprintf('AND %s >= date_start AND %s <= date_end', $checkDate, $checkDate);
00699 }
00700
00701 $result = &$this->retrieve(
00702 sprintf('SELECT subscription_id
00703 FROM subscriptions, subscription_types
00704 WHERE POSITION(UPPER(LPAD(domain, LENGTH(domain)+1, \'.\')) IN UPPER(LPAD(?, LENGTH(?)+1, \'.\'))) != 0
00705 AND domain != \'\'
00706 AND subscriptions.journal_id = ? '
00707 . $sqlDate .
00708 ' AND subscriptions.type_id = subscription_types.type_id
00709 AND subscription_types.institutional = 1
00710 AND (subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE .' OR subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . ')'),
00711 array(
00712 $domain,
00713 $domain,
00714 $journalId
00715 ));
00716
00717 if ($result->RecordCount() != 0) {
00718 $returner = $result->fields[0];
00719 } else {
00720 $returner = false;
00721 }
00722
00723 $result->Close();
00724 unset($result);
00725
00726 return $returner;
00727 }
00728
00737 function isValidSubscriptionByIP($IP, $journalId, $check = SUBSCRIPTION_DATE_BOTH, $checkDate = null) {
00738 if (empty($IP) || empty($journalId)) {
00739 return false;
00740 }
00741
00742 $IP = sprintf('%u', ip2long($IP));
00743 $today = $this->dateToDB(Core::getCurrentDate());
00744
00745 if ($checkDate == null) {
00746 $checkDate = $today;
00747 } else {
00748 $checkDate = $this->dateToDB($checkDate);
00749 }
00750
00751 switch($check) {
00752 case SUBSCRIPTION_DATE_START:
00753 $sqlDate = sprintf('AND %s >= date_start AND %s >= date_start', $checkDate, $today);
00754 break;
00755 case SUBSCRIPTION_DATE_END:
00756 $sqlDate = sprintf('AND %s <= date_end AND %s >= date_start', $checkDate, $today);
00757 break;
00758 default:
00759 $sqlDate = sprintf('AND %s >= date_start AND %s <= date_end', $checkDate, $checkDate);
00760 }
00761
00762 $result = &$this->retrieve(
00763 sprintf('SELECT subscription_ip.subscription_id
00764 FROM subscription_ip, subscriptions, subscription_types
00765 WHERE ((ip_end IS NOT NULL
00766 AND ? >= ip_start AND ? <= ip_end
00767 AND subscription_ip.subscription_id = subscriptions.subscription_id
00768 AND subscriptions.journal_id = ? '
00769 . $sqlDate .
00770 ' AND subscriptions.type_id = subscription_types.type_id
00771 AND subscription_types.institutional = 1
00772 AND (subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE .' OR subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . '))
00773 OR (ip_end IS NULL
00774 AND ? = ip_start
00775 AND subscription_ip.subscription_id = subscriptions.subscription_id
00776 AND subscriptions.journal_id = ? '
00777 . $sqlDate .
00778 ' AND subscriptions.type_id = subscription_types.type_id
00779 AND subscription_types.institutional = 1
00780 AND (subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE .' OR subscription_types.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . ')))'),
00781 array (
00782 $IP,
00783 $IP,
00784 $journalId,
00785 $IP,
00786 $journalId
00787 ));
00788
00789 if ($result->RecordCount() != 0) {
00790 $returner = $result->fields[0];
00791 } else {
00792 $returner = false;
00793 }
00794
00795 $result->Close();
00796 unset($result);
00797
00798 return $returner;
00799 }
00800
00805 function getInsertSubscriptionId() {
00806 return $this->getInsertId('subscriptions', 'subscription_id');
00807 }
00808 }
00809
00810 ?>