<?php
// vim:filetype=php expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent smartindent
function tribune_pokemon_info() {
'description' => t('Automatically gives a random username to anonymous users.'),
'weight' => 10,
);
}
function tribune_pokemon_filter(&$post, &$help) {
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['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)];
}
$tribune_pokemon_default_pokemons = <<<EOT
<|!REG3XP0!>Blue
Red
Yellow
Green
Amber
Azure
Carmine
Cerise
Cyan
Emerald
Fuchsia
Gray
Indigo
Ivory
Jade
Lavender
Lilac
Magenta
Mauve
Olive
Orange
Peach
Purple
Saffron
Sepia
Teal|>
EOT;