/** * Exclude object from result * * @param JournalComment $journalComment Object to remove from the list of results * * @return JournalCommentQuery The current query, for fluid interface */ public function prune($journalComment = null) { if ($journalComment) { $this->addUsingAlias(JournalCommentPeer::ID, $journalComment->getId(), Criteria::NOT_EQUAL); } return $this; }
public function comment($id = 0) { $journal_id = isset($_POST['id']) && !empty($_POST['id']) ? intval($_POST['id']) : $id; $type_id = isset($_POST['type_id']) && !empty($_POST['type_id']) ? intval($_POST['type_id']) : 0; $comment = isset($_POST['comment']) && !empty($_POST['comment']) ? htmlspecialchars(trim($_POST['comment'])) : ''; if (!$journal_id || !$comment) { echo "0"; throw new Exception('exit'); } $uid = User::getLoginUid(); $rs_insert = JournalComment::addJournalComment($type_id, $journal_id, $comment, $uid); if ($rs_insert) { echo '1'; throw new Exception('exit'); } else { echo '0'; throw new Exception('exit'); } }
private function renderComment(JournalComment $oComment, Template $oCommentTemplate, $iCounter) { $oCommentTemplate->replaceIdentifier('author', $oComment->getUsername()); $oCommentTemplate->replaceIdentifier('counter', $iCounter + 1); $oCommentTemplate->replaceIdentifier('email', $oComment->getEmail()); $oCommentTemplate->replaceIdentifier('email_hash', md5($oComment->getEmail())); $oCommentTemplate->replaceIdentifier('id', $oComment->getId()); $oCommentTemplate->replaceIdentifier('text', $oComment->getText(), null, Template::NO_HTML_ESCAPE); if ($oComment->getCreatedAtTimestamp() !== null) { $oCommentTemplate->replaceIdentifier('date', LocaleUtil::localizeDate($oComment->getCreatedAtTimestamp())); } return $oCommentTemplate; }
/** * @param JournalComment $journalComment The journalComment object to add. */ protected function doAddJournalComment($journalComment) { $this->collJournalComments[] = $journalComment; $journalComment->setJournalEntry($this); }
/** * Filter the query by a related JournalComment object * * @param JournalComment|PropelObjectCollection $journalComment the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return JournalEntryQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByJournalComment($journalComment, $comparison = null) { if ($journalComment instanceof JournalComment) { return $this->addUsingAlias(JournalEntryPeer::ID, $journalComment->getJournalEntryId(), $comparison); } elseif ($journalComment instanceof PropelObjectCollection) { return $this->useJournalCommentQuery()->filterByPrimaryKeys($journalComment->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByJournalComment() only accepts arguments of type JournalComment or PropelCollection'); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param JournalComment $obj A JournalComment object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null JournalCommentPeer::$instances[$key] = $obj; } }
private function handleNewJournalComment($oPage, $oEntry) { $oFlash = Flash::getFlash(); // Validate form and create new comment and $oComment = new JournalComment(); $oComment->setUsername($_POST['comment_name']); $oFlash->checkForValue('comment_name', 'comment_name_required'); $oComment->setEmail($_POST['comment_email']); $oFlash->checkForEmail('comment_email', 'comment_email_required'); if ($oEntry->getJournal()->getUseCaptcha() && !Session::getSession()->isAuthenticated() && !FormFrontendModule::validateRecaptchaInput() && !isset($_POST['preview'])) { $oFlash->addMessage('captcha_required'); } $oPurifierConfig = HTMLPurifier_Config::createDefault(); $oPurifierConfig->set('Cache.SerializerPath', MAIN_DIR . '/' . DIRNAME_GENERATED . '/' . DIRNAME_CACHES . '/purifier'); $oPurifierConfig->set('HTML.Doctype', 'XHTML 1.0 Transitional'); $oPurifierConfig->set('AutoFormat.AutoParagraph', true); $oPurifier = new HTMLPurifier($oPurifierConfig); $_POST['comment_text'] = $oPurifier->purify($_POST['comment_text']); $oComment->setText($_POST['comment_text']); $oFlash->checkForValue('comment_text', 'comment_required'); $oFlash->finishReporting(); if (isset($_POST['preview'])) { $oComment->setCreatedAt(date('c')); $_POST['preview'] = $oComment; } else { if (Flash::noErrors()) { $oEntry->addJournalComment($oComment); // Post is considered as spam $bIsProblablySpam = isset($_POST['important_note']) && $_POST['important_note'] != null; $sCommentNotificationTemplate = 'e_mail_comment_notified'; // Prevent publication if comments are not enabled or post is spam if (!$oEntry->getJournal()->getEnableComments() || $bIsProblablySpam) { if (!Session::getSession()->isAuthenticated()) { $oComment->setIsPublished(false); $sCommentNotificationTemplate = 'e_mail_comment_moderated'; } } $oComment->save(); // Notify new comment if ($oEntry->getJournal()->getNotifyComments()) { $oEmailContent = JournalPageTypeModule::templateConstruct($sCommentNotificationTemplate, $oPage->getPagePropertyValue('journal:template_set', 'default')); $oEmailContent->replaceIdentifier('email', $oComment->getEmail()); $oEmailContent->replaceIdentifier('user', $oComment->getUsername()); if ($bIsProblablySpam) { $oEmailContent->replaceIdentifier('this_comment_is_spam_note', TranslationPeer::getString('journal.this_comment_is_spam_note', null, null, array('important_note_content' => $_POST['important_note']))); } $oEmailContent->replaceIdentifier('comment', $oComment->getText()); $oEmailContent->replaceIdentifier('entry', $oEntry->getTitle()); $oEmailContent->replaceIdentifier('journal', $oEntry->getJournal()->getName()); $oEmailContent->replaceIdentifier('entry_link', LinkUtil::absoluteLink(LinkUtil::link($oEntry->getLink($oPage)))); $oEmailContent->replaceIdentifier('deactivation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'deactivate'), 'FileManager'), null, LinkUtil::isSSL())); $oEmailContent->replaceIdentifier('activation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'activate'), 'FileManager'), null, LinkUtil::isSSL())); $oEmailContent->replaceIdentifier('deletion_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'delete'), 'FileManager'), null, LinkUtil::isSSL())); $sSubject = TranslationPeer::getString('journal.notification_subject', null, null, array('entry' => $oEntry->getTitle())); $oEmail = new EMail($sSubject, $oEmailContent); $oSender = $oEntry->getUserRelatedByCreatedBy(); $oEmail->addRecipient($oSender->getEmail(), $oSender->getFullName()); $oEmail->send(); } $oSession = Session::getSession(); Flash::getFlash()->unfinishReporting()->addMessage('journal.has_new_comment', array(), "journal_entry.new_comment_thank_you" . ($oEntry->getJournal()->getEnableComments() || $oSession->isAuthenticated() ? '' : '.moderated'), 'new_comment_thank_you_message', 'p')->stick(); LinkUtil::redirect(LinkUtil::link($oEntry->getLink($oPage)) . "#comments"); } } }