GetArticlesWithTopic() public static method

Get the Articles that have the given Topic.
public static GetArticlesWithTopic ( integer $p_topicId ) : array
$p_topicId integer
return array
Example #1
0
}
if (!$g_user->hasPermission('ManageTopics')) {
    camp_html_display_error(getGS("You do not have the right to delete topics."));
    exit;
}
$f_confirmed = Input::Get('f_confirmed', 'int', 0);
$f_topic_language_id = Input::Get('f_topic_language_id', 'int', 0);
$f_topic_delete_id = Input::Get('f_topic_delete_id', 'int', 0);
$errorMsgs = array();
$doDelete = true;
$deleteTopic = new Topic($f_topic_delete_id);
if ($deleteTopic->hasSubtopics()) {
    $doDelete = false;
    $errorMsgs[] = getGS('This topic has subtopics, therefore it cannot be deleted.');
}
$numArticles = count(ArticleTopic::GetArticlesWithTopic($f_topic_delete_id));
if ($numArticles > 0) {
    $doDelete = false;
    $errorMsgs[] = getGS('There are $1 articles using the topic.', $numArticles);
}
if ($f_confirmed == 1) {
    // get a list of subtopics
    $deleteTopics = $deleteTopic->getSubtopics();
    // detach all subtopics from all articles
    foreach ($deleteTopics as $topic) {
        ArticleTopic::RemoveTopicFromArticles($topic->getTopicId());
    }
    // delete all subtopics
    foreach ($deleteTopics as $topic) {
        $topic->delete($f_topic_language_id);
    }