function _HTML_editColumn($id) { $source = new ArticleComment(AMP_Registry::getDbcon(), $id); $article_id = $source->getArticle(); $allowed_articles = AMP_lookup('articles'); $existing_articles = AMP_lookup('articles_existing'); if (!isset($allowed_articles[$article_id]) && isset($existing_articles[$article_id])) { return "\n<td nowrap><div align='center'>" . "</div></td>\n"; } return parent::_HTML_editColumn($id); }
function _spamchecker($data, $fieldname) { if (preg_match("/<\\/?(script|object|embed)>/", $data['comment'])) { return true; } if (!AKISMET_KEY) { return false; } $comment_frame = new ArticleComment(AMP_Registry::getDbcon()); $comment_frame->mergeData($data); $akismet = $comment_frame->to_akismet(); if (!$akismet) { return false; } return $akismet->isSpam(); }
function fixAllBlogCommentsRC($dry) { global $method, $wgExternalDatawareDB, $wgCityId; # select rc_title from recentchanges where rc_namespace = 501 and ( rc_title not rlike '.+[0-9]+$' or rc_title not like '%@comment%' ); $dbw = wfGetDB(DB_MASTER); $res = $dbw->select(array('recentchanges'), array('rc_id, rc_title, rc_namespace'), array('rc_namespace' => NS_BLOG_ARTICLE_TALK, "( rc_title not rlike '.+[0-9]+\$' or rc_title not like '%@comment%' )"), $method); $pages = array(); while ($row = $dbw->fetchRow($res)) { $pages[] = $row; } $dbw->freeResult($res); print sprintf("Found %0d pages \n", count($pages)); if (!empty($pages)) { foreach ($pages as $row) { print "parse {$row['rc_title']}\n"; $parts = ArticleComment::explode($row['rc_title']); if ($parts['blog'] == 1 && count($parts['partsOriginal']) > 0) { $parts['parsed'] = array(); foreach ($parts['partsOriginal'] as $id => $title) { $parts['parsed'][$id] = sprintf('%s-%s', '@comment', $title); } $newTitle = sprintf('%s/%s', $parts['title'], implode("/", $parts['parsed'])); if ($dry) { printf("update recentchanges set rc_title = '%s' where rc_id = %d and rc_namespace = %d\n", $newTitle, $row['rc_id'], NS_BLOG_ARTICLE_TALK); } else { $dbw->update('recentchanges', array('rc_title' => $newTitle), array('rc_id' => $row['rc_id'], 'rc_namespace' => NS_BLOG_ARTICLE_TALK), $method); } } } } }
protected function getArticle() { $article = ArticleComment::GetArticleOf($this->m_dbObject->getMessageId()); if (is_null($article)) { return new MetaArticle(); } return new MetaArticle($article->getLanguageId(), $article->getArticleNumber()); }
/** * Creates the list of objects. Sets the parameter $p_hasNextElements to * true if this list is limited and elements still exist in the original * list (from which this was truncated) after the last element of this * list. * * @param int $p_start * @param int $p_limit * @param array $p_parameters * @param int &$p_count * @return array */ protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count) { $this->m_defaultTTL = ArticleComment::DEFAULT_TTL; $articleCommentsList = ArticleComment::GetList($this->m_constraints, $this->m_order, $p_start, $p_limit, $p_count); $metaCommentsList = array(); foreach ($articleCommentsList as $comment) { $metaCommentsList[] = new MetaComment($comment->getMessageId()); } return $metaCommentsList; }
public function handleComment($data, $form) { $comment = ArticleComment::create(); $comment->Name = $data['Name']; $comment->Email = $data['Email']; $comment->Comment = $data['Comment']; $comment->ArticleID = $this->ID; $comment->write(); $form->sessionMessage('Thanks for your comment!', 'good'); return $this->redirectBack(); }
function execute($options = array()) { $options = array_merge($this->getOptions(), $options); if (!(isset($this->udm->uid) && $this->udm->uid)) { $list_format_function = $options['format_list']; if (is_callable(array($this, $list_format_function))) { return $this->{$list_format_function}($options); } if (is_callable($list_format_function)) { return $list_format_function($options, $this); } trigger_error(sprintf(AMP_TEXT_ERROR_METHOD_NOT_SUPPORTED, 'AMP', $list_format_function, get_class($this))); } else { $options['_linked_uid'] = $this->udm->uid; $output = $this->_listLink($options); $comment_source = new ArticleComment($this->dbcon); $comments = $comment_source->search($comment_source->makeCriteria(array('userdata_id' => $this->udm->uid))); if (!$comments) { return $output; } $display = new AMP_Content_Article_Comment_Public_Display_List($comments); return $output . $display->execute($options); } }
public function handleComment($data, $form) { Session::set("FormData.{$form->getName()}.data", $data); $existing = $this->Comments()->filter(array('Comment' => $data['Comment'])); if ($existing->exists() && strlen($data['Comment']) > 20) { $form->sessionMessage('That comment already exists! Spammer!', 'bad'); return $this->redirectBack(); } $comment = ArticleComment::create(); $comment->ArticlePageID = $this->ID; $form->saveInto($comment); $comment->write(); Session::clear("FormData.{$form->getName()}.data"); $form->sessionMessage('Thanks for your comment', 'good'); return $this->redirectBack(); }
public function handleComment($data, $form) { //store the info in the session so that the user field will not empty after the validation Session::set("FormData.{$form->getName()}.data", $data); //this->Commets = the $has_many value is Comments $existing = $this->Comments()->filter(array('Comment' => $data['Comment'])); if ($existing->exists() && strlen($data['Comment']) > 0) { $form->sessionMessage('That comment already exists!', 'bad'); //if everything checkout we cleare it. Session::clear('$FormData.{$form->getName()}.data'); return $this->redirectBack(); } $comment = ArticleComment::create(); $comment->Name = $data['Name']; $comment->Email = $data['Email']; $comment->Comment = $data['Comment']; $comment->ArticlePageID = $this->ID; $comment->write(); $form->sessionMessage('Thanks for your comment', 'good'); return $this->redirectBack(); }
/** * Regenerate / invalidate service cache for current page */ public function regenerateData() { global $wgMemc; wfProfileIn(__METHOD__); wfDebug(__METHOD__ . ": page #{$this->pageId}\n"); // invalidate cached data from getMostLinkedCategories() $wgMemc->delete($this->getKey('mostlinkedcategories')); // invalidate cached data from getCurrentRevision() $wgMemc->delete($this->getKey('current-revision')); // invalidate cached data from getPreviousEdits() $wgMemc->delete($this->getKey('previous-edits')); // invalidate cached data from getCommentsCount() $title = Title::newFromId($this->pageId, Title::GAID_FOR_UPDATE); if (!empty($title)) { $pageName = $title->getPrefixedText(); wfDebug(__METHOD__ . ": page '{$pageName}' has been touched\n"); // invalidate cache with number of comments / talk page revisions if ($title->isTalkPage()) { if (self::isArticleCommentsEnabled() && ArticleComment::isTitleComment($title)) { // get subject page for this article comment $parts = ArticleComment::explode($title->getText()); $title = Title::newFromText($parts['title'], MWNamespace::getSubject($title->getNamespace())); wfDebug(__METHOD__ . ": article comment added\n"); } else { // get subject page for this talk page $title = $title->getSubjectPage(); } $contentPageName = $title->getPrefixedText(); wfDebug(__METHOD__ . ": talk page / article comment for '{$contentPageName}' has been touched\n"); $contentPageService = new self($title->getArticleId()); $contentPageService->regenerateCommentsCount(); } } wfProfileOut(__METHOD__); return true; }
public function getTopParentObj() { $title = $this->getTopParent(); if (empty($title)) { return null; } $title = Title::newFromText($title, $this->mNamespace); if ($title instanceof Title) { $obj = ArticleComment::newFromTitle($title); return $obj; } return null; }
function importArticles() { assert($this->xml->name == 'articles'); $articleDAO =& DAORegistry::getDAO('ArticleDAO'); $articles = $articleDAO->getArticlesByJournalId($this->journal->getId()); $journalFileManager = new JournalFileManager($this->journal); $publicFileManager =& new PublicFileManager(); $this->nextElement(); while ($this->xml->name == 'article') { $articleXML = $this->getCurrentElementAsDom(); $article = new Article(); $article->setJournalId($this->journal->getId()); $article->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleXML->userId)); $article->setSectionId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_SECTION, (int) $articleXML->sectionId)); $article->setLocale((string) $articleXML->locale); $article->setLanguage((string) $articleXML->language); $article->setCommentsToEditor((string) $articleXML->commentsToEditor); $article->setCitations((string) $articleXML->citations); $article->setDateSubmitted((string) $articleXML->dateSubmitted); $article->setDateStatusModified((string) $articleXML->dateStatusModified); $article->setLastModified((string) $articleXML->lastModified); $article->setStatus((int) $articleXML->status); $article->setSubmissionProgress((int) $articleXML->submissionProgress); $article->setCurrentRound((int) $articleXML->currentRound); $article->setPages((string) $articleXML->pages); $article->setFastTracked((int) $articleXML->fastTracked); $article->setHideAuthor((int) $articleXML->hideAuthor); $article->setCommentsStatus((int) $articleXML->commentsStatus); $articleDAO->insertArticle($article); $oldArticleId = (int) $articleXML->oldId; $this->restoreDataObjectSettings($articleDAO, $articleXML->settings, 'article_settings', 'article_id', $article->getId()); $article =& $articleDAO->getArticle($article->getId()); // Reload article with restored settings $covers = $article->getFileName(null); if ($covers) { foreach ($covers as $locale => $oldCoverFileName) { $sourceFile = $this->publicFolderPath . '/' . $oldCoverFileName; $extension = $publicFileManager->getExtension($oldCoverFileName); $destFile = 'cover_issue_' . $article->getId() . "_{$locale}.{$extension}"; $publicFileManager->copyJournalFile($this->journal->getId(), $sourceFile, $destFile); unlink($sourceFile); $article->setFileName($destFile, $locale); $articleDAO->updateArticle($article); } } $articleFileManager = new ArticleFileManager($article->getId()); $authorDAO =& DAORegistry::getDAO('AuthorDAO'); foreach ($articleXML->author as $authorXML) { $author = new Author(); $author->setArticleId($article->getId()); $author->setFirstName((string) $authorXML->firstName); $author->setMiddleName((string) $authorXML->middleName); $author->setLastName((string) $authorXML->lastName); $author->setSuffix((string) $authorXML->suffix); $author->setCountry((string) $authorXML->country); $author->setEmail((string) $authorXML->email); $author->setUrl((string) $authorXML->url); $author->setUserGroupId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_GROUP, (int) $authorXML->userGroupId)); $author->setPrimaryContact((int) $authorXML->primaryContact); $author->setSequence((int) $authorXML->sequence); $authorDAO->insertAuthor($author); $this->restoreDataObjectSettings($authorDAO, $authorXML->settings, 'author_settings', 'author_id', $author->getId()); unset($author); } $articleEmailLogDAO =& DAORegistry::getDAO('ArticleEmailLogDAO'); $emailLogsXML = array(); foreach ($articleXML->emailLogs->emailLog as $emailLogXML) { array_unshift($emailLogsXML, $emailLogXML); } foreach ($emailLogsXML as $emailLogXML) { $emailLog = new ArticleEmailLogEntry(); $emailLog->setAssocType(ASSOC_TYPE_ARTICLE); $emailLog->setAssocId($article->getId()); $emailLog->setSenderId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $emailLogXML->senderId)); $emailLog->setDateSent((string) $emailLogXML->dateSent); $emailLog->setIPAddress((string) $emailLogXML->IPAddress); $emailLog->setEventType((int) $emailLogXML->eventType); $emailLog->setFrom((string) $emailLogXML->from); $emailLog->setRecipients((string) $emailLogXML->recipients); $emailLog->setCcs((string) $emailLogXML->ccs); $emailLog->setBccs((string) $emailLogXML->bccs); $emailLog->setSubject((string) $emailLogXML->subject); $emailLog->setBody((string) $emailLogXML->body); $articleEmailLogDAO->insertObject($emailLog); $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $emailLogXML->oldId, $emailLog->getId()); } $articleFileDAO =& DAORegistry::getDAO('ArticleFileDAO'); foreach ($articleXML->articleFile as $articleFileXML) { try { $articleFile = new ArticleFile(); $articleFile->setArticleId($article->getId()); $articleFile->setSourceFileId((int) $articleFileXML->sourceFileId); $articleFile->setSourceRevision((int) $articleFileXML->sourceRevision); $articleFile->setRevision((int) $articleFileXML->revision); $articleFile->setFileName((string) $articleFileXML->fileName); $articleFile->setFileType((string) $articleFileXML->fileType); $articleFile->setFileSize((string) $articleFileXML->fileSize); $articleFile->setOriginalFileName((string) $articleFileXML->originalFileName); $articleFile->setFileStage((int) $articleFileXML->fileStage); $articleFile->setAssocId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $articleFileXML->assocId)); $articleFile->setDateUploaded((string) $articleFileXML->dateUploaded); $articleFile->setDateModified((string) $articleFileXML->dateModified); $articleFile->setRound((int) $articleFileXML->round); $articleFile->setViewable((int) $articleFileXML->viewable); $articleFileDAO->insertArticleFile($articleFile); $oldArticleFileId = (int) $articleFileXML->oldId; $oldFileName = $articleFile->getFileName(); $stagePath = $articleFileManager->fileStageToPath($articleFile->getFileStage()); $fileInTransferPackage = $this->journalFolderPath . "/articles/{$oldArticleId}/{$stagePath}/{$oldFileName}"; $newFileName = $articleFileManager->generateFilename($articleFile, $articleFile->getFileStage(), $articleFile->getOriginalFileName()); $newFilePath = "/articles/" . $article->getId() . "/{$stagePath}/{$newFileName}"; $journalFileManager->copyFile($fileInTransferPackage, $journalFileManager->filesDir . $newFilePath); unlink($fileInTransferPackage); $articleFileDAO->updateArticleFile($articleFile); $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $oldArticleFileId, $articleFile->getFileId()); } catch (Exception $e) { } } $articleFiles = $articleFileDAO->getArticleFilesByArticle($article->getId()); foreach ($articleFiles as $articleFile) { try { $articleFile->setSourceFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $articleFile->getSourceFileId())); $articleFileDAO->updateArticleFile($articleFile); } catch (Exception $e) { } } $suppFileDAO =& DAORegistry::getDAO('SuppFileDAO'); foreach ($articleXML->suppFile as $suppFileXML) { $suppFile =& new SuppFile(); $suppFile->setArticleId($article->getId()); $suppFile->setRemoteURL((string) $suppFileXML->remoteURL); $suppFile->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $suppFileXML->fileId)); $suppFile->setType((string) $suppFileXML->type); $suppFile->setDateCreated((string) $suppFileXML->dateCreated); $suppFile->setLanguage((string) $suppFileXML->language); $suppFile->setShowReviewers((int) $suppFileXML->showReviewers); $suppFile->setDateSubmitted((string) $suppFileXML->dateSubmitted); $suppFile->setSequence((int) $suppFileXML->sequence); $suppFileDAO->insertSuppFile($suppFile); $this->restoreDataObjectSettings($suppFileDAO, $suppFileXML->settings, 'article_supp_file_settings', 'supp_id', $suppFile->getId()); } $articleCommentDAO =& DAORegistry::getDAO('ArticleCommentDAO'); foreach ($articleXML->articleComment as $articleCommentXML) { $articleComment = new ArticleComment(); $articleComment->setArticleId($article->getId()); $articleComment->setAssocId($article->getId()); $articleComment->setCommentType((int) $articleCommentXML->commentType); $articleComment->setRoleId((int) $articleCommentXML->roleId); $articleComment->setAuthorId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleCommentXML->authorId)); $articleComment->setCommentTitle((string) $articleCommentXML->commentTitle); $articleComment->setComments((string) $articleCommentXML->comments); $articleComment->setDatePosted((string) $articleCommentXML->datePosted); $articleComment->setDateModified((string) $articleCommentXML->dateModified); $articleComment->setViewable((int) $articleCommentXML->viewable); $articleCommentDAO->insertArticleComment($articleComment); } $articleGalleyDAO =& DAORegistry::getDAO('ArticleGalleyDAO'); foreach ($articleXML->articleGalley as $articleGalleyXML) { $articleGalley = null; if ($articleGalleyXML->htmlGalley == "1") { $articleGalley = new ArticleHTMLGalley(); } else { $articleGalley = new ArticleGalley(); } $articleGalley->setArticleId($article->getId()); $articleGalley->setLocale((string) $articleGalleyXML->locale); $articleGalley->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyXML->fileId)); $articleGalley->setLabel((string) $articleGalleyXML->label); $articleGalley->setSequence((int) $articleGalleyXML->sequence); $articleGalley->setRemoteURL((string) $articleGalleyXML->remoteURL); if ($articleGalley instanceof ArticleHTMLGalley) { $articleGalley->setStyleFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyXML->styleFileId)); } $articleGalleyDAO->insertGalley($articleGalley); if ($articleGalley instanceof ArticleHTMLGalley) { foreach ($articleGalleyXML->htmlGalleyImage as $articleGalleyImageXML) { $imageId = $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyImageXML); $articleGalleyDAO->insertGalleyImage($articleGalley->getId(), $imageId); } } $this->restoreDataObjectSettings($articleGalleyDAO, $articleGalleyXML->settings, 'article_galley_settings', 'galley_id', $articleGalley->getId()); } $noteDAO =& DAORegistry::getDAO('NoteDAO'); foreach ($articleXML->articleNote as $articleNoteXML) { $articleNote = new Note(); $articleNote->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleNoteXML->userId)); $articleNote->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleNoteXML->fileId)); $articleNote->setAssocType(ASSOC_TYPE_ARTICLE); $articleNote->setAssocId($article->getId()); $articleNote->setDateCreated((string) $articleNoteXML->dateCreated); $articleNote->setDateModified((string) $articleNoteXML->dateModified); $articleNote->setContents((string) $articleNoteXML->contents); $articleNote->setTitle((string) $articleNoteXML->title); $noteDAO->insertObject($articleNote); } $editAssignmentDAO =& DAORegistry::getDAO('EditAssignmentDAO'); foreach ($articleXML->editAssignment as $editAssignmentXML) { $editAssignment = new EditAssignment(); $editAssignment->setArticleId($article->getId()); $editAssignment->setEditorId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $editAssignmentXML->editorId)); $editAssignment->setCanReview((int) $editAssignmentXML->canReview); $editAssignment->setCanEdit((int) $editAssignmentXML->canEdit); $editAssignment->setDateUnderway((string) $editAssignmentXML->dateUnderway); $editAssignment->setDateNotified((string) $editAssignmentXML->dateNotified); $editAssignmentDAO->insertEditAssignment($editAssignment); } $reviewAssignmentDAO =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewFormResponseDAO =& DAORegistry::getDAO('ReviewFormResponseDAO'); foreach ($articleXML->reviewAssignment as $reviewAssignmentXML) { $reviewAssignment = new ReviewAssignment(); $reviewAssignment->setSubmissionId($article->getId()); $reviewAssignment->setReviewerId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $reviewAssignmentXML->reviewerId)); try { $reviewAssignment->setReviewerFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $reviewAssignmentXML->reviewerFileId)); } catch (Exception $e) { $this->logger->log("Arquivo do artigo {$oldArticleId} não encontrado. ID: " . (int) $reviewAssignmentXML->reviewerFileId . "\n"); } $reviewAssignment->setReviewFormId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM, (int) $reviewAssignmentXML->reviewFormId)); $reviewAssignment->setReviewRoundId((int) $reviewAssignmentXML->reviewRoundId); $reviewAssignment->setStageId((int) $reviewAssignmentXML->stageId); $reviewAssignment->setReviewerFullName((string) $reviewAssignmentXML->reviewerFullName); $reviewAssignment->setCompetingInterests((string) $reviewAssignmentXML->competingInterests); $reviewAssignment->setRegretMessage((string) $reviewAssignmentXML->regretMessage); $reviewAssignment->setRecommendation((string) $reviewAssignmentXML->recommendation); $reviewAssignment->setDateAssigned((string) $reviewAssignmentXML->dateAssigned); $reviewAssignment->setDateNotified((string) $reviewAssignmentXML->dateNotified); $reviewAssignment->setDateConfirmed((string) $reviewAssignmentXML->dateConfirmed); $reviewAssignment->setDateCompleted((string) $reviewAssignmentXML->dateCompleted); $reviewAssignment->setDateAcknowledged((string) $reviewAssignmentXML->dateAcknowledged); $reviewAssignment->setDateDue((string) $reviewAssignmentXML->dateDue); $reviewAssignment->setDateResponseDue((string) $reviewAssignmentXML->dateResponseDue); $reviewAssignment->setLastModified((string) $reviewAssignmentXML->lastModified); $reviewAssignment->setDeclined((int) $reviewAssignmentXML->declined); $reviewAssignment->setReplaced((int) $reviewAssignmentXML->replaced); $reviewAssignment->setCancelled((int) $reviewAssignmentXML->cancelled); $reviewAssignment->setQuality((int) $reviewAssignmentXML->quality); $reviewAssignment->setDateRated((string) $reviewAssignmentXML->dateRated); $reviewAssignment->setDateReminded((string) $reviewAssignmentXML->dateReminded); $reviewAssignment->setReminderWasAutomatic((int) $reviewAssignmentXML->reminderWasAutomatic); $reviewAssignment->setRound((int) $reviewAssignmentXML->round); $reviewAssignment->setReviewRevision((int) $reviewAssignmentXML->reviewRevision); $reviewAssignment->setReviewMethod((int) $reviewAssignmentXML->reviewMethod); $reviewAssignment->setUnconsidered((int) $reviewAssignmentXML->unconsidered); $reviewAssignmentDAO->insertObject($reviewAssignment); foreach ($reviewAssignmentXML->formResponses->formResponse as $formResponseXML) { $reviewFormResponseDAO->update('INSERT INTO review_form_responses (review_form_element_id, review_id, response_type, response_value) VALUES (?, ?, ?, ?)', array($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM_ELEMENT, (int) $formResponseXML->reviewFormElementId), $reviewAssignment->getId(), (string) $formResponseXML->responseType, (string) $formResponseXML->responseValue)); } } $signoffDAO =& DAORegistry::getDAO('SignoffDAO'); foreach ($articleXML->signoff as $signoffXML) { $signoff = new Signoff(); $signoff->setAssocType(ASSOC_TYPE_ARTICLE); $signoff->setAssocId($article->getId()); $signoff->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $signoffXML->userId)); $signoff->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $signoffXML->fileId)); $signoff->setUserGroupId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_GROUP, (int) $signoffXML->userGroupId)); $signoff->setSymbolic((string) $signoffXML->symbolic); $signoff->setFileRevision((int) $signoffXML->fileRevision); $signoff->setDateUnderway((string) $signoffXML->dateUnderway); $signoff->setDateNotified((string) $signoffXML->dateNotified); $signoff->setDateCompleted((string) $signoffXML->dateCompleted); $signoff->setDateAcknowledged((string) $signoffXML->dateAcknowledged); $signoffDAO->insertObject($signoff); } $editorSubmissionDAO =& DAORegistry::getDAO('EditorSubmissionDAO'); foreach ($articleXML->editDecisions as $editDecisionXML) { $editDecisions =& $editorSubmissionDAO->update('INSERT INTO edit_decisions (article_id, round, editor_id, decision, date_decided) values (?, ?, ?, ?, ?)', array($article->getId(), (string) $editDecisionXML->round, $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $editDecisionXML->editorId), (string) $editDecisionXML->decision, (string) $editDecisionXML->dateDecided)); } $publishedArticleDAO =& DAORegistry::getDAO('PublishedArticleDAO'); if (isset($articleXML->publishedArticle)) { $publishedArticleXML = $articleXML->publishedArticle; $publishedArticle = new PublishedArticle(); $publishedArticle->setId($article->getId()); $publishedArticle->setIssueId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ISSUE, (int) $publishedArticleXML->issueId)); $publishedArticle->setDatePublished((string) $publishedArticleXML->datePublished); $publishedArticle->setSeq((int) $publishedArticleXML->seq); $publishedArticle->setAccessStatus((int) $publishedArticleXML->accessStatus); $publishedArticleDAO->insertPublishedArticle($publishedArticle); } $articleEventLogDAO =& DAORegistry::getDAO('ArticleEventLogDAO'); $eventLogsXML =& iterator_to_array($articleXML->eventLogs->eventLog); $eventLogsXML = array(); foreach ($articleXML->eventLogs->eventLog as $eventLogXML) { array_unshift($eventLogsXML, $eventLogXML); } foreach ($eventLogsXML as $eventLogXML) { $eventLog = new ArticleEventLogEntry(); $eventLog->setAssocType(ASSOC_TYPE_ARTICLE); $eventLog->setAssocId($article->getId()); $eventLog->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $eventLogXML->userId)); $eventLog->setDateLogged((string) $eventLogXML->dateLogged); $eventLog->setIPAddress((string) $eventLogXML->IPAddress); $eventLog->setEventType((int) $eventLogXML->eventType); $eventLog->setMessage((string) $eventLogXML->message); $eventLog->setIsTranslated((int) $eventLogXML->isTranslated); $articleEventLogDAO->insertObject($eventLog); $this->restoreDataObjectSettings($articleEventLogDAO, $eventLogXML->settings, 'event_log_settings', 'log_id', $eventLog->getId()); } try { $article->setSubmissionFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->submissionFileId)); } catch (Exception $e) { } try { $article->setRevisedFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->revisedFileId)); } catch (Exception $e) { } try { $article->setReviewFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->reviewFileId)); } catch (Exception $e) { } try { $article->setEditorFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->editorFileId)); } catch (Exception $e) { } $articleDAO->updateArticle($article); $this->nextElement(); } }
$articleObj->setOnSectionPage(!empty($f_on_section_page)); $articleObj->setIsPublic(!empty($f_is_public)); $articleObj->setKeywords($f_keywords); $articleObj->setTitle($f_article_title); $articleObj->setIsIndexed(false); if (!empty($f_comment_status)) { if ($f_comment_status == "enabled" || $f_comment_status == "locked") { $commentsEnabled = true; } else { $commentsEnabled = false; } // If status has changed, then you need to show/hide all the comments // as appropriate. if ($articleObj->commentsEnabled() != $commentsEnabled) { $articleObj->setCommentsEnabled($commentsEnabled); $comments = ArticleComment::GetArticleComments($f_article_number, $f_language_selected); if ($comments) { foreach ($comments as $comment) { $comment->setStatus($commentsEnabled?PHORUM_STATUS_APPROVED:PHORUM_STATUS_HIDDEN); } } } $articleObj->setCommentsLocked($f_comment_status == "locked"); } // Make sure that the time stamp is updated. $articleObj->setProperty('time_updated', 'NOW()', true, true); // Verify creation date is in the correct format. // If not, dont change it. if (preg_match("/\d{4}-\d{2}-\d{2}/", $f_creation_date)) {
/** * Handle confirmations when page is deleted * * @param WikiPage $article */ public static function addPageDeletedConfirmation(&$article, &$user, $reason, $articleId) { global $wgOut; if (F::app()->checkSkin('oasis')) { $title = $article->getTitle(); // special handling of ArticleComments if (class_exists('ArticleComment') && MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title) && $title->getNamespace() != NS_USER_WALL) { self::addConfirmation(wfMessage('oasis-confirmation-comment-deleted')->escaped()); return true; } $pageName = $title->getPrefixedText(); $message = wfMessage('oasis-confirmation-page-deleted', $pageName)->inContentLanguage()->parse(); wfRunHooks('OasisAddPageDeletedConfirmationMessage', array(&$title, &$message)); self::addConfirmation($message, self::CONFIRMATION_CONFIRM, true); // redirect to main page $wgOut->redirect(Title::newMainPage()->getFullUrl(array('cb' => rand(1, 1000)))); } return true; }
/** * Create the first message for an article, which is a blank message * with the title of the article as the subject. * * @param Article $p_article * @param int $p_forumId * @return mixed * The comment created (or the one that already exists) on success, * or false on error. */ private function CreateFirstComment($p_article, $p_forumId) { // Check if the first post already exists. $articleNumber = $p_article->getArticleNumber(); $languageId = $p_article->getLanguageId(); $firstPost = ArticleComment::GetCommentThreadId($articleNumber, $languageId); if ($firstPost) { return new Phorum_message($firstPost); } // Get article creator $user = new User($p_article->getCreatorId()); if ($user->exists()) { $userId = $user->getUserId(); $userEmail = $user->getEmail(); $userPasswd = $user->getPassword(); $userName = $user->getUserName(); $userRealName = $user->getRealName(); // Create phorum user if necessary $phorumUser = Phorum_user::GetByUserName($userName); if (!is_object($phorumUser)) { $phorumUser = new Phorum_user(); } if (!$phorumUser->CampUserExists($userId) && !$phorumUser->create($userName, $userPasswd, $userEmail, $userId)) { return null; } } else { $userId = null; $userEmail = ''; $userRealName = ''; } // Create the comment. $title = $p_article->getTitle(); $commentObj = new Phorum_message(); if ($commentObj->create($p_forumId, $title, '', 0, 0, $userRealName, $userEmail, is_null($userId) ? 0 : $userId)) { // Link the message to the current article. ArticleComment::Link($articleNumber, $languageId, $commentObj->getMessageId(), true); return $commentObj; } else { return null; } } // method CreateFirstComment
private function filterLog($res) { wfProfileIn(__METHOD__); if ($res['logtype'] == 'move') { if (isset($res['move'], $res['move']['new_title'], $res['move']['new_ns'])) { //FB#35775 //RT#27870 if (!empty($this->parameters['type']) && $this->parameters['type'] == 'widget') { return; } $newTitle = Title::newFromText($res['move']['new_title'], $res['move']['new_ns']); } else { $newTitle = Title::newFromText(trim($res['rc_params'])); } if ($newTitle && $newTitle->exists()) { $oldTitle = Title::newFromText($res['title']); if (empty($oldTitle)) { wfProfileOut(__METHOD__); return; } // Filter Article Comments from Activity Log without using rc_params FB:1336 if (class_exists('ArticleComment') && ArticleComment::isTitleComment($newTitle)) { wfProfileOut(__METHOD__); return; } $this->add(array('type' => 'move', 'to_title' => $newTitle->getPrefixedText(), 'to_url' => $newTitle->getLocalUrl(), 'title' => $oldTitle->getPrefixedText(), 'url' => $oldTitle->getLocalUrl(), 'comment' => $res['comment']), $res); wfProfileOut(__METHOD__); return true; } } if ($this->proxyType == self::WL) { if ($res['logtype'] == 'delete') { $this->add(array('type' => 'delete', 'title' => $res['title']), $res); wfProfileOut(__METHOD__); return true; } else { if ($res['logtype'] == 'upload') { $title = Title::newFromText($res['title']); if ($title && $title->exists()) { $file = wfFindFile($title); if ($file) { $this->add(array('type' => 'upload', 'title' => $title->getPrefixedText(), 'url' => $title->getLocalUrl(), 'thumbnail' => $file->transform(array('width' => self::UPLOAD_THUMB_WIDTH))->toHtml()), $res); wfProfileOut(__METHOD__); return true; } } } } } wfProfileOut(__METHOD__); }
/** * @static * @param Title $title * @param User $user * @param $action * @param $result * @return bool */ public static function userCan($title, $user, $action, &$result) { $namespace = $title->getNamespace(); /** * here we only handle Blog articles, everyone can read it */ if ($namespace != NS_BLOG_ARTICLE && $namespace != NS_BLOG_ARTICLE_TALK) { $result = null; return true; } /** * check if default blog post was passed (BugId:8331) */ if ($namespace == NS_BLOG_ARTICLE && $title->mTextform == '') { return true; } $username = $user->getName(); if ($namespace == NS_BLOG_ARTICLE_TALK && class_exists('ArticleComment')) { $oComment = ArticleComment::newFromTitle($title); // $oComment->load(); $canEdit = $oComment->canEdit(); $isOwner = (bool) ($canEdit && !in_array($action, array('watch', 'protect'))); $isArticle = false; //if this is TALK it is not article } else { $owner = BlogArticle::getOwner($title); $isOwner = (bool) ($username == $owner); $isArticle = (bool) ($namespace == NS_BLOG_ARTICLE); } /** * returned values */ $result = array(); $return = false; switch ($action) { case "move": case "move-target": if ($isArticle && ($user->isAllowed("blog-articles-move") || $isOwner)) { $result = true; $return = true; } break; case "read": $result = true; $return = true; break; /** * creating permissions: * -- article can be created only by blog owner * -- comment can be created by everyone */ /** * creating permissions: * -- article can be created only by blog owner * -- comment can be created by everyone */ case "create": if ($isArticle) { $return = $username == $owner; $result = $username == $owner; } else { $result = true; $return = true; } break; /** * edit permissions -- owner of blog and one who has * "blog-articles-edit" permission */ /** * edit permissions -- owner of blog and one who has * "blog-articles-edit" permission */ case "edit": if ($isArticle && ($user->isAllowed("blog-articles-edit") || $isOwner)) { $result = true; $return = true; } break; case "delete": if (!$isArticle && $user->isAllowed("blog-comments-delete")) { $result = true; $return = true; } if ($user->isAllowed('delete')) { $result = true; $return = true; } break; case "protect": if ($isArticle && $user->isAllowed("blog-articles-protect")) { $result = true; $return = true; } break; case "autopatrol": case "patrol": $result = true; $return = true; break; default: /** * for other actions we demand that user has to be logged in */ if ($user->isAnon()) { $result = array("{$action} is forbidden for anon user"); $return = false; } else { if (isset($owner) && $username != $owner) { $result = array(); } $return = isset($owner) && $username == $owner; } } return $return; }
/** * Add the comment. */ function execute() { $commentDao =& DAORegistry::getDAO('ArticleCommentDAO'); $article = $this->article; // Insert new comment $comment = new ArticleComment(); $comment->setCommentType($this->commentType); $comment->setRoleId($this->roleId); $comment->setArticleId($article->getId()); $comment->setAssocId($this->assocId); $comment->setAuthorId($this->user->getId()); $comment->setCommentTitle($this->getData('commentTitle')); $comment->setComments($this->getData('comments')); $comment->setDatePosted(Core::getCurrentDate()); $comment->setViewable($this->getData('viewable')); $this->commentId = $commentDao->insertArticleComment($comment); }
function _filter_by_article($article_id) { require_once 'AMP/Content/Article/Comment/ArticleComment.php'; $comment = new ArticleComment(AMP_Registry::getDbcon()); $this->criteria = join(' AND ', $comment->makeCriteria(array('displayable' => 1, 'article' => $article_id))); }
protected function getCommentCount() { return ArticleComment::GetArticleComments($this->m_dbObject->getArticleNumber(), $this->m_dbObject->getLanguageId(), 'approved', true, false); }
/** * Email editor decision comment. * @param $authorSubmission object * @param $send boolean * @param $request object */ function emailEditorDecisionComment($authorSubmission, $send, $request) { $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& $request->getJournal(); $user =& $request->getUser(); import('classes.mail.ArticleMailTemplate'); $email = new ArticleMailTemplate($authorSubmission); $editAssignments = $authorSubmission->getEditAssignments(); $editors = array(); foreach ($editAssignments as $editAssignment) { array_push($editors, $userDao->getUser($editAssignment->getEditorId())); } if ($send && !$email->hasErrors()) { HookRegistry::call('AuthorAction::emailEditorDecisionComment', array(&$authorSubmission, &$email)); $email->send($request); $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO'); $articleComment = new ArticleComment(); $articleComment->setCommentType(COMMENT_TYPE_EDITOR_DECISION); $articleComment->setRoleId(ROLE_ID_AUTHOR); $articleComment->setArticleId($authorSubmission->getId()); $articleComment->setAuthorId($authorSubmission->getUserId()); $articleComment->setCommentTitle($email->getSubject()); $articleComment->setComments($email->getBody()); $articleComment->setDatePosted(Core::getCurrentDate()); $articleComment->setViewable(true); $articleComment->setAssocId($authorSubmission->getId()); $articleCommentDao->insertArticleComment($articleComment); return true; } else { if (!$request->getUserVar('continued')) { $email->setSubject($authorSubmission->getLocalizedTitle()); if (!empty($editors)) { foreach ($editors as $editor) { $email->addRecipient($editor->getEmail(), $editor->getFullName()); } } else { $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); } } $email->displayEditForm(Request::url(null, null, 'emailEditorDecisionComment', 'send'), array('articleId' => $authorSubmission->getId()), 'submission/comment/editorDecisionEmail.tpl'); return false; } }
/** * @return null|ArticleComment */ protected function getArticleComment() { if (empty($this->articleComment)) { $this->articleComment = ArticleComment::newFromTitle($this->title); } return $this->articleComment; }
/** * formats links in the "File usage" section of file pages * @author Jakub Olek */ public static function onFilePageImageUsageSingleLink(&$link, &$element) { $app = F::app(); $ns = $element->page_namespace; $title = Title::newFromText($element->page_title, $ns); if (empty($title)) { // sanity check return true; } // format links to comment pages if ($ns == NS_TALK && ArticleComment::isTitleComment($title)) { $parentTitle = reset(explode('/', $element->page_title)); // getBaseText returns me parent comment for subcomment $link = wfMsgExt('article-comments-file-page', array('parsemag'), $title->getLocalURL(), self::getUserNameFromRevision($title), Title::newFromText($parentTitle)->getLocalURL(), $parentTitle); // format links to blog posts } else { if (defined('NS_BLOG_ARTICLE_TALK') && $ns == NS_BLOG_ARTICLE_TALK) { $baseText = $title->getBaseText(); $titleNames = explode('/', $baseText); $userBlog = Title::newFromText($titleNames[0], NS_BLOG_ARTICLE); $link = wfMsgExt('article-blog-comments-file-page', array('parsemag'), $title->getLocalURL(), self::getUserNameFromRevision($title), Title::newFromText($baseText, NS_BLOG_ARTICLE)->getLocalURL(), $titleNames[1], $userBlog->getLocalURL(), $userBlog->getBaseText()); } } return true; }
/** * Creates and returns an article comment object from a row * @param $row array * @return ArticleComment object */ function &_returnArticleCommentFromRow($row) { $articleComment = new ArticleComment(); $articleComment->setId($row['comment_id']); $articleComment->setCommentType($row['comment_type']); $articleComment->setRoleId($row['role_id']); $articleComment->setArticleId($row['article_id']); $articleComment->setAssocId($row['assoc_id']); $articleComment->setAuthorId($row['author_id']); $articleComment->setCommentTitle($row['comment_title']); $articleComment->setComments($row['comments']); $articleComment->setDatePosted($this->datetimeFromDB($row['date_posted'])); $articleComment->setDateModified($this->datetimeFromDB($row['date_modified'])); $articleComment->setViewable($row['viewable']); HookRegistry::call('ArticleCommentDAO::_returnArticleCommentFromRow', array(&$articleComment, &$row)); return $articleComment; }
/** * Delete article from database. This will * only delete one specific translation of the article. * * @return boolean */ public function delete() { // It is an optimization to put these here because in most cases // you dont need these files. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleTopic.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleIndex.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleComment.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticlePublish.php'); // Delete scheduled publishing ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']); // Delete Article Comments ArticleComment::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']); // is this the last translation? if (count($this->getLanguages()) <= 1) { // Delete image pointers ArticleImage::OnArticleDelete($this->m_data['Number']); // Delete topics pointers ArticleTopic::OnArticleDelete($this->m_data['Number']); // Delete file pointers ArticleAttachment::OnArticleDelete($this->m_data['Number']); // Delete indexes ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(), $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber()); } // geo-map processing // is this the last translation? if (count($this->getLanguages()) <= 1) { // unlink the article-map pointers Geo_Map::OnArticleDelete($this->m_data['Number']); } else { // removing non-last translation of the map poi contents Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']); } // Delete row from article type table. $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articleData->delete(); $tmpObj = clone $this; // for log $tmpData = $this->m_data; $tmpData['languageName'] = $this->getLanguageName(); // Delete row from Articles table. $deleted = parent::delete(); if ($deleted) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } Log::ArticleMessage($tmpObj, getGS('Article deleted.'), null, 32); } $this->m_cacheUpdate = true; return $deleted; } // fn delete
/** * Add the comment. */ function execute() { // Personalized execute() method since now there are possibly two comments contained within each form submission. $commentDao =& DAORegistry::getDAO('ArticleCommentDAO'); $this->insertedComments = array(); // Assign all common information $comment = new ArticleComment(); $comment->setCommentType($this->commentType); $comment->setRoleId($this->roleId); $comment->setArticleId($this->article->getId()); $comment->setAssocId($this->assocId); $comment->setAuthorId($this->user->getId()); $comment->setCommentTitle($this->getData('commentTitle')); $comment->setDatePosted(Core::getCurrentDate()); // If comments "For authors and editor" submitted if ($this->getData('authorComments') != null) { $comment->setComments($this->getData('authorComments')); $comment->setViewable(1); array_push($this->insertedComments, $commentDao->insertArticleComment($comment)); } // If comments "For editor" submitted if ($this->getData('comments') != null) { $comment->setComments($this->getData('comments')); $comment->setViewable(null); array_push($this->insertedComments, $commentDao->insertArticleComment($comment)); } }
/** * axPost -- static hook/entry for ajax request post * * @static * @access public * * @return String -- json-ized array` */ public static function axPost() { global $wgRequest, $wgUser, $wgLang; $articleId = $wgRequest->getVal('article', false); $parentId = $wgRequest->getVal('parentId'); $result = array('error' => 1); $title = Title::newFromID($articleId); if (!$title) { return $result; } if (!ArticleComment::canComment($title)) { return $result; } WikiaLogger::instance()->info(__METHOD__ . ' : Comment posted', ['skin' => $wgRequest->getVal('useskin'), 'articleId' => $articleId, 'parentId' => $parentId]); $response = ArticleComment::doPost(self::getConvertedContent($wgRequest->getVal('wpArticleComment')), $wgUser, $title, $parentId); if ($response !== false) { if ($title->getNamespace() == NS_USER_TALK && $response[0] == EditPage::AS_SUCCESS_NEW_ARTICLE && $title->getText() != $wgUser->getName()) { $user = User::newFromName($title->getText()); if ($user) { $user->setNewtalk(true); } } $listing = ArticleCommentList::newFromTitle($title); $countAll = $wgLang->formatNum($listing->getCountAllNested()); $commentsHTML = $response[2]['text']; $result = array('text' => $commentsHTML, 'counter' => $countAll); if (F::app()->checkskin('wikiamobile')) { $result['counterMessage'] = wfMessage('wikiamobile-article-comments-counter')->params($countAll)->text(); } if ($parentId) { $result['parentId'] = $parentId; } return $result; } return $result; }
/** * TODO: Document what the parameters are. */ static function ChangesListInsertArticleLink($changeList, &$articlelink, &$s, $rc, $unpatrolled, $watched) { $rcTitle = $rc->getAttribute('rc_title'); $rcNamespace = $rc->getAttribute('rc_namespace'); $title = Title::newFromText($rcTitle, $rcNamespace); if (MWNamespace::isTalk($rcNamespace) && ArticleComment::isTitleComment($title)) { $parts = ArticleComment::explode($rcTitle); $titleMainArticle = Title::newFromText($parts['title'], MWNamespace::getSubject($rcNamespace)); //fb#15143 if ($titleMainArticle instanceof Title) { if (defined('NS_BLOG_ARTICLE') && $rcNamespace == NS_BLOG_ARTICLE || defined('NS_BLOG_ARTICLE_TALK') && $rcNamespace == NS_BLOG_ARTICLE_TALK) { $messageKey = 'article-comments-rc-blog-comment'; } else { $messageKey = 'article-comments-rc-comment'; } $articleId = $title->getArticleId(); $articlelink = wfMsgExt($messageKey, array('parseinline'), $title->getFullURL("permalink={$articleId}#comm-{$articleId}"), $titleMainArticle->getText()); } else { //it should never happened because $rcTitle is never empty, //ArticleComment::explode() always returns an array with not-empty 'title' element, //(both files: ArticleComments/classes/ArticleComments.class.php //and WallArticleComment/classes/ArticleComments.class.php have //the same definition of explode() method) //and static constructor newFromText() should create a Title instance for $parts['title'] Wikia::log(__METHOD__, false, 'WALL_ARTICLE_COMMENT_ERROR: no main article title: ' . print_r($parts, true) . ' namespace: ' . $rcNamespace); } } return true; }
/** * Email editor decision comment. * @param $sectionEditorSubmission object * @param $send boolean * @param $request object */ function emailEditorDecisionComment($sectionEditorSubmission, $send, $request) { $userDao =& DAORegistry::getDAO('UserDAO'); $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO'); $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $journal =& $request->getJournal(); $user =& $request->getUser(); import('classes.mail.ArticleMailTemplate'); $decisionTemplateMap = array(SUBMISSION_EDITOR_DECISION_ACCEPT => 'EDITOR_DECISION_ACCEPT', SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS => 'EDITOR_DECISION_REVISIONS', SUBMISSION_EDITOR_DECISION_RESUBMIT => 'EDITOR_DECISION_RESUBMIT', SUBMISSION_EDITOR_DECISION_DECLINE => 'EDITOR_DECISION_DECLINE'); $decisions = $sectionEditorSubmission->getDecisions(); $decisions = array_pop($decisions); // Rounds $decision = array_pop($decisions); $decisionConst = $decision ? $decision['decision'] : null; $email = new ArticleMailTemplate($sectionEditorSubmission, isset($decisionTemplateMap[$decisionConst]) ? $decisionTemplateMap[$decisionConst] : null); $copyeditor = $sectionEditorSubmission->getUserBySignoffType('SIGNOFF_COPYEDITING_INITIAL'); if ($send && !$email->hasErrors()) { HookRegistry::call('SectionEditorAction::emailEditorDecisionComment', array(&$sectionEditorSubmission, &$send, &$request)); $email->send($request); if ($decisionConst == SUBMISSION_EDITOR_DECISION_DECLINE) { // If the most recent decision was a decline, // sending this email archives the submission. $sectionEditorSubmission->setStatus(STATUS_ARCHIVED); $sectionEditorSubmission->stampStatusModified(); $sectionEditorSubmissionDao->updateSectionEditorSubmission($sectionEditorSubmission); } $articleComment = new ArticleComment(); $articleComment->setCommentType(COMMENT_TYPE_EDITOR_DECISION); $articleComment->setRoleId(Validation::isEditor() ? ROLE_ID_EDITOR : ROLE_ID_SECTION_EDITOR); $articleComment->setArticleId($sectionEditorSubmission->getId()); $articleComment->setAuthorId($sectionEditorSubmission->getUserId()); $articleComment->setCommentTitle($email->getSubject()); $articleComment->setComments($email->getBody()); $articleComment->setDatePosted(Core::getCurrentDate()); $articleComment->setViewable(true); $articleComment->setAssocId($sectionEditorSubmission->getId()); $articleCommentDao->insertArticleComment($articleComment); return true; } else { if (!$request->getUserVar('continued')) { $authorUser =& $userDao->getUser($sectionEditorSubmission->getUserId()); $authorEmail = $authorUser->getEmail(); $email->assignParams(array('editorialContactSignature' => $user->getContactSignature(), 'authorName' => $authorUser->getFullName(), 'journalTitle' => $journal->getLocalizedTitle())); $email->addRecipient($authorEmail, $authorUser->getFullName()); if ($journal->getSetting('notifyAllAuthorsOnDecision')) { foreach ($sectionEditorSubmission->getAuthors() as $author) { if ($author->getEmail() != $authorEmail) { $email->addCc($author->getEmail(), $author->getFullName()); } } } } elseif ($request->getUserVar('importPeerReviews')) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignments =& $reviewAssignmentDao->getBySubmissionId($sectionEditorSubmission->getId(), $sectionEditorSubmission->getCurrentRound()); $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForRound($sectionEditorSubmission->getId(), $sectionEditorSubmission->getCurrentRound()); $body = ''; foreach ($reviewAssignments as $reviewAssignment) { // If the reviewer has completed the assignment, then import the review. if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) { // Get the comments associated with this review assignment $articleComments =& $articleCommentDao->getArticleComments($sectionEditorSubmission->getId(), COMMENT_TYPE_PEER_REVIEW, $reviewAssignment->getId()); if ($articleComments) { $body .= "------------------------------------------------------\n"; $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => String::enumerateAlphabetically($reviewIndexes[$reviewAssignment->getReviewId()]))) . "\n"; if (is_array($articleComments)) { foreach ($articleComments as $comment) { // If the comment is viewable by the author, then add the comment. if ($comment->getViewable()) { $body .= String::html2text($comment->getComments()) . "\n\n"; } } } $body .= "------------------------------------------------------\n\n"; } if ($reviewFormId = $reviewAssignment->getReviewFormId()) { $reviewId = $reviewAssignment->getId(); $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO'); $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO'); $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewFormId); if (!$articleComments) { $body .= "------------------------------------------------------\n"; $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => String::enumerateAlphabetically($reviewIndexes[$reviewAssignment->getReviewId()]))) . "\n\n"; } foreach ($reviewFormElements as $reviewFormElement) { if ($reviewFormElement->getIncluded()) { $body .= String::html2text($reviewFormElement->getLocalizedQuestion()) . ": \n"; $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewId, $reviewFormElement->getId()); if ($reviewFormResponse) { $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses(); if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) { if ($reviewFormElement->getElementType() == REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) { foreach ($reviewFormResponse->getValue() as $value) { $body .= "\t" . String::html2text($possibleResponses[$value - 1]['content']) . "\n"; } } else { $body .= "\t" . String::html2text($possibleResponses[$reviewFormResponse->getValue() - 1]['content']) . "\n"; } $body .= "\n"; } else { $body .= "\t" . $reviewFormResponse->getValue() . "\n\n"; } } } } $body .= "------------------------------------------------------\n\n"; } } } $oldBody = $email->getBody(); if (!empty($oldBody)) { $oldBody .= "\n"; } $email->setBody($oldBody . $body); } $email->displayEditForm($request->url(null, null, 'emailEditorDecisionComment', 'send'), array('articleId' => $sectionEditorSubmission->getId()), 'submission/comment/editorDecisionEmail.tpl', array('isAnEditor' => true)); return false; } }
// This is here again on purpose because sometimes the pager // must correct this value. $f_comment_start_inbox = camp_session_get('f_comment_start_inbox', 0); $f_comment_start_archive = camp_session_get('f_comment_start_archive', 0); if ($f_comment_screen == 'inbox') { $comments = ArticleComment::GetComments('unapproved', false, $f_comment_search, array('ORDER BY' => array($f_comment_order_by => $f_comment_order_direction), 'LIMIT' => array('START'=> $f_comment_start_inbox, 'MAX_ROWS' => $f_comment_per_page))); } elseif ($f_comment_screen == 'archive') { $comments = ArticleComment::GetComments('approved', false, $f_comment_search, array('ORDER BY' => array($f_comment_order_by => $f_comment_order_direction), 'LIMIT' => array('START'=> $f_comment_start_archive, 'MAX_ROWS' => $f_comment_per_page))); } } $crumbs = array(); $crumbs[] = array(getGS("Content"), ""); $crumbs[] = array(getGS("Comments"), ""); echo camp_html_content_top(getGS('Comments'), null); ?> <script type="text/javascript" src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/campsite.js"></script> <?php camp_html_display_msgs("0.25em", "0.25em"); ?>