private function getArticle($number, $language, $user)
 {
     $em = $this->container->get('em');
     $languageObject = $em->getRepository('Newscoop\\Entity\\Language')->findOneByCode($language);
     // Fetch article
     $articleObj = new \Article($languageObject->getId(), $number);
     if (!$articleObj->exists()) {
         throw new NewscoopException('Article does not exist');
     }
     if (!$articleObj->userCanModify($user)) {
         throw new AccessDeniedException('User cannot modify article.');
     }
     // Only users with a lock on the article can change it.
     if ($articleObj->isLocked() && $user->getUserId() != $articleObj->getLockedByUser()) {
         $lockTime = new \DateTime($articleObj->getLockTime());
         $now = new \DateTime('now');
         $difference = $now->diff($lockTime);
         $ago = $difference->format('%R%H:%I:%S');
         $lockUser = new \User($articleObj->getLockedByUser());
         throw new NewscoopException(sprintf('Article locked by %s (%s ago)', $lockUser->getRealName(), $ago));
     }
     return $articleObj;
 }
Example #2
0
        switch ($f_value) {
            case 'New':
                $f_value = 'N';
                break;
            case 'Published':
                $f_value = 'Y';
                break;
            case 'Submitted':
                $f_value = 'S';
                break;
        }
        $access = false;
        // A publisher can change the status in any way he sees fit.
        // Someone who can change an article can submit/unsubmit articles.
        // A user who owns the article may submit it.
        if ($g_user->hasPermission('Publish') || $g_user->hasPermission('ChangeArticle') && $f_value != 'Y' || $articleObj->userCanModify($g_user) && $f_value == 'S') {
            $access = true;
        }
        // If the article is not yet categorized, force it to be before publication.
        if ($f_action_workflow == "Y" && ($articleObj->getPublicationId() == 0 || $articleObj->getIssueNumber() == 0 || $articleObj->getSectionNumber() == 0)) {
            //$args = $_REQUEST;
            //$argsStr = camp_implode_keys_and_values($_REQUEST, "=", "&");
            //$argsStr .= "&f_article_code[]=".$f_article_number."_".$f_language_selected;
            //$argsStr .= "&f_mode=single&f_action=publish";
            //camp_html_goto_page("/$ADMIN/articles/duplicate.php?".$argsStr);
        }
        $success = $articleObj->setWorkflowStatus($f_value);
        $message = $translator->trans("Article status set to \$1", array('$1' => $articleObj->getWorkflowDisplayString($f_value)), 'library');
    }
}
if ($affectedArticles == 0 && $success) {
     camp_html_goto_page("/{$ADMIN}/articles/duplicate.php?" . $argsStr);
 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}";
Example #4
0
    $message = getGS("$1 toggled.", """.getGS("On Section Page").""");
}
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'; break;
        case 'Submitted': $f_value = 'S'; break;
        }
        $access = false;
        // A publisher can change the status in any way he sees fit.
        // Someone who can change an article can submit/unsubmit articles.
        // A user who owns the article may submit it.
        if ($g_user->hasPermission('Publish')
                || ($g_user->hasPermission('ChangeArticle') && ($f_value != 'Y'))
                || ($articleObj->userCanModify($g_user) && ($f_value == 'S') )) {
            $access = true;
        }

        // If the article is not yet categorized, force it to be before publication.
        if (($f_action_workflow == "Y")
                && (($articleObj->getPublicationId() == 0)
                || ($articleObj->getIssueNumber() == 0) || ($articleObj->getSectionNumber() == 0))) {
            //$args = $_REQUEST;
            //$argsStr = camp_implode_keys_and_values($_REQUEST, "=", "&");
            //$argsStr .= "&f_article_code[]=".$f_article_number."_".$f_language_selected;
            //$argsStr .= "&f_mode=single&f_action=publish";
            //camp_html_goto_page("/$ADMIN/articles/duplicate.php?".$argsStr);
        }

        $success = $articleObj->setWorkflowStatus($f_value);