From 024514c549c477286b87c351f8d3b191f6c9762f Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 9 Jan 2006 19:56:26 +0000 Subject: [PATCH] more session related changes --- docs/migration.txt | 34 ++- lib/WebGUI.pm | 2 +- lib/WebGUI/AdminConsole.pm | 49 ++-- lib/WebGUI/Affiliate.pm | 30 ++- lib/WebGUI/Asset.pm | 180 +++++++------- lib/WebGUI/Asset/Post.pm | 4 +- lib/WebGUI/Asset/Post/Thread.pm | 6 +- lib/WebGUI/Asset/Redirect.pm | 25 +- lib/WebGUI/Asset/Shortcut.pm | 8 +- lib/WebGUI/Asset/Snippet.pm | 2 +- lib/WebGUI/Asset/Wobject.pm | 4 +- lib/WebGUI/Asset/Wobject/Collaboration.pm | 6 +- lib/WebGUI/Asset/Wobject/DataForm.pm | 8 +- lib/WebGUI/Asset/Wobject/HttpProxy.pm | 4 +- lib/WebGUI/Asset/Wobject/Navigation.pm | 2 +- lib/WebGUI/Asset/Wobject/SQLReport.pm | 8 +- lib/WebGUI/Asset/Wobject/StockData.pm | 2 +- lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 6 +- lib/WebGUI/Asset/Wobject/WSClient.pm | 6 +- lib/WebGUI/Asset/Wobject/WeatherData.pm | 2 +- lib/WebGUI/AssetBranch.pm | 56 ++--- lib/WebGUI/AssetClipboard.pm | 54 ++--- lib/WebGUI/AssetExportHtml.pm | 52 ++-- lib/WebGUI/AssetLineage.pm | 80 +++--- lib/WebGUI/AssetMetaData.pm | 80 +++--- lib/WebGUI/AssetPackage.pm | 6 +- lib/WebGUI/AssetTrash.pm | 52 ++-- lib/WebGUI/AssetVersioning.pm | 106 ++++---- lib/WebGUI/Auth.pm | 129 +++++----- lib/WebGUI/Auth/LDAP.pm | 71 +++--- lib/WebGUI/Auth/WebGUI.pm | 192 ++++++++------- lib/WebGUI/Cache.pm | 34 ++- lib/WebGUI/Cache/FileCache.pm | 35 ++- lib/WebGUI/Cache/Memcached.pm | 16 +- lib/WebGUI/Commerce.pm | 11 +- lib/WebGUI/Commerce/Item.pm | 18 +- lib/WebGUI/Commerce/Payment.pm | 32 +-- lib/WebGUI/Commerce/Payment/ITransact.pm | 98 ++++---- lib/WebGUI/Commerce/Shipping.pm | 14 +- lib/WebGUI/Commerce/ShoppingCart.pm | 22 +- lib/WebGUI/Commerce/Transaction.pm | 74 +++--- lib/WebGUI/DatabaseLink.pm | 227 ++++++++++++++---- lib/WebGUI/DateTime.pm | 13 +- lib/WebGUI/Form.pm | 4 +- lib/WebGUI/Form/Codearea.pm | 2 +- lib/WebGUI/Form/Color.pm | 2 +- lib/WebGUI/Form/DatabaseLink.pm | 4 +- lib/WebGUI/Form/Date.pm | 8 +- lib/WebGUI/Form/DateTime.pm | 8 +- lib/WebGUI/Form/DynamicField.pm | 6 +- lib/WebGUI/Form/Email.pm | 2 +- lib/WebGUI/Form/FieldType.pm | 2 +- lib/WebGUI/Form/File.pm | 2 +- lib/WebGUI/Form/Float.pm | 2 +- lib/WebGUI/Form/HTMLArea.pm | 2 +- lib/WebGUI/Form/Integer.pm | 2 +- lib/WebGUI/Form/Phone.pm | 2 +- lib/WebGUI/Form/TimeField.pm | 2 +- lib/WebGUI/Form/Url.pm | 2 +- lib/WebGUI/Form/Zipcode.pm | 2 +- lib/WebGUI/Group.pm | 92 +++---- lib/WebGUI/Grouping.pm | 100 ++++---- lib/WebGUI/HTML.pm | 4 +- lib/WebGUI/HTMLForm.pm | 6 +- lib/WebGUI/Help/Asset.pm | 6 +- lib/WebGUI/Help/Macros.pm | 2 +- lib/WebGUI/Icon.pm | 46 ++-- lib/WebGUI/International.pm | 24 +- lib/WebGUI/LDAPLink.pm | 4 +- lib/WebGUI/Macro.pm | 2 +- lib/WebGUI/Mail.pm | 34 +-- lib/WebGUI/MessageLog.pm | 30 +-- lib/WebGUI/Operation/ActiveSessions.pm | 2 +- lib/WebGUI/Operation/Cache.pm | 6 +- lib/WebGUI/Operation/Commerce.pm | 2 +- lib/WebGUI/Operation/DatabaseLink.pm | 56 ++--- lib/WebGUI/Operation/Group.pm | 7 +- lib/WebGUI/Operation/Help.pm | 10 +- lib/WebGUI/Operation/LDAPLink.pm | 2 +- lib/WebGUI/Operation/LoginHistory.pm | 2 +- lib/WebGUI/Operation/ProductManager.pm | 2 +- lib/WebGUI/Operation/ProfileSettings.pm | 6 +- lib/WebGUI/Operation/Replacements.pm | 2 +- lib/WebGUI/Operation/Settings.pm | 2 +- lib/WebGUI/Operation/Statistics.pm | 4 +- lib/WebGUI/Operation/Subscription.pm | 2 +- lib/WebGUI/Operation/User.pm | 4 +- lib/WebGUI/Paginator.pm | 20 +- lib/WebGUI/PassiveProfiling.pm | 46 ++-- lib/WebGUI/Privilege.pm | 2 +- lib/WebGUI/Product.pm | 78 +++--- lib/WebGUI/ProfileCategory.pm | 34 +-- lib/WebGUI/ProfileField.pm | 50 ++-- lib/WebGUI/SQL.pm | 18 +- lib/WebGUI/Session.pm | 8 +- lib/WebGUI/Session/Http.pm | 2 +- lib/WebGUI/Session/Scratch.pm | 4 +- lib/WebGUI/Session/Style.pm | 6 +- lib/WebGUI/Session/Url.pm | 8 +- lib/WebGUI/Storage.pm | 28 +-- lib/WebGUI/Storage/Image.pm | 28 +-- lib/WebGUI/Subscription.pm | 16 +- lib/WebGUI/TabForm.pm | 12 +- lib/WebGUI/User.pm | 52 ++-- lib/WebGUI/i18n/English/Asset_Redirect.pm | 20 ++ .../i18n/English/Automated_Information.pm | 6 +- 106 files changed, 1498 insertions(+), 1313 deletions(-) diff --git a/docs/migration.txt b/docs/migration.txt index c82413952..a02864d5b 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -656,17 +656,43 @@ find . -name '*.pm' -exec perl -pi.bak -e 's!\$session{page}{useEmptyStyle} = (\ find . -name '*.pm' -exec perl -pi.bak -e 's!\$session{page}{makePrintable} = (\d+);!\$self->session->style->makePrintable("$1")!g' {} \; find . -name '*.pm' -exec perl -pi.bak -e 's!WebGUI\:\:Style\:\:!\$self->session->style->!g' {} \; -5.23.5 WebGUI::URL API Refactored +5.23.5 WebGUI::Macro API Refactored + +You now need to pass in a reference to $session to the process function. + +find . -name '*.pm' -exec perl -pi.bak -e 's!WebGUI\:\:Macro\:\:process\((.*)\)!WebGUI::Macro::process(\$self->session,$1)!g' {} \; + + +5.23.6 WebGUI::URL API Refactored As of 6.9 WebGUI::URL is now accessed through session like $session->url find . -name '*.pm' -exec perl -pi.bak -e 's!WebGUI\:\:URL\:\:!\$self->session->url->!g' {} \; -5.23.5 Lots of APIs Refactored +5.23.7 WebGUI::Cache API Refactored -Lots of other API's have been refactored in 6.9 to conform to the new OO based -session system. You should look at the API docs for individual details. +As of 6.9 WebGUI::Cache requires you to pass in a reference to $session into +the constructor. + +find . -name '*.pm' -exec perl -pi.bak -e 's!WebGUI\:\:Cache\-\>new\(!WebGUI::Cache->new(\$self->session,!g' {} \; + + +5.23.8 WebGUI::AdminConsole Refactored + +As of 6.9 WebGUI::AdminConsole requires you to pass a reference to $session +into the constructor. + +find . -name '*.pm' -exec perl -pi.bak -e 's!WebGUI\:\:AdminConsole\-\>new\(!WebGUI::AdminConsole->new(\$self->session,!g' {} \; + + +5.23.9 WebGUI::DatabaseLink API Refactored + +As of 6.9 WebGUI::DatabaseLink requires you to pass in a reference to +$session into the constructor. Also, the API has been heavily refactored to be +more complete. Please see it's API docs for more info. + +find . -name '*.pm' -exec perl -pi.bak -e 's!WebGUI\:\:DatabaseLink\-\>new\(!WebGUI::DatabaseLink->new(\$self->session,!g' {} \; diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index f0393cf2e..5ca03bb14 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -89,7 +89,7 @@ sub contentHandler { } $r->print($session->http->getHeader()); $r->print($output) unless ($session->http->isRedirect()); - #WebGUI::Affiliate::grabReferral(); # process affilliate tracking request + WebGUI::Affiliate::grabReferral($session); # process affilliate tracking request } $session->close; return Apache2::Const::OK; diff --git a/lib/WebGUI/AdminConsole.pm b/lib/WebGUI/AdminConsole.pm index da3c773b1..c376a2bca 100644 --- a/lib/WebGUI/AdminConsole.pm +++ b/lib/WebGUI/AdminConsole.pm @@ -17,10 +17,7 @@ package WebGUI::AdminConsole; use strict; use WebGUI::Grouping; use WebGUI::International; -use WebGUI::Session; -use WebGUI::Style; use WebGUI::Asset::Template; -use WebGUI::URL; =head1 NAME @@ -66,17 +63,17 @@ sub _formatFunction { my $function = shift; my $url; if (exists $function->{func}) { - $url = WebGUI::URL::page("func=".$function->{func}); + $url = $self->session->url->page("func=".$function->{func}); } else { - $url = WebGUI::URL::page("op=".$function->{op}); + $url = $self->session->url->page("op=".$function->{op}); } return { title=>WebGUI::International::get($function->{title}{id}, $function->{title}{namespace}), - icon=>$session{config}{extrasURL}."/adminConsole/".$function->{icon}, - 'icon.small'=>$session{config}{extrasURL}."/adminConsole/small/".$function->{icon}, + icon=>$self->session->config->get("extrasURL")."/adminConsole/".$function->{icon}, + 'icon.small'=>$self->session->config->get("extrasURL")."/adminConsole/small/".$function->{icon}, url=>$url, canUse=>WebGUI::Grouping::isInGroup($function->{group}), - isCurrentOpFunc=>($session{form}{op} eq $function->{op} || $session{form}{func} eq $function->{func}) + isCurrentOpFunc=>($self->session->form->get("op") eq $function->{op} || $self->session->form->get("func") eq $function->{func}) }; } @@ -121,10 +118,11 @@ Returns a Hash of title, url, canUse, and icon. title is the Internationalizatio =cut sub getAdminConsoleParams { + my $self = shift; return { 'title' => WebGUI::International::get("admin console","AdminConsole"), - url => WebGUI::URL::page("op=adminConsole"), + url => $self->session->url->page("op=adminConsole"), canUse => WebGUI::Grouping::isInGroup("12"), - icon => $session{config}{extrasURL}."/adminConsole/adminConsole.gif" + icon => $self->session->config->get("extrasURL")."/adminConsole/adminConsole.gif" }; } @@ -353,10 +351,14 @@ sub getAdminFunction { #------------------------------------------------------------------- -=head2 new ( [id] ) +=head2 new ( session, [id] ) Constructor. +=head2 session + +A reference to the current session. + =head3 id If supplied, updates the _function of the AdminFunction. @@ -365,9 +367,11 @@ If supplied, updates the _function of the AdminFunction. sub new { my $class = shift; + my $session = shift; my $id = shift; my %self; $self{_function} = $class->getAdminFunction($id) if ($id); + $self{_session} = $session; bless \%self, $class; } @@ -405,20 +409,20 @@ sub render { $var{"console.canUse"} = $acParams->{canUse}; $var{"console.icon"} = $acParams->{icon}; $var{"help.url"} = $self->{_helpUrl}; - if (exists $session{asset}) { - my $importNode = $session{asset}->getImportNode; + if (exists $self->session->asset) { + my $importNode = $self->session->asset->getImportNode; my $importNodeLineage = $importNode->get("lineage"); - my $assetLineage = $session{asset}->get("lineage"); + my $assetLineage = $self->session->asset->get("lineage"); if ($assetLineage =~ /^$importNodeLineage/ || $assetLineage eq "000001") { - $var{"backtosite.url"} = $session{asset}->getDefault->getUrl; + $var{"backtosite.url"} = $self->session->asset->getDefault->getUrl; } else { - $var{"backtosite.url"} = $session{asset}->getContainer->getUrl; + $var{"backtosite.url"} = $self->session->asset->getContainer->getUrl; } } else { - $var{"backtosite.url"} = WebGUI::URL::page(); + $var{"backtosite.url"} = $self->session->url->page(); } $var{"application_loop"} = $self->getAdminFunction; - return WebGUI::Style::process(WebGUI::Asset::Template->new($session{setting}{AdminConsoleTemplate})->process(\%var),"PBtmpl0000000000000137"); + return $self->session->style->:process(WebGUI::Asset::Template->new($self->session,$self->session->setting->get("AdminConsoleTemplate"))->process(\%var),"PBtmpl0000000000000137"); } #------------------------------------------------------------------- @@ -442,7 +446,14 @@ sub setHelp { my $id = shift; my $namespace = shift || "WebGUI"; $id =~ s/ /%20/g; - $self->{_helpUrl} = WebGUI::URL::page('op=viewHelp;hid='.$id.';namespace='.$namespace) if ($id); + $self->{_helpUrl} = $self->session->url->page('op=viewHelp;hid='.$id.';namespace='.$namespace) if ($id); +} + +#------------------------------------------------------------------- + +sub session { + my $self = shift; + return $self->{_session}; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Affiliate.pm b/lib/WebGUI/Affiliate.pm index 2ac7e92de..047ace05d 100644 --- a/lib/WebGUI/Affiliate.pm +++ b/lib/WebGUI/Affiliate.pm @@ -14,10 +14,6 @@ package WebGUI::Affiliate; =cut -use WebGUI::Session; -use WebGUI::SQL; -use WebGUI::User; - =head1 NAME Package WebGUI::Affiliate @@ -42,24 +38,26 @@ These functions are available from this package: #------------------------------------------------------------------- -=head2 grabReferral ( ) +=head2 grabReferral ( session ) -Grabs referral information out of the session and adds it to the user's -account if possible. +Grabs referral information out of the session and adds it to the user's account if possible. + +=head2 session + +A reference to the current session. =cut sub grabReferral { - if ($session{user}{userId} ne "1" && $session{user}{referringAffiliate}) { + my $session = shift; + if ($session->user->userId ne "1" && $session->user->referringAffiliate) { return ""; - } elsif ($session{user}{userId} ne "1" && (($session{user}{referringAffiliate} eq "0" && $session{scratch}{referringAffiliate}) || $session{form}{affiliateId})) { - my $u = WebGUI::User->new($session{user}{userId}); - $u->referringAffiliate($session{scratch}{referringAffiliate}); - } elsif ($session{user}{userId} != 1) { - my $u = WebGUI::User->new($session{user}{userId}); - $u->referringAffiliate(1); - } elsif ($session{form}{affiliateId} ne "") { - WebGUI::Session::setScratch("referringAffiliate",$session{form}{affiliateId}); + } elsif ($session->user->userId ne "1" && (($session->user->referringAffiliate eq "0" && $session->scratch->get("referringAffiliate")) || $session->form->get("affiliateId"))) { + $session->user->referringAffiliate($session->scratch->get("referringAffiliate")); + } elsif ($session->user->userId ne "1") { + $session->user->referringAffiliate(1); + } elsif ($session->form->get("affiliateId") ne "") { + $session->scratch->set("referringAffiliate",$session->form->get("affiliateId")); } } diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index cf05afb07..130f47f5f 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -77,9 +77,9 @@ Only developers extending this method should use this parameter. By default WebG sub canAdd { my $className = shift; - my $userId = shift || $session{user}{userId}; + my $userId = shift || $self->session->user->profileField("userId"); my $subclassGroupId = shift; - my $groupId = $session{config}{assetAddPrivilege}{$className} || $subclassGroupId || '12'; + my $groupId = $self->session->config->get("assetAddPrivilege"){$className} || $subclassGroupId || '12'; return WebGUI::Grouping::isInGroup($groupId,$userId); } @@ -98,7 +98,7 @@ Unique hash identifier for a user. If not supplied, current user. sub canEdit { my $self = shift; - my $userId = shift || $session{user}{userId}; + my $userId = shift || $self->session->user->profileField("userId"); if ($userId eq $self->get("ownerUserId")) { return 1; } @@ -123,7 +123,7 @@ Unique hash identifier for a user. If not specified, uses current userId. sub canView { my $self = shift; - my $userId = shift || $session{user}{userId}; + my $userId = shift || $self->session->user->profileField("userId"); return 0 unless ($self->get("state") eq "published"); if ($userId eq $self->get("ownerUserId")) { return 1; @@ -267,8 +267,8 @@ Any text string. Most likely will have been the Asset's name or title. sub fixUrl { my $self = shift; - my $url = WebGUI::URL::urlize(shift); - my @badUrls = ($session{config}{extrasURL}, $session{config}{uploadsURL}); + my $url = $self->session->url->urlize(shift); + my @badUrls = ($self->session->config->get("extrasURL"), $self->session->config->get("uploadsURL")); foreach my $badUrl (@badUrls) { if ($badUrl =~ /^http/) { $badUrl =~ s/^http.*\/(.*)$/$1/; @@ -282,13 +282,13 @@ sub fixUrl { if (length($url) > 250) { $url = substr($url,220); } - if ($session{setting}{urlExtension} ne "" #don't add an extension if one isn't set + if ($self->session->setting->get("urlExtension") ne "" #don't add an extension if one isn't set && !($url =~ /\./) #don't add an extension of the url already contains a dot && $self->get("url") eq $self->getId # only add it if we're creating a new url ) { - $url .= ".".$session{setting}{urlExtension}; + $url .= ".".$self->session->setting->get("urlExtension"); } - my ($test) = WebGUI::SQL->quickArray("select url from assetData where assetId<>".quote($self->getId)." and url=".quote($url)); + my ($test) = $self->session->db->quickArray("select url from assetData where assetId<>".$self->session->db->quote($self->getId)." and url=".$self->session->db->quote($url)); if ($test) { my @parts = split(/\./,$url); if ($parts[0] =~ /(.*)(\d+$)/) { @@ -337,7 +337,7 @@ Returns a reference to a WebGUI::AdminConsole object. sub getAdminConsole { my $self = shift; unless (exists $self->{_adminConsole}) { - $self->{_adminConsole} = WebGUI::AdminConsole->new("assets"); + $self->{_adminConsole} = WebGUI::AdminConsole->new($self->session,"assets"); } $self->{_adminConsole}->setIcon($self->getIcon); return $self->{_adminConsole}; @@ -369,26 +369,26 @@ sub getAssetAdderLinks { my $load = "use ".$class; eval ($load); if ($@) { - WebGUI::ErrorHandler::error("Couldn't compile ".$class." because ".$@); + $self->session->errorHandler->error("Couldn't compile ".$class." because ".$@); } else { my $uiLevel = eval{$class->getUiLevel()}; if ($@) { - WebGUI::ErrorHandler::error("Couldn't get UI level of ".$class." because ".$@); + $self->session->errorHandler->error("Couldn't get UI level of ".$class." because ".$@); } else { - next if ($uiLevel > $session{user}{uiLevel} && !WebGUI::Grouping::isInGroup(3)); + next if ($uiLevel > $self->session->user->profileField("uiLevel") && !WebGUI::Grouping::isInGroup(3)); } my $canAdd = eval{$class->canAdd()}; if ($@) { - WebGUI::ErrorHandler::error("Couldn't determine if user can add ".$class." because ".$@); + $self->session->errorHandler->error("Couldn't determine if user can add ".$class." because ".$@); } else { next unless ($canAdd); } my $label = eval{$class->getName()}; if ($@) { - WebGUI::ErrorHandler::error("Couldn't get the name of ".$class." because ".$@); + $self->session->errorHandler->error("Couldn't get the name of ".$class." because ".$@); } else { my $url = $self->getUrl("func=add;class=".$class); - $url = WebGUI::URL::append($url,$addToUrl) if ($addToUrl); + $url = $self->session->url->append($url,$addToUrl) if ($addToUrl); $links{$label}{url} = $url; $links{$label}{icon} = $class->getIcon; $links{$label}{'icon.small'} = $class->getIcon(1); @@ -397,18 +397,18 @@ sub getAssetAdderLinks { } my $constraint; if ($type eq "assetContainers") { - $constraint = quoteAndJoin($session{config}{assetContainers}); + $constraint = $self->session->db->quoteAndJoin($self->session->config->get("assetContainers")); } elsif ($type eq "utilityAssets") { - $constraint = quoteAndJoin($session{config}{utilityAssets}); + $constraint = $self->session->db->quoteAndJoin($self->session->config->get("utilityAssets")); } else { - $constraint = quoteAndJoin($session{config}{assets}); + $constraint = $self->session->db->quoteAndJoin($self->session->config->get("assets")); } - my $sth = WebGUI::SQL->read("select asset.className,asset.assetId,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.isPrototype=1 and asset.state='published' and asset.className in ($constraint) and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) group by assetData.assetId"); + my $sth = $self->session->db->read("select asset.className,asset.assetId,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.isPrototype=1 and asset.state='published' and asset.className in ($constraint) and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) group by assetData.assetId"); while (my ($class,$id,$date) = $sth->array) { my $asset = WebGUI::Asset->new($self->session,$id,$class,$date); - next unless ($asset->canView && $asset->canAdd && $asset->getUiLevel <= $session{user}{uiLevel}); + next unless ($asset->canView && $asset->canAdd && $asset->getUiLevel <= $self->session->user->profileField("uiLevel")); my $url = $self->getUrl("func=add;class=".$class.";prototype=".$id); - $url = WebGUI::URL::append($url,$addToUrl) if ($addToUrl); + $url = $self->session->url->append($url,$addToUrl) if ($addToUrl); $links{$asset->getTitle}{url} = $url; $links{$asset->getTitle}{icon} = $asset->getIcon; $links{$asset->getTitle}{'icon.small'} = $asset->getIcon(1); @@ -441,10 +441,10 @@ Returns a reference to the container asset. If this asset is a container it retu sub getContainer { my $self = shift; - if (WebGUI::Utility::isIn($self->get("className"), @{$session{config}{assetContainers}})) { + if (WebGUI::Utility::isIn($self->get("className"), @{$self->session->config->get("assetContainers")})) { return $self; } else { - $session{asset} = $self->getParent; + $self->session->asset = $self->getParent; return $self->getParent; } } @@ -492,13 +492,13 @@ sub getEditForm { }); $tabform->hidden({ name=>"class", - value=>$session{form}{class} + value=>$self->session->form->process("class") }); } - 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")); @@ -573,12 +573,12 @@ sub getEditForm { 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, @@ -632,7 +632,7 @@ sub getEditForm { -value=>$self->getValue("isPrototype"), -uiLevel=>9 ); - if ($session{setting}{metaDataEnabled}) { + if ($self->session->setting->get("metaDataEnabled")) { my $meta = $self->getMetaDataFields(); foreach my $field (keys %$meta) { my $fieldType = $meta->{$field}{fieldType} || "text"; @@ -656,7 +656,7 @@ sub getEditForm { if (WebGUI::Grouping::isInGroup(3)) { # Add a quick link to add field $tabform->getTab("meta")->readOnly( - -value=>'

'. + -value=>'

'. WebGUI::International::get('Add new field','Asset'). '

', -hoverHelp=>WebGUI::International::get('Add new field description',"Asset"), @@ -671,7 +671,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 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 in Shortcut.pm. =cut @@ -698,8 +698,8 @@ sub getIcon { my $small = shift; my $definition = $self->definition; my $icon = $definition->[0]{icon} || "assets.gif"; - return $session{config}{extrasURL}.'/assets/small/'.$icon if ($small); - return $session{config}{extrasURL}.'/assets/'.$icon; + return $self->session->config->get("extrasURL").'/assets/small/'.$icon if ($small); + return $self->session->config->get("extrasURL").'/assets/'.$icon; } #------------------------------------------------------------------- @@ -866,7 +866,7 @@ sub getToolbar { my $toolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43,"Asset")); my $commit; my $i18n = WebGUI::International->new("Asset"); - if (($self->canEditIfLocked && $session{scratch}{versionTag} eq $self->get("tagId")) || !$self->isLocked) { + if (($self->canEditIfLocked && $self->session->scratch->get("versionTag") eq $self->get("tagId")) || !$self->isLocked) { $toolbar .= editIcon('func=edit',$self->get("url")); } else { $toolbar .= lockedIcon('func=manageRevisions',$self->get("url")); @@ -875,9 +875,9 @@ sub getToolbar { $toolbar .= cutIcon('func=cut',$self->get("url")) .copyIcon('func=copy',$self->get("url")); $toolbar .= shortcutIcon('func=createShortcut',$self->get("url")) unless ($self->get("className") =~ /Shortcut/); - $toolbar .= exportIcon('func=export',$self->get("url")) if defined ($session{config}{exportPath}); - WebGUI::Style::setLink($session{config}{extrasURL}.'/contextMenu/contextMenu.css', {rel=>"stylesheet",type=>"text/css"}); - WebGUI::Style::setScript($session{config}{extrasURL}.'/contextMenu/contextMenu.js', {type=>"text/javascript"}); + $toolbar .= exportIcon('func=export',$self->get("url")) if defined ($self->session->config->get("exportPath")); + $self->session->style->setLink($self->session->config->get("extrasURL").'/contextMenu/contextMenu.css', {rel=>"stylesheet",type=>"text/css"}); + $self->session->style->setScript($self->session->config->get("extrasURL").'/contextMenu/contextMenu.js', {type=>"text/javascript"}); return ''; } diff --git a/lib/WebGUI/Form/DatabaseLink.pm b/lib/WebGUI/Form/DatabaseLink.pm index 5d1d03ea0..55d6b16ca 100644 --- a/lib/WebGUI/Form/DatabaseLink.pm +++ b/lib/WebGUI/Form/DatabaseLink.pm @@ -20,8 +20,6 @@ use WebGUI::DatabaseLink; use WebGUI::Grouping; use WebGUI::Icon; use WebGUI::International; -use WebGUI::Session; -use WebGUI::URL; =head1 NAME @@ -109,7 +107,7 @@ Renders a database connection picker control. sub toHtml { my $self = shift; - $self->get("options") = WebGUI::DatabaseLink::getList(); + $self->get("options") = WebGUI::DatabaseLink->getList($self->session); return $self->SUPER::toHtml(); } diff --git a/lib/WebGUI/Form/Date.pm b/lib/WebGUI/Form/Date.pm index caff51410..4e43b4970 100644 --- a/lib/WebGUI/Form/Date.pm +++ b/lib/WebGUI/Form/Date.pm @@ -145,10 +145,10 @@ sub toHtml { unless ($language) { $language = WebGUI::International::getLanguage("English","languageAbbreviation"); } - WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/calendar.js',{ type=>'text/javascript' }); - WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/lang/calendar-'.$language.'.js',{ type=>'text/javascript' }); - WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/calendar-setup.js',{ type=>'text/javascript' }); - WebGUI::Style::setLink($self->session->config->get("extrasURL").'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" }); + $self->session->style->setScript($self->session->config->get("extrasURL").'/calendar/calendar.js',{ type=>'text/javascript' }); + $self->session->style->setScript($self->session->config->get("extrasURL").'/calendar/lang/calendar-'.$language.'.js',{ type=>'text/javascript' }); + $self->session->style->setScript($self->session->config->get("extrasURL").'/calendar/calendar-setup.js',{ type=>'text/javascript' }); + $self->session->style->setLink($self->session->config->get("extrasURL").'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" }); return $self->SUPER::toHtml. ''; + return $_[0]->{_header}.$_[0]->{_data}.$_[0]->{_footer}.''; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Help/Asset.pm b/lib/WebGUI/Help/Asset.pm index 8faacb9d0..f71dc2c7d 100644 --- a/lib/WebGUI/Help/Asset.pm +++ b/lib/WebGUI/Help/Asset.pm @@ -239,9 +239,9 @@ our $HELP = { namespace => $namespace } } grep { $_ } ##Filter out empty entries - @{ $session{config}{assets} }, - @{ $session{config}{assetContainers} }, - @{ $session{config}{utilityAssets} }, + @{ $self->session->config->get("assets") }, + @{ $self->session->config->get("assetContainers") }, + @{ $self->session->config->get("utilityAssets") }, ], }, diff --git a/lib/WebGUI/Help/Macros.pm b/lib/WebGUI/Help/Macros.pm index 17853a3d0..fffffc57c 100644 --- a/lib/WebGUI/Help/Macros.pm +++ b/lib/WebGUI/Help/Macros.pm @@ -34,7 +34,7 @@ our $HELP = { { tag => $tag, namespace => $namespace } } - values %{ $session{config}{macros} } + values %{ $self->session->config->get("macros") } ], }, diff --git a/lib/WebGUI/Icon.pm b/lib/WebGUI/Icon.pm index 4232d32d6..c59d540c0 100644 --- a/lib/WebGUI/Icon.pm +++ b/lib/WebGUI/Icon.pm @@ -72,11 +72,11 @@ Returns the base URL for this user's toolbar. =cut sub _getBaseURL { - my $url = $session{config}{extrasURL}.'/toolbar/'; - if ($session{user}{toolbar} ne "useLanguageDefault") { - $url .= $session{user}{toolbar}; + my $url = $self->session->config->get("extrasURL").'/toolbar/'; + if ($self->session->user->profileField("toolbar") ne "useLanguageDefault") { + $url .= $self->session->user->profileField("toolbar"); } else { - $url .= WebGUI::International::getLanguage($session{user}{language},"toolbar"); + $url .= WebGUI::International::getLanguage($self->session->user->profileField("language"),"toolbar"); } $url .= '/'; return $url; @@ -102,7 +102,7 @@ The URL to any page. Defaults to the current page. sub copyIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Copy','Icon').''; return $output; } @@ -126,7 +126,7 @@ The URL to any page. Defaults to the current page. sub cutIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Cut','Icon').''; return $output; } @@ -160,7 +160,7 @@ sub deleteIcon { $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Delete','Icon').''; return $output; } @@ -196,7 +196,7 @@ The URL to any page. Defaults to the current page. sub editIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Edit','Icon').''; return $output; } @@ -220,7 +220,7 @@ The URL to any page. Defaults to the current page. sub exportIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; # TODO Change icon to Jeffs export icon $output .= ''.WebGUI::International::get('Export','Icon').''; return $output; @@ -238,8 +238,8 @@ sub getToolbarOptions { my %options; tie %options, 'Tie::IxHash'; $options{useLanguageDefault} = WebGUI::International::get(1084); - my $dir = $session{config}{extrasPath}."/toolbar"; - opendir (DIR,$dir) or WebGUI::ErrorHandler::warn("Can't open toolbar directory!"); + my $dir = $self->session->config->get("extrasPath")."/toolbar"; + opendir (DIR,$dir) or $self->session->errorHandler->warn("Can't open toolbar directory!"); my @files = readdir(DIR); foreach my $file (@files) { if (substr($file,0,1) ne ".") { @@ -269,7 +269,7 @@ If your help documentation is not in the WebGUI namespace, then you must specify sub helpIcon { my ($output, $namespace); $namespace = $_[1] || "WebGUI"; - $output = 'session->url->page('op=viewHelp;hid='.$_[0].';namespace='.$namespace). '" target="_blank">'.WebGUI::International::get('Help','Icon').''; return $output; } @@ -293,7 +293,7 @@ The URL to any page. Defaults to the current page. sub lockedIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('locked','Icon').''; return $output; } @@ -317,7 +317,7 @@ The URL to any page. Defaults to the current page. sub manageIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Manage','Icon').''; return $output; } @@ -341,7 +341,7 @@ The URL to any page. Defaults to the current page. sub moveBottomIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Move To Bottom','Icon').''; return $output; } @@ -365,7 +365,7 @@ The URL to any page. Defaults to the current page. sub moveDownIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Move Down','Icon').''; return $output; } @@ -389,7 +389,7 @@ The URL to any page. Defaults to the current page. sub moveLeftIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Move Left','Icon').''; return $output; } @@ -413,7 +413,7 @@ The URL to any page. Defaults to the current page. sub moveRightIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Move Right','Icon').''; return $output; } @@ -437,7 +437,7 @@ The URL to any page. Defaults to the current page. sub moveTopIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Move To Top','Icon').''; return $output; } @@ -461,7 +461,7 @@ The URL to any page. Defaults to the current page. sub moveUpIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Move Up','Icon').''; return $output; } @@ -497,7 +497,7 @@ The URL to any page. Defaults to the current page. sub pasteIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Paste','Icon').''; return $output; } @@ -521,7 +521,7 @@ The URL to any page. Defaults to the current page. sub shortcutIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('Create Shortcut','Icon').''; return $output; } @@ -545,7 +545,7 @@ The URL to any page. Defaults to the current page. sub viewIcon { my ($output, $pageURL); $pageURL = $_[1] || $session{requestedUrl}; - $output = ''; + $output = ''; $output .= ''.WebGUI::International::get('View','Icon').''; return $output; } diff --git a/lib/WebGUI/International.pm b/lib/WebGUI/International.pm index 07f808d55..2a74b35a0 100644 --- a/lib/WebGUI/International.pm +++ b/lib/WebGUI/International.pm @@ -74,11 +74,11 @@ sub get { if (ref($_[0]) eq "WebGUI::International") { $id = $_[1]; $namespace = $_[2] || $_[0]->{_namespace} || "WebGUI"; - $language = $_[3] || $_[0]->{_language} || $session{user}{language} || "English"; + $language = $_[3] || $_[0]->{_language} || $self->session->user->profileField("language") || "English"; } else { $id = $_[0]; $namespace = $_[1] || "WebGUI"; - $language = $_[2] || $session{user}{language} || "English"; + $language = $_[2] || $self->session->user->profileField("language") || "English"; } $id =~ s/[^\w\d\s\/]//g; $language =~ s/[^\w\d\s\/]//g; @@ -86,10 +86,10 @@ sub get { my $cmd = "WebGUI::i18n::".$language."::".$namespace; my $load = "use ".$cmd; eval($load); - WebGUI::ErrorHandler::warn($cmd." failed to compile because ".$@) if ($@); + $self->session->errorHandler->warn($cmd." failed to compile because ".$@) if ($@); $cmd = "\$".$cmd."::I18N->{'".$id."'}{message}"; my $output = eval($cmd); - WebGUI::ErrorHandler::warn("Couldn't get value from ".$cmd." because ".$@) if ($@); + $self->session->errorHandler->warn("Couldn't get value from ".$cmd." because ".$@) if ($@); $output = get($id,$namespace,"English") if ($output eq "" && $language ne "English"); return $output; } @@ -120,14 +120,14 @@ sub getLanguage { unless ($@) { $cmd = "\$".$cmd."::LANGUAGE"; my $hashRef = eval($cmd); - WebGUI::ErrorHandler::warn("Failed to retrieve language properties because ".$@) if ($@); + $self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@); if ($property) { return $hashRef->{$property}; } else { return $hashRef; } } else { - WebGUI::ErrorHandler::warn("Language failed to compile: $language. ".$@); + $self->session->errorHandler->warn("Language failed to compile: $language. ".$@); } } @@ -142,8 +142,8 @@ Returns a hash reference to the languages (languageId/lanugage) installed on thi sub getLanguages { my ($hashRef); - my $dir = $session{config}{webguiRoot}."/lib/WebGUI/i18n"; - opendir (DIR,$dir) or WebGUI::ErrorHandler::fatal("Can't open I18N directory! ".$dir); + my $dir = $self->session->config->getWebguiRoot."/lib/WebGUI/i18n"; + opendir (DIR,$dir) or $self->session->errorHandler->fatal("Can't open I18N directory! ".$dir); my @files = readdir(DIR); closedir(DIR); foreach my $file (@files) { @@ -176,18 +176,18 @@ sub makeUrlCompliant { my ($language, $url); if (ref($_[0]) eq "WebGUI::International") { $url = $_[1]; - $language = $_[2] || $_[0]->{_language} || $session{user}{language} || "English"; + $language = $_[2] || $_[0]->{_language} || $self->session->user->profileField("language") || "English"; } else { $url = $_[0]; - $language = $_[1] || $session{user}{language} || "English"; + $language = $_[1] || $self->session->user->profileField("language") || "English"; } my $cmd = "WebGUI::i18n::".$language; my $load = "use ".$cmd; eval($load); - WebGUI::ErrorHandler::warn($cmd." failed to compile because ".$@) if ($@); + $self->session->errorHandler->warn($cmd." failed to compile because ".$@) if ($@); $cmd = $cmd."::makeUrlCompliant"; my $output = eval{&$cmd($url)}; - WebGUI::ErrorHandler::fatal("Couldn't execute ".$cmd." because ".$@.". Maybe your languagepack misses the makeUrlCompliant method?") if ($@); + $self->session->errorHandler->fatal("Couldn't execute ".$cmd." because ".$@.". Maybe your languagepack misses the makeUrlCompliant method?") if ($@); return $output; } diff --git a/lib/WebGUI/LDAPLink.pm b/lib/WebGUI/LDAPLink.pm index 45ae850d9..919ab78bf 100644 --- a/lib/WebGUI/LDAPLink.pm +++ b/lib/WebGUI/LDAPLink.pm @@ -137,7 +137,7 @@ Returns a hash reference containing all ldap links. The format is: sub getList { my %list; tie %list, "Tie::IxHash"; - %list = WebGUI::SQL->buildHash("select ldapLinkId, ldapLinkName from ldapLink order by ldapLinkName"); + %list = $self->session->db->buildHash("select ldapLinkId, ldapLinkName from ldapLink order by ldapLinkName"); return \%list; } @@ -156,7 +156,7 @@ A valid ldapLinkId sub get { my %hash; tie %hash, 'Tie::CPHash'; - %hash = WebGUI::SQL->quickHash("select * from ldapLink where ldapLinkId=".quote($_[0])); + %hash = $self->session->db->quickHash("select * from ldapLink where ldapLinkId=".$self->session->db->quote($_[0])); return \%hash; } diff --git a/lib/WebGUI/Macro.pm b/lib/WebGUI/Macro.pm index dc9e67e54..a03372767 100644 --- a/lib/WebGUI/Macro.pm +++ b/lib/WebGUI/Macro.pm @@ -34,7 +34,7 @@ B This entire system is likely to be replaced in the near future. It has WebGUI::Macro::filter(\$html); WebGUI::Macro::negate(\$html); - WebGUI::Macro::process(\$html); + WebGUI::Macro::process($self->session,\$html); =head1 METHODS diff --git a/lib/WebGUI/Mail.pm b/lib/WebGUI/Mail.pm index a29d2490d..8cd163934 100644 --- a/lib/WebGUI/Mail.pm +++ b/lib/WebGUI/Mail.pm @@ -80,17 +80,17 @@ sub send { if(${$option}) { if (${$option} =~ /(?:From|To|Date|X-Mailer|Subject|Received|Message-Id)\s*:/is) { use WebGUI::ErrorHandler; - return WebGUI::ErrorHandler::security("pass a malicious value to the mail header."); + return $self->session->errorHandler->security("pass a malicious value to the mail header."); } } } - $from = $_[4] || $session{setting}{companyEmail}; + $from = $_[4] || $self->session->setting->get("companyEmail"); #header - my $to = $session{config}{emailOverride} || $_[0]; + my $to = $self->session->config->get("emailOverride") || $_[0]; $message = "To: $to\n"; $message .= "From: $from\n"; - $message .= "CC: $_[3]\n" if ($_[3] && !$session{config}{emailOverride}); - $message .= "BCC: $_[5]\n" if ($_[5] && !$session{config}{emailOverride}); + $message .= "CC: $_[3]\n" if ($_[3] && !$self->session->config->get("emailOverride")); + $message .= "BCC: $_[5]\n" if ($_[5] && !$self->session->config->get("emailOverride")); $message .= "Subject: ".$_[1]."\n"; $message .= "Date: ".WebGUI::DateTime::epochToHuman("","%W, %d %C %y %j:%n:%s %O")."\n"; if (($_[2] =~ m//i) || ($_[2] =~ m/session,\$message); #body $message .= $_[2]."\n"; #footer - my $footer = "\n".$session{setting}{mailFooter}; - WebGUI::Macro::process(\$footer); + my $footer = "\n".$self->session->setting->get("mailFooter"); + WebGUI::Macro::process($self->session,\$footer); $message .= $footer; - $message .= "\n\n\nThis message was intended for ".$_[0].", but was overridden in the config file.\n\n\n" if ($session{config}{emailOverride}); - if ($session{setting}{smtpServer} =~ /\/sendmail/) { - if (open(MAIL,"| $session{setting}{smtpServer} -t -oi")) { + $message .= "\n\n\nThis message was intended for ".$_[0].", but was overridden in the config file.\n\n\n" if ($self->session->config->get("emailOverride")); + if ($self->session->setting->get("smtpServer") =~ /\/sendmail/) { + if (open(MAIL,"| $self->session->setting->get("smtpServer") -t -oi")) { print MAIL $message; - close(MAIL) or WebGUI::ErrorHandler::warn("Couldn't close connection to mail server: ".$session{setting}{smtpServer}); + close(MAIL) or $self->session->errorHandler->warn("Couldn't close connection to mail server: ".$self->session->setting->get("smtpServer")); } else { - WebGUI::ErrorHandler::warn("Couldn't connect to mail server: ".$session{setting}{smtpServer}); + $self->session->errorHandler->warn("Couldn't connect to mail server: ".$self->session->setting->get("smtpServer")); } } else { - $smtp = Net::SMTP->new($session{setting}{smtpServer}); # connect to an SMTP server + $smtp = Net::SMTP->new($self->session->setting->get("smtpServer")); # connect to an SMTP server if (defined $smtp) { $smtp->mail($from); # use the sender's address here $smtp->to($to); # recipient's address - $smtp->cc($_[3]) if ($_[3] && !$session{config}{emailOverride}); - $smtp->bcc($_[5]) if ($_[5] && !$session{config}{emailOverride}); + $smtp->cc($_[3]) if ($_[3] && !$self->session->config->get("emailOverride")); + $smtp->bcc($_[5]) if ($_[5] && !$self->session->config->get("emailOverride")); $smtp->data(); # Start the mail $smtp->datasend($message); $smtp->dataend(); # Finish sending the mail $smtp->quit; # Close the SMTP connection } else { - WebGUI::ErrorHandler::warn("Couldn't connect to mail server: ".$session{setting}{smtpServer}); + $self->session->errorHandler->warn("Couldn't connect to mail server: ".$self->session->setting->get("smtpServer")); } } } diff --git a/lib/WebGUI/MessageLog.pm b/lib/WebGUI/MessageLog.pm index 8ab6fdbf7..f036bb47f 100644 --- a/lib/WebGUI/MessageLog.pm +++ b/lib/WebGUI/MessageLog.pm @@ -122,25 +122,25 @@ sub addEntry { $message = $_[3]; $url = $_[4]; if ($url && !$url =~ /^http/) { - $url = WebGUI::URL::getSiteURL().$url; + $url = $self->session->url->getSiteURL().$url; } if ($url && !($url =~ /func=/ || $url =~ /op=/)) { - $url = WebGUI::URL::append($url, "op=viewMessageLogMessage"); + $url = $self->session->url->append($url, "op=viewMessageLogMessage"); } $status = $_[5]; $from = $_[6]; if ($groupId ne "") { - @users = WebGUI::SQL->buildArray("select userId from groupings where groupId=".quote($groupId)); + @users = $self->session->db->buildArray("select userId from groupings where groupId=".$self->session->db->quote($groupId)); } @users = ($userId,@users) if ($userId ne "" && !isIn($userId, @users)); foreach $user (@users) { $u = WebGUI::User->new($user); if ($u->userId ne "") { - WebGUI::SQL->write("insert into messageLog (messageLogId, userId, message, url, dateOfEntry, - subject, status) values (".quote($messageLogId).",".quote($u->userId).", - ".quote($message).",".quote($url).",".time().",".quote($subject).", ".quote($status).")"); + $self->session->db->write("insert into messageLog (messageLogId, userId, message, url, dateOfEntry, + subject, status) values (".$self->session->db->quote($messageLogId).",".$self->session->db->quote($u->userId).", + ".$self->session->db->quote($message).",".$self->session->db->quote($url).",".time().",".$self->session->db->quote($subject).", ".$self->session->db->quote($status).")"); if ($url ne "") { - $message .= "\n".WebGUI::URL::append($url,'mlog='.$messageLogId); + $message .= "\n".$self->session->url->append($url,'mlog='.$messageLogId); } _notify($u,$subject,$message,$from); } @@ -190,10 +190,10 @@ sub addInternationalizedEntry { $groupId = $_[1]; $url = $_[2]; if ($url && !$url =~ /^http/) { - $url = WebGUI::URL::getSiteURL().$url; + $url = $self->session->url->getSiteURL().$url; } if ($url && !($url =~ /func=/ || $url =~ /op=/)) { - $url = WebGUI::URL::append($url, "op=viewMessageLogMessage"); + $url = $self->session->url->append($url, "op=viewMessageLogMessage"); } $internationalId = $_[3]; $namespace = $_[4] || "WebGUI"; @@ -204,7 +204,7 @@ sub addInternationalizedEntry { $subject{$language} = WebGUI::International::get(523,"WebGUI",$language); } if ($groupId ne "") { - @users = WebGUI::SQL->buildArray("select userId from groupings where groupId=".quote($groupId)); + @users = $self->session->db->buildArray("select userId from groupings where groupId=".$self->session->db->quote($groupId)); } @users = ($userId,@users) if ($userId ne "" && !isIn($userId, @users)); foreach $user (@users) { @@ -214,11 +214,11 @@ sub addInternationalizedEntry { $subject = $subject{$u->profileField("language")}; $message{$u->profileField("language")} = $message{1} if ($message{$u->profileField("language")} eq ""); $message = $message{$u->profileField("language")}; - WebGUI::Macro::process(\$message); - WebGUI::SQL->write("insert into messageLog values (".quote($messageLogId).",".quote($u->userId).", - ".quote($message).",".quote($url).",".time().",".quote($message).",".quote($status).")"); + WebGUI::Macro::process($self->session,\$message); + $self->session->db->write("insert into messageLog values (".$self->session->db->quote($messageLogId).",".$self->session->db->quote($u->userId).", + ".$self->session->db->quote($message).",".$self->session->db->quote($url).",".time().",".$self->session->db->quote($message).",".$self->session->db->quote($status).")"); if ($url ne "") { - $message .= "\n".WebGUI::URL::append($url,'mlog='.$messageLogId); + $message .= "\n".$self->session->url->append($url,'mlog='.$messageLogId); } _notify($u,$subject,$message); } @@ -238,7 +238,7 @@ The id of the message to complete. =cut sub completeEntry { - WebGUI::SQL->write("update messageLog set status='completed', dateOfEntry=".time()." where messageLogId=".quote($_[0])); + $self->session->db->write("update messageLog set status='completed', dateOfEntry=".time()." where messageLogId=".$self->session->db->quote($_[0])); } diff --git a/lib/WebGUI/Operation/ActiveSessions.pm b/lib/WebGUI/Operation/ActiveSessions.pm index 3d19871f1..fce161bc8 100644 --- a/lib/WebGUI/Operation/ActiveSessions.pm +++ b/lib/WebGUI/Operation/ActiveSessions.pm @@ -88,7 +88,7 @@ sub www_viewActiveSessions { $output .= $p->getPage($session->form->process("pn")); $output .= ''; $output .= $p->getBarTraditional($session->form->process("pn")); - return WebGUI::AdminConsole->new("activeSessions")->render($output); + return WebGUI::AdminConsole->new($session,"activeSessions")->render($output); } 1; diff --git a/lib/WebGUI/Operation/Cache.pm b/lib/WebGUI/Operation/Cache.pm index 6cf10811e..4cba0802c 100644 --- a/lib/WebGUI/Operation/Cache.pm +++ b/lib/WebGUI/Operation/Cache.pm @@ -51,7 +51,7 @@ sub _submenu { my $workarea = shift; my $title = shift; $title = WebGUI::International::get($title) if ($title); - my $ac = WebGUI::AdminConsole->new("cache"); + my $ac = WebGUI::AdminConsole->new($session,"cache"); if ($session->setting->get("trackPageStatistics")) { $ac->addSubmenuItem( $session->url->page('op=manageCache'), WebGUI::International::get('manage cache')); } @@ -77,7 +77,7 @@ Text description of how long the subscription lasts. sub www_flushCache { my $session = shift; return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); - my $cache = WebGUI::Cache->new(); + my $cache = WebGUI::Cache->new($session,); $cache->flush; return www_manageCache(); } @@ -95,7 +95,7 @@ sub www_manageCache { my $session = shift; return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); my ($output, $data); - my $cache = WebGUI::Cache->new(); + my $cache = WebGUI::Cache->new($session,); my $flushURL = $session->url->page('op=flushCache'); $output .= ''; $output .= ''; diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index e2d4c25d4..f9cf6c7bb 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -34,7 +34,7 @@ sub _submenu { my $title = shift; $title = $i18n->get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("commerce"); + my $ac = WebGUI::AdminConsole->new($session,"commerce"); if ($help) { $ac->setHelp($help, 'Commerce'); } diff --git a/lib/WebGUI/Operation/DatabaseLink.pm b/lib/WebGUI/Operation/DatabaseLink.pm index e7b494a93..a947e65d2 100644 --- a/lib/WebGUI/Operation/DatabaseLink.pm +++ b/lib/WebGUI/Operation/DatabaseLink.pm @@ -16,13 +16,8 @@ use WebGUI::AdminConsole; use WebGUI::DatabaseLink; use WebGUI::Grouping; use WebGUI::Icon; -use WebGUI::Id; use WebGUI::International; -use WebGUI::Paginator; use WebGUI::Privilege; -use WebGUI::Session; -use WebGUI::SQL; -use WebGUI::URL; #------------------------------------------------------------------- sub _submenu { @@ -31,7 +26,7 @@ sub _submenu { my $title = shift; $title = WebGUI::International::get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("databases"); + my $ac = WebGUI::AdminConsole->new($session,"databases"); if ($help) { $ac->setHelp($help); } @@ -49,11 +44,7 @@ sub _submenu { sub www_copyDatabaseLink { my $session = shift; return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3)); - my (%db); - tie %db, 'Tie::CPHash'; - %db = $session->db->quickHash("select * from databaseLink where databaseLinkId=".$session->db->quote($session->form->process("dlid"))); - $session->db->write("insert into databaseLink (databaseLinkId,title,DSN,username,identifier) values (".$session->db->quote(WebGUI::Id::generate()).", - ".$session->db->quote($db{title}." (copy)").", ".$session->db->quote($db{DSN}).", ".$session->db->quote($db{username}).", ".$session->db->quote($db{identifier}).")"); + WebGUI::DatabaseLink->new($session,$session->form->process("dlid"))->copy; return www_listDatabaseLinks(); } @@ -75,7 +66,7 @@ sub www_deleteDatabaseLink { sub www_deleteDatabaseLinkConfirm { my $session = shift; return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3)); - $session->db->write("delete from databaseLink where databaseLinkId=".$session->db->quote($session->form->process("dlid"))); + WebGUI::DatabaseLink->new($session,$session->form->process("dlid"))->delete; return www_listDatabaseLinks(); } @@ -88,7 +79,7 @@ sub www_editDatabaseLink { if ($session->form->process("dlid") eq "new") { } else { - %db = $session->db->quickHash("select * from databaseLink where databaseLinkId=".$session->db->quote($session->form->process("dlid"))); + %db = %{WebGUI::DatabaseLink->new($session,$session->form->process("dlid"))->get}; } $f = WebGUI::HTMLForm->new( -extras=>'autocomplete="off"' @@ -139,12 +130,17 @@ sub www_editDatabaseLink { sub www_editDatabaseLinkSave { my $session = shift; return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3)); + my $params = { + title=>$session->form->process("title"), + username=>$session->form->process("dbusername"), + identifier=>$session->form->process("dbidentifier") + DSN=>$session->form->process("DSN") + }); if ($session->form->process("dlid") eq "new") { - $session->form->process("dlid") = WebGUI::Id::generate(); - $session->db->write("insert into databaseLink (databaseLinkId) values (".$session->db->quote($session->form->process("dlid")).")"); + WebGUI::DatabaseLink->create($session,$params); + } else { + WebGUI::DatabaseLink->new($session,$session->form->process("dlid"))->set($params); } - $session->db->write("update databaseLink set title=".$session->db->quote($session->form->process("title")).", DSN=".$session->db->quote($session->form->process("DSN")).", - username=".$session->db->quote($session->form->process("dbusername")).", identifier=".$session->db->quote($session->form->process("dbidentifier"))." where databaseLinkId=".$session->db->quote($session->form->process("dlid"))); return www_listDatabaseLinks(); } @@ -152,26 +148,18 @@ sub www_editDatabaseLinkSave { sub www_listDatabaseLinks { my $session = shift; return WebGUI::Privilege::adminOnly() unless(WebGUI::Grouping::isInGroup(3)); - my ($output, $p, $sth, %data, @row, $i); - $sth = $session->db->read("select * from databaseLink order by title"); - $row[$i] = ''; - $i++; - while (%data = $sth->hash) { - $row[$i] = '
'.WebGUI::International::get('cache type').':'.ref($cache).'
'.WebGUI::International::get(1076).'
' - .deleteIcon('op=deleteDatabaseLink;dlid='.$data{databaseLinkId}) - .editIcon('op=editDatabaseLink;dlid='.$data{databaseLinkId}) - .copyIcon('op=copyDatabaseLink;dlid='.$data{databaseLinkId}) + my $links = WebGUI::DatabaseLinks->getList($session); + my $output = ''; + foreach my $id (keys %{$links}) { + $output .= ''; + $output = ''; - $row[$i] .= ''; - $i++; + $output .= ''; } - $sth->finish; - $p = WebGUI::Paginator->new($session->url->page('op=listDatabaseLinks')); - $p->setDataByArrayRef(\@row); - $output .= '
'.WebGUI::International::get(1076).'
' + .deleteIcon('op=deleteDatabaseLink;dlid='.$id) + .editIcon('op=editDatabaseLink;dlid='.$id) + .copyIcon('op=copyDatabaseLink;dlid='.$id) .''.$data{title}.'
'.$links->{$id}.'
'; - $output .= $p->getPage; $output .= '
'; - $output .= $p->getBarTraditional; return _submenu($output,"database links manage"); } diff --git a/lib/WebGUI/Operation/Group.pm b/lib/WebGUI/Operation/Group.pm index 6252cc78e..66e29d066 100644 --- a/lib/WebGUI/Operation/Group.pm +++ b/lib/WebGUI/Operation/Group.pm @@ -13,7 +13,6 @@ package WebGUI::Operation::Group; use strict; use Tie::CPHash; use WebGUI::AdminConsole; -use WebGUI::DatabaseLink; use WebGUI::DateTime; use WebGUI::Group; use WebGUI::Grouping; @@ -46,7 +45,7 @@ sub _submenu { my $title = shift; $title = WebGUI::International::get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("groups"); + my $ac = WebGUI::AdminConsole->new($session,"groups"); if ($help) { $ac->setHelp($help); } @@ -181,7 +180,7 @@ sub www_addUsersToGroupSave { #------------------------------------------------------------------- sub www_autoAddToGroup { my $session = shift; - return WebGUI::AdminConsole->new("groups")->render(WebGUI::Privilege::insufficient()) unless ($session->user->profileField("userId") ne 1); + return WebGUI::AdminConsole->new($session,"groups")->render(WebGUI::Privilege::insufficient()) unless ($session->user->profileField("userId") ne 1); my $group = WebGUI::Group->new($session->form->process("groupId")); if ($group->autoAdd) { WebGUI::Grouping::addUsersToGroups([$session->user->profileField("userId")],[$session->form->process("groupId")]); @@ -192,7 +191,7 @@ sub www_autoAddToGroup { #------------------------------------------------------------------- sub www_autoDeleteFromGroup { my $session = shift; - return WebGUI::AdminConsole->new("groups")->render(WebGUI::Privilege::insufficient()) unless ($session->user->profileField("userId") ne 1); + return WebGUI::AdminConsole->new($session,"groups")->render(WebGUI::Privilege::insufficient()) unless ($session->user->profileField("userId") ne 1); my $group = WebGUI::Group->new($session->form->process("groupId")); if ($group->autoDelete) { WebGUI::Grouping::deleteUsersFromGroups([$session->user->profileField("userId")],[$session->form->process("groupId")]); diff --git a/lib/WebGUI/Operation/Help.pm b/lib/WebGUI/Operation/Help.pm index 33c932514..8a8a4f9f9 100644 --- a/lib/WebGUI/Operation/Help.pm +++ b/lib/WebGUI/Operation/Help.pm @@ -100,7 +100,7 @@ sub _getHelpName { sub www_viewHelp { my $session = shift; return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(7)); - my $ac = WebGUI::AdminConsole->new("help"); + my $ac = WebGUI::AdminConsole->new($session,"help"); my $namespace = $session->form->process("namespace") || "WebGUI"; my $i18n = WebGUI::International->new($namespace); my $help = _get($session->form->process("hid"),$namespace); @@ -118,7 +118,7 @@ sub www_viewHelp { my $body = WebGUI::Asset::Template->new("PBtmplHelp000000000001")->process(\%vars); $ac->addSubmenuItem($session->url->page('op=viewHelpIndex'),WebGUI::International::get(95)); $ac->addSubmenuItem($session->url->page('op=viewHelpTOC'),WebGUI::International::get('help contents')); - WebGUI::Macro::process(\$body); + WebGUI::Macro::process($session,\$body); return $ac->render( $body, WebGUI::International::get(93).': '.$i18n->get($help->{title}) @@ -154,7 +154,7 @@ sub www_viewHelpIndex { } } $output .= '
'; - my $ac = WebGUI::AdminConsole->new("help"); + my $ac = WebGUI::AdminConsole->new($session,"help"); $ac->addSubmenuItem($session->url->page('op=viewHelpTOC'),WebGUI::International::get('help contents')); return $ac->render($output, join ': ',WebGUI::International::get(93), WebGUI::International::get('help index')); } @@ -184,7 +184,7 @@ sub www_viewHelpTOC { } } $output .= ''; - my $ac = WebGUI::AdminConsole->new("help"); + my $ac = WebGUI::AdminConsole->new($session,"help"); $ac->addSubmenuItem($session->url->page('op=viewHelpIndex'),WebGUI::International::get(95)); return $ac->render($output, join ': ',WebGUI::International::get(93), WebGUI::International::get('help toc')); } @@ -200,7 +200,7 @@ sub www_viewHelpChapter { foreach my $id (@entries) { $output .= '

