Example #1
0
	function test_article() {
		$article = new Article(9000001,9000002,9000003,9000004);

		// Test create
		$article->create("Unit Test Long Name",
						 "Unit Test Short Name",
						 "fastnews");
		$this->assertTrue($article->exists());

		// Test SET functions
		$article->setTitle("Unit Test New Title");
		$article->setCreatorId(9000005);
		$article->setOnFrontPage(true);
		$article->setOnSection(true);
		$article->setWorkflowStatus('Y');
		$article->setKeywords("Unit, Test");
		$article->setIsIndexed(true);

		// Test GET functions
		$articleCopy = new Article(9000001, 9000002, 9000003, 9000004, $article->getArticleId());
		$this->assertEquals(9000001, $articleCopy->getPublicationId());
		$this->assertEquals(9000002, $articleCopy->getIssueNumber());
		$this->assertEquals(9000003, $articleCopy->getSectionNumber());
		$this->assertEquals(9000004, $articleCopy->getLanguageId());
		$this->assertEquals(9000005, $articleCopy->getCreatorId());
		$this->assertEquals("Unit Test New Title", $articleCopy->getTitle());
		$this->assertEquals(true, $articleCopy->onFrontPage());
		$this->assertEquals(true, $articleCopy->onSection());
		$this->assertEquals('Y', $articleCopy->getWorkflowStatus());
		$this->assertEquals("Unit, Test", $articleCopy->getKeywords());
		$this->assertEquals(true, $articleCopy->isIndexed());

		// Test DELETE functions
		$article->delete();
		$this->assertFalse($article->exists());
	}
        break;
}
$articleCodes = array();
$groupedArticleCodes = array();
foreach ($f_article_codes as $code) {
    list($articleId, $languageId) = explode("_", $code);
    $articleCodes[] = array("article_id" => $articleId, "language_id" => $languageId);
    $groupedArticleCodes[$articleId][$languageId] = $languageId;
}
switch ($f_article_list_action) {
    case "workflow_new":
        foreach ($articleCodes as $articleCode) {
            $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
            // A publisher can change the status in any way he sees fit.
            // Someone who can change an article can submit/unsubmit articles.
            if ($g_user->hasPermission('Publish') || $g_user->hasPermission('ChangeArticle') && $articleObj->getWorkflowStatus() == 'S') {
                $articleObj->setWorkflowStatus('N');
            }
        }
        camp_html_add_msg(getGS("Article status set to '\$1'", getGS("New")), "ok");
        break;
    case "workflow_submit":
        foreach ($articleCodes as $articleCode) {
            $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
            // A user who owns the article may submit it.
            if ($g_user->hasPermission("Publish") || $articleObj->userCanModify($g_user)) {
                $articleObj->setWorkflowStatus('S');
            }
        }
        camp_html_add_msg(getGS("Article status set to '\$1'", getGS("Submitted")), "ok");
        break;
Example #3
0
    $args = $_REQUEST;
    unset($args["f_article_code"]);
    $argsStr = camp_implode_keys_and_values($args, "=", "&");
    $backLink = "/{$ADMIN}/articles/autopublish.php?" . $argsStr;
}
if (!Input::IsValid()) {
    camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $BackLink);
    exit;
}
// Get all the articles.
$articles = array();
$errorArticles = array();
foreach ($f_article_code as $code) {
    list($articleId, $languageId) = explode("_", $code);
    $tmpArticle = new Article($languageId, $articleId);
    if ($tmpArticle->getWorkflowStatus() != 'N') {
        $articles[] = $tmpArticle;
    } else {
        $errorArticles[] = $tmpArticle;
    }
}
$publicationObj = new Publication($f_publication_id);
if (!$publicationObj->exists()) {
    camp_html_display_error(getGS('Publication does not exist.'));
    exit;
}
$issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
if (!$issueObj->exists()) {
    camp_html_display_error(getGS('Issue does not exist.'));
    exit;
}
$articleCodes = array();
$groupedArticleCodes = array();
foreach ($f_article_codes as $code) {
	list($articleId, $languageId) = explode("_", $code);
	$articleCodes[] = array("article_id" => $articleId, "language_id" => $languageId);
	$groupedArticleCodes[$articleId][$languageId] = $languageId;
}

switch ($f_article_list_action) {
case "workflow_new":
	foreach ($articleCodes as $articleCode) {
		$articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
		// A publisher can change the status in any way he sees fit.
		// Someone who can change an article can submit/unsubmit articles.
		if ($g_user->hasPermission('Publish')
			|| ($g_user->hasPermission('ChangeArticle') && ($articleObj->getWorkflowStatus() == 'S'))) {
			$articleObj->setWorkflowStatus('N');
		}
	}
	camp_html_add_msg(getGS("Article status set to '$1'", getGS("New")), "ok");
	break;
case "workflow_submit":
	foreach ($articleCodes as $articleCode) {
		$articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
		// A user who owns the article may submit it.
		if ($g_user->hasPermission("Publish") || $articleObj->userCanModify($g_user)) {
			$articleObj->setWorkflowStatus('S');
		}
	}
	camp_html_add_msg(getGS("Article status set to '$1'", getGS("Submitted")), "ok");
	break;
Example #5
0
 /**
  * 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);
 }