function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors) { $p_errors = array(); $articles = Article::GetArticlesOfType($p_sourceField->getArticleType()); foreach ($articles as $article) { $articleData = $article->getArticleData(); $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName())); if (empty($authorName)) { continue; } $author = new Author($authorName); if (!$author->exists()) { if (!$author->create()) { $p_errors[] = getGS('Unable to create author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType()); continue; } } if (!$article->setAuthorId($author->getId())) { $p_errors[] = getGS('Error setting the author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType()); continue; } } return count($p_errors); }
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors) { $translator = \Zend_Registry::get('container')->getService('translator'); $p_errors = array(); $articles = Article::GetArticlesOfType($p_sourceField->getArticleType()); foreach ($articles as $article) { $articleData = $article->getArticleData(); $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName())); if (empty($authorName)) { continue; } $author = new Author($authorName); if (!$author->exists()) { if (!$author->create()) { $p_errors[] = $translator->trans('Unable to create author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home'); continue; } } if (!$article->setAuthorId($author->getId())) { $p_errors[] = $translator->trans('Error setting the author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home'); continue; } } $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('authors'); $cacheService->clearNamespace('article'); return count($p_errors); }
exit; } // Check permissions if (!$g_user->hasPermission('DeleteArticleTypes')) { camp_html_display_error(getGS("You do not have the right to delete article types.")); exit; } $articleTypeName = Input::Get('f_article_type'); $doDelete = true; $errorMsgs = array(); if ($doDelete) { $articleType = new ArticleType($articleTypeName); $articles = Article::GetArticlesOfType($articleTypeName); foreach ($articles as $a) { $a->delete(); } $articleType->delete(); camp_html_goto_page("/$ADMIN/article_types/"); } else { $errorMsgs[] = getGS('The article type $1 could not be deleted.', '<B>'.htmlspecialchars($articleTypeName).'</B>'); } $crumbs = array(); $crumbs[] = array(getGS("Configure"), ""); $crumbs[] = array(getGS("Article Types"), "/$ADMIN/article_types/"); $crumbs[] = array(getGS("Delete article type $1", $articleTypeName), "");