'.WebGUI::International::get($help->{$id}{title},$namespace).'

'; } - my $ac = WebGUI::AdminConsole->new("help"); + my $ac = WebGUI::AdminConsole->new($session,"help"); $ac->addSubmenuItem($session->url->page('op=viewHelpIndex'),WebGUI::International::get(95)); $ac->addSubmenuItem($session->url->page('op=viewHelpTOC'),WebGUI::International::get('help contents')); return $ac->render($output, join ': ',WebGUI::International::get(93), _getHelpName($namespace)); diff --git a/lib/WebGUI/Operation/LDAPLink.pm b/lib/WebGUI/Operation/LDAPLink.pm index 6a8a8d55a..db22a3cf9 100644 --- a/lib/WebGUI/Operation/LDAPLink.pm +++ b/lib/WebGUI/Operation/LDAPLink.pm @@ -31,7 +31,7 @@ sub _submenu { my $title = shift; $title = WebGUI::International::get($title,"AuthLDAP") if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("ldapconnections"); + my $ac = WebGUI::AdminConsole->new($session,"ldapconnections"); if ($help) { $ac->setHelp($help,"AuthLDAP"); } diff --git a/lib/WebGUI/Operation/LoginHistory.pm b/lib/WebGUI/Operation/LoginHistory.pm index b6b44f5f0..ac518be7d 100644 --- a/lib/WebGUI/Operation/LoginHistory.pm +++ b/lib/WebGUI/Operation/LoginHistory.pm @@ -64,7 +64,7 @@ sub www_viewLoginHistory { $output .= $p->getPage($session->form->process("pn")); $output .= ''; $output .= $p->getBar($session->form->process("pn")); - return WebGUI::AdminConsole->new("loginHistory")->render($output); + return WebGUI::AdminConsole->new($session,"loginHistory")->render($output); } 1; diff --git a/lib/WebGUI/Operation/ProductManager.pm b/lib/WebGUI/Operation/ProductManager.pm index 323eaf171..1c227438f 100755 --- a/lib/WebGUI/Operation/ProductManager.pm +++ b/lib/WebGUI/Operation/ProductManager.pm @@ -25,7 +25,7 @@ sub _submenu { my $title = shift; $title = $i18n->get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("productManager"); + my $ac = WebGUI::AdminConsole->new($session,"productManager"); if ($help) { $ac->setHelp($help, 'ProductManager'); } diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index a14da9485..a0ebd606e 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -31,7 +31,7 @@ sub _submenu { my $help = shift; my $namespace = shift; $title = WebGUI::International::get($title,$namespace) if ($title); - my $ac = WebGUI::AdminConsole->new("userProfiling"); + my $ac = WebGUI::AdminConsole->new($session,"userProfiling"); if ($help) { $ac->setHelp($help,"WebGUIProfile"); } @@ -54,7 +54,7 @@ sub www_deleteProfileCategoryConfirm { my $session = shift; return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); my $category = WebGUI::ProfileCategory->new($session->form->process("cid")); - return WebGUI::AdminConsole->new("userProfiling")->render(WebGUI::Privilege::vitalComponent()) if ($category->isProtected); + return WebGUI::AdminConsole->new($session,"userProfiling")->render(WebGUI::Privilege::vitalComponent()) if ($category->isProtected); $category->delete; return www_editProfileSettings(); } @@ -64,7 +64,7 @@ sub www_deleteProfileFieldConfirm { my $session = shift; return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); my $field = WebGUI::ProfileField->new($session->form->process("fid")); - return WebGUI::AdminConsole->new("userProfiling")->render(WebGUI::Privilege::vitalComponent()) if ($field->isProtected); + return WebGUI::AdminConsole->new($session,"userProfiling")->render(WebGUI::Privilege::vitalComponent()) if ($field->isProtected); $field->delete; return www_editProfileSettings(); } diff --git a/lib/WebGUI/Operation/Replacements.pm b/lib/WebGUI/Operation/Replacements.pm index 4203e140d..7102b5ab7 100644 --- a/lib/WebGUI/Operation/Replacements.pm +++ b/lib/WebGUI/Operation/Replacements.pm @@ -27,7 +27,7 @@ sub _submenu { my $title = shift; $title = WebGUI::International::get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("contentFilters"); + my $ac = WebGUI::AdminConsole->new($session,"contentFilters"); if ($help) { $ac->setHelp($help); } diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index 0a81af400..a3e3113fc 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -289,7 +289,7 @@ sub www_editSettings { $tabform->getTab("auth")->raw(''.$authInstance->editUserSettingsForm.'
  
