t('Automatically gives a random username to anonymous users.'), 'weight' => 10, ); } function tribune_pokemon_filter(&$post, &$help) { global $user; if (!$user->uid and $post) { if (!tribune_variable_get('tribune_pokemon_allow_custom_name', true) or !isset($_SESSION['tribune_nickname'])) { if (!isset($_SESSION['tribune_pokemon'])) { $_SESSION['tribune_pokemon'] = tribune_pokemon_random_pokemon(); } $post['info'] = $_SESSION['tribune_pokemon']; } } } function tribune_pokemon_settings() { global $tribune_pokemon_default_pokemons; $form = array(); $form['tribune_pokemon_allow_custom_name'] = array( '#type' => "checkbox", '#title' => t("Allow users to choose their name (with the \"nick\" filter)"), '#default_value' => tribune_variable_get('tribune_pokemon_allow_custom_name', true), ); $form['tribune_pokemon_names'] = array( '#type' => "textarea", '#title' => t("Available names"), '#default_value' => tribune_variable_get('tribune_pokemon_names', $tribune_pokemon_default_pokemons), '#description' => t("One name per line"), ); return tribune_settings_form($form); } function tribune_pokemon_random_pokemon() { global $tribune_pokemon_default_pokemons; $pokemons = explode("\n", trim(tribune_variable_get('tribune_pokemon_names', $tribune_pokemon_default_pokemons))); $pokemon = $pokemons[rand(0, count($pokemons) - 1)]; return trim($pokemon); } $tribune_pokemon_default_pokemons = <<