Example #1
0
        $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);
}
// Verify publish date is in the correct format.
// If not, dont change it.
if (preg_match("/\\d{4}-\\d{2}-\\d{2}/", $f_publish_date)) {
    $articleObj->setPublishDate($f_publish_date);
}
foreach ($articleFields as $dbColumnName => $text) {
    $articleTypeObj->setProperty($dbColumnName, $text);
}
Log::ArticleMessage($articleObj, $translator->trans('Content edited', array(), 'articles'), $g_user->getUserId(), 37);
ArticleIndex::RunIndexer(3, 10, true);
if (CampTemplateCache::factory()) {
    CampTemplateCache::factory()->update(array('language' => $articleObj->getLanguageId(), 'publication' => $articleObj->getPublicationId(), 'issue' => $articleObj->getIssueNumber(), 'section' => $articleObj->getSectionNumber(), 'article' => $articleObj->getArticleNumber()), !($articleObj->isPublished() || $articleObj->m_published));
}
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('authors');
$cacheService->clearNamespace('article');
$cacheService->clearNamespace('article_type');
$cacheService->clearNamespace('boxarticles');
echo json_encode($data);
exit;
Example #2
0
    /**
     * Set the workflow state of the article.
     * 	   'Y' = 'Published'
     *     'S' = 'Submitted'
     *     'N' = 'New'
     *
     * @param string $p_value
     * @return boolean
     */
    public function setWorkflowStatus($p_value)
    {
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleIndex.php');

        $p_value = strtoupper($p_value);
        if ( ($p_value != 'Y') && ($p_value != 'S') && ($p_value != 'N') && ($p_value != 'M')) {
            return false;
        }

        // If the article is being published
        if ( ($this->getWorkflowStatus() != 'Y') && ($p_value == 'Y') ) {
            $this->setProperty('PublishDate', 'NOW()', true, true);
        }
        // Unlock the article if it changes status.
        if ( $this->getWorkflowStatus() != $p_value ) {
            $this->setIsLocked(false);
        }

        if ($p_value == 'Y' || $p_value == 'M') {
            $issueObj = new Issue($this->getPublicationId(), $this->getLanguageId(),
            $this->getIssueNumber());
            if (!$issueObj->exists()) {
                return false;
            }
            $p_value = $issueObj->isPublished() ? 'Y' : 'M';
        }

        $oldStatus = $this->getWorkflowStatus();

        if (!parent::setProperty('Published', $p_value)) {
            return false;
        }

        CampCache::singleton()->clear('user');
        $this->m_cacheUpdate = true;

        if (function_exists("camp_load_translation_strings")) {
            camp_load_translation_strings("api");
        }
        $logtext = getGS('Article status changed from $1 to $2.',
            $this->getWorkflowDisplayString($oldStatus), $this->getWorkflowDisplayString($p_value));
        Log::ArticleMessage($this, $logtext, null, 35);
        return true;
    } // fn setWorkflowStatus
Example #3
0
	$articleObj->setCreationDate($f_creation_date);
}

// Verify publish date is in the correct format.
// If not, dont change it.
if (preg_match("/\d{4}-\d{2}-\d{2}/", $f_publish_date)) {
	$articleObj->setPublishDate($f_publish_date);
}

foreach ($articleFields as $dbColumnName => $text) {
	$articleTypeObj->setProperty($dbColumnName, $text);
}

$articleObj->setIsLocked(false);

Log::ArticleMessage($articleObj, getGS('Content edited'), $g_user->getUserId(), 37);

if ($f_save_button == "save") {
	camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'), false);
} elseif ($f_save_button == "save_and_close") {
	if ($f_publication_id > 0) {
		camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'index.php'), false);
	} else {
		camp_html_goto_page("/$ADMIN/", false);
	}
}

ArticleIndex::RunIndexer(3, 10, true);