'); } $tabform->submit(); - my $ac = WebGUI::AdminConsole->new("settings"); + my $ac = WebGUI::AdminConsole->new($session,"settings"); $ac->setHelp("settings"); return $ac->render($tabform->print); } diff --git a/lib/WebGUI/Operation/Statistics.pm b/lib/WebGUI/Operation/Statistics.pm index 197b707f3..8e9500d6b 100644 --- a/lib/WebGUI/Operation/Statistics.pm +++ b/lib/WebGUI/Operation/Statistics.pm @@ -25,7 +25,7 @@ sub _submenu { my $workarea = shift; my $title = shift; $title = WebGUI::International::get($title) if ($title); - my $ac = WebGUI::AdminConsole->new("statistics"); + my $ac = WebGUI::AdminConsole->new($session,"statistics"); if ($session->setting->get("trackPageStatistics")) { $ac->addSubmenuItem( $session->url->page('op=viewStatistics'), WebGUI::International::get(144)); } @@ -39,7 +39,7 @@ sub www_viewStatistics { return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); my ($output, $data); my $url = "http://www.plainblack.com/downloads/latest-version.txt"; - my $cache = WebGUI::Cache->new($url,"URL"); + my $cache = WebGUI::Cache->new($session,$url,"URL"); my $version = $cache->get; if (not defined $version) { $version = $cache->setByHTTP($url,43200); diff --git a/lib/WebGUI/Operation/Subscription.pm b/lib/WebGUI/Operation/Subscription.pm index 3cf3dec9e..f51235039 100644 --- a/lib/WebGUI/Operation/Subscription.pm +++ b/lib/WebGUI/Operation/Subscription.pm @@ -40,7 +40,7 @@ sub _submenu { my $title = shift; $title = $i18n->get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("subscriptions"); + my $ac = WebGUI::AdminConsole->new($session,"subscriptions"); if ($help) { $ac->setHelp($help, 'Subscription'); } diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index b9804f48f..6cda2d293 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -69,7 +69,7 @@ sub _submenu { my $title = shift; $title = WebGUI::International::get($title) if ($title); my $help = shift; - my $ac = WebGUI::AdminConsole->new("users"); + my $ac = WebGUI::AdminConsole->new($session,"users"); if ($help) { $ac->setHelp($help); } @@ -274,7 +274,7 @@ sub www_deleteUserConfirm { return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); my ($u); if ($session->form->process("uid") eq '1' || $session->form->process("uid") eq '3') { - return WebGUI::AdminConsole->new("users")->render(WebGUI::Privilege::vitalComponent()); + return WebGUI::AdminConsole->new($session,"users")->render(WebGUI::Privilege::vitalComponent()); } else { $u = WebGUI::User->new($session->form->process("uid")); $u->delete; diff --git a/lib/WebGUI/Paginator.pm b/lib/WebGUI/Paginator.pm index 28d15ffdb..039726391 100644 --- a/lib/WebGUI/Paginator.pm +++ b/lib/WebGUI/Paginator.pm @@ -16,8 +16,6 @@ package WebGUI::Paginator; use strict; use WebGUI::International; -use WebGUI::Session; -use WebGUI::URL; use WebGUI::Utility; =head1 NAME @@ -221,7 +219,7 @@ sub getFirstPageLink { $text = '|<'.WebGUI::International::get(404); if ($pn > 1) { return ''.$text.''; } else { return $text; @@ -243,7 +241,7 @@ sub getLastPageLink { $text = WebGUI::International::get(405).'>|'; if ($pn != $_[0]->getNumberOfPages) { return ''.$text.''; } else { return $text; @@ -264,7 +262,7 @@ sub getNextPageLink { $pn = $_[0]->getPageNumber; $text = WebGUI::International::get(92).'»'; if ($pn < $_[0]->getNumberOfPages) { - return ''.$text.''; + return ''.$text.''; } else { return $text; } @@ -365,7 +363,7 @@ sub getPageLinks { if ($i+1 == $pn) { push(@pages,($i+1)); } else { - push(@pages,''.($i+1).''); + push(@pages,''.($i+1).''); } } if ($limit) { @@ -401,7 +399,7 @@ sub getPreviousPageLink { $pn = $_[0]->getPageNumber; $text = '«'.WebGUI::International::get(91); if ($pn > 1) { - return ''.$text.''; + return ''.$text.''; } else { return $text; } @@ -437,7 +435,7 @@ The number of rows to display per page. If left blank it defaults to 50. =head3 pageNumber -By default the page number will be determined by looking at $session{form}{pn}. If that is empty the page number will be defaulted to "1". If you'd like to override the page number specify it here. +By default the page number will be determined by looking at $self->session->form->process("pn"). If that is empty the page number will be defaulted to "1". If you'd like to override the page number specify it here. =head3 formVar @@ -511,12 +509,12 @@ A value to match the dynamicPageNumberKey. sub setDataByQuery { my ($sth, $rowCount, @row); my ($self, $sql, $dbh, $unconditional, $placeholders, $dynamicPageNumberKey, $dynamicPageNumberValue) = @_; - $dbh ||= WebGUI::SQL->getSlave; + $dbh ||= $self->session->db->getSlave; if ($unconditional) { - $sth = WebGUI::SQL->unconditionalRead($sql,$dbh,$placeholders); + $sth = $self->session->db->unconditionalRead($sql,$dbh,$placeholders); return $sth->errorMessage if ($sth->errorCode > 0); } else { - $sth = WebGUI::SQL->read($sql,$dbh,$placeholders); + $sth = $self->session->db->read($sql,$dbh,$placeholders); } my $defaultPageNumber = $self->getPageNumber; $self->{_totalRows} = $sth->rows; diff --git a/lib/WebGUI/PassiveProfiling.pm b/lib/WebGUI/PassiveProfiling.pm index c3c366249..d2673358a 100644 --- a/lib/WebGUI/PassiveProfiling.pm +++ b/lib/WebGUI/PassiveProfiling.pm @@ -54,15 +54,15 @@ The assetId to add. =cut sub add { - return unless ($session{setting}{passiveProfilingEnabled}); + return unless ($self->session->setting->get("passiveProfilingEnabled")); my $assetId = shift; my $sql = "insert into passiveProfileLog (passiveProfileLogId, userId, sessionId, assetId, dateOfEntry) - values (".quote(WebGUI::Id::generate()).",". - quote($session{user}{userId}).",". - quote($session{var}{sessionId}).",". - quote($assetId).",". - quote(WebGUI::DateTime::time()).")"; - WebGUI::SQL->write($sql); + values (".$self->session->db->quote(WebGUI::Id::generate()).",". + $self->session->db->quote($self->session->user->profileField("userId")).",". + $self->session->db->quote($self->session->var->get("sessionId")).",". + $self->session->db->quote($assetId).",". + $self->session->db->quote(WebGUI::DateTime::time()).")"; + $self->session->db->write($sql); return; } @@ -80,9 +80,9 @@ The pageId of the page you want to log. =cut sub addPage { - return unless ($session{setting}{passiveProfilingEnabled}); + return unless ($self->session->setting->get("passiveProfilingEnabled")); my $pageId = shift || $session{page}{pageId}; - my @wids = WebGUI::SQL->buildArray("select * from wobject where pageId=".quote($pageId)); + my @wids = $self->session->db->buildArray("select * from wobject where pageId=".$self->session->db->quote($pageId)); foreach my $wid (@wids) { add($wid); } @@ -112,28 +112,28 @@ sub summarizeAOI { d.value from metaData_values d , metaData_properties f where f.fieldId = d.fieldId - and d.assetId = ".quote($data->{assetId}); + and d.assetId = ".$self->session->db->quote($data->{assetId}); - my $sth = WebGUI::SQL->read($sql); + my $sth = $self->session->db->read($sql); while (my $field = $sth->hashRef) { - my $aoi = WebGUI::SQL->quickHashRef("select * from passiveProfileAOI - where userId=".quote($data->{userId})." - and fieldId=".quote($field->{fieldId})." and - value=".quote($field->{value})); + my $aoi = $self->session->db->quickHashRef("select * from passiveProfileAOI + where userId=".$self->session->db->quote($data->{userId})." + and fieldId=".$self->session->db->quote($field->{fieldId})." and + value=".$self->session->db->quote($field->{value})); if(not exists $aoi->{userId}) { # Add record to DB - WebGUI::SQL->write("insert into passiveProfileAOI (userId, fieldId, value) - values (".quote($data->{userId}).",". - quote($field->{fieldId}).",". - quote($field->{value}).")"); + $self->session->db->write("insert into passiveProfileAOI (userId, fieldId, value) + values (".$self->session->db->quote($data->{userId}).",". + $self->session->db->quote($field->{fieldId}).",". + $self->session->db->quote($field->{value}).")"); } my $count = $aoi->{count}; $count++; - WebGUI::SQL->write("update passiveProfileAOI set count=".quote($count)." - where userId=".quote($data->{userId})." - and fieldId=".quote($field->{fieldId})." and - value=".quote($field->{value})); + $self->session->db->write("update passiveProfileAOI set count=".$self->session->db->quote($count)." + where userId=".$self->session->db->quote($data->{userId})." + and fieldId=".$self->session->db->quote($field->{fieldId})." and + value=".$self->session->db->quote($field->{value})); } $sth->finish; } diff --git a/lib/WebGUI/Privilege.pm b/lib/WebGUI/Privilege.pm index 126ac9801..5f318b634 100644 --- a/lib/WebGUI/Privilege.pm +++ b/lib/WebGUI/Privilege.pm @@ -88,7 +88,7 @@ Returns a message stating that the user does not have the privileges necessary t sub noAccess { WebGUI::HTTP::setStatus("401", "No Access"); - if ($session{user}{userId} eq '1') { + if ($self->session->user->profileField("userId") eq '1') { return WebGUI::Operation::Auth::www_auth("init"); } else { my $output = '

