camp_html_add_msg(getGS("\$1 toggled.", """ . getGS("On Front Page") . """), "ok"); break; case "toggle_section_page": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); if ($articleObj->userCanModify($g_user)) { $articleObj->setOnSectionPage(!$articleObj->onSectionPage()); } } camp_html_add_msg(getGS("\$1 toggled.", """ . getGS("On Section Page") . """), "ok"); break; case "toggle_comments": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); if ($articleObj->userCanModify($g_user)) { $articleObj->setCommentsEnabled(!$articleObj->commentsEnabled()); } } camp_html_add_msg(getGS("\$1 toggled.", """ . getGS("Comments") . """), "ok"); break; case "copy": foreach ($groupedArticleCodes as $articleNumber => $languageArray) { $languageId = camp_array_peek($languageArray); $articleObj = new Article($languageId, $articleNumber); $articleObj->copy($articleObj->getPublicationId(), $articleObj->getIssueNumber(), $articleObj->getSectionNumber(), $g_user->getUserId(), $languageArray); camp_html_add_msg(getGS("Article(s) duplicated."), "ok"); } camp_session_set($offsetVarName, 0); break; case "copy_interactive": $args = $_REQUEST;
$f_comment_nickname = Input::Get('f_comment_nickname', 'string', '', true); $f_comment_subject = Input::Get('f_comment_subject', 'string', '', true); $f_comment_body = Input::Get('f_comment_body'); $f_comment_parent_id = Input::Get('f_comment_id', 'int', 0, true); if (!Input::IsValid()) { camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $BackLink); exit; } // Check that the article exists. $articleObj = new Article($f_language_id, $f_article_number); if (!$articleObj->exists()) { exit; } if (!$articleObj->commentsEnabled() || $articleObj->commentsLocked()) { camp_html_goto_page(camp_html_article_url($articleObj, $f_language_selected, "edit.php")); } if (SystemPref::Get("UseDBReplication") == 'Y') { $dbReplicationObj = new DbReplication(); $connectedToOnlineServer = $dbReplicationObj->connect(); if ($connectedToOnlineServer == false) { camp_html_add_msg(getGS("Comments Disabled: you are either offline or not able to reach the Online server")); camp_html_goto_page(camp_html_article_url($articleObj, $f_language_selected, "edit.php")); } } // Add the user if it doesnt exist in the Phorum user table $phorumUser = new Phorum_user($g_user->getUserId()); if (!$phorumUser->CampUserExists($g_user->getUserId())) {
$issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number); if ($issueObj->exists()) { $sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number); if ($sectionObj->exists()) { $languageObj = new Language($articleObj->getLanguageId()); } else { $sectionObj = null; } } else { $issueObj = null; } } else { $publicationObj = null; } $showCommentControls = $publicationObj->commentsEnabled() && $articleType->commentsEnabled(); $showComments = $showCommentControls && $articleObj->commentsEnabled(); } if ($showComments) { // $comments = array(); /** * @todoget comments */ } // Automatically switch to "view" mode if user doesnt have permissions if (!$articleObj->userCanModify($g_user)) { $f_edit_mode = 'view'; } // // Automatic unlocking // $locked = TRUE;
} $i++; } } // Update the article. $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); global $controller; $repository = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment'); $repository->setArticleStatus($f_article_number, $f_language_selected, $commentsEnabled ? STATUS_APPROVED : STATUS_HIDDEN); $repository->flush(); } $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)) { $articleObj->setCreationDate($f_creation_date); }
/** * Process item * @param Article $article * @return array */ public function processItem(Article $article) { global $g_user, $Campsite; $articleLinkParams = '?f_publication_id=' . $article->getPublicationId() . '&f_issue_number=' . $article->getIssueNumber() . '&f_section_number=' . $article->getSectionNumber() . '&f_article_number=' . $article->getArticleNumber() . '&f_language_id=' . $article->getLanguageId() . '&f_language_selected=' . $article->getLanguageId(); $articleLinkParamsTranslate = $articleLinkParams . '&f_action=translate&f_action_workflow=' . $article->getWorkflowStatus() . '&f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId(); $articleLink = $Campsite['WEBSITE_URL'] . '/admin/articles/edit.php' . $articleLinkParams; $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $articleLinkParams; $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . getGS('Preview') . '">' . getGS('Preview') . '</a>'; $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate; $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . getGS('Translate') . '">' . getGS('Translate') . '</a>'; $lockInfo = ''; $lockHighlight = false; $timeDiff = camp_time_diff_str($article->getLockTime()); if ($article->isLocked() && $timeDiff['days'] <= 0) { $lockUser = new User($article->getLockedByUser()); if ($timeDiff['hours'] > 0) { $lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['hours'], $timeDiff['minutes']); } else { $lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['minutes']); } if ($article->getLockedByUser() != $g_user->getUserId()) { $lockHighlight = true; } } $tmpUser = new User($article->getCreatorId()); $tmpArticleType = new ArticleType($article->getType()); $tmpAuthor = new Author(); $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId()); foreach ((array) $articleAuthors as $author) { if (strtolower($author->getAuthorType()->getName()) == 'author') { $tmpAuthor = $author; break; } } if (!$tmpAuthor->exists() && isset($articleAuthors[0])) { $tmpAuthor = $articleAuthors[0]; } $onFrontPage = $article->onFrontPage() ? getGS('Yes') : getGS('No'); $onSectionPage = $article->onSectionPage() ? getGS('Yes') : getGS('No'); $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true); $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true); $commentsNo = ''; if ($article->commentsEnabled()) { global $controller; $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment'); $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId()); $params = array('sFilter' => $filter); $commentsNo = $repositoryComments->getCount($params); } else { $commentsNo = 'No'; } // get language code $language = new Language($article->getLanguageId()); return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, getGS('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != NULL ? getGS('Yes') : getGS('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink); }