From 2866a2c8734e693ca83352675ea42a6153a7227f Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 2 Jan 2006 03:12:54 +0000 Subject: [PATCH] converting assets to new session system --- lib/WebGUI/Asset/Event.pm | 38 +- lib/WebGUI/Asset/File.pm | 16 +- lib/WebGUI/Asset/File/Image.pm | 14 +- lib/WebGUI/Asset/File/ZipArchive.pm | 30 +- lib/WebGUI/Asset/FilePile.pm | 22 +- lib/WebGUI/Asset/Post.pm | 126 +++--- lib/WebGUI/Asset/Post/Thread.pm | 84 ++-- lib/WebGUI/Asset/Redirect.pm | 2 +- lib/WebGUI/Asset/RichEdit.pm | 10 +- lib/WebGUI/Asset/Shortcut.pm | 56 +-- lib/WebGUI/Asset/Snippet.pm | 2 +- lib/WebGUI/Asset/Template.pm | 80 ++-- lib/WebGUI/Asset/Wobject.pm | 72 ++-- lib/WebGUI/Asset/Wobject/Article.pm | 6 +- lib/WebGUI/Asset/Wobject/Collaboration.pm | 98 ++--- lib/WebGUI/Asset/Wobject/Dashboard.pm | 28 +- lib/WebGUI/Asset/Wobject/DataForm.pm | 238 +++++------ lib/WebGUI/Asset/Wobject/EventsCalendar.pm | 10 +- lib/WebGUI/Asset/Wobject/HttpProxy.pm | 20 +- lib/WebGUI/Asset/Wobject/HttpProxy/Parse.pm | 2 +- lib/WebGUI/Asset/Wobject/InOutBoard.pm | 88 ++--- lib/WebGUI/Asset/Wobject/IndexedSearch.pm | 86 ++-- .../Asset/Wobject/IndexedSearch/Search.pm | 68 ++-- lib/WebGUI/Asset/Wobject/Layout.pm | 20 +- lib/WebGUI/Asset/Wobject/Matrix.pm | 274 ++++++------- lib/WebGUI/Asset/Wobject/Navigation.pm | 60 +-- lib/WebGUI/Asset/Wobject/Poll.pm | 38 +- lib/WebGUI/Asset/Wobject/Product.pm | 152 ++++---- lib/WebGUI/Asset/Wobject/SQLReport.pm | 10 +- lib/WebGUI/Asset/Wobject/StockData.pm | 14 +- lib/WebGUI/Asset/Wobject/Survey.pm | 368 +++++++++--------- lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 18 +- lib/WebGUI/Asset/Wobject/WSClient.pm | 44 +-- lib/WebGUI/Asset/Wobject/WeatherData.pm | 4 +- 34 files changed, 1099 insertions(+), 1099 deletions(-) diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index 4891fa751..c595da772 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -98,7 +98,7 @@ sub getEditForm { -hoverHelp=>WebGUI::International::get('515 description',"Asset_Event"), -value=>$self->getValue("eventLocation") ); - if ($session{form}{func} eq "add") { + if ($self->session->form->process("func") eq "add") { my %recursEvery; tie %recursEvery, 'Tie::IxHash'; %recursEvery = ( @@ -142,12 +142,12 @@ sub getEditForm { sub processPropertiesFromFormPost { my $self = shift; $self->SUPER::processPropertiesFromFormPost; - if ($session{form}{assetId} eq "new") { + if ($self->session->form->process("assetId") eq "new") { $self->update({eventEndDate=>$self->get("eventStartDate")}) unless ($self->get("eventEndDate") >= $self->get("eventStartDate")); - if ($session{form}{recursEvery} && $session{form}{recursEvery} ne "never") { - my $until = WebGUI::DateTime::setToEpoch($session{form}{until}); + if ($self->session->form->process("recursEvery") && $self->session->form->process("recursEvery") ne "never") { + my $until = WebGUI::DateTime::setToEpoch($self->session->form->process("until")); $until = $self->get("eventEndDate") unless ($until >= $self->get("eventEndDate")); - my $interval = ($session{form}{interval} < 1) ? 1 : $session{form}{interval}; + my $interval = ($self->session->form->process("interval") < 1) ? 1 : $self->session->form->process("interval"); my $recurringEventId = WebGUI::Id::generate(); $self->update({EventsCalendar_recurringId=>$recurringEventId}); my $start = $self->get("eventStartDate"); @@ -155,16 +155,16 @@ sub processPropertiesFromFormPost { my $i = 0; while ($start < $until) { $i++; - if ($session{form}{recursEvery} eq "day") { + if ($self->session->form->process("recursEvery") eq "day") { $start = WebGUI::DateTime::addToDate($self->get("eventStartDate"),0,0,($i*$interval)); $end = WebGUI::DateTime::addToDate($self->get("eventEndDate"),0,0,($i*$interval)); - } elsif ($session{form}{recursEvery} eq "week") { + } elsif ($self->session->form->process("recursEvery") eq "week") { $start = WebGUI::DateTime::addToDate($self->get("eventStartDate"),0,0,(7*$i*$interval)); $end = WebGUI::DateTime::addToDate($self->get("eventEndDate"),0,0,(7*$i*$interval)); - } elsif ($session{form}{recursEvery} eq "month") { + } elsif ($self->session->form->process("recursEvery") eq "month") { $start = WebGUI::DateTime::addToDate($self->get("eventStartDate"),0,($i*$interval),0); $end = WebGUI::DateTime::addToDate($self->get("eventEndDate"),0,($i*$interval),0); - } elsif ($session{form}{recursEvery} eq "year") { + } elsif ($self->session->form->process("recursEvery") eq "year") { $start = WebGUI::DateTime::addToDate($self->get("eventStartDate"),($i*$interval),0,0); $end = WebGUI::DateTime::addToDate($self->get("eventEndDate"),($i*$interval),0,0); } @@ -212,14 +212,14 @@ sub view { $var{"end.date"} = epochToHuman($self->getValue("eventEndDate"),"%z"); $var{"end.time"} = epochToHuman($self->getValue("eventEndDate"),"%Z"); $var{canEdit} = $self->canEdit; - $var{"edit.url"} = WebGUI::URL::page('func=edit'); + $var{"edit.url"} = $self->session->url->page('func=edit'); $var{"edit.label"} = WebGUI::International::get(575,"Asset_Event"); - $var{"delete.url"} = WebGUI::URL::page('func=deleteEvent;rid='.$self->getValue("EventsCalendar_recurringId")); + $var{"delete.url"} = $self->session->url->page('func=deleteEvent;rid='.$self->getValue("EventsCalendar_recurringId")); $var{"delete.label"} = WebGUI::International::get(576,"Asset_Event"); my @others; my ($start, $garbage) = WebGUI::DateTime::dayStartEnd($self->get("eventStartDate")); my ($garbage, $end) = WebGUI::DateTime::dayStartEnd($self->get("eventEndDate")); - my $sth = WebGUI::SQL->read("select assetId from EventsCalendar_event where ((eventStartDate >= $start and eventStartDate <= $end) or (eventEndDate >= $start and eventEndDate <= $end)) and assetId<>".quote($self->getId)); + my $sth = $self->session->db->read("select assetId from EventsCalendar_event where ((eventStartDate >= $start and eventStartDate <= $end) or (eventEndDate >= $start and eventEndDate <= $end)) and assetId<>".$self->session->db->quote($self->getId)); while (my ($assetId) = $sth->array) { my $asset = WebGUI::Asset::Event->new($assetId); # deal with multiple versions of the same event with conflicting dates @@ -241,12 +241,12 @@ sub www_deleteEvent { my ($output); $output = '

'.WebGUI::International::get(42,"Asset_Event").'

'; $output .= WebGUI::International::get(75,"Asset_Event").'

'; - $output .= ''.WebGUI::International::get(76,"Asset_Event").'

'; - $output .= '' - .WebGUI::International::get(77,"Asset_Event").'

' if (($session{form}{rid} ne "") and ($session{form}{rid} ne "0")); + $output .= ''.WebGUI::International::get(76,"Asset_Event").'

'; + $output .= '' + .WebGUI::International::get(77,"Asset_Event").'

' if (($self->session->form->process("rid") ne "") and ($self->session->form->process("rid") ne "0")); $output .= ''.WebGUI::International::get(78,"Asset_Event").''; $output .= '

'; - return WebGUI::Style::process($output,$self->getParent->getValue("styleTemplateId")); + return $self->session->style->process($output,$self->getParent->getValue("styleTemplateId")); } @@ -254,10 +254,10 @@ sub www_deleteEvent { sub www_deleteEventConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - if (($session{form}{rid} ne "") and ($session{form}{rid} ne "0")) { + if (($self->session->form->process("rid") ne "") and ($self->session->form->process("rid") ne "0")) { my $series = $self->getParent->getLineage(["descendants"],{returnObjects=>1}); foreach my $event (@{$series}) { - $event->trash if $event->get("EventsCalendar_recurringId") eq $session{form}{rid}; + $event->trash if $event->get("EventsCalendar_recurringId") eq $self->session->form->process("rid"); } } else { $self->trash; @@ -278,7 +278,7 @@ sub www_edit { sub www_view { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canView); - return WebGUI::Style::process($self->view,$self->getParent->getValue("styleTemplateId")); + return $self->session->style->process($self->view,$self->getParent->getValue("styleTemplateId")); } diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 1f5d4572a..74dcb33c2 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -168,11 +168,11 @@ sub getIcon { my $self = shift; my $small = shift; if ($small && ref($self) eq '') { - return $session{config}{extrasURL}.'/assets/small/file.gif'; + return $self->session->config->get("extrasURL").'/assets/small/file.gif'; } elsif ($small) { return $self->getFileIconUrl; } - return $session{config}{extrasURL}.'/assets/file.gif'; + return $self->session->config->get("extrasURL").'/assets/file.gif'; } @@ -202,9 +202,9 @@ sub processPropertiesFromFormPost { my %data; $data{filename} = $filename; $data{storageId} = $storage->getId; - $data{title} = $filename unless ($session{form}{title}); - $data{menuTitle} = $filename unless ($session{form}{menuTitle}); - $data{url} = $self->getParent->get('url').'/'.$filename unless ($session{form}{url}); + $data{title} = $filename unless ($self->session->form->process("title")); + $data{menuTitle} = $filename unless ($self->session->form->process("menuTitle")); + $data{url} = $self->getParent->get('url').'/'.$filename unless ($self->session->form->process("url")); $self->update(\%data); } } @@ -214,7 +214,7 @@ sub processPropertiesFromFormPost { sub purge { my $self = shift; - my $sth = WebGUI::SQL->read("select storageId from FileAsset where assetId=".quote($self->getId)); + my $sth = $self->session->db->read("select storageId from FileAsset where assetId=".$self->session->db->quote($self->getId)); while (my ($storageId) = $sth->array) { WebGUI::Storage->get($storageId)->delete; } @@ -284,7 +284,7 @@ sub www_edit { -namespace=>"FileAsset" ); $self->getAdminConsole->setHelp("file add/edit", "Asset_File"); - my $addEdit = ($session{form}{func} eq 'add') ? WebGUI::International::get('add','Wobject') : WebGUI::International::get('edit','Wobject'); + my $addEdit = ($self->session->form->process("func") eq 'add') ? WebGUI::International::get('add','Wobject') : WebGUI::International::get('edit','Wobject'); return $self->getAdminConsole->render($tabform->print,$addEdit.' '.$self->getName); } @@ -292,7 +292,7 @@ sub www_edit { sub www_view { my $self = shift; return WebGUI::Privilege::noAccess() unless $self->canView; - if ($session{var}{adminOn}) { + if ($self->session->var->get("adminOn")) { return $self->getContainer->www_view; } WebGUI::HTTP::setRedirect($self->getFileUrl); diff --git a/lib/WebGUI/Asset/File/Image.pm b/lib/WebGUI/Asset/File/Image.pm index 7c690be19..9c2398213 100644 --- a/lib/WebGUI/Asset/File/Image.pm +++ b/lib/WebGUI/Asset/File/Image.pm @@ -70,7 +70,7 @@ sub definition { properties=>{ thumbnailSize=>{ fieldType=>'integer', - defaultValue=>$session{setting}{thumbnailSize} + defaultValue=>$self->session->setting->get("thumbnailSize") }, parameters=>{ fieldType=>'textarea', @@ -148,7 +148,7 @@ sub getEditForm { sub getIcon { my $self = shift; my $small = shift; - return $session{config}{extrasURL}.'/assets/image.gif' unless ($small); + return $self->session->config->get("extrasURL").'/assets/image.gif' unless ($small); $self->SUPER::getIcon(1); } @@ -196,10 +196,10 @@ sub processPropertiesFromFormPost { $self->update({parameters=>$parameters.' alt="'.$self->get("title").'"'}); } my $storage = $self->getStorageLocation; - $self->generateThumbnail($session{setting}{maxImageSize}); + $self->generateThumbnail($self->session->setting->get("maxImageSize")); $storage->deleteFile($self->get("filename")); $storage->renameFile('thumb-'.$self->get("filename"),$self->get("filename")); - $self->generateThumbnail($session{form}{thumbnailSize}); + $self->generateThumbnail($self->session->form->process("thumbnailSize")); } #------------------------------------------------------------------- @@ -242,8 +242,8 @@ sub www_edit { sub www_resize { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - if ($session{form}{newWidth} || $session{form}{newHeight}) { - $self->getStorageLocation->resize($self->get("filename"),$session{form}{newWidth},$session{form}{newHeight}); + if ($self->session->form->process("newWidth") || $self->session->form->process("newHeight")) { + $self->getStorageLocation->resize($self->get("filename"),$self->session->form->process("newWidth"),$self->session->form->process("newHeight")); $self->setSize($self->getStorageLocation->getFileSize($self->get("filename"))); } $self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),WebGUI::International::get("edit image","Asset_Image")); @@ -286,7 +286,7 @@ A web executable method that redirects the user to the specified page, or displa sub www_view { my $self = shift; - if ($session{var}{adminOn}) { + if ($self->session->var->get("adminOn")) { return $self->www_edit; } my $storage = $self->getStorageLocation; diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm index 7b3c90474..750edd268 100644 --- a/lib/WebGUI/Asset/File/ZipArchive.pm +++ b/lib/WebGUI/Asset/File/ZipArchive.pm @@ -60,18 +60,18 @@ sub unzip { if($filename =~ m/\.zip/i){ my $zip = Archive::Zip->new(); unless ($zip->read($filename) == $zip->AZ_OK){ - WebGUI::ErrorHandler::warn(WebGUI::International::get("zip_error","Asset_ZipArchive")); + $self->session->errorHandler->warn(WebGUI::International::get("zip_error","Asset_ZipArchive")); return 0; } $zip->extractTree(); } elsif($filename =~ m/\.tar/i){ Archive::Tar->extract_archive($filepath.'/'.$filename,1); if (Archive::Tar->error){ - WebGUI::ErrorHandler::warn(Archive::Tar->error); + $self->session->errorHandler->warn(Archive::Tar->error); return 0; } } else{ - WebGUI::ErrorHandler::warn(WebGUI::International::get("bad_archive","Asset_ZipArchive")); + $self->session->errorHandler->warn(WebGUI::International::get("bad_archive","Asset_ZipArchive")); } return 1; @@ -179,8 +179,8 @@ If this evaluates to True, then the smaller icon is returned. sub getIcon { my $self = shift; my $small = shift; - return $session{config}{extrasURL}.'/assets/ziparchive.gif' unless ($small); - return $session{config}{extrasURL}.'/assets/small/ziparchive.gif'; + return $self->session->config->get("extrasURL").'/assets/ziparchive.gif' unless ($small); + return $self->session->config->get("extrasURL").'/assets/small/ziparchive.gif'; } @@ -201,22 +201,22 @@ sub processPropertiesFromFormPost { my $file = $self->get("filename"); #return unless $file; - unless($session{form}{showPage}) { + unless($self->session->form->process("showPage")) { $storage->delete; - WebGUI::SQL->write("update FileAsset set filename=NULL where assetId=".quote($self->getId)); - WebGUI::Session::setScratch("za_error",WebGUI::International::get("za_show_error","Asset_ZipArchive")); + $self->session->db->write("update FileAsset set filename=NULL where assetId=".$self->session->db->quote($self->getId)); + $self->session->scratch->set("za_error",WebGUI::International::get("za_show_error","Asset_ZipArchive")); return; } unless($file =~ m/\.tar/i || $file =~ m/\.zip/i) { $storage->delete; - WebGUI::SQL->write("update FileAsset set filename=NULL where assetId=".quote($self->getId)); - WebGUI::Session::setScratch("za_error",WebGUI::International::get("za_error","Asset_ZipArchive")); + $self->session->db->write("update FileAsset set filename=NULL where assetId=".$self->session->db->quote($self->getId)); + $self->session->scratch->set("za_error",WebGUI::International::get("za_error","Asset_ZipArchive")); return; } unless ($self->unzip($storage,$self->get("filename"))) { - WebGUI::ErrorHandler::warn(WebGUI::International::get("unzip_error","Asset_ZipArchive")); + $self->session->errorHandler->warn(WebGUI::International::get("unzip_error","Asset_ZipArchive")); } } @@ -256,12 +256,12 @@ used to show the file to administrators. sub view { my $self = shift; my %var = %{$self->get}; - #WebGUI::ErrorHandler::warn($self->getId); + #$self->session->errorHandler->warn($self->getId); $var{controls} = $self->getToolbar; - if($session{scratch}{za_error}) { - $var{error} = $session{scratch}{za_error}; + if($self->session->scratch->get("za_error")) { + $var{error} = $self->session->scratch->get("za_error"); } - WebGUI::Session::deleteScratch("za_error"); + $self->session->scratch->delete("za_error"); my $storage = $self->getStorageLocation; if($self->get("filename") ne "") { $var{fileUrl} = $storage->getUrl($self->get("showPage")); diff --git a/lib/WebGUI/Asset/FilePile.pm b/lib/WebGUI/Asset/FilePile.pm index 35244d257..380e500dd 100644 --- a/lib/WebGUI/Asset/FilePile.pm +++ b/lib/WebGUI/Asset/FilePile.pm @@ -64,10 +64,10 @@ sub edit { name=>"class", value=>"WebGUI::Asset::FilePile" }); - if ($session{form}{proceed}) { + if ($self->session->form->process("proceed")) { $tabform->hidden({ name=>"proceed", - value=>$session{form}{proceed} + value=>$self->session->form->process("proceed") }); } $tabform->addTab("properties",WebGUI::International::get("properties","Asset")); @@ -109,12 +109,12 @@ sub edit { my $clause; if (WebGUI::Grouping::isInGroup(3)) { my $contentManagers = WebGUI::Grouping::getUsersInGroup(4,1); - push (@$contentManagers, $session{user}{userId}); - $clause = "userId in (".quoteAndJoin($contentManagers).")"; + push (@$contentManagers, $self->session->user->profileField("userId")); + $clause = "userId in (".$self->session->db->quoteAndJoin($contentManagers).")"; } else { - $clause = "userId=".quote($self->get("ownerUserId")); + $clause = "userId=".$self->session->db->quote($self->get("ownerUserId")); } - my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username"); + my $users = $self->session->db->buildHashRef("select userId,username from users where $clause order by username"); $tabform->getTab("security")->selectBox( -name=>"ownerUserId", -options=>$users, @@ -162,7 +162,7 @@ sub editSave { $className = "WebGUI::Asset::File::Image" if ($storage->isImage($filename)); foreach my $definition (@{$className->definition}) { foreach my $property (keys %{$definition->{properties}}) { - $data{$property} = WebGUI::FormProcessor::process( + $data{$property} = $self->session->form->process( $property, $definition->{properties}{$property}{fieldType}, $definition->{properties}{$property}{defaultValue} @@ -182,7 +182,7 @@ sub editSave { $newAsset->commit; } $tempStorage->delete; - return $class->getParent->www_manageAssets if ($session{form}{proceed} eq "manageAssets"); + return $class->getParent->www_manageAssets if ($self->session->form->process("proceed") eq "manageAssets"); return $class->getParent->www_view; } @@ -191,9 +191,9 @@ sub getIcon { my $self = shift; my $small = shift; if ($small) { - return $session{config}{extrasURL}.'/assets/small/filePile.gif'; + return $self->session->config->get("extrasURL").'/assets/small/filePile.gif'; } - return $session{config}{extrasURL}.'/assets/filePile.gif'; + return $self->session->config->get("extrasURL").'/assets/filePile.gif'; } @@ -214,7 +214,7 @@ sub getName { #------------------------------------------------------------------- sub www_edit { my $self = shift; - unless ($session{form}{doit}) { + unless ($self->session->form->process("doit")) { return $self->edit; } else { return $self->editSave; diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index e1e439e7c..5225a3c5f 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -66,7 +66,7 @@ sub canAdd { #------------------------------------------------------------------- sub canEdit { my $self = shift; - return (($session{form}{func} eq "add" || ($session{form}{assetId} eq "new" && $session{form}{func} eq "editSave" && $session{form}{class} eq "WebGUI::Asset::Post")) && $self->getThread->getParent->canPost) || # account for new posts + return (($self->session->form->process("func") eq "add" || ($self->session->form->process("assetId") eq "new" && $self->session->form->process("func") eq "editSave" && $self->session->form->process("class") eq "WebGUI::Asset::Post")) && $self->getThread->getParent->canPost) || # account for new posts ($self->isPoster && $self->getThread->getParent->get("editTimeout") > (WebGUI::DateTime::time() - $self->get("dateUpdated"))) || $self->getThread->getParent->canModerate; @@ -137,7 +137,7 @@ sub definition { }, username => { fieldType=>"hidden", - defaultValue=>$session{form}{visitorUsername} || $session{user}{alias} || $session{user}{username} + defaultValue=>$self->session->form->process("visitorUsername") || $self->session->user->profileField("alias") || $self->session->user->profileField("username") }, rating => { noFormPost=>1, @@ -229,7 +229,7 @@ Formats the URL to approve a post. sub getApproveUrl { my $self = shift; - return $self->getUrl("revision=".$self->get("revisionDate").";func=approve;mlog=".$session{form}{mlog}); + return $self->getUrl("revision=".$self->get("revisionDate").";func=approve;mlog=".$self->session->form->process("mlog")); } #------------------------------------------------------------------- @@ -284,7 +284,7 @@ Formats the url to deny a post. sub getDenyUrl { my $self = shift; - return $self->getUrl("revision=".$self->get("revisionDate").";func=deny;mlog=".$session{form}{mlog}); + return $self->getUrl("revision=".$self->get("revisionDate").";func=deny;mlog=".$self->session->form->process("mlog")); } #------------------------------------------------------------------- @@ -398,8 +398,8 @@ sub getStorageLocation { #------------------------------------------------------------------- sub getSynopsisAndContentFromFormPost { my $self = shift; - my $synopsis = $session{form}{synopsis}; - my $body = $session{form}{content}; + my $synopsis = $self->session->form->process("synopsis"); + my $body = $self->session->form->process("content"); unless ($synopsis) { $body =~ s/\n/\^\-\;/ unless ($body =~ m/\^\-\;/); my @content = split(/\^\-\;/,$body); @@ -526,9 +526,9 @@ Returns a boolean indicating whether this user has already rated this post. sub hasRated { my $self = shift; return 1 if $self->isPoster; - my ($flag) = WebGUI::SQL->quickArray("select count(*) from Post_rating where assetId=" - .quote($self->getId)." and ((userId=".quote($session{user}{userId})." and userId<>'1') or (userId='1' and - ipAddress=".quote($session{env}{REMOTE_ADDR})."))"); + my ($flag) = $self->session->db->quickArray("select count(*) from Post_rating where assetId=" + .$self->session->db->quote($self->getId)." and ((userId=".$self->session->db->quote($self->session->user->profileField("userId"))." and userId<>'1') or (userId='1' and + ipAddress=".$self->session->db->quote($self->session->env->get("REMOTE_ADDR"))."))"); return $flag; } @@ -556,7 +556,7 @@ Returns a boolean indicating whether this post is marked read for the user. sub isMarkedRead { my $self = shift; return 1 if $self->isPoster; - my ($isRead) = WebGUI::SQL->quickArray("select count(*) from Post_read where userId=".quote($session{user}{userId})." and postId=".quote($self->getId)); + my ($isRead) = $self->session->db->quickArray("select count(*) from Post_read where userId=".$self->session->db->quote($self->session->user->profileField("userId"))." and postId=".$self->session->db->quote($self->getId)); return $isRead; } @@ -570,7 +570,7 @@ Returns a boolean that is true if the current user created this post and is not sub isPoster { my $self = shift; - return ($session{user}{userId} ne "1" && $session{user}{userId} eq $self->get("ownerUserId")); + return ($self->session->user->profileField("userId") ne "1" && $self->session->user->profileField("userId") eq $self->get("ownerUserId")); } @@ -599,8 +599,8 @@ Marks this post read for this user. sub markRead { my $self = shift; unless ($self->isMarkedRead) { - WebGUI::SQL->write("insert into Post_read (userId, postId, threadId, readDate) values (".quote($session{user}{userId}).", - ".quote($self->getId).", ".quote($self->get("threadId")).", ".WebGUI::DateTime::time().")"); + $self->session->db->write("insert into Post_read (userId, postId, threadId, readDate) values (".$self->session->db->quote($self->session->user->profileField("userId")).", + ".$self->session->db->quote($self->getId).", ".$self->session->db->quote($self->get("threadId")).", ".WebGUI::DateTime::time().")"); } } @@ -627,7 +627,7 @@ sub notifySubscribers { if ($lang{$u->profileField("language")}{message} eq "") { $lang{$u->profileField("language")}{var} = $self->getTemplateVars(); $self->getThread->getParent->appendTemplateLabels($lang{$u->profileField("language")}{var}); - $lang{$u->profileField("language")}{var}{url} = WebGUI::URL::getSiteURL().$self->getUrl; + $lang{$u->profileField("language")}{var}{url} = $self->session->url->getSiteURL().$self->getUrl; $lang{$u->profileField("language")}{var}{'notify.subscription.message'} = WebGUI::International::get(875,"Asset_Post",$u->profileField("language")); $lang{$u->profileField("language")}{subject} = WebGUI::International::get(523,"Asset_Post",$u->profileField("language")); @@ -643,40 +643,40 @@ sub processPropertiesFromFormPost { my $self = shift; $self->SUPER::processPropertiesFromFormPost; my %data; - if ($session{form}{assetId} eq "new") { + if ($self->session->form->process("assetId") eq "new") { if ($self->getParent->get("className") eq "WebGUI::Asset::Wobject::Collaboration") { $self->update({threadId=>$self->getId}); } else { $self->update({threadId=>$self->getParent->get("threadId")}); } - if ($session{setting}{enableKarma} && $self->getThread->getParent->get("karmaPerPost")) { - my $u = WebGUI::User->new($session{user}{userId}); + if ($self->session->setting->get("enableKarma") && $self->getThread->getParent->get("karmaPerPost")) { + my $u = WebGUI::User->new($self->session->user->profileField("userId")); $u->addKarma($self->getThread->getParent->get("karmaPerPost"), $self->getId, "Collaboration post"); } %data = ( - ownerUserId => $session{user}{userId}, - username => $session{form}{visitorName} || $session{user}{alias} || $session{user}{username}, + ownerUserId => $self->session->user->profileField("userId"), + username => $self->session->form->process("visitorName") || $self->session->user->profileField("alias") || $self->session->user->profileField("username"), isHidden => 1, ); $data{url} = $self->fixUrl($self->getThread->get("url")."/1") if ($self->isReply); if ($self->getThread->getParent->canModerate) { $self->getThread->lock if ($session{form}{'lock'}); - $self->getThread->stick if ($session{form}{stick}); + $self->getThread->stick if ($self->session->form->process("stick")); } } $data{groupIdView} =$self->getThread->getParent->get("groupIdView"); $data{groupIdEdit} = $self->getThread->getParent->get("groupIdEdit"); - $data{startDate} = $self->getThread->getParent->get("startDate") unless ($session{form}{startDate}); - $data{endDate} = $self->getThread->getParent->get("endDate") unless ($session{form}{endDate}); + $data{startDate} = $self->getThread->getParent->get("startDate") unless ($self->session->form->process("startDate")); + $data{endDate} = $self->getThread->getParent->get("endDate") unless ($self->session->form->process("endDate")); ($data{synopsis}, $data{content}) = $self->getSynopsisAndContentFromFormPost; if ($self->getThread->getParent->get("addEditStampToPosts")) { - $data{content} .= "\n\n --- (".WebGUI::International::get('Edited_on','Asset_Post')." ".WebGUI::DateTime::epochToHuman(undef,"%z %Z [GMT%O]").WebGUI::International::get('By','Asset_Post').$session{user}{alias}.") --- \n"; + $data{content} .= "\n\n --- (".WebGUI::International::get('Edited_on','Asset_Post')." ".WebGUI::DateTime::epochToHuman(undef,"%z %Z [GMT%O]").WebGUI::International::get('By','Asset_Post').$self->session->user->profileField("alias").") --- \n"; if ($self->getValue("contentType") eq "mixed" || $self->getValue("contentType") eq "html") { $data{content} = '

'.$data{content}.'

'; } } $self->update(\%data); - $self->getThread->subscribe if ($session{form}{subscribe}); + $self->getThread->subscribe if ($self->session->form->process("subscribe")); if ($self->getThread->getParent->get("moderatePosts")) { $self->setStatusPending; } else { @@ -691,17 +691,17 @@ sub processPropertiesFromFormPost { $self->setSize($storage->getFileSize($filename)); foreach my $file (@{$storage->getFiles}) { if ($storage->isImage($file)) { - $storage->generateThumbnail($file,$session{setting}{maxImageSize}); + $storage->generateThumbnail($file,$self->session->setting->get("maxImageSize")); $storage->deleteFile($file); $storage->renameFile('thumb-'.$file,$file); $storage->generateThumbnail($file); } } } - $session{form}{proceed} = "redirectToParent"; + $self->session->form->process("proceed") = "redirectToParent"; # clear some cache - WebGUI::Cache->new("wobject_".$self->getThread->getParent->getId."_".$session{user}{userId})->delete; - WebGUI::Cache->new("cspost_".($self->getParent->getId)."_".$session{user}{userId}."_".$session{scratch}{discussionLayout}."_1")->delete; + WebGUI::Cache->new("wobject_".$self->getThread->getParent->getId."_".$self->session->user->profileField("userId"))->delete; + WebGUI::Cache->new("cspost_".($self->getParent->getId)."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_1")->delete; } @@ -709,13 +709,13 @@ sub processPropertiesFromFormPost { sub purge { my $self = shift; - my $sth = WebGUI::SQL->read("select storageId from Post where assetId=".quote($self->getId)); + my $sth = $self->session->db->read("select storageId from Post where assetId=".$self->session->db->quote($self->getId)); while (my ($storageId) = $sth->array) { WebGUI::Storage->get($storageId)->delete; } $sth->finish; - WebGUI::SQL->write("delete from Post_rating where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Post_read where postId=".quote($self->getId)); + $self->session->db->write("delete from Post_rating where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Post_read where postId=".$self->session->db->quote($self->getId)); return $self->SUPER::purge; } @@ -745,12 +745,12 @@ sub rate { my $self = shift; my $rating = shift || 3; unless ($self->hasRated) { - WebGUI::SQL->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (" - .quote($self->getId).", ".quote($session{user}{userId}).", ".quote($session{env}{REMOTE_ADDR}).", - ".WebGUI::DateTime::time().", ".quote($rating).")"); - my ($count) = WebGUI::SQL->quickArray("select count(*) from Post_rating where assetId=".quote($self->getId)); + $self->session->db->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (" + .$self->session->db->quote($self->getId).", ".$self->session->db->quote($self->session->user->profileField("userId")).", ".$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).", + ".WebGUI::DateTime::time().", ".$self->session->db->quote($rating).")"); + my ($count) = $self->session->db->quickArray("select count(*) from Post_rating where assetId=".$self->session->db->quote($self->getId)); $count = $count || 1; - my ($sum) = WebGUI::SQL->quickArray("select sum(rating) from Post_rating where assetId=".quote($self->getId)); + my ($sum) = $self->session->db->quickArray("select sum(rating) from Post_rating where assetId=".$self->session->db->quote($self->getId)); my $average = WebGUI::Utility::round($sum/$count); $self->update({rating=>$average}); $self->getThread->rate($rating); @@ -790,9 +790,9 @@ sub setStatusApproved { $self->commit; $self->getThread->incrementReplies($self->get("dateUpdated"),$self->getId) if $self->isReply; unless ($self->isPoster) { - WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',WebGUI::URL::getSiteURL().'/'.$self->getUrl,579); + WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',$self->session->url->getSiteURL().'/'.$self->getUrl,579); } - $self->notifySubscribers unless ($session{form}{func} eq 'add'); + $self->notifySubscribers unless ($self->session->form->process("func") eq 'add'); } @@ -823,7 +823,7 @@ Sets the status of this post to denied. sub setStatusDenied { my ($self) = @_; $self->update({status=>'denied'}); - WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',WebGUI::URL::getSiteURL().'/'.$self->getUrl,580); + WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',$self->session->url->getSiteURL().'/'.$self->getUrl,580); } #------------------------------------------------------------------- @@ -841,7 +841,7 @@ sub setStatusPending { } else { $self->update({status=>'pending'}); WebGUI::MessageLog::addInternationalizedEntry('',$self->getThread->getParent->get("moderateGroupId"), - WebGUI::URL::getSiteURL().'/'.$self->getUrl("revision=".$self->get("revisionDate")),578,'WebGUI','pending'); + $self->session->url->getSiteURL().'/'.$self->getUrl("revision=".$self->get("revisionDate")),578,'WebGUI','pending'); } } @@ -860,12 +860,12 @@ sub trash { $self->getThread->decrementReplies if ($self->isReply); if ($self->getThread->get("lastPostId") eq $self->getId) { my $threadLineage = $self->getThread->get("lineage"); - my ($id, $date) = WebGUI::SQL->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".quote($threadLineage.'%')." and Post.assetId<>".quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc"); + my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($threadLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc"); $self->getThread->update({lastPostId=>$id, lastPostDate=>$date}); } if ($self->getThread->getParent->get("lastPostId") eq $self->getId) { my $forumLineage = $self->getThread->getParent->get("lineage"); - my ($id, $date) = WebGUI::SQL->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".quote($forumLineage.'%')." and Post.assetId<>".quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc"); + my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($forumLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc"); $self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date}); } } @@ -880,7 +880,7 @@ Negates the markRead method. sub unmarkRead { my $self = shift; - WebGUI::SQL->write("delete from forumRead where userId=".quote($session{user}{userId})." and postId=".quote($self->getId)); + $self->session->db->write("delete from forumRead where userId=".$self->session->db->quote($self->session->user->profileField("userId"))." and postId=".$self->session->db->quote($self->getId)); } #------------------------------------------------------------------- @@ -931,7 +931,7 @@ sub www_approve { #------------------------------------------------------------------- sub www_deleteFile { my $self = shift; - $self->getStorageLocation->deleteFile($session{form}{filename}) if $self->canEdit; + $self->getStorageLocation->deleteFile($self->session->form->process("filename")) if $self->canEdit; return $self->www_edit; } @@ -956,7 +956,7 @@ sub www_edit { my %var; my $content; my $title; - if ($session{form}{func} eq "add") { # new post + if ($self->session->form->process("func") eq "add") { # new post $var{'form.header'} = WebGUI::Form::formHeader({action=>$self->getParent->getUrl}) .WebGUI::Form::hidden({ name=>"func", @@ -968,12 +968,12 @@ sub www_edit { }) .WebGUI::Form::hidden({ name=>"class", - value=>$session{form}{class} + value=>$self->session->form->process("class") }); $var{'isNewPost'} = 1; - $content = $session{form}{content}; - $title = $session{form}{title}; - if ($session{form}{class} eq "WebGUI::Asset::Post") { # new reply + $content = $self->session->form->process("content"); + $title = $self->session->form->process("title"); + if ($self->session->form->process("class") eq "WebGUI::Asset::Post") { # new reply $self->{_thread} = $self->getParent->getThread; return WebGUI::Privilege::insufficient() unless ($self->getThread->canReply); $var{isReply} = 1; @@ -983,22 +983,22 @@ sub www_edit { for my $i (1..5) { $var{'reply.userDefined'.$i} = WebGUI::HTML::filter($self->getParent->get('userDefined'.$i),"macros"); } - unless ($session{form}{content} || $session{form}{title}) { - $content = "[quote]".$self->getParent->get("content")."[/quote]" if ($session{form}{withQuote}); + unless ($self->session->form->process("content") || $self->session->form->process("title")) { + $content = "[quote]".$self->getParent->get("content")."[/quote]" if ($self->session->form->process("withQuote")); $title = $self->getParent->get("title"); $title = "Re: ".$title unless ($title =~ /^Re:/); } $var{'subscribe.form'} = WebGUI::Form::yesNo({ name=>"subscribe", - value=>$session{form}{subscribe} + value=>$self->session->form->process("subscribe") }); - } elsif ($session{form}{class} eq "WebGUI::Asset::Post::Thread") { # new thread + } elsif ($self->session->form->process("class") eq "WebGUI::Asset::Post::Thread") { # new thread return WebGUI::Privilege::insufficient() unless ($self->getThread->getParent->canPost); $var{isNewThread} = 1; if ($self->getThread->getParent->canModerate) { $var{'sticky.form'} = WebGUI::Form::yesNo({ name=>'stick', - value=>$session{form}{stick} + value=>$self->session->form->process("stick") }); $var{'lock.form'} = WebGUI::Form::yesNo({ name=>'lock', @@ -1007,10 +1007,10 @@ sub www_edit { } $var{'subscribe.form'} = WebGUI::Form::yesNo({ name=>"subscribe", - value=>$session{form}{subscribe} || 1 + value=>$self->session->form->process("subscribe") || 1 }); } - $content .= "\n\n".$session{user}{signature} if ($session{user}{signature} && !$session{form}{content}); + $content .= "\n\n".$self->session->user->profileField("signature") if ($self->session->user->profileField("signature") && !$self->session->form->process("content")); } else { # edit return WebGUI::Privilege::insufficient() unless ($self->canEdit); $var{'form.header'} = WebGUI::Form::formHeader({action=>$self->getUrl}) @@ -1030,10 +1030,10 @@ sub www_edit { $content = $self->getValue("content"); $title = $self->getValue("title"); } - if ($session{form}{title} || $session{form}{content} || $session{form}{synopsis}) { - $var{'preview.title'} = WebGUI::HTML::filter($session{form}{title},"all"); + if ($self->session->form->process("title") || $self->session->form->process("content") || $self->session->form->process("synopsis")) { + $var{'preview.title'} = WebGUI::HTML::filter($self->session->form->process("title"),"all"); ($var{'preview.synopsis'}, $var{'preview.content'}) = $self->getSynopsisAndContentFromFormPost; - $var{'preview.content'} = $self->formatContent($var{'preview.content'},$session{form}{contentType}); + $var{'preview.content'} = $self->formatContent($var{'preview.content'},$self->session->form->process("contentType")); for my $i (1..5) { $var{'preview.userDefined'.$i} = WebGUI::HTML::filter($session{form}{'userDefined'.$i},"macros"); } @@ -1041,7 +1041,7 @@ sub www_edit { $var{'form.footer'} = WebGUI::Form::formFooter(); $var{usePreview} = $self->getThread->getParent->get("usePreview"); $var{'user.isModerator'} = $self->getThread->getParent->canModerate; - $var{'user.isVisitor'} = ($session{user}{userId} eq '1'); + $var{'user.isVisitor'} = ($self->session->user->profileField("userId") eq '1'); $var{'visitorName.form'} = WebGUI::Form::text({ name=>"visitorName", value=>$self->getValue("visitorName") @@ -1095,13 +1095,13 @@ sub www_edit { value=>$self->getValue("contentType") || "mixed" }); my $startDate = $self->get("startDate"); - $startDate = WebGUI::DateTime::setToEpoch($session{form}{startDate}) if ($session{form}{startDate}); + $startDate = WebGUI::DateTime::setToEpoch($self->session->form->process("startDate")) if ($self->session->form->process("startDate")); $var{'startDate.form'} = WebGUI::Form::dateTime({ name => 'startDate', value => $startDate }); my $endDate = $self->get("endDate"); - $endDate = WebGUI::DateTime::setToEpoch($session{form}{endDate}) if ($session{form}{endDate}); + $endDate = WebGUI::DateTime::setToEpoch($self->session->form->process("endDate")) if ($self->session->form->process("endDate")); $var{'endDate.form'} = WebGUI::Form::dateTime({ name => 'endDate', value => $endDate @@ -1121,7 +1121,7 @@ The web method to rate a post. sub www_rate { my $self = shift; - $self->WebGUI::Asset::Post::rate($session{form}{rating}) if ($self->canView && !$self->hasRated); + $self->WebGUI::Asset::Post::rate($self->session->form->process("rating")) if ($self->canView && !$self->hasRated); $self->www_view; } diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 86e8fb2d3..d08770a79 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -35,7 +35,7 @@ sub canReply { #------------------------------------------------------------------- sub canSubscribe { my $self = shift; - return ($session{user}{userId} ne "1" && $self->canView); + return ($self->session->user->profileField("userId") ne "1" && $self->canView); } #------------------------------------------------------------------- @@ -149,7 +149,7 @@ A string indicating the type of layout to use. Can be flat or nested. sub getLayoutUrl { my $self = shift; my $layout = shift; - return $session{asset}->getUrl("layout=".$layout.'#id'.$session{asset}->getId) if (exists $session{asset}); + return $self->session->asset->getUrl("layout=".$layout.'#id'.$self->session->asset->getId) if (exists $self->session->asset); return $self->getUrl("layout=".$layout); } @@ -179,24 +179,24 @@ sub getNextThread { my $self = shift; unless (defined $self->{_next}) { my $sortBy = $self->getParent->getValue("sortBy"); - my ($id, $class, $version) = WebGUI::SQL->quickArray(" + my ($id, $class, $version) = $self->session->db->quickArray(" select asset.assetId,asset.className,max(assetData.revisionDate) from Thread left join asset on asset.assetId=Thread.assetId left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate - where asset.parentId=".quote($self->get("parentId"))." + where asset.parentId=".$self->session->db->quote($self->get("parentId"))." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' - and ".$sortBy.">".quote($self->get($sortBy))." + and ".$sortBy.">".$self->session->db->quote($self->get($sortBy))." and ( assetData.status in ('approved','archived') - or assetData.tagId=".quote($session{scratch}{versionTag})." - or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1') + or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag"))." + or (assetData.ownerUserId=".$self->session->db->quote($self->session->user->profileField("userId"))." and assetData.ownerUserId<>'1') ) group by assetData.assetId order by ".$sortBy." asc - ",WebGUI::SQL->getSlave); + ",$self->session->db->getSlave); $self->{_next} = WebGUI::Asset->new($id,$class,$version); # delete $self->{_next} unless ($self->{_next}->{_properties}{className} =~ /Thread/); }; @@ -217,23 +217,23 @@ sub getPreviousThread { my $self = shift; unless (defined $self->{_previous}) { my $sortBy = $self->getParent->getValue("sortBy"); - my ($id, $class, $version) = WebGUI::SQL->quickArray(" + my ($id, $class, $version) = $self->session->db->quickArray(" select asset.assetId,asset.className,max(assetData.revisionDate) from Thread left join asset on asset.assetId=Thread.assetId left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate - where asset.parentId=".quote($self->get("parentId"))." + where asset.parentId=".$self->session->db->quote($self->get("parentId"))." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' - and ".$sortBy."<".quote($self->get($sortBy))." + and ".$sortBy."<".$self->session->db->quote($self->get($sortBy))." and ( assetData.status in ('approved','archived') - or assetData.tagId=".quote($session{scratch}{versionTag})." - or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1') + or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag"))." + or (assetData.ownerUserId=".$self->session->db->quote($self->session->user->profileField("userId"))." and assetData.ownerUserId<>'1') ) group by assetData.assetId - order by ".$sortBy." desc, assetData.revisionDate desc ",WebGUI::SQL->getSlave); + order by ".$sortBy." desc, assetData.revisionDate desc ",$self->session->db->getSlave); $self->{_previous} = WebGUI::Asset::Post::Thread->new($id,$class,$version); # delete $self->{_previous} unless ($self->{_previous}->{_properties}{className} =~ /Thread/); }; @@ -375,7 +375,7 @@ Returns a boolean indicating whether this thread is marked read for the user. sub isMarkedRead { my $self = shift; return 1 if $self->isPoster; - my ($isRead) = WebGUI::SQL->quickArray("select count(*) from Post_read where userId=".quote($session{user}{userId})." and threadId=".quote($self->getId)." and postId=".quote($self->get("lastPostId"))); + my ($isRead) = $self->session->db->quickArray("select count(*) from Post_read where userId=".$self->session->db->quote($self->session->user->profileField("userId"))." and threadId=".$self->session->db->quote($self->getId)." and postId=".$self->session->db->quote($self->get("lastPostId"))); return $isRead; } @@ -446,18 +446,18 @@ sub rate { my $self = shift; my $rating = shift; unless ($self->hasRated) { - WebGUI::SQL->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (" - .quote($self->getId).", ".quote($session{user}{userId}).", ".quote($session{env}{REMOTE_ADDR}).", - ".WebGUI::DateTime::time().", ".quote($rating).")"); - my ($count) = WebGUI::SQL->quickArray("select count(*) from Post left join asset on Post.assetId=asset.assetId where Post.threadId=".quote($self->getId)." and Post.rating>0"); + $self->session->db->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (" + .$self->session->db->quote($self->getId).", ".$self->session->db->quote($self->session->user->profileField("userId")).", ".$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).", + ".WebGUI::DateTime::time().", ".$self->session->db->quote($rating).")"); + my ($count) = $self->session->db->quickArray("select count(*) from Post left join asset on Post.assetId=asset.assetId where Post.threadId=".$self->session->db->quote($self->getId)." and Post.rating>0"); $count = $count || 1; - my ($sum) = WebGUI::SQL->quickArray("select sum(Post.rating) from Post left join asset on Post.assetId=asset.assetId where Post.threadId=".quote($self->getId)." and Post.rating>0"); + my ($sum) = $self->session->db->quickArray("select sum(Post.rating) from Post left join asset on Post.assetId=asset.assetId where Post.threadId=".$self->session->db->quote($self->getId)." and Post.rating>0"); my $average = round($sum/$count); $self->update({rating=>$average}); - if ($session{setting}{useKarma}) { + if ($self->session->setting->get("useKarma")) { my $poster = WebGUI::User->new($self->get("ownerUserId")); $poster->karma($rating*$self->getParent->get("karmaRatingMultiplier"),"collaboration rating","someone rated post ".$self->getId); - my $rater = WebGUI::User->new($session{user}{userId}); + my $rater = WebGUI::User->new($self->session->user->profileField("userId")); $rater->karma(-$self->getParent->get("karmaSpentToRate"),"collaboration rating","spent karma to rate post ".$self->getId); } $self->getParent->recalculateRating; @@ -549,8 +549,8 @@ Subscribes the user to this thread. sub subscribe { my $self = shift; $self->createSubscriptionGroup; - WebGUI::Cache->new("cspost_".$self->getId."_".$session{user}{userId}."_".$session{scratch}{discussionLayout}."_".$session{form}{pn})->delete; - WebGUI::Grouping::addUsersToGroups([$session{user}{userId}],[$self->get("subscriptionGroupId")]); + WebGUI::Cache->new("cspost_".$self->getId."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"))->delete; + WebGUI::Grouping::addUsersToGroups([$self->session->user->profileField("userId")],[$self->get("subscriptionGroupId")]); } #------------------------------------------------------------------- @@ -567,7 +567,7 @@ sub trash { $self->getParent->decrementThreads; if ($self->getParent->get("lastPostId") eq $self->getId) { my $parentLineage = $self->getThread->get("lineage"); - my ($id, $date) = WebGUI::SQL->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".quote($parentLineage.'%')." and Post.assetId<>".quote($self->getId)." and Post.assetId=asset.assetId and asset.state='published' order by Post.dateSubmitted desc"); + my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($parentLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and Post.assetId=asset.assetId and asset.state='published' order by Post.dateSubmitted desc"); $self->getParent->setLastPost('','') ? $self->getParent->setLastPost($id,$date) : $id; } } @@ -609,8 +609,8 @@ Negates the subscribe method. sub unsubscribe { my $self = shift; - WebGUI::Cache->new("cspost_".$self->getId."_".$session{user}{userId}."_".$session{scratch}{discussionLayout}."_".$session{form}{pn})->delete; - WebGUI::Grouping::deleteUsersFromGroups([$session{user}{userId}],[$self->get("subscriptionGroupId")]); + WebGUI::Cache->new("cspost_".$self->getId."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"))->delete; + WebGUI::Grouping::deleteUsersFromGroups([$self->session->user->profileField("userId")],[$self->get("subscriptionGroupId")]); } @@ -618,12 +618,12 @@ sub unsubscribe { sub view { my $self = shift; $self->markRead; - $self->incrementViews unless ($session{form}{func} eq 'rate'); - WebGUI::Session::setScratch("discussionLayout",$session{form}{layout}); + $self->incrementViews unless ($self->session->form->process("func") eq 'rate'); + $self->session->scratch->set("discussionLayout",$self->session->form->process("layout")); my $var = $self->getTemplateVars; $self->getParent->appendTemplateLabels($var); - $var->{'user.isVisitor'} = ($session{user}{userId} eq '1'); + $var->{'user.isVisitor'} = ($self->session->user->profileField("userId") eq '1'); $var->{'user.isModerator'} = $self->getParent->canModerate; $var->{'user.canPost'} = $self->getParent->canPost; $var->{'user.canReply'} = $self->canReply; @@ -631,7 +631,7 @@ sub view { $var->{'layout.nested.url'} = $self->getLayoutUrl("nested"); $var->{'layout.flat.url'} = $self->getLayoutUrl("flat"); - my $layout = $session{scratch}{discussionLayout} || $session{user}{discussionLayout}; + my $layout = $self->session->scratch->get("discussionLayout") || $self->session->user->profileField("discussionLayout"); $var->{'layout.isFlat'} = ($layout eq "flat"); $var->{'layout.isNested'} = ($layout eq "nested" || !$var->{'layout.isFlat'}); @@ -651,14 +651,14 @@ sub view { my $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate from asset left join assetData on assetData.assetId=asset.assetId left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate - where asset.lineage like ".quote($self->get("lineage").'%') + where asset.lineage like ".$self->session->db->quote($self->get("lineage").'%') ." and asset.state='published' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and ( assetData.status in ('approved','archived') - or assetData.tagId=".quote($session{scratch}{versionTag}); + or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")); $sql .= " or assetData.status='pending'" if ($self->getParent->canModerate); - $sql .= " or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1') + $sql .= " or (assetData.ownerUserId=".$self->session->db->quote($self->session->user->profileField("userId"))." and assetData.ownerUserId<>'1') )) group by assetData.assetId order by "; @@ -794,23 +794,23 @@ sub www_view { my $cache; my $output; my $useCache = ( - $session{form}{op} eq "" && - $session{form}{func} eq "" && - $session{form}{layout} eq "" && + $self->session->form->process("op") eq "" && + $self->session->form->process("func") eq "" && + $self->session->form->process("layout") eq "" && ( - ( $self->getParent->get("cacheTimeout") > 10 && $session{user}{userId} ne '1') || - ( $self->getParent->get("cacheTimeoutVisitor") > 10 && $session{user}{userId} eq '1') + ( $self->getParent->get("cacheTimeout") > 10 && $self->session->user->profileField("userId") ne '1') || + ( $self->getParent->get("cacheTimeoutVisitor") > 10 && $self->session->user->profileField("userId") eq '1') ) && - not $session{var}{adminOn} + not $self->session->var->get("adminOn") ); if ($useCache) { - $cache = WebGUI::Cache->new("cspost_".($postId||$self->getId)."_".$session{user}{userId}."_".$session{scratch}{discussionLayout}."_".$session{form}{pn}); + $cache = WebGUI::Cache->new("cspost_".($postId||$self->getId)."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn")); $output = $cache->get; } unless ($output) { $output = $self->getParent->processStyle($self->view); my $ttl; - if ($session{user}{userId} eq '1') { + if ($self->session->user->profileField("userId") eq '1') { $ttl = $self->getParent->get("cacheTimeoutVisitor"); } else { $ttl = $self->getParent->get("cacheTimeout"); diff --git a/lib/WebGUI/Asset/Redirect.pm b/lib/WebGUI/Asset/Redirect.pm index ac4f969c1..3e96b590a 100644 --- a/lib/WebGUI/Asset/Redirect.pm +++ b/lib/WebGUI/Asset/Redirect.pm @@ -117,7 +117,7 @@ A web executable method that redirects the user to the specified page, or displa sub www_view { my $self = shift; return WebGUI::Privilege::noAccess() unless $self->canView; - if ($session{var}{adminOn}) { + if ($self->session->var->get("adminOn")) { return $self->getContainer->www_view; } my $url = $self->get("redirectUrl"); diff --git a/lib/WebGUI/Asset/RichEdit.pm b/lib/WebGUI/Asset/RichEdit.pm index b6b22e2a4..6422f6ea8 100644 --- a/lib/WebGUI/Asset/RichEdit.pm +++ b/lib/WebGUI/Asset/RichEdit.pm @@ -459,12 +459,12 @@ sub getRichEditor { $config{theme_advanced_source_editor_height} = $self->getValue("sourceEditorHeight") if ($self->getValue("sourceEditorHeight") > 0); } } - my $language = WebGUI::International::getLanguage($session{user}{language},"languageAbbreviation"); + my $language = WebGUI::International::getLanguage($self->session->user->profileField("language"),"languageAbbreviation"); unless ($language) { $language = WebGUI::International::getLanguage("English","languageAbbreviation"); } $config{language} = $language; - $config{content_css} = $self->getValue("cssFile") || $session{config}{extrasURL}.'/tinymce2/defaultcontent.css'; + $config{content_css} = $self->getValue("cssFile") || $self->session->config->get("extrasURL").'/tinymce2/defaultcontent.css'; $config{width} = $self->getValue("editorWidth") if ($self->getValue("editorWidth") > 0); $config{height} = $self->getValue("editorHeight") if ($self->getValue("editorHeight") > 0); $config{plugins} = join(",",@plugins); @@ -476,8 +476,8 @@ sub getRichEditor { push(@directives,$key." : '".$config{$key}."'"); } } - WebGUI::Style::setScript($session{config}{extrasURL}."/tinymce2/jscripts/tiny_mce/tiny_mce.js",{type=>"text/javascript"}); - WebGUI::Style::setScript($session{config}{extrasURL}."/tinymce2/jscripts/webgui.js",{type=>"text/javascript"}); + $self->session->style->setScript($self->session->config->get("extrasURL")."/tinymce2/jscripts/tiny_mce/tiny_mce.js",{type=>"text/javascript"}); + $self->session->style->setScript($self->session->config->get("extrasURL")."/tinymce2/jscripts/webgui.js",{type=>"text/javascript"}); return ''; - $output .= ''; + $output .= ''; $output .= qq||; @@ -213,7 +213,7 @@ sub definition { #------------------------------------------------------------------- sub discernUserId { my $self = shift; - return ($self->canManage && WebGUI::Session::isAdminOn()) ? '1' : $session{user}{userId}; + return ($self->canManage && WebGUI::Session::isAdminOn()) ? '1' : $self->session->user->profileField("userId"); } #------------------------------------------------------------------- @@ -233,7 +233,7 @@ sub getEditForm { -hoverHelp=>WebGUI::International::get('shortcut template title description', 'Asset_Shortcut'), -namespace=>"Shortcut" ); - if($session{setting}{metaDataEnabled}) { + if($self->session->setting->get("metaDataEnabled")) { $tabform->getTab("properties")->yesNo( -name=>"shortcutByCriteria", -value=>$self->getValue("shortcutByCriteria"), @@ -294,7 +294,7 @@ sub getEditForm { =head2 getExtraHeadTags ( ) -Returns the extraHeadTags stored in the asset. Called in WebGUI::Style::generateAdditionalHeadTags if this asset is the $session{asset}. Also called in WebGUI::Layout::view for its child assets. Overriden here in Shortcut.pm. +Returns the extraHeadTags stored in the asset. Called in $self->session->style->generateAdditionalHeadTags if this asset is the $self->session->asset. Also called in WebGUI::Layout::view for its child assets. Overriden here in Shortcut.pm. =cut @@ -376,7 +376,7 @@ sub getOverrides { my $self = shift; my $i = 0; #cache by userId, assetId of this shortcut, and whether adminMode is on or not. - my $cache = WebGUI::Cache->new(["shortcutOverrides",$self->getId,$session{user}{userId},$session{var}{adminOn}]); + my $cache = WebGUI::Cache->new(["shortcutOverrides",$self->getId,$self->session->user->profileField("userId"),$self->session->var->get("adminOn")]); my $overridesRef = $cache->get; unless ($overridesRef->{cacheNotExpired}) { my %overrides; @@ -389,7 +389,7 @@ sub getOverrides { $orig->{_propertyDefinitions} = \%properties; } $overrides{cacheNotExpired} = 1; - my $sth = WebGUI::SQL->read("select fieldName, newValue from Shortcut_overrides where assetId=".quote($self->getId)." order by fieldName"); + my $sth = $self->session->db->read("select fieldName, newValue from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." order by fieldName"); while (my ($fieldName, $newValue) = $sth->array) { $overrides{overrides}{$fieldName}{fieldType} = $orig->{_propertyDefinitions}{$fieldName}{fieldType}; $overrides{overrides}{$fieldName}{origValue} = $self->getShortcutOriginal->get($fieldName); @@ -464,7 +464,7 @@ sub getShortcutByCriteria { if ($assetId) { $scratchId = "Shortcut_" . $assetId; if($session{scratch}{$scratchId} && !$self->getValue("disableContentLock")) { - return $session{scratch}{$scratchId} unless ($session{var}{adminOn}); + return $session{scratch}{$scratchId} unless ($self->session->var->get("adminOn")); } } @@ -495,10 +495,10 @@ sub getShortcutByCriteria { my $quotedField = $field; my $quotedValue = $value; unless ($field =~ /^\s*['"].*['"]\s*/) { - $quotedField = quote($field); + $quotedField = $self->session->db->quote($field); } unless ($value =~ /^\s*['"].*['"]\s*/) { - $quotedValue = quote($value); + $quotedValue = $self->session->db->quote($value); } # transform replacement from "State = Wisconsin" to @@ -513,7 +513,7 @@ sub getShortcutByCriteria { from metaData_values d, metaData_properties f, asset w where f.fieldId = d.fieldId and w.assetId = d.assetId - and w.className=".quote($self->getShortcutDefault->get("className")); + and w.className=".$self->session->db->quote($self->getShortcutDefault->get("className")); # Add constraint only if it has been modified. @@ -523,7 +523,7 @@ sub getShortcutByCriteria { # Execute the query with an unconditional read my @ids; - my $sth = WebGUI::SQL->unconditionalRead($sql); + my $sth = $self->session->db->unconditionalRead($sql); while (my ($data) = $sth->array) { push (@ids, $data); } @@ -543,7 +543,7 @@ sub getShortcutByCriteria { } # Store the matching assetId in user scratch. - WebGUI::Session::setScratch($scratchId,$id) if ($scratchId); + $self->session->scratch->set($scratchId,$id) if ($scratchId); return WebGUI::Asset->newByDynamicClass($id); } @@ -588,7 +588,7 @@ sub processPropertiesFromFormPost { my $self = shift; $self->SUPER::processPropertiesFromFormPost; my $scratchId = "Shortcut_" . $self->getId; - WebGUI::Session::deleteAllScratch($scratchId); + $self->session->scratch->deleteAll($scratchId); } #------------------------------------------------------------------- @@ -618,7 +618,7 @@ sub view { foreach my $prop (keys %{$self->{_shortcut}{_properties}}) { next if ($prop eq 'content' || $prop eq 'label' || $prop eq 'url'); $var{'shortcut.'.$prop} = $self->{_shortcut}{_properties}{$prop}; - WebGUI::ErrorHandler::warn($prop.' = '.$self->{_shortcut}{_properties}{$prop}); + $self->session->errorHandler->warn($prop.' = '.$self->{_shortcut}{_properties}{$prop}); } return $self->processTemplate(\%var,$self->getValue("templateId")); } @@ -636,7 +636,7 @@ sub www_edit { sub www_getUserPrefsForm { #This is a form retrieved by "ajax". my $self = shift; - return 'You are no longer logged in' if $session{user}{userId} eq '1'; + return 'You are no longer logged in' if $self->session->user->profileField("userId") eq '1'; return 'You are not allowed to personalize this Dashboard.' unless $self->getParent->canPersonalize; my $output; my @fielden = $self->getPrefFieldsToShow; @@ -692,7 +692,7 @@ sub www_purgeOverrideCache { sub www_deleteOverride { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - WebGUI::SQL->write('delete from Shortcut_overrides where assetId='.quote($self->getId).' and fieldName='.quote($session{form}{fieldName})); + $self->session->db->write('delete from Shortcut_overrides where assetId='.$self->session->db->quote($self->getId).' and fieldName='.$self->session->db->quote($self->session->form->process("fieldName"))); $self->uncacheOverrides; return $self->www_manageOverrides; } @@ -733,7 +733,7 @@ sub www_editOverride { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; my $i18n = WebGUI::International->new("Asset_Shortcut"); - my $fieldName = $session{form}{fieldName}; + my $fieldName = $self->session->form->process("fieldName"); my %overrides = $self->getOverrides; my $output = ''; my %props; @@ -743,8 +743,8 @@ sub www_editOverride { $output .= '
$shortcutCriteriaField
$conjunctionField
'; my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden(-name=>"func",-value=>"saveOverride"); - $f->hidden(-name=>"overrideFieldName",-value=>$session{form}{fieldName}); - $f->readOnly(-label=>$i18n->get("fieldName"),-value=>$session{form}{fieldName}); + $f->hidden(-name=>"overrideFieldName",-value=>$self->session->form->process("fieldName")); + $f->readOnly(-label=>$i18n->get("fieldName"),-value=>$self->session->form->process("fieldName")); $f->readOnly(-label=>$i18n->get("Original Value"),-value=>$overrides{overrides}{$fieldName}{origValue}); my %params; foreach my $key (keys %{$props{$fieldName}}) { @@ -773,7 +773,7 @@ sub www_editOverride { sub www_saveOverride { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - my $fieldName = $session{form}{overrideFieldName}; + my $fieldName = $self->session->form->process("overrideFieldName"); my %overrides = $self->getOverrides; my $output = ''; my %props; @@ -781,10 +781,10 @@ sub www_saveOverride { %props = (%props,%{$def->{properties}}); } my $fieldType = $props{$fieldName}{fieldType}; - my $value = WebGUI::FormProcessor::process($fieldName,$fieldType); - $value = $session{form}{newOverrideValueText} || $value; - WebGUI::SQL->write("delete from Shortcut_overrides where assetId=".quote($self->getId)." and fieldName=".quote($fieldName)); - WebGUI::SQL->write("insert into Shortcut_overrides values (".quote($self->getId).",".quote($fieldName).",".quote($value).")"); + my $value = $self->session->form->process($fieldName,$fieldType); + $value = $self->session->form->process("newOverrideValueText") || $value; + $self->session->db->write("delete from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." and fieldName=".$self->session->db->quote($fieldName)); + $self->session->db->write("insert into Shortcut_overrides values (".$self->session->db->quote($self->getId).",".$self->session->db->quote($fieldName).",".$self->session->db->quote($value).")"); $self->uncacheOverrides; return $self->www_manageOverrides; } @@ -794,8 +794,8 @@ sub www_view { my $self = shift; if ($self->isDashlet) { return WebGUI::Privilege::noAccess() unless $self->canView; - $session{asset} = $self->getParent; - return $session{asset}->www_view; + $self->session->asset = $self->getParent; + return $self->session->asset->www_view; } else { return $self->getShortcut->www_view; } diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index 0f001de30..784375d8b 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -150,7 +150,7 @@ sub view { my $calledAsWebMethod = shift; my $output = $self->get("snippet"); WebGUI::Macro::process(\$output); - $output = '

'.$self->getToolbar.'

'.$output if ($session{var}{adminOn} && !$calledAsWebMethod); + $output = '

'.$self->getToolbar.'

'.$output if ($self->session->var->get("adminOn") && !$calledAsWebMethod); return $output unless ($self->getValue("processAsTemplate")); return WebGUI::Asset::Template->processRaw($output); } diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index ec76a2c45..af9f088a1 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -77,7 +77,7 @@ sub _execute { $t->param("webgui.status"=>$WebGUI::STATUS); return $t->output; } else { - WebGUI::ErrorHandler::error("Error in template. ".$@); + $self->session->errorHandler->error("Error in template. ".$@); return WebGUI::International::get('template error', 'Asset_Template').$@; } } @@ -140,17 +140,17 @@ sub getEditForm { my $tabform = $self->SUPER::getEditForm(); $tabform->hidden({ name=>"returnUrl", - value=>$session{form}{returnUrl} + value=>$self->session->form->process("returnUrl") }); if ($self->getValue("namespace") eq "") { - my $namespaces = WebGUI::SQL->buildHashRef("select distinct(namespace),namespace + my $namespaces = $self->session->db->buildHashRef("select distinct(namespace),namespace from template order by namespace"); $tabform->getTab("properties")->combo( -name=>"namespace", -options=>$namespaces, -label=>WebGUI::International::get('namespace','Asset_Template'), -hoverHelp=>WebGUI::International::get('namespace description','Asset_Template'), - -value=>[$session{form}{namespace}] + -value=>[$self->session->form->process("namespace")] ); } else { $tabform->getTab("meta")->readOnly( @@ -199,8 +199,8 @@ Specify the namespace to build the list for. sub getList { my $class = shift; my $namespace = shift; -my $sql = "select asset.assetId, assetData.revisionDate from template left join asset on asset.assetId=template.assetId left join assetData on assetData.revisionDate=template.revisionDate and assetData.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 and asset.state='published' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")) order by assetData.title"; - my $sth = WebGUI::SQL->read($sql,WebGUI::SQL->getSlave); +my $sql = "select asset.assetId, assetData.revisionDate from template left join asset on asset.assetId=template.assetId left join assetData on assetData.revisionDate=template.revisionDate and assetData.assetId=template.assetId where template.namespace=".$self->session->db->quote($namespace)." and template.showInForms=1 and asset.state='published' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")) order by assetData.title"; + my $sth = $self->session->db->read($sql,$self->session->db->getSlave); my %templates; tie %templates, 'Tie::IxHash'; while (my ($id, $version) = $sth->array) { @@ -230,7 +230,7 @@ sub process { return $self->processRaw($self->get("template"),$vars); # skip all the junk below here for now until we have time to bring it inline with the new system my $file = _getTemplateFile($self->get("templateId")); - my $fileCacheDir = $session{config}{uploadsPath}.'/temp/templatecache'; + my $fileCacheDir = $self->session->config->get("uploadsPath").'/temp/templatecache'; my %params = ( filename=>$file->getPath, global_vars=>1, @@ -241,34 +241,34 @@ sub process { strict=>0 ); my $error=0; - if ($session{config}{templateCacheType} =~ /file/) { + if ($self->session->config->get("templateCacheType") =~ /file/) { eval { mkpath($fileCacheDir) }; if($@) { - WebGUI::ErrorHandler::error("Could not create dir $fileCacheDir: $@\nTemplate file caching disabled"); + $self->session->errorHandler->error("Could not create dir $fileCacheDir: $@\nTemplate file caching disabled"); $error++; } if(not -w $fileCacheDir) { - WebGUI::ErrorHandler::error("Directory $fileCacheDir is not writable. Template file caching is disabled"); + $self->session->errorHandler->error("Directory $fileCacheDir is not writable. Template file caching is disabled"); $error++; } } - if ($session{config}{templateCacheType} eq "file" && not $error) { + if ($self->session->config->get("templateCacheType") eq "file" && not $error) { # disabled until we can figure out what's wrong with it # $params{file_cache} = 1; - } elsif ($session{config}{templateCacheType} eq "memory") { + } elsif ($self->session->config->get("templateCacheType") eq "memory") { $params{cache} = 1; - } elsif ($session{config}{templateCacheType} eq "ipc") { + } elsif ($self->session->config->get("templateCacheType") eq "ipc") { $params{shared_cache} = 1; - } elsif ($session{config}{templateCacheType} eq "memory-ipc") { + } elsif ($self->session->config->get("templateCacheType") eq "memory-ipc") { $params{double_cache} = 1; - } elsif ($session{config}{templateCacheType} eq "memory-file" && not $error) { + } elsif ($self->session->config->get("templateCacheType") eq "memory-file" && not $error) { $params{double_file_cache} = 1; } my $template; unless (-e $file->getPath) { $file->saveFromScalar($self->get("template")); unless (-e $file->getPath) { - WebGUI::ErrorHandler::error("Could not create file ".$file->getPath."\nTemplate file caching is disabled"); + $self->session->errorHandler->error("Could not create file ".$file->getPath."\nTemplate file caching is disabled"); $params{scalarref} = \$template; delete $params{filename}; } @@ -335,7 +335,7 @@ sub www_edit { #------------------------------------------------------------------- sub www_goBackToPage { my $self = shift; - WebGUI::HTTP::setRedirect($session{form}{returnUrl}) if ($session{form}{returnUrl}); + WebGUI::HTTP::setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl")); return ""; } @@ -356,12 +356,12 @@ sub www_styleWizard { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; my $output = ""; - if ($session{form}{step} == 2) { + if ($self->session->form->process("step") == 2) { my $f = WebGUI::HTMLForm->new({action=>$self->getUrl}); $f->hidden(name=>"func", value=>"styleWizard"); - $f->hidden(name=>"proceed", value=>"manageAssets") if ($session{form}{proceed}); + $f->hidden(name=>"proceed", value=>"manageAssets") if ($self->session->form->process("proceed")); $f->hidden(name=>"step", value=>3); - $f->hidden(name=>"layout", value=>$session{form}{layout}); + $f->hidden(name=>"layout", value=>$self->session->form->process("layout")); $f->text(name=>"heading", value=>"My Site", label=>"Site Name"); $f->file(name=>"logo", label=>"Logo", subtext=>"
JPEG, GIF, or PNG thats less than 200 pixels wide and 100 pixels tall"); $f->color(name=>"pageBackgroundColor", value=>"#ccccdd", label=>"Page Background Color"); @@ -374,16 +374,16 @@ sub www_styleWizard { $f->color(name=>"visitedLinkColor", value=>"#ff00ff", label=>"Visited Link Color"); $f->submit; $output = $f->print; - } elsif ($session{form}{step} == 3) { - my $storageId = WebGUI::FormProcessor::file("logo"); + } elsif ($self->session->form->process("step") == 3) { + my $storageId = $self->session->form->file("logo"); my $logo; if ($storageId) { - my $storage = WebGUI::Storage::Image->get(WebGUI::FormProcessor::file("logo")); + my $storage = WebGUI::Storage::Image->get($self->session->form->file("logo")); $logo = $self->addChild({ className=>"WebGUI::Asset::File::Image", - title=>WebGUI::FormProcessor::text("heading")." Logo", - menuTitle=>WebGUI::FormProcessor::text("heading")." Logo", - url=>WebGUI::FormProcessor::text("heading")." Logo", + title=>$self->session->form->text("heading")." Logo", + menuTitle=>$self->session->form->text("heading")." Logo", + url=>$self->session->form->text("heading")." Logo", storageId=>$storage->getId, filename=>@{$storage->getFiles}[0], templateId=>"PBtmpl0000000000000088" @@ -403,13 +403,13 @@ my $style = ' font-size: 12px; } body { - background-color: '.WebGUI::FormProcessor::color("pageBackgroundColor").'; + background-color: '.$self->session->form->color("pageBackgroundColor").'; font-family: helvetica; font-size: 14px; } .heading { - background-color: '.WebGUI::FormProcessor::color("headingBackgroundColor").'; - color: '.WebGUI::FormProcessor::color("headingForegroundColor").'; + background-color: '.$self->session->form->color("headingBackgroundColor").'; + color: '.$self->session->form->color("headingForegroundColor").'; font-size: 30px; margin-left: 10%; margin-right: 10%; @@ -430,10 +430,10 @@ my $style = ' padding: 5px; } .bodyContent { - background-color: '.WebGUI::FormProcessor::color("bodyBackgroundColor").'; - color: '.WebGUI::FormProcessor::color("bodyForegroundColor").'; + background-color: '.$self->session->form->color("bodyBackgroundColor").'; + color: '.$self->session->form->color("bodyForegroundColor").'; width: 55%; '; -if ($session{form}{layout} == 1) { +if ($self->session->form->process("layout") == 1) { $style .= ' float: left; height: 75%; @@ -449,9 +449,9 @@ if ($session{form}{layout} == 1) { $style .= ' } .menu { - background-color: '.WebGUI::FormProcessor::color("menuBackgroundColor").'; + background-color: '.$self->session->form->color("menuBackgroundColor").'; width: 25%; '; -if ($session{form}{layout} == 1) { +if ($self->session->form->process("layout") == 1) { $style .= ' margin-left: 10%; height: 75%; @@ -468,10 +468,10 @@ if ($session{form}{layout} == 1) { $style .= ' } a { - color: '.WebGUI::FormProcessor::color("linkColor").'; + color: '.$self->session->form->color("linkColor").'; } a:visited { - color: '.WebGUI::FormProcessor::color("visitedLinkColor").'; + color: '.$self->session->form->color("visitedLinkColor").'; } @@ -484,17 +484,17 @@ if ($session{form}{layout} == 1) { $style .= ''; } $style .= ' - '.WebGUI::FormProcessor::text("heading").' + '.$self->session->form->text("heading").'
'; -if ($session{form}{layout} == 1) { +if ($self->session->form->process("layout") == 1) { $style .= '
'; } $style .= ' @@ -512,7 +512,7 @@ $style .= ' })->www_edit; } else { $output = WebGUI::Form::formHeader({action=>$self->getUrl}).WebGUI::Form::hidden({name=>"func", value=>"styleWizard"}); - $output .= WebGUI::Form::hidden({name=>"proceed", value=>"manageAssets"}) if ($session{form}{proceed}); + $output .= WebGUI::Form::hidden({name=>"proceed", value=>"manageAssets"}) if ($self->session->form->process("proceed")); $output .= ' '); $vars{"dragger.icon"} = WebGUI::Icon::dragIcon(); $vars{"dragger.init"} = ' - + @@ -221,9 +221,9 @@ sub www_setContentPositions { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); $self->addRevision({ - contentPositions=>$session{form}{map} + contentPositions=>$self->session->form->process("map") }); - return "Map set: ".$session{form}{map}; + return "Map set: ".$self->session->form->process("map"); } diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 0e1cfad82..489d6eb5b 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -131,9 +131,9 @@ sub getCompareForm { name=>"listingId", vertical=>1, value=>\@ids, - options=>WebGUI::SQL->buildHashRef("select listingId, concat('$self->session->db->buildHashRef("select listingId, concat('getUrl("func=viewDetail")."&listingId=',listingId,'\\\">', productName,'') from Matrix_listing - where assetId=".quote($self->getId)." and status='approved' order by productName") + where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by productName") }) ."
" .WebGUI::Form::submit({ @@ -150,9 +150,9 @@ sub hasRated { my $listingId = shift; return 1 unless (WebGUI::Grouping::isInGroup($self->get("groupToRate"))); my $ratingTimeout = WebGUI::Grouping::isInGroup($self->get("privilegedGroup")) ? $self->get("ratingTimeoutPrivileged") : $self->get("ratingTimeout"); - my ($hasRated) = WebGUI::SQL->quickArray("select count(*) from Matrix_rating where - ((userId=".quote($session{user}{userId})." and userId<>'1') or (userId='1' and ipAddress=".quote($session{env}{HTTP_X_FORWARDED_FOR}).")) and - listingId=".quote($listingId)." and timeStamp>".(WebGUI::DateTime::time()-$ratingTimeout)); + my ($hasRated) = $self->session->db->quickArray("select count(*) from Matrix_rating where + ((userId=".$self->session->db->quote($self->session->user->profileField("userId"))." and userId<>'1') or (userId='1' and ipAddress=".$self->session->db->quote($self->session->env->get("HTTP_X_FORWARDED_FOR")).")) and + listingId=".$self->session->db->quote($listingId)." and timeStamp>".(WebGUI::DateTime::time()-$ratingTimeout)); return $hasRated; } @@ -160,20 +160,20 @@ sub hasRated { sub incrementCounter { my $listingId = shift; my $counter = shift; - my ($lastIp) = WebGUI::SQL->quickArray("select ".$counter."LastIp from Matrix_listing where listingId = ".quote($listingId)); - unless ($lastIp eq $session{env}{HTTP_X_FORWARDED_FOR}) { - WebGUI::SQL->write("update Matrix_listing set $counter=$counter+1, ".$counter."LastIp=".quote($session{env}{HTTP_X_FORWARDED_FOR})." where listingId=".quote($listingId)); + my ($lastIp) = $self->session->db->quickArray("select ".$counter."LastIp from Matrix_listing where listingId = ".$self->session->db->quote($listingId)); + unless ($lastIp eq $self->session->env->get("HTTP_X_FORWARDED_FOR")) { + $self->session->db->write("update Matrix_listing set $counter=$counter+1, ".$counter."LastIp=".$self->session->db->quote($self->session->env->get("HTTP_X_FORWARDED_FOR"))." where listingId=".$self->session->db->quote($listingId)); } } #------------------------------------------------------------------- sub purge { my $self = shift; - WebGUI::SQL->write("delete from Matrix_listing where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Matrix_listingData where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Matrix_field where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Matrix_rating where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Matrix_ratingSummary where assetId=".quote($self->getId)); + $self->session->db->write("delete from Matrix_listing where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Matrix_listingData where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Matrix_field where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Matrix_rating where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Matrix_ratingSummary where assetId=".$self->session->db->quote($self->getId)); $self->SUPER::purge; } @@ -184,18 +184,18 @@ sub setRatings { my $ratings = shift; foreach my $category ($self->getCategories) { if ($ratings->{$category}) { - WebGUI::SQL->write("insert into Matrix_rating (userId, category, rating, timeStamp, listingId,ipAddress, assetId) values ( - ".quote($session{user}{userId}).", ".quote($category).", ".quote($ratings->{$category}).", ".WebGUI::DateTime::time() - .", ".quote($listingId).", ".quote($session{env}{HTTP_X_FORWARDED_FOR}).",".quote($self->getId).")"); + $self->session->db->write("insert into Matrix_rating (userId, category, rating, timeStamp, listingId,ipAddress, assetId) values ( + ".$self->session->db->quote($self->session->user->profileField("userId")).", ".$self->session->db->quote($category).", ".$self->session->db->quote($ratings->{$category}).", ".WebGUI::DateTime::time() + .", ".$self->session->db->quote($listingId).", ".$self->session->db->quote($self->session->env->get("HTTP_X_FORWARDED_FOR")).",".$self->session->db->quote($self->getId).")"); } - my $sql = "from Matrix_rating where listingId=".quote($listingId)." and category=".quote($category); - my ($sum) = WebGUI::SQL->quickArray("select sum(rating) $sql"); - my ($count) = WebGUI::SQL->quickArray("select count(*) $sql"); + my $sql = "from Matrix_rating where listingId=".$self->session->db->quote($listingId)." and category=".$self->session->db->quote($category); + my ($sum) = $self->session->db->quickArray("select sum(rating) $sql"); + my ($count) = $self->session->db->quickArray("select count(*) $sql"); my $half = round($count/2); my $mean = $sum / ($count || 1); - my ($median) = WebGUI::SQL->quickArray("select rating $sql limit $half,$half"); - WebGUI::SQL->write("replace into Matrix_ratingSummary (listingId, category, meanValue, medianValue, countValue,assetId) values ( - ".quote($listingId).", ".quote($category).", $mean, ".quote($median).", $count, ".quote($self->getId).")"); + my ($median) = $self->session->db->quickArray("select rating $sql limit $half,$half"); + $self->session->db->write("replace into Matrix_ratingSummary (listingId, category, meanValue, medianValue, countValue,assetId) values ( + ".$self->session->db->quote($listingId).", ".$self->session->db->quote($category).", $mean, ".$self->session->db->quote($median).", $count, ".$self->session->db->quote($self->getId).")"); } } @@ -203,11 +203,11 @@ sub setRatings { sub www_approveListing { my $self = shift; return WebGUI::Privilege::insufficient() unless($self->canEdit); - my $listing = WebGUI::SQL->getRow("Matrix_listing","listingId",$session{form}{listingId}); - WebGUI::SQL->write("update Matrix_listing set status='approved' where listingId=".quote($session{form}{listingId})); + my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId")); + $self->session->db->write("update Matrix_listing set status='approved' where listingId=".$self->session->db->quote($self->session->form->process("listingId"))); WebGUI::MessageLog::addEntry($listing->{maintainerId},"","New Listing Approved","Your new listing, ".$listing->{productName}.", has been approved.", - $self->formatURL("viewDetail",$session{form}{listingId}),"notice"); - WebGUI::MessageLog::completeEntry($session{form}{mlog}); + $self->formatURL("viewDetail",$self->session->form->process("listingId")),"notice"); + WebGUI::MessageLog::completeEntry($self->session->form->process("mlog")); return $self->www_viewDetail; } @@ -215,9 +215,9 @@ sub www_approveListing { #------------------------------------------------------------------- sub www_click { my $self = shift; - incrementCounter($session{form}{listingId},"clicks"); - my $listing = WebGUI::SQL->getRow("Matrix_listing","listingId",$session{form}{listingId}); - if ($session{form}{m}) { + incrementCounter($self->session->form->process("listingId"),"clicks"); + my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId")); + if ($self->session->form->process("m")) { WebGUI::HTTP::setRedirect($listing->{manufacturerUrl}); } else { WebGUI::HTTP::setRedirect($listing->{productUrl}); @@ -231,7 +231,7 @@ sub www_compare { my $self = shift; my @cmsList = @_; unless (scalar(@cmsList)) { - @cmsList = WebGUI::FormProcessor::checkList("listingId"); + @cmsList = $self->session->form->checkList("listingId"); } my ( %var, @prodcol, @datecol); my $max = WebGUI::Grouping::isInGroup($self->get("privilegedGroup")) ? $self->get("maxComparisonsPrivileged") : $self->get("maxComparisons"); @@ -243,8 +243,8 @@ sub www_compare { } foreach my $cms (@cmsList) { incrementCounter($cms,"compares"); - my $data = WebGUI::SQL->quickHashRef("select listingId, productName, versionNumber, lastUpdated - from Matrix_listing where listingId=".quote($cms)); + my $data = $self->session->db->quickHashRef("select listingId, productName, versionNumber, lastUpdated + from Matrix_listing where listingId=".$self->session->db->quote($cms)); push(@prodcol, { name=>$data->{productName} || "__untitled__", version=>$data->{versionNumber}, @@ -265,10 +265,10 @@ sub www_compare { foreach my $cms (@cmsList) { $select .= ", ".$tableCount.".value"; $from .= " left join Matrix_listingData ".$tableCount." on a.fieldId=" - .$tableCount.".fieldId and ".$tableCount.".listingId=".quote($cms); + .$tableCount.".fieldId and ".$tableCount.".listingId=".$self->session->db->quote($cms); $tableCount++; } - my $sth = WebGUI::SQL->read("$select $from where a.category=".quote($category)." order by a.label"); + my $sth = $self->session->db->read("$select $from where a.category=".$self->session->db->quote($category)." order by a.label"); while (my @row = $sth->array) { my @columnloop; my $first = 1; @@ -316,8 +316,8 @@ sub www_copy { sub www_deleteListing { my $self = shift; my $output = sprintf WebGUI::International::get('delete listing confirmation','Asset_Matrix'), - $self->getUrl("func=deleteListingConfirm&listingId=".$session{form}{listingId}), - $self->formatURL("viewDetail",$session{form}{listingId}); + $self->getUrl("func=deleteListingConfirm&listingId=".$self->session->form->process("listingId")), + $self->formatURL("viewDetail",$self->session->form->process("listingId")); return $self->processStyle($output); } @@ -325,14 +325,14 @@ sub www_deleteListing { sub www_deleteListingConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless($self->canEdit); - my $listing = WebGUI::SQL->getRow("Matrix_listing","listingId",$session{form}{listingId}); + my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId")); WebGUI::Asset::Wobject::Collaboration->new($listing->{forumId})->purge; - WebGUI::SQL->write("delete from Matrix_listing where listingId=".quote($session{form}{listingId})); - WebGUI::SQL->write("delete from Matrix_listingData where listingId=".quote($session{form}{listingId})); - WebGUI::SQL->write("delete from Matrix_rating where listingId=".quote($session{form}{listingId})); - WebGUI::SQL->write("delete from Matrix_ratingSummary where listingId=".quote($session{form}{listingId})); + $self->session->db->write("delete from Matrix_listing where listingId=".$self->session->db->quote($self->session->form->process("listingId"))); + $self->session->db->write("delete from Matrix_listingData where listingId=".$self->session->db->quote($self->session->form->process("listingId"))); + $self->session->db->write("delete from Matrix_rating where listingId=".$self->session->db->quote($self->session->form->process("listingId"))); + $self->session->db->write("delete from Matrix_ratingSummary where listingId=".$self->session->db->quote($self->session->form->process("listingId"))); WebGUI::MessageLog::addEntry($listing->{maintainerId},"","Listing Deleted","Your listing, ".$listing->{productName}.", has been deleted from the matrix.","","notice"); - WebGUI::MessageLog::completeEntry($session{form}{mlog}); + WebGUI::MessageLog::completeEntry($self->session->form->process("mlog")); return ""; } @@ -440,8 +440,8 @@ sub www_edit { #------------------------------------------------------------------- sub www_editListing { my $self = shift; - my $listing= WebGUI::SQL->getRow("Matrix_listing","listingId",$session{form}{listingId}); - return WebGUI::International('no edit rights','Asset_Matrix') unless (($session{form}{listingId} eq "new" && WebGUI::Grouping::isInGroup($self->get("groupToAdd"))) || $session{user}{userId} eq $listing->{maintainerId} || $self->canEdit); + my $listing= $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId")); + return WebGUI::International('no edit rights','Asset_Matrix') unless (($self->session->form->process("listingId") eq "new" && WebGUI::Grouping::isInGroup($self->get("groupToAdd"))) || $self->session->user->profileField("userId") eq $listing->{maintainerId} || $self->canEdit); my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden( -name=>"func", @@ -449,7 +449,7 @@ sub www_editListing { ); $f->hidden( -name=>"listingId", - -value=>$session{form}{listingId} + -value=>$self->session->form->process("listingId") ); $f->text( -name=>"productName", @@ -487,7 +487,7 @@ sub www_editListing { -name=>"maintainerId", -value=>[$listing->{maintainerId}], -label=>WebGUI::International::get('listing maintainer','Asset_Matrix'), - -options=>WebGUI::SQL->buildHashRef("select userId,username from users order by username") + -options=>$self->session->db->buildHashRef("select userId,username from users order by username") ); } my %goodBad = ( @@ -500,14 +500,14 @@ sub www_editListing { foreach my $category ($self->getCategories()) { $f->raw(''.$category.''); my $a; - if ($session{form}{listingId} ne "new") { - $a = WebGUI::SQL->read("select a.name, a.fieldType, a.defaultValue, a.description, a.label, b.value, a.fieldId + if ($self->session->form->process("listingId") ne "new") { + $a = $self->session->db->read("select a.name, a.fieldType, a.defaultValue, a.description, a.label, b.value, a.fieldId from Matrix_field a left join Matrix_listingData b on a.fieldId=b.fieldId and - listingId=".quote($session{form}{listingId})." where - a.category=".quote($category)." order by a.label"); + listingId=".$self->session->db->quote($self->session->form->process("listingId"))." where + a.category=".$self->session->db->quote($category)." order by a.label"); } else { - $a = WebGUI::SQL->read("select name, fieldType, defaultValue, description, label, fieldId - from Matrix_field where category=".quote($category)." and assetId=".quote($self->getId)); + $a = $self->session->db->read("select name, fieldType, defaultValue, description, label, fieldId + from Matrix_field where category=".$self->session->db->quote($category)." and assetId=".$self->session->db->quote($self->getId)); } while (my $field = $a->hashRef) { if ($field->{fieldType} eq "text") { @@ -546,9 +546,9 @@ sub www_editListing { -name=>$field->{name}, -value=>[$value], -label=>$field->{label}, - -options=>WebGUI::SQL->buildHashRef("select distinct value,value from Matrix_listingData - where fieldId=".quote($field->{fieldId})." and - assetId=".quote($self->getId)." order by value"), + -options=>$self->session->db->buildHashRef("select distinct value,value from Matrix_listingData + where fieldId=".$self->session->db->quote($field->{fieldId})." and + assetId=".$self->session->db->quote($self->getId)." order by value"), -subtext=>"
".$field->{description} ); } @@ -564,26 +564,26 @@ sub www_editListing { #------------------------------------------------------------------- sub www_editListingSave { my $self = shift; - my $listing = WebGUI::SQL->getRow("Matrix_listing","listingId",$session{form}{listingId}); - return WebGUI::International('no edit rights','Asset_Matrix') unless (($session{form}{listingId} eq "new" && WebGUI::Grouping::isInGroup($self->get("groupToAdd"))) || $session{user}{userId} eq $listing->{maintainerId} || $self->canEdit); + my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId")); + return WebGUI::International('no edit rights','Asset_Matrix') unless (($self->session->form->process("listingId") eq "new" && WebGUI::Grouping::isInGroup($self->get("groupToAdd"))) || $self->session->user->profileField("userId") eq $listing->{maintainerId} || $self->canEdit); my %data = ( - listingId => $session{form}{listingId}, + listingId => $self->session->form->process("listingId"), lastUpdated => WebGUI::DateTime::time(), - productName => $session{form}{productName}, - productUrl => $session{form}{productUrl}, - manufacturerName => $session{form}{manufacturerName}, - manufacturerUrl => $session{form}{manufacturerUrl}, - description => $session{form}{description}, - versionNumber=>$session{form}{versionNumber} + productName => $self->session->form->process("productName"), + productUrl => $self->session->form->process("productUrl"), + manufacturerName => $self->session->form->process("manufacturerName"), + manufacturerUrl => $self->session->form->process("manufacturerUrl"), + description => $self->session->form->process("description"), + versionNumber=>$self->session->form->process("versionNumber") ); my $isNew = 0; - if ($session{form}{listingId} eq "new") { - $data{maintainerId} = $session{user}{userId} if ($session{form}{listingId} eq "new"); + if ($self->session->form->process("listingId") eq "new") { + $data{maintainerId} = $self->session->user->profileField("userId") if ($self->session->form->process("listingId") eq "new"); my $forum = $self->addChild({ className=>"WebGUI::Asset::Wobject::Collaboration", - title=>$session{form}{productName}, - menuTitle=>$session{form}{productName}, - url=>$session{form}{productName}, + title=>$self->session->form->process("productName"), + menuTitle=>$self->session->form->process("productName"), + url=>$self->session->form->process("productName"), groupIdView=>7, groupIdEdit=>3, startDate=>time(), @@ -618,23 +618,23 @@ sub www_editListingSave { $data{status} = "pending"; $isNew = 1; } - $data{maintainerId} = $session{form}{maintainerId} if ($self->canEdit); + $data{maintainerId} = $self->session->form->process("maintainerId") if ($self->canEdit); $data{assetId} = $self->getId; - $session{form}{listingId} = WebGUI::SQL->setRow("Matrix_listing","listingId",\%data); + $self->session->form->process("listingId") = $self->session->db->setRow("Matrix_listing","listingId",\%data); if ($data{status} eq "pending") { WebGUI::MessageLog::addEntry($self->get("ownerUserId"),$self->get("groupIdEdit"),"New Listing Added","A new listing, ".$data{productName}.", is waiting to be added.", - WebGUI::URL::getSiteURL()."/".$self->formatURL("viewDetail",$session{form}{listingId}),"pending"); + $self->session->url->getSiteURL()."/".$self->formatURL("viewDetail",$self->session->form->process("listingId")),"pending"); } - my $a = WebGUI::SQL->read("select fieldId, name, fieldType from Matrix_field"); + my $a = $self->session->db->read("select fieldId, name, fieldType from Matrix_field"); while (my ($id, $name, $type) = $a->array) { my $value; if ($type eq "goodBad") { - $value = WebGUI::FormProcessor::selectBox($name); + $value = $self->session->form->selectBox($name); } else { - $value = WebGUI::FormProcessor::process($name,$type); + $value = $self->session->form->process($name,$type); } - WebGUI::SQL->write("replace into Matrix_listingData (assetId, listingId, fieldId, value) values ( - ".quote($self->getId).", ".quote($session{form}{listingId}).", ".quote($id).", ".quote($value).")"); + $self->session->db->write("replace into Matrix_listingData (assetId, listingId, fieldId, value) values ( + ".$self->session->db->quote($self->getId).", ".$self->session->db->quote($self->session->form->process("listingId")).", ".$self->session->db->quote($id).", ".$self->session->db->quote($value).")"); } $a->finish; return $self->www_viewDetail; @@ -644,7 +644,7 @@ sub www_editListingSave { sub www_editField { my $self = shift; return WebGUI::Privilege::insufficient() unless($self->canEdit); - my $field = WebGUI::SQL->getRow("Matrix_field","fieldId",$session{form}{fieldId}); + my $field = $self->session->db->getRow("Matrix_field","fieldId",$self->session->form->process("fieldId")); my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden( -name=>"func", @@ -652,7 +652,7 @@ sub www_editField { ); $f->hidden( -name=>"fieldId", - -value=>$session{form}{fieldId} + -value=>$self->session->form->process("fieldId") ); $f->text( -name=>"name", @@ -705,14 +705,14 @@ sub www_editField { sub www_editFieldSave { my $self = shift; return WebGUI::Privilege::insufficient() unless($self->canEdit); - WebGUI::SQL->setRow("Matrix_field","fieldId",{ - fieldId=>$session{form}{fieldId}, - name=>$session{form}{name}, - label=>$session{form}{label}, - fieldType=>$session{form}{fieldType}, - description=>$session{form}{description}, - defaultValue=>$session{form}{defaultValue}, - category=>$session{form}{category}, + $self->session->db->setRow("Matrix_field","fieldId",{ + fieldId=>$self->session->form->process("fieldId"), + name=>$self->session->form->process("name"), + label=>$self->session->form->process("label"), + fieldType=>$self->session->form->process("fieldType"), + description=>$self->session->form->process("description"), + defaultValue=>$self->session->form->process("defaultValue"), + category=>$self->session->form->process("category"), assetId=>$self->getId }); return $self->www_listFields(); @@ -724,7 +724,7 @@ sub www_listFields { return WebGUI::Privilege::insufficient() unless($self->canEdit); my $output = sprintf WebGUI::International::get('list fields','Asset_Matrix'), $self->getUrl("func=editField&fieldId=new"); - my $sth = WebGUI::SQL->read("select fieldId, label from Matrix_field where assetId=".quote($self->getId)." order by label"); + my $sth = $self->session->db->read("select fieldId, label from Matrix_field where assetId=".$self->session->db->quote($self->getId)." order by label"); while (my ($id, $label) = $sth->array) { $output .= ''.$label.'
'; } @@ -736,7 +736,7 @@ sub www_listFields { #------------------------------------------------------------------- sub www_rate { my $self = shift; - my $hasRated = $self->hasRated($session{form}{listingId}); + my $hasRated = $self->hasRated($self->session->form->process("listingId")); my $sameRating = 1; my $first = 1; my $lastRating; @@ -751,7 +751,7 @@ sub www_rate { $lastRating = $session{form}{$category}; } return $self->www_viewDetail("",1) if ($hasRated || $sameRating); # Throw out ratings that are all the same number, or if the user rates twice. - $self->setRatings($session{form}{listingId},$session{form}); + $self->setRatings($self->session->form->process("listingId"),$session{form}); return $self->www_viewDetail; } @@ -759,31 +759,31 @@ sub www_rate { sub www_search { my $self = shift; my %var; - my @list = WebGUI::SQL->buildArray("select listingId from Matrix_listing"); - if ($session{form}{doit}) { + my @list = $self->session->db->buildArray("select listingId from Matrix_listing"); + if ($self->session->form->process("doit")) { my $count; my $keyword; - if ($session{form}{keyword}) { - $keyword = " and (a.value like ".quote('%'.$session{form}{keyword}.'%')." or a.value='Any')"; + if ($self->session->form->process("keyword")) { + $keyword = " and (a.value like ".$self->session->db->quote('%'.$self->session->form->process("keyword").'%')." or a.value='Any')"; } - my $sth = WebGUI::SQL->read("select name,fieldType from Matrix_field"); + my $sth = $self->session->db->read("select name,fieldType from Matrix_field"); while (my ($name,$fieldType) = $sth->array) { next unless ($session{form}{$name}); push(@list,0); my $where; if ($fieldType ne "goodBad") { $where = "(" - ."a.value like ".quote("%".$session{form}{$name}."%") + ."a.value like ".$self->session->db->quote("%".$session{form}{$name}."%") ." or a.value='Any'" - #." or a.value<".quote($session{form}{$name}) + #." or a.value<".$self->session->db->quote($session{form}{$name}) ." or a.value='Free'" .")"; } else { $where = "a.value<>'no'"; } - @list = WebGUI::SQL->buildArray("select a.listingId from Matrix_listingData a left join Matrix_field b + @list = $self->session->db->buildArray("select a.listingId from Matrix_listingData a left join Matrix_field b on (a.fieldId=b.fieldId) - where a.listingId in (".quoteAndJoin(\@list).") and $where and b.name=".quote($name)); + where a.listingId in (".$self->session->db->quoteAndJoin(\@list).") and $where and b.name=".$self->session->db->quote($name)); $count = scalar(@list); last unless ($count > 0); } @@ -811,13 +811,13 @@ sub www_search { $var{'form.footer'} = ""; $var{'form.keyword'} = WebGUI::Form::text({ name=>"keyword", - value=>$session{form}{keyword} + value=>$self->session->form->process("keyword") }); $var{'form.submit'} = WebGUI::Form::submit({ value=>"search" }); foreach my $category ($self->getCategories()) { - my $sth = WebGUI::SQL->read("select name, fieldType, label, description from Matrix_field where category = ".quote($category)." order by label"); + my $sth = $self->session->db->read("select name, fieldType, label, description from Matrix_field where category = ".$self->session->db->quote($category)." order by label"); my @loop; while (my $data = $sth->hashRef) { $data->{description} =~ s/\n//g; @@ -839,7 +839,7 @@ sub www_search { push(@loop,$data); } $sth->finish; - $var{WebGUI::URL::urlize($category)."_loop"} = \@loop; + $var{$self->session->url->urlize($category)."_loop"} = \@loop; } return $self->processStyle($self->processTemplate(\%var,$self->get("searchTemplateId"))); } @@ -851,22 +851,22 @@ sub view { my (%var); $var{'compare.form'} = $self->getCompareForm; $var{'search.url'} = $self->getUrl("func=search"); - $var{'isLoggedIn'} = ($session{user}{userId} ne "1"); + $var{'isLoggedIn'} = ($self->session->user->profileField("userId") ne "1"); $var{'field.list.url'} = $self->getUrl('func=listFields'); $var{'listing.add.url'} = $self->formatURL("editListing","new"); - my $data = WebGUI::SQL->quickHashRef("select views, productName, listingId from Matrix_listing - where assetId=".quote($self->getId)." and status='approved' order by views desc limit 1"); + my $data = $self->session->db->quickHashRef("select views, productName, listingId from Matrix_listing + where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by views desc limit 1"); $var{'best.views.url'} = $self->formatURL("viewDetail",$data->{listingId}); $var{'best.views.count'} = $data->{views}; $var{'best.views.name'} = $data->{productName}; - my $data = WebGUI::SQL->quickHashRef("select compares, productName, listingId from Matrix_listing - where assetId=".quote($self->getId)." and status='approved' order by compares desc limit 1"); + my $data = $self->session->db->quickHashRef("select compares, productName, listingId from Matrix_listing + where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by compares desc limit 1"); $var{'best.compares.url'} = $self->formatURL("viewDetail",$data->{listingId}); $var{'best.compares.count'} = $data->{compares}; $var{'best.compares.name'} = $data->{productName}; - my $data = WebGUI::SQL->quickHashRef("select clicks, productName, listingId from Matrix_listing - where assetId=".quote($self->getId)." and status='approved' order by clicks desc limit 1"); + my $data = $self->session->db->quickHashRef("select clicks, productName, listingId from Matrix_listing + where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by clicks desc limit 1"); $var{'best.clicks.url'} = $self->formatURL("viewDetail",$data->{listingId}); $var{'best.clicks.count'} = $data->{clicks}; $var{'best.clicks.name'} = $data->{productName}; @@ -885,15 +885,15 @@ sub view { Matrix_ratingSummary on Matrix_listing.listingId=Matrix_ratingSummary.listingId and - Matrix_ratingSummary.category=".quote($category)." + Matrix_ratingSummary.category=".$self->session->db->quote($category)." where - Matrix_listing.assetId=".quote($self->getId)." and + Matrix_listing.assetId=".$self->session->db->quote($self->getId)." and Matrix_listing.status='approved' and Matrix_ratingSummary.countValue > 0 order by Matrix_ratingSummary.meanValue "; - my $data = WebGUI::SQL->quickHashRef($sql." desc limit 1"); + my $data = $self->session->db->quickHashRef($sql." desc limit 1"); push(@best,{ url=>$self->formatURL("viewDetail",$data->{listingId}), category=>$category, @@ -902,7 +902,7 @@ sub view { median=>$data->{medianValue}, count=>$data->{countValue} }); - $data = WebGUI::SQL->quickHashRef($sql." asc limit 1"); + $data = $self->session->db->quickHashRef($sql." asc limit 1"); push(@worst,{ url=>$self->formatURL("viewDetail",$data->{listingId}), category=>$category, @@ -915,10 +915,10 @@ sub view { $var{'best_rating_loop'} = \@best; $var{'worst_rating_loop'} = \@worst; $var{'ratings.details.url'} = $self->getUrl("func=viewRatingDetails"); - my $data = WebGUI::SQL->quickHashRef("select lastUpdated, productName, listingId from Matrix_listing - where assetId=".quote($self->getId)." and status='approved' order by lastUpdated desc limit 1"); + my $data = $self->session->db->quickHashRef("select lastUpdated, productName, listingId from Matrix_listing + where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by lastUpdated desc limit 1"); my @lastUpdated; - my $sth = WebGUI::SQL->read("select listingId,lastUpdated,productName from Matrix_listing order by lastUpdated desc limit 20"); + my $sth = $self->session->db->read("select listingId,lastUpdated,productName from Matrix_listing order by lastUpdated desc limit 20"); while (my ($listingId, $lastUpdated, $productName) = $sth->array) { push(@lastUpdated, { url => $self->formatURL("viewDetail",$listingId), @@ -932,10 +932,10 @@ sub view { $var{'best.updated.name'} = $data->{productName}; # site stats - ($var{'user.count'}) = WebGUI::SQL->quickArray("select count(*) from users"); - ($var{'current.user.count'}) = WebGUI::SQL->quickArray("select count(*)+0 from userSession where lastPageView>".(WebGUI::DateTime::time()-600)); - ($var{'listing.count'}) = WebGUI::SQL->quickArray("select count(*) from Matrix_listing where status = 'approved' and assetId=".quote($self->getId)); - my $sth = WebGUI::SQL->read("select listingId,productName from Matrix_listing where status='pending'"); + ($var{'user.count'}) = $self->session->db->quickArray("select count(*) from users"); + ($var{'current.user.count'}) = $self->session->db->quickArray("select count(*)+0 from userSession where lastPageView>".(WebGUI::DateTime::time()-600)); + ($var{'listing.count'}) = $self->session->db->quickArray("select count(*) from Matrix_listing where status = 'approved' and assetId=".$self->session->db->quote($self->getId)); + my $sth = $self->session->db->read("select listingId,productName from Matrix_listing where status='pending'"); while (my ($id,$name) = $sth->array) { push(@{$var{pending_list}},{ url=>$self->formatURL("viewDetail",$id), @@ -949,16 +949,16 @@ sub view { #------------------------------------------------------------------- sub www_viewDetail { my $self = shift; - my $listingId = shift || $session{form}{listingId}; + my $listingId = shift || $self->session->form->process("listingId"); my $hasRated = shift || $self->hasRated($listingId); my %var; - my $listing = WebGUI::SQL->getRow("Matrix_listing","listingId",$listingId); + my $listing = $self->session->db->getRow("Matrix_listing","listingId",$listingId); my $forum = WebGUI::Asset::Wobject::Collaboration->new($listing->{forumId}); $var{"discussion"} = $forum->view; - if ($session{form}{do} eq "sendEmail") { - if ($session{form}{body} ne "") { + if ($self->session->form->process("do") eq "sendEmail") { + if ($self->session->form->process("body") ne "") { my $u = WebGUI::User->new($listing->{maintainerId}); - WebGUI::Mail::send($u->profileField("email"),$listing->{productName}." - ".$session{form}{subject},$session{form}{body},"",$session{form}{from}); + WebGUI::Mail::send($u->profileField("email"),$listing->{productName}." - ".$self->session->form->process("subject"),$self->session->form->process("body"),"",$self->session->form->process("from")); } $var{'email.wasSent'} = 1; } else { @@ -966,10 +966,10 @@ sub www_viewDetail { } $var{'edit.url'} = $self->formatURL("editListing",$listingId); $var{id} = $listingId; - $var{'user.canEdit'} = ($session{user}{userId} eq $listing->{maintainerId} || $self->canEdit); + $var{'user.canEdit'} = ($self->session->user->profileField("userId") eq $listing->{maintainerId} || $self->canEdit); $var{'user.canApprove'} = $self->canEdit; - $var{'approve.url'} = $self->getUrl("func=approveListing&listingId=".$listingId."&mlog=".$session{form}{mlog}); - $var{'delete.url'} = $self->getUrl("func=deleteListing&listingId=".$listingId."&mlog=".$session{form}{mlog}); + $var{'approve.url'} = $self->getUrl("func=approveListing&listingId=".$listingId."&mlog=".$self->session->form->process("mlog")); + $var{'delete.url'} = $self->getUrl("func=deleteListing&listingId=".$listingId."&mlog=".$self->session->form->process("mlog")); $var{'isPending'} = ($listing->{status} eq "pending"); $var{'lastUpdated.epoch'} = $listing->{lastupdated}; $var{'lastUpdated.date'} = WebGUI::DateTime::epochToHuman($listing->{lastUpdated},"%z"); @@ -1000,7 +1000,7 @@ sub www_viewDetail { $f->email( -extras=>'class="content"', -name=>"from", - -value=>$session{user}{email}, + -value=>$self->session->user->profileField("email"), -label=>WebGUI::International::get('your email','Asset_Matrix'), ); $f->selectBox( @@ -1027,8 +1027,8 @@ sub www_viewDetail { $var{views} = $listing->{views}; $var{compares} = $listing->{compares}; $var{clicks} = $listing->{clicks}; - my $sth = WebGUI::SQL->read("select a.value, b.name, b.label, b.description, category from Matrix_listingData a left join - Matrix_field b on a.fieldId=b.fieldId where listingId=".quote($listingId)." order by b.label"); + my $sth = $self->session->db->read("select a.value, b.name, b.label, b.description, category from Matrix_listingData a left join + Matrix_field b on a.fieldId=b.fieldId where listingId=".$self->session->db->quote($listingId)." order by b.label"); while (my $data = $sth->hashRef) { $data->{description} =~ s/\n//g; $data->{description} =~ s/\r//g; @@ -1037,7 +1037,7 @@ sub www_viewDetail { $data->{class} = lc($data->{value}); $data->{class} =~ s/\s/_/g; $data->{class} =~ s/\W//g; - my $cat = WebGUI::URL::urlize($data->{category})."_loop"; + my $cat = $self->session->url->urlize($data->{category})."_loop"; push(@{$var{$cat}},$data); } $sth->finish; @@ -1069,8 +1069,8 @@ sub www_viewDetail { -value=>"rate" ); foreach my $category ($self->getCategories) { - my ($mean,$median,$count) = WebGUI::SQL->quickArray("select meanValue, medianValue, countValue from Matrix_ratingSummary - where listingId=".quote($listingId)." and category=".quote($category)); + my ($mean,$median,$count) = $self->session->db->quickArray("select meanValue, medianValue, countValue from Matrix_ratingSummary + where listingId=".$self->session->db->quote($listingId)." and category=".$self->session->db->quote($category)); $ratingsTable .= ''.$category.''.$mean.''.$median.''.$count.''; $f->selectBox( -name=>$category, @@ -1115,15 +1115,15 @@ sub www_viewRatingDetails { Matrix_ratingSummary on Matrix_listing.listingId=Matrix_ratingSummary.listingId and - Matrix_ratingSummary.category=".quote($category)." + Matrix_ratingSummary.category=".$self->session->db->quote($category)." where - Matrix_listing.assetId=".quote($self->getId)." and + Matrix_listing.assetId=".$self->session->db->quote($self->getId)." and Matrix_listing.status='approved' and Matrix_ratingSummary.countValue > 0 order by Matrix_ratingSummary.meanValue desc "; - my $sth = WebGUI::SQL->read($sql); + my $sth = $self->session->db->read($sql); while (my $data = $sth->hashRef) { push(@detailloop,{ url=>$self->formatURL("viewDetail",$data->{listingId}), diff --git a/lib/WebGUI/Asset/Wobject/Navigation.pm b/lib/WebGUI/Asset/Wobject/Navigation.pm index dfd6b4349..589ca642b 100644 --- a/lib/WebGUI/Asset/Wobject/Navigation.pm +++ b/lib/WebGUI/Asset/Wobject/Navigation.pm @@ -91,7 +91,7 @@ sub getEditForm { ); $tabform->hidden({ name=>"returnUrl", - value=>$session{form}{returnUrl} + value=>$self->session->form->process("returnUrl") }); my ($descendantsChecked, $ancestorsChecked, $selfChecked, $pedigreeChecked, $siblingsChecked); my @assetsToInclude = split("\n",$self->getValue("assetsToInclude")); @@ -282,11 +282,11 @@ sub getToolbar { my $self = shift; if ($self->getToolbarState) { my $returnUrl; - if (exists $session{asset}) { - $returnUrl = ";proceed=goBackToPage;returnUrl=".WebGUI::URL::escape($session{asset}->getUrl); + if (exists $self->session->asset) { + $returnUrl = ";proceed=goBackToPage;returnUrl=".$self->session->url->escape($self->session->asset->getUrl); } my $toolbar; - if (!$self->isLocked || $self->get("isLockedBy") eq $session{user}{userId}) { + if (!$self->isLocked || $self->get("isLockedBy") eq $self->session->user->profileField("userId")) { $toolbar = editIcon('func=edit'.$returnUrl,$self->get("url")); } my $i18n = WebGUI::International->new("Asset"); @@ -308,8 +308,8 @@ sub view { my $self = shift; # we've got to determine what our start point is based upon user conditions my $start; - $session{asset} = WebGUI::Asset->newByUrl unless (exists $session{asset}); - my $current = $session{asset}; + $self->session->asset = WebGUI::Asset->newByUrl unless (exists $self->session->asset); + my $current = $self->session->asset; if ($self->get("startType") eq "specificUrl") { $start = WebGUI::Asset->newByUrl($self->get("startPoint")); } elsif ($self->get("startType") eq "relativeToRoot") { @@ -334,7 +334,7 @@ sub view { } $var->{'currentPage.menuTitle'} = $current->getMenuTitle; $var->{'currentPage.title'} = $current->getTitle; - $var->{'currentPage.isHome'} = ($current->getId eq $session{setting}{defaultPage}); + $var->{'currentPage.isHome'} = ($current->getId eq $self->session->setting->get("defaultPage")); $var->{'currentPage.url'} = $current->getUrl; $var->{'currentPage.hasChild'} = $current->hasChildren; my $currentLineage = $current->get("lineage"); @@ -370,8 +370,8 @@ sub view { $pageData->{"page.isSystem"} = $asset->get("isSystem"); $pageData->{"page.isHidden"} = $asset->get("isHidden"); $pageData->{"page.isViewable"} = $asset->canView; - $pageData->{'page.isContainer'} = isIn($asset->get('className'), @{$session{config}{assetContainers}}); - $pageData->{'page.isUtility'} = isIn($asset->get('className'), @{$session{config}{utilityAssets}}); + $pageData->{'page.isContainer'} = isIn($asset->get('className'), @{$self->session->config->get("assetContainers")}); + $pageData->{'page.isUtility'} = isIn($asset->get('className'), @{$self->session->config->get("utilityAssets")}); $pageData->{"page.url"} = $asset->getUrl; my $indent = $pageData->{"page.relDepth"}; $pageData->{"page.indent_loop"} = []; @@ -433,14 +433,14 @@ sub view { ($lastChildren{@{$var->{page_loop}}[$counter]->{"page.parent.assetId"}} eq @{$var->{page_loop}}[$counter]->{"page.assetId"}); } - #use Data::Dumper;WebGUI::ErrorHandler::warn(Dumper($var)); + #use Data::Dumper;$self->session->errorHandler->warn(Dumper($var)); return $self->processTemplate($var,$self->get("templateId")); } #------------------------------------------------------------------- sub www_goBackToPage { my $self = shift; - WebGUI::HTTP::setRedirect($session{form}{returnUrl}) if ($session{form}{returnUrl}); + WebGUI::HTTP::setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl")); return ""; } @@ -449,16 +449,16 @@ sub www_goBackToPage { # we eventually should reaadd this sub www_preview { my $self = shift; - $session{var}{adminOn} = 0; + $self->session->var->get("adminOn") = 0; return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(3)); - my $nav = WebGUI::Navigation->new( depth=>$session{form}{depth}, - method=>$session{form}{method}, - startAt=>$session{form}{startAt}, - stopAtLevel=>$session{form}{stopAtLevel}, - templateId=>$session{form}{templateId}, - showSystemPages=>$session{form}{showSystemPages}, - showHiddenPages=>$session{form}{showHiddenPages}, - showUnprivilegedPages=>$session{form}{showUnprivilegedPages}, + my $nav = WebGUI::Navigation->new( depth=>$self->session->form->process("depth"), + method=>$self->session->form->process("method"), + startAt=>$self->session->form->process("startAt"), + stopAtLevel=>$self->session->form->process("stopAtLevel"), + templateId=>$self->session->form->process("templateId"), + showSystemPages=>$self->session->form->process("showSystemPages"), + showHiddenPages=>$self->session->form->process("showHiddenPages"), + showUnprivilegedPages=>$self->session->form->process("showUnprivilegedPages"), 'reverse'=>$session{form}{'reverse'}, ); my $output = qq( @@ -468,22 +468,22 @@ sub www_preview { Output - Identifier: $session{form}{identifier}
- startAt: $session{form}{startAt}
- method: $session{form}{method}
- stopAtLevel: $session{form}{stopAtLevel}
- depth: $session{form}{depth}
- templateId: $session{form}{templateId}
+ Identifier: $self->session->form->process("identifier")
+ startAt: $self->session->form->process("startAt")
+ method: $self->session->form->process("method")
+ stopAtLevel: $self->session->form->process("stopAtLevel")
+ depth: $self->session->form->process("depth")
+ templateId: $self->session->form->process("templateId")
reverse: $session{form}{'reverse'}
- showSystemPages: $session{form}{showSystemPages}
- showHiddenPages: $session{form}{showHiddenPages}
- showUnprivilegedPages: $session{form}{showUnprivilegedPages}
+ showSystemPages: $self->session->form->process("showSystemPages")
+ showHiddenPages: $self->session->form->process("showHiddenPages")
+ showUnprivilegedPages: $self->session->form->process("showUnprivilegedPages")
) . $nav->build . qq(); # Because of the way the system is set up, the preview is cached. So let's remove it again... - WebGUI::Cache->new($nav->{_identifier}."$session{page}{pageId}", "Navigation-".$session{config}{configFile})->delete; + WebGUI::Cache->new($nav->{_identifier}."$session{page}{pageId}", "Navigation-".$self->session->config->getFilename)->delete; return _submenu($output,"preview"); } diff --git a/lib/WebGUI/Asset/Wobject/Poll.pm b/lib/WebGUI/Asset/Wobject/Poll.pm index 176eddc08..aa4b1e639 100644 --- a/lib/WebGUI/Asset/Wobject/Poll.pm +++ b/lib/WebGUI/Asset/Wobject/Poll.pm @@ -27,9 +27,9 @@ our @ISA = qw(WebGUI::Asset::Wobject); #------------------------------------------------------------------- sub _hasVoted { my $self = shift; - my ($hasVoted) = WebGUI::SQL->quickArray("select count(*) from Poll_answer - where assetId=".quote($self->getId)." and ((userId=".quote($session{user}{userId})." - and userId<>'1') or (userId=".quote($session{user}{userId})." and ipAddress='$session{env}{REMOTE_ADDR}'))"); + my ($hasVoted) = $self->session->db->quickArray("select count(*) from Poll_answer + where assetId=".$self->session->db->quote($self->getId)." and ((userId=".$self->session->db->quote($self->session->user->profileField("userId"))." + and userId<>'1') or (userId=".$self->session->db->quote($self->session->user->profileField("userId"))." and ipAddress='$self->session->env->get("REMOTE_ADDR")'))"); return $hasVoted; } @@ -160,7 +160,7 @@ sub definition { sub duplicate { my $self = shift; my $newAsset = $self->SUPER::duplicate(shift); - my $sth = WebGUI::SQL->read("select * from Poll_answer where assetId=".quote($self->getId)); + my $sth = $self->session->db->read("select * from Poll_answer where assetId=".$self->session->db->quote($self->getId)); while (my $data = $sth->hashRef) { $newAsset->setVote($data->{answer}, $data->{userId}, $data->{ipAddress}); } @@ -196,7 +196,7 @@ sub getEditForm { -hoverHelp=>WebGUI::International::get('4 description',"Asset_Poll"), -value=>[$self->getValue("voteGroup")] ); - if ($session{setting}{useKarma}) { + if ($self->session->setting->get("useKarma")) { $tabform->getTab("properties")->integer( -name=>"karmaPerVote", -label=>WebGUI::International::get(20,"Asset_Poll"), @@ -238,7 +238,7 @@ sub getEditForm { -name=>"resetVotes", -label=>WebGUI::International::get(10,"Asset_Poll"), -hoverHelp=>WebGUI::International::get('10 description',"Asset_Poll") - ) if $session{form}{func} ne 'add'; + ) if $self->session->form->process("func") ne 'add'; return $tabform; } @@ -247,19 +247,19 @@ sub processPropertiesFromFormPost { my $self = shift; $self->SUPER::processPropertiesFromFormPost; my (@answer, $i, $property); - @answer = split("\n",$session{form}{answers}); + @answer = split("\n",$self->session->form->process("answers")); for ($i=1; $i<=20; $i++) { $property->{'a'.$i} = $answer[($i-1)]; } $self->update($property); - WebGUI::SQL->write("delete from Poll_answer where assetId=".quote($self->getId)) if ($session{form}{resetVotes}); + $self->session->db->write("delete from Poll_answer where assetId=".$self->session->db->quote($self->getId)) if ($self->session->form->process("resetVotes")); } #------------------------------------------------------------------- sub purge { my $self = shift; - WebGUI::SQL->write("delete from Poll_answer where assetId=".quote($self->getId)); + $self->session->db->write("delete from Poll_answer where assetId=".$self->session->db->quote($self->getId)); $self->SUPER::purge(); } @@ -269,8 +269,8 @@ sub setVote { my $answer = shift; my $userId = shift; my $ip = shift; - WebGUI::SQL->write("insert into Poll_answer (assetId, answer, userId, ipAddress) values (".quote($self->getId).", - ".quote($answer).", ".quote($userId).", '$ip')"); + $self->session->db->write("insert into Poll_answer (assetId, answer, userId, ipAddress) values (".$self->session->db->quote($self->getId).", + ".$self->session->db->quote($answer).", ".$self->session->db->quote($userId).", '$ip')"); } #------------------------------------------------------------------- @@ -280,7 +280,7 @@ sub view { $var{question} = $self->get("question"); if ($self->get("active") eq "0") { $showPoll = 0; - } elsif (WebGUI::Grouping::isInGroup($self->get("voteGroup"),$session{user}{userId})) { + } elsif (WebGUI::Grouping::isInGroup($self->get("voteGroup"),$self->session->user->profileField("userId"))) { if ($self->_hasVoted()) { $showPoll = 0; } else { @@ -290,7 +290,7 @@ sub view { $showPoll = 0; } $var{canVote} = $showPoll; - my ($totalResponses) = WebGUI::SQL->quickArray("select count(*) from Poll_answer where assetId=".quote($self->getId)); + my ($totalResponses) = $self->session->db->quickArray("select count(*) from Poll_answer where assetId=".$self->session->db->quote($self->getId)); $var{"responses.label"} = WebGUI::International::get(12,"Asset_Poll"); $var{"responses.total"} = $totalResponses; $var{"form.start"} = WebGUI::Form::formHeader({action=>$self->getUrl}); @@ -300,8 +300,8 @@ sub view { $totalResponses = 1 if ($totalResponses < 1); for (my $i=1; $i<=20; $i++) { if ($self->get('a'.$i) =~ /\C/) { - my ($tally) = WebGUI::SQL->quickArray("select count(*) from Poll_answer where answer='a" - .$i."' and assetId=".quote($self->getId)." group by answer"); + my ($tally) = $self->session->db->quickArray("select count(*) from Poll_answer where answer='a" + .$i."' and assetId=".$self->session->db->quote($self->getId)." group by answer"); push(@answers,{ "answer.form"=>WebGUI::Form::radio({name=>"answer",value=>"a".$i}), "answer.text"=>$self->get('a'.$i), @@ -330,10 +330,10 @@ sub view { sub www_vote { my $self = shift; my $u; - if ($session{form}{answer} ne "" && WebGUI::Grouping::isInGroup($self->get("voteGroup")) && !($self->_hasVoted())) { - $self->setVote($session{form}{answer},$session{user}{userId},$session{env}{REMOTE_ADDR}); - if ($session{setting}{useKarma}) { - $u = WebGUI::User->new($session{user}{userId}); + if ($self->session->form->process("answer") ne "" && WebGUI::Grouping::isInGroup($self->get("voteGroup")) && !($self->_hasVoted())) { + $self->setVote($self->session->form->process("answer"),$self->session->user->profileField("userId"),$self->session->env->get("REMOTE_ADDR")); + if ($self->session->setting->get("useKarma")) { + $u = WebGUI::User->new($self->session->user->profileField("userId")); $u->karma($self->get("karmaPerVote"),"Poll (".$self->getId.")","Voted on this poll."); } $self->deletePageCache; diff --git a/lib/WebGUI/Asset/Wobject/Product.pm b/lib/WebGUI/Asset/Wobject/Product.pm index a8093ef59..70caf424c 100644 --- a/lib/WebGUI/Asset/Wobject/Product.pm +++ b/lib/WebGUI/Asset/Wobject/Product.pm @@ -68,7 +68,7 @@ sub _save { return ""; } $file->generateThumbnail($filename); - WebGUI::SQL->write("update Product set $_[0]=".quote($file->getId)." where assetId=".quote($self->getId)." and revisionDate=".quote($self->get("revisionDate"))); + $self->session->db->write("update Product set $_[0]=".$self->session->db->quote($file->getId)." where assetId=".$self->session->db->quote($self->getId)." and revisionDate=".$self->session->db->quote($self->get("revisionDate"))); } #------------------------------------------------------------------- @@ -86,7 +86,7 @@ sub addRevision { if ($self->get($field)) { my $newStorage = WebGUI::Storage->get($self->get($field))->copy; $newSelf->update({$field=>$newStorage->getId}); - WebGUI::SQL->write("update Product set $field=".quote($newStorage->getId)." where assetId=".quote($newSelf->getId)." and revisionDate=".quote($newSelf->get("revisionDate"))); + $self->session->db->write("update Product set $field=".$self->session->db->quote($newStorage->getId)." where assetId=".$self->session->db->quote($newSelf->getId)." and revisionDate=".$self->session->db->quote($newSelf->get("revisionDate"))); } } return $newSelf; @@ -158,7 +158,7 @@ sub duplicate { $self->_duplicateFile($newAsset,"brochure"); $self->_duplicateFile($newAsset,"warranty"); - $sth = WebGUI::SQL->read("select * from Product_feature where assetId=".quote($self->getId)); + $sth = $self->session->db->read("select * from Product_feature where assetId=".$self->session->db->quote($self->getId)); while ($row = $sth->hashRef) { $row->{"Product_featureId"} = "new"; $row->{"assetId"} = $newAsset->getId; @@ -166,7 +166,7 @@ sub duplicate { } $sth->finish; - $sth = WebGUI::SQL->read("select * from Product_benefit where assetId=".quote($self->getId)); + $sth = $self->session->db->read("select * from Product_benefit where assetId=".$self->session->db->quote($self->getId)); while ($row = $sth->hashRef) { $row->{"Product_benefitId"} = "new"; $row->{"assetId"} = $newAsset->getId; @@ -174,7 +174,7 @@ sub duplicate { } $sth->finish; - $sth = WebGUI::SQL->read("select * from Product_specification where assetId=".quote($self->getId)); + $sth = $self->session->db->read("select * from Product_specification where assetId=".$self->session->db->quote($self->getId)); while ($row = $sth->hashRef) { $row->{"Product_specificationId"} = "new"; $row->{"assetId"} = $newAsset->getId; @@ -182,15 +182,15 @@ sub duplicate { } $sth->finish; - $sth = WebGUI::SQL->read("select * from Product_accessory where assetId=".quote($self->getId)); + $sth = $self->session->db->read("select * from Product_accessory where assetId=".$self->session->db->quote($self->getId)); while (%data = $sth->hash) { - WebGUI::SQL->write("insert into Product_accessory (assetId,accessoryAssetId,sequenceNumber) values (".quote($newAsset->getId).", ".quote($data{accessoryAssetId}).", $data{sequenceNumber})"); + $self->session->db->write("insert into Product_accessory (assetId,accessoryAssetId,sequenceNumber) values (".$self->session->db->quote($newAsset->getId).", ".$self->session->db->quote($data{accessoryAssetId}).", $data{sequenceNumber})"); } $sth->finish; - $sth = WebGUI::SQL->read("select * from Product_related where assetId=".quote($self->getId)); + $sth = $self->session->db->read("select * from Product_related where assetId=".$self->session->db->quote($self->getId)); while (%data = $sth->hash) { - WebGUI::SQL->write("insert into Product_related (assetId,relatedAssetId,sequenceNumber) values (".quote($newAsset->getId).", ".quote($data{relatedAssetId}).", $data{sequenceNumber})"); + $self->session->db->write("insert into Product_related (assetId,relatedAssetId,sequenceNumber) values (".$self->session->db->quote($newAsset->getId).", ".$self->session->db->quote($data{relatedAssetId}).", $data{sequenceNumber})"); } $sth->finish; return $newAsset; @@ -278,7 +278,7 @@ sub getThumbnailUrl { #------------------------------------------------------------------- sub purge { my $self = shift; - my $sth = WebGUI::SQL->read("select image1, image2, image3, brochure, manual, warranty from Product where assetId=".quote($self->getId)); + my $sth = $self->session->db->read("select image1, image2, image3, brochure, manual, warranty from Product where assetId=".$self->session->db->quote($self->getId)); while (my @array = $sth->array) { foreach my $id (@array){ next if ($id eq ""); @@ -286,11 +286,11 @@ sub purge { } } $sth->finish; - WebGUI::SQL->write("delete from Product_accessory where assetId=".quote($self->getId)." or accessoryAssetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Product_related where assetId=".quote($self->getId)." or relatedAssetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Product_benefit where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Product_feature where assetId=".quote($self->getId)); - WebGUI::SQL->write("delete from Product_specification where assetId=".quote($self->getId)); + $self->session->db->write("delete from Product_accessory where assetId=".$self->session->db->quote($self->getId)." or accessoryAssetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Product_related where assetId=".$self->session->db->quote($self->getId)." or relatedAssetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Product_benefit where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Product_feature where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("delete from Product_specification where assetId=".$self->session->db->quote($self->getId)); $self->SUPER::purge(); } @@ -317,9 +317,9 @@ sub www_addAccessory { -name => "func", -value => "addAccessorySave", ); - @usedAccessories = WebGUI::SQL->buildArray("select accessoryAssetId from Product_accessory where assetId=".quote($self->getId)); + @usedAccessories = $self->session->db->buildArray("select accessoryAssetId from Product_accessory where assetId=".$self->session->db->quote($self->getId)); push(@usedAccessories,$self->getId); - $accessory = WebGUI::SQL->buildHashRef("select asset.assetId, assetData.title from asset left join assetData on assetData.assetId=asset.assetId where asset.className='WebGUI::Asset::Wobject::Product' and asset.assetId not in (".quoteAndJoin(\@usedAccessories).") and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).") group by assetData.assetId"); + $accessory = $self->session->db->buildHashRef("select asset.assetId, assetData.title from asset left join assetData on assetData.assetId=asset.assetId where asset.className='WebGUI::Asset::Wobject::Product' and asset.assetId not in (".$self->session->db->quoteAndJoin(\@usedAccessories).") and (assetData.status='approved' or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).") group by assetData.assetId"); $f->selectBox( -name => "accessoryAccessId", -options => $accessory, @@ -339,10 +339,10 @@ sub www_addAccessory { sub www_addAccessorySave { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - return "" unless ($session{form}{accessoryAccessId}); - my ($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from Product_accessory where assetId=".quote($self->getId())); - WebGUI::SQL->write("insert into Product_accessory (assetId,accessoryAssetId,sequenceNumber) values (".quote($self->getId()).",".quote($session{form}{accessoryAccessId}).",".($seq+1).")"); - return "" unless($session{form}{proceed}); + return "" unless ($self->session->form->process("accessoryAccessId")); + my ($seq) = $self->session->db->quickArray("select max(sequenceNumber) from Product_accessory where assetId=".$self->session->db->quote($self->getId())); + $self->session->db->write("insert into Product_accessory (assetId,accessoryAssetId,sequenceNumber) values (".$self->session->db->quote($self->getId()).",".$self->session->db->quote($self->session->form->process("accessoryAccessId")).",".($seq+1).")"); + return "" unless($self->session->form->process("proceed")); return $self->www_addAccessory(); } @@ -356,9 +356,9 @@ sub www_addRelated { -name => "func", -value => "addRelatedSave", ); - @usedRelated = WebGUI::SQL->buildArray("select relatedAssetId from Product_related where assetId=".quote($self->getId)); + @usedRelated = $self->session->db->buildArray("select relatedAssetId from Product_related where assetId=".$self->session->db->quote($self->getId)); push(@usedRelated,$self->getId); - $related = WebGUI::SQL->buildHashRef("select assetId,title from asset where className='WebGUI::Asset::Wobject::Product' and assetId not in (".quoteAndJoin(\@usedRelated).")"); + $related = $self->session->db->buildHashRef("select assetId,title from asset where className='WebGUI::Asset::Wobject::Product' and assetId not in (".$self->session->db->quoteAndJoin(\@usedRelated).")"); $f->selectBox( -name => "relatedAssetId", -options => $related, @@ -378,10 +378,10 @@ sub www_addRelated { sub www_addRelatedSave { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - return "" unless ($session{form}{relatedAssetId}); - my ($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from Product_related where assetId=".quote($self->getId)); - WebGUI::SQL->write("insert into Product_related (assetId,relatedAssetId,sequenceNumber) values (".quote($self->getId).",".quote($session{form}{relatedAssetId}).",".($seq+1).")"); - return "" unless($session{form}{proceed}); + return "" unless ($self->session->form->process("relatedAssetId")); + my ($seq) = $self->session->db->quickArray("select max(sequenceNumber) from Product_related where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("insert into Product_related (assetId,relatedAssetId,sequenceNumber) values (".$self->session->db->quote($self->getId).",".$self->session->db->quote($self->session->form->process("relatedAssetId")).",".($seq+1).")"); + return "" unless($self->session->form->process("proceed")); return $self->www_addRelated(); } @@ -389,7 +389,7 @@ sub www_addRelatedSave { sub www_deleteAccessoryConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - WebGUI::SQL->write("delete from Product_accessory where assetId=".quote($self->getId())." and accessoryAssetId=".quote($session{form}{aid})); + $self->session->db->write("delete from Product_accessory where assetId=".$self->session->db->quote($self->getId())." and accessoryAssetId=".$self->session->db->quote($self->session->form->process("aid"))); $self->reorderCollateral("Product_accessory","accessoryAssetId"); return ""; } @@ -398,7 +398,7 @@ sub www_deleteAccessoryConfirm { sub www_deleteBenefitConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->deleteCollateral("Product_benefit","Product_benefitId",$session{form}{bid}); + $self->deleteCollateral("Product_benefit","Product_benefitId",$self->session->form->process("bid")); $self->reorderCollateral("Product_benefit","Product_benefitId"); return ""; } @@ -407,7 +407,7 @@ sub www_deleteBenefitConfirm { sub www_deleteFeatureConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->deleteCollateral("Product_feature","Product_featureId",$session{form}{fid}); + $self->deleteCollateral("Product_feature","Product_featureId",$self->session->form->process("fid")); $self->reorderCollateral("Product_feature","Product_featureId"); return ""; } @@ -415,7 +415,7 @@ sub www_deleteFeatureConfirm { #------------------------------------------------------------------- sub www_deleteFileConfirm { my $self = shift; - my $column = $session{form}{file}; + my $column = $self->session->form->process("file"); return WebGUI::Privilege::insufficient() unless ($self->canEdit); my $store = $self->get($column); my $file = WebGUI::Storage->get($store); @@ -428,7 +428,7 @@ sub www_deleteFileConfirm { sub www_deleteRelatedConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - WebGUI::SQL->write("delete from Product_related where assetId=".quote($self->getId)." and relatedAssetId=".quote($session{form}{rid})); + $self->session->db->write("delete from Product_related where assetId=".$self->session->db->quote($self->getId)." and relatedAssetId=".$self->session->db->quote($self->session->form->process("rid"))); $self->reorderCollateral("Product_related","relatedAssetId"); return ""; } @@ -437,7 +437,7 @@ sub www_deleteRelatedConfirm { sub www_deleteSpecificationConfirm { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->deleteCollateral("Product_specification","Product_specificationId",$session{form}{sid}); + $self->deleteCollateral("Product_specification","Product_specificationId",$self->session->form->process("sid")); $self->reorderCollateral("Product_specification","Product_specificationId"); return ""; } @@ -468,7 +468,7 @@ sub www_editBenefit { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); my ($data, $f, $benefits); - $data = $self->getCollateral("Product_benefit","Product_benefitId",$session{form}{bid}); + $data = $self->getCollateral("Product_benefit","Product_benefitId",$self->session->form->process("bid")); $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden( -name => "bid", @@ -478,7 +478,7 @@ sub www_editBenefit { -name => "func", -value => "editBenefitSave", ); - $benefits = WebGUI::SQL->buildHashRef("select benefit,benefit from Product_benefit order by benefit"); + $benefits = $self->session->db->buildHashRef("select benefit,benefit from Product_benefit order by benefit"); $f->combo( -name => "benefit", -options => $benefits, @@ -499,14 +499,14 @@ sub www_editBenefit { sub www_editBenefitSave { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $session{form}{benefit} = $session{form}{benefit_new} if ($session{form}{benefit_new} ne ""); + $self->session->form->process("benefit") = $self->session->form->process("benefit_new") if ($self->session->form->process("benefit_new") ne ""); $self->setCollateral("Product_benefit", "Product_benefitId", { - Product_benefitId => $session{form}{bid}, - benefit => $session{form}{benefit} + Product_benefitId => $self->session->form->process("bid"), + benefit => $self->session->form->process("benefit") }); - return "" unless($session{form}{proceed}); - $session{form}{bid} = "new"; + return "" unless($self->session->form->process("proceed")); + $self->session->form->process("bid") = "new"; return $self->www_editBenefit(); } @@ -515,7 +515,7 @@ sub www_editFeature { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); my ($data, $f, $features); - $data = $self->getCollateral("Product_feature","Product_featureId",$session{form}{fid}); + $data = $self->getCollateral("Product_feature","Product_featureId",$self->session->form->process("fid")); $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden( -name => "fid", @@ -525,7 +525,7 @@ sub www_editFeature { -name => "func", -value => "editFeatureSave", ); - $features = WebGUI::SQL->buildHashRef("select feature,feature from Product_feature order by feature"); + $features = $self->session->db->buildHashRef("select feature,feature from Product_feature order by feature"); $f->combo( -name => "feature", -options => $features, @@ -546,13 +546,13 @@ sub www_editFeature { sub www_editFeatureSave { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $session{form}{feature} = $session{form}{feature_new} if ($session{form}{feature_new} ne ""); + $self->session->form->process("feature") = $self->session->form->process("feature_new") if ($self->session->form->process("feature_new") ne ""); $self->setCollateral("Product_feature", "Product_featureId", { - Product_featureId => $session{form}{fid}, - feature => $session{form}{feature} + Product_featureId => $self->session->form->process("fid"), + feature => $self->session->form->process("feature") }); - return "" unless($session{form}{proceed}); - $session{form}{fid} = "new"; + return "" unless($self->session->form->process("proceed")); + $self->session->form->process("fid") = "new"; return $self->www_editFeature(); } @@ -561,7 +561,7 @@ sub www_editSpecification { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); my ($data, $f, $hashRef); - $data = $self->getCollateral("Product_specification","Product_specificationId",$session{form}{sid}); + $data = $self->getCollateral("Product_specification","Product_specificationId",$self->session->form->process("sid")); $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden( -name => "sid", @@ -571,7 +571,7 @@ sub www_editSpecification { -name => "func", -value => "editSpecificationSave", ); - $hashRef = WebGUI::SQL->buildHashRef("select name,name from Product_specification order by name"); + $hashRef = $self->session->db->buildHashRef("select name,name from Product_specification order by name"); $f->combo( -name => "name", -options => $hashRef, @@ -585,7 +585,7 @@ sub www_editSpecification { -hoverHelp => WebGUI::International::get('27 description','Asset_Product'), -value => $data->{value}, ); - $hashRef = WebGUI::SQL->buildHashRef("select units,units from Product_specification order by units"); + $hashRef = $self->session->db->buildHashRef("select units,units from Product_specification order by units"); $f->combo( -name => "units", -options => $hashRef, @@ -606,17 +606,17 @@ sub www_editSpecification { sub www_editSpecificationSave { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $session{form}{name} = $session{form}{name_new} if ($session{form}{name_new} ne ""); - $session{form}{units} = $session{form}{units_new} if ($session{form}{units_new} ne ""); + $self->session->form->process("name") = $self->session->form->process("name_new") if ($self->session->form->process("name_new") ne ""); + $self->session->form->process("units") = $self->session->form->process("units_new") if ($self->session->form->process("units_new") ne ""); $self->setCollateral("Product_specification", "Product_specificationId", { - Product_specificationId => $session{form}{sid}, - name => $session{form}{name}, - value => $session{form}{value}, - units => $session{form}{units} + Product_specificationId => $self->session->form->process("sid"), + name => $self->session->form->process("name"), + value => $self->session->form->process("value"), + units => $self->session->form->process("units") }); - return "" unless($session{form}{proceed}); - $session{form}{sid} = "new"; + return "" unless($self->session->form->process("proceed")); + $self->session->form->process("sid") = "new"; return $self->www_editSpecification(); } @@ -624,7 +624,7 @@ sub www_editSpecificationSave { sub www_moveAccessoryDown { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralDown("Product_accessory","accessoryAssetId",$session{form}{aid}); + $self->moveCollateralDown("Product_accessory","accessoryAssetId",$self->session->form->process("aid")); return ""; } @@ -632,7 +632,7 @@ sub www_moveAccessoryDown { sub www_moveAccessoryUp { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralUp("Product_accessory","accessoryAssetId",$session{form}{aid}); + $self->moveCollateralUp("Product_accessory","accessoryAssetId",$self->session->form->process("aid")); return ""; } @@ -640,7 +640,7 @@ sub www_moveAccessoryUp { sub www_moveBenefitDown { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralDown("Product_benefit","Product_benefitId",$session{form}{bid}); + $self->moveCollateralDown("Product_benefit","Product_benefitId",$self->session->form->process("bid")); return ""; } @@ -648,7 +648,7 @@ sub www_moveBenefitDown { sub www_moveBenefitUp { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralUp("Product_benefit","Product_benefitId",$session{form}{bid}); + $self->moveCollateralUp("Product_benefit","Product_benefitId",$self->session->form->process("bid")); return ""; } @@ -656,7 +656,7 @@ sub www_moveBenefitUp { sub www_moveFeatureDown { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralDown("Product_feature","Product_featureId",$session{form}{fid}); + $self->moveCollateralDown("Product_feature","Product_featureId",$self->session->form->process("fid")); return ""; } @@ -664,7 +664,7 @@ sub www_moveFeatureDown { sub www_moveFeatureUp { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralUp("Product_feature","Product_featureId",$session{form}{fid}); + $self->moveCollateralUp("Product_feature","Product_featureId",$self->session->form->process("fid")); return ""; } @@ -672,7 +672,7 @@ sub www_moveFeatureUp { sub www_moveRelatedDown { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralDown("Product_related","relatedAssetId",$session{form}{rid}); + $self->moveCollateralDown("Product_related","relatedAssetId",$self->session->form->process("rid")); return ""; } @@ -680,7 +680,7 @@ sub www_moveRelatedDown { sub www_moveRelatedUp { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralUp("Product_related","relatedAssetId",$session{form}{rid}); + $self->moveCollateralUp("Product_related","relatedAssetId",$self->session->form->process("rid")); return ""; } @@ -688,7 +688,7 @@ sub www_moveRelatedUp { sub www_moveSpecificationDown { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralDown("Product_specification","Product_specificationId",$session{form}{sid}); + $self->moveCollateralDown("Product_specification","Product_specificationId",$self->session->form->process("sid")); return ""; } @@ -696,14 +696,14 @@ sub www_moveSpecificationDown { sub www_moveSpecificationUp { my $self = shift; return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $self->moveCollateralUp("Product_specification","Product_specificationId",$session{form}{sid}); + $self->moveCollateralUp("Product_specification","Product_specificationId",$self->session->form->process("sid")); return ""; } #------------------------------------------------------------------- sub view { my $self = shift; - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); my (%data, $sth, $file, $segment, %var, @featureloop, @benefitloop, @specificationloop, @accessoryloop, @relatedloop); tie %data, 'Tie::CPHash'; my $brochure = $self->get("brochure"); @@ -755,7 +755,7 @@ sub view { #---features $var{"addFeature.url"} = $self->getUrl('func=editFeature&fid=new'); $var{"addFeature.label"} = WebGUI::International::get(34,'Asset_Product'); - $sth = WebGUI::SQL->read("select feature,Product_featureId from Product_feature where assetId=".quote($self->getId)." order by sequenceNumber"); + $sth = $self->session->db->read("select feature,Product_featureId from Product_feature where assetId=".$self->session->db->quote($self->getId)." order by sequenceNumber"); while (%data = $sth->hash) { $segment = deleteIcon('func=deleteFeatureConfirm&fid='.$data{Product_featureId},$self->get("url"),WebGUI::International::get(3,'Asset_Product')) .editIcon('func=editFeature&fid='.$data{Product_featureId},$self->get("url")) @@ -772,7 +772,7 @@ sub view { #---benefits $var{"addBenefit.url"} = $self->getUrl('func=editBenefit&fid=new'); $var{"addBenefit.label"} = WebGUI::International::get(55,'Asset_Product'); - $sth = WebGUI::SQL->read("select benefit,Product_benefitId from Product_benefit where assetId=".quote($self->getId)." order by sequenceNumber"); + $sth = $self->session->db->read("select benefit,Product_benefitId from Product_benefit where assetId=".$self->session->db->quote($self->getId)." order by sequenceNumber"); while (%data = $sth->hash) { $segment = deleteIcon('func=deleteBenefitConfirm&bid='.$data{Product_benefitId},$self->get("url"),WebGUI::International::get(48,'Asset_Product')) .editIcon('func=editBenefit&bid='.$data{Product_benefitId},$self->get("url")) @@ -789,7 +789,7 @@ sub view { #---specifications $var{"addSpecification.url"} = $self->getUrl('func=editSpecification&sid=new'); $var{"addSpecification.label"} = WebGUI::International::get(35,'Asset_Product'); - $sth = WebGUI::SQL->read("select name,value,units,Product_specificationId from Product_specification where assetId=".quote($self->getId)." order by sequenceNumber"); + $sth = $self->session->db->read("select name,value,units,Product_specificationId from Product_specification where assetId=".$self->session->db->quote($self->getId)." order by sequenceNumber"); while (%data = $sth->hash) { $segment = deleteIcon('func=deleteSpecificationConfirm&sid='.$data{Product_specificationId},$self->get("url"),WebGUI::International::get(5,'Asset_Product')) .editIcon('func=editSpecification&sid='.$data{Product_specificationId},$self->get("url")) @@ -808,8 +808,8 @@ sub view { #---accessories $var{"addaccessory.url"} = $self->getUrl('func=addAccessory'); $var{"addaccessory.label"} = WebGUI::International::get(36,'Asset_Product'); - $sth = WebGUI::SQL->read("select Product_accessory.accessoryAssetId from Product_accessory - where Product_accessory.assetId=".quote($self->getId)." + $sth = $self->session->db->read("select Product_accessory.accessoryAssetId from Product_accessory + where Product_accessory.assetId=".$self->session->db->quote($self->getId)." order by Product_accessory.sequenceNumber"); while (my ($id) = $sth->array) { $segment = deleteIcon('func=deleteAccessoryConfirm&aid='.$id,$self->get("url"),WebGUI::International::get(2,'Asset_Product')) @@ -828,9 +828,9 @@ sub view { #---related $var{"addrelatedproduct.url"} = $self->getUrl('func=addRelated'); $var{"addrelatedproduct.label"} = WebGUI::International::get(37,'Asset_Product'); - $sth = WebGUI::SQL->read("select Product_related.relatedAssetId + $sth = $self->session->db->read("select Product_related.relatedAssetId from Product_related - where Product_related.assetId=".quote($self->getId)." + where Product_related.assetId=".$self->session->db->quote($self->getId)." order by Product_related.sequenceNumber"); while (my ($id) = $sth->array) { $segment = deleteIcon('func=deleteRelatedConfirm&rid='.$id,$self->get("url"),WebGUI::International::get(4,'Asset_Product')) diff --git a/lib/WebGUI/Asset/Wobject/SQLReport.pm b/lib/WebGUI/Asset/Wobject/SQLReport.pm index 4e9e37373..e6d97529e 100644 --- a/lib/WebGUI/Asset/Wobject/SQLReport.pm +++ b/lib/WebGUI/Asset/Wobject/SQLReport.pm @@ -331,8 +331,8 @@ sub _processQuery { my $url = $self->getUrl('func=view'); foreach (keys %{$session{form}}) { unless ($_ eq "pn" || $_ eq "func" || $_ =~ /identifier/i || $_ =~ /password/i) { - $url = WebGUI::URL::append($url, WebGUI::URL::escape($_) - .'='.WebGUI::URL::escape($session{form}{$_})); + $url = $self->session->url->append($url, $self->session->url->escape($_) + .'='.$self->session->url->escape($session{form}{$_})); } } my $paginateAfter = $self->get("paginateAfter"); @@ -340,7 +340,7 @@ sub _processQuery { my $p = WebGUI::Paginator->new($url,$paginateAfter); my $error = $p->setDataByQuery($query,$dbh,1,$placeholderParams); if ($error ne "") { - WebGUI::ErrorHandler::warn("There was a problem with the query: ".$error); + $self->session->errorHandler->warn("There was a problem with the query: ".$error); push(@{$self->{_debug_loop}},{'debug.output'=>WebGUI::International::get(11,"Asset_SQLReport")." ".$error}); } else { my $first = 1; @@ -390,12 +390,12 @@ sub _processQuery { } } else { push(@{$self->{_debug_loop}},{'debug.output'=>WebGUI::International::get(10,"Asset_SQLReport")}); - WebGUI::ErrorHandler::warn("SQLReport [".$self->getId."] The SQL query is improperly formatted."); + $self->session->errorHandler->warn("SQLReport [".$self->getId."] The SQL query is improperly formatted."); } $dbLink->disconnect; } else { push(@{$self->{_debug_loop}},{'debug.output'=>WebGUI::International::get(12,"Asset_SQLReport")}); - WebGUI::ErrorHandler::warn("SQLReport [".$self->getId."] Could not connect to database."); + $self->session->errorHandler->warn("SQLReport [".$self->getId."] Could not connect to database."); } return \%var; } diff --git a/lib/WebGUI/Asset/Wobject/StockData.pm b/lib/WebGUI/Asset/Wobject/StockData.pm index 1b108a77f..db6ea2888 100644 --- a/lib/WebGUI/Asset/Wobject/StockData.pm +++ b/lib/WebGUI/Asset/Wobject/StockData.pm @@ -145,8 +145,8 @@ Clears the session variables from session used by the stock list edit form sub _clearStockEditSession { my $self = shift; - $session{form}{symbol} = ""; - $session{form}{stockId} = ""; + $self->session->form->process("symbol") = ""; + $self->session->form->process("stockId") = ""; } #------------------------------------------------------------------- @@ -381,9 +381,9 @@ sub view { my $self = shift; my $var = {}; #Set some template variables - $var->{'extrasFolder'} = $session{config}{extrasURL}."/wobject/StockData"; + $var->{'extrasFolder'} = $self->session->config->get("extrasURL")."/wobject/StockData"; $var->{'editUrl'} = $self->getUrl("func=editStocks"); - $var->{'isVisitor'} = $session{user}{userId} eq 1; + $var->{'isVisitor'} = $self->session->user->profileField("userId") eq 1; $var->{'stock.display.url'} = $self->getUrl("func=displayStock&symbol="); #Build list of stocks as an array @@ -430,9 +430,9 @@ sub www_displayStock { my $var = {}; return WebGUI::Privilege::noAccess() unless $self->canView(); - $var->{'extrasFolder'} = $session{config}{extrasURL}."/wobject/StockData"; + $var->{'extrasFolder'} = $self->session->config->get("extrasURL")."/wobject/StockData"; - my $symbol = $session{form}{symbol}; + my $symbol = $self->session->form->process("symbol"); my $data = $self->_getStocks([$symbol]); #Append Template Variables for stock symbol $self->_appendStockVars($var,$data,$symbol); @@ -442,7 +442,7 @@ sub www_displayStock { $var->{'lastUpdate.intl'} = WebGUI::DateTime::epochToHuman($luEpoch,"%y-%m-%d"); $var->{'lastUpdate.us'} = WebGUI::DateTime::epochToHuman($luEpoch,"%m/%d/%y"); - $session{setting}{showDebug} = 0; + $self->session->setting->get("showDebug") = 0; return $self->processTemplate($var, $self->get("displayTemplateId")); } diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index 90c547536..0e0e03779 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -53,11 +53,11 @@ sub addSection { sub completeResponse { my $self = shift; my $responseId = shift; - WebGUI::SQL->setRow("Survey_response","Survey_responseId",{ + $self->session->db->setRow("Survey_response","Survey_responseId",{ 'Survey_responseId'=>$responseId, isComplete=>1 }); - WebGUI::Session::deleteScratch($self->getResponseIdString); + $self->session->scratch->delete($self->getResponseIdString); } #------------------------------------------------------------------- @@ -140,7 +140,7 @@ sub duplicate { Survey_id=>$newSurveyId }); - my $section = WebGUI::SQL->read("select * from Survey_section where Survey_id=".quote($self->get("Survey_id")) + my $section = $self->session->db->read("select * from Survey_section where Survey_id=".$self->session->db->quote($self->get("Survey_id")) ." order by sequenceNumber"); while ($sdata = $section->hashRef) { $oldSectionId = $sdata->{Survey_sectionId}; @@ -148,17 +148,17 @@ sub duplicate { $sdata->{Survey_Id} = $newSurveyId; $sdata->{Survey_sectionId} = $newAsset->setCollateral("Survey_section", "Survey_sectionId",$sdata,1,0, "Survey_id"); - my $questions = WebGUI::SQL->read("select * from Survey_question where Survey_id=".quote($self->get("Survey_id")) - ." and Survey_sectionId=".quote($oldSectionId)." order by sequenceNumber"); + my $questions = $self->session->db->read("select * from Survey_question where Survey_id=".$self->session->db->quote($self->get("Survey_id")) + ." and Survey_sectionId=".$self->session->db->quote($oldSectionId)." order by sequenceNumber"); while ($qdata = $questions->hashRef) { - my $answers = WebGUI::SQL->read("select * from Survey_answer where Survey_questionId=".quote($qdata->{Survey_questionId}) + my $answers = $self->session->db->read("select * from Survey_answer where Survey_questionId=".$self->session->db->quote($qdata->{Survey_questionId}) ." order by sequenceNumber"); $qdata->{Survey_questionId} = "new"; $qdata->{Survey_id} = $newSurveyId; $qdata->{Survey_sectionId} = $sdata->{Survey_sectionId}; $qdata->{Survey_questionId} = $newAsset->setCollateral("Survey_question","Survey_questionId",$qdata,1,0,"Survey_id"); while ($adata = $answers->hashRef) { - my $responses = WebGUI::SQL->read("select * from Survey_questionResponse where Survey_answerId=".quote($adata->{Survey_answerId})); + my $responses = $self->session->db->read("select * from Survey_questionResponse where Survey_answerId=".$self->session->db->quote($adata->{Survey_answerId})); $adata->{Survey_answerId} = "new"; $adata->{Survey_questionId} = $qdata->{Survey_questionId}; $adata->{Survey_id} = $newSurveyId; @@ -192,15 +192,15 @@ sub generateResponseId { } my $ipAddress = $self->getIp; my $userId = $self->getUserId; - my $responseId = WebGUI::SQL->setRow("Survey_response","Survey_responseId",{ + my $responseId = $self->session->db->setRow("Survey_response","Survey_responseId",{ 'Survey_responseId'=>"new", userId=>$userId, ipAddress=>$ipAddress, - username=>$session{user}{username}, + username=>$self->session->user->profileField("username"), startDate=>WebGUI::DateTime::time(), 'Survey_id'=>$self->get("Survey_id") }); - WebGUI::Session::setScratch($varname,$responseId); + $self->session->scratch->set($varname,$responseId); return $responseId; } @@ -321,7 +321,7 @@ sub getEditForm { #------------------------------------------------------------------- sub getIp { my $self = shift; - my $ip = ($self->get("anonymous")) ? substr(md5_hex($session{env}{REMOTE_ADDR}),0,8) : $session{env}{REMOTE_ADDR}; + my $ip = ($self->get("anonymous")) ? substr(md5_hex($self->session->env->get("REMOTE_ADDR")),0,8) : $self->session->env->get("REMOTE_ADDR"); return $ip; } @@ -352,7 +352,7 @@ sub getMenuVars { #------------------------------------------------------------------- sub getQuestionCount { my $self = shift; - my ($count) = WebGUI::SQL->quickArray("select count(*) from Survey_question where Survey_id=".quote($self->get("Survey_id"))); + my ($count) = $self->session->db->quickArray("select count(*) from Survey_question where Survey_id=".$self->session->db->quote($self->get("Survey_id"))); return ($count < $self->getValue("questionsPerResponse")) ? $count : $self->getValue("questionsPerResponse"); } @@ -396,7 +396,7 @@ sub getQuestionsLoop { sub getQuestionResponseCount { my $self = shift; my $responseId = shift; - my ($count) = WebGUI::SQL->quickArray("select count(*) from Survey_questionResponse where Survey_responseId=".quote($responseId)); + my ($count) = $self->session->db->quickArray("select count(*) from Survey_questionResponse where Survey_responseId=".$self->session->db->quote($responseId)); return $count; } @@ -405,7 +405,7 @@ sub getQuestionVars { my $self = shift; my $questionId = shift; my %var; - my $question = WebGUI::SQL->getRow("Survey_question","Survey_questionId",$questionId); + my $question = $self->session->db->getRow("Survey_question","Survey_questionId",$questionId); $var{'question.question'} = $question->{question}; $var{'question.allowComment'} = $question->{allowComment}; $var{'question.id'} = $question->{Survey_questionId}; @@ -415,7 +415,7 @@ sub getQuestionVars { $var{'question.comment.label'} = WebGUI::International::get(51,'Asset_Survey'); my $answer; - ($answer) = WebGUI::SQL->quickArray("select Survey_answerId from Survey_answer where Survey_questionId=".quote($question->{Survey_questionId})); + ($answer) = $self->session->db->quickArray("select Survey_answerId from Survey_answer where Survey_questionId=".$self->session->db->quote($question->{Survey_questionId})); $var{'question.answer.field'} = WebGUI::Form::hidden({ name=>'answerId_'.$questionId, value=>$answer @@ -433,7 +433,7 @@ sub getQuestionVars { name=>'textResponse_'.$questionId }); } else { - my $answer = WebGUI::SQL->buildHashRef("select Survey_answerId,answer from Survey_answer where Survey_questionId=".quote($question->{Survey_questionId})." order by sequenceNumber"); + my $answer = $self->session->db->buildHashRef("select Survey_answerId,answer from Survey_answer where Survey_questionId=".$self->session->db->quote($question->{Survey_questionId})." order by sequenceNumber"); if ($question->{randomizeAnswers}) { $answer = randomizeHash($answer); } @@ -450,12 +450,12 @@ sub getQuestionVars { sub getRandomQuestionIds { my $self = shift; my $responseId = shift; - my @usedQuestionIds = WebGUI::SQL->buildArray("select Survey_questionId from Survey_questionResponse where Survey_responseId=".quote($responseId)); - my $where = " where Survey_id=".quote($self->get("Survey_id")); + my @usedQuestionIds = $self->session->db->buildArray("select Survey_questionId from Survey_questionResponse where Survey_responseId=".$self->session->db->quote($responseId)); + my $where = " where Survey_id=".$self->session->db->quote($self->get("Survey_id")); if ($#usedQuestionIds+1 > 0) { - $where .= " and Survey_questionId not in (".quoteAndJoin(\@usedQuestionIds).")"; + $where .= " and Survey_questionId not in (".$self->session->db->quoteAndJoin(\@usedQuestionIds).")"; } - my @questions = WebGUI::SQL->buildArray("select Survey_questionId from Survey_question".$where); + my @questions = $self->session->db->buildArray("select Survey_questionId from Survey_question".$where); randomizeArray(\@questions); return @questions; } @@ -465,8 +465,8 @@ sub getResponseCount { my $self = shift; my $ipAddress = $self->getIp; my $userId = $self->getUserId; - my ($count) = WebGUI::SQL->quickArray("select count(*) from Survey_response where Survey_id=".quote($self->get("Survey_id"))." and - ((userId<>'1' and userId=".quote($userId).") or ( userId='1' and ipAddress=".quote($ipAddress)."))"); + my ($count) = $self->session->db->quickArray("select count(*) from Survey_response where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." and + ((userId<>'1' and userId=".$self->session->db->quote($userId).") or ( userId='1' and ipAddress=".$self->session->db->quote($ipAddress)."))"); return $count; } @@ -475,23 +475,23 @@ sub getResponseCount { sub getResponseDrivenQuestionIds { my $self = shift; my $responseId = shift; - my $previousResponse = WebGUI::SQL->quickHashRef("select Survey_questionId, Survey_answerId from Survey_questionResponse - where Survey_responseId=".quote($responseId)." order by dateOfResponse desc"); + my $previousResponse = $self->session->db->quickHashRef("select Survey_questionId, Survey_answerId from Survey_questionResponse + where Survey_responseId=".$self->session->db->quote($responseId)." order by dateOfResponse desc"); my $questionId; my @questions; if ($previousResponse->{Survey_answerId}) { - ($questionId) = WebGUI::SQL->quickArray("select gotoQuestion from Survey_answer where - Survey_answerId=".quote($previousResponse->{Survey_answerId})); + ($questionId) = $self->session->db->quickArray("select gotoQuestion from Survey_answer where + Survey_answerId=".$self->session->db->quote($previousResponse->{Survey_answerId})); unless ($questionId) { - ($questionId) = WebGUI::SQL->quickArray("select gotoQuestion from Survey_question where - Survey_questionId=".quote($previousResponse->{Survey_questionId})); + ($questionId) = $self->session->db->quickArray("select gotoQuestion from Survey_question where + Survey_questionId=".$self->session->db->quote($previousResponse->{Survey_questionId})); } unless ($questionId) { # terminate survey $self->completeResponse($responseId); return (); } } else { - ($questionId) = WebGUI::SQL->quickArray("select Survey_questionId from Survey_question where Survey_id=".quote($self->getValue("Survey_id"))." + ($questionId) = $self->session->db->quickArray("select Survey_questionId from Survey_question where Survey_id=".$self->session->db->quote($self->getValue("Survey_id"))." order by sequenceNumber"); } push(@questions,$questionId); @@ -502,16 +502,16 @@ sub getResponseDrivenQuestionIds { sub getSectionDrivenQuestionIds { my $self = shift; my $responseId = shift; - my @usedQuestionIds = WebGUI::SQL->buildArray("select Survey_questionId from Survey_questionResponse where Survey_responseId=".quote($responseId)); + my @usedQuestionIds = $self->session->db->buildArray("select Survey_questionId from Survey_questionResponse where Survey_responseId=".$self->session->db->quote($responseId)); my @questions; - my $where = " where Survey_question.Survey_id=".quote($self->get("Survey_id")); + my $where = " where Survey_question.Survey_id=".$self->session->db->quote($self->get("Survey_id")); $where .= " and Survey_question.Survey_sectionId=Survey_section.Survey_sectionId"; if ($#usedQuestionIds+1 > 0) { - $where .= " and Survey_questionId not in (".quoteAndJoin(\@usedQuestionIds).")"; + $where .= " and Survey_questionId not in (".$self->session->db->quoteAndJoin(\@usedQuestionIds).")"; } - my $sth = WebGUI::SQL->read("select Survey_questionId, Survey_question.Survey_sectionId from Survey_question, + my $sth = $self->session->db->read("select Survey_questionId, Survey_question.Survey_sectionId from Survey_question, Survey_section $where order by Survey_section.sequenceNumber, Survey_question.sequenceNumber"); my $loopCount=0; @@ -546,19 +546,19 @@ sub getResponseIdString { sub getSequentialQuestionIds { my $self = shift; my $responseId = shift; - my @usedQuestionIds = WebGUI::SQL->buildArray("select Survey_questionId from Survey_questionResponse where Survey_responseId=".quote($responseId)); - my $where = " where Survey_id=".quote($self->get("Survey_id")); + my @usedQuestionIds = $self->session->db->buildArray("select Survey_questionId from Survey_questionResponse where Survey_responseId=".$self->session->db->quote($responseId)); + my $where = " where Survey_id=".$self->session->db->quote($self->get("Survey_id")); if ($#usedQuestionIds+1 > 0) { - $where .= " and Survey_questionId not in (".quoteAndJoin(\@usedQuestionIds).")"; + $where .= " and Survey_questionId not in (".$self->session->db->quoteAndJoin(\@usedQuestionIds).")"; } - my @questions = WebGUI::SQL->buildArray("select Survey_questionId from Survey_question $where order by sequenceNumber"); + my @questions = $self->session->db->buildArray("select Survey_questionId from Survey_question $where order by sequenceNumber"); return @questions; } #------------------------------------------------------------------- sub getUserId { my $self = shift; - my $userId = ($self->get("anonymous") && $session{user}{userId} != 1) ? substr(md5_hex($session{user}{userId}),0,8) : $session{user}{userId}; + my $userId = ($self->get("anonymous") && $self->session->user->profileField("userId") != 1) ? substr(md5_hex($self->session->user->profileField("userId")),0,8) : $self->session->user->profileField("userId"); return $userId; } @@ -566,19 +566,19 @@ sub getUserId { sub processPropertiesFromFormPost { my $self = shift; $self->SUPER::processPropertiesFromFormPost; - if ($session{form}{assetId} eq "new") { + if ($self->session->form->process("assetId") eq "new") { $self->addSection(WebGUI::International::get(107, 'Asset_Survey')); } } #------------------------------------------------------------------- sub purge { - my ($count) = WebGUI::SQL->quickArray("select count(*) from Survey where Survey_id=".quote($_[0]->get("Survey_id"))); + my ($count) = $self->session->db->quickArray("select count(*) from Survey where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); if ($count < 2) { ### Check for other wobjects using this survey. - WebGUI::SQL->write("delete from Survey_question where Survey_id=".quote($_[0]->get("Survey_id"))); - WebGUI::SQL->write("delete from Survey_answer where Survey_id=".quote($_[0]->get("Survey_id"))); - WebGUI::SQL->write("delete from Survey_response where Survey_id=".quote($_[0]->get("Survey_id"))); - WebGUI::SQL->write("delete from Survey_section where Survey_id=".quote($_[0]->get("Survey_id"))); + $self->session->db->write("delete from Survey_question where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); + $self->session->db->write("delete from Survey_answer where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); + $self->session->db->write("delete from Survey_response where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); + $self->session->db->write("delete from Survey_section where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); } $_[0]->SUPER::purge(); } @@ -588,7 +588,7 @@ sub purge { sub responseIsComplete { my $self = shift; my $responseId = shift; - my $response = WebGUI::SQL->getRow("Survey_response","Survey_responseId",$responseId); + my $response = $self->session->db->getRow("Survey_response","Survey_responseId",$responseId); return $response->{isComplete}; } @@ -605,7 +605,7 @@ sub setAnswerType { #------------------------------------------------------------------- sub view { my $self = shift; - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); my $var = $self->getMenuVars; $var->{'question.add.url'} = $self->getUrl('func=editQuestion;qid=new'); $var->{'question.add.label'} = WebGUI::International::get(30,'Asset_Survey'); @@ -614,14 +614,14 @@ sub view { my @sectionEdit; # Get Sections - my $sth = WebGUI::SQL->read("select Survey_sectionId,sectionName from Survey_section where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); + my $sth = $self->session->db->read("select Survey_sectionId,sectionName from Survey_section where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by sequenceNumber"); while (my %sectionData = $sth->hash) { my @edit; # Get Questions for this section - my $sth2 = WebGUI::SQL->read("select Survey_questionId,question from Survey_question - where Survey_id=".quote($self->get("Survey_id"))." - and Survey_sectionId=".quote($sectionData{Survey_sectionId})." order by sequenceNumber"); + my $sth2 = $self->session->db->read("select Survey_questionId,question from Survey_question + where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." + and Survey_sectionId=".$self->session->db->quote($sectionData{Survey_sectionId})." order by sequenceNumber"); while (my %data = $sth2->hash) { push(@edit,{ 'question.edit.controls'=> @@ -656,13 +656,13 @@ sub view { $var->{'response.Count'} = $self->getResponseCount; $var->{'user.isFirstResponse'} = ($var->{'response.Count'} == 0 && !(exists $var->{'response.id'})); $var->{'user.canRespondAgain'} = ($var->{'response.Count'} < $self->get("maxResponsesPerUser")); - if (($var->{'user.isFirstResponse'}) || ($session{form}{startNew} && $var->{'user.canRespondAgain'})) { + if (($var->{'user.isFirstResponse'}) || ($self->session->form->process("startNew") && $var->{'user.canRespondAgain'})) { $var->{'response.Id'} = $self->generateResponseId; } if ($var->{'response.Id'}) { $var->{'questions.soFar.count'} = $self->getQuestionResponseCount($var->{'response.Id'}); - ($var->{'questions.correct.count'}) = WebGUI::SQL->quickArray("select count(*) from Survey_questionResponse a, Survey_answer b where a.Survey_responseId=" - .quote($var->{'response.Id'})." and a.Survey_answerId=b.Survey_answerId and b.isCorrect=1"); + ($var->{'questions.correct.count'}) = $self->session->db->quickArray("select count(*) from Survey_questionResponse a, Survey_answer b where a.Survey_responseId=" + .$self->session->db->quote($var->{'response.Id'})." and a.Survey_answerId=b.Survey_answerId and b.isCorrect=1"); if ($var->{'questions.soFar.count'} > 0) { $var->{'questions.correct.percent'} = round(($var->{'questions.correct.count'}/$var->{'questions.soFar.count'})*100) } @@ -696,10 +696,10 @@ sub view { #------------------------------------------------------------------- sub www_deleteAnswerConfirm { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - my ($answerCount) = WebGUI::SQL->quickArray("select count(*) from Survey_answer where Survey_questionId=".quote($session{form}{qid})); + my ($answerCount) = $self->session->db->quickArray("select count(*) from Survey_answer where Survey_questionId=".$self->session->db->quote($self->session->form->process("qid"))); return $_[0]->i18n("cannot delete the last answer") unless($answerCount); - WebGUI::SQL->write("delete from Survey_questionResponse where Survey_answerId=".quote($session{form}{aid})); - $_[0]->deleteCollateral("Survey_answer","Survey_answerId",$session{form}{aid}); + $self->session->db->write("delete from Survey_questionResponse where Survey_answerId=".$self->session->db->quote($self->session->form->process("aid"))); + $_[0]->deleteCollateral("Survey_answer","Survey_answerId",$self->session->form->process("aid")); $_[0]->reorderCollateral("Survey_answer","Survey_answerId","Survey_id"); return $_[0]->www_editQuestion; } @@ -707,9 +707,9 @@ sub www_deleteAnswerConfirm { #------------------------------------------------------------------- sub www_deleteQuestionConfirm { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - WebGUI::SQL->write("delete from Survey_answer where Survey_questionId=".quote($session{form}{qid})); - WebGUI::SQL->write("delete from Survey_questionResponse where Survey_questionId=".quote($session{form}{qid})); - $_[0]->deleteCollateral("Survey_question","Survey_questionId",$session{form}{qid}); + $self->session->db->write("delete from Survey_answer where Survey_questionId=".$self->session->db->quote($self->session->form->process("qid"))); + $self->session->db->write("delete from Survey_questionResponse where Survey_questionId=".$self->session->db->quote($self->session->form->process("qid"))); + $_[0]->deleteCollateral("Survey_question","Survey_questionId",$self->session->form->process("qid")); $_[0]->reorderCollateral("Survey_question","Survey_questionId","Survey_id"); return ""; } @@ -718,14 +718,14 @@ sub www_deleteQuestionConfirm { sub www_deleteSectionConfirm { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); my $none = WebGUI::International::get(107, 'Asset_Survey'); - my ($sectionName) = WebGUI::SQL->quickArray("select sectionName from Survey_section where Survey_sectionId=" - .quote($session{form}{sid})); + my ($sectionName) = $self->session->db->quickArray("select sectionName from Survey_section where Survey_sectionId=" + .$self->session->db->quote($self->session->form->process("sid"))); if ($sectionName =~ /$none/) { return WebGUI::Privilege::vitalComponent(); } - WebGUI::SQL->write("delete from Survey_section where Survey_sectionId=".quote($session{form}{sid})); - $_[0]->deleteCollateral("Survey_section","Survey_sectionId",$session{form}{sid}); + $self->session->db->write("delete from Survey_section where Survey_sectionId=".$self->session->db->quote($self->session->form->process("sid"))); + $_[0]->deleteCollateral("Survey_section","Survey_sectionId",$self->session->form->process("sid")); $_[0]->reorderCollateral("Survey_section","Survey_sectionId","Survey_id"); return ""; } @@ -733,29 +733,29 @@ sub www_deleteSectionConfirm { #------------------------------------------------------------------- sub www_deleteResponse { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - return WebGUI::Style::process($_[0]->confirm(WebGUI::International::get(72,'Asset_Survey'), - $_[0]->getUrl('func=deleteResponseConfirm;responseId='.$session{form}{responseId})),$_[0]->getValue("styleTemplateId")); + return $self->session->style->process($_[0]->confirm(WebGUI::International::get(72,'Asset_Survey'), + $_[0]->getUrl('func=deleteResponseConfirm;responseId='.$self->session->form->process("responseId"))),$_[0]->getValue("styleTemplateId")); } #------------------------------------------------------------------- sub www_deleteResponseConfirm { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - WebGUI::SQL->write("delete from Survey_response where Survey_responseId=".quote($session{form}{responseId})); - WebGUI::SQL->write("delete from Survey_questionResponse where Survey_responseId=".quote($session{form}{responseId})); + $self->session->db->write("delete from Survey_response where Survey_responseId=".$self->session->db->quote($self->session->form->process("responseId"))); + $self->session->db->write("delete from Survey_questionResponse where Survey_responseId=".$self->session->db->quote($self->session->form->process("responseId"))); return $_[0]->www_viewGradebook; } #------------------------------------------------------------------- sub www_deleteAllResponses { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - return WebGUI::Style::process($_[0]->confirm(WebGUI::International::get(74,'Asset_Survey'),$_[0]->getUrl('func=deleteAllResponsesConfirm')),$_[0]->getValue("styleTemplateId")); + return $self->session->style->process($_[0]->confirm(WebGUI::International::get(74,'Asset_Survey'),$_[0]->getUrl('func=deleteAllResponsesConfirm')),$_[0]->getValue("styleTemplateId")); } #------------------------------------------------------------------- sub www_deleteAllResponsesConfirm { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - WebGUI::SQL->write("delete from Survey_response where Survey_id=".quote($_[0]->get("Survey_id"))); - WebGUI::SQL->write("delete from Survey_questionResponse where Survey_id=".quote($_[0]->get("Survey_id"))); + $self->session->db->write("delete from Survey_response where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); + $self->session->db->write("delete from Survey_questionResponse where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); return ""; } @@ -763,8 +763,8 @@ sub www_deleteAllResponsesConfirm { sub www_editSave { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); my $output = $_[0]->SUPER::www_editSave(); - if ($session{form}{proceed} eq "addQuestion") { - $session{form}{qid} = "new"; + if ($self->session->form->process("proceed") eq "addQuestion") { + $self->session->form->process("qid") = "new"; return $_[0]->www_editQuestion; } return $output; @@ -777,11 +777,11 @@ sub www_editAnswer { return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $answer = $self->getCollateral("Survey_answer","Survey_answerId",$session{form}{aid}); + $answer = $self->getCollateral("Survey_answer","Survey_answerId",$self->session->form->process("aid")); $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); $f->hidden( -name => "assetId", - -value => $session{form}{assetId} + -value => $self->session->form->process("assetId") ); $f->hidden( -name => "func", @@ -789,7 +789,7 @@ sub www_editAnswer { ); $f->hidden( -name => "qid", - -value => $session{form}{qid} + -value => $self->session->form->process("qid") ); $f->hidden( -name => "aid", @@ -815,8 +815,8 @@ sub www_editAnswer { ); } if ($self->get("questionOrder") eq "response") { - $question = WebGUI::SQL->buildHashRef("select Survey_questionId,question - from Survey_question where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); + $question = $self->session->db->buildHashRef("select Survey_questionId,question + from Survey_question where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by sequenceNumber"); $question = { ('-1' => WebGUI::International::get(82,'Asset_Survey'),%$question) }; $f->selectBox( -name=>"gotoQuestion", @@ -852,19 +852,19 @@ sub www_editAnswer { sub www_editAnswerSave { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); $_[0]->setCollateral("Survey_answer", "Survey_answerId", { - Survey_answerId => $session{form}{aid}, - Survey_questionId => $session{form}{qid}, - answer => $session{form}{answer}, - isCorrect => $session{form}{isCorrect}, + Survey_answerId => $self->session->form->process("aid"), + Survey_questionId => $self->session->form->process("qid"), + answer => $self->session->form->process("answer"), + isCorrect => $self->session->form->process("isCorrect"), Survey_id=>$_[0]->get("Survey_id"), - gotoQuestion => $session{form}{gotoQuestion} + gotoQuestion => $self->session->form->process("gotoQuestion") },1,0,"Survey_Id"); - if ($session{form}{proceed} eq "addQuestion") { - $session{form}{qid} = "new"; - } elsif ($session{form}{proceed} eq "addAnswer") { - $session{form}{aid} = "new"; + if ($self->session->form->process("proceed") eq "addQuestion") { + $self->session->form->process("qid") = "new"; + } elsif ($self->session->form->process("proceed") eq "addAnswer") { + $self->session->form->process("aid") = "new"; return $_[0]->www_editAnswer(); - } elsif ($session{form}{proceed} eq "backToPage") { + } elsif ($self->session->form->process("proceed") eq "backToPage") { return ""; } return $_[0]->www_editQuestion(); @@ -878,7 +878,7 @@ sub www_editQuestion { return WebGUI::Privilege::insufficient() unless ($self->canEdit); tie %data, 'Tie::CPHash'; - $question = $self->getCollateral("Survey_question","Survey_questionId",$session{form}{qid}); + $question = $self->getCollateral("Survey_question","Survey_questionId",$self->session->form->process("qid")); $answerFieldType = $question->{answerFieldType} || "radioList"; $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); @@ -917,8 +917,8 @@ sub www_editQuestion { -hoverHelp => WebGUI::International::get('16 description','Asset_Survey') ); - my $sectionList = WebGUI::SQL->buildHashRef("select Survey_sectionId,sectionName - from Survey_section where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); + my $sectionList = $self->session->db->buildHashRef("select Survey_sectionId,sectionName + from Survey_section where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by sequenceNumber"); $f->selectBox( -name => "section", @@ -928,8 +928,8 @@ sub www_editQuestion { ); if ($self->get("questionOrder") eq "response") { - my $ql = WebGUI::SQL->buildHashRef("select Survey_questionId,question - from Survey_question where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); + my $ql = $self->session->db->buildHashRef("select Survey_questionId,question + from Survey_question where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by sequenceNumber"); $ql = { ('-1' => WebGUI::International::get(82,'Asset_Survey'),%$ql) }; $f->selectBox( -name => "gotoQuestion", @@ -969,8 +969,8 @@ sub www_editQuestion { ) { $output .= ''.WebGUI::International::get(23,'Asset_Survey').'

'; - $sth = WebGUI::SQL->read("select Survey_answerId,answer from Survey_answer - where Survey_questionId=".quote($question->{Survey_questionId})." order by sequenceNumber"); + $sth = $self->session->db->read("select Survey_answerId,answer from Survey_answer + where Survey_questionId=".$self->session->db->quote($question->{Survey_questionId})." order by sequenceNumber"); while (%data = $sth->hash) { $output .= deleteIcon('func=deleteAnswerConfirm;qid='.$question->{Survey_questionId}.';aid='.$data{Survey_answerId}, @@ -990,47 +990,47 @@ sub www_editQuestion { sub www_editQuestionSave { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $session{form}{qid} = $_[0]->setCollateral("Survey_question", "Survey_questionId", { - question=>$session{form}{question}, - Survey_questionId=>$session{form}{qid}, + $self->session->form->process("qid") = $_[0]->setCollateral("Survey_question", "Survey_questionId", { + question=>$self->session->form->process("question"), + Survey_questionId=>$self->session->form->process("qid"), Survey_id=>$_[0]->get("Survey_id"), - allowComment=>$session{form}{allowComment}, - gotoQuestion=>$session{form}{gotoQuestion}, - answerFieldType=>$session{form}{answerFieldType}, - randomizeAnswers=>$session{form}{randomizeAnswers}, - Survey_sectionId=>$session{form}{section} + allowComment=>$self->session->form->process("allowComment"), + gotoQuestion=>$self->session->form->process("gotoQuestion"), + answerFieldType=>$self->session->form->process("answerFieldType"), + randomizeAnswers=>$self->session->form->process("randomizeAnswers"), + Survey_sectionId=>$self->session->form->process("section") },1,0,"Survey_id"); - if ($session{form}{proceed} eq "addMultipleChoiceAnswer") { - $session{form}{aid} = "new"; + if ($self->session->form->process("proceed") eq "addMultipleChoiceAnswer") { + $self->session->form->process("aid") = "new"; return $_[0]->www_editAnswer(); - } elsif ($session{form}{proceed} eq "addTextAnswer") { - $_[0]->setAnswerType("text",$session{form}{qid}); - $_[0]->addAnswer(0,$session{form}{qid}); - } elsif ($session{form}{proceed} eq "addBooleanAnswer") { - $_[0]->addAnswer(31,$session{form}{qid}); - $_[0]->addAnswer(32,$session{form}{qid}); - } elsif ($session{form}{proceed} eq "addOpinionAnswer") { - $_[0]->addAnswer(33,$session{form}{qid}); - $_[0]->addAnswer(34,$session{form}{qid}); - $_[0]->addAnswer(35,$session{form}{qid}); - $_[0]->addAnswer(36,$session{form}{qid}); - $_[0]->addAnswer(37,$session{form}{qid}); - $_[0]->addAnswer(38,$session{form}{qid}); - $_[0]->addAnswer(39,$session{form}{qid}); - } elsif ($session{form}{proceed} eq "addFrequencyAnswer") { - $_[0]->addAnswer(40,$session{form}{qid}); - $_[0]->addAnswer(41,$session{form}{qid}); - $_[0]->addAnswer(42,$session{form}{qid}); - $_[0]->addAnswer(43,$session{form}{qid}); - $_[0]->addAnswer(39,$session{form}{qid}); - } elsif ($session{form}{proceed} eq "addHTMLAreaAnswer") { - $_[0]->setAnswerType("HTMLArea",$session{form}{qid}); - $_[0]->addAnswer(0,$session{form}{qid}); - } elsif ($session{form}{proceed} eq "addTextAreaAnswer") { - $_[0]->setAnswerType("textArea",$session{form}{qid}); - $_[0]->addAnswer(0,$session{form}{qid}); - } elsif ($session{form}{proceed} eq "addQuestion") { - $session{form}{qid} = "new"; + } elsif ($self->session->form->process("proceed") eq "addTextAnswer") { + $_[0]->setAnswerType("text",$self->session->form->process("qid")); + $_[0]->addAnswer(0,$self->session->form->process("qid")); + } elsif ($self->session->form->process("proceed") eq "addBooleanAnswer") { + $_[0]->addAnswer(31,$self->session->form->process("qid")); + $_[0]->addAnswer(32,$self->session->form->process("qid")); + } elsif ($self->session->form->process("proceed") eq "addOpinionAnswer") { + $_[0]->addAnswer(33,$self->session->form->process("qid")); + $_[0]->addAnswer(34,$self->session->form->process("qid")); + $_[0]->addAnswer(35,$self->session->form->process("qid")); + $_[0]->addAnswer(36,$self->session->form->process("qid")); + $_[0]->addAnswer(37,$self->session->form->process("qid")); + $_[0]->addAnswer(38,$self->session->form->process("qid")); + $_[0]->addAnswer(39,$self->session->form->process("qid")); + } elsif ($self->session->form->process("proceed") eq "addFrequencyAnswer") { + $_[0]->addAnswer(40,$self->session->form->process("qid")); + $_[0]->addAnswer(41,$self->session->form->process("qid")); + $_[0]->addAnswer(42,$self->session->form->process("qid")); + $_[0]->addAnswer(43,$self->session->form->process("qid")); + $_[0]->addAnswer(39,$self->session->form->process("qid")); + } elsif ($self->session->form->process("proceed") eq "addHTMLAreaAnswer") { + $_[0]->setAnswerType("HTMLArea",$self->session->form->process("qid")); + $_[0]->addAnswer(0,$self->session->form->process("qid")); + } elsif ($self->session->form->process("proceed") eq "addTextAreaAnswer") { + $_[0]->setAnswerType("textArea",$self->session->form->process("qid")); + $_[0]->addAnswer(0,$self->session->form->process("qid")); + } elsif ($self->session->form->process("proceed") eq "addQuestion") { + $self->session->form->process("qid") = "new"; return $_[0]->www_editQuestion(); } return ""; @@ -1042,7 +1042,7 @@ sub www_editSection { $self = shift; my $none = WebGUI::International::get(107, 'Asset_Survey'); return WebGUI::Privilege::insufficient() unless ($self->canEdit); - $section = $self->getCollateral("Survey_section","Survey_sectionId",$session{form}{sid}); + $section = $self->getCollateral("Survey_section","Survey_sectionId",$self->session->form->process("sid")); if ($section->{sectionName} =~ /$none/) { return WebGUI::Privilege::vitalComponent; @@ -1075,9 +1075,9 @@ sub www_editSection { #------------------------------------------------------------------- sub www_editSectionSave { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $session{form}{sid} = $_[0]->setCollateral("Survey_section", "Survey_sectionId", { - sectionName => $session{form}{sectionName}, - Survey_sectionId=>$session{form}{sid}, + $self->session->form->process("sid") = $_[0]->setCollateral("Survey_section", "Survey_sectionId", { + sectionName => $self->session->form->process("sectionName"), + Survey_sectionId=>$self->session->form->process("sid"), Survey_id=>$_[0]->get("Survey_id"), },1,0,"Survey_id"); return ""; @@ -1086,73 +1086,73 @@ sub www_editSectionSave { #------------------------------------------------------------------- sub www_exportAnswers { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_answers.tab"),"text/tab"); - return WebGUI::SQL->quickTab("select * from Survey_answer where Survey_id=".quote($_[0]->get("Survey_id"))); + WebGUI::HTTP::setFilename($self->session->url->escape($_[0]->get("title")."_answers.tab"),"text/tab"); + return $self->session->db->quickTab("select * from Survey_answer where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); } #------------------------------------------------------------------- sub www_exportComposite { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_composite.tab"),"text/tab"); - return WebGUI::SQL->quickTab("select b.question, c.response, a.userId, a.username, a.ipAddress, c.comment, c.dateOfResponse from Survey_response a + WebGUI::HTTP::setFilename($self->session->url->escape($_[0]->get("title")."_composite.tab"),"text/tab"); + return $self->session->db->quickTab("select b.question, c.response, a.userId, a.username, a.ipAddress, c.comment, c.dateOfResponse from Survey_response a left join Survey_questionResponse c on a.Survey_responseId=c.Survey_responseId left join Survey_question b on c.Survey_questionId=b.Survey_questionId - where a.Survey_id=".quote($_[0]->get("Survey_id"))." order by a.userId, a.ipAddress, b.sequenceNumber"); + where a.Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))." order by a.userId, a.ipAddress, b.sequenceNumber"); } #------------------------------------------------------------------- sub www_exportQuestions { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_questions.tab"),"text/tab"); - return WebGUI::SQL->quickTab("select * from Survey_question where Survey_id=".quote($_[0]->get("Survey_id"))); + WebGUI::HTTP::setFilename($self->session->url->escape($_[0]->get("title")."_questions.tab"),"text/tab"); + return $self->session->db->quickTab("select * from Survey_question where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); } #------------------------------------------------------------------- sub www_exportResponses { return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports"))); - WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_responses.tab"),"text/tab"); - return WebGUI::SQL->quickTab("select * from Survey_response where Survey_id=".quote($_[0]->get("Survey_id"))); + WebGUI::HTTP::setFilename($self->session->url->escape($_[0]->get("title")."_responses.tab"),"text/tab"); + return $self->session->db->quickTab("select * from Survey_response where Survey_id=".$self->session->db->quote($_[0]->get("Survey_id"))); } #------------------------------------------------------------------- sub www_moveAnswerDown { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $_[0]->moveCollateralDown("Survey_answer","Survey_answerId",$session{form}{aid},"Survey_id"); + $_[0]->moveCollateralDown("Survey_answer","Survey_answerId",$self->session->form->process("aid"),"Survey_id"); return $_[0]->www_editQuestion; } #------------------------------------------------------------------- sub www_moveAnswerUp { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $_[0]->moveCollateralUp("Survey_answer","Survey_answerId",$session{form}{aid},"Survey_id"); + $_[0]->moveCollateralUp("Survey_answer","Survey_answerId",$self->session->form->process("aid"),"Survey_id"); return $_[0]->www_editQuestion; } #------------------------------------------------------------------- sub www_moveQuestionDown { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $_[0]->moveCollateralDown("Survey_question","Survey_questionId",$session{form}{qid},"Survey_id"); + $_[0]->moveCollateralDown("Survey_question","Survey_questionId",$self->session->form->process("qid"),"Survey_id"); return ""; } #------------------------------------------------------------------- sub www_moveQuestionUp { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $_[0]->moveCollateralUp("Survey_question","Survey_questionId",$session{form}{qid},"Survey_id"); + $_[0]->moveCollateralUp("Survey_question","Survey_questionId",$self->session->form->process("qid"),"Survey_id"); return ""; } #------------------------------------------------------------------- sub www_moveSectionDown { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $_[0]->moveCollateralDown("Survey_section","Survey_sectionId",$session{form}{sid},"Survey_id"); + $_[0]->moveCollateralDown("Survey_section","Survey_sectionId",$self->session->form->process("sid"),"Survey_id"); return ""; } #------------------------------------------------------------------- sub www_moveSectionUp { return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit); - $_[0]->moveCollateralUp("Survey_section","Survey_sectionId",$session{form}{sid},"Survey_id"); + $_[0]->moveCollateralUp("Survey_section","Survey_sectionId",$self->session->form->process("sid"),"Survey_id"); return ""; } @@ -1162,33 +1162,33 @@ sub www_respond { return "" unless (WebGUI::Grouping::isInGroup($self->get("groupToTakeSurvey"))); my $varname = $self->getResponseIdString; return "" unless ($session{scratch}{$varname}); - my $userId = ($self->get("anonymous")) ? substr(md5_hex($session{user}{userId}),0,8) : $session{user}{userId}; + my $userId = ($self->get("anonymous")) ? substr(md5_hex($self->session->user->profileField("userId")),0,8) : $self->session->user->profileField("userId"); my $terminate = 0; foreach my $key (keys %{$session{form}}) { if ($key =~ /^answerId_(.+)$/) { my $id = $1; - my ($previousResponse) = WebGUI::SQL->quickArray("select count(*) from Survey_questionResponse - where Survey_answerId=".quote($session{form}{"answerId_".$id})." and Survey_responseId=".quote($session{scratch}{$varname})); + my ($previousResponse) = $self->session->db->quickArray("select count(*) from Survey_questionResponse + where Survey_answerId=".$self->session->db->quote($session{form}{"answerId_".$id})." and Survey_responseId=".$self->session->db->quote($session{scratch}{$varname})); next if ($previousResponse); my $answer = $self->getCollateral("Survey_answer","Survey_answerId",$session{form}{"answerId_".$id}); if ($self->get("questionOrder") eq "response" && $answer->{gotoQuestion} eq "") { $terminate = 1; } my $response = $session{form}{"textResponse_".$id} || $answer->{answer}; - WebGUI::SQL->write("insert into Survey_questionResponse (Survey_answerId,Survey_questionId,Survey_responseId,Survey_id,comment,response,dateOfResponse) values ( - ".quote($answer->{Survey_answerId}).", ".quote($answer->{Survey_questionId}).", ".quote($session{scratch}{$varname}).", ".quote($answer->{Survey_id}).", - ".quote($session{form}{"comment_".$id}).", ".quote($response).", ".WebGUI::DateTime::time().")"); + $self->session->db->write("insert into Survey_questionResponse (Survey_answerId,Survey_questionId,Survey_responseId,Survey_id,comment,response,dateOfResponse) values ( + ".$self->session->db->quote($answer->{Survey_answerId}).", ".$self->session->db->quote($answer->{Survey_questionId}).", ".$self->session->db->quote($session{scratch}{$varname}).", ".$self->session->db->quote($answer->{Survey_id}).", + ".$self->session->db->quote($session{form}{"comment_".$id}).", ".$self->session->db->quote($response).", ".WebGUI::DateTime::time().")"); } } my $responseCount = $self->getQuestionResponseCount($session{scratch}{$varname}); if ($terminate || $responseCount >= $self->getValue("questionsPerResponse") || $responseCount >= $self->getQuestionCount) { - WebGUI::SQL->setRow("Survey_response","Survey_responseId",{ + $self->session->db->setRow("Survey_response","Survey_responseId",{ isComplete=>1, endDate=>WebGUI::DateTime::time(), Survey_responseId=>$session{scratch}{$varname} }); } - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); return ""; } @@ -1209,14 +1209,14 @@ sub www_view { sub www_viewGradebook { my $self = shift; return "" unless (WebGUI::Grouping::isInGroup($self->get("groupToViewReports"))); - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); my $var = $self->getMenuVars; $var->{title} = WebGUI::International::get(71,'Asset_Survey'); my $p = WebGUI::Paginator->new($self->getUrl('func=viewGradebook')); $p->setDataByQuery("select userId,username,ipAddress,Survey_responseId,startDate,endDate from Survey_response - where Survey_id=".quote($self->get("Survey_id"))." order by username,ipAddress,startDate"); + where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by username,ipAddress,startDate"); my $users = $p->getPageData; - ($var->{'question.count'}) = WebGUI::SQL->quickArray("select count(*) from Survey_question where Survey_id=".quote($self->get("Survey_id"))); + ($var->{'question.count'}) = $self->session->db->quickArray("select count(*) from Survey_question where Survey_id=".$self->session->db->quote($self->get("Survey_id"))); if ($var->{'question.count'} > $self->get("questionsPerResponse")) { $var->{'question.count'} = $self->get("questionsPerResponse"); } @@ -1225,8 +1225,8 @@ sub www_viewGradebook { $var->{'response.percent.label'} = WebGUI::International::get(54,'Asset_Survey'); my @responseloop; foreach my $user (@$users) { - my ($correctCount) = WebGUI::SQL->quickArray("select count(*) from Survey_questionResponse a left join - Survey_answer b on a.Survey_answerId=b.Survey_answerId where a.Survey_responseId=".quote($user->{Survey_responseId}) + my ($correctCount) = $self->session->db->quickArray("select count(*) from Survey_questionResponse a left join + Survey_answer b on a.Survey_answerId=b.Survey_answerId where a.Survey_responseId=".$self->session->db->quote($user->{Survey_responseId}) ." and b.isCorrect=1"); push(@responseloop, { 'response.url'=>$self->getUrl('func=viewIndividualSurvey;responseId='.$user->{Survey_responseId}), @@ -1237,7 +1237,7 @@ sub www_viewGradebook { } $var->{response_loop} = \@responseloop; $p->appendTemplateVars($var); - return WebGUI::Style::process($self->processTemplate($var,$self->getValue("gradebookTemplateId")),$self->getValue("styleTemplateId")); + return $self->session->style->process($self->processTemplate($var,$self->getValue("gradebookTemplateId")),$self->getValue("styleTemplateId")); # return $self->processTemplate($self->getValue("gradebookTemplateId"),$var,"Survey/Gradebook"); } @@ -1246,12 +1246,12 @@ sub www_viewGradebook { sub www_viewIndividualSurvey { my $self = shift; return "" unless (WebGUI::Grouping::isInGroup($self->get("groupToViewReports"))); - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); my $var = $self->getMenuVars; $var->{'title'} = WebGUI::International::get(70,'Asset_Survey'); - $var->{'delete.url'} = $self->getUrl('func=deleteResponse;responseId='.$session{form}{responseId}); + $var->{'delete.url'} = $self->getUrl('func=deleteResponse;responseId='.$self->session->form->process("responseId")); $var->{'delete.label'} = WebGUI::International::get(69,'Asset_Survey'); - my $response = WebGUI::SQL->getRow("Survey_response","Survey_responseId",$session{form}{responseId}); + my $response = $self->session->db->getRow("Survey_response","Survey_responseId",$self->session->form->process("responseId")); $var->{'start.date.label'} = WebGUI::International::get(76,'Asset_Survey'); $var->{'start.date.epoch'} = $response->{startDate}; $var->{'start.date.human'} = epochToHuman($response->{startDate},"%z"); @@ -1268,23 +1268,23 @@ sub www_viewIndividualSurvey { $var->{'answer.label'} = WebGUI::International::get(19,'Asset_Survey'); $var->{'response.label'} = WebGUI::International::get(66,'Asset_Survey'); $var->{'comment.label'} = WebGUI::International::get(57,'Asset_Survey'); - my $questions = WebGUI::SQL->read("select Survey_questionId,question,answerFieldType from Survey_question - where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); + my $questions = $self->session->db->read("select Survey_questionId,question,answerFieldType from Survey_question + where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by sequenceNumber"); my @questionloop; while (my $qdata = $questions->hashRef) { my @aid; my @answer; if ($qdata->{answerFieldType} eq "radioList") { - my $sth = WebGUI::SQL->read("select Survey_answerId,answer from Survey_answer - where Survey_questionId=".quote($qdata->{Survey_questionId})." and isCorrect=1 order by sequenceNumber"); + my $sth = $self->session->db->read("select Survey_answerId,answer from Survey_answer + where Survey_questionId=".$self->session->db->quote($qdata->{Survey_questionId})." and isCorrect=1 order by sequenceNumber"); while (my $adata = $sth->hashRef) { push(@aid,$adata->{Survey_answerId}); push(@answer,$adata->{answer}); } $sth->finish; } - my $rdata = WebGUI::SQL->quickHashRef("select Survey_answerId,response,comment from Survey_questionResponse - where Survey_questionId=".quote($qdata->{Survey_questionId})." and Survey_responseId=".quote($session{form}{responseId})); + my $rdata = $self->session->db->quickHashRef("select Survey_answerId,response,comment from Survey_questionResponse + where Survey_questionId=".$self->session->db->quote($qdata->{Survey_questionId})." and Survey_responseId=".$self->session->db->quote($self->session->form->process("responseId"))); push(@questionloop,{ question => $qdata->{question}, 'question.id'=>$qdata->{Survey_questionId}, @@ -1297,7 +1297,7 @@ sub www_viewIndividualSurvey { } $questions->finish; $var->{question_loop} = \@questionloop; - return WebGUI::Style::process($self->processTemplate($var, $self->getValue("responseTemplateId")),$self->getValue("styleTemplateId")); + return $self->session->style->process($self->processTemplate($var, $self->getValue("responseTemplateId")),$self->getValue("styleTemplateId")); # return $self->processTemplate($self->getValue("responseTemplateId"),$var,"Survey/Response"); } @@ -1305,12 +1305,12 @@ sub www_viewIndividualSurvey { sub www_viewStatisticalOverview { my $self = shift; return "" unless (WebGUI::Grouping::isInGroup($self->get("groupToViewReports"))); - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); my $var = $self->getMenuVars; $var->{title} = WebGUI::International::get(58,'Asset_Survey'); my $p = WebGUI::Paginator->new($self->getUrl('func=viewStatisticalOverview')); $p->setDataByQuery("select Survey_questionId,question,answerFieldType,allowComment from Survey_question - where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); + where Survey_id=".$self->session->db->quote($self->get("Survey_id"))." order by sequenceNumber"); my $questions = $p->getPageData; my @questionloop; $var->{'answer.label'} = WebGUI::International::get(19,'Asset_Survey'); @@ -1320,12 +1320,12 @@ sub www_viewStatisticalOverview { $var->{'show.comments.label'} = WebGUI::International::get(56,'Asset_Survey'); foreach my $question (@$questions) { my @answerloop; - my ($totalResponses) = WebGUI::SQL->quickArray("select count(*) from Survey_questionResponse where Survey_questionId=".quote($question->{Survey_questionId})); + my ($totalResponses) = $self->session->db->quickArray("select count(*) from Survey_questionResponse where Survey_questionId=".$self->session->db->quote($question->{Survey_questionId})); if ($question->{answerFieldType} eq "radioList") { - my $sth = WebGUI::SQL->read("select Survey_answerId,answer,isCorrect from Survey_answer where - Survey_questionId=".quote($question->{Survey_questionId})." order by sequenceNumber"); + my $sth = $self->session->db->read("select Survey_answerId,answer,isCorrect from Survey_answer where + Survey_questionId=".$self->session->db->quote($question->{Survey_questionId})." order by sequenceNumber"); while (my $answer = $sth->hashRef) { - my ($numResponses) = WebGUI::SQL->quickArray("select count(*) from Survey_questionResponse where Survey_answerId=".quote($answer->{Survey_answerId})); + my ($numResponses) = $self->session->db->quickArray("select count(*) from Survey_questionResponse where Survey_answerId=".$self->session->db->quote($answer->{Survey_answerId})); my $responsePercent; if ($totalResponses) { $responsePercent = round(($numResponses/$totalResponses)*100); @@ -1333,7 +1333,7 @@ sub www_viewStatisticalOverview { $responsePercent = 0; } my @commentloop; - my $sth2 = WebGUI::SQL->read("select comment from Survey_questionResponse where Survey_answerId=".quote($answer->{Survey_answerId})); + my $sth2 = $self->session->db->read("select comment from Survey_questionResponse where Survey_answerId=".$self->session->db->quote($answer->{Survey_answerId})); while (my ($comment) = $sth2->array) { push(@commentloop,{ 'answer.comment'=>$comment @@ -1350,7 +1350,7 @@ sub www_viewStatisticalOverview { } $sth->finish; } else { - my $sth = WebGUI::SQL->read("select response,comment from Survey_questionResponse where Survey_questionId=".quote($question->{Survey_questionId})); + my $sth = $self->session->db->read("select response,comment from Survey_questionResponse where Survey_questionId=".$self->session->db->quote($question->{Survey_questionId})); while (my $response = $sth->hashRef) { push(@answerloop,{ 'answer.response'=>$response->{response}, @@ -1371,7 +1371,7 @@ sub www_viewStatisticalOverview { $var->{question_loop} = \@questionloop; $p->appendTemplateVars($var); - return WebGUI::Style::process($self->processTemplate($var, $self->getValue("overviewTemplateId")),$self->getValue("styleTemplateId")); + return $self->session->style->process($self->processTemplate($var, $self->getValue("overviewTemplateId")),$self->getValue("styleTemplateId")); } 1; diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index cc91eba19..387342e6d 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -247,7 +247,7 @@ sub _get_rss_data { my $ua = LWP::UserAgent->new(timeout => 5); my $response = $ua->get($url); if (!$response->is_success()) { - WebGUI::ErrorHandler::warn("Error retrieving url '$url': " . + $self->session->errorHandler->warn("Error retrieving url '$url': " . $response->status_line()); return undef; } @@ -260,7 +260,7 @@ sub _get_rss_data { my $encoding = 'utf8'; if (lc($xmlEncoding) ne lc($encoding)) { eval { from_to($xml, $xmlEncoding, $encoding) }; - WebGUI::ErrorHandler::warn($@) if ($@); + $self->session->errorHandler->warn($@) if ($@); } } @@ -270,7 +270,7 @@ sub _get_rss_data { XML::RSSLite::parseXML($rss_lite, \$xml); }; if ($@) { - WebGUI::ErrorHandler::warn("error parsing rss for url $url :".$@); + $self->session->errorHandler->warn("error parsing rss for url $url :".$@); #Returning undef on a parse failure is a change from previous behaviour, #but it SHOULDN'T have a major effect. return undef; @@ -285,10 +285,10 @@ sub _get_rss_data { $rss_lite = {channel => $rss_lite}; if (!($rss->{channel} = _find_record($rss_lite, qr/^channel$/))) { - WebGUI::ErrorHandler::warn("unable to find channel info for url $url"); + $self->session->errorHandler->warn("unable to find channel info for url $url"); } if (!($rss->{items} = _find_record($rss_lite, qr/^items?$/))) { - WebGUI::ErrorHandler::warn("unable to find item info for url $url"); + $self->session->errorHandler->warn("unable to find item info for url $url"); $rss->{items} = []; } @@ -482,7 +482,7 @@ Returns the rendered output of the wobject. sub view { my $self = shift; my $rssFlavor = shift; - $self->logView() if ($session{setting}{passiveProfilingEnabled}); + $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); my $maxHeadlines = $self->get('maxHeadlines') || 1000000; my @urls = split(/\s+/,$self->get('rssUrl')); @@ -517,7 +517,7 @@ sub view { #Looks like a kludge, but what this does is put in the proper #XSLT stylesheet so the RSS doesn't look like total ass. - my $siteURL=WebGUI::URL::getSiteURL().WebGUI::URL::gateway(); + my $siteURL=$self->session->url->getSiteURL().$self->session->url->gateway(); $rss=~s|<\?xml version="1\.0" encoding="UTF\-8"\?>|<\?xml version="1\.0" encoding="UTF\-8"\?>\n\n|; return $rss; @@ -534,7 +534,7 @@ sub _constructRSSHeadTitleLink{ my $rssFeedSuffix=WebGUI::International::get('RSS Feed Title Suffix','Asset_SyndicatedContent'); my $title = ($rssTitle) ? ($rssTitle." ".$rssFeedSuffix) : $rssFeedSuffix; $title =~ s/\"/"/g; - WebGUI::Style::setLink($var->{'rss.url'}, + $self->session->style->setLink($var->{'rss.url'}, { rel=> 'alternate', type=> 'application/rss+xml', title=> ($rssTitle) ? ($rssTitle." ".$rssFeedSuffix) : $rssFeedSuffix } @@ -548,7 +548,7 @@ sub _constructRSS{ #They've chosen to emit this as an RSS feed, in one of the four flavors we support. $rssObject->channel( title=>$var->{'channel.title'} || $self->get('title'), - link=>WebGUI::URL::page('',1), + link=>$self->session->url->page('',1), description=>$var->{'channel.description'} || '' ); foreach my $item (@{$var->{item_loop}}) { diff --git a/lib/WebGUI/Asset/Wobject/WSClient.pm b/lib/WebGUI/Asset/Wobject/WSClient.pm index 5ba42d2ec..f3f545dd3 100644 --- a/lib/WebGUI/Asset/Wobject/WSClient.pm +++ b/lib/WebGUI/Asset/Wobject/WSClient.pm @@ -27,7 +27,7 @@ sub _create_cache_key { $cache_key = $_[0]->get('sharedCache') ? Digest::MD5::md5_hex($call, $param_str) : Digest::MD5::md5_hex($call, $param_str, $session{'var'}{'sessionId'}); - WebGUI::ErrorHandler::warn(($_[0]->get('sharedCache')?'shared':'session') + $self->session->errorHandler->warn(($_[0]->get('sharedCache')?'shared':'session') . " cache_key=$cache_key md5_hex($call, $param_str)"); return $cache_key; } @@ -258,11 +258,11 @@ sub view { @seen{@exclude_params} = (); for (keys %{$session{'form'}}) { unless (exists $seen{$_}) { - $query_string .= WebGUI::URL::escape($_) . '=' - . WebGUI::URL::escape($session{'form'}{$_}) . ';'; + $query_string .= $self->session->url->escape($_) . '=' + . $self->session->url->escape($session{'form'}{$_}) . ';'; } } - $url = WebGUI::URL::page($query_string); + $url = $self->session->url->page($query_string); # snag our SOAP call and preprocess if needed @@ -282,7 +282,7 @@ sub view { ($session{'form'}{'disableWobjects'} && grep /^$call$/, $session{'form'}{'disableWobjects'})) { - WebGUI::ErrorHandler::warn("disabling soap call $call"); + $self->session->errorHandler->warn("disabling soap call $call"); $var{'disableWobject'} = 1; return $self->processTemplate(\%var,$self->get("templateId")); } @@ -302,9 +302,9 @@ sub view { && grep /^$call$/, @targetWobjects) { $cache_key = $session{'form'}{'cache'}; - WebGUI::ErrorHandler::warn("passed a cache_key for $call"); + $self->session->errorHandler->warn("passed a cache_key for $call"); } else { - WebGUI::ErrorHandler::warn("cache_key not applicable to $call "); + $self->session->errorHandler->warn("cache_key not applicable to $call "); $cache_key = _create_cache_key($self, $call, $param_str); } } else { @@ -326,7 +326,7 @@ sub view { # the solution is to normalize all params to another table eval "\$arr_ref = [$param_str];"; eval { @params = @$arr_ref; }; - WebGUI::ErrorHandler::debug(WebGUI::International::get(22, "Asset_WSClient")) if $@ && $self->get('debugMode'); + $self->session->errorHandler->debug(WebGUI::International::get(22, "Asset_WSClient")) if $@ && $self->get('debugMode'); if ($self->get('execute_by_default') || grep /^$call$/, @targetWobjects) { @@ -335,12 +335,12 @@ sub view { # valid looking uri, but I haven't hunted for the relevant RFC yet if ($self->get("uri") =~ m!.+/.+!) { - WebGUI::ErrorHandler::debug('uri=' . $self->get("uri")) + $self->session->errorHandler->debug('uri=' . $self->get("uri")) if $self->get('debugMode'); $soap = $self->_instantiate_soap; } else { - WebGUI::ErrorHandler::debug(WebGUI::International::get(23, "Asset_WSClient")) if $self->get('debugMode'); + $self->session->errorHandler->debug(WebGUI::International::get(23, "Asset_WSClient")) if $self->get('debugMode'); } } } @@ -355,14 +355,14 @@ sub view { # otherwise)". That "not stated otherwise" bit is important. my $return = $soap->$call(@params); - WebGUI::ErrorHandler::debug("$call(" . (join ',', @params) . ')') + $self->session->errorHandler->debug("$call(" . (join ',', @params) . ')') if $self->get('debugMode'); # The possible return types I've come across include a SOAP object, # a hash reference, a blessed object or a simple scalar. Each type # requires different handling (woohoo!) before being passed to the # template system - WebGUI::ErrorHandler::debug(WebGUI::International::get(24, "Asset_WSClient") . (ref $return ? ref $return : 'scalar')) if $self->get('debugMode'); + $self->session->errorHandler->debug(WebGUI::International::get(24, "Asset_WSClient") . (ref $return ? ref $return : 'scalar')) if $self->get('debugMode'); # SOAP object if ((ref $return) =~ /SOAP/i) { @@ -374,7 +374,7 @@ sub view { # blessed object, to be stripped with Data::Structure::Util } elsif ( ref $return) { - WebGUI::ErrorHandler::warn("Data::Structure::Util::unbless($return)"); + $self->session->errorHandler->warn("Data::Structure::Util::unbless($return)"); @result = Data::Structure::Util::unbless($return); # scalar value, we hope @@ -390,18 +390,18 @@ sub view { # did the soap call fault? if ($@) { - WebGUI::ErrorHandler::debug($@) if $self->get('debugMode'); + $self->session->errorHandler->debug($@) if $self->get('debugMode'); $var{'soapError'} = $@; - WebGUI::ErrorHandler::debug(WebGUI::International::get(25, "Asset_WSClient") . $var{'soapError'}) + $self->session->errorHandler->debug(WebGUI::International::get(25, "Asset_WSClient") . $var{'soapError'}) if $self->get('debugMode'); } # cached data was found } else { - WebGUI::ErrorHandler::warn("Using cached data"); + $self->session->errorHandler->warn("Using cached data"); } - WebGUI::ErrorHandler::debug(Dumper(@result)) if + $self->session->errorHandler->debug(Dumper(@result)) if $self->get('debugMode'); # Do we need to decode utf8 data? Will only decode if modules were @@ -475,7 +475,7 @@ sub view { } else { - WebGUI::ErrorHandler::debug(WebGUI::International::get(26, "Asset_WSClient") . $@) if $self->get('debugMode'); + $self->session->errorHandler->debug(WebGUI::International::get(26, "Asset_WSClient") . $@) if $self->get('debugMode'); } # did they request a funky http header? @@ -483,7 +483,7 @@ sub view { $self->get("httpHeader")) { WebGUI::HTTP::setMimeType($self->get("httpHeader")); - WebGUI::ErrorHandler::warn("changed mimetype: " . $session{'header'}{'mimetype'}); + $self->session->errorHandler->warn("changed mimetype: " . $session{'header'}{'mimetype'}); } # Note, we still process our template below even though it will never @@ -507,7 +507,7 @@ sub _instantiate_soap { # we don't use fault handling with wsdls becuase they seem to behave # differently. Not sure if that is by design. if ( ($self->get("uri") =~ m/\.wsdl\s*$/i) || ($self->get("uri") =~ m/\.\w*\?wsdl\s*$/i) ) { - WebGUI::ErrorHandler::debug('wsdl=' . $self->get('uri')) + $self->session->errorHandler->debug('wsdl=' . $self->get('uri')) if $self->get('debugMode'); # instantiate SOAP service @@ -515,7 +515,7 @@ sub _instantiate_soap { # standard uri namespace } else { - WebGUI::ErrorHandler::debug('uri=' . $self->get('uri')) + $self->session->errorHandler->debug('uri=' . $self->get('uri')) if $self->get('debugMode'); # instantiate SOAP service, with fault handling @@ -529,7 +529,7 @@ sub _instantiate_soap { # proxy the call if requested if ($self->get("proxy") && $soap) { - WebGUI::ErrorHandler::debug('proxy=' . $self->get('proxy')) + $self->session->errorHandler->debug('proxy=' . $self->get('proxy')) if $self->get('debugMode'); $soap->proxy($self->get('proxy'), options => {compress_threshold => 10000}); diff --git a/lib/WebGUI/Asset/Wobject/WeatherData.pm b/lib/WebGUI/Asset/Wobject/WeatherData.pm index 98f460226..8241a68a2 100644 --- a/lib/WebGUI/Asset/Wobject/WeatherData.pm +++ b/lib/WebGUI/Asset/Wobject/WeatherData.pm @@ -91,7 +91,7 @@ sub _getLocationData { my $ua = LWP::UserAgent->new; $ua->timeout(10); $oldagent = $ua->agent(); - $ua->agent($session{env}{HTTP_USER_AGENT}); # Act as a proxy. + $ua->agent($self->session->env->get("HTTP_USER_AGENT")); # Act as a proxy. my $response = $ua->get('http://www.srh.noaa.gov/port/port_zc.php?inputstring='.$location); my $document = $response->content; $document =~ s/\n/ /g; @@ -102,7 +102,7 @@ sub _getLocationData { cityState => $1 || $location, sky => $2 || 'N/A', tempF => $3 || 'N/A', - iconUrl => $session{config}{extrasURL}.'/wobject/WeatherData/'.$self->_chooseWeatherConditionsIcon($2).'.jpg' + iconUrl => $self->session->config->get("extrasURL").'/wobject/WeatherData/'.$self->_chooseWeatherConditionsIcon($2).'.jpg' }; $cache->set($locData, 60*60) if $locData->{sky} ne 'NULL'; }