/** * @dataProvider module_auth_test_data */ public function test_modules_auth($module_auth, $expected) { global $phpbb_extension_manager, $phpbb_dispatcher; $phpbb_extension_manager = $this->extension_manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array('vendor2/foo' => array('ext_name' => 'vendor2/foo', 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/'), 'vendor3/bar' => array('ext_name' => 'vendor3/bar', 'ext_active' => '0', 'ext_path' => 'ext/vendor3/bar/'))); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $this->assertEquals($expected, p_master::module_auth($module_auth, 0)); }
/** * Simple version of jumpbox, just lists modules */ function make_module_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $ignore_noncat = false) { global $db, $user, $auth, $config; $sql = 'SELECT module_id, module_enabled, module_basename, parent_id, module_langname, left_id, right_id, module_auth FROM ' . MODULES_TABLE . "\n\t\t\tWHERE module_class = '" . $db->sql_escape($this->module_class) . "'\n\t\t\tORDER BY left_id ASC"; $result = $db->sql_query($sql); $right = $iteration = 0; $padding_store = array('0' => ''); $module_list = $padding = ''; while ($row = $db->sql_fetchrow($result)) { if ($row['left_id'] < $right) { $padding .= ' '; $padding_store[$row['parent_id']] = $padding; } else { if ($row['left_id'] > $right + 1) { $padding = isset($padding_store[$row['parent_id']]) ? $padding_store[$row['parent_id']] : ''; } } $right = $row['right_id']; if (!$ignore_acl && $row['module_auth']) { // We use zero as the forum id to check - global setting. if (!p_master::module_auth($row['module_auth'], 0)) { continue; } } // ignore this module? if (is_array($ignore_id) && in_array($row['module_id'], $ignore_id) || $row['module_id'] == $ignore_id) { continue; } // empty category if (!$row['module_basename'] && $row['left_id'] + 1 == $row['right_id'] && $ignore_emptycat) { continue; } // ignore non-category? if ($row['module_basename'] && $ignore_noncat) { continue; } $selected = is_array($select_id) ? in_array($row['module_id'], $select_id) ? ' selected="selected"' : '' : ($row['module_id'] == $select_id ? ' selected="selected"' : ''); $langname = $this->lang_name($row['module_langname']); $module_list .= '<option value="' . $row['module_id'] . '"' . $selected . (!$row['module_enabled'] ? ' class="disabled"' : '') . '>' . $padding . $langname . '</option>'; $iteration++; } $db->sql_freeresult($result); unset($padding_store); return $module_list; }