Skip to content

Commit

Permalink
Change Enable beta path text field to a simpler boolean checkbox only
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Mar 13, 2012
1 parent 27be82c commit 96a17fe
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 56 deletions.
39 changes: 37 additions & 2 deletions tests/TestOfCheckVersionController.php
Expand Up @@ -76,8 +76,8 @@ public function testOptedOut() {
$results = $controller->go();
$this->assertNoPattern('/You must <a href="\/session\/login.php">log in<\/a> to do this/', $results);
$this->assertPattern('/var ROOT = \'thinkup_version\'/', $results);
$this->assertPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php\?v='.$THINKUP_VERSION.
'\&usage=n/', $results);
$this->assertPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php\?usage=n\&v='.$THINKUP_VERSION.
'/', $results);
}

public function testNotOptedOut() {
Expand All @@ -91,4 +91,39 @@ public function testNotOptedOut() {
$this->assertNoPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php?v='.$THINKUP_VERSION.
'\&usage=n/', $results);
}

public function testInBetaNotOptedOut() {
include THINKUP_WEBAPP_PATH.'install/version.php';
$bvalues = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'is_subcribed_to_beta',
'option_value' => 'true');
$bdata = FixtureBuilder::build('options', $bvalues);

$this->simulateLogin('me@example.com');
$controller = new CheckVersionController(true);

$results = $controller->go();
$this->assertPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php\?channel=beta\&v='.
$THINKUP_VERSION.'/', $results);
$this->assertNoPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php?v='.$THINKUP_VERSION.
'\&usage=n/', $results);
}

public function testInBetaOptedOut() {
include THINKUP_WEBAPP_PATH.'install/version.php';
$bvalues = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'is_subcribed_to_beta',
'option_value' => 'true');
$bdata = FixtureBuilder::build('options', $bvalues);
$bvalues1 = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'is_opted_out_usage_stats',
'option_value' => 'true');
$bdata2= FixtureBuilder::build('options', $bvalues);

$this->simulateLogin('me@example.com');
$controller = new CheckVersionController(true);

$results = $controller->go();
$this->assertPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php\?channel=beta\&v='.
$THINKUP_VERSION.'/', $results);
$this->assertNoPattern('/var CONTENT_URL = \'http:\/\/thinkupapp.com\/version.php?v='.$THINKUP_VERSION.
'\&usage=n/', $results);
}
}
17 changes: 16 additions & 1 deletion webapp/_lib/controller/class.CheckVersionController.php
Expand Up @@ -34,7 +34,22 @@ public function authControl() {
$this->setContentType('text/javascript');
$this->setViewTemplate('install.checkversion.tpl');
$config = Config::getInstance();
$this->addToView('is_opted_out_usage_stats', $config->getValue('is_opted_out_usage_stats'));

$is_in_beta = $config->getValue('is_subcribed_to_beta');
$is_in_beta = isset($is_in_beta)?$is_in_beta:false;
if ($is_in_beta) {
$upgrade_checker_url = 'http://thinkupapp.com/version.php?channel=beta&';
} else {
$upgrade_checker_url = 'http://thinkupapp.com/version.php?';
}

$opt_out = $config->getValue('is_opted_out_usage_stats');
$opt_out = isset($opt_out)?$opt_out:false;
if ( $opt_out) {
$upgrade_checker_url .= 'usage=n&';
}
$upgrade_checker_url .= 'v='.$config->getValue('THINKUP_VERSION');
$this->addToView('checker_url', $upgrade_checker_url);
return $this->generateView();
}
}
15 changes: 3 additions & 12 deletions webapp/_lib/model/class.AppConfig.php
Expand Up @@ -117,22 +117,13 @@ class AppConfig {
'match' => '/^[0-9]{1,}$/',
'match_message' => ' be numeric'
),
'enable_beta_update_path' => array(
'is_subcribed_to_beta' => array(

This comment has been minimized.

Copy link
@ginatrapani

ginatrapani Mar 13, 2012

Author Member

TYPO! subcribed

'type' => 'checkbox',
'title' => 'Enable Beta Update Path',
'title' => 'Get beta upgrades',
'required' => false,
'default' => 'false',
'match' => '/^true$/',
'match_message' => 'Must be true',
'dependencies' => array('beta_update_path')
),
'beta_update_path' => array(
'type' => 'text',
'title' => 'Beta Update Path Url',
'required' => false,
'match' => '/^(http(s)?:\/\/\w|\/\w)/',
'match_message' => 'be a valid URL',
'default' => '',
'match_message' => 'Must be true'
)
);

