Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
ArticleLog.inc.php
1 <?php
2 
20 import('classes.article.log.ArticleEventLogEntry');
21 import('classes.article.log.ArticleEmailLogEntry');
22 
23 class ArticleLog {
33  function logEvent(&$request, &$article, $eventType, $messageKey, $params = array()) {
34  $journal =& $request->getJournal();
35  $user =& $request->getUser();
36  $userId = (isset($user)) ? $user->getId() : 0;
37  return ArticleLog::logEventHeadless($journal, $userId, $article, $eventType, $messageKey, $params);
38  }
39 
49  function logEventHeadless(&$journal, $userId, &$article, $eventType, $messageKey, $params = array()) {
50 
51  // Create a new entry object
52  $articleEventLogDao =& DAORegistry::getDAO('ArticleEventLogDAO');
53  $entry = $articleEventLogDao->newDataObject();
54 
55  // Set implicit parts of the log entry
56  $entry->setDateLogged(Core::getCurrentDate());
57  $entry->setIPAddress(Request::getRemoteAddr());
58  $entry->setUserId($userId);
59  $entry->setAssocType(ASSOC_TYPE_ARTICLE);
60  $entry->setAssocId($article->getId());
61 
62  // Set explicit parts of the log entry
63  $entry->setEventType($eventType);
64  $entry->setMessage($messageKey);
65  $entry->setParams($params);
66  $entry->setIsTranslated(0);
67  $entry->setParams($params);
68 
69  // Insert the resulting object
70  $articleEventLogDao->insertObject($entry);
71  return $entry;
72  }
73 
80  function logEmail($articleId, &$entry, $request = null) {
81  $articleDao =& DAORegistry::getDAO('ArticleDAO');
82  $journalId = $articleDao->getArticleJournalId($articleId);
83 
84  if (!$journalId) {
85  // Invalid article
86  return false;
87  }
88 
89  // Add the entry
90  $entry->setAssocType(ASSOC_TYPE_ARTICLE);
91  $entry->setAssocId($articleId);
92 
93  if ($request) {
94  $user =& $request->getUser();
95  $entry->setSenderId($user == null ? 0 : $user->getId());
96  $entry->setIPAddress($request->getRemoteAddr());
97  } else $entry->setSenderId(0);
98 
99  $entry->setDateSent(Core::getCurrentDate());
100 
101  $logDao =& DAORegistry::getDAO('ArticleEmailLogDAO');
102  return $logDao->insertObject($entry);
103  }
104 }
105 
106 ?>
logEmail($articleId, &$entry, $request=null)
logEvent(&$request, &$article, $eventType, $messageKey, $params=array())
Static class for adding / accessing article log entries.
getCurrentDate($ts=null)
Definition: Core.inc.php:94
& getDAO($name, $dbconn=null)
logEventHeadless(&$journal, $userId, &$article, $eventType, $messageKey, $params=array())