diff --git a/acp/portal_module.php b/acp/portal_module.php index 474ad0cf..85ec7ce4 100644 --- a/acp/portal_module.php +++ b/acp/portal_module.php @@ -15,7 +15,7 @@ class portal_module public $new_config = array(); protected $c_class; protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container; - protected $root_path, $version_check, $request, $php_ext, $portal_helper; + protected $root_path, $version_check, $request, $php_ext, $portal_helper, $modules_helper; public $module_column = array(); public function __construct() @@ -41,6 +41,7 @@ class portal_module $this->phpbb_container = $phpbb_container; $this->version_check = $this->phpbb_container->get('board3.version.check'); $this->portal_helper = $this->phpbb_container->get('board3.portal.helper'); + $this->modules_helper = $this->phpbb_container->get('board3.portal.modules_helper'); define('PORTAL_MODULES_TABLE', $this->phpbb_container->getParameter('board3.modules.table')); define('PORTAL_CONFIG_TABLE', $this->phpbb_container->getParameter('board3.config.table')); @@ -331,7 +332,14 @@ class portal_module } else { - $func = $vars['method']; + if ($vars['method'][0] == 'board3.portal.modules_helper') + { + $func = array($this->modules_helper, $vars['method'][1]); + } + else + { + $func = $vars['method']; + } } $content = call_user_func_array($func, $args); } diff --git a/includes/modules_helper.php b/includes/modules_helper.php index ff18fa9d..e366aeac 100644 --- a/includes/modules_helper.php +++ b/includes/modules_helper.php @@ -65,10 +65,42 @@ class modules_helper $options = ''; return $options; } + + /** + * Generate forum select box + * + * @param string $value Value of select box + * @param string $key Key of select box + * + * @return string HTML code of select box + * @access public + */ + public function generate_forum_select($value, $key) + { + $forum_list = make_forum_select(false, false, true, true, true, false, true); + + $selected_options = $select_ary = array(); + if(isset($this->config[$key]) && strlen($this->config[$key]) > 0) + { + $selected_options = explode(',', $this->config[$key]); + } + + // Build forum options + foreach ($forum_list as $f_id => $f_row) + { + $select_ary[] = array( + 'value' => $f_id, + 'title' => $f_row['padding'] . $f_row['forum_name'], + 'disabled' => $f_row['disabled'], + ); + } + + return $this->generate_select_box($key, $select_ary, $selected_options); + } } diff --git a/modules/attachments.php b/modules/attachments.php index d86b52ae..8780d471 100644 --- a/modules/attachments.php +++ b/modules/attachments.php @@ -121,7 +121,7 @@ class attachments extends module_base 'legend1' => 'ACP_PORTAL_ATTACHMENTS_NUMBER_SETTINGS', 'board3_attachments_number_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_NUMBER' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), 'board3_attach_max_length_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_MAX_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), - 'board3_attachments_forum_ids_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FORUM_IDS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'), + 'board3_attachments_forum_ids_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FORUM_IDS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => array('board3.portal.modules_helper', 'generate_forum_select'), 'submit' => 'store_selected_forums'), 'board3_attachments_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FORUM_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_attachments_filetype_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FILETYPE', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_filetype', 'submit' => 'store_filetypes'), 'board3_attachments_exclude_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), diff --git a/tests/unit/acp/move_module_test.php b/tests/unit/acp/move_module_test.php index 5d1aaea1..a76d389b 100644 --- a/tests/unit/acp/move_module_test.php +++ b/tests/unit/acp/move_module_test.php @@ -39,6 +39,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data new \board3\portal\modules\donation($config, $template, $user), )); $phpbb_container->set('board3.portal.helper', new \board3\portal\includes\helper($phpbb_container->get('board3.module_collection'))); + $phpbb_container->set('board3.portal.modules_helper', new \board3\portal\includes\modules_helper(new \phpbb\auth\auth())); $phpbb_container->setParameter('board3.modules.table', $table_prefix . 'portal_modules'); $phpbb_container->setParameter('board3.config.table', $table_prefix . 'portal_config'); $cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put')); diff --git a/tests/unit/includes/fixtures/auth.xml b/tests/unit/includes/fixtures/auth.xml index 03bcb3f5..84a5d919 100644 --- a/tests/unit/includes/fixtures/auth.xml +++ b/tests/unit/includes/fixtures/auth.xml @@ -17,12 +17,14 @@