Open Journal Systems  3.0.0
 All Data Structures Namespaces Functions Variables Groups Pages
ArticleReportDAO.inc.php
1 <?php
2 
16 import('lib.pkp.classes.db.DBRowIterator');
17 
18 class ArticleReportDAO extends DAO {
24  function getArticleReport($journalId) {
25  $primaryLocale = AppLocale::getPrimaryLocale();
26  $locale = AppLocale::getLocale();
27 
28  $result = $this->retrieve(
29  'SELECT a.submission_id AS submission_id,
30  COALESCE(asl1.setting_value, aspl1.setting_value) AS title,
31  COALESCE(asl2.setting_value, aspl2.setting_value) AS abstract,
32  COALESCE(sl.setting_value, spl.setting_value) AS section_title,
33  a.status AS status,
34  a.language AS language
35  FROM submissions a
36  LEFT JOIN submission_settings aspl1 ON (aspl1.submission_id=a.submission_id AND aspl1.setting_name = ? AND aspl1.locale = a.locale)
37  LEFT JOIN submission_settings asl1 ON (asl1.submission_id=a.submission_id AND asl1.setting_name = ? AND asl1.locale = ?)
38  LEFT JOIN submission_settings aspl2 ON (aspl2.submission_id=a.submission_id AND aspl2.setting_name = ? AND aspl2.locale = a.locale)
39  LEFT JOIN submission_settings asl2 ON (asl2.submission_id=a.submission_id AND asl2.setting_name = ? AND asl2.locale = ?)
40  LEFT JOIN section_settings spl ON (spl.section_id=a.section_id AND spl.setting_name = ? AND spl.locale = ?)
41  LEFT JOIN section_settings sl ON (sl.section_id=a.section_id AND sl.setting_name = ? AND sl.locale = ?)
42  WHERE a.context_id = ? AND
43  a.submission_progress = 0
44  ORDER BY a.submission_id',
45  array(
46  'title', // Article title
47  'title',
48  $locale,
49  'abstract', // Article abstract
50  'abstract',
51  $locale,
52  'title',
53  $primaryLocale,
54  'title',
55  $locale,
56  (int) $journalId
57  )
58  );
59  $articlesReturner = new DBRowIterator($result);
60  unset($result);
61 
62  $result = $this->retrieve(
63  'SELECT MAX(d.date_decided) AS date_decided,
64  d.submission_id AS submission_id
65  FROM edit_decisions d,
66  submissions a
67  WHERE a.context_id = ? AND
68  a.submission_progress = 0 AND
69  a.submission_id = d.submission_id
70  GROUP BY d.submission_id',
71  array((int) $journalId)
72  );
73  $decisionDatesIterator = new DBRowIterator($result);
74  $decisionsReturner = array();
75  while ($row = $decisionDatesIterator->next()) {
76  $result = $this->retrieve(
77  'SELECT d.decision AS decision,
78  d.submission_id AS submission_id
79  FROM edit_decisions d,
80  submissions a
81  WHERE d.date_decided = ? AND
82  d.submission_id = a.submission_id AND
83  a.submission_progress = 0 AND
84  d.submission_id = ?',
85  array(
86  $row['date_decided'],
87  $row['submission_id']
88  )
89  );
90  $decisionsReturner[] = new DBRowIterator($result);
91  unset($result);
92  }
93 
94  $articleDao = DAORegistry::getDAO('ArticleDAO');
95  $articles = $articleDao->getByContextId($journalId);
96  $authorsReturner = array();
97  $index = 1;
98  while ($article = $articles->next()) {
99  $result = $this->retrieve(
100  'SELECT aa.first_name AS fname,
101  aa.middle_name AS mname,
102  aa.last_name AS lname,
103  aa.email AS email,
104  aa.country AS country,
105  aa.url AS url,
106  COALESCE(aasl.setting_value, aas.setting_value) AS biography,
107  COALESCE(aaasl.setting_value, aaas.setting_value) AS affiliation
108  FROM authors aa
109  JOIN submissions a ON (aa.submission_id = a.submission_id)
110  LEFT JOIN author_settings aas ON (aa.author_id = aas.author_id AND aas.setting_name = ? AND aas.locale = ?)
111  LEFT JOIN author_settings aasl ON (aa.author_id = aasl.author_id AND aasl.setting_name = ? AND aasl.locale = ?)
112  LEFT JOIN author_settings aaas ON (aa.author_id = aaas.author_id AND aaas.setting_name = ? AND aaas.locale = ?)
113  LEFT JOIN author_settings aaasl ON (aa.author_id = aaasl.author_id AND aaasl.setting_name = ? AND aaasl.locale = ?)
114  WHERE
115  a.context_id = ? AND
116  a.submission_progress = 0 AND
117  aa.submission_id = ?',
118  array(
119  'biography',
120  $primaryLocale,
121  'biography',
122  $locale,
123  'affiliation',
124  $primaryLocale,
125  'affiliation',
126  $locale,
127  (int) $journalId,
128  $article->getId()
129  )
130  );
131  $authorIterator = new DBRowIterator($result);
132  $authorsReturner[$article->getId()] = $authorIterator;
133  unset($result);
134  $index++;
135  }
136 
137  return array($articlesReturner, $authorsReturner, $decisionsReturner);
138  }
139 }
140 
141 ?>
static & getDAO($name, $dbconn=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...
static getPrimaryLocale()
static getLocale()
getArticleReport($journalId)
Article report DAO.