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;
 case "delete":
     foreach ($articleCodes as $articleCode) {
         $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
         $articleObj->delete();
     }
     if ($f_article_offset > 15 && count($articleCodes) + $f_article_offset == $f_total_articles) {
         $f_article_offset -= $ArticlesPerPage;
     }
     camp_html_add_msg(getGS("Article(s) deleted."), "ok");
     break;
 case "toggle_front_page":
     foreach ($articleCodes as $articleCode) {
         $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
         if ($articleObj->userCanModify($g_user)) {
             $articleObj->setOnFrontPage(!$articleObj->onFrontPage());
         }
     }
     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) {
Example #3
0
	/**
	 * Execute the action, and mark the action as completed.
	 * @return void
	 */
	public function doAction()
	{
		$publishAction = $this->getPublishAction();
		$frontPageAction = $this->getFrontPageAction();
		$sectionPageAction = $this->getSectionPageAction();
        $article = new Article($this->m_data['fk_language_id'], $this->m_data['fk_article_number']);
		if ($publishAction == 'P') {
		    $article->setWorkflowStatus('Y');
		}
		if ($publishAction == 'U') {
            $article->setWorkflowStatus('S');
		}
		if ($frontPageAction == 'S') {
		    $article->setOnFrontPage(true);
		}
		if ($frontPageAction == 'R') {
		    $article->setOnFrontPage(false);
		}
		if ($sectionPageAction == 'S') {
		    $article->setOnSectionPage(true);
		}
		if ($sectionPageAction == 'R') {
		    $article->setOnSectionPage(false);
		}
		$this->setCompleted();
	} // fn doAction
Example #4
0
        foreach ($contextArticleIds as $contextArticleId) {
            $articleObj = new Article($f_language_selected, $contextArticleId);
            $item['title'] = $articleObj->getTitle();
            $item['articleId'] = 'article_' . $contextArticleId;
            $item['date'] = $articleObj->getCreationDate();
            $item['status'] = $articleObj->getWorkflowDisplayString();
            $items[] = $item;
        }
        $return['items'] = $items;
        $return['code'] = 200;
        return $return;
        break;
}
if ($f_target == 'art_ofp') {
    $value = $f_value == 'Yes' ? true : false;
    $success = $articleObj->setOnFrontPage($value);
    $message = $translator->trans("\$1 toggled.", array('$1' => """ . $translator->trans("On Front Page") . """), 'library');
}
if ($f_target == 'art_osp') {
    $value = $f_value == 'Yes' ? true : false;
    $success = $articleObj->setOnSectionPage($value);
    $message = $translator->trans("\$1 toggled.", array('$1' => """ . $translator->trans("On Section Page") . """), 'library');
}
if ($f_target == 'art_status') {
    if (in_array($f_value, array('Published', 'Submitted', 'New'))) {
        switch ($f_value) {
            case 'New':
                $f_value = 'N';
                break;
            case 'Published':
                $f_value = 'Y';
Example #5
0
        // Sets the author type selected
        $author_type = $f_article_author_type[$i];
        $authorObj->setType($author_type);
        // Links the author to the article
        $articleAuthorObj = new ArticleAuthor($articleObj->getArticleNumber(),
                                              $articleObj->getLanguageId(),
                                              $authorObj->getId(), $author_type);
        if (!$articleAuthorObj->exists()) {
            $articleAuthorObj->create();
        }
        $i++;
    }
}

// Update the article.
$articleObj->setOnFrontPage(!empty($f_on_front_page));
$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);