/** * Save the email in the monograph email log. */ function log() { import('classes.monograph.log.MonographEmailLogEntry'); import('classes.monograph.log.MonographLog'); $entry = new MonographEmailLogEntry(); $monograph =& $this->monograph; // Log data $entry->setEventType($this->eventType); $entry->setAssocType($this->assocType); $entry->setAssocId($this->assocId); // Email data $entry->setSubject($this->getSubject()); $entry->setBody($this->getBody()); $entry->setFrom($this->getFromString(false)); $entry->setRecipients($this->getRecipientString()); $entry->setCcs($this->getCcString()); $entry->setBccs($this->getBccString()); // Add log entry $logEntryId = MonographLog::logEmailEntry($monograph->getId(), $entry); // Add attachments import('classes.file.MonographFileManager'); foreach ($this->getAttachmentFiles() as $attachment) { MonographFileManager::temporaryFileToMonographFile($monograph->getId(), $attachment, MONOGRAPH_FILE_ATTACHMENT, $logEntryId, ASSOC_TYPE_MONOGRAPH_EMAIL_LOG_ENTRY); } }
/** * Save the email in the monograph email log. */ function log($request = null) { import('classes.log.MonographLog'); $entry = new MonographEmailLogEntry(); $monograph =& $this->monograph; // Event data $entry->setEventType($this->logEventType); $entry->setAssocType(ASSOC_TYPE_MONOGRAPH); $entry->setAssocId($monograph->getId()); $entry->setDateSent(Core::getCurrentDate()); // User data if ($request) { $user =& $request->getUser(); $entry->setSenderId($user == null ? 0 : $user->getId()); $entry->setIPAddress($request->getRemoteAddr()); } // Email data $entry->setSubject($this->getSubject()); $entry->setBody($this->getBody()); $entry->setFrom($this->getFromString(false)); $entry->setRecipients($this->getRecipientString()); $entry->setCcs($this->getCcString()); $entry->setBccs($this->getBccString()); // Add log entry $logDao =& DAORegistry::getDAO('MonographEmailLogDAO'); $logDao->insertObject($entry); // Add attachments import('classes.file.MonographFileManager'); foreach ($this->getAttachmentFiles() as $attachment) { MonographFileManager::temporaryFileToMonographFile($monograph->getId(), $attachment, MONOGRAPH_FILE_ATTACHMENT, $logEntryId, ASSOC_TYPE_MONOGRAPH_EMAIL_LOG_ENTRY); } }