Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
AuthorDAO.inc.php
1 <?php
2 
17 import('classes.article.Author');
18 import('classes.article.Article');
19 import('lib.pkp.classes.submission.PKPAuthorDAO');
20 
21 class AuthorDAO extends PKPAuthorDAO {
25  function AuthorDAO() {
26  parent::PKPAuthorDAO();
27  }
28 
39  function &getPublishedArticlesForAuthor($journalId, $firstName, $middleName, $lastName, $affiliation, $country) {
40  $publishedArticles = array();
41  $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
42  $params = array(
43  'affiliation',
44  $firstName, $middleName, $lastName,
45  $affiliation, $country
46  );
47  if ($journalId !== null) $params[] = (int) $journalId;
48 
49  $result = $this->retrieve(
50  'SELECT DISTINCT
51  aa.submission_id
52  FROM authors aa
53  LEFT JOIN submissions a ON (aa.submission_id = a.submission_id)
54  LEFT JOIN author_settings asl ON (asl.author_id = aa.author_id AND asl.setting_name = ?)
55  WHERE aa.first_name = ?
56  AND a.status = ' . STATUS_PUBLISHED . '
57  AND (aa.middle_name = ?' . (empty($middleName)?' OR aa.middle_name IS NULL':'') . ')
58  AND aa.last_name = ?
59  AND (asl.setting_value = ?' . (empty($affiliation)?' OR asl.setting_value IS NULL':'') . ')
60  AND (aa.country = ?' . (empty($country)?' OR aa.country IS NULL':'') . ') ' .
61  ($journalId!==null?(' AND a.context_id = ?'):''),
62  $params
63  );
64 
65  while (!$result->EOF) {
66  $row = $result->getRowAssoc(false);
67  $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($row['submission_id']);
68  if ($publishedArticle) {
69  $publishedArticles[] = $publishedArticle;
70  }
71  $result->MoveNext();
72  }
73 
74  $result->Close();
75  return $publishedArticles;
76  }
77 
90  function getAuthorsAlphabetizedByJournal($journalId = null, $initial = null, $rangeInfo = null, $includeEmail = false) {
91  $params = array(
92  'affiliation', AppLocale::getPrimaryLocale(),
93  'affiliation', AppLocale::getLocale()
94  );
95 
96  if (isset($journalId)) $params[] = $journalId;
97  if (isset($initial)) {
98  $params[] = String::strtolower($initial) . '%';
99  $initialSql = ' AND LOWER(aa.last_name) LIKE LOWER(?)';
100  } else {
101  $initialSql = '';
102  }
103 
104  $result = $this->retrieveRange(
105  'SELECT DISTINCT
106  CAST(\'\' AS CHAR) AS url,
107  0 AS author_id,
108  0 AS submission_id,
109  ' . ($includeEmail?'aa.email AS email,':'CAST(\'\' AS CHAR) AS email,') . '
110  0 AS primary_contact,
111  0 AS seq,
112  aa.first_name,
113  aa.middle_name,
114  aa.last_name,
115  SUBSTRING(asl.setting_value FROM 1 FOR 255) AS affiliation_l,
116  asl.locale,
117  SUBSTRING(aspl.setting_value FROM 1 FOR 255) AS affiliation_pl,
118  aspl.locale AS primary_locale,
119  aa.country
120  FROM authors aa
121  LEFT JOIN author_settings aspl ON (aa.author_id = aspl.author_id AND aspl.setting_name = ? AND aspl.locale = ?)
122  LEFT JOIN author_settings asl ON (aa.author_id = asl.author_id AND asl.setting_name = ? AND asl.locale = ?)
123  JOIN submissions a ON (a.submission_id = aa.submission_id AND a.status = ' . STATUS_PUBLISHED . ')
124  JOIN published_submissions pa ON (pa.submission_id = a.submission_id)
125  JOIN issues i ON (pa.issue_id = i.issue_id AND i.published = 1)
126  WHERE ' . (isset($journalId)?'a.context_id = ? AND ':'') . '
127  (aa.last_name IS NOT NULL AND aa.last_name <> \'\')' .
128  $initialSql . '
129  ORDER BY aa.last_name, aa.first_name',
130  $params,
131  $rangeInfo
132  );
133 
134  return new DAOResultFactory($result, $this, '_returnSimpleAuthorFromRow');
135  }
136 
141  function newDataObject() {
142  return new Author();
143  }
144 }
145 
146 ?>
static & getDAO($name, $dbconn=null)
Operations for retrieving and modifying Author objects.
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
Article author metadata class.
Definition: Author.inc.php:20
static getPrimaryLocale()
Operations for retrieving and modifying PKPAuthor objects.
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:174
static getLocale()
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
static strtolower($string)
Definition: String.inc.php:238
getAuthorsAlphabetizedByJournal($journalId=null, $initial=null, $rangeInfo=null, $includeEmail=false)
& getPublishedArticlesForAuthor($journalId, $firstName, $middleName, $lastName, $affiliation, $country)