?>
Example #4
0
    }
    $articlePublishObj = new ArticlePublish();
    $articlePublishObj->create();
    $articlePublishObj->setArticleNumber($tmpArticle->getArticleNumber());
    $articlePublishObj->setLanguageId($tmpArticle->getLanguageId());
    $articlePublishObj->setActionTime($publishTime);
    if ($f_publish_action == "P" || $f_publish_action == "U") {
        $articlePublishObj->setPublishAction($f_publish_action);
    }
    if ($f_front_page_action == "S" || $f_front_page_action == "R") {
        $articlePublishObj->setFrontPageAction($f_front_page_action);
    }
    if ($f_section_page_action == "S" || $f_section_page_action == "R") {
        $articlePublishObj->setSectionPageAction($f_section_page_action);
    }
    Log::ArticleMessage($tmpArticle, getGS('Scheduled action added'), $g_user->getUserId(), 37);
}
if ($f_mode == "multi") {
    $args = $_REQUEST;
    unset($args["f_article_code"]);
    $argsStr = camp_implode_keys_and_values($args, "=", "&");
    camp_html_add_msg(getGS("Scheduled action added."), "ok");
    camp_html_goto_page("/{$ADMIN}/articles/index.php?" . $argsStr);
} else {
    ?>
	<script type="text/javascript">
    try {
        parent.$.fancybox.reload = true;
        parent.$.fancybox.message = '<?php 
    putGS('Actions updated.');
    ?>
Example #5
0
 /**
  * Set the workflow state of the article.
  * 	   'Y' = 'Published'
  *     'S' = 'Submitted'
  *     'N' = 'New'
  *
  * @param  string  $p_value
  * @return boolean
  */
 public function setWorkflowStatus($p_value)
 {
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleIndex.php';
     $translator = \Zend_Registry::get('container')->getService('translator');
     $em = \Zend_Registry::get('container')->getService('em');
     $p_value = strtoupper($p_value);
     if ($p_value != 'Y' && $p_value != 'S' && $p_value != 'N' && $p_value != 'M') {
         return false;
     }
     // If the article is being published
     if ($this->getWorkflowStatus() != 'Y' && $p_value == 'Y') {
         $this->setProperty('PublishDate', 'NOW()', true, true);
         // send out an article.published event
         self::dispatchEvent("article.published", $this);
         self::dispatchEvent("article.publish", $this, array('number' => $this->getArticleNumber(), 'language' => $this->getLanguageId()));
         // dispatch blog.published
         $blogConfig = \Zend_Registry::get('container')->getParameter('blog');
         if ($this->getType() == $blogConfig['article_type']) {
             self::dispatchEvent('blog.published', $this, array('number' => $this->getArticleNumber(), 'language' => $this->getLanguageId()));
         }
         $article_images = ArticleImage::GetImagesByArticleNumber($this->getArticleNumber());
         foreach ($article_images as $article_image) {
             $image = $article_image->getImage();
             $user_id = (int) $image->getUploadingUserId();
             //send out an image.published event
             self::dispatchEvent("image.published", $this, array("user" => $user_id));
         }
     }
     // Unlock the article if it changes status.
     if ($this->getWorkflowStatus() != $p_value) {
         $this->setIsLocked(false);
     }
     if ($p_value == 'Y' || $p_value == 'M') {
         $issueObj = new Issue($this->getPublicationId(), $this->getLanguageId(), $this->getIssueNumber());
         if (!$issueObj->exists()) {
             return false;
         }
         $p_value = $issueObj->isPublished() ? 'Y' : 'M';
     }
     $oldStatus = $this->getWorkflowStatus();
     if (!parent::setProperty('Published', $p_value)) {
         return false;
     }
     $language = $em->getRepository('Newscoop\\Entity\\Language')->findOneById($this->getLanguageId());
     $authors = $em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthors($this->getArticleNumber(), $language->getCode())->getArrayResult();
     foreach ($authors as $author) {
         self::dispatchEvent("user.set_points", $this, array('authorId' => $author['fk_author_id']));
     }
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     $cacheService->clearNamespace('article');
     $logtext = $translator->trans('Article status changed from $1 to $2.', array('$1' => $this->getWorkflowDisplayString($oldStatus), '$2' => $this->getWorkflowDisplayString($p_value)), 'api');
     Log::ArticleMessage($this, $logtext, null, 35);
     return true;
 }
Example #6
0
</script>
<?php
	exit;
}

$f_language_selected = Input::Get('f_language_selected', 'int', 0);
$f_article_number = Input::Get('f_article_number', 'int', 0);
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
	camp_html_display_error(getGS("Article does not exist."), null, true);
	exit;
}

foreach ((array) $_POST['item'] as $attachmentId) {
    ArticleAttachment::AddFileToArticle((int) $attachmentId, $articleObj->getArticleNumber());
}
$logtext = getGS('$1 file/s attached to article', sizeof($_POST['item']));
Log::ArticleMessage($articleObj, $logtext, null, 38, TRUE);

?>
<script type="text/javascript">
try {
    parent.$.fancybox.reload = true;
    parent.$.fancybox.message = '<?php putGS('Files attached.'); ?>';
    parent.$.fancybox.close();
} catch (e) {}
</script>

<?php exit; ?>

Example #7
0
$f_article_number = Input::Get('f_article_number', 'int', 0);
$f_attachment_id = Input::Get('f_attachment_id', 'int', 0);
// Check input
if (!Input::IsValid()) {
    camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())), null, true);
    exit;
}
if (!$g_user->hasPermission("DeleteFile")) {
    camp_html_display_error($translator->trans("You do not have the right to delete file attachments.", array(), 'article_files'), null, true);
    exit;
}
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
    camp_html_display_error($translator->trans("Article does not exist."), null, true);
    exit;
}
$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
    camp_html_display_error($translator->trans('Attachment does not exist.', array(), 'article_files'), null, true);
    exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
