colas@0: # colas@0: # TWiki Enterprise Collaboration Platform, http://TWiki.org/ colas@0: # colas@0: # Copyright (C) 2000-2006 TWiki Contributors. colas@0: # colas@0: # This program is free software; you can redistribute it and/or colas@0: # modify it under the terms of the GNU General Public License colas@0: # as published by the Free Software Foundation; either version 2 colas@0: # of the License, or (at your option) any later version. For colas@0: # more details read LICENSE in the root of this distribution. colas@0: # colas@0: # This program is distributed in the hope that it will be useful, colas@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of colas@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. colas@0: # colas@0: # As per the GPL, removal of this notice is prohibited. colas@0: package TWiki::Configure::UIs::UPDATE; colas@0: use base 'TWiki::Configure::UI'; colas@0: colas@0: use strict; colas@0: colas@0: use TWiki::Configure::UI; colas@0: use TWiki::Configure::TWikiCfg; colas@0: colas@0: sub ui { colas@0: my ($this, $root, $valuer, $updated) = @_; colas@0: colas@0: $this->{changed} = 0; colas@0: $this->{updated} = $updated; colas@0: colas@0: $this->{output} = CGI::h2('Updating configuration'); colas@0: colas@0: my $logfile; colas@0: $this->{log} = ''; colas@0: $this->{user} = ''; colas@0: if (defined $TWiki::query) { colas@0: $this->{user} = $TWiki::query->remote_user() || ''; colas@0: } colas@0: colas@0: TWiki::Configure::TWikiCfg::save($root, $valuer, $this); colas@0: colas@0: if( $this->{log} && colas@0: defined( $TWiki::cfg{ConfigurationLogName} ) && colas@0: open(F, '>>'.$TWiki::cfg{ConfigurationLogName} )) { colas@0: print F $this->{log}; colas@0: close(F); colas@0: } colas@0: colas@0: # Put in a link to the front page of the TWiki colas@0: my $url = "$TWiki::cfg{DefaultUrlHost}$TWiki::cfg{ScriptUrlPath}/view$TWiki::cfg{ScriptSuffix}/"; colas@0: return $this->{output}.CGI::p().CGI::strong( colas@0: 'Setting ' . $this->{changed}. colas@0: ' configuration item' . (($this->{changed} == 1) ? '' : 's').'.'). colas@0: CGI::p(). colas@0: CGI::a({ href => $url}, "Go to the TWiki front page")." or "; colas@0: } colas@0: colas@0: # Listener for when a saved configuration item is changed. colas@0: sub logChange { colas@0: my ($this, $keys, $value) = @_; colas@0: colas@0: if ($this->{updated}->{$keys}) { colas@0: $this->{output} .= CGI::h3($keys).CGI::code($value); colas@0: $this->{changed}++; colas@0: $this->{log} .= '| '.gmtime().' | '.$this->{user}.' | '.$keys.' | '. colas@0: $value," |\n"; colas@0: } colas@0: } colas@0: colas@0: 1;