bugfixes from session conversion

This commit is contained in:
JT Smith 2006-01-12 23:13:18 +00:00
parent a66fe79ea4
commit 4b439f610e
4 changed files with 16 additions and 41 deletions

View file

@ -214,7 +214,7 @@ sub www_editBranch {
} }
my $clause; my $clause;
if ($self->session->user->isInGroup(3)) { if ($self->session->user->isInGroup(3)) {
my $contentManagers = $group->getUsers(4,1); my $contentManagers = WebGUI::Group->new(4)->getUsers(1);
push (@$contentManagers, $self->session->user->profileField("userId")); push (@$contentManagers, $self->session->user->profileField("userId"));
$clause = "userId in (".$self->session->db->quoteAndJoin($contentManagers).")"; $clause = "userId in (".$self->session->db->quoteAndJoin($contentManagers).")";
} else { } else {
@ -334,7 +334,7 @@ sub www_editBranchSave {
} }
} }
my $newRevision = $descendant->addRevision(\%data); my $newRevision = $descendant->addRevision(\%data);
foreach my $form (keys %{$session{form}}) { foreach my $form ($self->session->request->param) {
if ($form =~ /^metadata_(.*)$/) { if ($form =~ /^metadata_(.*)$/) {
my $fieldName = $1; my $fieldName = $1;
if ($self->session->form->yesNo("change_metadata_".$fieldName)) { if ($self->session->form->yesNo("change_metadata_".$fieldName)) {

View file

@ -51,7 +51,7 @@ sub cut {
return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage")); return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage"));
$self->session->db->beginTransaction; $self->session->db->beginTransaction;
$self->session->db->write("update asset set state='clipboard-limbo' where lineage like ".$self->session->db->quote($self->get("lineage").'%')." and state='published'"); $self->session->db->write("update asset set state='clipboard-limbo' where lineage like ".$self->session->db->quote($self->get("lineage").'%')." and state='published'");
$self->session->db->write("update asset set state='clipboard', stateChangedBy=".$self->session->db->quote($self->session->user->profileField("userId")).", stateChanged="$self->session->datetime->time()." where assetId=".$self->session->db->quote($self->getId)); $self->session->db->write("update asset set state='clipboard', stateChangedBy=".$self->session->db->quote($self->session->user->profileField("userId")).", stateChanged=".$self->session->datetime->time()." where assetId=".$self->session->db->quote($self->getId));
$self->session->db->commit; $self->session->db->commit;
$self->updateHistory("cut"); $self->updateHistory("cut");
$self->{_properties}{state} = "clipboard"; $self->{_properties}{state} = "clipboard";

View file

@ -45,6 +45,7 @@ Returns a descriptive error message (HTML) if the export path is not writable, d
=cut =cut
sub checkExportPath { sub checkExportPath {
my $self = shift;
my $error; my $error;
if(defined $self->session->config->get("exportPath")) { if(defined $self->session->config->get("exportPath")) {
if(-d $self->session->config->get("exportPath")) { if(-d $self->session->config->get("exportPath")) {
@ -76,18 +77,10 @@ Executes the export and returns html content.
A hashref containing one of the following properties: A hashref containing one of the following properties:
=head4 extrasUrl
The URL where the page will be able to find the WebGUI extras folder. Defaults to the extrasURL in the config file.
=head4 stripHtml =head4 stripHtml
A boolean indicating whether the resulting output should be stripped of HTML tags. A boolean indicating whether the resulting output should be stripped of HTML tags.
=head4 uploadsUrl
The URL where the page will be able to find the files uploaded to WebGUI. Defaults to the uploadsURL in the config file.
=head4 userId =head4 userId
The unique id of the user to become when exporting this page. Defaults to '1' (Visitor). The unique id of the user to become when exporting this page. Defaults to '1' (Visitor).
@ -97,22 +90,13 @@ The unique id of the user to become when exporting this page. Defaults to '1' (V
sub exportAsHtml { sub exportAsHtml {
my $self = shift; my $self = shift;
my $params = shift; my $params = shift;
my $uploadsUrl = $params->{uploadsUrl} || $self->session->config->get("uploadsUrl");
my $extrasUrl = $params->{extrasUrl} || $self->session->config->get("extrasUrl");
my $userId = $params->{userId} || 1; my $userId = $params->{userId} || 1;
my $stripHtml = $params->{stripHtml} || undef; my $stripHtml = $params->{stripHtml} || undef;
# Save current session information because we need to restore current session after the export has finished.
my %oldSession = %session;
# Change the stuff we need to change to do the export # Change the stuff we need to change to do the export
$session->user({userId=>$userId}) unless ($userId == $self->session->user->profileField("userId")); my $session = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename);
delete $session{form}; $session->user({userId=>$userId}) unless ($userId eq $self->session->user->profileField("userId"));
$self->session->var->get("adminOn") = $self->get('adminOn');
$self->WebGUI::Session::refreshPageInfo;
$self->{_properties}{cacheTimeout} = $self->{_properties}{cacheTimeoutVisitor} = 1; $self->{_properties}{cacheTimeout} = $self->{_properties}{cacheTimeoutVisitor} = 1;
$self->session->config->get("uploadsURL") = $uploadsUrl;
$self->session->config->get("extrasURL") = $extrasUrl;
# Generate the page # Generate the page
my $content = $self->www_view; my $content = $self->www_view;
@ -120,9 +104,6 @@ sub exportAsHtml {
$content = WebGUI::HTML::html2text($content); $content = WebGUI::HTML::html2text($content);
} }
# Restore session
%session = %oldSession;
delete $session{page}{noHttpHeader};
return $content; return $content;
} }
@ -216,12 +197,11 @@ sub www_exportGenerate {
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(13)); return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(13));
# This routine is called in an IFRAME and prints status output directly to the browser. # This routine is called in an IFRAME and prints status output directly to the browser.
$|++; # Unbuffered data output $|++; # Unbuffered data output
$session{page}{empty} = 1; # Write directly to the browser $self->session->request->print($self->session->http->getHeader());
print WebGUI::HTTP::getHeader();
my $startTime =$self->session->datetime->time(); my $startTime =$self->session->datetime->time();
my $error = $self->checkExportPath(); my $error = $self->checkExportPath();
if ($error) { if ($error) {
print $error; $self->session->request->print($error);
return; return;
} }
my $i18n = WebGUI::International->new($self->session); my $i18n = WebGUI::International->new($self->session);
@ -232,9 +212,9 @@ sub www_exportGenerate {
my $assets = $self->getLineage(["self","descendants"],{returnObjects=>1,endingLineageLength=>$self->getLineageLength+$self->session->form->process("depth")}); my $assets = $self->getLineage(["self","descendants"],{returnObjects=>1,endingLineageLength=>$self->getLineageLength+$self->session->form->process("depth")});
foreach my $asset (@{$assets}) { foreach my $asset (@{$assets}) {
my $url = $asset->get("url"); my $url = $asset->get("url");
printf $i18n->get('exporting page'), $url; $self->session->request->printf( $i18n->get('exporting page'), $url);
unless ($asset->canView($userId)) { unless ($asset->canView($userId)) {
print $i18n->get('bad user privileges')."\n"; $self->session->request->print ($i18n->get('bad user privileges')."\n");
next; next;
} }
my $path; my $path;
@ -255,28 +235,23 @@ sub www_exportGenerate {
$path = $self->session->config->get("exportPath") . "/" . $path; $path = $self->session->config->get("exportPath") . "/" . $path;
eval { mkpath($path) }; eval { mkpath($path) };
if($@) { if($@) {
printf $i18n->get('could not create path'), $path, $@; $self->session->request->printf($i18n->get('could not create path'), $path, $@);
return; return;
} }
} }
$path .= "/".$filename; $path .= "/".$filename;
eval { open(FILE, "> $path") or die "$!" }; eval { open(FILE, "> $path") or die "$!" };
if ($@) { if ($@) {
printf $i18n->get('could not open path'), $path, $@; $self->session->request->printf($i18n->get('could not open path'), $path, $@);
return; return;
} else { } else {
print FILE $asset->exportAsHtml({userId=>$userId,extrasUrl=>$extrasURL,uploadsUrl=>$uploadsURL}); print FILE $asset->exportAsHtml({userId=>$userId,extrasUrl=>$extrasURL,uploadsUrl=>$uploadsURL});
close(FILE); close(FILE);
} }
print $i18n->get('done'); $self->session->request->print($i18n->get('done'));
} }
<<<<<<< .mine $self->session->request->printf($i18n->get('export information'), scalar(@{$assets}), ($self->session->datetime->time()-$startTime));
printf $i18n->get('export information'), scalar(@{$assets}), (time()-$startTime); $self->session->request->print('<a target="_parent" href="'.$self->getUrl.'">'.$i18n->get(493).'</a>');
print '<a target="_parent" href="'.$self->getUrl.'">'.$i18n->get(493).'</a>';
=======
printf WebGUI::International::get('export information','Asset'), scalar(@{$assets}), $self->session->datetime->time()-$startTime);
print '<a target="_parent" href="'.$self->getUrl.'">'.WebGUI::International::get(493,"Asset").'</a>';
>>>>>>> .r425
return; return;
} }

View file

@ -534,7 +534,7 @@ A boolean that if set true will return the users list minus the expired grouping
=cut =cut
sub getUsersInGroup { sub getUsers {
my $self = shift; my $self = shift;
my $recursive = shift; my $recursive = shift;
my $withoutExpired = shift; my $withoutExpired = shift;