Expand Down
9 changes: 5 additions & 4 deletions webapp/_lib/model/class.AppUpgraderClient.php
Expand Up @@ -36,10 +36,11 @@ class AppUpgraderClient {
* @return AppUpgraderClient
*/
public function __construct() {
$option_dao = DAOFactory::getDAO('OptionDAO');
$beta_path = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'beta_update_path');
if (isset($beta_path)) {
self::$UPDATE_URL = $beta_path->option_value;
$config = Config::getInstance();
$is_in_beta = $config->getValue('is_subcribed_to_beta');
$is_in_beta = isset($is_in_beta)?$is_in_beta:false;
if ($is_in_beta) {
self::$UPDATE_URL = 'http://thinkupapp.com/version_download_beta.php';
}

This comment has been minimized.

Copy link
@mwilkie

mwilkie Mar 13, 2012

Contributor

one thing I would suggest is to move that url up into a static var like UPDATE_URL, maybe $BETA_UPDATE_URL

This comment has been minimized.

Copy link
@ginatrapani

ginatrapani Mar 13, 2012

Author Member

Good suggestion. Fixed that, the typo, and a couple of other things in 697c994.

}
/**
Expand Down
21 changes: 4 additions & 17 deletions webapp/_lib/view/account.appconfig.tpl
Expand Up @@ -154,32 +154,19 @@
</div>

<div style="float: left;">
<label for="enable_beta_update_path">
Enable Beta Update Path:
<label for="is_subcribed_to_beta">
Enable beta upgrades:
<br>
</label>
</div>
<div style="float: left;">
<input type="checkbox" name="enable_beta_update_path" id="enable_beta_update_path" value="true">
<input type="checkbox" name="is_subcribed_to_beta" id="is_subcribed_to_beta" value="true">
</div>
<div style="clear:both;"></div>
<div style="font-size: 12px; color : #555; margin: 0px 0px 10px 0px;">
Beta Update Path Docs link...
Test bleeding edge, beta upgrades. May require command line server access. Proceed at your own risk.
</div>

<div id="enable_beta_update_path_deps" style="display: none; width: 470px; margin: 10px 0px 60px 20px;">
<div style="float: left;">
<label for="beta_update_path">
Beta Path Url:
</label>
</div>
<div>
<input type="text" name="beta_update_path" id="beta_update_path" value=""
style="width: 320px; font-size: 11px; margin-left: 10px;">
</div>
<div style="clear:both;"></div>
</div>

<div style="text-align: center" id="save_setting_image">
<img id="save_setting_image" src="{$site_root_path}assets/img/loading.gif" width="31" height="31"
style="display: none; margin: 10px;"/>
Expand Down
4 changes: 2 additions & 2 deletions webapp/_lib/view/install.checkversion.tpl
@@ -1,5 +1,5 @@
{literal}ThinkUpAppVersion = new function() {
var CONTENT_URL = 'http://thinkupapp.com/version.php?v={/literal}{$thinkup_version}{if $is_opted_out_usage_stats}&usage=n{/if}{literal}';
var CONTENT_URL = '{/literal}{$checker_url}{literal}';
var ROOT = 'thinkup_version';
function requestContent( local ) {
Expand All @@ -18,7 +18,7 @@
var txt = '';
// console.debug(data);
// console.debug('version ' + data[0].version);
txt += ' | <a href="http://thinkupapp.com/docs/install/upgrade.html">'+data[0].version+'</a>';
txt += ' | <a href="install/upgrade-application.php">'+data[0].version+'</a>';
div.innerHTML = txt; // assign new HTML into #ROOT
div.style.display = 'inline'; // make element visible
}
Expand Down
18 changes: 0 additions & 18 deletions webapp/assets/js/appconfig.js
Expand Up @@ -73,24 +73,6 @@ var TUApplicationSettings = function() {
$('#recaptcha_enable_deps').hide();
}
});

$('#enable_beta_update_path')
.click(
function(event) {
var checked = $('#enable_beta_update_path:checked').val() ? true : false;
if (tu_app_settings.DEBUG) {
console
.log(
"beta path enable setting checkbox selected, value = %s",
checked);
}
if (checked) {
$('#enable_beta_update_path_deps').show();
} else {
$('#enable_beta_update_path_deps').hide();
}
});

if (document.location.href.match(/#app_settings/)) {
if (tu_app_settings.DEBUG) {
console
Expand Down

0 comments on commit 96a17fe

Please sign in to comment.