<?php

abstract class Tac_StopHumanSpam_Option_ForumSelector
{
	public static function renderOption(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
	{
		$value = $preparedOption['option_value'];

		$editLink = $view->createTemplateObject('option_list_option_editlink', array(
			'preparedOption' => $preparedOption,
			'canEditOptionDefinition' => $canEdit
		));

		$nodeModel = XenForo_Model::create('XenForo_Model_Node');
					
		$forumOptions = $nodeModel->getNodeOptionsArray($nodeModel->getAllNodes(), $preparedOption['option_value'], false);

		foreach ($forumOptions as &$forumOpt){
			$forumOpt['disabled'] = ($forumOpt['node_type_id'] == "Forum" ? false : true);
		}	
		
		
		$forumOptions[0] = array
		(
			'value' => 0,
			'label' => 'None',
			'selected' => false,
			'depth' => 0,
			'node_type_id' => 0
		);
		sort($forumOptions);


		
		return $view->createTemplateObject('option_list_option_multi_shs', array(
			'fieldPrefix' => $fieldPrefix,
			'listedFieldName' => $fieldPrefix . '_listed[]',
			'preparedOption' => $preparedOption,
			'formatParams' => $forumOptions,
			'editLink' => $editLink
		));
	}
}