From 4b439f610eef70942359e90f346d3188b08eae91 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 12 Jan 2006 23:13:18 +0000 Subject: [PATCH] bugfixes from session conversion --- lib/WebGUI/AssetBranch.pm | 4 +-- lib/WebGUI/AssetClipboard.pm | 2 +- lib/WebGUI/AssetExportHtml.pm | 49 +++++++++-------------------------- lib/WebGUI/Group.pm | 2 +- 4 files changed, 16 insertions(+), 41 deletions(-) diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index 9fa740204..29fbebdef 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -214,7 +214,7 @@ sub www_editBranch { } my $clause; 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")); $clause = "userId in (".$self->session->db->quoteAndJoin($contentManagers).")"; } else { @@ -334,7 +334,7 @@ sub www_editBranchSave { } } my $newRevision = $descendant->addRevision(\%data); - foreach my $form (keys %{$session{form}}) { + foreach my $form ($self->session->request->param) { if ($form =~ /^metadata_(.*)$/) { my $fieldName = $1; if ($self->session->form->yesNo("change_metadata_".$fieldName)) { diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 60208322d..9318d6c35 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -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")); $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', 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->updateHistory("cut"); $self->{_properties}{state} = "clipboard"; diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index 8d404521e..658a07285 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -45,6 +45,7 @@ Returns a descriptive error message (HTML) if the export path is not writable, d =cut sub checkExportPath { + my $self = shift; my $error; if(defined $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: -=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 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 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 { my $self = 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 $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 - $session->user({userId=>$userId}) unless ($userId == $self->session->user->profileField("userId")); - delete $session{form}; - $self->session->var->get("adminOn") = $self->get('adminOn'); - $self->WebGUI::Session::refreshPageInfo; + my $session = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename); + $session->user({userId=>$userId}) unless ($userId eq $self->session->user->profileField("userId")); $self->{_properties}{cacheTimeout} = $self->{_properties}{cacheTimeoutVisitor} = 1; - $self->session->config->get("uploadsURL") = $uploadsUrl; - $self->session->config->get("extrasURL") = $extrasUrl; # Generate the page my $content = $self->www_view; @@ -120,9 +104,6 @@ sub exportAsHtml { $content = WebGUI::HTML::html2text($content); } - # Restore session - %session = %oldSession; - delete $session{page}{noHttpHeader}; return $content; } @@ -216,12 +197,11 @@ sub www_exportGenerate { 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. $|++; # Unbuffered data output - $session{page}{empty} = 1; # Write directly to the browser - print WebGUI::HTTP::getHeader(); + $self->session->request->print($self->session->http->getHeader()); my $startTime =$self->session->datetime->time(); my $error = $self->checkExportPath(); if ($error) { - print $error; + $self->session->request->print($error); return; } 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")}); foreach my $asset (@{$assets}) { my $url = $asset->get("url"); - printf $i18n->get('exporting page'), $url; + $self->session->request->printf( $i18n->get('exporting page'), $url); unless ($asset->canView($userId)) { - print $i18n->get('bad user privileges')."\n"; + $self->session->request->print ($i18n->get('bad user privileges')."\n"); next; } my $path; @@ -255,28 +235,23 @@ sub www_exportGenerate { $path = $self->session->config->get("exportPath") . "/" . $path; eval { mkpath($path) }; if($@) { - printf $i18n->get('could not create path'), $path, $@; + $self->session->request->printf($i18n->get('could not create path'), $path, $@); return; } } $path .= "/".$filename; eval { open(FILE, "> $path") or die "$!" }; if ($@) { - printf $i18n->get('could not open path'), $path, $@; + $self->session->request->printf($i18n->get('could not open path'), $path, $@); return; } else { print FILE $asset->exportAsHtml({userId=>$userId,extrasUrl=>$extrasURL,uploadsUrl=>$uploadsURL}); close(FILE); } - print $i18n->get('done'); + $self->session->request->print($i18n->get('done')); } -<<<<<<< .mine - printf $i18n->get('export information'), scalar(@{$assets}), (time()-$startTime); - print ''.$i18n->get(493).''; -======= - printf WebGUI::International::get('export information','Asset'), scalar(@{$assets}), $self->session->datetime->time()-$startTime); - print ''.WebGUI::International::get(493,"Asset").''; ->>>>>>> .r425 + $self->session->request->printf($i18n->get('export information'), scalar(@{$assets}), ($self->session->datetime->time()-$startTime)); + $self->session->request->print(''.$i18n->get(493).''); return; } diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index d5a72cb05..dfc6c59b7 100755 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -534,7 +534,7 @@ A boolean that if set true will return the users list minus the expired grouping =cut -sub getUsersInGroup { +sub getUsers { my $self = shift; my $recursive = shift; my $withoutExpired = shift;