ArticleAttachment::RemoveAttachmentFromArticle($f_attachment_id, $f_article_number);
$logtext = $translator->trans('File #$1 "$2" unattached', array('$1' => $attachmentObj->getAttachmentId(), '$2' => $attachmentObj->getFileName()), 'article_files');
Log::ArticleMessage($articleObj, $logtext, null, 39);
$attachmentFileName = $attachmentObj->getFileName();
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('attachments');
// Go back to article.
camp_html_add_msg($translator->trans("File \$1 unattached.", array('$1' => $attachmentFileName), 'article_files'), "ok");
camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
Example #8
0
 /**
  * Set the workflow state of the article.
  * 	   'Y' = 'Published'
  *     'S' = 'Submitted'
  *     'N' = 'New'
  *
  * @param string $p_value
  * @return boolean
  */
 public function setWorkflowStatus($p_value)
 {
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleIndex.php';
     $p_value = strtoupper($p_value);
     if ($p_value != 'Y' && $p_value != 'S' && $p_value != 'N' && $p_value != 'M') {
         return false;
     }
     // If the article is being published
     if ($this->getWorkflowStatus() != 'Y' && $p_value == 'Y') {
         $this->setProperty('PublishDate', 'NOW()', true, true);
         // send out an article.published event
         self::dispatchEvent("article.published", $this);
         // dispatch blog.published
         $blogConfig = \Zend_Registry::get('container')->getParameter('blog');
         if ($this->getType() == $blogConfig['article_type']) {
             self::dispatchEvent('blog.published', $this, array('number' => $this->getArticleNumber(), 'language' => $this->getLanguageId()));
         }
         $article_images = ArticleImage::GetImagesByArticleNumber($this->getArticleNumber());
         foreach ($article_images as $article_image) {
             $image = $article_image->getImage();
             $user_id = (int) $image->getUploadingUserId();
             //send out an image.published event
             self::dispatchEvent("image.published", $this, array("user" => $user_id));
         }
     }
     // Unlock the article if it changes status.
     if ($this->getWorkflowStatus() != $p_value) {
         $this->setIsLocked(false);
     }
     if ($p_value == 'Y' || $p_value == 'M') {
         $issueObj = new Issue($this->getPublicationId(), $this->getLanguageId(), $this->getIssueNumber());
         if (!$issueObj->exists()) {
             return false;
         }
         $p_value = $issueObj->isPublished() ? 'Y' : 'M';
     }
     $oldStatus = $this->getWorkflowStatus();
     if (!parent::setProperty('Published', $p_value)) {
         return false;
     }
     CampCache::singleton()->clear('user');
     if (function_exists("camp_load_translation_strings")) {
         camp_load_translation_strings("api");
     }
     $logtext = getGS('Article status changed from $1 to $2.', $this->getWorkflowDisplayString($oldStatus), $this->getWorkflowDisplayString($p_value));
     Log::ArticleMessage($this, $logtext, null, 35);
     return true;
 }
    }
    $articlePublishObj = new ArticlePublish();
    $articlePublishObj->create();
    $articlePublishObj->setArticleNumber($tmpArticle->getArticleNumber());
    $articlePublishObj->setLanguageId($tmpArticle->getLanguageId());
    $articlePublishObj->setActionTime($publishTime);
    if ($f_publish_action == "P" || $f_publish_action == "U") {
        $articlePublishObj->setPublishAction($f_publish_action);
    }
    if ($f_front_page_action == "S" || $f_front_page_action == "R") {
        $articlePublishObj->setFrontPageAction($f_front_page_action);
    }
    if ($f_section_page_action == "S" || $f_section_page_action == "R") {
        $articlePublishObj->setSectionPageAction($f_section_page_action);
    }
    Log::ArticleMessage($tmpArticle, $translator->trans('Scheduled action added', array(), 'articles'), $g_user->getUserId(), 37);
}
if ($f_mode == "multi") {
    $args = $_REQUEST;
    unset($args["f_article_code"]);
    $argsStr = camp_implode_keys_and_values($args, "=", "&");
    camp_html_add_msg($translator->trans("Scheduled action added.", array(), 'articles'), "ok");
    camp_html_goto_page("/{$ADMIN}/articles/index.php?" . $argsStr);
} else {
    ?>
	<script type="text/javascript">
    try {
        parent.$.fancybox.reload = true;
        parent.$.fancybox.message = '<?php 
    echo $translator->trans('Actions updated.', array(), 'articles');
    ?>