Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
InstitutionalSubscriptionDAO.inc.php
1 <?php
2 
17 import('classes.subscription.SubscriptionDAO');
18 import('classes.subscription.InstitutionalSubscription');
19 
20 define('SUBSCRIPTION_INSTITUTION_NAME', 0x20);
21 define('SUBSCRIPTION_DOMAIN', 0x21);
22 define('SUBSCRIPTION_IP_RANGE', 0x22);
23 
30  function getSubscription($subscriptionId) {
31  $result = $this->retrieve(
32  'SELECT s.*, iss.*
33  FROM
34  subscriptions s,
35  subscription_types st,
36  institutional_subscriptions iss
37  WHERE s.type_id = st.type_id
38  AND st.institutional = 1
39  AND s.subscription_id = iss.subscription_id
40  AND s.subscription_id = ?',
41  $subscriptionId
42  );
43 
44  $returner = null;
45  if ($result->RecordCount() != 0) {
46  $returner = $this->_fromRow($result->GetRowAssoc(false));
47  }
48 
49  $result->Close();
50  return $returner;
51  }
52 
58  function getSubscriptionsByUser($userId, $rangeInfo = null) {
59  $result = $this->retrieveRange(
60  'SELECT s.*, iss.*
61  FROM
62  subscriptions s,
63  subscription_types st,
64  institutional_subscriptions iss
65  WHERE s.type_id = st.type_id
66  AND st.institutional = 1
67  AND s.subscription_id = iss.subscription_id
68  AND s.user_id = ?',
69  $userId,
70  $rangeInfo
71  );
72 
73  return new DAOResultFactory($result, $this, '_fromRow');
74  }
75 
82  function getSubscriptionsByUserForJournal($userId, $journalId, $rangeInfo = null) {
83  $result = $this->retrieveRange(
84  'SELECT s.*, iss.*
85  FROM
86  subscriptions s,
87  subscription_types st,
88  institutional_subscriptions iss
89  WHERE s.type_id = st.type_id
90  AND st.institutional = 1
91  AND s.subscription_id = iss.subscription_id
92  AND s.user_id = ?
93  AND s.journal_id = ?',
94  array(
95  $userId,
96  $journalId
97  ),
98  $rangeInfo
99  );
100 
101  return new DAOResultFactory($result, $this, '_fromRow');
102  }
103 
111  function getSubscriptionsByInstitutionName($institutionName, $journalId, $exactMatch = true, $rangeInfo = null) {
112  $sql = 'SELECT s.*, iss.*
113  FROM
114  subscriptions s,
115  subscription_types st,
116  institutional_subscriptions iss
117  WHERE s.type_id = st.type_id
118  AND st.institutional = 1
119  AND s.subscription_id = iss.subscription_id' .
120  $exactMatch ? ' AND LOWER(iss.institution_name) = LOWER(?)'
121  : ' AND LOWER(iss.institution_name) LIKE LOWER(?)'
122  . ' AND s.journal_id = ?';
123 
124  $result = $this->retrieveRange(
125  $sql,
126  array(
127  $institutionName,
128  $journalId
129  ),
130  $rangeInfo
131  );
132 
133  return new DAOResultFactory($result, $this, '_fromRow');
134  }
135 
141  function getStatusCount($journalId, $status = null) {
142  $params = array((int) $journalId);
143  if ($status !== null) $params[] = (int) $status;
144 
145  $result = $this->retrieve(
146  'SELECT COUNT(*)
147  FROM subscriptions s,
148  subscription_types st
149  WHERE s.type_id = st.type_id AND
150  st.institutional = 1 AND
151  s.journal_id = ?
152  ' . ($status !== null?' AND s.status = ?':''),
153  $params
154  );
155 
156  $returner = isset($result->fields[0]) ? $result->fields[0] : 0;
157 
158  $result->Close();
159  return $returner;
160  }
161 
167  function getSubscribedUserCount($journalId) {
168  return $this->getStatusCount($journalId);
169  }
170 
176  function subscriptionExists($subscriptionId) {
177  $result = $this->retrieve(
178  'SELECT COUNT(*)
179  FROM
180  subscriptions s,
181  subscription_types st
182  WHERE s.type_id = st.type_id
183  AND st.institutional = 1
184  AND s.subscription_id = ?',
185  $subscriptionId
186  );
187 
188  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
189 
190  $result->Close();
191  return $returner;
192  }
193 
200  function subscriptionExistsByUser($subscriptionId, $userId){
201  $result = $this->retrieve(
202  'SELECT COUNT(*)
203  FROM
204  subscriptions s,
205  subscription_types st
206  WHERE s.type_id = st.type_id
207  AND st.institutional = 1
208  AND s.subscription_id = ?
209  AND s.user_id = ?',
210  array(
211  $subscriptionId,
212  $userId
213  )
214  );
215 
216  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
217 
218  $result->Close();
219  return $returner;
220  }
221 
228  function subscriptionExistsByUserForJournal($userId, $journalId) {
229  $result = $this->retrieve(
230  'SELECT COUNT(*)
231  FROM
232  subscriptions s,
233  subscription_types st
234  WHERE s.type_id = st.type_id
235  AND st.institutional = 1
236  AND s.user_id = ?
237  AND s.journal_id = ?',
238  array(
239  $userId,
240  $journalId
241  )
242  );
243 
244  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
245 
246  $result->Close();
247  return $returner;
248  }
249 
257  function subscriptionExistsByInstitutionName($institutionName, $journalId, $exactMatch = true) {
258  $sql = 'SELECT COUNT(*)
259  FROM
260  subscriptions s,
261  subscription_types st,
262  institutional_subscriptions iss
263  WHERE s.type_id = st.type_id
264  AND st.institutional = 1' .
265  $exactMatch ? ' AND LOWER(iss.institution_name) = LOWER(?)'
266  : ' AND LOWER(iss.institution_name) LIKE LOWER(?)'
267  . ' AND s.journal_id = ?';
268 
269  $result = $this->retrieve(
270  $sql,
271  array(
272  $institutionName,
273  $journalId
274  )
275  );
276 
277  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
278 
279  $result->Close();
280  return $returner;
281  }
282 
288  function insertSubscription($institutionalSubscription) {
289  $subscriptionId = null;
290  if ($this->_insertSubscription($institutionalSubscription)) {
291  $subscriptionId = $institutionalSubscription->getId();
292 
293  $this->update(
294  'INSERT INTO institutional_subscriptions
295  (subscription_id, institution_name, mailing_address, domain)
296  VALUES
297  (?, ?, ?, ?)',
298  array(
299  $subscriptionId,
300  $institutionalSubscription->getInstitutionName(),
301  $institutionalSubscription->getInstitutionMailingAddress(),
302  $institutionalSubscription->getDomain()
303  )
304  );
305 
306  $this->_insertSubscriptionIPRanges($subscriptionId, $institutionalSubscription->getIPRanges());
307  }
308 
309  return $subscriptionId;
310  }
311 
317  function updateSubscription($institutionalSubscription) {
318  $returner = false;
319  if ($this->_updateSubscription($institutionalSubscription)) {
320 
321  $returner = $this->update(
322  'UPDATE institutional_subscriptions
323  SET
324  institution_name = ?,
325  mailing_address = ?,
326  domain = ?
327  WHERE subscription_id = ?',
328  array(
329  $institutionalSubscription->getInstitutionName(),
330  $institutionalSubscription->getInstitutionMailingAddress(),
331  $institutionalSubscription->getDomain(),
332  $institutionalSubscription->getId()
333  )
334  );
335 
336  $this->_deleteSubscriptionIPRanges($institutionalSubscription->getId());
337  $this->_insertSubscriptionIPRanges($institutionalSubscription->getId(), $institutionalSubscription->getIPRanges());
338  }
339 
340  return $returner;
341  }
342 
347  function deleteSubscriptionById($subscriptionId) {
348  if ($this->subscriptionExists($subscriptionId)) {
349  $this->update(
350  'DELETE
351  FROM
352  subscriptions
353  WHERE subscription_id = ?',
354  (int) $subscriptionId
355  );
356 
357  $this->update(
358  'DELETE
359  FROM
360  institutional_subscriptions
361  WHERE subscription_id = ?',
362  (int) $subscriptionId
363  );
364 
365  $this->_deleteSubscriptionIPRanges($subscriptionId);
366  }
367  }
368 
374  function deleteSubscriptionsByJournal($journalId) {
375  $result = $this->retrieve(
376  'SELECT s.subscription_id
377  FROM
378  subscriptions s
379  WHERE s.journal_id = ?',
380  $journalId
381  );
382 
383  $returner = true;
384  if ($result->RecordCount() != 0) {
385  while (!$result->EOF) {
386  $subscriptionId = $result->fields[0];
387  $this->deleteSubscriptionById($subscriptionId);
388  $result->MoveNext();
389  }
390  }
391 
392  $result->Close();
393  return $returner;
394  }
395 
401  function deleteSubscriptionsByUserId($userId) {
402  $result = $this->retrieve(
403  'SELECT s.subscription_id
404  FROM
405  subscriptions s
406  WHERE s.user_id = ?',
407  $userId
408  );
409 
410  $returner = true;
411  if ($result->RecordCount() != 0) {
412  while (!$result->EOF) {
413  $subscriptionId = $result->fields[0];
414  $this->deleteSubscriptionById($subscriptionId);
415  $result->MoveNext();
416  }
417  }
418 
419  $result->Close();
420  return $returner;
421  }
422 
429  function deleteSubscriptionsByUserIdForJournal($userId, $journalId) {
430  $result = $this->retrieve(
431  'SELECT s.subscription_id
432  FROM
433  subscriptions s
434  WHERE s.user_id = ?
435  AND s.journal_id = ?',
436  array (
437  $userId,
438  $journalId
439  )
440  );
441 
442  $returner = true;
443  if ($result->RecordCount() != 0) {
444  while (!$result->EOF) {
445  $subscriptionId = $result->fields[0];
446  $this->deleteSubscriptionById($subscriptionId);
447  $result->MoveNext();
448  }
449  }
450 
451  $result->Close();
452  return $returner;
453  }
454 
460  function deleteSubscriptionsByTypeId($subscriptionTypeId) {
461  $result = $this->retrieve(
462  'SELECT s.subscription_id
463  FROM
464  subscriptions s
465  WHERE s.type_id = ?',
466  $subscriptionTypeId
467  );
468 
469  $returner = true;
470  if ($result->RecordCount() != 0) {
471  while (!$result->EOF) {
472  $subscriptionId = $result->fields[0];
473  $this->deleteSubscriptionById($subscriptionId);
474  $result->MoveNext();
475  }
476  }
477 
478  $result->Close();
479  return $returner;
480  }
481 
486  function getSubscriptions($rangeInfo = null) {
487  $result = $this->retrieveRange(
488  'SELECT s.*, iss.*
489  FROM
490  subscriptions s,
491  subscription_types st,
492  institutional_subscriptions iss
493  WHERE s.type_id = st.type_id
494  AND st.institutional = 1
495  AND s.subscription_id = iss.subscription_id
496  ORDER BY
497  iss.institution_name ASC,
498  s.subscription_id',
499  false,
500  $rangeInfo
501  );
502 
503  return new DAOResultFactory($result, $this, '_fromRow');
504  }
505 
510  function getSubscribedUsers($journalId, $rangeInfo = null) {
511  $result = $this->retrieveRange(
512  'SELECT u.*
513  FROM subscriptions s,
514  subscription_types st,
515  users u
516  WHERE s.type_id = st.type_id AND
517  st.institutional = 1 AND
518  s.user_id = u.user_id AND
519  s.journal_id = ?
520  ORDER BY u.last_name ASC, s.subscription_id',
521  array((int) $journalId),
522  $rangeInfo
523  );
524 
525  $userDao = DAORegistry::getDAO('UserDAO');
526  return new DAOResultFactory($result, $userDao, '_returnUserFromRow');
527  }
528 
541  function getSubscriptionsByJournalId($journalId, $status = null, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null) {
542 
543  $params = array($journalId);
544  $ipRangeSql1 = $ipRangeSql2 = '';
545  $searchSql = $this->_generateSearchSQL($status, $searchField, $searchMatch, $search, $dateField, $dateFrom, $dateTo, $params);
546 
547  if (!empty($search)) switch ($searchField) {
548  case SUBSCRIPTION_INSTITUTION_NAME:
549  if ($searchMatch === 'is') {
550  $searchSql = ' AND LOWER(iss.institution_name) = LOWER(?)';
551  } elseif ($searchMatch === 'contains') {
552  $searchSql = ' AND LOWER(iss.institution_name) LIKE LOWER(?)';
553  $search = '%' . $search . '%';
554  } else { // $searchMatch === 'startsWith'
555  $searchSql = ' AND LOWER(iss.institution_name) LIKE LOWER(?)';
556  $search = $search . '%';
557  }
558  $params[] = $search;
559  break;
560  case SUBSCRIPTION_DOMAIN:
561  if ($searchMatch === 'is') {
562  $searchSql = ' AND LOWER(iss.domain) = LOWER(?)';
563  } elseif ($searchMatch === 'contains') {
564  $searchSql = ' AND LOWER(iss.domain) LIKE LOWER(?)';
565  $search = '%' . $search . '%';
566  } else { // $searchMatch === 'startsWith'
567  $searchSql = ' AND LOWER(iss.domain) LIKE LOWER(?)';
568  $search = $search . '%';
569  }
570  $params[] = $search;
571  break;
572  case SUBSCRIPTION_IP_RANGE:
573  if ($searchMatch === 'is') {
574  $searchSql = ' AND LOWER(isip.ip_string) = LOWER(?)';
575  } elseif ($searchMatch === 'contains') {
576  $searchSql = ' AND LOWER(isip.ip_string) LIKE LOWER(?)';
577  $search = '%' . $search . '%';
578  } else { // $searchMatch === 'startsWith'
579  $searchSql = ' AND LOWER(isip.ip_string) LIKE LOWER(?)';
580  $search = $search . '%';
581  }
582  $params[] = $search;
583  $ipRangeSql1 = ', institutional_subscription_ip isip' ;
584  $ipRangeSql2 = ' AND s.subscription_id = isip.subscription_id';
585  break;
586  }
587 
588  $sql = 'SELECT DISTINCT
589  s.*, iss.*
590  FROM
591  subscriptions s,
592  subscription_types st,
593  users u,
594  institutional_subscriptions iss'
595  . $ipRangeSql1 .
596  ' WHERE s.type_id = st.type_id
597  AND s.user_id = u.user_id
598  AND st.institutional = 1
599  AND s.subscription_id = iss.subscription_id'
600  . $ipRangeSql2 .
601  ' AND s.journal_id = ?';
602 
603  $result = $this->retrieveRange(
604  $sql . ' ' . $searchSql . ' ORDER BY iss.institution_name ASC, s.subscription_id',
605  count($params)===1?array_shift($params):$params,
606  $rangeInfo
607  );
608 
609  return new DAOResultFactory($result, $this, '_fromRow');
610  }
611 
621  function isValidInstitutionalSubscription($domain, $IP, $journalId, $check = SUBSCRIPTION_DATE_BOTH, $checkDate = null) {
622  if (empty($journalId) || (empty($domain) && empty($IP))) {
623  return false;
624  }
625  $returner = false;
626 
627  $today = $this->dateToDB(Core::getCurrentDate());
628 
629  if ($checkDate == null) {
630  $checkDate = $today;
631  } else {
632  $checkDate = $this->dateToDB($checkDate);
633  }
634 
635  switch($check) {
636  case SUBSCRIPTION_DATE_START:
637  $dateSql = sprintf('%s >= s.date_start AND %s >= s.date_start', $checkDate, $today);
638  break;
639  case SUBSCRIPTION_DATE_END:
640  $dateSql = sprintf('%s <= s.date_end AND %s >= s.date_start', $checkDate, $today);
641  break;
642  default:
643  $dateSql = sprintf('%s >= s.date_start AND %s <= s.date_end', $checkDate, $checkDate);
644  }
645 
646  $nonExpiringSql = "AND ((st.non_expiring = 1) OR (st.non_expiring = 0 AND ($dateSql)))";
647 
648  // Check if domain match
649  if (!empty($domain)) {
650  $result = $this->retrieve('
651  SELECT iss.subscription_id
652  FROM
653  institutional_subscriptions iss,
654  subscriptions s,
655  subscription_types st
656  WHERE POSITION(UPPER(LPAD(iss.domain, LENGTH(iss.domain)+1, \'.\')) IN UPPER(LPAD(?, LENGTH(?)+1, \'.\'))) != 0
657  AND iss.domain != \'\'
658  AND iss.subscription_id = s.subscription_id
659  AND s.journal_id = ?
660  AND s.status = ' . SUBSCRIPTION_STATUS_ACTIVE . '
661  AND s.type_id = st.type_id
662  AND st.institutional = 1 '
663  . $nonExpiringSql .
664  ' AND (st.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE . '
665  OR st.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . ')',
666  array(
667  $domain,
668  $domain,
669  $journalId
670  )
671  );
672 
673  if ($result->RecordCount() != 0) {
674  $returner = $result->fields[0];
675  }
676 
677  $result->Close();
678 
679  if ($returner) {
680  return $returner;
681  }
682  }
683 
684  // Check for IP match
685  if (!empty($IP)) {
686  $IP = sprintf('%u', ip2long($IP));
687 
688  $result = $this->retrieve('
689  SELECT isip.subscription_id
690  FROM
691  institutional_subscription_ip isip,
692  subscriptions s,
693  subscription_types st
694  WHERE ((isip.ip_end IS NOT NULL
695  AND ? >= isip.ip_start AND ? <= isip.ip_end
696  AND isip.subscription_id = s.subscription_id
697  AND s.journal_id = ?
698  AND s.status = ' . SUBSCRIPTION_STATUS_ACTIVE . '
699  AND s.type_id = st.type_id
700  AND st.institutional = 1 '
701  . $nonExpiringSql .
702  ' AND (st.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE . '
703  OR st.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . '))
704  OR (isip.ip_end IS NULL
705  AND ? = isip.ip_start
706  AND isip.subscription_id = s.subscription_id
707  AND s.journal_id = ?
708  AND s.status = ' . SUBSCRIPTION_STATUS_ACTIVE . '
709  AND s.type_id = st.type_id
710  AND st.institutional = 1 '
711  . $nonExpiringSql .
712  ' AND (st.format = ' . SUBSCRIPTION_TYPE_FORMAT_ONLINE . '
713  OR st.format = ' . SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE . ')))',
714  array (
715  $IP,
716  $IP,
717  $journalId,
718  $IP,
719  $journalId
720  )
721  );
722 
723  if ($result->RecordCount() != 0) {
724  $returner = $result->fields[0];
725  }
726 
727  $result->Close();
728  }
729 
730  return $returner;
731  }
732 
739  function getSubscriptionsByDateEnd($dateEnd, $journalId, $rangeInfo = null) {
740  $dateEnd = explode('-', $dateEnd);
741 
742  $result = $this->retrieveRange(
743  'SELECT s.*, iss.*
744  FROM
745  subscriptions s,
746  subscription_types st,
747  institutional_subscriptions iss
748  WHERE s.type_id = st.type_id
749  AND s.status = ' . SUBSCRIPTION_STATUS_ACTIVE . ' ' .
750  'AND st.institutional = 1
751  AND s.subscription_id = iss.subscription_id AND
752  EXTRACT(YEAR FROM s.date_end) = ? AND
753  EXTRACT(MONTH FROM s.date_end) = ? AND
754  EXTRACT(DAY FROM s.date_end) = ? AND
755  s.journal_id = ?
756  ORDER BY iss.institution_name ASC, s.subscription_id',
757  array(
758  $dateEnd[0],
759  $dateEnd[1],
760  $dateEnd[2],
761  $journalId
762  ), $rangeInfo
763  );
764 
765  return new DAOResultFactory($result, $this, '_fromRow');
766  }
767 
774  function renewSubscription($institutionalSubscription) {
775  return $this->_renewSubscription($institutionalSubscription);
776  }
777 
782  function newDataObject() {
783  return new InstitutionalSubscription();
784  }
785 
791  function _fromRow($row) {
792  $institutionalSubscription = parent::_fromRow($row);
793 
794  $institutionalSubscription->setInstitutionName($row['institution_name']);
795  $institutionalSubscription->setInstitutionMailingAddress($row['mailing_address']);
796  $institutionalSubscription->setDomain($row['domain']);
797 
798  $ipResult = $this->retrieve(
799  'SELECT ip_string
800  FROM
801  institutional_subscription_ip
802  WHERE subscription_id = ?
803  ORDER BY institutional_subscription_ip_id ASC',
804  $institutionalSubscription->getId()
805  );
806 
807  $ipRanges = array();
808  while (!$ipResult->EOF) {
809  $ipRow = $ipResult->GetRowAssoc(false);
810  $ipRanges[] = $ipRow['ip_string'];
811  $ipResult->MoveNext();
812  }
813 
814  $institutionalSubscription->setIPRanges($ipRanges);
815  $ipResult->Close();
816 
817  HookRegistry::call('InstitutionalSubscriptionDAO::_fromRow', array(&$institutionalSubscription, &$row));
818 
819  return $institutionalSubscription;
820  }
821 
828  function _insertSubscriptionIPRanges($subscriptionId, $ipRanges) {
829  if (empty($ipRanges)) {
830  return true;
831  }
832 
833  if (empty($subscriptionId)) {
834  return false;
835  }
836 
837  $returner = true;
838 
839  while (list(, $curIPString) = each($ipRanges)) {
840  $ipStart = null;
841  $ipEnd = null;
842 
843  // Parse and check single IP string
844  if (strpos($curIPString, SUBSCRIPTION_IP_RANGE_RANGE) === false) {
845 
846  // Check for wildcards in IP
847  if (strpos($curIPString, SUBSCRIPTION_IP_RANGE_WILDCARD) === false) {
848 
849  // Get non-CIDR IP
850  if (strpos($curIPString, '/') === false) {
851  $ipStart = sprintf("%u", ip2long(trim($curIPString)));
852 
853  // Convert CIDR IP to IP range
854  } else {
855  list($cidrIPString, $cidrBits) = explode('/', trim($curIPString));
856 
857  if ($cidrBits == 0) {
858  $cidrMask = 0;
859  } else {
860  $cidrMask = (0xffffffff << (32 - $cidrBits));
861  }
862 
863  $ipStart = sprintf('%u', ip2long($cidrIPString) & $cidrMask);
864 
865  if ($cidrBits != 32) {
866  $ipEnd = sprintf('%u', ip2long($cidrIPString) | (~$cidrMask & 0xffffffff));
867  }
868  }
869 
870  // Convert wildcard IP to IP range
871  } else {
872  $ipStart = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '0', trim($curIPString))));
873  $ipEnd = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '255', trim($curIPString))));
874  }
875 
876  // Convert wildcard IP range to IP range
877  } else {
878  list($ipStart, $ipEnd) = explode(SUBSCRIPTION_IP_RANGE_RANGE, $curIPString);
879 
880  // Replace wildcards in start and end of range
881  $ipStart = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '0', trim($ipStart))));
882  $ipEnd = sprintf('%u', ip2long(str_replace(SUBSCRIPTION_IP_RANGE_WILDCARD, '255', trim($ipEnd))));
883  }
884 
885  // Insert IP or IP range
886  if (($ipStart != null) && ($returner)) {
887  $returner = $this->update(
888  'INSERT INTO institutional_subscription_ip
889  (subscription_id, ip_string, ip_start, ip_end)
890  VALUES
891  (?, ?, ?, ?)',
892  array(
893  $subscriptionId,
894  $curIPString,
895  $ipStart,
896  $ipEnd
897  )
898  );
899  } else {
900  $returner = false;
901  break;
902  }
903 
904  }
905 
906  return $returner;
907  }
908 
914  function _deleteSubscriptionIPRanges($subscriptionId) {
915  return $this->update(
916  'DELETE FROM institutional_subscription_ip WHERE subscription_id = ?', $subscriptionId
917  );
918  }
919 }
920 
921 ?>
getSubscribedUsers($journalId, $rangeInfo=null)
static & getDAO($name, $dbconn=null)
getSubscriptionsByDateEnd($dateEnd, $journalId, $rangeInfo=null)
getSubscriptionsByUser($userId, $rangeInfo=null)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
Basic class describing an institutional subscription.
dateToDB($d)
Definition: DAO.inc.php:303
Abstract class for retrieving and modifying subscriptions.
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:174
getSubscriptionsByUserForJournal($userId, $journalId, $rangeInfo=null)
static call($hookName, $args=null)
subscriptionExistsByInstitutionName($institutionName, $journalId, $exactMatch=true)
_renewSubscription($subscription)
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
_insertSubscription($subscription)
_updateSubscription($subscription)
_insertSubscriptionIPRanges($subscriptionId, $ipRanges)
Operations for retrieving and modifying InstitutionalSubscription objects.
insertSubscription($institutionalSubscription)
isValidInstitutionalSubscription($domain, $IP, $journalId, $check=SUBSCRIPTION_DATE_BOTH, $checkDate=null)
_generateSearchSQL($status=null, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, &$params)
subscriptionExistsByUser($subscriptionId, $userId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208
getSubscriptionsByJournalId($journalId, $status=null, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $rangeInfo=null)
getSubscriptionsByInstitutionName($institutionName, $journalId, $exactMatch=true, $rangeInfo=null)
updateSubscription($institutionalSubscription)
static getCurrentDate($ts=null)
Definition: Core.inc.php:95