Open Journal Systems  3.0.0
 All Classes 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 
61  $result = $this->retrieve(
62  'SELECT MAX(d.date_decided) AS date_decided,
63  d.submission_id AS submission_id
64  FROM edit_decisions d,
65  submissions a
66  WHERE a.context_id = ? AND
67  a.submission_progress = 0 AND
68  a.submission_id = d.submission_id
69  GROUP BY d.submission_id',
70  array((int) $journalId)
71  );
72  $decisionDatesIterator = new DBRowIterator($result);
73  $decisionsReturner = array();
74  while ($row = $decisionDatesIterator->next()) {
75  $result = $this->retrieve(
76  'SELECT d.decision AS decision,
77  d.submission_id AS submission_id
78  FROM edit_decisions d,
79  submissions a
80  WHERE d.date_decided = ? AND
81  d.submission_id = a.submission_id AND
82  a.submission_progress = 0 AND
83  d.submission_id = ?',
84  array(
85  $row['date_decided'],
86  $row['submission_id']
87  )
88  );
89  $decisionsReturner[] = new DBRowIterator($result);
90  }
91 
92  $articleDao = DAORegistry::getDAO('ArticleDAO');
93  $articles = $articleDao->getByContextId($journalId);
94  $authorsReturner = array();
95  $index = 1;
96  while ($article = $articles->next()) {
97  $result = $this->retrieve(
98  'SELECT aa.first_name AS fname,
99  aa.middle_name AS mname,
100  aa.last_name AS lname,
101  aa.email AS email,
102  aa.country AS country,
103  aa.url AS url,
104  COALESCE(aasl.setting_value, aas.setting_value) AS biography,
105  COALESCE(aaasl.setting_value, aaas.setting_value) AS affiliation
106  FROM authors aa
107  JOIN submissions a ON (aa.submission_id = a.submission_id)
108  LEFT JOIN author_settings aas ON (aa.author_id = aas.author_id AND aas.setting_name = ? AND aas.locale = ?)
109  LEFT JOIN author_settings aasl ON (aa.author_id = aasl.author_id AND aasl.setting_name = ? AND aasl.locale = ?)
110  LEFT JOIN author_settings aaas ON (aa.author_id = aaas.author_id AND aaas.setting_name = ? AND aaas.locale = ?)
111  LEFT JOIN author_settings aaasl ON (aa.author_id = aaasl.author_id AND aaasl.setting_name = ? AND aaasl.locale = ?)
112  WHERE
113  a.context_id = ? AND
114  a.submission_progress = 0 AND
115  aa.submission_id = ?',
116  array(
117  'biography',
118  $primaryLocale,
119  'biography',
120  $locale,
121  'affiliation',
122  $primaryLocale,
123  'affiliation',
124  $locale,
125  (int) $journalId,
126  $article->getId()
127  )
128  );
129  $authorIterator = new DBRowIterator($result);
130  $authorsReturner[$article->getId()] = $authorIterator;
131  $index++;
132  }
133 
134  return array($articlesReturner, $authorsReturner, $decisionsReturner);
135  }
136 }
137 
138 ?>
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.