Example #1
0
    /**
     * @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;
// If the article has not been touched in 24 hours
$timeDiff = camp_time_diff_str($articleObj->getLockTime());
if ($timeDiff['days'] > 0) {
    $articleObj->setIsLocked(FALSE);
    $locked = FALSE;
} elseif ($articleObj->getLockedByUser() != 0 && !$lockUserObj->exists()) {
    // If the user who locked the article doesnt exist anymore, unlock the article
    $articleObj->setIsLocked(FALSE);
    $locked = FALSE;
}
//
// Automatic locking
//
// If the article has not been unlocked and is not locked by a user.
if ($f_unlock === FALSE) {
    if (!$articleObj->isLocked()) {
        // Lock the article
        $articleObj->setIsLocked(TRUE, $g_user->getUserId());
    }
 case "move":
     $args = $_REQUEST;
     unset($args[SecurityToken::SECURITY_TOKEN]);
     unset($args["f_article_code"]);
     $argsStr = camp_implode_keys_and_values($args, "=", "&");
     $argsStr .= "&f_mode=multi&f_action=move";
     foreach ($_REQUEST["f_article_code"] as $code) {
         $argsStr .= "&f_article_code[]={$code}";
     }
     camp_session_set($offsetVarName, 0);
     camp_html_goto_page("/{$ADMIN}/articles/duplicate.php?" . $argsStr);
 case "unlock":
     foreach ($articleCodes as $articleCode) {
         $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
         if ($articleObj->userCanModify($g_user)) {
             $articleObj->setIsLocked(false);
         }
     }
     camp_html_add_msg(getGS("Article(s) unlocked."), "ok");
     break;
 case "context_box_update":
     camp_html_add_msg(getGS("Context Box updated"), "ok");
     break;
 case "schedule_publish":
     $args = $_REQUEST;
     unset($args[SecurityToken::SECURITY_TOKEN]);
     unset($args["f_article_code"]);
     $argsStr = camp_implode_keys_and_values($args, "=", "&");
     foreach ($_REQUEST["f_article_code"] as $code) {
         $argsStr .= "&f_article_code[]={$code}";
     }
 /**
  * Creates an legacy Article based on a feed entry
  *
  * @param \NewscoopIngestPluginBundle\Entity\Feed\Entry $entry
  *
  * @return \Article Returns legacy article opbject
  */
 protected function createLegacy(\Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry)
 {
     $feed = $entry->getFeed();
     $publication = $feed->getPublication();
     // Determine issue
     if ($feed->getIssue() === null) {
         $issue = $this->em->getRepository('\\Newscoop\\Entity\\Issue')->findOneBy(array('publication' => $publication, 'language' => $entry->getLanguage(), 'workflowStatus' => 'Y'), array('number' => 'DESC'));
     } else {
         $issue = $feed->getIssue();
     }
     $articleType = $this->em->getRepository('\\Newscoop\\Entity\\ArticleType')->findOneByName('Newswire');
     $article = new \Article($entry->getLanguage()->getId());
     $createSuccess = $article->create($articleType->getName(), $entry->getTitle(), $publication->getId(), $issue->getNumber(), $entry->getSection()->getNumber());
     $article->setCreatorId(1);
     $article->setWorkflowStatus('N');
     $article->setKeywords(implode(',', $entry->getKeywords()));
     $article->setCommentsEnabled(1);
     $article->setIsLocked(false);
     // ArticleType data
     $this->setArticleDataLegacy($article, $entry);
     // Dates
     $article->setCreationDate($entry->getCreated()->format('Y-m-d H:i:s'));
     $article->setProperty('time_updated', $entry->getUpdated()->format('Y-m-d H:i:s'));
     // Author
     $this->setArticleAuthorsLegacy($article, $entry);
     $this->setArticleImagesLegacy($article, $entry);
     try {
         $entry->setArticleId($article->getArticleNumber());
         $articleAdded = $article->commit();
         $this->em->persist($entry);
         $this->em->flush();
     } catch (\Exception $e) {
         throw new Exception('Could not publish article.');
     }
     // Topics
     $this->setArticleTopics($article->getArticleNumber(), $entry->getFeed()->getTopics());
     // Webcode
     $articleEntity = $this->em->getRepository('Newscoop\\Entity\\Article')->findOneByNumber($article->getArticleNumber());
     if (!is_null($articleEntity)) {
         $this->webcode->setArticleWebcode($articleEntity);
     }
     return $article;
 }