Skip to content

Commit

Permalink
Item9945: Updates to extension installer
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x01@9869 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Nov 5, 2010
1 parent a0adb41 commit 3a633c4
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 66 deletions.
176 changes: 121 additions & 55 deletions core/bin/configure
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ sub _actionSavechanges {

my ( $authorised, $messageType ) = Foswiki::Configure::UI::authorised();
if ( !$authorised ) {
_screenAuthorize($messageType);
_screenAuthorize('UPDATE', $messageType);
}
else {
_screenFeedback($messageType);
Expand All @@ -497,17 +497,8 @@ sub _actionSavechanges {

# Screen that prompts for a password
sub _screenAuthorize {
my ($messageType) = @_;
my ($transact, $messageType) = @_;
my $contents = '';
my $valuer =
new Foswiki::Configure::Valuer( $Foswiki::defaultCfg, \%Foswiki::cfg );
my %updated;
my $modified = $valuer->loadCGIParams( $Foswiki::query, \%updated );
my $changesList = ();
foreach my $key ( sort keys %updated ) {
my $valueString = $query->param($key);
push( @{$changesList}, { key => $key, value => $valueString } );
}

# create the root of the UI
my $root = new Foswiki::Configure::Root();
Expand All @@ -516,7 +507,6 @@ sub _screenAuthorize {
my $params = '';
my $hasPassword = ( $Foswiki::cfg{Password} ne '' ) || 0;

@items = sort keys %updated if $modified;

$ui = _checkLoadUI( 'AUTH', $root );
return '' unless $ui;
Expand All @@ -525,21 +515,94 @@ sub _screenAuthorize {
my $contentTemplate =
Foswiki::Configure::UI::getTemplateParser()->readTemplate('authorize');
my $changePassword = $Foswiki::query->param('changePassword') || undef;
Foswiki::Configure::UI::getTemplateParser()->parse(
$contentTemplate,
{
'main' => $contents,
'hasPassword' => $hasPassword,
'modifiedCount' => $modified,
'items' => \@items,
'changesList' => $changesList,
'params' => $params,
'messageType' => $messageType,
'formAction' => $scriptName,
'configureUrl' => $url,
'changePassword' => $changePassword,

# displayStatus - 1 = No Changes, 2 = Changes, 4 = No Extensions, 8 = Extensions

if ( $transact eq 'UPDATE' ) {
my $valuer =
new Foswiki::Configure::Valuer( $Foswiki::defaultCfg, \%Foswiki::cfg );
my %updated;
my $modified = $valuer->loadCGIParams( $Foswiki::query, \%updated );
my $changesList = ();
foreach my $key ( sort keys %updated ) {
my $valueString = $query->param($key);
push( @{$changesList}, { key => $key, value => $valueString } );
}
);
@items = sort keys %updated if $modified;
my @dummy = ();
my $displayStatus = ( $modified ) ? 2 : 1;

Foswiki::Configure::UI::getTemplateParser()->parse(
$contentTemplate,
{
'main' => $contents,
'hasPassword' => $hasPassword,
'formAction' => $scriptName,
'displayStatus' => $displayStatus,
'modifiedCount' => $modified,
'items' => \@items,
'changesList' => $changesList,
'params' => $params,
'messageType' => $messageType,
'configureUrl' => $url,
'changePassword' => $changePassword,
'extAction' => '',
'extAddCount' => 0,
'extRemoveCount' => 0,
'extAddItems' => \@dummy,
'extRemoveItems' => \@dummy,
}
);
}
elsif ( $transact eq 'EXTEND' ) {

my $processExt = $query->param('processExt');
my @remove = ();
my @add = ();

foreach my $ext ( $query->param('remove') ) {
my ($repo, $extn) = split(/\//, $ext);
push (@remove, "<td>$extn</td>");
}

foreach my $ext ( $query->param('add') ) {
my ($repo, $extn) = split(/\//, $ext);
push (@add, "<td>$repo</td><td>$extn</td>");
}

my $action = $processExt eq 'dep' ? 'run a dependency Report'
: $processExt eq 'sim' ? 'Simulate Only'
: $processExt eq 'nodep' ? 'install without Dependencies'
: $processExt eq 'all' ? 'perform all actions'
: $processExt;

my $addCount = scalar @add;
my $removeCount = scalar @remove;
my @dummy = ();
my $displayStatus = ( $addCount || $removeCount ) ? 8 : 4;

Foswiki::Configure::UI::getTemplateParser()->parse(
$contentTemplate,
{
'main' => $contents,
'hasPassword' => $hasPassword,
'formAction' => $scriptName,
'displayStatus' => $displayStatus,
'changesList' => \@dummy,
'modifiedCount' => 0,
'items' => \@dummy,
'extAddCount' => $addCount,
'extRemoveCount' => $removeCount,
'extAddItems' => \@add,
'extRemoveItems' => \@remove,
'params' => $params,
'messageType' => $messageType,
'extAction' => $action,
'configureUrl' => $url,
'changePassword' => $changePassword,
}
);
}

my $html =
Foswiki::Configure::UI::getTemplateParser()->readTemplate('pagebegin');
Expand All @@ -551,6 +614,8 @@ sub _screenAuthorize {
{
'time' => $time,
'formAction' => $scriptName,
'extAddCount' => 0,
'extRemoveCount' => 0,
}
);

Expand Down Expand Up @@ -673,50 +738,51 @@ sub _actionFindMoreExtensions {
# Invoked when extensions are to be (un)installed
sub _actionManageExtensions {

my $html =
Foswiki::Configure::UI::getTemplateParser()->readTemplate('pagebegin');
Foswiki::Configure::UI::getTemplateParser()->parse(
$html,
{
}
);
Foswiki::Configure::UI::getTemplateParser()->cleanupTemplateResidues($html);
print $html;

my $root = new Foswiki::Configure::Root();
my $ui;
if ( !Foswiki::Configure::UI::authorised() ) {

my ( $authorised, $messageType ) = Foswiki::Configure::UI::authorised();

if ( !$authorised ) {
$ui = _checkLoadUI( 'AUTH', $root );
return 1 unless $ui;

# SMELL: this doesn't work - should invoke _screenAuthorize, surely?
print $ui->ui( 0, 'Install ' . ( $query->param('extension') || '' ) );
_screenAuthorize( 'EXTEND', $messageType );
}
else {
my $html =
Foswiki::Configure::UI::getTemplateParser()->readTemplate('pagebegin');
Foswiki::Configure::UI::getTemplateParser()->parse(
$html,
{
}
);
Foswiki::Configure::UI::getTemplateParser()->cleanupTemplateResidues($html);
print $html;
$ui = _checkLoadUI( 'EXTEND', $root );
return 1 unless $ui;

# Warning: the 'install' method uses print for rapid feedback
print $ui->install();
}
$html =
Foswiki::Configure::UI::getTemplateParser()->readTemplate('installed');
$html .=
Foswiki::Configure::UI::getTemplateParser()->readTemplate('pageend');
my $frontpageUrl =
"$Foswiki::cfg{DefaultUrlHost}$Foswiki::cfg{ScriptUrlPath}/view$Foswiki::cfg{ScriptSuffix}/";
Foswiki::Configure::UI::getTemplateParser()->parse(
$html,
{
'frontpageUrl' => $frontpageUrl,
'configureUrl' => $url,
}
);

$html =
Foswiki::Configure::UI::getTemplateParser()->readTemplate('installed');
$html .=
Foswiki::Configure::UI::getTemplateParser()->readTemplate('pageend');
Foswiki::Configure::UI::getTemplateParser()->cleanupTemplateResidues($html);
print $html;
}

my $frontpageUrl =
"$Foswiki::cfg{DefaultUrlHost}$Foswiki::cfg{ScriptUrlPath}/view$Foswiki::cfg{ScriptSuffix}/";
Foswiki::Configure::UI::getTemplateParser()->parse(
$html,
{
'frontpageUrl' => $frontpageUrl,
'configureUrl' => $url,
}
);

Foswiki::Configure::UI::getTemplateParser()->cleanupTemplateResidues($html);
print $html;
}

# This is the default screen
Expand Down
105 changes: 94 additions & 11 deletions core/lib/Foswiki/Configure/templates/authorize.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,34 @@
</div>
</#assign>

<#assign extEnterPassword>
<div class='foswikiFormSteps'>
<div class='foswikiFormStep'>
<h2>In order to process the extension changes, configure requires that you type your password.</h2>
</div>
<div class='foswikiFormStep'>
<p>Password: <input type="password" name='cfgAccess' size='30' maxlength='80' class='foswikiInputField foswikiFocus' />
&nbsp; <input type="submit" class='foswikiSubmit' value='Process extensions' /></p>
</div>
<div class='foswikiFormStep configureFormStepOutside'>
${localNotePasswordForgotten}
</div>
<#if displayStatus == 2>
<div class='foswikiFormStep configureFormStepOutside'>
<p><input type="submit" class='foswikiButton' name='changePassword' value='Change password...' /></p>
</div>
</#if>
</div>
</#assign>

<#assign localNotePasswordForgotten>
<#if displayStatus == 2>
<p>Password forgotten? To reset your password, log in to the server and delete the <code>$Foswiki::cfg{Password} = '...';</code> line from <code>lib/LocalSite.cfg</code>. Then reload this page and create a new password.</p>
</#if>
<#if displayStatus == 8>
<p>Password forgotten? Password cannot be reset from the Extension installation screens. To reset your password, log in to the server and delete the <code>$Foswiki::cfg{Password} = '...';</code> line from <code>lib/LocalSite.cfg</code>.
Then return to configuration and save a configuration change before attempting to install or remove extensions..</p>
</#if>
</#assign>

<#assign localChangePassword>
Expand Down Expand Up @@ -115,25 +141,82 @@
<#if hasPassword == 1 && changePassword??>
${localChangePassword}
</#if>
<#if hasPassword == 1 && !changePassword??>
${localEnterPassword}
</#if>
</form>
<#if hasPassword == 1 && !changePassword??>
${localEnterPassword}
</#if>
</#assign>

<#assign localNoUpdate>
<h2>Nothing to save - you haven't made any changes yet</h2>
<p>Go back in your browser to continue.</p>
<h2>Nothing to do - you haven't made any changes yet</h2>

<p>Go back in your browser to continue.</p>
</#assign>

<#assign extRemove>
<h2>You are about to remove the following
<#if extRemoveCount == 1>
extension
<#else>
${extRemoveCount} extensions
</#if> </h2>
<div class='configureChangeList'>
<table>
<tr><th><b>Extension</b></th></tr>
<#list extRemoveItems as i>
<tr>${i}</tr>
</#list>
</table>
<p>Go back in your browser if you want to make any changes.</p>
</div>
</#assign>

<#assign extAdd>
<h2>You are about to add the following
<#if extAddCount == 1>
extension
<#else>
${extAddCount} extensions
</#if> </h2>
<div class='configureChangeList'>
<table>
<tr><th><b>Repository</b></th><th><b>Extension</b></th></tr>
<#list extAddItems as i>
<tr>${i}</tr>
</#list>
</table>
<p>Go back in your browser if you want to make any changes.</p>
</div>
</#assign>

<#assign extUpdate>
<h1>Configure will ${extAction}</h1>
<#if extRemoveCount == 0>
<h2>No extensions to remove</h2>
<#else>
${extRemove}
</#if>

<#if extAddCount == 0>
<h2>No extensions to install</h2>
<#else>
${extAdd}
</#if>

<form method="post" action="${formAction}" enctype="multipart/form-data" name="foswiki_configure">
<#if params??>${params}</#if>
${extEnterPassword}
</#assign>


<#if messageType == 4><div class="foswikiNotification"> Password changed </div></#if>
<#if messageType == 8><div class="foswikiNotification foswikiAlert"> Password not set. Try again below.</div></#if>
<#if messageType == 16><div class="foswikiNotification foswikiAlert"> Password incorrect. Try again below.</div></#if>
<#if messageType == 32><div class="foswikiNotification foswikiAlert"> New and repeated passwords do not match. Try again below.</div></#if>
<#if messageType == 64><div class="foswikiNotification foswikiAlert"> Please enter a new password.</div></#if>

<#if modifiedCount == 0>
${localNoUpdate}
<#else>
${localUpdate}
</#if>

<#if displayStatus == 1>${localNoUpdate}</#if>
<#if displayStatus == 2>${localUpdate}</#if>
<#if displayStatus == 4>${localNoUpdate}</#if>
<#if displayStatus == 8>${extUpdate}</#if>

0 comments on commit 3a633c4

Please sign in to comment.