00001 <?php
00002
00015
00016
00017
00018 import('submission.common.Action');
00019
00020 class ArticleReportDAO extends DAO {
00026 function getArticleReport($journalId) {
00027 $primaryLocale = Locale::getPrimaryLocale();
00028 $locale = Locale::getLocale();
00029
00030 $result =& $this->retrieve(
00031 'SELECT
00032 a.article_id AS article_id,
00033 COALESCE(asl1.setting_value, aspl1.setting_value) AS title,
00034 COALESCE(asl2.setting_value, aspl2.setting_value) AS abstract,
00035 u.first_name AS fname,
00036 u.middle_name AS mname,
00037 u.last_name AS lname,
00038 u.email AS email,
00039 u.affiliation AS affiliation,
00040 u.country AS country,
00041 u.phone AS phone,
00042 u.fax AS fax,
00043 u.url AS url,
00044 u.mailing_address AS address,
00045 COALESCE(usl.setting_value, uspl.setting_value) AS biography,
00046 COALESCE(sl.setting_value, spl.setting_value) AS section_title,
00047 a.language AS language
00048 FROM
00049 articles a
00050 LEFT JOIN users u ON a.user_id=u.user_id
00051 LEFT JOIN user_settings uspl ON (u.user_id=uspl.user_id AND uspl.setting_name = ? AND uspl.locale = ?)
00052 LEFT JOIN user_settings usl ON (u.user_id=usl.user_id AND usl.setting_name = ? AND usl.locale = ?)
00053 LEFT JOIN article_settings aspl1 ON (aspl1.article_id=a.article_id AND aspl1.setting_name = ? AND aspl1.locale = ?)
00054 LEFT JOIN article_settings asl1 ON (asl1.article_id=a.article_id AND asl1.setting_name = ? AND asl1.locale = ?)
00055 LEFT JOIN article_settings aspl2 ON (aspl2.article_id=a.article_id AND aspl2.setting_name = ? AND aspl2.locale = ?)
00056 LEFT JOIN article_settings asl2 ON (asl2.article_id=a.article_id AND asl2.setting_name = ? AND asl2.locale = ?)
00057 LEFT JOIN section_settings spl ON (spl.section_id=a.section_id AND spl.setting_name = ? AND spl.locale = ?)
00058 LEFT JOIN section_settings sl ON (sl.section_id=a.section_id AND sl.setting_name = ? AND sl.locale = ?)
00059 WHERE
00060 a.journal_id = ?
00061 ORDER BY
00062 title',
00063 array(
00064 'biography',
00065 $primaryLocale,
00066 'biography',
00067 $locale,
00068 'title',
00069 $primaryLocale,
00070 'title',
00071 $locale,
00072 'abstract',
00073 $primaryLocale,
00074 'abstract',
00075 $locale,
00076 'title',
00077 $primaryLocale,
00078 'title',
00079 $locale,
00080 $journalId
00081 )
00082 );
00083 $articlesReturner =& new DBRowIterator($result);
00084
00085 $result =& $this->retrieve(
00086 'SELECT MAX(ed.date_decided) AS date,
00087 ed.article_id AS article_id
00088 FROM edit_decisions ed,
00089 articles a
00090 WHERE a.journal_id = ? AND
00091 a.article_id = ed.article_id
00092 GROUP BY ed.article_id',
00093 array($journalId)
00094 );
00095 $decisionDatesIterator =& new DBRowIterator($result);
00096 $decisions = array();
00097 $decisionsReturner = array();
00098 while ($row =& $decisionDatesIterator->next()) {
00099 $result =& $this->retrieve(
00100 'SELECT decision AS decision,
00101 article_id AS article_id
00102 FROM edit_decisions
00103 WHERE date_decided = ? AND
00104 article_id = ?',
00105 array(
00106 $row['date'],
00107 $row['article_id']
00108 )
00109 );
00110 $decisionsReturner[] =& new DBRowIterator($result);
00111 unset($result);
00112 }
00113
00114 return array($articlesReturner, $decisionsReturner);
00115 }
00116 }
00117
00118 ?>