'.WebGUI::International::get(37).'

'; diff --git a/lib/WebGUI/Product.pm b/lib/WebGUI/Product.pm index 9c75f8a6a..f9b5f307f 100755 --- a/lib/WebGUI/Product.pm +++ b/lib/WebGUI/Product.pm @@ -29,9 +29,9 @@ sub addOptionToParameter { $optionId = WebGUI::Id::generate; - WebGUI::SQL->write("insert into productParameterOptions ". + $self->session->db->write("insert into productParameterOptions ". "(optionId, parameterId) values ". - "(".quote($optionId).", ".quote($parameterId).")"); + "(".$self->session->db->quote($optionId).", ".$self->session->db->quote($parameterId).")"); $self->{_options}->{$optionId} = { %$properties, @@ -54,8 +54,8 @@ sub addParameter { $parameterId = WebGUI::Id::generate; - WebGUI::SQL->write("insert into productParameters (parameterId, productId) values ". - "(".quote($parameterId).", ".quote($self->get('productId')).")"); + $self->session->db->write("insert into productParameters (parameterId, productId) values ". + "(".$self->session->db->quote($parameterId).", ".$self->session->db->quote($self->get('productId')).")"); $self->{_parameters}->{$parameterId}->{parameterId} = $parameterId; $self->{_parameters}->{$parameterId}->{options} = []; @@ -68,12 +68,12 @@ sub delete { my ($self) = shift; foreach (@{$self->getParameter}) { - WebGUI::SQL->write("delete from productParameterOptions where parameterId=".quote($_->{parameterId})); + $self->session->db->write("delete from productParameterOptions where parameterId=".$self->session->db->quote($_->{parameterId})); } - WebGUI::SQL->write("delete from productParameters where productId=".quote($self->get('productId'))); - WebGUI::SQL->write("delete from productVariants where productId=".quote($self->get('productId'))); - WebGUI::SQL->write("delete from products where productId=".quote($self->get('productId'))); + $self->session->db->write("delete from productParameters where productId=".$self->session->db->quote($self->get('productId'))); + $self->session->db->write("delete from productVariants where productId=".$self->session->db->quote($self->get('productId'))); + $self->session->db->write("delete from products where productId=".$self->session->db->quote($self->get('productId'))); return undef; } @@ -84,8 +84,8 @@ sub deleteParameter { $self = shift; $parameterId = shift; - WebGUI::SQL->write("delete from productParameterOptions where parameterId=".quote($parameterId)); - WebGUI::SQL->write("delete from productParameters where parameterId=".quote($parameterId)); + $self->session->db->write("delete from productParameterOptions where parameterId=".$self->session->db->quote($parameterId)); + $self->session->db->write("delete from productParameters where parameterId=".$self->session->db->quote($parameterId)); $self->updateVariants; @@ -98,7 +98,7 @@ sub deleteOption { $self = shift; $optionId = shift; - WebGUI::SQL->write("delete from productParameterOptions where optionId=".quote($optionId)); + $self->session->db->write("delete from productParameterOptions where optionId=".$self->session->db->quote($optionId)); $parameterId = $self->{_options}->{$optionId}->{parameterId}; @@ -134,8 +134,8 @@ sub getByOptionId { $optionId = shift; - ($productId) = WebGUI::SQL->quickArray("select productId from productParameters as t1, productParameterOptions as t2 ". - "where t1.parameterId=t2.parameterId and t2.optionId=".quote($optionId)); + ($productId) = $self->session->db->quickArray("select productId from productParameters as t1, productParameterOptions as t2 ". + "where t1.parameterId=t2.parameterId and t2.optionId=".$self->session->db->quote($optionId)); return undef unless ($productId); @@ -148,7 +148,7 @@ sub getByParameterId { $class = shift; $parameterId = shift; - ($productId) = WebGUI::SQL->quickArray("select productId from productParameters where parameterId=".quote($parameterId)); + ($productId) = $self->session->db->quickArray("select productId from productParameters where parameterId=".$self->session->db->quote($parameterId)); return WebGUI::Product->new($productId); } @@ -159,7 +159,7 @@ sub getByVariantId { $class = shift; $variantId = shift; - ($productId) = WebGUI::SQL->quickArray("select productId from productVariants where variantId=".quote($variantId)); + ($productId) = $self->session->db->quickArray("select productId from productVariants where variantId=".$self->session->db->quote($variantId)); return WebGUI::Product->new($productId); } @@ -203,7 +203,7 @@ sub new { $class = shift; $productId = shift; - WebGUI::ErrorHandler::fatal('no productId') unless ($productId); + $self->session->errorHandler->fatal('no productId') unless ($productId); $parameters = {}; $variants = {}; @@ -212,13 +212,13 @@ sub new { if ($productId eq 'new') { $productId = WebGUI::Id::generate; $properties = {productId => $productId}; - WebGUI::SQL->write("insert into products (productId) values (".quote($productId).")"); + $self->session->db->write("insert into products (productId) values (".$self->session->db->quote($productId).")"); } else { - $properties = WebGUI::SQL->quickHashRef("select * from products where productId=".quote($productId)); + $properties = $self->session->db->quickHashRef("select * from products where productId=".$self->session->db->quote($productId)); # fetch parameters and options - $sth = WebGUI::SQL->read("select opt.*, param.* from productParameters as param left join productParameterOptions as opt ". - "on param.parameterId=opt.parameterId where param.productId=".quote($productId)); + $sth = $self->session->db->read("select opt.*, param.* from productParameters as param left join productParameterOptions as opt ". + "on param.parameterId=opt.parameterId where param.productId=".$self->session->db->quote($productId)); while (%row = $sth->hash) { $parameters->{$row{parameterId}} = { name => $row{name}, @@ -240,7 +240,7 @@ sub new { } # fetch variants - $sth = WebGUI::SQL->read("select * from productVariants where productId=".quote($productId)); + $sth = $self->session->db->read("select * from productVariants where productId=".$self->session->db->quote($productId)); while (%row = $sth->hash) { $variants->{$row{variantId}} = {%row}; } @@ -257,8 +257,8 @@ sub set { $self = shift; $properties = shift; - WebGUI::SQL->write("update products set ".join(', ', map {$_."=".quote($properties->{$_})} keys(%$properties)). - " where productId=".quote($self->get('productId'))); + $self->session->db->write("update products set ".join(', ', map {$_."=".$self->session->db->quote($properties->{$_})} keys(%$properties)). + " where productId=".$self->session->db->quote($self->get('productId'))); foreach (keys(%$properties)) { $self->{_properties}->{$_} = $properties->{$_}; @@ -274,8 +274,8 @@ sub setParameter { $parameterId = shift; $properties = shift; - WebGUI::SQL->write("update productParameters set ".join(', ', map {$_."=".quote($properties->{$_})} keys(%$properties)). - " where parameterId=".quote($parameterId)); + $self->session->db->write("update productParameters set ".join(', ', map {$_."=".$self->session->db->quote($properties->{$_})} keys(%$properties)). + " where parameterId=".$self->session->db->quote($parameterId)); map {$self->{_parameter}->{$parameterId}->{$_} = $properties->{$_}} keys %$properties; } @@ -287,8 +287,8 @@ sub setOption { $optionId = shift; $properties = shift; - WebGUI::SQL->write("update productParameterOptions set ".join(', ', map {$_."=".quote($properties->{$_})} keys(%$properties)). - " where optionId=".quote($optionId)); + $self->session->db->write("update productParameterOptions set ".join(', ', map {$_."=".$self->session->db->quote($properties->{$_})} keys(%$properties)). + " where optionId=".$self->session->db->quote($optionId)); foreach (keys(%$properties)) { $self->{_options}->{$optionId}->{$_} = $properties->{$_}; @@ -321,29 +321,29 @@ my $currentOption = $self->getOption($_); if (defined $properties->{price}) { if ($properties->{price} ne '') { - push(@pairs, 'price='.quote($properties->{price}).', priceOverride=1'); + push(@pairs, 'price='.$self->session->db->quote($properties->{price}).', priceOverride=1'); } else { - push(@pairs, 'price='.quote($original->{price}).', priceOverride=0'); + push(@pairs, 'price='.$self->session->db->quote($original->{price}).', priceOverride=0'); } } if (defined $properties->{weight}) { if ($properties->{weight} ne '') { - push(@pairs, 'weight='.quote($properties->{weight}).', weightOverride=1'); + push(@pairs, 'weight='.$self->session->db->quote($properties->{weight}).', weightOverride=1'); } else { - push(@pairs, 'weight='.quote($original->{weight}).', weightOverride=0'); + push(@pairs, 'weight='.$self->session->db->quote($original->{weight}).', weightOverride=0'); } } if (defined $properties->{sku}) { if ($properties->{sku} ne '') { - push(@pairs, 'sku='.quote($properties->{sku}).', skuOverride=1'); + push(@pairs, 'sku='.$self->session->db->quote($properties->{sku}).', skuOverride=1'); } else { - push(@pairs, 'sku='.quote($original->{sku}).', skuOverride=0'); + push(@pairs, 'sku='.$self->session->db->quote($original->{sku}).', skuOverride=0'); } } - push(@pairs, 'available='.quote($properties->{available})) if (defined $properties->{available}); + push(@pairs, 'available='.$self->session->db->quote($properties->{available})) if (defined $properties->{available}); - WebGUI::SQL->write("update productVariants set ".join(', ', @pairs)." where variantId=".quote($variantId)) if (@pairs); + $self->session->db->write("update productVariants set ".join(', ', @pairs)." where variantId=".$self->session->db->quote($variantId)) if (@pairs); $self->{_variants}->{$variantId} = {%{$self->{_variants}->{$variantId}}, %$properties}; } @@ -407,11 +407,11 @@ sub updateVariants { $newVariants{$var{variantId}} = {%var}; } - WebGUI::SQL->write("delete from productVariants where productId=".quote($self->get('productId'))); + $self->session->db->write("delete from productVariants where productId=".$self->session->db->quote($self->get('productId'))); foreach (values %newVariants) { - WebGUI::SQL->write("insert into productVariants (variantId, productId, composition, price, weight, sku, available) values ". - "(".quote($_->{variantId}).", ".quote($_->{productId}).", ".quote($_->{composition}).", ".quote($_->{price}). - ", ".quote($_->{weight}).", ".quote($_->{sku}).", ".quote($_->{available}).")"); + $self->session->db->write("insert into productVariants (variantId, productId, composition, price, weight, sku, available) values ". + "(".$self->session->db->quote($_->{variantId}).", ".$self->session->db->quote($_->{productId}).", ".$self->session->db->quote($_->{composition}).", ".$self->session->db->quote($_->{price}). + ", ".$self->session->db->quote($_->{weight}).", ".$self->session->db->quote($_->{sku}).", ".$self->session->db->quote($_->{available}).")"); } $self->{_variants} = \%newVariants; diff --git a/lib/WebGUI/ProfileCategory.pm b/lib/WebGUI/ProfileCategory.pm index 3055b6726..bb53c680b 100644 --- a/lib/WebGUI/ProfileCategory.pm +++ b/lib/WebGUI/ProfileCategory.pm @@ -43,10 +43,10 @@ These methods are available from this package: #------------------------------------------------------------------- sub _reorderCategories { my ($sth, $i, $id); - $sth = WebGUI::SQL->read("select profileCategoryId from userProfileCategory order by sequenceNumber"); + $sth = $self->session->db->read("select profileCategoryId from userProfileCategory order by sequenceNumber"); while (($id) = $sth->array) { $i++; - WebGUI::SQL->write("update userProfileCategory set sequenceNumber='$i' where profileCategoryId=".quote($id)); + $self->session->db->write("update userProfileCategory set sequenceNumber='$i' where profileCategoryId=".$self->session->db->quote($id)); } $sth->finish; } @@ -66,8 +66,8 @@ A hash reference containing the properties of this field. See the set() method f sub create { my $class = shift; my $properties = shift; - my ($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) from userProfileCategory"); - my $id = WebGUI::SQL->setRow("userProfileCategory","profileCategoryId",{profileCategoryId=>"new", sequenceNumber=>$sequenceNumber+1}); + my ($sequenceNumber) = $self->session->db->quickArray("select max(sequenceNumber) from userProfileCategory"); + my $id = $self->session->db->setRow("userProfileCategory","profileCategoryId",{profileCategoryId=>"new", sequenceNumber=>$sequenceNumber+1}); my $self = $class->new($id); $self->set($properties); return $self; @@ -86,7 +86,7 @@ sub delete { foreach my $field (@{$self->getFields}) { $field->delete; } - WebGUI::SQL->deleteRow("userProfileCategory","profileCategoryId",$self->getId); + $self->session->db->deleteRow("userProfileCategory","profileCategoryId",$self->getId); } #------------------------------------------------------------------- @@ -121,7 +121,7 @@ Returns an array reference of all WebGUI::ProfileCategory objects in order of se sub getCategories { my $self = shift; my @categories = (); - foreach my $id (WebGUI::SQL->buildArray("select profileCategoryId from userProfileCategory order by sequenceNumber")) { + foreach my $id ($self->session->db->buildArray("select profileCategoryId from userProfileCategory order by sequenceNumber")) { push(@categories,WebGUI::ProfileCategory->new($id)); } return \@categories; @@ -139,7 +139,7 @@ Returns an array reference of all WebGUI::ProfileField objects that are part of sub getFields { my $self = shift; my @fields = (); - foreach my $fieldName (WebGUI::SQL->buildArray("select fieldName from userProfileField where profileCategoryId=".quote($self->getId)." order by sequenceNumber")){ + foreach my $fieldName ($self->session->db->buildArray("select fieldName from userProfileField where profileCategoryId=".$self->session->db->quote($self->getId)." order by sequenceNumber")){ push(@fields,WebGUI::ProfileField->new($fieldName)); } return \@fields; @@ -223,11 +223,11 @@ Moves this category down one position. sub moveDown { my $self = shift; my ($id, $thisSeq); - ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from userProfileCategory where profileCategoryId=".quote($self->getId)); - ($id) = WebGUI::SQL->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq+1"); + ($thisSeq) = $self->session->db->quickArray("select sequenceNumber from userProfileCategory where profileCategoryId=".$self->session->db->quote($self->getId)); + ($id) = $self->session->db->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq+1"); if ($id ne "") { - WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=".quote($self->getId)); - WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=".quote($id)); + $self->session->db->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=".$self->session->db->quote($self->getId)); + $self->session->db->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=".$self->session->db->quote($id)); _reorderCategories(); } } @@ -243,11 +243,11 @@ Moves this field up one position. sub moveUp { my $self = shift; my ($id, $thisSeq); - ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from userProfileCategory where profileCategoryId=".quote($self->getId)); - ($id) = WebGUI::SQL->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq-1"); + ($thisSeq) = $self->session->db->quickArray("select sequenceNumber from userProfileCategory where profileCategoryId=".$self->session->db->quote($self->getId)); + ($id) = $self->session->db->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq-1"); if ($id ne "") { - WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=".quote($self->getId)); - WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=".quote($id)); + $self->session->db->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=".$self->session->db->quote($self->getId)); + $self->session->db->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=".$self->session->db->quote($id)); _reorderCategories(); } } @@ -268,7 +268,7 @@ sub new { my $class = shift; my $id = shift; return undef unless ($id); - my $properties = WebGUI::SQL->getRow("userProfileCategory","profileCategoryId",$id); + my $properties = $self->session->db->getRow("userProfileCategory","profileCategoryId",$id); bless {_properties=>$properties}, $class; } @@ -309,7 +309,7 @@ sub set { $properties->{protected} = 0 unless ($properties->{protected} == 1); $properties->{label} = 'Undefined' if ($properties->{label} =~ /^[\"\']*$/); $properties->{profileCategoryId} = $self->getId; - WebGUI::SQL->setRow("userProfileCategory","profileCategoryId",$properties); + $self->session->db->setRow("userProfileCategory","profileCategoryId",$properties); } diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index d6b23cf98..4016d37cc 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -48,10 +48,10 @@ These methods are available from this package: sub _reorderFields { my $category = shift; my ($sth, $i, $id); - $sth = WebGUI::SQL->read("select fieldName from userProfileField where profileCategoryId=".quote($category)." order by sequenceNumber"); + $sth = $self->session->db->read("select fieldName from userProfileField where profileCategoryId=".$self->session->db->quote($category)." order by sequenceNumber"); while (($id) = $sth->array) { $i++; - WebGUI::SQL->write("update userProfileField set sequenceNumber='$i' where fieldName=".quote($id)); + $self->session->db->write("update userProfileField set sequenceNumber='$i' where fieldName=".$self->session->db->quote($id)); } $sth->finish; } @@ -81,9 +81,9 @@ sub create { my $fieldName = shift; my $properties = shift; my $categoryId = shift || "1"; - my ($fieldNameExists) = WebGUI::SQL->quickArray("select count(*) from userProfileField where fieldName=".quote($fieldName)); + my ($fieldNameExists) = $self->session->db->quickArray("select count(*) from userProfileField where fieldName=".$self->session->db->quote($fieldName)); return undef if ($fieldNameExists); - my $id = WebGUI::SQL->setRow("userProfileField","fieldName",{fieldName=>"new"},undef,$fieldName); + my $id = $self->session->db->setRow("userProfileField","fieldName",{fieldName=>"new"},undef,$fieldName); my $self = $class->new($id); $self->setCategory($categoryId); $self->set($properties); @@ -100,8 +100,8 @@ Deletes this field and all user data attached to it. sub delete { my $self = shift; - WebGUI::SQL->write("delete from userProfileData where fieldName=".quote($self->getId)); - WebGUI::SQL->deleteRow("userProfileField","fieldName",$self->getId); + $self->session->db->write("delete from userProfileData where fieldName=".$self->session->db->quote($self->getId)); + $self->session->db->deleteRow("userProfileField","fieldName",$self->getId); } #------------------------------------------------------------------- @@ -170,7 +170,7 @@ Returns the value retrieved from a form post. sub formProcess { my $self = shift; - my $result = WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("dataDefault"))); + my $result = $self->session->form->process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("dataDefault"))); if (ref $result eq "ARRAY") { my @results = @$result; for (my $count=0;$countbuildArray("select fieldName from userProfileField where required=1 or editable=1 order by sequenceNumber")) { + foreach my $fieldName ($self->session->db->buildArray("select fieldName from userProfileField where required=1 or editable=1 order by sequenceNumber")) { push(@fields,WebGUI::ProfileField->new($fieldName)); } return \@fields; @@ -246,7 +246,7 @@ Returns an array reference of WebGUI::ProfileField objects. This is a class meth sub getFields { my $self = shift; my @fields = (); - foreach my $fieldName (WebGUI::SQL->buildArray("select fieldName from userProfileField order by profileCategoryId, sequenceNumber")) { + foreach my $fieldName ($self->session->db->buildArray("select fieldName from userProfileField order by profileCategoryId, sequenceNumber")) { push(@fields,WebGUI::ProfileField->new($fieldName)); } return \@fields; @@ -291,7 +291,7 @@ Returns an array reference of WebGUI::ProfileField objects that are marked "requ sub getRequiredFields { my $self = shift; my @fields = (); - foreach my $fieldName (WebGUI::SQL->buildArray("select fieldName from userProfileField where required=1 order by sequenceNumber")) { + foreach my $fieldName ($self->session->db->buildArray("select fieldName from userProfileField where required=1 order by sequenceNumber")) { push(@fields,WebGUI::ProfileField->new($fieldName)); } return \@fields; @@ -361,11 +361,11 @@ Moves this field down one position within it's category. sub moveDown { my $self = shift; my ($id, $thisSeq, $profileCategoryId); - ($thisSeq,$profileCategoryId) = WebGUI::SQL->quickArray("select sequenceNumber,profileCategoryId from userProfileField where fieldName=".quote($self->getId)); - ($id) = WebGUI::SQL->quickArray("select fieldName from userProfileField where profileCategoryId=".quote($profileCategoryId)." and sequenceNumber=$thisSeq+1"); + ($thisSeq,$profileCategoryId) = $self->session->db->quickArray("select sequenceNumber,profileCategoryId from userProfileField where fieldName=".$self->session->db->quote($self->getId)); + ($id) = $self->session->db->quickArray("select fieldName from userProfileField where profileCategoryId=".$self->session->db->quote($profileCategoryId)." and sequenceNumber=$thisSeq+1"); if ($id ne "") { - WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".quote($self->getId)); - WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".quote($id)); + $self->session->db->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".$self->session->db->quote($self->getId)); + $self->session->db->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".$self->session->db->quote($id)); _reorderFields($profileCategoryId); } } @@ -381,11 +381,11 @@ Moves this field up one position within it's category. sub moveUp { my $self = shift; my ($id, $thisSeq, $profileCategoryId); - ($thisSeq,$profileCategoryId) = WebGUI::SQL->quickArray("select sequenceNumber,profileCategoryId from userProfileField where fieldName=".quote($self->getId)); - ($id) = WebGUI::SQL->quickArray("select fieldName from userProfileField where profileCategoryId=".quote($profileCategoryId)." and sequenceNumber=$thisSeq-1"); + ($thisSeq,$profileCategoryId) = $self->session->db->quickArray("select sequenceNumber,profileCategoryId from userProfileField where fieldName=".$self->session->db->quote($self->getId)); + ($id) = $self->session->db->quickArray("select fieldName from userProfileField where profileCategoryId=".$self->session->db->quote($profileCategoryId)." and sequenceNumber=$thisSeq-1"); if ($id ne "") { - WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".quote($self->getId)); - WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".quote($id)); + $self->session->db->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".$self->session->db->quote($self->getId)); + $self->session->db->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".$self->session->db->quote($id)); _reorderFields($profileCategoryId); } } @@ -407,7 +407,7 @@ sub new { my $class = shift; my $id = shift; return undef unless ($id); - my $properties = WebGUI::SQL->getRow("userProfileField","fieldName",$id); + my $properties = $self->session->db->getRow("userProfileField","fieldName",$id); bless {_properties=>$properties}, $class; } @@ -426,10 +426,10 @@ The new name this field should take. sub rename { my $self = shift; my $newName = shift; - my ($fieldNameExists) = WebGUI::SQL->quickArray("select count(*) from userProfileField where fieldName=".quote($newName)); + my ($fieldNameExists) = $self->session->db->quickArray("select count(*) from userProfileField where fieldName=".$self->session->db->quote($newName)); return 0 if ($fieldNameExists); - WebGUI::SQL->write("update userProfileData set fieldName=".quote($newName)." where fieldName=".quote($self->getId)); - WebGUI::SQL->write("update userProfileField set fieldName=".quote($newName)." where fieldName=".quote($self->getId)); + $self->session->db->write("update userProfileData set fieldName=".$self->session->db->quote($newName)." where fieldName=".$self->session->db->quote($self->getId)); + $self->session->db->write("update userProfileField set fieldName=".$self->session->db->quote($newName)." where fieldName=".$self->session->db->quote($self->getId)); $self->{_properties}{fieldName} = $newName; return 1; } @@ -497,7 +497,7 @@ sub set { } } $properties->{fieldName} = $self->getId; - WebGUI::SQL->setRow("userProfileField","fieldName",$properties); + $self->session->db->setRow("userProfileField","fieldName",$properties); foreach my $key (keys %{$properties}) { $self->{_property}{$key} = $properties->{$key}; } @@ -520,8 +520,8 @@ sub setCategory { my $categoryId = shift; return undef unless ($categoryId); my $currentCategoryId = $self->get("profileCategoryId"); - my ($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) from userProfileField where profileCategoryId=".quote($categoryId)); - WebGUI::SQL->setRow("userProfileField","fieldName",{fieldName=>$self->getId, profileCategoryId=>$categoryId, sequenceNumber=>$sequenceNumber+1}); + my ($sequenceNumber) = $self->session->db->quickArray("select max(sequenceNumber) from userProfileField where profileCategoryId=".$self->session->db->quote($categoryId)); + $self->session->db->setRow("userProfileField","fieldName",{fieldName=>$self->getId, profileCategoryId=>$categoryId, sequenceNumber=>$sequenceNumber+1}); $self->{_property}{profileCategoryId} = $categoryId; $self->{_property}{sequenceNumber} = $sequenceNumber+1; _reorderFields($currentCategoryId) if ($currentCategoryId); diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index 1e290fe19..d87824eb6 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -37,7 +37,7 @@ Package for interfacing with SQL databases. This package implements Perl DBI fun use WebGUI::SQL; - $db = WebGUI::SQL->connect($dsn, $user, $pass, $session); + $db = $self->session->db->connect($dsn, $user, $pass, $session); $db->disconnect; $sth = $db->prepare($sql); @@ -63,8 +63,8 @@ Package for interfacing with SQL databases. This package implements Perl DBI fun $dbh = $db->getSlave; $id = $db->getNextId("someId"); - $string = $db->quote($string); - $string = $db->quoteAndJoin(\@array); + $string = $db->$self->session->db->quote($string); + $string = $db->$self->session->db->quoteAndJoin(\@array); =head1 METHODS @@ -272,7 +272,7 @@ The value to search for in the key column. sub deleteRow { my ($self, $table, $key, $keyValue) = @_; - WebGUI::SQL->write("delete from $table where ".$key."=".$self->quote($keyValue)); + $self->session->db->write("delete from $table where ".$key."=".$self->$self->session->db->quote($keyValue)); } @@ -366,7 +366,7 @@ The value to search for in the key column. sub getRow { my ($self, $table, $key, $keyValue) = @_; - my $row = WebGUI::SQL->quickHashRef("select * from $table where ".$key."=".$self->quote($keyValue)); + my $row = $self->session->db->quickHashRef("select * from $table where ".$key."=".$self->$self->session->db->quote($keyValue)); return $row; } @@ -533,14 +533,14 @@ Any scalar variable that needs to be escaped to be inserted into the database. sub quote { my $self = shift; my $value = shift; - return $self->dbh->quote($value); + return $self->dbh->$self->session->db->quote($value); } #------------------------------------------------------------------- =head2 quoteAndJoin ( arrayRef ) -Returns a comma seperated string quoted and ready for insert/select into/from the database. This is typically used for a statement like "select * from someTable where field in (".quoteAndJoin(\@strings).")". +Returns a comma seperated string quoted and ready for insert/select into/from the database. This is typically used for a statement like "select * from someTable where field in (".$self->session->db->quoteAndJoin(\@strings).")". B This is not a regular method, but is an exported subroutine. @@ -555,7 +555,7 @@ sub quoteAndJoin { my $arrayRef = shift; my @newArray; foreach my $value (@$arrayRef) { - push(@newArray,$self->quote($value)); + push(@newArray,$self->$self->session->db->quote($value)); } return join(",",@newArray); } @@ -650,7 +650,7 @@ sub setRow { my (@pairs); foreach my $key (keys %{$data}) { unless ($key eq $keyColumn) { - push(@pairs, $key.'='.$self->quote($data->{$key})); + push(@pairs, $key.'='.$self->$self->session->db->quote($data->{$key})); } } if ($pairs[0] ne "") { diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 443b876ca..782e1eda6 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -110,7 +110,7 @@ Cleans up a WebGUI session information from memory and disconnects from any reso sub close { my $self = shift; - $session{asset}->DESTROY() if (exists $session{asset} && $session{asset} ne ""); + $self->session->asset->DESTROY() if (exists $self->session->asset && $self->session->asset ne ""); foreach my $slavedbh (@{$self->{_slave}}) { $slavedbh->disconnect(); } @@ -143,7 +143,7 @@ Returns a WebGUI::SQL object, which is connected to the WebGUI database. sub db { my $self = shift; if (exists $self->{_db}) { - $self->{_db} = WebGUI::SQL->connect($self->config->get("dsn"), $self->config->get("dbuser"), $self->config->get("dbpass"), $self); + $self->{_db} = $self->session->db->connect($self->config->get("dsn"), $self->config->get("dbuser"), $self->config->get("dbpass"), $self); } return $self->{_db}; } @@ -162,7 +162,7 @@ sub dbSlave { foreach (1..3) { my $slave = $self->config->get("dbslave".$_); if (exists $slave->{dsn}) { - push(@{$self->{_slave}},WebGUI::SQL->connect($slave->{dsn},$slave->{user},$slave->{pass}, $self)); + push(@{$self->{_slave}},$self->session->db->connect($slave->{dsn},$slave->{user},$slave->{pass}, $self)); } } } @@ -431,7 +431,7 @@ sub user { $self->{_var}{userId} = $option->{userId} || $option->{user}->userId; $self->db-setRow("userSession","sessionId", $self->{_var}); if ($self->setting("passiveProfilingEnabled")) { - $self->db->write("update passiveProfileLog set userId = ".quote($self->{_var}{userId})." where sessionId = ".quote($self->getId)); + $self->db->write("update passiveProfileLog set userId = ".$self->session->db->quote($self->{_var}{userId})." where sessionId = ".$self->session->db->quote($self->getId)); } delete $self->{_stow}; $self->{_user} = $option->{user} || WebGUI::User->new($session, $self->{_var}{userId}); diff --git a/lib/WebGUI/Session/Http.pm b/lib/WebGUI/Session/Http.pm index 43fbabca0..eb879ab7b 100644 --- a/lib/WebGUI/Session/Http.pm +++ b/lib/WebGUI/Session/Http.pm @@ -202,7 +202,7 @@ sub setCookie { my $cookie = Apache2::Cookie->new($self->session->request, -name=>$name, -value=>$value, - # -domain=>'.'.$session{env}{HTTP_HOST}, + # -domain=>'.'.$self->session->env->get("HTTP_HOST"), -expires=>$ttl, -path=>'/' ); diff --git a/lib/WebGUI/Session/Scratch.pm b/lib/WebGUI/Session/Scratch.pm index 1395d3a93..e24b70779 100644 --- a/lib/WebGUI/Session/Scratch.pm +++ b/lib/WebGUI/Session/Scratch.pm @@ -76,7 +76,7 @@ Deletes all scratch variables for this session. sub deleteAll { my $self = shift; delete $self->{_data}; - WebGUI::SQL->write("delete from userSessionScratch where sessionId=".quote($self->{_sessionId})); + $self->session->db->write("delete from userSessionScratch where sessionId=".quote($self->{_sessionId})); } @@ -97,7 +97,7 @@ sub deleteName { my $name = shift; return undef unless ($name); delete $self->{_data}{$name}; - WebGUI::SQL->write("delete from userSessionScratch where name=".quote($name)); + $self->session->db->write("delete from userSessionScratch where name=".quote($name)); } diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index 2d31bc09f..06ac15312 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -177,7 +177,7 @@ $var{'head.tags'} = ' function getWebguiProperty (propName) { var props = new Array(); props["extrasURL"] = "'.$self->session->config->get("extrasURL").'"; -props["pageURL"] = "'.WebGUI::URL::page(undef, undef, 1).'"; +props["pageURL"] = "'.$self->session->url->page(undef, undef, 1).'"; return props[propName]; } @@ -202,8 +202,8 @@ if (WebGUI::Grouping::isInGroup(2)) { my $macroHeadTags = generateAdditionalHeadTags(); WebGUI::Macro::process(\$macroHeadTags); $output =~ s/\<\!-- macro head tags --\>/$macroHeadTags/; - if (WebGUI::ErrorHandler::canShowDebug()) { - $output .= WebGUI::ErrorHandler::showDebug(); + if ($self->session->errorHandler->canShowDebug()) { + $output .= $self->session->errorHandler->showDebug(); } return $output; } diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index 21e1d7d25..da7e50d31 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -94,7 +94,7 @@ sub append { Encodes a string to make it safe to pass in a URL. -B See WebGUI::URL::unescape() +B See $self->session->url->unescape() =head3 string @@ -177,10 +177,10 @@ sub getSiteURL { if ($self->session->setting->get("hostToUse") eq "sitename" || !isIn($self->session->env->get("HTTP_HOST"),@{$sitenames})) { $site = $sitenames->[0]; } else { - $site = $session{env}{HTTP_HOST} || $sitenames->[0]; + $site = $self->session->env->get("HTTP_HOST") || $sitenames->[0]; } my $proto = "http://"; - if ($session{env}{HTTPS} eq "on") { + if ($self->session->env->get("HTTPS") eq "on") { $proto = "https://"; } $self->{_siteUrl} = $proto.$site; @@ -322,7 +322,7 @@ sub setSiteURL { Decodes a string that was URL encoded. -B See WebGUI::URL::escape() +B See $self->session->url->escape() =head3 string diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index a972d549e..7ec2ccc09 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -96,7 +96,7 @@ sub _addError { my $self = shift; my $errorMessage = shift; push(@{$self->{_errors}},$errorMessage); - WebGUI::ErrorHandler::error($errorMessage); + $self->session->errorHandler->error($errorMessage); } @@ -112,7 +112,7 @@ NOTE: This is a private method and should never be called except internally to t sub _makePath { my $self = shift; - my $node = $session{config}{uploadsPath}; + my $node = $self->session->config->get("uploadsPath"); foreach my $folder ($self->{_part1}, $self->{_part2}, $self->{_id}) { $node .= '/'.$folder; unless (-e $node) { # check to see if it already exists @@ -149,9 +149,9 @@ sub addFileFromFilesystem { $filename =~ s/\./\_/g; $filename .= ".txt"; } - $filename = WebGUI::URL::makeCompliant($filename); + $filename = $self->session->url->makeCompliant($filename); if (-d $pathToFile) { - WebGUI::ErrorHandler::error($pathToFile." is a directory, not a file."); + $self->session->errorHandler->error($pathToFile." is a directory, not a file."); } else { my $source = FileHandle->new($pathToFile,"r"); if (defined $source) { @@ -201,7 +201,7 @@ sub addFileFromFormPost { return "" if (WebGUI::HTTP::getStatus() =~ /^413/); my $filename; my $attachmentCount = 1; - foreach my $upload ($session{req}->upload($formVariableName)) { + foreach my $upload ($self->session->request->upload($formVariableName)) { return $filename if $attachmentCount > $attachmentLimit; $filename = $upload->filename(); next unless $filename; @@ -211,7 +211,7 @@ sub addFileFromFormPost { $filename =~ s/\./\_/g; $filename .= ".txt"; } - $filename = WebGUI::URL::makeCompliant($filename); + $filename = $self->session->url->makeCompliant($filename); my $bytesread; my $file = FileHandle->new(">".$self->getPath($filename)); $attachmentCount++; @@ -251,7 +251,7 @@ A hash reference containing the data you wish to persist to the filesystem. sub addFileFromHashref { my $self = shift; - my $filename = WebGUI::URL::makeCompliant(shift); + my $filename = $self->session->url->makeCompliant(shift); my $hashref = shift; bless $hashref; nstore $hashref, $self->getPath($filename) or $self->_addError("Couldn't create file ".$self->getPath($filename)." because ".$!); @@ -276,7 +276,7 @@ The content to write to the file. sub addFileFromScalar { my $self = shift; - my $filename = WebGUI::URL::makeCompliant(shift); + my $filename = $self->session->url->makeCompliant(shift); my $content = shift; if (open(FILE,">".$self->getPath($filename))) { print FILE $content; @@ -483,11 +483,11 @@ sub getFileIconUrl { my $self = shift; my $filename = shift; my $extension = $self->getFileExtension($filename); - my $path = $session{config}{extrasPath}.'/fileIcons/'.$extension.".gif"; + my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif"; if (-e $path) { - return $session{config}{extrasURL}."/fileIcons/".$extension.".gif"; + return $self->session->config->get("extrasURL")."/fileIcons/".$extension.".gif"; } - return $session{config}{extrasURL}."/fileIcons/unknown.gif"; + return $self->session->config->get("extrasURL")."/fileIcons/unknown.gif"; } @@ -601,11 +601,11 @@ If specified, we'll return a path to the file rather than the storage location. sub getPath { my $self = shift; my $file = shift; - unless ($session{config}{uploadsPath} && $self->{_part1} && $self->{_part2} && $self->getId) { + unless ($self->session->config->get("uploadsPath") && $self->{_part1} && $self->{_part2} && $self->getId) { $self->_addError("storage object malformed"); return undef; } - my $path = $session{config}{uploadsPath} + my $path = $self->session->config->get("uploadsPath") .'/'.$self->{_part1} .'/'.$self->{_part2} .'/'.$self->getId; @@ -631,7 +631,7 @@ If specified, we'll return a URL to the file rather than the storage location. sub getUrl { my $self = shift; my $file = shift; - my $url = $session{config}{uploadsURL}.'/'.$self->{_part1}.'/'.$self->{_part2}.'/'.$self->getId; + my $url = $self->session->config->get("uploadsURL").'/'.$self->{_part1}.'/'.$self->{_part2}.'/'.$self->getId; if (defined $file) { $url .= '/'.$file; } diff --git a/lib/WebGUI/Storage/Image.pm b/lib/WebGUI/Storage/Image.pm index 8ff1bbb38..ab283c006 100644 --- a/lib/WebGUI/Storage/Image.pm +++ b/lib/WebGUI/Storage/Image.pm @@ -68,7 +68,7 @@ sub addFileFromCaptcha { $image->Set(size=>'105x26'); $image->ReadImage('xc:white'); $image->AddNoise(noise=>"Multiplicative"); - $image->Annotate(font=>$session{config}{webguiRoot}."/lib/default.ttf", pointsize=>30, skewY=>0, skewX=>0, gravity=>'center', fill=>'white', antialias=>'true', text=>$challenge); + $image->Annotate(font=>$self->session->config->getWebguiRoot."/lib/default.ttf", pointsize=>30, skewY=>0, skewX=>0, gravity=>'center', fill=>'white', antialias=>'true', text=>$challenge); $image->Blur(geometry=>"1"); $image->Set(type=>"Grayscale"); $image->Border(fill=>'black', width=>1, height=>1); @@ -96,19 +96,19 @@ The size in pixels of the thumbnail to be generated. If not specified the thumbn sub generateThumbnail { my $self = shift; my $filename = shift; - my $thumbnailSize = shift || $session{setting}{thumbnailSize}; + my $thumbnailSize = shift || $self->session->setting->get("thumbnailSize"); unless (defined $filename) { - WebGUI::ErrorHandler::error("Can't generate a thumbnail when you haven't specified a file."); + $self->session->errorHandler->error("Can't generate a thumbnail when you haven't specified a file."); return 0; } unless ($self->isImage($filename)) { - WebGUI::ErrorHandler::error("Can't generate a thumbnail for something that's not an image."); + $self->session->errorHandler->error("Can't generate a thumbnail for something that's not an image."); return 0; } my $image = Image::Magick->new; my $error = $image->Read($self->getPath($filename)); if ($error) { - WebGUI::ErrorHandler::error("Couldn't read image for thumbnail creation: ".$error); + $self->session->errorHandler->error("Couldn't read image for thumbnail creation: ".$error); return 0; } my ($x, $y) = $image->Get('width','height'); @@ -120,7 +120,7 @@ sub generateThumbnail { } $error = $image->Write($self->getPath.'/'.'thumb-'.$filename); if ($error) { - WebGUI::ErrorHandler::error("Couldn't create thumbnail: ".$error); + $self->session->errorHandler->error("Couldn't create thumbnail: ".$error); return 0; } return 1; @@ -161,17 +161,17 @@ sub getSizeInPixels { my $self = shift; my $filename = shift; unless (defined $filename) { - WebGUI::ErrorHandler::error("Can't check the size when you haven't specified a file."); + $self->session->errorHandler->error("Can't check the size when you haven't specified a file."); return 0; } unless ($self->isImage($filename)) { - WebGUI::ErrorHandler::error("Can't check the size of something that's not an image."); + $self->session->errorHandler->error("Can't check the size of something that's not an image."); return 0; } my $image = Image::Magick->new; my $error = $image->Read($self->getPath($filename)); if ($error) { - WebGUI::ErrorHandler::error("Couldn't read image to check the size of it: ".$error); + $self->session->errorHandler->error("Couldn't read image to check the size of it: ".$error); return 0; } return $image->Get('width','height'); @@ -241,21 +241,21 @@ sub resize { my $width = shift; my $height = shift; unless (defined $filename) { - WebGUI::ErrorHandler::error("Can't resize when you haven't specified a file."); + $self->session->errorHandler->error("Can't resize when you haven't specified a file."); return 0; } unless ($self->isImage($filename)) { - WebGUI::ErrorHandler::error("Can't resize something that's not an image."); + $self->session->errorHandler->error("Can't resize something that's not an image."); return 0; } unless ($width || $height) { - WebGUI::ErrorHandler::error("Can't resize with no resizing parameters."); + $self->session->errorHandler->error("Can't resize with no resizing parameters."); return 0; } my $image = Image::Magick->new; my $error = $image->Read($self->getPath($filename)); if ($error) { - WebGUI::ErrorHandler::error("Couldn't read image for resizing: ".$error); + $self->session->errorHandler->error("Couldn't read image for resizing: ".$error); return 0; } my ($x, $y) = $image->Get('width','height'); @@ -267,7 +267,7 @@ sub resize { $image->Scale(width=>$width, height=>$height); $error = $image->Write($self->getPath($filename)); if ($error) { - WebGUI::ErrorHandler::error("Couldn't create thumbnail: ".$error); + $self->session->errorHandler->error("Couldn't create thumbnail: ".$error); return 0; } return 1; diff --git a/lib/WebGUI/Subscription.pm b/lib/WebGUI/Subscription.pm index 05b7808f2..5c1dbb3e1 100644 --- a/lib/WebGUI/Subscription.pm +++ b/lib/WebGUI/Subscription.pm @@ -58,7 +58,7 @@ specified by the session variable. sub apply { my ($self, $userId, $groupId); $self = shift; - $userId = shift || $session{user}{userId}; + $userId = shift || $self->session->user->profileField("userId"); $groupId = $self->{_properties}{subscriptionGroup}; # Make user part of the right group @@ -69,7 +69,7 @@ sub apply { # Process executeOnPurchase field my $command = $self->{_properties}{executeOnSubscription}; - WebGUI::Macro::process(\$command); + WebGUI::Macro::process($self->session,\$command); system($command) if ($self->{_properties}{executeOnSubscription} ne ""); } @@ -86,7 +86,7 @@ sub delete { my ($self); $self = shift; - WebGUI::SQL->write("update subscription set deleted=1 where subscriptionId=".quote($self->{_subscriptionId})); + $self->session->db->write("update subscription set deleted=1 where subscriptionId=".$self->session->db->quote($self->{_subscriptionId})); $self->{_properties}{deleted} = 1; } @@ -131,10 +131,10 @@ sub new { if ($subscriptionId eq 'new') { $subscriptionId = WebGUI::Id::generate; - WebGUI::SQL->write("insert into subscription (subscriptionId) values (".quote($subscriptionId).")"); + $self->session->db->write("insert into subscription (subscriptionId) values (".$self->session->db->quote($subscriptionId).")"); } - %properties = WebGUI::SQL->quickHash("select * from subscription where subscriptionId=".quote($subscriptionId)); + %properties = $self->session->db->quickHash("select * from subscription where subscriptionId=".$self->session->db->quote($subscriptionId)); bless {_subscriptionId => $subscriptionId, _properties => \%properties}, $class; } @@ -169,9 +169,9 @@ sub set { } } - WebGUI::SQL->write("update subscription set ". - join(',', map {"$_=".quote($properties->{$_})} @fieldsToUpdate). - " where subscriptionId=".quote($self->{_subscriptionId})); + $self->session->db->write("update subscription set ". + join(',', map {"$_=".$self->session->db->quote($properties->{$_})} @fieldsToUpdate). + " where subscriptionId=".$self->session->db->quote($self->{_subscriptionId})); } 1; diff --git a/lib/WebGUI/TabForm.pm b/lib/WebGUI/TabForm.pm index ce28c77f1..6fac7d5d6 100644 --- a/lib/WebGUI/TabForm.pm +++ b/lib/WebGUI/TabForm.pm @@ -191,8 +191,8 @@ A string containing the link to the tab-CascadingStyleSheet sub new { my $class = shift; my $startingTabs = shift; - my $css = shift || $session{config}{extrasURL}.'/tabs/tabs.css'; - my $cancelUrl = shift || WebGUI::URL::page(); + my $css = shift || $self->session->config->get("extrasURL").'/tabs/tabs.css'; + my $cancelUrl = shift || $self->session->url->page(); my $uiLevelOverride = shift; my %tabs; tie %tabs, 'Tie::IxHash'; @@ -219,8 +219,8 @@ Returns an HTML string with all the necessary components to draw the tab form. sub print { my $self = shift; - WebGUI::Style::setScript($session{config}{extrasURL}.'/tabs/tabs.js',{type=>"text/javascript"}); - WebGUI::Style::setLink($self->{_css},{rel=>"stylesheet", rev=>"stylesheet",type=>"text/css"}); + $self->session->style->setScript($self->session->config->get("extrasURL").'/tabs/tabs.js',{type=>"text/javascript"}); + $self->session->style->setLink($self->{_css},{rel=>"stylesheet", rev=>"stylesheet",type=>"text/css"}); my $output = $self->{_form}; $output .= $self->{_hidden}; my $i = 1; @@ -228,7 +228,7 @@ sub print { my $form; foreach my $key (keys %{$self->{_tab}}) { $tabs .= '{_tab}->{$key}{uiLevel} > $session{user}{uiLevel}) { + if ($self->{_tab}->{$key}{uiLevel} > $self->session->user->profileField("uiLevel")) { $tabs .= 'style="display: none;"'; } $tabs .= '>'.$self->{_tab}{$key}{label}.' '; @@ -241,7 +241,7 @@ sub print { $output .= $form; $output .= WebGUI::Form::formFooter(); $output .= ''; - $output .= ''; + $output .= ''; return $output; } diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 3754854b5..9e1398f1c 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -55,7 +55,7 @@ These methods are available from this class: #------------------------------------------------------------------- sub _create { my $userId = shift || WebGUI::Id::generate(); - WebGUI::SQL->write("insert into users (userId,dateCreated) values (".quote($userId).",".time().")"); + $self->session->db->write("insert into users (userId,dateCreated) values (".$self->session->db->quote($userId).",".time().")"); require WebGUI::Grouping; WebGUI::Grouping::addUsersToGroups([$userId],[2,7]); return $userId; @@ -106,8 +106,8 @@ sub authMethod { $self->uncache; $self->{_user}{"authMethod"} = $value; $self->{_user}{"lastUpdated"} = time(); - WebGUI::SQL->write("update users set authMethod=".quote($value).", - lastUpdated=".time()." where userId=".quote($self->{_userId})); + $self->session->db->write("update users set authMethod=".$self->session->db->quote($value).", + lastUpdated=".time()." where userId=".$self->session->db->quote($self->{_userId})); } return $self->{_user}{"authMethod"}; } @@ -136,15 +136,15 @@ sub delete { my $self = shift; $self->uncache; require WebGUI::Operation::Auth; - WebGUI::SQL->write("delete from users where userId=".quote($self->{_userId})); - WebGUI::SQL->write("delete from userProfileData where userId=".quote($self->{_userId})); + $self->session->db->write("delete from users where userId=".$self->session->db->quote($self->{_userId})); + $self->session->db->write("delete from userProfileData where userId=".$self->session->db->quote($self->{_userId})); require WebGUI::Grouping; WebGUI::Grouping::deleteUsersFromGroups([$self->{_userId}],WebGUI::Grouping::getGroupsForUser($self->{_userId})); - WebGUI::SQL->write("delete from messageLog where userId=".quote($self->{_userId})); + $self->session->db->write("delete from messageLog where userId=".$self->session->db->quote($self->{_userId})); my $authMethod = WebGUI::Operation::Auth::getInstance($self->authMethod,$self->{_userId}); $authMethod->deleteParams($self->{_userId}); - my $sth = WebGUI::SQL->read("select sessionId from userSession where userId=".quote($self->{_userId})); + my $sth = $self->session->db->read("select sessionId from userSession where userId=".$self->session->db->quote($self->{_userId})); while (my ($sid) = $sth->array) { WebGUI::Session::end($sid); } @@ -180,8 +180,8 @@ sub identifier { if (defined $value) { $self->uncache; $self->{_user}{"identifier"} = $value; - WebGUI::SQL->write("update authentication set fieldData=".quote($value)." - where userId=".quote($self->{_userId})." and authMethod='WebGUI' and fieldName='identifier'"); + $self->session->db->write("update authentication set fieldData=".$self->session->db->quote($value)." + where userId=".$self->session->db->quote($self->{_userId})." and authMethod='WebGUI' and fieldName='identifier'"); } return $self->{_user}{"identifier"}; } @@ -214,8 +214,8 @@ sub karma { if (defined $amount && defined $source && defined $description) { $self->uncache; $self->{_user}{karma} += $amount; - WebGUI::SQL->write("update users set karma=karma+".quote($amount)." where userId=".quote($self->userId)); - WebGUI::SQL->write("insert into karmaLog values (".quote($self->userId).",$amount,".quote($source).",".quote($description).",".time().")"); + $self->session->db->write("update users set karma=karma+".$self->session->db->quote($amount)." where userId=".$self->session->db->quote($self->userId)); + $self->session->db->write("insert into karmaLog values (".$self->session->db->quote($self->userId).",$amount,".$self->session->db->quote($source).",".$self->session->db->quote($description).",".time().")"); } return $self->{_user}{karma}; } @@ -253,16 +253,16 @@ sub new { my $userId = shift || 1; my $overrideId = shift; $userId = _create($overrideId) if ($userId eq "new"); - my $cache = WebGUI::Cache->new(["user",$userId]); + my $cache = WebGUI::Cache->new($self->session,["user",$userId]); my $userData = $cache->get; unless ($userData->{_userId} && $userData->{_user}{username}) { my %user; tie %user, 'Tie::CPHash'; - %user = WebGUI::SQL->quickHash("select * from users where userId=".quote($userId)); - my %profile = WebGUI::SQL->buildHash("select userProfileField.fieldName, userProfileData.fieldData + %user = $self->session->db->quickHash("select * from users where userId=".$self->session->db->quote($userId)); + my %profile = $self->session->db->buildHash("select userProfileField.fieldName, userProfileData.fieldData from userProfileField, userProfileData where userProfileField.fieldName=userProfileData.fieldName and - userProfileData.userId=".quote($user{userId})); - my %default = WebGUI::SQL->buildHash("select fieldName, dataDefault from userProfileField"); + userProfileData.userId=".$self->session->db->quote($user{userId})); + my %default = $self->session->db->buildHash("select fieldName, dataDefault from userProfileField"); foreach my $key (keys %default) { my $value; if ($profile{$key} eq "" && $default{$key}) { @@ -309,10 +309,10 @@ sub profileField { if (defined $value) { $self->uncache; $self->{_profile}{$fieldName} = $value; - WebGUI::SQL->write("delete from userProfileData where userId=".quote($self->{_userId})." and fieldName=".quote($fieldName)); - WebGUI::SQL->write("insert into userProfileData values (".quote($self->{_userId}).", ".quote($fieldName).", ".quote($value).")"); + $self->session->db->write("delete from userProfileData where userId=".$self->session->db->quote($self->{_userId})." and fieldName=".$self->session->db->quote($fieldName)); + $self->session->db->write("insert into userProfileData values (".$self->session->db->quote($self->{_userId}).", ".$self->session->db->quote($fieldName).", ".$self->session->db->quote($value).")"); $self->{_user}{"lastUpdated"} = time(); - WebGUI::SQL->write("update users set lastUpdated=".time()." where userId=".quote($self->{_userId})); + $self->session->db->write("update users set lastUpdated=".time()." where userId=".$self->session->db->quote($self->{_userId})); } return $self->{_profile}{$fieldName}; } @@ -336,8 +336,8 @@ sub referringAffiliate { $self->uncache; $self->{_user}{"referringAffiliate"} = $value; $self->{_user}{"lastUpdated"} = time(); - WebGUI::SQL->write("update users set referringAffiliate=".quote($value).", - lastUpdated=".time()." where userId=".quote($self->userId)); + $self->session->db->write("update users set referringAffiliate=".$self->session->db->quote($value).", + lastUpdated=".time()." where userId=".$self->session->db->quote($self->userId)); } return $self->{_user}{"referringAffiliate"}; } @@ -361,8 +361,8 @@ sub status { $self->uncache; $self->{_user}{"status"} = $value; $self->{_user}{"lastUpdated"} = time(); - WebGUI::SQL->write("update users set status=".quote($value).", - lastUpdated=".time()." where userId=".quote($self->userId)); + $self->session->db->write("update users set status=".$self->session->db->quote($value).", + lastUpdated=".time()." where userId=".$self->session->db->quote($self->userId)); } return $self->{_user}{"status"}; } @@ -377,7 +377,7 @@ Deletes this user object out of the cache. sub uncache { my $self = shift; - my $cache = WebGUI::Cache->new(["user",$self->userId]); + my $cache = WebGUI::Cache->new($self->session,["user",$self->userId]); $cache->delete; } @@ -400,8 +400,8 @@ sub username { $self->uncache; $self->{_user}{"username"} = $value; $self->{_user}{"lastUpdated"} = time(); - WebGUI::SQL->write("update users set username=".quote($value).", - lastUpdated=".time()." where userId=".quote($self->userId)); + $self->session->db->write("update users set username=".$self->session->db->quote($value).", + lastUpdated=".time()." where userId=".$self->session->db->quote($self->userId)); } return $self->{_user}{"username"}; } diff --git a/lib/WebGUI/i18n/English/Asset_Redirect.pm b/lib/WebGUI/i18n/English/Asset_Redirect.pm index bd63380fc..43bbd4ba1 100644 --- a/lib/WebGUI/i18n/English/Asset_Redirect.pm +++ b/lib/WebGUI/i18n/English/Asset_Redirect.pm @@ -2,6 +2,26 @@ package WebGUI::i18n::English::Asset_Redirect; our $I18N = { + 'what do you want to do with this redirect' => { + message => q|What do you want to do with this redirect?|, + lastUpdated => 0, + }, + + 'go to the redirect url' => { + message => q|Go to the redirect URL.|, + lastUpdated => 0, + }, + + 'edit the redirect properties' => { + message => q|Edit the redirect properties.|, + lastUpdated => 0, + }, + + 'go to the redirect parent page' => { + message => q|Go to the redirect's parent.|, + lastUpdated => 0, + }, + 'redirect url' => { message => q|Redirect URL|, lastUpdated => 1104719740, diff --git a/lib/WebGUI/i18n/English/Automated_Information.pm b/lib/WebGUI/i18n/English/Automated_Information.pm index d69865a8f..18e691107 100644 --- a/lib/WebGUI/i18n/English/Automated_Information.pm +++ b/lib/WebGUI/i18n/English/Automated_Information.pm @@ -7,15 +7,15 @@ use WebGUI::Session; use WebGUI::International; ##Get list of all macros by namespace/module name -my $dir = join '/', $session{config}{webguiRoot},"lib","WebGUI","Macro"; -opendir (DIR,$dir) or WebGUI::ErrorHandler::fatal("Can't open Macro directory: $dir!"); +my $dir = join '/', $self->session->config->getWebguiRoot,"lib","WebGUI","Macro"; +opendir (DIR,$dir) or $self->session->errorHandler->fatal("Can't open Macro directory: $dir!"); my @macros = map { s/Macro_//; s/\.pm//; $_; } grep { /\.pm$/ } readdir(DIR); ##list of namespaces closedir(DIR); ##Build list of enabled macros, by namespace by reversing session hash: -my %macros = reverse %{ $session{config}{macros} }; +my %macros = reverse %{ $self->session->config->get("macros") }; $macro_table = join "\n",