other options

This commit is contained in:
John Bintz 2009-08-13 19:36:47 -04:00
parent 33358a4ec2
commit e2c5b30173
2 changed files with 31 additions and 0 deletions

View File

@ -62,6 +62,23 @@ class WhatDidTheySayAdmin {
$this->_update_options('allowed_users', $allowed_users); $this->_update_options('allowed_users', $allowed_users);
} }
function handle_update_options($requested_options) {
$updated_options = array(
'only_allowed_users' => false
);
foreach ($requested_options as $option => $value) {
switch ($option) {
case 'only_allowed_users':
$updated_options['only_allowed_users'] = true;
break;
}
}
$options = array_merge(get_option('what-did-they-say-options'), $updated_options);
update_option('what-did-they-say-options', $options);
}
function read_language_file() { function read_language_file() {
if (file_exists($this->language_file)) { if (file_exists($this->language_file)) {
foreach (file($this->language_file, FILE_IGNORE_NEW_LINES) as $language) { foreach (file($this->language_file, FILE_IGNORE_NEW_LINES) as $language) {

View File

@ -38,6 +38,20 @@ class WhatDidTheySayAdminTest extends PHPUnit_Framework_TestCase {
$options = get_option('what-did-they-say-options'); $options = get_option('what-did-they-say-options');
$this->assertEquals(array(1), $options['allowed_users']); $this->assertEquals(array(1), $options['allowed_users']);
} }
function testHandleUpdateOptions() {
$admin = new WhatDidTheySayAdmin();
update_option('what-did-they-say-options', array('only_allowed_users' => false));
$admin->handle_update_options(array(
'only_allowed_users' => 'yes'
));
$options = get_option('what-did-they-say-options');
$this->assertTrue($options['only_allowed_users']);
}
} }
?> ?>