.
*
*
* Author: Yu-Jie Lin
* Creation Date: 2007-10-29T07:43:42+0800
*/
function GAOptions() {
$options = bb_get_option('GAOptions');
if (isset($_POST['manage'])) {
switch($_POST['manage']) {
case __('Reset All Options', GRAVATAR_DOMAIN):
$options = GAGetAllDefaultOptions();
bb_update_option('GAOptions', $options);
echo '
' . __('All options are reseted!', GRAVATAR_DOMAIN) . '
';
break;
case __('Deactivate Plugin', GRAVATAR_DOMAIN):
$plugin_file = dirname(bb_plugin_basename(__FILE__)) . '/Gravatar.php';
wp_redirect(str_replace('&', '&', bb_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", "deactivate-plugin_$plugin_file")) . '&by=plugin');
break;
}
}
elseif (isset($_POST['updateGeneralOptions'])) {
switch($_POST['updateGeneralOptions']) {
case __('Save', GRAVATAR_DOMAIN):
$newOptions = array();
$newOptions['useRegisteredEmail'] = ($_POST['useRegisteredEmail'] == 'true') ? true : false;
$newOptions['rating'] = $_POST['rating'];
$newOptions['size'] = $_POST['size'];
$options = array_merge($options, $newOptions);
bb_update_option('GAOptions', $options);
echo '' . __('General options saved!', GRAVATAR_DOMAIN) . '
';
break;
case __('Reset', GRAVATAR_DOMAIN):
$options = array_merge($options, GAGetDefaultGeneralOptions());
bb_update_option('GAOptions', $options);
echo '' . __('General options reseted!', GRAVATAR_DOMAIN) . '
';
break;
}
}
elseif (isset($_POST['updateImageOptions'])) {
switch($_POST['updateImageOptions']) {
case __('Save', GRAVATAR_DOMAIN):
$newOptions = array();
$newOptions['defaultImage'] = $_POST['defaultImage'];
// Find default image URIs for roles
foreach ($_POST as $name => $value) {
if (preg_match('/defaultImage\-(.+)/', $name, $match)) {
if (empty($_POST[$name]))
unset($options['defaultRoleImages'][$match[1]]);
else
$newOptions['defaultRoleImages'][$match[1]] = $value;
}
}
$options = array_merge($options, $newOptions);
bb_update_option('GAOptions', $options);
echo '' . __('Image options saved!', GRAVATAR_DOMAIN) . '
';
break;
case __('Reset', GRAVATAR_DOMAIN):
$options = array_merge($options, GAGetDefaultImageOptions());
unset($options['defaultRoleImages']);
bb_update_option('GAOptions', $options);
echo '' . __('Image options reseted!', GRAVATAR_DOMAIN) . '
';
break;
}
}
// Render options page
?>