Permalink
Browse files

App Upgrader tweaks

Rename templates (style guide); make file permission error message more informative
  • Loading branch information...
1 parent 697c994 commit e4724e1421dbe03138909e97bbf1158b6a5252d8 @ginatrapani ginatrapani committed Mar 13, 2012
@@ -39,7 +39,7 @@ class UpgradeApplicationController extends ThinkUpAuthController {
*/
public function __construct($session_started=false) {
parent::__construct($session_started);
- $this->setViewTemplate('install.update.tpl');
+ $this->setViewTemplate('install.upgrade-application.tpl');
}
public function authControl() {
@@ -53,14 +53,14 @@ public function authControl() {
$this->addToView('updated',true);
} else {
$verify_updatable = true;
- $update_info = $this->runUpdate($verify_updatable);
- if (isset($update_info['latest_version'])) {
- $this->addToView('latest_version',$update_info['latest_version']);
- }
- $this->addToView('updateable',true);
try {
+ $update_info = $this->runUpdate($verify_updatable);
+ if (isset($update_info['latest_version'])) {
+ $this->addToView('latest_version',$update_info['latest_version']);
+ }
+ $this->addToView('updateable',true);
} catch(Exception $e) {
- $this->addToView('error',$e->getMessage());
+ $this->addErrorMessage($e->getMessage(), null, true);
}
}
return $this->generateView();
View
@@ -163,7 +163,17 @@ public function backUpInstall() {
*/
public function findAllFiles($file) {
if (!is_writable($file)) {
- throw new Exception("File permissions prevent writing to the ".$file."/ directory.");
+ //throw new Exception("File permissions prevent writing to the ".$file."/ directory.");
+ $config = Config::getInstance();
+ $whoami = @exec('whoami');
+ if (empty($whoami)) {
+ $whoami = 'nobody';
+ }
+ throw new Exception("<b>Oops!</b> ThinkUp is unable to upgrade itself because of incorrect folder ".
+ "permissions. To fix this problem, run<br><br><code>chown -R $whoami ".
+ $config->getValue('source_root_path')."</code><br><br>on your server, using root (or sudo), and then ".
+ "reload this page to continue.<br /><br /> If you don't have root access, use the following command ".
+ "instead:<br><br> <code>chmod -R 664 ".$config->getValue('source_root_path')."</code><br><br>");
}
$root = scandir($file);
foreach($root as $value) {
@@ -247,7 +257,17 @@ public function validateUpdatePermissions($app_path) {
$app_files = $this->findAllFiles($app_path);
foreach($app_files as $file) {
if (!is_writable($file)) {
- throw new Exception("File $file is not writable. Unable to continue update.");
+ //throw new Exception("File $file is not writable. Unable to continue update.");
+ $config = Config::getInstance();
+ $whoami = @exec('whoami');
+ if (empty($whoami)) {
+ $whoami = 'nobody';
+ }
+ throw new Exception("<b>Oops!</b> ThinkUp is unable to upgrade itself because of incorrect folder ".
+ "permissions. To fix this problem, run<br><br><code>chown -R $whoami ".
+ $config->getValue('source_root_path')."</code><br><br>on your server, using root (or sudo), and then ".
+ "reload this page to continue.<br /><br /> If you don't have root access, use the following command ".
+ "instead:<br><br> <code>chmod -R 664 ".$config->getValue('source_root_path')."</code><br><br>");
}
}
}
@@ -1,28 +1,27 @@
{include file="_header.tpl"}
{include file="_statusbar.tpl"}
-
<div class="container_24 thinkup-canvas round-all clearfix" style="margin-top : 10px;">
+ <h1>Upgrade ThinkUp's Application Code</h1>
<div class="clearfix prepend_20 append_20">
- <div class="grid_22 push_1 clearfix alert stats">
+
+ {include file="_usermessage.tpl"}
{if $updateable}
- <h1>Update Your ThinkUp Install</h1>
- <p>Your install is ready to run a web based update
- {if $latest_version} to version <b>{$latest_version}</b>{/if}.</p>
+ <div class="grid_22 push_1 clearfix alert stats">
+ <p>Ready to upgrade {if $latest_version} to version <b>{$latest_version}</b>{/if}.</p>
<p>
- <a href="{$site_root_path}install/update.php?run_update=1" onclick="$('#update-spinner').show();">
- Run the web update</a>
+ <a href="{$site_root_path}install/update-application.php?run_update=1" onclick="$('#update-spinner').show();">
+ Upgrade ThinkUp</a>
</p>
<p id="update-spinner" style="text-align: center; display: none;">
<img src="{$site_root_path}assets/img/loading.gif" width="31" height="31" />
</p>
{/if}
{if $updated}
- <h1>ThinkUp Install Has Been Updated</h1>
- <p><a href="{$site_root_path}install/upgrade-database.php">Run any database updates needed.</a></p>
+ <h1>Success! ThinkUp's Application Code Has Been Upgraded</h1>
+ <p><a href="{$site_root_path}install/upgrade-database.php">Upgrade your database.</a></p>
{/if}
-
</div>
</div>
</div>

0 comments on commit e4724e1

Please sign in to comment.