Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
TimedViewReportDAO.inc.php
1 <?php
2 
16 class TimedViewReportDAO extends DAO {
24  function getAbstractViewCount($journalId, $startDate = null, $endDate = null) {
25  if ($startDate && $endDate) {
26  $result = $this->retrieve(
27  sprintf('SELECT tvl.submission_id, COUNT(tvl.submission_id) AS total_abstract_views
28  FROM timed_views_log tvl
29  WHERE tvl.galley_id IS NULL
30  AND tvl.journal_id = ?
31  AND tvl.date >= %s
32  AND tvl.date <= %s
33  GROUP BY submission_id',
34  $this->datetimeToDB($startDate),
35  $this->datetimeToDB($endDate)),
36  array((int) $journalId)
37  );
38  } else {
39  $result = $this->retrieve(
40  'SELECT tvl.submission_id, COUNT(tvl.submission_id) AS total_abstract_views
41  FROM timed_views_log tvl
42  WHERE tvl.galley_id IS NULL
43  AND tvl.journal_id = ?
44  GROUP BY submission_id',
45  array((int) $journalId)
46  );
47  }
48  return new DBRowIterator($result);
49  }
50 
58  function getGalleyViewCountsForArticle($articleId, $startDate = null, $endDate = null) {
59  if ($startDate && $endDate) {
60  $result = $this->retrieve(
61  sprintf('SELECT tvl.submission_id, tvl.galley_id, COUNT(tvl.galley_id) AS total_galley_views, ag.label
62  FROM timed_views_log tvl
63  LEFT JOIN submission_galleys ag ON (tvl.galley_id = ag.galley_id)
64  WHERE tvl.galley_id IS NOT NULL
65  AND tvl.date >= %s
66  AND tvl.date <= %s
67  AND tvl.submission_id = ?
68  GROUP BY galley_id, submission_id',
69  $this->datetimeToDB($startDate),
70  $this->datetimeToDB($endDate)),
71  array((int) $articleId)
72  );
73  } else {
74  $result = $this->retrieve(
75  'SELECT tvl.submission_id, tvl.galley_id, COUNT(tvl.galley_id) AS total_galley_views, ag.label
76  FROM timed_views_log tvl
77  LEFT JOIN submission_galleys ag ON (tvl.galley_id = ag.galley_id)
78  WHERE tvl.galley_id IS NOT NULL
79  AND tvl.submission_id = ?
80  GROUP BY galley_id, submission_id',
81  array((int) $articleId)
82  );
83  }
84  return new DBRowIterator($result);
85  }
86 
94  function incrementViewCount($journalId, $articleId, $galleyId = null, $ipAddress = null, $userAgent = null) {
95  $this->update(
96  sprintf('INSERT INTO timed_views_log
97  (submission_id, galley_id, journal_id, date, ip_address, user_agent)
98  VALUES
99  (?, ?, ?, %s, ?, ?)',
101  array(
102  (int) $articleId,
103  isset($galleyId) ? (int) $galleyId : null,
104  (int) $journalId,
105  $ipAddress,
106  $userAgent
107  )
108  );
109  }
110 
116  function clearLogs($dateClear, $journalId) {
117  return $this->update(sprintf('DELETE FROM timed_views_log WHERE date < %s AND journal_id = ?', $this->datetimeToDB($dateClear)), (int) $journalId);
118  }
119 }
120 
121 ?>
getAbstractViewCount($journalId, $startDate=null, $endDate=null)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
getGalleyViewCountsForArticle($articleId, $startDate=null, $endDate=null)
Timed view report DAO.
incrementViewCount($journalId, $articleId, $galleyId=null, $ipAddress=null, $userAgent=null)
datetimeToDB($dt)
Definition: DAO.inc.php:293
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208
clearLogs($dateClear, $journalId)
static getCurrentDate($ts=null)
Definition: Core.inc.php:95