Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
ArticleReportDAO.inc.php
1 <?php
2 
16 import('classes.submission.common.Action');
17 import('lib.pkp.classes.db.DBRowIterator');
18 
19 class ArticleReportDAO extends DAO {
25  function getArticleReport($journalId) {
26  $primaryLocale = AppLocale::getPrimaryLocale();
27  $locale = AppLocale::getLocale();
28 
29  $result =& $this->retrieve(
30  'SELECT a.article_id AS article_id,
31  COALESCE(asl1.setting_value, aspl1.setting_value) AS title,
32  COALESCE(asl2.setting_value, aspl2.setting_value) AS abstract,
33  COALESCE(sl.setting_value, spl.setting_value) AS section_title,
34  a.status AS status,
35  a.language AS language
36  FROM articles a
37  LEFT JOIN article_settings aspl1 ON (aspl1.article_id=a.article_id AND aspl1.setting_name = ? AND aspl1.locale = a.locale)
38  LEFT JOIN article_settings asl1 ON (asl1.article_id=a.article_id AND asl1.setting_name = ? AND asl1.locale = ?)
39  LEFT JOIN article_settings aspl2 ON (aspl2.article_id=a.article_id AND aspl2.setting_name = ? AND aspl2.locale = a.locale)
40  LEFT JOIN article_settings asl2 ON (asl2.article_id=a.article_id AND asl2.setting_name = ? AND asl2.locale = ?)
41  LEFT JOIN section_settings spl ON (spl.section_id=a.section_id AND spl.setting_name = ? AND spl.locale = ?)
42  LEFT JOIN section_settings sl ON (sl.section_id=a.section_id AND sl.setting_name = ? AND sl.locale = ?)
43  WHERE a.journal_id = ? AND
44  a.submission_progress = 0
45  ORDER BY a.article_id',
46  array(
47  'title', // Article title
48  'title',
49  $locale,
50  'abstract', // Article abstract
51  'abstract',
52  $locale,
53  'title',
54  $primaryLocale,
55  'title',
56  $locale,
57  $journalId
58  )
59  );
60  $articlesReturner = new DBRowIterator($result);
61 
62  $result =& $this->retrieve(
63  'SELECT MAX(d.date_decided) AS date_decided,
64  d.article_id AS article_id
65  FROM edit_decisions d,
66  articles a
67  WHERE a.journal_id = ? AND
68  a.submission_progress = 0 AND
69  a.article_id = d.article_id
70  GROUP BY d.article_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.article_id AS article_id
79  FROM edit_decisions d,
80  articles a
81  WHERE d.date_decided = ? AND
82  d.article_id = a.article_id AND
83  a.submission_progress = 0 AND
84  d.article_id = ?',
85  array(
86  $row['date_decided'],
87  $row['article_id']
88  )
89  );
90  $decisionsReturner[] = new DBRowIterator($result);
91  unset($result);
92  }
93 
94  $articleDao =& DAORegistry::getDAO('ArticleDAO');
95  $articles =& $articleDao->getArticlesByJournalId($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 articles a ON (aa.submission_id = a.article_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.journal_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  $journalId,
128  $article->getId()
129  )
130  );
131  $authorIterator = new DBRowIterator($result);
132  $authorsReturner[$article->getId()] =& $authorIterator;
133  unset($authorIterator);
134  $index++;
135  unset($article);
136  }
137 
138  return array($articlesReturner, $authorsReturner, $decisionsReturner);
139  }
140 }
141 
142 ?>
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
& getDAO($name, $dbconn=null)
getArticleReport($journalId)
Article report DAO.