more session related changes

This commit is contained in:
JT Smith 2006-01-09 19:56:26 +00:00
parent 16b9675b0c
commit 024514c549
106 changed files with 1498 additions and 1313 deletions

View file

@ -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' {} \;

View file

@ -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;

View file

@ -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};
}
#-------------------------------------------------------------------

View file

@ -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"));
}
}

View file

@ -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=>'<p><a href="'.WebGUI::URL::page("func=editMetaDataField;fid=new").'">'.
-value=>'<p><a href="'.$self->session->url->page("func=editMetaDataField;fid=new").'">'.
WebGUI::International::get('Add new field','Asset').
'</a></p>',
-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 '<script type="text/javascript">
//<![CDATA[
var contextMenu = new contextMenu_createWithImage("'.$self->getIcon(1).'","'.$self->getId.'","'.$self->getName.'");
@ -918,7 +918,7 @@ Returns the UI Level specified in the asset definition or from the config file i
sub getUiLevel {
my $self = shift;
my $definition = $self->definition;
return $session{config}{assetUiLevel}{$definition->[0]{className}} || $definition->[0]{uiLevel} || 1;
return $self->session->config->get("assetUiLevel"){$definition->[0]{className}} || $definition->[0]{uiLevel} || 1;
}
@ -940,9 +940,9 @@ sub getUrl {
my $self = shift;
my $params = shift;
my $url = $self->get("url");
$url = WebGUI::URL::gateway($url,$params);
$url = $self->session->url->gateway($url,$params);
if ($self->get("encryptPage")) {
$url = WebGUI::URL::getSiteURL().$url;
$url = $self->session->url->getSiteURL().$url;
$url =~ s/http:/https:/;
}
return $url;
@ -1014,8 +1014,8 @@ sub new {
my $revisionDate = shift || $assetRevision->{$assetId}{$session->scratch->get("versionTag")||'_'};
unless ($revisionDate) {
($revisionDate) = $session->db->quickArray("select max(revisionDate) from assetData where assetId="
.$session->db->quote($assetId)." and (status='approved' or status='archived' or tagId="
.$session->db->quote($session->scratch->get("versionTag")).")
.$session->db->$self->session->db->quote($assetId)." and (status='approved' or status='archived' or tagId="
.$session->db->$self->session->db->quote($session->scratch->get("versionTag")).")
group by assetData.assetId order by assetData.revisionDate");
$assetRevision->{$assetId}{$session->scratch->get("versionTag")||'_'} = $revisionDate;
$session->stow("assetRevision",$assetRevision);
@ -1030,7 +1030,7 @@ sub new {
}
$class = $className;
}
my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]);
my $cache = WebGUI::Cache->new($self->session,$session, ["asset",$assetId,$revisionDate]);
my $properties = $cache->get;
if (exists $properties->{assetId}) {
# got properties from cache
@ -1040,7 +1040,7 @@ sub new {
$sql .= " left join ".$definition->{tableName}." on asset.assetId="
.$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate;
}
$sql .= " where asset.assetId=".$session->db->quote($assetId);
$sql .= " where asset.assetId=".$session->db->$self->session->db->quote($assetId);
$properties = $session->db->quickHashRef($sql);
return undef unless (exists $properties->{assetId});
$cache->set($properties,60*60*24);
@ -1082,7 +1082,7 @@ sub newByDynamicClass {
my $assetClass = $session->stow->get("assetClass");
my $className = $assetClass->{$assetId};
unless ($className) {
($className) = $session->db->quickArray("select className from asset where assetId=".$session->db->quote($assetId));
($className) = $session->db->quickArray("select className from asset where assetId=".$session->db->$self->session->db->quote($assetId));
$assetClass->{$assetId} = $className;
$session->stow->set("assetClass",$assetClass);
}
@ -1161,7 +1161,7 @@ sub newByUrl {
left join
assetData on asset.assetId=assetData.assetId
where
assetData.url=".$session->db->quote($url)."
assetData.url=".$session->db->$self->session->db->quote($url)."
group by
assetData.assetId
");
@ -1189,10 +1189,10 @@ sub processPropertiesFromFormPost {
foreach my $definition (@{$self->definition}) {
foreach my $property (keys %{$definition->{properties}}) {
if ($definition->{properties}{$property}{noFormPost}) {
$data{$property} = $definition->{properties}{$property}{defaultValue} if $session{form}{assetId} eq "new";
$data{$property} = $definition->{properties}{$property}{defaultValue} if $self->session->form->process("assetId") eq "new";
next;
}
$data{$property} = WebGUI::FormProcessor::process(
$data{$property} = $self->session->form->process(
$property,
$definition->{properties}{$property}{fieldType},
$definition->{properties}{$property}{defaultValue}
@ -1211,9 +1211,9 @@ sub processPropertiesFromFormPost {
$data{url} =~ s/(.*)\..*/$1/;
$data{url} .= '/'.$data{menuTitle};
}
WebGUI::SQL->beginTransaction;
$self->session->db->beginTransaction;
$self->update(\%data);
WebGUI::SQL->commit;
$self->session->db->commit;
}
@ -1237,7 +1237,7 @@ sub processTemplate {
my $self = shift;
my $var = shift;
my $templateId = shift;
my $meta = $self->getMetaDataFields() if ($session{setting}{metaDataEnabled});
my $meta = $self->getMetaDataFields() if ($self->session->setting->get("metaDataEnabled"));
foreach my $field (keys %$meta) {
$var->{$meta->{$field}{fieldName}} = $meta->{$field}{value};
}
@ -1250,7 +1250,7 @@ sub processTemplate {
if (defined $template) {
return $template->process(\%vars);
} else {
WebGUI::ErrorHandler::error("Can't instantiate template $templateId for asset ".$self->getId);
$self->session->errorHandler->error("Can't instantiate template $templateId for asset ".$self->getId);
return "Error: Can't instantiate template ".$templateId;
}
}
@ -1266,9 +1266,9 @@ Sets an asset and it's descendants to a state of 'published' regardless of it's
sub publish {
my $self = shift;
my $assetIds = WebGUI::SQL->buildArrayRef("select assetId from asset where lineage like ".quote($self->get("lineage").'%'));
my $idList = quoteAndJoin($assetIds);
WebGUI::SQL->write("update asset set state='published', stateChangedBy=".quote($session{user}{userId}).", stateChanged=".time()." where assetId in (".$idList.")");
my $assetIds = $self->session->db->buildArrayRef("select assetId from asset where lineage like ".$self->session->db->quote($self->get("lineage").'%'));
my $idList = $self->session->db->quoteAndJoin($assetIds);
$self->session->db->write("update asset set state='published', stateChangedBy=".$self->session->db->quote($self->session->user->profileField("userId")).", stateChanged=".time()." where assetId in (".$idList.")");
my $cache = WebGUI::Cache->new;
foreach my $id (@{$assetIds}) {
# we do the purge directly cuz it's a lot faster than instantiating all these assets
@ -1291,7 +1291,7 @@ sub purgeCache {
delete $session{assetLineage};
delete $session{assetClass};
delete $session{assetRevision};
WebGUI::Cache->new(["asset",$self->getId,$self->get("revisionDate")])->deleteChunk(["asset",$self->getId]);
WebGUI::Cache->new($self->session,["asset",$self->getId,$self->get("revisionDate")])->deleteChunk(["asset",$self->getId]);
}
@ -1326,7 +1326,7 @@ sub setSize {
foreach my $key (keys %{$self->get}) {
$sizetest .= $self->get($key);
}
WebGUI::SQL->write("update assetData set assetSize=".(length($sizetest)+$extra)." where assetId=".quote($self->getId)." and revisionDate=".quote($self->get("revisionDate")));
$self->session->db->write("update assetData set assetSize=".(length($sizetest)+$extra)." where assetId=".$self->session->db->quote($self->getId)." and revisionDate=".$self->session->db->quote($self->get("revisionDate")));
$self->purgeCache;
}
@ -1374,10 +1374,10 @@ sub update {
$value = $self->$filter($value);
}
$self->{_properties}{$property} = $value;
push(@setPairs, $property."=".quote($value));
push(@setPairs, $property."=".$self->session->db->quote($value));
}
if (scalar(@setPairs) > 0) {
WebGUI::SQL->write("update ".$definition->{tableName}." set ".join(",",@setPairs)." where assetId=".quote($self->getId)." and revisionDate=".$self->get("revisionDate"));
$self->session->db->write("update ".$definition->{tableName}." set ".join(",",@setPairs)." where assetId=".$self->session->db->quote($self->getId)." and revisionDate=".$self->get("revisionDate"));
$self->setSize;
}
}
@ -1396,7 +1396,7 @@ Returns "".
sub view {
my $self = shift;
WebGUI::HTTP::setRedirect($self->getDefault->getUrl) if ($self->getId eq "PBasset000000000000001");
return $self->getToolbar if ($session{var}{adminOn});
return $self->getToolbar if ($self->session->var->get("adminOn"));
return undef;
}
@ -1411,9 +1411,9 @@ Adds a new Asset based upon the class of the current form. Returns the Asset cal
sub www_add {
my $self = shift;
my %prototypeProperties;
my $class = $session{form}{class};
my $class = $self->session->form->process("class");
unless ($class =~ m/^[A-Za-z0-9\:]+$/) {
WebGUI::ErrorHandler::security("tried to call an invalid class ".$class);
$self->session->errorHandler->security("tried to call an invalid class ".$class);
return "";
}
if ($session{form}{'prototype'}) {
@ -1440,7 +1440,7 @@ sub www_add {
className=>$class,
assetId=>"new"
);
$properties{isHidden} = 1 unless (WebGUI::Utility::isIn($class, @{$session{config}{assetContainers}}));
$properties{isHidden} = 1 unless (WebGUI::Utility::isIn($class, @{$self->session->config->get("assetContainers")}));
my $newAsset = WebGUI::Asset->newByPropertyHashRef($self->session,\%properties);
$newAsset->{_parent} = $self;
return WebGUI::Privilege::insufficient() unless ($newAsset->canAdd);
@ -1491,11 +1491,11 @@ sub www_editSave {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
my $object;
unless($session{setting}{autoCommit} || $session{scratch}{versionTag}) {
unless($self->session->setting->get("autoCommit") || $self->session->scratch->get("versionTag")) {
$self->addVersionTag;
}
if ($session{form}{assetId} eq "new") {
$object = $self->addChild({className=>$session{form}{class}});
if ($self->session->form->process("assetId") eq "new") {
$object = $self->addChild({className=>$self->session->form->process("class")});
$object->{_parent} = $self;
} else {
if ($self->canEditIfLocked || !$self->isLocked) {
@ -1506,21 +1506,21 @@ sub www_editSave {
}
$object->processPropertiesFromFormPost;
$object->updateHistory("edited");
if ($session{form}{proceed} eq "manageAssets") {
$session{asset} = $object->getParent;
return $session{asset}->www_manageAssets;
if ($self->session->form->process("proceed") eq "manageAssets") {
$self->session->asset = $object->getParent;
return $self->session->asset->www_manageAssets;
}
if ($session{form}{proceed} eq "viewParent") {
$session{asset} = $object->getParent;
return $session{asset}->www_view;
if ($self->session->form->process("proceed") eq "viewParent") {
$self->session->asset = $object->getParent;
return $self->session->asset->www_view;
}
if ($session{form}{proceed} ne "") {
my $method = "www_".$session{form}{proceed};
$session{asset} = $object;
return $session{asset}->$method();
if ($self->session->form->process("proceed") ne "") {
my $method = "www_".$self->session->form->process("proceed");
$self->session->asset = $object;
return $self->session->asset->$method();
}
$session{asset} = $object->getContainer;
return $session{asset}->www_view;
$self->session->asset = $object->getContainer;
return $self->session->asset->www_view;
}
@ -1535,10 +1535,10 @@ Main page to manage assets. Renders an AdminConsole with a list of assets. If ca
sub www_manageAssets {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
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"});
WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/assetManager.js', {type=>"text/javascript"});
$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"});
$self->session->style->setLink($self->session->config->get("extrasURL").'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->config->get("extrasURL").'/assetManager/assetManager.js', {type=>"text/javascript"});
my $i18n = WebGUI::International->new("Asset");
my $ancestors = $self->getLineage(["self","ancestors"],{returnObjects=>1});
my @crumbtrail;
@ -1557,7 +1557,7 @@ sub www_manageAssets {
assetManager.AddColumn('".$i18n->get("type")."','','left','');
assetManager.AddColumn('".$i18n->get("last updated")."','','center','');
assetManager.AddColumn('".$i18n->get("size")."','','right','');\n";
$output .= "assetManager.AddColumn('".$i18n->get("locked")."','','center','');\n" unless ($session{setting}{autoCommit});
$output .= "assetManager.AddColumn('".$i18n->get("locked")."','','center','');\n" unless ($self->session->setting->get("autoCommit"));
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1})}) {
my $commit = 'contextMenu.addLink("'.$child->getUrl("func=commitRevision").'","'.$i18n->get("commit").'");' if ($child->canEditIfLocked);
$output .= 'var contextMenu = new contextMenu_createWithLink("'.$child->getId.'","More");
@ -1571,13 +1571,13 @@ sub www_manageAssets {
my $locked;
my $edit;
if ($child->isLocked) {
$locked = '<img src="'.$session{config}{extrasURL}.'/assetManager/locked.gif" alt="locked" border="0" />';
$edit = "'<a href=\"".$child->getUrl("func=edit;proceed=manageAssets")."\">Edit<\\/a> | '+" if ($child->canEditIfLocked && $session{scratch}{versionTag} eq $self->get("tagId"));
$locked = '<img src="'.$self->session->config->get("extrasURL").'/assetManager/locked.gif" alt="locked" border="0" />';
$edit = "'<a href=\"".$child->getUrl("func=edit;proceed=manageAssets")."\">Edit<\\/a> | '+" if ($child->canEditIfLocked && $self->session->scratch->get("versionTag") eq $self->get("tagId"));
} else {
$edit = "'<a href=\"".$child->getUrl("func=edit;proceed=manageAssets")."\">Edit<\\/a> | '+";
$locked = '<img src="'.$session{config}{extrasURL}.'/assetManager/unlocked.gif" alt="unlocked" border="0" />';
$locked = '<img src="'.$self->session->config->get("extrasURL").'/assetManager/unlocked.gif" alt="unlocked" border="0" />';
}
my $lockLink = ", '<a href=\"".$child->getUrl("func=manageRevisions")."\">".$locked."<\\/a>'" unless ($session{setting}{autoCommit});
my $lockLink = ", '<a href=\"".$child->getUrl("func=manageRevisions")."\">".$locked."<\\/a>'" unless ($self->session->setting->get("autoCommit"));
$output .= "assetManager.AddLine('"
.WebGUI::Form::checkbox({
name=>'assetId',

View file

@ -700,8 +700,8 @@ sub processPropertiesFromFormPost {
}
$self->session->form->process("proceed") = "redirectToParent";
# clear some cache
WebGUI::Cache->new("wobject_".$self->getThread->getParent->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Cache->new("cspost_".($self->getParent->getId)."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_1")->delete;
WebGUI::Cache->new($self->session,"wobject_".$self->getThread->getParent->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Cache->new($self->session,"cspost_".($self->getParent->getId)."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_1")->delete;
}

View file

@ -549,7 +549,7 @@ Subscribes the user to this thread.
sub subscribe {
my $self = shift;
$self->createSubscriptionGroup;
WebGUI::Cache->new("cspost_".$self->getId."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"))->delete;
WebGUI::Cache->new($self->session,"cspost_".$self->getId."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"))->delete;
WebGUI::Grouping::addUsersToGroups([$self->session->user->profileField("userId")],[$self->get("subscriptionGroupId")]);
}
@ -609,7 +609,7 @@ Negates the subscribe method.
sub unsubscribe {
my $self = shift;
WebGUI::Cache->new("cspost_".$self->getId."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"))->delete;
WebGUI::Cache->new($self->session,"cspost_".$self->getId."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"))->delete;
WebGUI::Grouping::deleteUsersFromGroups([$self->session->user->profileField("userId")],[$self->get("subscriptionGroupId")]);
}
@ -804,7 +804,7 @@ sub www_view {
not $self->session->var->get("adminOn")
);
if ($useCache) {
$cache = WebGUI::Cache->new("cspost_".($postId||$self->getId)."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"));
$cache = WebGUI::Cache->new($self->session,"cspost_".($postId||$self->getId)."_".$self->session->user->profileField("userId")."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn"));
$output = $cache->get;
}
unless ($output) {

View file

@ -115,17 +115,22 @@ A web executable method that redirects the user to the specified page, or displa
=cut
sub www_view {
my $self = shift;
return WebGUI::Privilege::noAccess() unless $self->canView;
if ($self->session->var->get("adminOn")) {
return $self->getContainer->www_view;
}
my $url = $self->get("redirectUrl");
WebGUI::Macro::process(\$url);
WebGUI::HTTP::setRedirect($url) unless $self->get("redirectUrl") eq $self->get("url");
return "Redirect is self-referential";
my $self = shift;
return WebGUI::Privilege::noAccess() unless $self->canView;
if ($self->session->var->isAdminOn() && $self->canEdit) {
my $i18n = WebGUI::International->new("Asset_Redirect");
return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").'
<ul>
<li><a href="'.$self->get("redirectUrl").'">'.$i18n->get("go to the redirect url").'</a></li>
<li><a href="'.$self->getUrl("func=edit").'">'.$i18n->get("edit the redirect properties").'</a></li>
<li><a href="'.$self->getParent->getUrl.'">'.$i18n->get("go to the redirect parent page").'</a></li>
</ul>',$i18n->get("assetName"));
}
my $url = $self->get("redirectUrl");
WebGUI::Macro::process(\$url);
$self->session->http->setRedirect($url) unless $self->get("redirectUrl") eq $self->get("url");
return "Redirect is self-referential";
}
1;

View file

@ -133,7 +133,7 @@ sub _submenu {
my $workarea = shift;
my $title = shift;
my $help = shift;
my $ac = WebGUI::AdminConsole->new("shortcutmanager");
my $ac = WebGUI::AdminConsole->new($self->session,"shortcutmanager");
$ac->setHelp($help) if ($help);
$ac->setIcon($self->getIcon);
$ac->addSubmenuItem($self->getUrl('func=edit'), WebGUI::International::get("Back to Edit Shortcut","Asset_Shortcut"));
@ -376,7 +376,7 @@ sub getOverrides {
my $self = shift;
my $i = 0;
#cache by userId, assetId of this shortcut, and whether adminMode is on or not.
my $cache = WebGUI::Cache->new(["shortcutOverrides",$self->getId,$self->session->user->profileField("userId"),$self->session->var->get("adminOn")]);
my $cache = WebGUI::Cache->new($self->session,["shortcutOverrides",$self->getId,$self->session->user->profileField("userId"),$self->session->var->get("adminOn")]);
my $overridesRef = $cache->get;
unless ($overridesRef->{cacheNotExpired}) {
my %overrides;
@ -456,7 +456,7 @@ sub getShortcutByCriteria {
my $assetId = $self->getId;
# Parse macro's in criteria
WebGUI::Macro::process(\$criteria);
WebGUI::Macro::process($self->session,\$criteria);
# Once a asset is found, we will stick to that asset,
# to prevent the proxying of multiple- depth assets like Surveys and USS.
@ -595,7 +595,7 @@ sub processPropertiesFromFormPost {
sub uncacheOverrides {
my $self = shift;
WebGUI::Cache->new(["shortcutOverrides",$self->getId])->delete;
WebGUI::Cache->new($self->session,["shortcutOverrides",$self->getId])->delete;
}
#-------------------------------------------------------------------

View file

@ -149,7 +149,7 @@ sub view {
my $self = shift;
my $calledAsWebMethod = shift;
my $output = $self->get("snippet");
WebGUI::Macro::process(\$output);
WebGUI::Macro::process($self->session,\$output);
$output = '<p>'.$self->getToolbar.'</p>'.$output if ($self->session->var->get("adminOn") && !$calledAsWebMethod);
return $output unless ($self->getValue("processAsTemplate"));
return WebGUI::Asset::Template->processRaw($output);

View file

@ -137,7 +137,7 @@ Deletes the rendered page cache for this wobject.
sub deletePageCache {
my $self = shift;
WebGUI::Cache->new("wobject_".$self->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Cache->new($self->session,"wobject_".$self->getId."_".$self->session->user->profileField("userId"))->delete;
}
#-------------------------------------------------------------------
@ -604,7 +604,7 @@ sub www_view {
&& !( $self->session->var->get("adminOn") || $disableCache)
);
if ($useCache) {
$cache = WebGUI::Cache->new("wobject_".$self->getId."_".$self->session->user->profileField("userId"));
$cache = WebGUI::Cache->new($self->session,"wobject_".$self->getId."_".$self->session->user->profileField("userId"));
$output = $cache->get;
}
unless ($output) {

View file

@ -870,7 +870,7 @@ Subscribes a user to this collaboration system.
sub subscribe {
my $self = shift;
WebGUI::Cache->new("wobject_".$self->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Cache->new($self->session,"wobject_".$self->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Grouping::addUsersToGroups([$self->session->user->profileField("userId")],[$self->get("subscriptionGroupId")]);
}
@ -884,7 +884,7 @@ Unsubscribes a user from this collaboration system
sub unsubscribe {
my $self = shift;
WebGUI::Cache->new("wobject_".$self->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Cache->new($self->session,"wobject_".$self->getId."_".$self->session->user->profileField("userId"))->delete;
WebGUI::Grouping::deleteUsersFromGroups([$self->session->user->profileField("userId")],[$self->get("subscriptionGroupId")]);
}
@ -1193,7 +1193,7 @@ sub www_viewRSS {
WebGUI::HTTP::setMimeType("text/xml");
my $output = $self->processTemplate(\%var,$self->get("rssTemplateId"));
WebGUI::Macro::process(\$output);
WebGUI::Macro::process($self->session,\$output);
return $output;
}

View file

@ -419,7 +419,7 @@ sub getRecordTemplateVars {
}
if (not exists $data{value}) {
my $defaultValue = $data{defaultValue};
WebGUI::Macro::process(\$defaultValue);
WebGUI::Macro::process($self->session,\$defaultValue);
$data{value} = $defaultValue;
}
my $hidden = (($data{status} eq "hidden" && !$self->session->var->get("adminOn")) || ($data{isMailField} && !$self->get("mailData")));
@ -463,7 +463,7 @@ sub getRecordTemplateVars {
}
if (not exists $data{value}) {
my $defaultValue = $data{defaultValue};
WebGUI::Macro::process(\$defaultValue);
WebGUI::Macro::process($self->session,\$defaultValue);
$data{value} = $defaultValue;
}
my $hidden = (($data{status} eq "hidden" && !$self->session->var->get("adminOn")) || ($data{isMailField} && !$self->get("mailData")));
@ -579,7 +579,7 @@ sub sendEmail {
my $self = shift;
my $var = shift;
my $message = $self->processTemplate($var,$self->get("emailTemplateId"));
WebGUI::Macro::process(\$message);
WebGUI::Macro::process($self->session,\$message);
my ($to, $subject, $from, $bcc, $cc);
foreach my $row (@{$var->{field_loop}}) {
if ($row->{"field.name"} eq "to") {
@ -1057,7 +1057,7 @@ sub www_process {
}
if ($row{status} eq "hidden") {
$value = $row{defaultValue};
WebGUI::Macro::process(\$value);
WebGUI::Macro::process($self->session,\$value);
}
unless ($hadErrors) {
my ($exists) = $self->session->db->quickArray("select count(*) from DataForm_entryData where DataForm_entryId=".$self->session->db->quote($entryId)."

View file

@ -200,8 +200,8 @@ sub view {
return $self->processTemplate({},$self->get("templateId")) unless ($proxiedUrl ne "");
my $cachedContent = WebGUI::Cache->new($proxiedUrl,"URL");
my $cachedHeader = WebGUI::Cache->new($proxiedUrl,"HEADER");
my $cachedContent = WebGUI::Cache->new($self->session,$proxiedUrl,"URL");
my $cachedHeader = WebGUI::Cache->new($self->session,$proxiedUrl,"HEADER");
$var{header} = $cachedHeader->get;
$var{content} = $cachedContent->get;
unless ($var{content} && $self->session->env->get("REQUEST_METHOD")=~/GET/i) {

View file

@ -483,7 +483,7 @@ sub www_preview {
) . $nav->build . qq(</td></tr></table>);
# Because of the way the system is set up, the preview is cached. So let's remove it again...
WebGUI::Cache->new($nav->{_identifier}."$session{page}{pageId}", "Navigation-".$self->session->config->getFilename)->delete;
WebGUI::Cache->new($self->session,$nav->{_identifier}."$session{page}{pageId}", "Navigation-".$self->session->config->getFilename)->delete;
return _submenu($output,"preview");
}

View file

@ -293,7 +293,7 @@ sub _parsePlaceholderParams {
} elsif ($type =~ /^query(\d)/) {
$param = $self->{_query}{$1}{rowData}{$field};
}
WebGUI::Macro::process(\$param);
WebGUI::Macro::process($self->session,\$param);
push(@placeholderParams, $param);
}
return \@placeholderParams;
@ -317,15 +317,15 @@ sub _processQuery {
# Preprocess macros
if ($self->{_query}{$nr}{preprocessMacros}) {
$query = $self->{_query}{$nr}{dbQuery};
WebGUI::Macro::process(\$query);
WebGUI::Macro::process($self->session,\$query);
} else {
$query = $self->{_query}{$nr}{dbQuery};
}
push(@{$self->{_debug_loop}},{'debug.output'=>WebGUI::International::get(17,"Asset_SQLReport").$query});
push(@{$self->{_debug_loop}},{'debug.output'=>WebGUI::International::get('debug placeholder parameters',"Asset_SQLReport").join(",",@$placeholderParams)});
my $dbLink = WebGUI::DatabaseLink->new($self->{_query}{$nr}{databaseLinkId});
my $dbh = $dbLink->dbh;
my $dbLink = WebGUI::DatabaseLink->new($self->session,$self->{_query}{$nr}{databaseLinkId});
my $dbh = $dbLink->db;
if (defined $dbh) {
if ($query =~ /^select/i || $query =~ /^show/i || $query =~ /^describe/i) {
my $url = $self->getUrl('func=view');

View file

@ -242,7 +242,7 @@ sub _submenu {
my $workarea = shift;
my $title = shift;
my $help = shift;
my $ac = WebGUI::AdminConsole->new("editstocks");
my $ac = WebGUI::AdminConsole->new($self->session,"editstocks");
$ac->setHelp($help) if ($help);
$ac->setIcon($self->getIcon);
return $ac->render($workarea, $title);

View file

@ -238,7 +238,7 @@ sub _normalize_items {
sub _get_rss_data {
my $url = shift;
my $cache = WebGUI::Cache->new('url:' . $url, 'RSS');
my $cache = WebGUI::Cache->new($self->session,'url:' . $url, 'RSS');
my $rss_serial = $cache->get;
my $rss = {};
if ($rss_serial) {
@ -320,7 +320,7 @@ sub _assign_rss_dates {
for my $item (@{$items}) {
my $key = 'dates:' . ($item->{guid} || $item->{title} ||
$item->{description} || $item->{link});
my $cache = WebGUI::Cache->new($key, 'RSS');
my $cache = WebGUI::Cache->new($self->session,$key, 'RSS');
if (my $date = $cache->get()) {
$item->{date} = $date;
} else {
@ -440,7 +440,7 @@ sub _get_items {
my $key=join(':',('aggregate', $displayMode,$hasTermsRegex,$maxHeadlines,$self->get('rssUrl')));
my $cache = WebGUI::Cache->new($key, 'RSS');
my $cache = WebGUI::Cache->new($self->session,$key, 'RSS');
my $items = Storable::thaw($cache->get());
my @rss_feeds;
if (!$items) {

View file

@ -268,9 +268,9 @@ sub view {
# snag our SOAP call and preprocess if needed
if ($self->get('preprocessMacros')) {
$call = $self->get("callMethod");
WebGUI::Macro::process(\$call);
WebGUI::Macro::process($self->session,\$call);
$param_str = $self->get("params");
WebGUI::Macro::process(\$param_str);
WebGUI::Macro::process($self->session,\$param_str);
} else {
$call = $self->get('callMethod');
$param_str = $self->get('params');
@ -310,7 +310,7 @@ sub view {
} else {
$cache_key = _create_cache_key($self, $call, $param_str);
}
$cache = WebGUI::Cache->new($cache_key,
$cache = WebGUI::Cache->new($self->session,$cache_key,
WebGUI::International::get(4, "Asset_WSClient"));
# passing a form param WSClient_skipCache lets us ignore even good caches

View file

@ -84,7 +84,7 @@ Accepts an array ref of locations, and returns
sub _getLocationData {
my $self = shift;
my $location = shift;
my $cache = WebGUI::Cache->new(["weatherLocation",$location]);
my $cache = WebGUI::Cache->new($self->session,["weatherLocation",$location]);
my $locData = $cache->get;
unless ($locData->{cityState}) {
my $oldagent;

View file

@ -95,7 +95,7 @@ Creates a tabform to edit the Asset Tree. If canEdit returns False, returns insu
sub www_editBranch {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("assets");
my $ac = WebGUI::AdminConsole->new($self->session,"assets");
return WebGUI::Privilege::insufficient() unless ($self->canEdit);
my $tabform = WebGUI::TabForm->new;
$tabform->hidden({name=>"func",value=>"editBranchSave"});
@ -158,7 +158,7 @@ sub www_editBranch {
-label=>WebGUI::International::get(1073,"Asset"),
-value=>$self->getValue("styleTemplateId"),
-namespace=>'style',
-afterEdit=>'op=editPage;npp='.$session{form}{npp},
-afterEdit=>'op=editPage;npp='.$self->session->form->process("npp"),
-subtext=>'<br />'.WebGUI::International::get("change","Asset").' '.WebGUI::Form::yesNo({name=>"change_styleTemplateId"})
);
$tabform->getTab("display")->template(
@ -166,7 +166,7 @@ sub www_editBranch {
-label=>WebGUI::International::get(1079,"Asset"),
-value=>$self->getValue("printableStyleTemplateId"),
-namespace=>'style',
-afterEdit=>'op=editPage;npp='.$session{form}{npp},
-afterEdit=>'op=editPage;npp='.$self->session->form->process("npp"),
-subtext=>'<br />'.WebGUI::International::get("change","Asset").' '.WebGUI::Form::yesNo({name=>"change_printableStyleTemplateId"})
);
$tabform->getTab("display")->interval(
@ -214,12 +214,12 @@ sub www_editBranch {
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,
@ -253,7 +253,7 @@ sub www_editBranch {
-uiLevel=>5,
-subtext=>'<br />'.WebGUI::International::get("change","Asset").' '.WebGUI::Form::yesNo({name=>"change_extraHeadTags"})
);
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";
@ -291,26 +291,26 @@ sub www_editBranchSave {
my $self = shift;
return WebGUI::Privilege::insufficient() unless ($self->canEdit);
my %data;
$data{isHidden} = WebGUI::FormProcessor::yesNo("isHidden") if (WebGUI::FormProcessor::yesNo("change_isHidden"));
$data{newWindow} = WebGUI::FormProcessor::yesNo("newWindow") if (WebGUI::FormProcessor::yesNo("change_newWindow"));
$data{displayTitle} = WebGUI::FormProcessor::yesNo("displayTitle") if (WebGUI::FormProcessor::yesNo("change_displayTitle"));
$data{styleTemplateId} = WebGUI::FormProcessor::template("styleTemplateId") if (WebGUI::FormProcessor::yesNo("change_styleTemplateId"));
$data{printableStyleTemplateId} = WebGUI::FormProcessor::template("printableStyleTemplateId") if (WebGUI::FormProcessor::yesNo("change_printableStyleTemplateId"));
$data{cacheTimeout} = WebGUI::FormProcessor::interval("cacheTimeout") if (WebGUI::FormProcessor::yesNo("change_cacheTimeout"));
$data{cacheTimeoutVisitor} = WebGUI::FormProcessor::interval("cacheTimeoutVisitor") if (WebGUI::FormProcessor::yesNo("change_cacheTimeoutVisitor"));
$data{encryptPage} = WebGUI::FormProcessor::yesNo("encryptPage") if (WebGUI::FormProcessor::yesNo("change_encryptPage"));
$data{startDate} = WebGUI::FormProcessor::dateTime("startDate") if (WebGUI::FormProcessor::yesNo("change_startDate"));
$data{endDate} = WebGUI::FormProcessor::dateTime("endDate") if (WebGUI::FormProcessor::yesNo("change_endDate"));
$data{ownerUserId} = WebGUI::FormProcessor::selectBox("ownerUserId") if (WebGUI::FormProcessor::yesNo("change_ownerUserId"));
$data{groupIdView} = WebGUI::FormProcessor::group("groupIdView") if (WebGUI::FormProcessor::yesNo("change_groupIdView"));
$data{groupIdEdit} = WebGUI::FormProcessor::group("groupIdEdit") if (WebGUI::FormProcessor::yesNo("change_groupIdEdit"));
$data{extraHeadTags} = WebGUI::FormProcessor::group("extraHeadTags") if (WebGUI::FormProcessor::yesNo("change_extraHeadTags"));
$data{isHidden} = $self->session->form->yesNo("isHidden") if ($self->session->form->yesNo("change_isHidden"));
$data{newWindow} = $self->session->form->yesNo("newWindow") if ($self->session->form->yesNo("change_newWindow"));
$data{displayTitle} = $self->session->form->yesNo("displayTitle") if ($self->session->form->yesNo("change_displayTitle"));
$data{styleTemplateId} = $self->session->form->template("styleTemplateId") if ($self->session->form->yesNo("change_styleTemplateId"));
$data{printableStyleTemplateId} = $self->session->form->template("printableStyleTemplateId") if ($self->session->form->yesNo("change_printableStyleTemplateId"));
$data{cacheTimeout} = $self->session->form->interval("cacheTimeout") if ($self->session->form->yesNo("change_cacheTimeout"));
$data{cacheTimeoutVisitor} = $self->session->form->interval("cacheTimeoutVisitor") if ($self->session->form->yesNo("change_cacheTimeoutVisitor"));
$data{encryptPage} = $self->session->form->yesNo("encryptPage") if ($self->session->form->yesNo("change_encryptPage"));
$data{startDate} = $self->session->form->dateTime("startDate") if ($self->session->form->yesNo("change_startDate"));
$data{endDate} = $self->session->form->dateTime("endDate") if ($self->session->form->yesNo("change_endDate"));
$data{ownerUserId} = $self->session->form->selectBox("ownerUserId") if ($self->session->form->yesNo("change_ownerUserId"));
$data{groupIdView} = $self->session->form->group("groupIdView") if ($self->session->form->yesNo("change_groupIdView"));
$data{groupIdEdit} = $self->session->form->group("groupIdEdit") if ($self->session->form->yesNo("change_groupIdEdit"));
$data{extraHeadTags} = $self->session->form->group("extraHeadTags") if ($self->session->form->yesNo("change_extraHeadTags"));
my ($urlBaseBy, $urlBase, $endOfUrl);
my $changeUrl = WebGUI::FormProcessor::yesNo("change_url");
my $changeUrl = $self->session->form->yesNo("change_url");
if ($changeUrl) {
$urlBaseBy = WebGUI::FormProcessor::selectBox("baseUrlBy");
$urlBase = WebGUI::FormProcessor::text("baseUrl");
$endOfUrl = WebGUI::FormProcessor::selectBox("endOfUrl");
$urlBaseBy = $self->session->form->selectBox("baseUrlBy");
$urlBase = $self->session->form->text("baseUrl");
$endOfUrl = $self->session->form->selectBox("endOfUrl");
}
my $descendants = $self->getLineage(["self","descendants"],{returnObjects=>1});
foreach my $descendant (@{$descendants}) {
@ -336,14 +336,14 @@ sub www_editBranchSave {
foreach my $form (keys %{$session{form}}) {
if ($form =~ /^metadata_(.*)$/) {
my $fieldName = $1;
if (WebGUI::FormProcessor::yesNo("change_metadata_".$fieldName)) {
if ($self->session->form->yesNo("change_metadata_".$fieldName)) {
$newRevision->updateMetaData($fieldName,$session{form}{$form});
}
}
}
}
delete $self->{_parent};
$session{asset} = $self->getParent;
$self->session->asset = $self->getParent;
return $self->getParent->www_manageAssets;
}

View file

@ -48,11 +48,11 @@ Removes asset from lineage, places it in clipboard state. The "gap" in the linea
sub cut {
my $self = shift;
return undef if ($self->getId eq $session{setting}{defaultPage} || $self->getId eq $session{setting}{notFoundPage});
WebGUI::SQL->beginTransaction;
WebGUI::SQL->write("update asset set state='clipboard-limbo' where lineage like ".quote($self->get("lineage").'%')." and state='published'");
WebGUI::SQL->write("update asset set state='clipboard', stateChangedBy=".quote($session{user}{userId}).", stateChanged=".time()." where assetId=".quote($self->getId));
WebGUI::SQL->commit;
return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage"));
$self->session->db->beginTransaction;
$self->session->db->write("update asset set state='clipboard-limbo' where lineage like ".$self->session->db->quote($self->get("lineage").'%')." and state='published'");
$self->session->db->write("update asset set state='clipboard', stateChangedBy=".$self->session->db->quote($self->session->user->profileField("userId")).", stateChanged=".time()." where assetId=".$self->session->db->quote($self->getId));
$self->session->db->commit;
$self->updateHistory("cut");
$self->{_properties}{state} = "clipboard";
$self->purgeCache;
@ -75,10 +75,10 @@ sub duplicate {
my $self = shift;
my $assetToDuplicate = shift || $self;
my $newAsset = $self->addChild($assetToDuplicate->get);
my $sth = WebGUI::SQL->read("select * from metaData_values where assetId = ".quote($assetToDuplicate->getId));
my $sth = $self->session->db->read("select * from metaData_values where assetId = ".$self->session->db->quote($assetToDuplicate->getId));
while( my $h = $sth->hashRef) {
WebGUI::SQL->write("insert into metaData_values (fieldId, assetId, value) values (".
quote($h->{fieldId}).",".quote($newAsset->getId).",".quote($h->{value}).")");
$self->session->db->write("insert into metaData_values (fieldId, assetId, value) values (".
$self->session->db->quote($h->{fieldId}).",".$self->session->db->quote($newAsset->getId).",".$self->session->db->quote($h->{value}).")");
}
$sth->finish;
return $newAsset;
@ -104,13 +104,13 @@ If not specified, uses current user.
sub getAssetsInClipboard {
my $self = shift;
my $limitToUser = shift;
my $userId = shift || $session{user}{userId};
my $userId = shift || $self->session->user->profileField("userId");
my @assets;
my $limit;
if ($limitToUser) {
$limit = "and asset.stateChangedBy=".quote($userId);
$limit = "and asset.stateChangedBy=".$self->session->db->quote($userId);
}
my $sth = WebGUI::SQL->read("
my $sth = $self->session->db->read("
select
asset.assetId,
assetData.revisionDate,
@ -188,7 +188,7 @@ Copies to clipboard assets in a list, then returns self calling method www_manag
sub www_copyList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $assetId ($session{req}->param("assetId")) {
foreach my $assetId ($self->session->request->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($assetId);
if ($asset->canEdit) {
my $newAsset = $asset->duplicate;
@ -196,8 +196,8 @@ sub www_copyList {
$newAsset->cut;
}
}
if ($session{form}{proceed} ne "") {
my $method = "www_".$session{form}{proceed};
if ($self->session->form->process("proceed") ne "") {
my $method = "www_".$self->session->form->process("proceed");
return $self->$method();
}
return $self->www_manageAssets();
@ -232,7 +232,7 @@ sub www_createShortcut () {
return $target->www_view;
} else {
$child->cut;
return $self->getContainer->www_manageAssets if ($session{form}{proceed} eq "manageAssets");
return $self->getContainer->www_manageAssets if ($self->session->form->process("proceed") eq "manageAssets");
return $self->getContainer->www_view;
}
}
@ -249,7 +249,7 @@ sub www_cut {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
$self->cut;
$session{asset} = $self->getParent;
$self->session->asset = $self->getParent;
return $self->getParent->www_view;
}
@ -264,14 +264,14 @@ Cuts assets in a list (removes to clipboard), then returns self calling method w
sub www_cutList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $assetId ($session{req}->param("assetId")) {
foreach my $assetId ($self->session->request->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($assetId);
if ($asset->canEdit) {
$asset->cut;
}
}
if ($session{form}{proceed} ne "") {
my $method = "www_".$session{form}{proceed};
if ($self->session->form->process("proceed") ne "") {
my $method = "www_".$self->session->form->process("proceed");
return $self->$method();
}
return $self->www_manageAssets();
@ -287,9 +287,9 @@ Moves assets in clipboard to trash. Returns www_manageClipboard() when finished.
sub www_emptyClipboard {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("clipboard");
my $ac = WebGUI::AdminConsole->new($self->session,"clipboard");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(4));
foreach my $asset (@{$self->getAssetsInClipboard(!($session{form}{systemClipboard} && WebGUI::Grouping::isInGroup(3)))}) {
foreach my $asset (@{$self->getAssetsInClipboard(!($self->session->form->process("systemClipboard") && WebGUI::Grouping::isInGroup(3)))}) {
$asset->trash;
}
return $self->www_manageClipboard();
@ -306,11 +306,11 @@ Returns an AdminConsole to deal with assets in the Clipboard. If isInGroup(12) i
sub www_manageClipboard {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("clipboard");
my $ac = WebGUI::AdminConsole->new($self->session,"clipboard");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(12));
my ($header,$limit);
$ac->setHelp("clipboard manage");
if ($session{form}{systemClipboard} && WebGUI::Grouping::isInGroup(3)) {
if ($self->session->form->process("systemClipboard") && WebGUI::Grouping::isInGroup(3)) {
$header = WebGUI::International::get(966,"Asset");
$ac->addSubmenuItem($self->getUrl('func=manageClipboard'), WebGUI::International::get(949,"Asset"));
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard;systemClipboard=1'), WebGUI::International::get(959,"Asset"),
@ -321,8 +321,8 @@ sub www_manageClipboard {
'onclick="return window.confirm(\''.WebGUI::International::get(951).'\')"',"Asset");
$limit = 1;
}
WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/assetManager.js', {type=>"text/javascript"});
$self->session->style->setLink($self->session->config->get("extrasURL").'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->config->get("extrasURL").'/assetManager/assetManager.js', {type=>"text/javascript"});
my $i18n = WebGUI::International->new("Asset");
my $output = "
<script type=\"text/javascript\">
@ -375,7 +375,7 @@ Returns "". Pastes an asset. If canEdit is False, returns an insufficient privil
sub www_paste {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
$self->paste($session{form}{assetId});
$self->paste($self->session->form->process("assetId"));
return "";
}
@ -390,7 +390,7 @@ Returns a www_manageAssets() method. Pastes a selection of assets. If canEdit is
sub www_pasteList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $clipId ($session{req}->param("assetId")) {
foreach my $clipId ($self->session->request->param("assetId")) {
$self->paste($clipId);
}
return $self->www_manageAssets();

View file

@ -46,16 +46,16 @@ Returns a descriptive error message (HTML) if the export path is not writable, d
sub checkExportPath {
my $error;
if(defined $session{config}{exportPath}) {
if(-d $session{config}{exportPath}) {
unless (-w $session{config}{exportPath}) {
$error .= 'Error: The export path '.$session{config}{exportPath}.' is not writable.<br />
if(defined $self->session->config->get("exportPath")) {
if(-d $self->session->config->get("exportPath")) {
unless (-w $self->session->config->get("exportPath")) {
$error .= 'Error: The export path '.$self->session->config->get("exportPath").' is not writable.<br />
Make sure that the webserver has permissions to write to that directory';
}
} else {
eval {mkpath($session{config}{exportPath},0)};
eval {mkpath($self->session->config->get("exportPath"),0)};
if ($@) {
$error .= 'Error: The export path '.$session{config}{exportPath}.' does not exist, and couldn\'t create it because '.$@;
$error .= 'Error: The export path '.$self->session->config->get("exportPath").' does not exist, and couldn\'t create it because '.$@;
}
}
} else {
@ -97,8 +97,8 @@ The unique id of the user to become when exporting this page. Defaults to '1' (V
sub exportAsHtml {
my $self = shift;
my $params = shift;
my $uploadsUrl = $params->{uploadsUrl} || $session{config}{uploadsUrl};
my $extrasUrl = $params->{extrasUrl} || $session{config}{extrasUrl};
my $uploadsUrl = $params->{uploadsUrl} || $self->session->config->get("uploadsUrl");
my $extrasUrl = $params->{extrasUrl} || $self->session->config->get("extrasUrl");
my $userId = $params->{userId} || 1;
my $stripHtml = $params->{stripHtml} || undef;
@ -106,13 +106,13 @@ sub exportAsHtml {
my %oldSession = %session;
# Change the stuff we need to change to do the export
$session->user({userId=>$userId}) unless ($userId == $session{user}{userId});
$session->user({userId=>$userId}) unless ($userId == $self->session->user->profileField("userId"));
delete $session{form};
$session{var}{adminOn} = $self->get('adminOn');
$self->session->var->get("adminOn") = $self->get('adminOn');
$self->WebGUI::Session::refreshPageInfo;
$self->{_properties}{cacheTimeout} = $self->{_properties}{cacheTimeoutVisitor} = 1;
$session{config}{uploadsURL} = $uploadsUrl;
$session{config}{extrasURL} = $extrasUrl;
$self->session->config->get("uploadsURL") = $uploadsUrl;
$self->session->config->get("extrasURL") = $extrasUrl;
# Generate the page
my $content = $self->www_view;
@ -154,7 +154,7 @@ sub www_export {
-label=>WebGUI::International::get('Export as user',"Asset"),
-hoverHelp=>WebGUI::International::get('Export as user description',"Asset"),
-name=>"userId",
-options=>WebGUI::SQL->buildHashRef("select userId, username from users"),
-options=>$self->session->db->buildHashRef("select userId, username from users"),
-value=>[1],
);
$f->text(
@ -167,13 +167,13 @@ sub www_export {
-label=>WebGUI::International::get('Extras URL',"Asset"),
-hoverHelp=>WebGUI::International::get('Extras URL description',"Asset"),
-name=>"extrasURL",
-value=>$session{config}{extrasURL}
-value=>$self->session->config->get("extrasURL")
);
$f->text(
-label=>WebGUI::International::get('Uploads URL',"Asset"),
-hoverHelp=>WebGUI::International::get('Uploads URL description',"Asset"),
-name=>"uploadsURL",
-value=>$session{config}{uploadsURL}
-value=>$self->session->config->get("uploadsURL")
);
$f->submit;
$self->getAdminConsole->render($self->checkExportPath.$f->print,WebGUI::International::get('Export Page',"Asset"));
@ -192,11 +192,11 @@ sub www_exportStatus {
my $self = shift;
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(13));
my $iframeUrl = $self->getUrl('func=exportGenerate');
$iframeUrl = WebGUI::URL::append($iframeUrl, 'index='.$session{form}{index});
$iframeUrl = WebGUI::URL::append($iframeUrl, 'depth='.$session{form}{depth});
$iframeUrl = WebGUI::URL::append($iframeUrl, 'userId='.$session{form}{userId});
$iframeUrl = WebGUI::URL::append($iframeUrl, 'extrasURL='.$session{form}{extrasURL});
$iframeUrl = WebGUI::URL::append($iframeUrl, 'uploadsURL='.$session{form}{uploadsURL});
$iframeUrl = $self->session->url->append($iframeUrl, 'index='.$self->session->form->process("index"));
$iframeUrl = $self->session->url->append($iframeUrl, 'depth='.$self->session->form->process("depth"));
$iframeUrl = $self->session->url->append($iframeUrl, 'userId='.$self->session->form->process("userId"));
$iframeUrl = $self->session->url->append($iframeUrl, 'extrasURL='.$self->session->form->process("extrasURL"));
$iframeUrl = $self->session->url->append($iframeUrl, 'uploadsURL='.$self->session->form->process("uploadsURL"));
my $output = '<iframe src="'.$iframeUrl.'" title="'.WebGUI::International::get('Page Export Status',"Asset").'" width="410" height="200"></iframe>';
$self->getAdminConsole->render($output,WebGUI::International::get('Page Export Status',"Asset"),"Asset");
}
@ -222,11 +222,11 @@ sub www_exportGenerate {
print $error;
return;
}
my $userId = $session{form}{userId};
my $extrasURL = $session{form}{extrasURL};
my $uploadsURL = $session{form}{uploadsURL};
my $index = $session{form}{index};
my $assets = $self->getLineage(["self","descendants"],{returnObjects=>1,endingLineageLength=>$self->getLineageLength+$session{form}{depth}});
my $userId = $self->session->form->process("userId");
my $extrasURL = $self->session->form->process("extrasURL");
my $uploadsURL = $self->session->form->process("uploadsURL");
my $index = $self->session->form->process("index");
my $assets = $self->getLineage(["self","descendants"],{returnObjects=>1,endingLineageLength=>$self->getLineageLength+$self->session->form->process("depth")});
foreach my $asset (@{$assets}) {
my $url = $asset->get("url");
printf WebGUI::International::get('exporting page', 'Asset'), $url;
@ -249,7 +249,7 @@ sub www_exportGenerate {
$filename = $index;
}
if($path) {
$path = $session{config}{exportPath} . "/" . $path;
$path = $self->session->config->get("exportPath") . "/" . $path;
eval { mkpath($path) };
if($@) {
printf WebGUI::International::get('could not create path', 'Asset'), $path, $@;

View file

@ -56,15 +56,15 @@ sub addChild {
my $id = shift || WebGUI::Id::generate();
my $lineage = $self->get("lineage").$self->getNextChildRank;
$self->{_hasChildren} = 1;
WebGUI::SQL->beginTransaction;
$self->session->db->beginTransaction;
my $now = time();
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, creationDate, createdBy, className, state) values (".quote($id).",".quote($self->getId).", ".quote($lineage).", ".$now.", ".quote($session{user}{userId}).", ".quote($properties->{className}).", 'published')");
$self->session->db->write("insert into asset (assetId, parentId, lineage, creationDate, createdBy, className, state) values (".$self->session->db->quote($id).",".$self->session->db->quote($self->getId).", ".$self->session->db->quote($lineage).", ".$now.", ".$self->session->db->quote($self->session->user->profileField("userId")).", ".$self->session->db->quote($properties->{className}).", 'published')");
my $temp = WebGUI::Asset->newByPropertyHashRef({
assetId=>$id,
className=>$properties->{className}
});
my $newAsset = $temp->addRevision($properties,$now);
WebGUI::SQL->commit;
$self->session->db->commit;
$self->updateHistory("added child ".$id);
return $newAsset;
}
@ -91,8 +91,8 @@ sub cascadeLineage {
my $newLineage = shift;
my $oldLineage = shift || $self->get("lineage");
my $now = time();
my $prepared = WebGUI::SQL->prepare("update asset set lineage=? where assetId=?");
my $descendants = WebGUI::SQL->read("select assetId,lineage from asset where lineage like ".quote($oldLineage.'%'));
my $prepared = $self->session->db->prepare("update asset set lineage=? where assetId=?");
my $descendants = $self->session->db->read("select assetId,lineage from asset where lineage like ".$self->session->db->quote($oldLineage.'%'));
my $cache = WebGUI::Cache->new;
while (my ($assetId, $lineage) = $descendants->array) {
my $fixedLineage = $newLineage.substr($lineage,length($oldLineage));
@ -113,9 +113,9 @@ Swaps lineage with sister below. Returns 1 if there is a sister to swap. Otherwi
sub demote {
my $self = shift;
my ($sisterLineage) = WebGUI::SQL->quickArray("select min(lineage) from asset
where parentId=".quote($self->get("parentId"))."
and state='published' and lineage>".quote($self->get("lineage")));
my ($sisterLineage) = $self->session->db->quickArray("select min(lineage) from asset
where parentId=".$self->session->db->quote($self->get("parentId"))."
and state='published' and lineage>".$self->session->db->quote($self->get("lineage")));
if (defined $sisterLineage) {
$self->swapRank($sisterLineage);
$self->{_properties}{lineage} = $sisterLineage;
@ -155,8 +155,8 @@ sub getFirstChild {
unless (exists $self->{_firstChild}) {
my $lineage = $session{assetLineage}{firstChild}{$self->getId};
unless ($lineage) {
($lineage) = WebGUI::SQL->quickArray("select min(asset.lineage) from asset,assetData where asset.parentId=".quote($self->getId)." and asset.assetId=assetData.assetId and asset.state='published'");
$session{assetLineage}{firstChild}{$self->getId} = $lineage unless ($session{config}{disableCache});
($lineage) = $self->session->db->quickArray("select min(asset.lineage) from asset,assetData where asset.parentId=".$self->session->db->quote($self->getId)." and asset.assetId=assetData.assetId and asset.state='published'");
$session{assetLineage}{firstChild}{$self->getId} = $lineage unless ($self->session->config->get("disableCache"));
}
$self->{_firstChild} = WebGUI::Asset->newByLineage($lineage);
}
@ -177,7 +177,7 @@ sub getLastChild {
unless (exists $self->{_lastChild}) {
my $lineage = $session{assetLineage}{lastChild}{$self->getId};
unless ($lineage) {
($lineage) = WebGUI::SQL->quickArray("select max(asset.lineage) from asset,assetData where asset.parentId=".quote($self->getId)." and asset.assetId=assetData.assetId and asset.state='published'");
($lineage) = $self->session->db->quickArray("select max(asset.lineage) from asset,assetData where asset.parentId=".$self->session->db->quote($self->getId)." and asset.assetId=assetData.assetId and asset.state='published'");
$session{assetLineage}{lastChild}{$self->getId} = $lineage;
}
$self->{_lastChild} = WebGUI::Asset->newByLineage($lineage);
@ -249,7 +249,7 @@ sub getLineage {
my @whereModifiers;
# let's get those siblings
if (isIn("siblings",@{$relatives})) {
push(@whereModifiers, " (asset.parentId=".quote($self->get("parentId"))." and asset.assetId<>".quote($self->getId).")");
push(@whereModifiers, " (asset.parentId=".$self->session->db->quote($self->get("parentId"))." and asset.assetId<>".$self->session->db->quote($self->getId).")");
}
# ancestors too
my @specificFamilyMembers = ();
@ -267,11 +267,11 @@ sub getLineage {
push(@specificFamilyMembers,$self->get("lineage"));
}
if (scalar(@specificFamilyMembers) > 0) {
push(@whereModifiers,"(asset.lineage in (".quoteAndJoin(\@specificFamilyMembers)."))");
push(@whereModifiers,"(asset.lineage in (".$self->session->db->quoteAndJoin(\@specificFamilyMembers)."))");
}
# we need to include descendants
if (isIn("descendants",@{$relatives})) {
my $mod = "(asset.lineage like ".quote($lineage.'%')." and asset.lineage<>".quote($lineage);
my $mod = "(asset.lineage like ".$self->session->db->quote($lineage.'%')." and asset.lineage<>".$self->session->db->quote($lineage);
if (exists $rules->{endingLineageLength}) {
$mod .= " and length(asset.lineage) <= ".($rules->{endingLineageLength}*6);
}
@ -280,7 +280,7 @@ sub getLineage {
}
# we need to include children
if (isIn("children",@{$relatives})) {
push(@whereModifiers,"(asset.parentId=".quote($self->getId).")");
push(@whereModifiers,"(asset.parentId=".$self->session->db->quote($self->getId).")");
}
# now lets add in all of the siblings in every level between ourself and the asset we wish to pedigree
if (isIn("pedigree",@{$relatives}) && exists $rules->{assetToPedigree}) {
@ -289,7 +289,7 @@ sub getLineage {
my $length = $rules->{assetToPedigree}->getLineageLength;
for (my $i = $length; $i > 0; $i--) {
my $line = substr($lineage,0,$i*6);
push(@mods,"( asset.lineage like ".quote($line.'%')." and length(asset.lineage)=".(($i+1)*6).")");
push(@mods,"( asset.lineage like ".$self->session->db->quote($line.'%')." and length(asset.lineage)=".(($i+1)*6).")");
last if ($self->getLineageLength == $i);
}
push(@whereModifiers, "(".join(" or ",@mods).")") if (scalar(@mods));
@ -300,7 +300,7 @@ sub getLineage {
my $className = $rules->{joinClass};
my $cmd = "use ".$className;
eval ($cmd);
WebGUI::ErrorHandler::fatal("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
$self->session->errorHandler->fatal("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
foreach my $definition (@{$className->definition}) {
unless ($definition->{tableName} eq "asset") {
my $tableName = $definition->{tableName};
@ -313,23 +313,23 @@ sub getLineage {
my $where;
## custom states
if (exists $rules->{statesToInclude}) {
$where = "asset.state in (".quoteAndJoin($rules->{statesToInclude}).")";
$where = "asset.state in (".$self->session->db->quoteAndJoin($rules->{statesToInclude}).")";
} else {
$where = "asset.state='published'";
}
## get only approved items or those that i'm currently working on
$where .= " and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")";
$where .= " and (assetData.status='approved' or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")";
## class exclusions
if (exists $rules->{excludeClasses}) {
my @set;
foreach my $className (@{$rules->{excludeClasses}}) {
push(@set,"asset.className not like ".quote($className.'%'));
push(@set,"asset.className not like ".$self->session->db->quote($className.'%'));
}
$where .= ' and ('.join(" and ",@set).')';
}
## class inclusions
if (exists $rules->{includeOnlyClasses}) {
$where .= ' and (asset.className in ('.quoteAndJoin($rules->{includeOnlyClasses}).'))';
$where .= ' and (asset.className in ('.$self->session->db->quoteAndJoin($rules->{includeOnlyClasses}).'))';
}
## finish up our where clause
$where .= ' and ('.join(" or ",@whereModifiers).')' if (scalar(@whereModifiers));
@ -338,7 +338,7 @@ sub getLineage {
}
# based upon all available criteria, let's get some assets
my $columns = "asset.assetId, asset.className, asset.parentId, assetData.revisionDate";
$where .= " and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")) ";
$where .= " and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")) ";
my $sortOrder = ($rules->{invertTree}) ? "asset.lineage desc" : "asset.lineage asc";
if (exists $rules->{orderByClause}) {
$sortOrder = $rules->{orderByClause};
@ -346,7 +346,7 @@ sub getLineage {
my $sql = "select $columns from $tables where $where group by assetData.assetId order by $sortOrder";
my @lineage;
my %relativeCache;
my $sth = WebGUI::SQL->read($sql);
my $sth = $self->session->db->read($sql);
while (my ($id, $class, $parentId, $version) = $sth->array) {
# create whatever type of object was requested
my $asset;
@ -399,11 +399,11 @@ Returns a 6 digit number with leading zeros of the next rank a child will get.
sub getNextChildRank {
my $self = shift;
my ($lineage) = WebGUI::SQL->quickArray("select max(lineage) from asset where parentId=".quote($self->getId));
my ($lineage) = $self->session->db->quickArray("select max(lineage) from asset where parentId=".$self->session->db->quote($self->getId));
my $rank;
if (defined $lineage) {
$rank = $self->getRank($lineage);
WebGUI::ErrorHandler::fatal("Asset ".$self->getId." has too many children.") if ($rank >= 999998);
$self->session->errorHandler->fatal("Asset ".$self->getId." has too many children.") if ($rank >= 999998);
$rank++;
} else {
$rank = 1;
@ -483,7 +483,7 @@ sub hasChildren {
} elsif (exists $self->{_lastChild}) {
$self->{_hasChildren} = 1;
} else {
my ($hasChildren) = WebGUI::SQL->quickArray("select count(*) from asset where parentId=".quote($self->getId));
my ($hasChildren) = $self->session->db->quickArray("select count(*) from asset where parentId=".$self->session->db->quote($self->getId));
$self->{_hasChildren} = $hasChildren;
}
}
@ -515,7 +515,7 @@ sub newByLineage {
my $id = $assetLineage->{$lineage}{id};
$class = $assetLineage->{$lineage}{class};
unless ($id && $class) {
($id,$class) = $session->db->quickArray("select assetId, className from asset where lineage=".quote($lineage));
($id,$class) = $session->db->quickArray("select assetId, className from asset where lineage=".$self->session->db->quote($lineage));
$assetLineage->{$lineage}{id} = $id;
$assetLineage->{$lineage}{class} = $class;
$session->stow->set("assetLineage",$assetLineage);
@ -534,9 +534,9 @@ Keeps the same rank of lineage, swaps with sister above. Returns 1 if there is a
sub promote {
my $self = shift;
my ($sisterLineage) = WebGUI::SQL->quickArray("select max(lineage) from asset
where parentId=".quote($self->get("parentId"))."
and state='published' and lineage<".quote($self->get("lineage")));
my ($sisterLineage) = $self->session->db->quickArray("select max(lineage) from asset
where parentId=".$self->session->db->quote($self->get("parentId"))."
and state='published' and lineage<".$self->session->db->quote($self->get("lineage")));
if (defined $sisterLineage) {
$self->swapRank($sisterLineage);
$self->{_properties}{lineage} = $sisterLineage;
@ -568,10 +568,10 @@ sub setParent {
my $oldLineage = $self->get("lineage");
my $lineage = $newParent->get("lineage").$newParent->getNextChildRank;
return 0 if ($lineage =~ m/^$oldLineage/); # can't move it to its own child
WebGUI::SQL->beginTransaction;
WebGUI::SQL->write("update asset set parentId=".quote($newParent->getId)." where assetId=".quote($self->getId));
$self->session->db->beginTransaction;
$self->session->db->write("update asset set parentId=".$self->session->db->quote($newParent->getId)." where assetId=".$self->session->db->quote($self->getId));
$self->cascadeLineage($lineage);
WebGUI::SQL->commit;
$self->session->db->commit;
$self->updateHistory("moved to parent ".$newParent->getId);
$self->{_properties}{lineage} = $lineage;
$self->purgeCache;
@ -604,7 +604,7 @@ sub setRank {
@{$siblings} = reverse @{$siblings};
}
my $previous = $self->get("lineage");
WebGUI::SQL->beginTransaction;
$self->session->db->beginTransaction;
$self->cascadeLineage($temp);
foreach my $sibling (@{$siblings}) {
if (isBetween($sibling->getRank, $newRank, $currentRank)) {
@ -614,7 +614,7 @@ sub setRank {
}
$self->cascadeLineage($previous,$temp);
$self->{_properties}{lineage} = $previous;
WebGUI::SQL->commit;
$self->session->db->commit;
$self->purgeCache;
$self->updateHistory("changed rank");
return 1;
@ -637,11 +637,11 @@ sub swapRank {
my $second = shift;
my $first = shift || $self->get("lineage");
my $temp = substr(WebGUI::Id::generate(),0,6); # need a temp in order to do the swap
WebGUI::SQL->beginTransaction;
$self->session->db->beginTransaction;
$self->cascadeLineage($temp,$first);
$self->cascadeLineage($first,$second);
$self->cascadeLineage($second,$temp);
WebGUI::SQL->commit;
$self->session->db->commit;
$self->updateHistory("swapped lineage between ".$first." and ".$second);
return 1;
}
@ -690,7 +690,7 @@ Returns a www_manageAssets() method. Sets a new parent via the results of a form
sub www_setParent {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
my $newParent = WebGUI::Asset->newByDynamicClass($session{form}{assetId});
my $newParent = WebGUI::Asset->newByDynamicClass($self->session->form->process("assetId"));
$self->setParent($newParent) if (defined $newParent);
return $self->www_manageAssets();
@ -707,9 +707,9 @@ Returns a www_manageAssets() method. Sets a new rank via the results of a form.
sub www_setRank {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
my $newRank = $session{form}{rank};
my $newRank = $self->session->form->process("rank");
$self->setRank($newRank) if (defined $newRank);
$session{asset} = $self->getParent;
$self->session->asset = $self->getParent;
return $self->getParent->www_manageAssets();
}

View file

@ -50,10 +50,10 @@ The fieldId to be deleted.
sub deleteMetaDataField {
my $self = shift;
my $fieldId = shift;
WebGUI::SQL->beginTransaction;
WebGUI::SQL->write("delete from metaData_properties where fieldId = ".quote($fieldId));
WebGUI::SQL->write("delete from metaData_values where fieldId = ".quote($fieldId));
WebGUI::SQL->commit;
$self->session->db->beginTransaction;
$self->session->db->write("delete from metaData_properties where fieldId = ".$self->session->db->quote($fieldId));
$self->session->db->write("delete from metaData_values where fieldId = ".$self->session->db->quote($fieldId));
$self->session->db->commit;
}
@ -81,14 +81,14 @@ sub getMetaDataFields {
f.possibleValues,
d.value
from metaData_properties f
left join metaData_values d on f.fieldId=d.fieldId and d.assetId=".quote($self->getId);
$sql .= " where f.fieldId = ".quote($fieldId) if ($fieldId);
left join metaData_values d on f.fieldId=d.fieldId and d.assetId=".$self->session->db->quote($self->getId);
$sql .= " where f.fieldId = ".$self->session->db->quote($fieldId) if ($fieldId);
$sql .= " order by f.fieldName";
if ($fieldId) {
return WebGUI::SQL->quickHashRef($sql);
return $self->session->db->quickHashRef($sql);
} else {
tie my %hash, 'Tie::IxHash';
my $sth = WebGUI::SQL->read($sql);
my $sth = $self->session->db->read($sql);
while( my $h = $sth->hashRef) {
foreach(keys %$h) {
$hash{$h->{fieldId}}{$_} = $h->{$_};
@ -120,14 +120,14 @@ sub updateMetaData {
my $self = shift;
my $fieldName = shift;
my $value = shift;
my ($exists) = WebGUI::SQL->quickArray("select count(*) from metaData_values where assetId = ".quote($self->getId)." and fieldId = ".quote($fieldName));
my ($exists) = $self->session->db->quickArray("select count(*) from metaData_values where assetId = ".$self->session->db->quote($self->getId)." and fieldId = ".$self->session->db->quote($fieldName));
if (!$exists && $value ne "") {
WebGUI::SQL->write("insert into metaData_values (fieldId, assetId) values (".quote($fieldName).",".quote($self->getId).")");
$self->session->db->write("insert into metaData_values (fieldId, assetId) values (".$self->session->db->quote($fieldName).",".$self->session->db->quote($self->getId).")");
}
if ($value eq "") { # Keep it clean
WebGUI::SQL->write("delete from metaData_values where assetId = ".quote($self->getId)." and fieldId = ".quote($fieldName));
$self->session->db->write("delete from metaData_values where assetId = ".$self->session->db->quote($self->getId)." and fieldId = ".$self->session->db->quote($fieldName));
} else {
WebGUI::SQL->write("update metaData_values set value = ".quote($value)." where assetId = ".quote($self->getId)." and fieldId=".quote($fieldName));
$self->session->db->write("update metaData_values set value = ".$self->session->db->quote($value)." where assetId = ".$self->session->db->quote($self->getId)." and fieldId=".$self->session->db->quote($fieldName));
}
}
@ -143,7 +143,7 @@ Deletes a MetaDataField and returns www_manageMetaData on self, if user isInGrou
sub www_deleteMetaDataField {
my $self = shift;
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(4));
$self->deleteMetaDataField($session{form}{fid});
$self->deleteMetaDataField($self->session->form->process("fid"));
return $self->www_manageMetaData;
}
@ -158,13 +158,13 @@ Returns a rendered page to edit MetaData. Will return an insufficient Privilege
sub www_editMetaDataField {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("contentProfiling");
my $ac = WebGUI::AdminConsole->new($self->session,"contentProfiling");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(4));
my $fieldInfo;
if($session{form}{fid} && $session{form}{fid} ne "new") {
$fieldInfo = $self->getMetaDataFields($session{form}{fid});
if($self->session->form->process("fid") && $self->session->form->process("fid") ne "new") {
$fieldInfo = $self->getMetaDataFields($self->session->form->process("fid"));
}
my $fid = $session{form}{fid} || "new";
my $fid = $self->session->form->process("fid") || "new";
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl);
$f->hidden(
-name => "func",
@ -217,40 +217,40 @@ Verifies that MetaData fields aren't duplicated or blank, assigns default values
sub www_editMetaDataFieldSave {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("content profiling");
my $ac = WebGUI::AdminConsole->new($self->session,"content profiling");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(4));
$ac->setHelp("metadata edit property","Asset");
# Check for duplicate field names
my $sql = "select count(*) from metaData_properties where fieldName = ".
quote($session{form}{fieldName});
if ($session{form}{fid} ne "new") {
$sql .= " and fieldId <> ".quote($session{form}{fid});
$self->session->db->quote($self->session->form->process("fieldName"));
if ($self->session->form->process("fid") ne "new") {
$sql .= " and fieldId <> ".$self->session->db->quote($self->session->form->process("fid"));
}
my ($isDuplicate) = WebGUI::SQL->buildArray($sql);
my ($isDuplicate) = $self->session->db->buildArray($sql);
if($isDuplicate) {
my $error = WebGUI::International::get("duplicateField", "Asset");
$error =~ s/\%field\%/$session{form}{fieldName}/;
$error =~ s/\%field\%/$self->session->form->process("fieldName")/;
return $ac->render($error,WebGUI::International::get('Edit Metadata',"Asset"));
}
if($session{form}{fieldName} eq "") {
if($self->session->form->process("fieldName") eq "") {
return $ac->render(WebGUI::International::get("errorEmptyField", "Asset"),WebGUI::International::get('Edit Metadata',"Asset"));
}
if($session{form}{fid} eq 'new') {
$session{form}{fid} = WebGUI::Id::generate();
WebGUI::SQL->write("insert into metaData_properties (fieldId, fieldName, defaultValue, description, fieldType, possibleValues) values (".
quote($session{form}{fid}).",".
quote($session{form}{fieldName}).",".
quote($session{form}{defaultValue}).",".
quote($session{form}{description}).",".
quote($session{form}{fieldType}).",".
quote($session{form}{possibleValues}).")");
if($self->session->form->process("fid") eq 'new') {
$self->session->form->process("fid") = WebGUI::Id::generate();
$self->session->db->write("insert into metaData_properties (fieldId, fieldName, defaultValue, description, fieldType, possibleValues) values (".
$self->session->db->quote($self->session->form->process("fid")).",".
$self->session->db->quote($self->session->form->process("fieldName")).",".
$self->session->db->quote($self->session->form->process("defaultValue")).",".
$self->session->db->quote($self->session->form->process("description")).",".
$self->session->db->quote($self->session->form->process("fieldType")).",".
$self->session->db->quote($self->session->form->process("possibleValues")).")");
} else {
WebGUI::SQL->write("update metaData_properties set fieldName = ".quote($session{form}{fieldName}).", ".
"defaultValue = ".quote($session{form}{defaultValue}).", ".
"description = ".quote($session{form}{description}).", ".
"fieldType = ".quote($session{form}{fieldType}).", ".
"possibleValues = ".quote($session{form}{possibleValues}).
" where fieldId = ".quote($session{form}{fid}));
$self->session->db->write("update metaData_properties set fieldName = ".$self->session->db->quote($self->session->form->process("fieldName")).", ".
"defaultValue = ".$self->session->db->quote($self->session->form->process("defaultValue")).", ".
"description = ".$self->session->db->quote($self->session->form->process("description")).", ".
"fieldType = ".$self->session->db->quote($self->session->form->process("fieldType")).", ".
"possibleValues = ".$self->session->db->quote($self->session->form->process("possibleValues")).
" where fieldId = ".$self->session->db->quote($self->session->form->process("fid")));
}
return $self->www_manageMetaData;
@ -267,7 +267,7 @@ Returns an AdminConsole to deal with MetaDataFields. If isInGroup(4) is False, r
sub www_manageMetaData {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("contentProfiling");
my $ac = WebGUI::AdminConsole->new($self->session,"contentProfiling");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(4));
$ac->addSubmenuItem($self->getUrl('func=editMetaDataField'), WebGUI::International::get("Add new field","Asset"));
my $output;

View file

@ -59,9 +59,9 @@ sub getPackageList {
assetData.isPackage=1
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and
(assetData.status='approved'";
$sql .= " or assetData.tagId=".quote($session{scratch}{versionTag}) if ($session{scratch}{versionTag});
$sql .= " or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")) if ($self->session->scratch->get("versionTag"));
$sql .= ")) and asset.state='published' group by assetData.assetId order by assetData.title desc";
my $sth = WebGUI::SQL->read($sql);
my $sth = $self->session->db->read($sql);
while (my ($id, $date, $class) = $sth->array) {
my $asset = WebGUI::Asset->new($id,$class);
push(@assets, $asset) if ($asset->get("isPackage"));
@ -82,7 +82,7 @@ Returns "". Deploys a Package. If canEdit is Fales, renders an insufficient Priv
sub www_deployPackage {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
my $packageMasterAssetId = $session{form}{assetId};
my $packageMasterAssetId = $self->session->form->process("assetId");
if (defined $packageMasterAssetId) {
my $packageMasterAsset = WebGUI::Asset->newByDynamicClass($packageMasterAssetId);
my $masterLineage = $packageMasterAsset->get("lineage");

View file

@ -54,13 +54,13 @@ If not specified, uses current user.
sub getAssetsInTrash {
my $self = shift;
my $limitToUser = shift;
my $userId = shift || $session{user}{userId};
my $userId = shift || $self->session->user->profileField("userId");
my @assets;
my $limit;
if ($limitToUser) {
$limit = "and asset.stateChangedBy=".quote($userId);
$limit = "and asset.stateChangedBy=".$self->session->db->quote($userId);
}
my $sth = WebGUI::SQL->read("
my $sth = $self->session->db->read("
select
asset.assetId,
assetData.revisionDate,
@ -96,14 +96,14 @@ Deletes an asset from tables and removes anything bound to that asset.
sub purge {
my $self = shift;
return undef if ($self->getId eq $session{setting}{defaultPage} || $self->getId eq $session{setting}{notFoundPage});
WebGUI::SQL->beginTransaction;
return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage"));
$self->session->db->beginTransaction;
foreach my $definition (@{$self->definition}) {
WebGUI::SQL->write("delete from ".$definition->{tableName}." where assetId=".quote($self->getId));
$self->session->db->write("delete from ".$definition->{tableName}." where assetId=".$self->session->db->quote($self->getId));
}
WebGUI::SQL->write("delete from metaData_values where assetId = ".quote($self->getId));
WebGUI::SQL->write("delete from asset where assetId=".quote($self->getId));
WebGUI::SQL->commit;
$self->session->db->write("delete from metaData_values where assetId = ".$self->session->db->quote($self->getId));
$self->session->db->write("delete from asset where assetId=".$self->session->db->quote($self->getId));
$self->session->db->commit;
$self->purgeCache;
WebGUI::Cache->new->deleteChunk(["asset",$self->getId]);
$self->updateHistory("purged");
@ -121,11 +121,11 @@ Removes asset from lineage, places it in trash state. The "gap" in the lineage i
sub trash {
my $self = shift;
return undef if ($self->getId eq $session{setting}{defaultPage} || $self->getId eq $session{setting}{notFoundPage});
WebGUI::SQL->beginTransaction;
WebGUI::SQL->write("update asset set state='trash-limbo' where lineage like ".quote($self->get("lineage").'%'));
WebGUI::SQL->write("update asset set state='trash', stateChangedBy=".quote($session{user}{userId}).", stateChanged=".time()." where assetId=".quote($self->getId));
WebGUI::SQL->commit;
return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage"));
$self->session->db->beginTransaction;
$self->session->db->write("update asset set state='trash-limbo' where lineage like ".$self->session->db->quote($self->get("lineage").'%'));
$self->session->db->write("update asset set state='trash', stateChangedBy=".$self->session->db->quote($self->session->user->profileField("userId")).", stateChanged=".time()." where assetId=".$self->session->db->quote($self->getId));
$self->session->db->commit;
$self->{_properties}{state} = "trash";
$self->updateHistory("trashed");
$self->purgeCache;
@ -143,9 +143,9 @@ Moves self to trash, returns www_view() method of Parent if canEdit. Otherwise r
sub www_delete {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
return WebGUI::Privilege::vitalComponent() if (isIn($self->getId, $session{setting}{defaultPage}, $session{setting}{notFoundPage}));
return WebGUI::Privilege::vitalComponent() if (isIn($self->getId, $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")));
$self->trash;
$session{asset} = $self->getParent;
$self->session->asset = $self->getParent;
return $self->getParent->www_view;
}
@ -160,14 +160,14 @@ Moves list of assets to trash, returns www_manageAssets() method of self if canE
sub www_deleteList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $assetId ($session{req}->param("assetId")) {
foreach my $assetId ($self->session->request->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($assetId);
if ($asset->canEdit) {
$asset->trash;
}
}
if ($session{form}{proceed} ne "") {
my $method = "www_".$session{form}{proceed};
if ($self->session->form->process("proceed") ne "") {
my $method = "www_".$self->session->form->process("proceed");
return $self->$method();
}
return $self->www_manageAssets();
@ -184,19 +184,19 @@ Returns an AdminConsole to deal with assets in the Trash. If isInGroup(4) is Fal
sub www_manageTrash {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("trash");
my $ac = WebGUI::AdminConsole->new($self->session,"trash");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(12));
my ($header, $limit);
$ac->setHelp("trash manage");
if ($session{form}{systemTrash} && WebGUI::Grouping::isInGroup(3)) {
if ($self->session->form->process("systemTrash") && WebGUI::Grouping::isInGroup(3)) {
$header = WebGUI::International::get(965,"Asset");
$ac->addSubmenuItem($self->getUrl('func=manageTrash'), WebGUI::International::get(10));
} else {
$ac->addSubmenuItem($self->getUrl('func=manageTrash;systemTrash=1'), WebGUI::International::get(964,"Asset"));
$limit = 1;
}
WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/assetManager.js', {type=>"text/javascript"});
$self->session->style->setLink($self->session->config->get("extrasURL").'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->config->get("extrasURL").'/assetManager/assetManager.js', {type=>"text/javascript"});
my $i18n = WebGUI::International->new("Asset");
my $output = "
<script type=\"text/javascript\">
@ -245,12 +245,12 @@ Restores a piece of content from the trash back to it's original location.
sub www_restoreList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $id ($session{req}->param("assetId")) {
foreach my $id ($self->session->request->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($id);
$asset->publish;
}
if ($session{form}{proceed} ne "") {
my $method = "www_".$session{form}{proceed};
if ($self->session->form->process("proceed") ne "") {
my $method = "www_".$self->session->form->process("proceed");
return $self->$method();
}
return $self->www_manageTrash();

View file

@ -56,20 +56,20 @@ sub addRevision {
my $self = shift;
my $properties = shift;
my $now = shift || time();
my $versionTag = $session{scratch}{versionTag} || 'pbversion0000000000002';
my $status = $session{setting}{autoCommit} ? 'approved' : 'pending';
WebGUI::SQL->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url, startDate, endDate,
ownerUserId, groupIdEdit, groupIdView) values (".quote($self->getId).",".$now.", ".quote($session{user}{userId}).",
".quote($versionTag).", ".quote($status).", ".quote($self->getId).", 997995720, 32472169200,'3','3','7')");
my $versionTag = $self->session->scratch->get("versionTag") || 'pbversion0000000000002';
my $status = $self->session->setting->get("autoCommit") ? 'approved' : 'pending';
$self->session->db->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url, startDate, endDate,
ownerUserId, groupIdEdit, groupIdView) values (".$self->session->db->quote($self->getId).",".$now.", ".$self->session->db->quote($self->session->user->profileField("userId")).",
".$self->session->db->quote($versionTag).", ".$self->session->db->quote($status).", ".$self->session->db->quote($self->getId).", 997995720, 32472169200,'3','3','7')");
foreach my $definition (@{$self->definition}) {
unless ($definition->{tableName} eq "assetData") {
WebGUI::SQL->write("insert into ".$definition->{tableName}." (assetId,revisionDate) values (".quote($self->getId).",".$now.")");
$self->session->db->write("insert into ".$definition->{tableName}." (assetId,revisionDate) values (".$self->session->db->quote($self->getId).",".$now.")");
}
}
my $newVersion = WebGUI::Asset->new($self->getId, $self->get("className"), $now);
$newVersion->updateHistory("created revision");
$newVersion->update($self->get);
$newVersion->setVersionLock unless ($session{setting}{autoCommit});
$newVersion->setVersionLock unless ($self->session->setting->get("autoCommit"));
$newVersion->update($properties) if (defined $properties);
return $newVersion;
}
@ -88,14 +88,14 @@ The name of the version tag. If not specified, one will be generated using the c
sub addVersionTag {
my $class = shift;
my $name = shift || "Autotag created ".WebGUI::DateTime::epochToHuman()." by ".$session{user}{username};
my $tagId = WebGUI::SQL->setRow("assetVersionTag","tagId",{
my $name = shift || "Autotag created ".WebGUI::DateTime::epochToHuman()." by ".$self->session->user->profileField("username");
my $tagId = $self->session->db->setRow("assetVersionTag","tagId",{
tagId=>"new",
name=>$name,
creationDate=>time(),
createdBy=>$session{user}{userId}
createdBy=>$self->session->user->profileField("userId")
});
WebGUI::Session::setScratch("versionTag",$tagId);
$self->session->scratch->set("versionTag",$tagId);
return $tagId;
}
@ -111,7 +111,7 @@ Returns a boolean indicating whether this asset is locked and if the current use
sub canEditIfLocked {
my $self = shift;
return 0 unless ($self->isLocked);
return ($self->get("isLockedBy") eq $session{user}{userId});
return ($self->get("isLockedBy") eq $self->session->user->profileField("userId"));
}
@ -145,13 +145,13 @@ The unique id of the tag to be committed.
sub commitVersionTag {
my $class = shift;
my $tagId = shift;
my $sth = WebGUI::SQL->read("select asset.assetId,asset.className,assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId=".quote($tagId));
my $sth = $self->session->db->read("select asset.assetId,asset.className,assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId=".$self->session->db->quote($tagId));
while (my ($id,$class,$version) = $sth->array) {
WebGUI::Asset->new($id,$class,$version)->commit;
}
$sth->finish;
WebGUI::SQL->write("update assetVersionTag set isCommitted=1, commitDate=".time().", committedBy=".quote($session{user}{userId})." where tagId=".quote($tagId));
WebGUI::SQL->write("delete from userSessionScratch where name='versionTag' and value=".quote($tagId));
$self->session->db->write("update assetVersionTag set isCommitted=1, commitDate=".time().", committedBy=".$self->session->db->quote($self->session->user->profileField("userId"))." where tagId=".$self->session->db->quote($tagId));
$self->session->db->write("delete from userSessionScratch where name='versionTag' and value=".$self->session->db->quote($tagId));
}
@ -170,8 +170,8 @@ Optionally specify to get the count based upon the status of the revisions. Opti
sub getRevisionCount {
my $self = shift;
my $status = shift;
my $statusClause = " and status=".quote($status) if ($status);
my ($count) = WebGUI::SQL->quickArray("select count(*) from assetData where assetId=".quote($self->getId).$statusClause);
my $statusClause = " and status=".$self->session->db->quote($status) if ($status);
my ($count) = $self->session->db->quickArray("select count(*) from assetData where assetId=".$self->session->db->quote($self->getId).$statusClause);
return $count;
}
@ -201,11 +201,11 @@ Deletes a revision of an asset. If it's the last revision, it purges the asset a
sub purgeRevision {
my $self = shift;
if ($self->getRevisionCount > 1) {
WebGUI::SQL->beginTransaction;
$self->session->db->beginTransaction;
foreach my $definition (@{$self->definition}) {
WebGUI::SQL->write("delete from ".$definition->{tableName}." where assetId=".quote($self->getId)." and revisionDate=".quote($self->get("revisionDate")));
$self->session->db->write("delete from ".$definition->{tableName}." where assetId=".$self->session->db->quote($self->getId)." and revisionDate=".$self->session->db->quote($self->get("revisionDate")));
}
WebGUI::SQL->commit;
$self->session->db->commit;
$self->purgeCache;
$self->updateHistory("purged revision ".$self->get("revisionDate"));
} else {
@ -231,9 +231,9 @@ sub rollbackToTime {
my $toTime = shift;
unless ($toTime) {
return 0;
WebGUI::ErrorHandler::warn("You must specify a time when you call rollbackSiteToTime().");
$self->session->errorHandler->warn("You must specify a time when you call rollbackSiteToTime().");
}
my $sth = WebGUI::SQL->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.revisionDate > ".$toTime." order by assetData.revisionDate desc");
my $sth = $self->session->db->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.revisionDate > ".$toTime." order by assetData.revisionDate desc");
while (my ($class, $id, $revisionDate) = $sth->array) {
my $revision = WebGUI::Asset->new($id, $class, $revisionDate);
$revision->purgeRevision;
@ -259,20 +259,20 @@ sub rollbackVersionTag {
my $tagId = shift;
unless ($tagId) {
return 0;
WebGUI::ErrorHandler::warn("You must specify a tag ID when you call rollbackVersionTag().");
$self->session->errorHandler->warn("You must specify a tag ID when you call rollbackVersionTag().");
}
if ($tagId eq "pbversion0000000000001" || $tagId eq "pbversion0000000000002") {
return 0;
WebGUI::ErrorHandler::warn("You cannot rollback a tag that is required for the system to operate.");
$self->session->errorHandler->warn("You cannot rollback a tag that is required for the system to operate.");
}
my $sth = WebGUI::SQL->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ".quote($tagId)." order by assetData.revisionDate desc");
my $sth = $self->session->db->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ".$self->session->db->quote($tagId)." order by assetData.revisionDate desc");
while (my ($class, $id, $revisionDate) = $sth->array) {
my $revision = WebGUI::Asset->new($id, $class, $revisionDate);
$revision->purgeRevision;
}
$sth->finish;
WebGUI::SQL->write("delete from assetVersionTag where tagId=".quote($tagId));
WebGUI::SQL->write("delete from userSessionScratch where name='versionTag' and value=".quote($tagId));
$self->session->db->write("delete from assetVersionTag where tagId=".$self->session->db->quote($tagId));
$self->session->db->write("delete from userSessionScratch where name='versionTag' and value=".$self->session->db->quote($tagId));
return 1;
}
@ -287,7 +287,7 @@ Sets the versioning lock to "on" so that this piece of content may not be edited
sub setVersionLock {
my $self = shift;
WebGUI::SQL->write("update asset set isLockedBy=".quote($session{user}{userId})." where assetId=".quote($self->getId));
$self->session->db->write("update asset set isLockedBy=".$self->session->db->quote($self->session->user->profileField("userId"))." where assetId=".$self->session->db->quote($self->getId));
$self->updateHistory("locked");
$self->purgeCache;
}
@ -303,7 +303,7 @@ Sets the versioning lock to "off" so that this piece of content may be edited on
sub unsetVersionLock {
my $self = shift;
WebGUI::SQL->write("update asset set isLockedBy=NULL where assetId=".quote($self->getId));
$self->session->db->write("update asset set isLockedBy=NULL where assetId=".$self->session->db->quote($self->getId));
$self->updateHistory("unlocked");
$self->purgeCache;
}
@ -328,9 +328,9 @@ If not specified, current user is used.
sub updateHistory {
my $self = shift;
my $action = shift;
my $userId = shift || $session{user}{userId} || '3';
my $userId = shift || $self->session->user->profileField("userId") || '3';
my $dateStamp = time();
WebGUI::SQL->write("insert into assetHistory (assetId, userId, actionTaken, dateStamp) values (".quote($self->getId).", ".quote($userId).", ".quote($action).", ".$dateStamp.")");
$self->session->db->write("insert into assetHistory (assetId, userId, actionTaken, dateStamp) values (".$self->session->db->quote($self->getId).", ".$self->session->db->quote($userId).", ".$self->session->db->quote($action).", ".$dateStamp.")");
}
@ -344,12 +344,12 @@ Displays the add version tag form.
sub www_addVersionTag {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("versions");
my $ac = WebGUI::AdminConsole->new($self->session,"versions");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(12));
my $i18n = WebGUI::International->new("Asset");
$ac->addSubmenuItem($self->getUrl('func=manageVersions'), $i18n->get("manage versions"));
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl);
my $tag = WebGUI::SQL->getRow("assetVersionTag","tagId",$session{form}{tagId});
my $tag = $self->session->db->getRow("assetVersionTag","tagId",$self->session->form->process("tagId"));
$f->hidden(
-name=>"func",
-value=>"addVersionTagSave"
@ -376,7 +376,7 @@ Adds a version tag and sets the user's default version tag to that.
sub www_addVersionTagSave {
my $self = shift;
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(12));
$self->addVersionTag($session{form}{name});
$self->addVersionTag($self->session->form->process("name"));
return $self->www_manageVersions();
}
@ -387,7 +387,7 @@ sub www_commitRevision {
my $self = shift;
return WebGUI::Privilege::adminOnly() unless $self->canEdit;
$self->commit;
return $self->getContainer->www_manageAssets if ($session{form}{proceed} eq "manageAssets");
return $self->getContainer->www_manageAssets if ($self->session->form->process("proceed") eq "manageAssets");
return $self->getContainer->www_view;
}
#-------------------------------------------------------------------
@ -395,7 +395,7 @@ sub www_commitRevision {
sub www_commitVersionTag {
my $self = shift;
return WebGUI::Privilege::adminOnly() unless WebGUI::Grouping::isInGroup(3);
my $tagId = $session{form}{tagId};
my $tagId = $self->session->form->process("tagId");
if ($tagId) {
$self->commitVersionTag($tagId);
}
@ -412,7 +412,7 @@ Shows a list of the currently available asset version tags.
sub www_manageCommittedVersions {
my $self = shift;
my $ac = WebGUI::AdminConsole->new("versions");
my $ac = WebGUI::AdminConsole->new($self->session,"versions");
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(3));
my $i18n = WebGUI::International->new("Asset");
my $rollback = $i18n->get('rollback');
@ -421,7 +421,7 @@ sub www_manageCommittedVersions {
$ac->addSubmenuItem($self->getUrl('func=manageVersions'), $i18n->get("manage versions"));
my $output = '<table width=100% class="content">
<tr><th>Tag Name</th><th>Committed On</th><th>Committed By</th><th></th></tr> ';
my $sth = WebGUI::SQL->read("select tagId,name,commitDate,committedBy from assetVersionTag where isCommitted=1");
my $sth = $self->session->db->read("select tagId,name,commitDate,committedBy from assetVersionTag where isCommitted=1");
while (my ($id,$name,$date,$by) = $sth->array) {
my $u = WebGUI::User->new($by);
$output .= '<tr>
@ -451,9 +451,9 @@ sub www_manageRevisions {
my $i18n = WebGUI::International->new("Asset");
my $output = '<table width=100% class="content">
<tr><th></th><th>Revision Date</th><th>Revised By</th><th>Tag Name</th></tr> ';
my $sth = WebGUI::SQL->read("select assetData.revisionDate, users.username, assetVersionTag.name,assetData.tagId from assetData
my $sth = $self->session->db->read("select assetData.revisionDate, users.username, assetVersionTag.name,assetData.tagId from assetData
left join assetVersionTag on assetData.tagId=assetVersionTag.tagId left join users on assetData.revisedBy=users.userId
where assetData.assetId=".quote($self->getId));
where assetData.assetId=".$self->session->db->quote($self->getId));
while (my ($date,$by,$tag,$tagId) = $sth->array) {
$output .= '<tr><td>'.WebGUI::Icon::deleteIcon("func=purgeRevision;revisionDate=".$date,$self->get("url"),$i18n->get("purge revision prompt")).'</td>
<td><a href="'.$self->getUrl("func=viewRevision;revisionDate=".$date).'">'.WebGUI::DateTime::epochToHuman($date).'</a></td>
@ -483,7 +483,7 @@ sub www_manageVersions {
$ac->setHelp("versions manage");
$ac->addSubmenuItem($self->getUrl('func=addVersionTag'), $i18n->get("add a version tag"));
$ac->addSubmenuItem($self->getUrl('func=manageCommittedVersions'), $i18n->get("manage committed versions"));
my ($tag) = WebGUI::SQL->quickArray("select name from assetVersionTag where tagId=".quote($session{scratch}{versionTag}));
my ($tag) = $self->session->db->quickArray("select name from assetVersionTag where tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")));
$tag ||= "None";
my $rollback = $i18n->get("rollback");
my $commit = $i18n->get("commit");
@ -492,7 +492,7 @@ sub www_manageVersions {
my $commitPrompt = $i18n->get("commit version tag confirm");
my $output = '<p>You are currently working under a tag called: <b>'.$tag.'</b>.</p><table width=100% class="content">
<tr><th></th><th>Tag Name</th><th>Created On</th><th>Created By</th><th></th></tr> ';
my $sth = WebGUI::SQL->read("select tagId,name,creationDate,createdBy from assetVersionTag where isCommitted=0");
my $sth = $self->session->db->read("select tagId,name,creationDate,createdBy from assetVersionTag where isCommitted=0");
while (my ($id,$name,$date,$by) = $sth->array) {
my $u = WebGUI::User->new($by);
$output .= '<tr>
@ -522,21 +522,21 @@ sub www_manageRevisionsInTag {
$ac->addSubmenuItem($self->getUrl('func=manageVersions'), $i18n->get("manage versions"));
my $output = '<table width=100% class="content">
<tr><th></th><th>Title</th><th>Type</th><th>Revision Date</th><th>Revised By</th></tr> ';
my $p = WebGUI::Paginator->new($self->getUrl("func=manageRevisionsInTag;tagId=".$session{form}{tagId}));
my $p = WebGUI::Paginator->new($self->getUrl("func=manageRevisionsInTag;tagId=".$self->session->form->process("tagId")));
$p->setDataByQuery("select assetData.revisionDate, users.username, asset.assetId, asset.className from assetData
left join asset on assetData.assetId=asset.assetId left join users on assetData.revisedBy=users.userId
where assetData.tagId=".quote($session{form}{tagId}));
where assetData.tagId=".$self->session->db->quote($self->session->form->process("tagId")));
foreach my $row (@{$p->getPageData}) {
my ($date,$by,$id, $class) = ($row->{revisionDate}, $row->{username}, $row->{assetId}, $row->{className});
my $asset = WebGUI::Asset->new($id,$class,$date);
$output .= '<tr><td>'.WebGUI::Icon::deleteIcon("func=purgeRevision;proceed=manageRevisionsInTag;tagId=".$session{form}{tagId}.";revisionDate=".$date,$asset->get("url"),$i18n->get("purge revision prompt")).'</td>
$output .= '<tr><td>'.WebGUI::Icon::deleteIcon("func=purgeRevision;proceed=manageRevisionsInTag;tagId=".$self->session->form->process("tagId").";revisionDate=".$date,$asset->get("url"),$i18n->get("purge revision prompt")).'</td>
<td>'.$asset->getTitle.'</td>
<td><img src="'.$asset->getIcon(1).'" alt="'.$asset->getName.'" />'.$asset->getName.'</td>
<td><a href="'.$asset->getUrl("func=viewRevision;revisionDate=".$date).'">'.WebGUI::DateTime::epochToHuman($date).'</a></td>
<td>'.$by.'</td></tr>';
}
$output .= '</table>'.$p->getBarSimple;
my $tag = WebGUI::SQL->getRow("assetVersionTag","tagId",$session{form}{tagId});
my $tag = $self->session->db->getRow("assetVersionTag","tagId",$self->session->form->process("tagId"));
return $ac->render($output,$i18n->get("revisions in tag").": ".$tag->{name});
}
@ -546,10 +546,10 @@ sub www_manageRevisionsInTag {
sub www_purgeRevision {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
my $revisionDate = $session{form}{revisionDate};
my $revisionDate = $self->session->form->process("revisionDate");
return undef unless $revisionDate;
WebGUI::Asset->new($self->getId,$self->get("className"),$revisionDate)->purgeRevision;
if ($session{form}{proceed} eq "manageRevisionsInTag") {
if ($self->session->form->process("proceed") eq "manageRevisionsInTag") {
return $self->www_manageRevisionsInTag;
}
return $self->www_manageRevisions;
@ -561,12 +561,12 @@ sub www_purgeRevision {
sub www_rollbackVersionTag {
my $self = shift;
return WebGUI::Privilege::adminOnly() unless WebGUI::Grouping::isInGroup(3);
return WebGUI::Privilege::vitalComponent() if ($session{form}{tagId} eq "pbversion0000000000001" || $session{form}{tagId} eq "pbversion0000000000002");
my $tagId = $session{form}{tagId};
return WebGUI::Privilege::vitalComponent() if ($self->session->form->process("tagId") eq "pbversion0000000000001" || $self->session->form->process("tagId") eq "pbversion0000000000002");
my $tagId = $self->session->form->process("tagId");
if ($tagId) {
$self->rollbackVersionTag($tagId);
}
if ($session{form}{proceed} eq "manageCommittedVersions") {
if ($self->session->form->process("proceed") eq "manageCommittedVersions") {
return $self->www_manageCommittedVersions;
}
return $self->www_manageVersions;
@ -592,7 +592,7 @@ Sets the current user's working version tag.
sub www_setVersionTag () {
my $self = shift;
return WebGUI::Privilege::insufficient() unless WebGUI::Grouping::isInGroup(12);
WebGUI::Session::setScratch("versionTag",$session{form}{tagId});
$self->session->scratch->set("versionTag",$self->session->form->process("tagId"));
return $self->www_manageVersions();
}
@ -601,7 +601,7 @@ sub www_setVersionTag () {
sub www_viewRevision {
my $self = shift;
my $otherSelf = WebGUI::Asset->new($self->getId,$self->get("className"),$session{form}{revisionDate});
my $otherSelf = WebGUI::Asset->new($self->getId,$self->get("className"),$self->session->form->process("revisionDate"));
return (defined $otherSelf) ? $otherSelf->www_view : undef;
}

View file

@ -19,20 +19,15 @@ use DBI;
use strict qw(subs vars);
use Tie::IxHash;
use WebGUI::DateTime;
use WebGUI::ErrorHandler;
use WebGUI::FormProcessor;
use WebGUI::HTML;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::TabForm;
use WebGUI::Asset::Template;
use WebGUI::URL;
use WebGUI::Utility;
use WebGUI::User;
use WebGUI::Operation::Shared;
use WebGUI::Operation::Profile;
@ -61,8 +56,8 @@ sub _isDuplicateUsername {
my $self = shift;
my $username = shift;
#Return false if the user is already logged in, but not changing their username.
return 0 if($self->userId ne "1" && $session{user}{username} eq $username);
my ($otherUser) = WebGUI::SQL->quickArray("select count(*) from users where username=".quote($username));
return 0 if($self->userId ne "1" && $self->session->user->username eq $username);
my ($otherUser) = $self->session->db->quickArray("select count(*) from users where username=".$self->session->db->quote($username));
return 0 if !$otherUser;
$self->error('<li>'.WebGUI::International::get(77).' "'.$username.'too", "'.$username.'2", '.'"'.$username.'_'.WebGUI::DateTime::epochToHuman(time(),"%y").'"'.'</li>');
return 1;
@ -81,7 +76,7 @@ sub _isValidUsername {
my $username = shift;
my $error = "";
return 1 if($self->userId ne "1" && $session{user}{username} eq $username);
return 1 if($self->userId ne "1" && $self->session->user->username eq $username);
if ($username =~ /^\s/ || $username =~ /\s$/) {
$error .= '<li>'.WebGUI::International::get(724).'</li>';
@ -98,8 +93,9 @@ sub _isValidUsername {
#-------------------------------------------------------------------
sub _logLogin {
WebGUI::SQL->write("insert into userLoginLog values (".quote($_[0]).",".quote($_[1]).",".time().","
.quote($session{env}{REMOTE_ADDR}).",".quote($session{env}{HTTP_USER_AGENT}).")");
my $self = shift;
$self->session->db->write("insert into userLoginLog values (".$self->session->db->$self->session->db->quote($_[0]).",".$self->session->db->quote($_[1]).",".time().","
.$self->session->db->$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).",".$self->session->db->$self->session->db->quote($self->session->env->get("HTTP_USER_AGENT")).")");
}
#-------------------------------------------------------------------
@ -138,7 +134,7 @@ Superclass method that performs standard login routines. This method should ret
sub authenticate {
my $self = shift;
my $username = shift;
my $user = WebGUI::SQL->quickHashRef("select userId,authMethod,status from users where username=".quote($username));
my $user = $self->session->db->quickHashRef("select userId,authMethod,status from users where username=".$self->session->db->$self->session->db->quote($username));
my $uid = $user->{userId};
#If userId does not exist or is not active, fail login
if(!$uid){
@ -146,12 +142,12 @@ sub authenticate {
return 0;
} elsif($user->{status} ne 'Active'){
$self->error(WebGUI::International::get(820));
_logLogin($uid, "failure");
$self->_logLogin($uid, "failure");
return 0;
}
#Set User Id
$self->user(WebGUI::User->new($uid));
$self->user(WebGUI::User->new($self->session,$uid));
return 1;
}
@ -205,10 +201,10 @@ sub createAccount {
$vars->{'create.form.submit'} = WebGUI::Form::submit({});
$vars->{'create.form.footer'} = WebGUI::Form::formFooter();
$vars->{'login.url'} = WebGUI::URL::page('op=auth;method=init');
$vars->{'login.url'} = $self->session->url->page('op=auth;method=init');
$vars->{'login.label'} = WebGUI::International::get(58);
return WebGUI::Asset::Template->new($self->getCreateAccountTemplateId)->process($vars);
return WebGUI::Asset::Template->new($self->session,$self->getCreateAccountTemplateId)->process($vars);
}
#-------------------------------------------------------------------
@ -243,12 +239,12 @@ sub createAccountSave {
my $profile = $_[3];
my $u = WebGUI::User->new("new");
my $u = WebGUI::User->new($self->session,"new");
$self->user($u);
my $userId = $u->userId;
$u->username($username);
$u->authMethod($self->authMethod);
$u->karma($session{setting}{karmaPerLogin},"Login","Just for logging in.") if ($session{setting}{useKarma});
$u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma"));
WebGUI::Operation::Profile::saveProfileFields($u,$profile) if($profile);
$self->saveParams($userId,$self->authMethod,$properties);
@ -259,11 +255,11 @@ sub createAccountSave {
WebGUI::MessageLog::addEntry($self->userId,"",WebGUI::International::get(870),$self->getSetting("welcomeMessage").$authInfo);
}
$session->user({user=>$u});
_logLogin($userId,"success");
my $command = $session{setting}{runOnRegistration};
WebGUI::Macro::process(\$command);
system($command) if ($session{setting}{runOnRegistration} ne "");
WebGUI::MessageLog::addInternationalizedEntry('',$session{setting}{onNewUserAlertGroup},'',536) if ($session{setting}{alertOnNewUser});
$self->_logLogin($userId,"success");
my $command = $self->session->setting->get("runOnRegistration");
WebGUI::Macro::process($self->session,\$command);
system($command) if ($self->session->setting->get("runOnRegistration") ne "");
WebGUI::MessageLog::addInternationalizedEntry('',$self->session->setting->get("onNewUserAlertGroup"),'',536) if ($self->session->setting->get("alertOnNewUser"));
return "";
}
@ -283,15 +279,15 @@ sub deactivateAccount {
my $self = shift;
my $method = $_[0];
return WebGUI::Privilege::vitalComponent() if($self->userId eq '1' || $self->userId eq '3');
return WebGUI::Privilege::adminOnly() if(!$session{setting}{selfDeactivation});
return WebGUI::Privilege::adminOnly() if(!$self->session->setting->get("selfDeactivation"));
my %var;
$var{title} = WebGUI::International::get(42);
$var{question} = WebGUI::International::get(60);
$var{'yes.url'} = WebGUI::URL::page('op=auth;method='.$method);
$var{'yes.url'} = $self->session->url->page('op=auth;method='.$method);
$var{'yes.label'} = WebGUI::International::get(44);
$var{'no.url'} = WebGUI::URL::page();
$var{'no.url'} = $self->session->url->page();
$var{'no.label'} = WebGUI::International::get(45);
return WebGUI::Asset::Template->new("PBtmpl0000000000000057")->process(\%var);
return WebGUI::Asset::Template->new($self->session,"PBtmpl0000000000000057")->process(\%var);
}
#-------------------------------------------------------------------
@ -307,8 +303,8 @@ sub deactivateAccountConfirm {
return WebGUI::Privilege::vitalComponent() if($self->userId eq '1' || $self->userId eq '3');
my $u = $self->user;
$u->status("Selfdestructed");
WebGUI::Session::end($session{var}{sessionId});
WebGUI::Session::start(1);
$self->session->var->end();
$self->session->var->start(1);
}
#-------------------------------------------------------------------
@ -321,7 +317,7 @@ Removes the user's authentication parameters from the database for all authentic
sub deleteParams {
my $self = shift;
WebGUI::SQL->write("delete from authentication where userId=".quote($self->userId));
$self->session->db->write("delete from authentication where userId=".$self->session->db->$self->session->db->quote($self->userId));
}
#-------------------------------------------------------------------
@ -350,15 +346,15 @@ sub displayAccount {
$vars->{'account.form.header'} = WebGUI::Form::formHeader({});
$vars->{'account.form.header'} .= WebGUI::Form::hidden({"name"=>"op","value"=>"auth"});
$vars->{'account.form.header'} .= WebGUI::Form::hidden({"name"=>"method","value"=>$method});
if($session{setting}{useKarma}){
$vars->{'account.form.karma'} = $session{user}{karma};
if($self->session->setting->get("useKarma")){
$vars->{'account.form.karma'} = $self->session->user->karma;
$vars->{'account.form.karma.label'} = WebGUI::International::get(537);
}
$vars->{'account.form.submit'} = WebGUI::Form::submit({});
$vars->{'account.form.footer'} = WebGUI::Form::formFooter();
$vars->{'account.options'} = WebGUI::Operation::Shared::accountOptions();
return WebGUI::Asset::Template->new($self->getAccountTemplateId)->process($vars);
return WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars);
}
#-------------------------------------------------------------------
@ -381,13 +377,13 @@ sub displayLogin {
my $self = shift;
my $method = $_[0] || "login";
my $vars = $_[1];
unless ($session{form}{op} eq "auth") {
WebGUI::Session::setScratch("redirectAfterLogin",WebGUI::URL::page($session{env}{QUERY_STRING}));
unless ($self->session->form->get("op") eq "auth") {
$self->session->scratch->set("redirectAfterLogin",$self->session->url->page($self->session->env->get("QUERY_STRING")));
}
$vars->{title} = WebGUI::International::get(66);
my $action;
if ($session{setting}{encryptLogin}) {
$action = WebGUI::URL::page(undef,1);
if ($self->session->setting->get("encryptLogin")) {
$action = $self->session->url->page(undef,1);
$action =~ s/http:/https:/;
}
$vars->{'login.form.header'} = WebGUI::Form::formHeader({action=>$action});
@ -399,10 +395,10 @@ sub displayLogin {
$vars->{'login.form.password.label'} = WebGUI::International::get(51);
$vars->{'login.form.submit'} = WebGUI::Form::submit({"value"=>WebGUI::International::get(52)});
$vars->{'login.form.footer'} = WebGUI::Form::formFooter();
$vars->{'anonymousRegistration.isAllowed'} = ($session{setting}{anonymousRegistration});
$vars->{'createAccount.url'} = WebGUI::URL::page('op=auth;method=createAccount');
$vars->{'anonymousRegistration.isAllowed'} = ($self->session->setting->get("anonymousRegistration"));
$vars->{'createAccount.url'} = $self->session->url->page('op=auth;method=createAccount');
$vars->{'createAccount.label'} = WebGUI::International::get(67);
return WebGUI::Asset::Template->new($self->getLoginTemplateId)->process($vars);
return WebGUI::Asset::Template->new($self->session,$self->getLoginTemplateId)->process($vars);
}
#-------------------------------------------------------------------
@ -492,7 +488,7 @@ sub getParams {
my $self = shift;
my $userId = $_[0] || $self->userId;
my $authMethod = $_[1] || $self->authMethod;
return WebGUI::SQL->buildHashRef("select fieldName, fieldData from authentication where userId=".quote($userId)." and authMethod=".quote($authMethod));
return $self->session->db->buildHashRef("select fieldName, fieldData from authentication where userId=".$self->session->db->quote($userId)." and authMethod=".$self->session->db->quote($authMethod));
}
#-------------------------------------------------------------------
@ -511,7 +507,7 @@ sub getSetting {
my $self = shift;
my $setting = $_[0];
$setting = lc($self->authMethod).ucfirst($setting);
return $session{setting}{$setting};
return $self->session->setting->get("$setting");
}
#-------------------------------------------------------------------
@ -559,12 +555,12 @@ sub login {
$uid = $self->userId;
$u = WebGUI::User->new($uid);
$session->user({user=>$u});
$u->karma($session{setting}{karmaPerLogin},"Login","Just for logging in.") if ($session{setting}{useKarma});
_logLogin($uid,"success");
$u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma"));
$self->_logLogin($uid,"success");
if ($session{scratch}{redirectAfterLogin}) {
WebGUI::HTTP::setRedirect($session{scratch}{redirectAfterLogin});
WebGUI::Session::deleteScratch("redirectAfterLogin");
if ($self->session->scratch->get("redirectAfterLogin")) {
$self->session->http->setRedirect($self->session->scratch->get("redirectAfterLogin"));
$self->session->scratch->delete("redirectAfterLogin");
}
return "";
}
@ -579,26 +575,28 @@ Superclass method that performs standard logout routines.
sub logout {
my $self = shift;
WebGUI::Session::end($session{var}{sessionId});
WebGUI::Session::start(1);
my $u = WebGUI::User->new(1);
$self->session->var->end($self->session->var->get("sessionId"));
$self->session->var->start(1);
my $u = WebGUI::User->new($self->session,1);
$self->{user} = $u;
return "";
}
#-------------------------------------------------------------------
=head2 new ( authMethod [,userId,callable] )
=head2 new ( session, authMethod [,userId,callable] )
Constructor.
=head3 session
=head3 authMethod
This object's authentication method
=head3 userId
userId for the user requesting authentication. This defaults to $session{user}{userId}
userId for the user requesting authentication. This defaults to $self->session->user->profileField("userId")
=head3 callable
@ -608,19 +606,17 @@ Array reference of methods allowed to be called externally;
sub new {
my $self = {};
shift;
#Initialize data
$self->{authMethod} = $_[0];
my $userId = $_[1] || $session{user}{userId};
my $u = WebGUI::User->new($userId);
$self->{user} = $u;
my $class = shift;
my $self->{_session} = shift;
$self->{authMethod} = shift;
my $userId = shift || $self->{_session}->user->userId;
$self->{user} = $self->{_session}->user;
$self->{error} = "";
$self->{profile} = ();
$self->{warning} = "";
my @callable = ('init', @{$_[2]});
my @callable = ('init', @{shift});
$self->{callable} = \@callable;
bless($self);
bless $self, $class;
return $self;
}
@ -640,6 +636,13 @@ sub profile {
#-------------------------------------------------------------------
sub session {
my $self = shift;
return $self->{_session};
}
#-------------------------------------------------------------------
=head2 setCallable ( callableMethods )
@ -683,8 +686,8 @@ sub saveParams {
my $self = shift;
my ($uid, $authMethod, $data) = @_;
foreach (keys %{$data}) {
WebGUI::SQL->write("delete from authentication where userId=".quote($uid)." and authMethod=".quote($authMethod)." and fieldName=".quote($_));
WebGUI::SQL->write("insert into authentication (userId,authMethod,fieldData,fieldName) values (".quote($uid).",".quote($authMethod).",".quote($data->{$_}).",".quote($_).")");
$self->session->db->write("delete from authentication where userId=".$self->session->db->quote($uid)." and authMethod=".$self->session->db->quote($authMethod)." and fieldName=".$self->session->db->quote($_));
$self->session->db->write("insert into authentication (userId,authMethod,fieldData,fieldName) values (".$self->session->db->quote($uid).",".$self->session->db->quote($authMethod).",".$self->session->db->quote($data->{$_}).",".$self->session->db->quote($_).")");
}
}

View file

@ -18,7 +18,6 @@ use WebGUI::Form;
use WebGUI::Icon;
use WebGUI::LDAPLink;
use WebGUI::Mail;
use WebGUI::Session;
use WebGUI::Utility;
use WebGUI::Operation::Shared;
use WebGUI::Asset::Template;
@ -60,23 +59,23 @@ sub _isValidLDAPUser {
$auth = $ldap->bind(dn=>$connectDN, password=>$session{form}{'authLDAP_identifier'});
if ($auth->code == 48 || $auth->code == 49) {
$error .= '<li>'.WebGUI::International::get(68).'</li>';
WebGUI::ErrorHandler::warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{'authLDAP_ldapId'});
$self->session->errorHandler->warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{'authLDAP_ldapId'});
} elsif ($auth->code > 0) {
$error .= '<li>LDAP error "'.$ldapStatusCode{$auth->code}.'" occured. '.WebGUI::International::get(69).'</li>';
WebGUI::ErrorHandler::error("LDAP error: ".$ldapStatusCode{$auth->code});
$self->session->errorHandler->error("LDAP error: ".$ldapStatusCode{$auth->code});
}
$ldap->unbind;
} else {
$error .= '<li>'.WebGUI::International::get(68).'</li>';
WebGUI::ErrorHandler::warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{'authLDAP_ldapId'});
$self->session->errorHandler->warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{'authLDAP_ldapId'});
}
} else {
$error = WebGUI::International::get(2,'AuthLDAP');
WebGUI::ErrorHandler::error("Couldn't bind to LDAP server: ".$connection->{ldapURL});
$self->session->errorHandler->error("Couldn't bind to LDAP server: ".$connection->{ldapURL});
}
} else {
$error = WebGUI::International::get(2,'AuthLDAP');
WebGUI::ErrorHandler::error("Couldn't create LDAP object: ".$uri->host);
$self->session->errorHandler->error("Couldn't create LDAP object: ".$uri->host);
}
$self->error($error);
return $error eq "";
@ -96,7 +95,7 @@ sub addUserForm {
my $ldapUrl = $session{form}{'authLDAP_ldapUrl'} || $userData->{ldapUrl} || $connection->{ldapURL};
my $connectDN = $session{form}{'authLDAP_connectDN'} || $userData->{connectDN};
my $ldapConnection = $session{form}{'authLDAP_ldapConnection'} || $userData->{ldapConnection};
my $ldapLinks = WebGUI::SQL->buildHashRef("select ldapLinkId,ldapUrl from ldapLink");
my $ldapLinks = $self->session->db->buildHashRef("select ldapLinkId,ldapUrl from ldapLink");
my $f = WebGUI::HTMLForm->new;
my $jscript = "";
if(scalar(keys %{$ldapLinks}) > 0) {
@ -132,7 +131,7 @@ sub addUserForm {
-label => WebGUI::International::get(4,'AuthLDAP'),
-value => $connectDN,
);
WebGUI::Style::setRawHeadTags($jscript);
$self->session->style->setRawHeadTags($jscript);
return $f->printRowsOnly;
}
@ -168,14 +167,14 @@ sub authenticate {
$self->error($error);
if($error ne ""){
$self->user(WebGUI::User->new(1));
$self->user(WebGUI::User->new($self->session,1));
return 0 ;
}
if($uri = URI->new($userData->{ldapUrl})) {
$ldap = Net::LDAP->new($uri->host, (port=>$uri->port)) or $error .= WebGUI::International::get(2,'AuthLDAP');
if($error ne ""){
$self->user(WebGUI::User->new(1));
$self->user(WebGUI::User->new($self->session,1));
return 0 ;
}
$auth = $ldap->bind(dn=>$userData->{connectDN}, password=>$identifier);
@ -183,16 +182,16 @@ sub authenticate {
$error .= WebGUI::International::get(68);
}elsif($auth->code > 0){
$error .= 'LDAP error "'.$ldapStatusCode{$auth->code}.'" occured.'.WebGUI::International::get(69);
WebGUI::ErrorHandler::error("LDAP error: ".$ldapStatusCode{$auth->code});
$self->session->errorHandler->error("LDAP error: ".$ldapStatusCode{$auth->code});
}
$ldap->unbind;
}else{
$error .= WebGUI::International::get(13,'AuthLDAP');
WebGUI::ErrorHandler::error("Could not process this LDAP URL: ".$userData->{ldapUrl});
$self->session->errorHandler->error("Could not process this LDAP URL: ".$userData->{ldapUrl});
}
if($error ne ""){
$self->error($error);
$self->user(WebGUI::User->new(1));
$self->user(WebGUI::User->new($self->session,1));
}
return $error eq "";
}
@ -202,21 +201,21 @@ sub authenticate {
sub createAccount {
my $self = shift;
my $vars;
if ($session{user}{userId} ne "1") {
if ($self->session->user->profileField("userId") ne "1") {
return $self->displayAccount;
} elsif (!$session{setting}{anonymousRegistration}) {
} elsif (!$self->session->setting->get("anonymousRegistration")) {
return $self->displayLogin;
}
if($session{form}{connection}) {
WebGUI::Session::setScratch("ldapConnection",$session{form}{connection});
$self->{_connection} = WebGUI::LDAPLink::get($session{form}{connection});
if($self->session->form->process("connection")) {
$self->session->scratch->set("ldapConnection",$self->session->form->process("connection"));
$self->{_connection} = WebGUI::LDAPLink::get($self->session->form->process("connection"));
}
my $connection = $self->{_connection};
$vars->{'create.message'} = $_[0] if ($_[0]);
$vars->{'create.form.ldapConnection.label'} = WebGUI::International::get("ldapConnection","AuthLDAP");
my $url = WebGUI::URL::page("op=auth;method=createAccount;connection=");
my $url = $self->session->url->page("op=auth;method=createAccount;connection=");
$vars->{'create.form.ldapConnection'} = WebGUI::Form::selectBox({
name=>"ldapConnection",
options=>WebGUI::LDAPLink::getList(),
@ -228,15 +227,15 @@ sub createAccount {
$vars->{'create.form.password'} = WebGUI::Form::password({"name"=>"authLDAP_identifier","value"=>$session{form}{"authLDAP_identifier"}});
$vars->{'create.form.password.label'} = $connection->{ldapPasswordName};
$vars->{'create.form.hidden'} = WebGUI::Form::hidden({"name"=>"confirm","value"=>$session{form}{confirm}});
$vars->{'create.form.hidden'} = WebGUI::Form::hidden({"name"=>"confirm","value"=>$self->session->form->process("confirm")});
return $self->SUPER::createAccount("createAccountSave",$vars);
}
#-------------------------------------------------------------------
sub createAccountSave {
my $self = shift;
my $username = $session{form}{'authLDAP_ldapId'};
my $password = $session{form}{'authLDAP_identifier'};
my $username = $self->session->form->get('authLDAP_ldapId');
my $password = $self->session->form->get('authLDAP_identifier');
my $error = "";
#Validate user in LDAP
@ -274,8 +273,8 @@ sub createAccountSave {
$error .= $temp;
return $self->createAccount("<h1>".WebGUI::International::get(70)."</h1>".$error) unless ($error eq "");
#If Email address is not unique, a warning is displayed
if($warning ne "" && !$session{form}{confirm}){
$session{form}{confirm} = 1;
if($warning ne "" && !$self->session->form->process("confirm")){
$self->session->form->process("confirm") = 1;
return $self->createAccount('<li>'.WebGUI::International::get(1078).'</li>');
}
@ -296,7 +295,7 @@ sub deactivateAccount {
#-------------------------------------------------------------------
sub deactivateAccountConfirm {
my $self = shift;
return $self->displayLogin unless ($session{setting}{selfDeactivation});
return $self->displayLogin unless ($self->session->setting->get("selfDeactivation"));
return $self->SUPER::deactivateAccountConfirm;
}
@ -307,12 +306,12 @@ sub displayAccount {
return $self->displayLogin($_[0]) if ($self->userId eq '1');
$vars->{displayTitle} = '<h1>'.WebGUI::International::get(61).'</h1>';
$vars->{'account.message'} = WebGUI::International::get(856);
if($session{setting}{useKarma}){
$vars->{'account.form.karma'} = $session{user}{karma};
if($self->session->setting->get("useKarma")){
$vars->{'account.form.karma'} = $self->session->user->profileField("karma");
$vars->{'account.form.karma.label'} = WebGUI::International::get(537);
}
$vars->{'account.options'} = WebGUI::Operation::Shared::accountOptions();
return WebGUI::Asset::Template->new($self->getAccountTemplateId)->process($vars);
return WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars);
}
#-------------------------------------------------------------------
@ -364,14 +363,14 @@ sub editUserSettingsForm {
my $ldapConnection = WebGUI::Form::selectBox({
name=>"ldapConnection",
options=>WebGUI::LDAPLink::getList(),
value=>[$session{setting}{ldapConnection}]
value=>[$self->session->setting->get("ldapConnection")]
});
my $ldapConnectionLabel = WebGUI::International::get("ldapConnection",'AuthLDAP');
my $buttons = "";
if($session{setting}{ldapConnection}) {
$buttons = editIcon("op=editLDAPLink;returnUrl=".WebGUI::URL::escape(WebGUI::URL::page("op=editSettings")).";llid=".$session{setting}{ldapConnection});
if($self->session->setting->get("ldapConnection")) {
$buttons = editIcon("op=editLDAPLink;returnUrl=".$self->session->url->escape($self->session->url->page("op=editSettings")).";llid=".$self->session->setting->get("ldapConnection"));
}
$buttons .= manageIcon("op=listLDAPLinks;returnUrl=".WebGUI::URL::escape(WebGUI::URL::page("op=editSettings")));
$buttons .= manageIcon("op=listLDAPLinks;returnUrl=".$self->session->url->escape($self->session->url->page("op=editSettings")));
$f->raw(qq|<tr><td class="formDescription" valign="top" style="width: 25%;">$ldapConnectionLabel</td><td class="tableData" style="width: 75%;">$ldapConnection&nbsp;$buttons</td></tr>|);
return $f->printRowsOnly;
}
@ -397,11 +396,11 @@ sub getLoginTemplateId {
#-------------------------------------------------------------------
sub login {
my $self = shift;
if(!$self->authenticate($session{form}{username},$session{form}{identifier})){
WebGUI::ErrorHandler::security("login to account ".$session{form}{username}." with invalid information.");
if(!$self->authenticate($self->session->form->process("username"),$self->session->form->process("identifier"))){
$self->session->errorHandler->security("login to account ".$self->session->form->process("username")." with invalid information.");
return $self->displayLogin("<h1>".WebGUI::International::get(70)."</h1>".$self->error);
}
WebGUI::Session::deleteScratch("ldapConnection");
$self->session->scratch->delete("ldapConnection");
return $self->SUPER::login(); #Standard login routine for login
}
@ -412,7 +411,7 @@ sub new {
my $userId = $_[1];
my @callable = ('createAccount','deactivateAccount','displayAccount','displayLogin','login','logout','createAccountSave','deactivateAccountConfirm');
my $self = WebGUI::Auth->new($authMethod,$userId,\@callable);
$self->{_connection} = WebGUI::LDAPLink::get(($session{scratch}{ldapConnection} || $session{setting}{ldapConnection}));
$self->{_connection} = WebGUI::LDAPLink::get(($self->session->scratch->get("ldapConnection") || $self->session->setting->get("ldapConnection")));
bless $self, $class;
}

View file

@ -16,13 +16,9 @@ use URI;
use WebGUI::Asset::Template;
use WebGUI::Auth;
use WebGUI::DateTime;
use WebGUI::FormProcessor;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Macro;
use WebGUI::Mail;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Storage::Image;
use WebGUI::User;
use WebGUI::Utility;
@ -70,7 +66,7 @@ sub _isValidPassword {
=cut
sub _logSecurityMessage {
WebGUI::ErrorHandler::security("change password. Password changed successfully");
$self->session->errorHandler->security("change password. Password changed successfully");
}
#-------------------------------------------------------------------
@ -94,9 +90,9 @@ sub addUserForm {
-name=>"authWebGUI.passwordTimeout",
-label=>WebGUI::International::get(16,'AuthWebGUI'),
-value=>$userData->{passwordTimeout},
-defaultValue=>$session{setting}{webguiPasswordTimeout}
-defaultValue=>$self->session->setting->get("webguiPasswordTimeout")
);
my $userChange = $session{setting}{webguiChangeUsername};
my $userChange = $self->session->setting->get("webguiChangeUsername");
if($userChange || $userChange eq "0"){
$userChange = $userData->{changeUsername};
}
@ -105,7 +101,7 @@ sub addUserForm {
-value=>$userChange,
-label=>WebGUI::International::get(21,'AuthWebGUI')
);
my $passwordChange = $session{setting}{webguiChangePassword};
my $passwordChange = $self->session->setting->get("webguiChangePassword");
if($passwordChange || $passwordChange eq "0"){
$passwordChange = $userData->{changePassword};
}
@ -128,14 +124,14 @@ sub addUserForm {
sub addUserFormSave {
my $self = shift;
my $properties;
unless ($session{form}{'authWebGUI.identifier'} eq "password") {
$properties->{identifier} = Digest::MD5::md5_base64($session{form}{'authWebGUI.identifier'});
unless ($self->session->form->get('authWebGUI.identifier') eq "password") {
$properties->{identifier} = Digest::MD5::md5_base64($self->session->form->get('authWebGUI.identifier'));
}
$properties->{changeUsername} = $session{form}{'authWebGUI.changeUsername'};
$properties->{changePassword} = $session{form}{'authWebGUI.changePassword'};
$properties->{passwordTimeout} = WebGUI::FormProcessor::interval('authWebGUI.passwordTimeout');
$properties->{changeUsername} = $self->session->form->get('authWebGUI.changeUsername');
$properties->{changePassword} = $self->session->form->get('authWebGUI.changePassword');
$properties->{passwordTimeout} = $self->session->form->interval('authWebGUI.passwordTimeout');
$properties->{passwordLastUpdated} = time();
if($session{setting}{webguiExpirePasswordOnCreation}){
if($self->session->setting->get("webguiExpirePasswordOnCreation")){
$properties->{passwordLastUpdated} = time() - $properties->{passwordTimeout};
}
$self->SUPER::addUserFormSave($properties);
@ -154,7 +150,7 @@ sub authenticate {
if ((Digest::MD5::md5_base64($identifier) eq $$userData{identifier}) && ($identifier ne "")) {
return 1;
}
$self->user(WebGUI::User->new(1));
$self->user(WebGUI::User->new($self->session,1));
$self->error(WebGUI::International::get(68));
return 0;
}
@ -163,15 +159,15 @@ sub authenticate {
sub createAccount {
my $self = shift;
my $vars;
if ($session{user}{userId} ne "1") {
if ($self->session->user->profileField("userId") ne "1") {
return $self->displayAccount;
} elsif (!$session{setting}{anonymousRegistration}) {
} elsif (!$self->session->setting->get("anonymousRegistration")) {
return $self->displayLogin;
}
$vars->{'create.message'} = $_[0] if ($_[0]);
my $storage = WebGUI::Storage::Image->createTemp;
my ($filename, $challenge) = $storage->addFileFromCaptcha;
$vars->{useCaptcha} = $session{setting}{webguiUseCaptcha};
$vars->{useCaptcha} = $self->session->setting->get("webguiUseCaptcha");
if ($vars->{useCaptcha}) {
$vars->{'create.form.captcha'} = WebGUI::Form::text({"name"=>"authWebGUI.captcha", size=>6, maxlength=>6})
.WebGUI::Form::hidden({name=>"authWebGUI.captcha.validation", value=>Digest::MD5::md5_base64(lc($challenge))})
@ -184,9 +180,9 @@ sub createAccount {
$vars->{'create.form.password.label'} = WebGUI::International::get(51);
$vars->{'create.form.passwordConfirm'} = WebGUI::Form::password({"name"=>"authWebGUI.identifierConfirm"});
$vars->{'create.form.passwordConfirm.label'} = WebGUI::International::get(2,'AuthWebGUI');
$vars->{'create.form.hidden'} = WebGUI::Form::hidden({"name"=>"confirm","value"=>$session{form}{confirm}});
$vars->{'create.form.hidden'} = WebGUI::Form::hidden({"name"=>"confirm","value"=>$self->session->form->process("confirm")});
$vars->{'recoverPassword.isAllowed'} = $self->getSetting("passwordRecovery");
$vars->{'recoverPassword.url'} = WebGUI::URL::page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.url'} = $self->session->url->page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.label'} = WebGUI::International::get(59);
return $self->SUPER::createAccount("createAccountSave",$vars);
}
@ -195,16 +191,16 @@ sub createAccount {
sub createAccountSave {
my $self = shift;
return $self->displayAccount if ($session{user}{userId} ne "1");
return $self->displayAccount if ($self->session->user->profileField("userId") ne "1");
my $username = $session{form}{'authWebGUI.username'};
my $password = $session{form}{'authWebGUI.identifier'};
my $passConfirm = $session{form}{'authWebGUI.identifierConfirm'};
my $username = $self->session->form->get('authWebGUI.username');
my $password = $self->session->form->get('authWebGUI.identifier');
my $passConfirm = $self->session->form->get('authWebGUI.identifierConfirm');
my $error;
$error = $self->error unless($self->validUsername($username));
if ($session{setting}{webguiUseCaptcha}) {
unless ($session{form}{'authWebGUI.captcha.validation'} eq Digest::MD5::md5_base64(lc($session{form}{'authWebGUI.captcha'}))) {
if ($self->session->setting->get("webguiUseCaptcha")) {
unless ($self->session->form->get('authWebGUI.captcha.validation') eq Digest::MD5::md5_base64(lc($self->session->form->get('authWebGUI.captcha')))) {
$error .= WebGUI::International::get("captcha failure","AuthWebGUI");
}
}
@ -215,31 +211,31 @@ sub createAccountSave {
return $self->createAccount($error) unless ($error eq "");
#If Email address is not unique, a warning is displayed
if($warning ne "" && !$session{form}{confirm}){
$session{form}{confirm} = 1;
if($warning ne "" && !$self->session->form->process("confirm")){
$self->session->form->process("confirm") = 1;
return $self->createAccount('<li>'.WebGUI::International::get(1078).'</li>');
}
my $properties;
$properties->{changeUsername} = $session{setting}{webguiChangeUsername};
$properties->{changePassword} = $session{setting}{webguiChangePassword};
$properties->{changeUsername} = $self->session->setting->get("webguiChangeUsername");
$properties->{changePassword} = $self->session->setting->get("webguiChangePassword");
$properties->{identifier} = Digest::MD5::md5_base64($password);
$properties->{passwordLastUpdated} = time();
$properties->{passwordTimeout} = $session{setting}{webguiPasswordTimeout};
$properties->{status} = 'Deactivated' if ($session{setting}{webguiValidateEmail});
$properties->{passwordTimeout} = $self->session->setting->get("webguiPasswordTimeout");
$properties->{status} = 'Deactivated' if ($self->session->setting->get("webguiValidateEmail"));
$self->SUPER::createAccountSave($username,$properties,$password,$profile);
if ($session{setting}{webguiValidateEmail}) {
if ($self->session->setting->get("webguiValidateEmail")) {
my $key = WebGUI::Id::generate();
$self->saveParams($self->userId,"WebGUI",{emailValidationKey=>$key});
WebGUI::Mail::send(
$profile->{email},
WebGUI::International::get('email address validation email subject','AuthWebGUI'),
WebGUI::International::get('email address validation email body','AuthWebGUI')."\n\n".WebGUI::URL::getSiteURL().WebGUI::URL::page("op=auth;method=validateEmail;key=".$key),
WebGUI::International::get('email address validation email body','AuthWebGUI')."\n\n".$self->session->url->getSiteURL().$self->session->url->page("op=auth;method=validateEmail;key=".$key),
);
$self->user->status("Deactivated");
WebGUI::Session::end($session{var}{sessionId});
WebGUI::Session::start(1);
my $u = WebGUI::User->new(1);
$self->session->var->end($self->session->var->get("sessionId"));
$self->session->var->start(1);
my $u = WebGUI::User->new($self->session,1);
$self->{user} = $u;
$self->logout;
return $self->displayLogin(WebGUI::International::get('check email for validation','AuthWebGUI'));
@ -257,7 +253,7 @@ sub deactivateAccount {
#-------------------------------------------------------------------
sub deactivateAccountConfirm {
my $self = shift;
return $self->displayLogin unless ($session{setting}{selfDeactivation});
return $self->displayLogin unless ($self->session->setting->get("selfDeactivation"));
return $self->SUPER::deactivateAccountConfirm;
}
@ -269,12 +265,12 @@ sub displayAccount {
my $userData = $self->getParams;
$vars->{'account.message'} = $_[0] if ($_[0]);
$vars->{'account.noform'} = 1;
if($userData->{changeUsername} || (!defined $userData->{changeUsername} && $session{setting}{webguiChangeUsername})){
if($userData->{changeUsername} || (!defined $userData->{changeUsername} && $self->session->setting->get("webguiChangeUsername"))){
$vars->{'account.form.username'} = WebGUI::Form::text({"name"=>"authWebGUI.username","value"=>$self->username});
$vars->{'account.form.username.label'} = WebGUI::International::get(50);
$vars->{'account.noform'} = 0;
}
if($userData->{changePassword} || (!defined $userData->{changePassword} && $session{setting}{webguiChangePassword})){
if($userData->{changePassword} || (!defined $userData->{changePassword} && $self->session->setting->get("webguiChangePassword"))){
$vars->{'account.form.password'} = WebGUI::Form::password({"name"=>"authWebGUI.identifier","value"=>"password"});
$vars->{'account.form.password.label'} = WebGUI::International::get(51);
$vars->{'account.form.passwordConfirm'} = WebGUI::Form::password({"name"=>"authWebGUI.identifierConfirm","value"=>"password"});
@ -299,7 +295,7 @@ sub displayLogin {
return $self->displayAccount($_[0]) if ($self->userId ne "1");
$vars->{'login.message'} = $_[0] if ($_[0]);
$vars->{'recoverPassword.isAllowed'} = $self->getSetting("passwordRecovery");
$vars->{'recoverPassword.url'} = WebGUI::URL::page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.url'} = $self->session->url->page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.label'} = WebGUI::International::get(59);
return $self->SUPER::displayLogin("login",$vars);
}
@ -329,15 +325,15 @@ sub editUserFormSave {
my $self = shift;
my $properties;
my $userData = $self->getParams;
unless (!$session{form}{'authWebGUI.identifier'} || $session{form}{'authWebGUI.identifier'} eq "password") {
$properties->{identifier} = Digest::MD5::md5_base64($session{form}{'authWebGUI.identifier'});
unless (!$self->session->form->get('authWebGUI.identifier') || $self->session->form->get('authWebGUI.identifier') eq "password") {
$properties->{identifier} = Digest::MD5::md5_base64($self->session->form->get('authWebGUI.identifier'));
if($userData->{identifier} ne $properties->{identifier}){
$properties->{passwordLastUpdated} = time();
}
}
$properties->{passwordTimeout} = WebGUI::FormProcessor::interval('authWebGUI.passwordTimeout');
$properties->{changeUsername} = $session{form}{'authWebGUI.changeUsername'};
$properties->{changePassword} = $session{form}{'authWebGUI.changePassword'};
$properties->{passwordTimeout} = $self->session->form->interval('authWebGUI.passwordTimeout');
$properties->{changeUsername} = $self->session->form->get('authWebGUI.changeUsername');
$properties->{changePassword} = $self->session->form->get('authWebGUI.changePassword');
$self->SUPER::editUserFormSave($properties);
}
@ -355,7 +351,7 @@ sub editUserSettingsForm {
my $f = WebGUI::HTMLForm->new;
$f->text(
-name=>"webguiPasswordLength",
-value=>$session{setting}{webguiPasswordLength},
-value=>$self->session->setting->get("webguiPasswordLength"),
-label=>WebGUI::International::get(15,'AuthWebGUI'),
-size=>5,
-maxLength=>5,
@ -363,80 +359,80 @@ sub editUserSettingsForm {
$f->interval(
-name=>"webguiPasswordTimeout",
-label=>WebGUI::International::get(16,'AuthWebGUI'),
-value=>$session{setting}{webguiPasswordTimeout}
-value=>$self->session->setting->get("webguiPasswordTimeout")
);
$f->yesNo(
-name=>"webguiExpirePasswordOnCreation",
-value=>$session{setting}{webguiExpirePasswordOnCreation},
-value=>$self->session->setting->get("webguiExpirePasswordOnCreation"),
-label=>WebGUI::International::get(9,'AuthWebGUI')
);
$f->yesNo(
-name=>"webguiSendWelcomeMessage",
-value=>$session{setting}{webguiSendWelcomeMessage},
-value=>$self->session->setting->get("webguiSendWelcomeMessage"),
-label=>WebGUI::International::get(868)
);
$f->textarea(
-name=>"webguiWelcomeMessage",
-value=>$session{setting}{webguiWelcomeMessage},
-value=>$self->session->setting->get("webguiWelcomeMessage"),
-label=>WebGUI::International::get(869)
);
$f->yesNo(
-name=>"webguiChangeUsername",
-value=>$session{setting}{webguiChangeUsername},
-value=>$self->session->setting->get("webguiChangeUsername"),
-label=>WebGUI::International::get(19,'AuthWebGUI')
);
$f->yesNo(
-name=>"webguiChangePassword",
-value=>$session{setting}{webguiChangePassword},
-value=>$self->session->setting->get("webguiChangePassword"),
-label=>WebGUI::International::get(18,'AuthWebGUI')
);
$f->yesNo(
-name=>"webguiPasswordRecovery",
-value=>$session{setting}{webguiPasswordRecovery},
-value=>$self->session->setting->get("webguiPasswordRecovery"),
-label=>WebGUI::International::get(6,'AuthWebGUI')
);
$f->textarea(
-name=>"webguiRecoverPasswordEmail",
-label=>WebGUI::International::get(134),
-value=>$session{setting}{webguiRecoverPasswordEmail}
-value=>$self->session->setting->get("webguiRecoverPasswordEmail")
);
$f->yesNo(
-name=>"webguiValidateEmail",
-value=>$session{setting}{webguiValidateEmail},
-value=>$self->session->setting->get("webguiValidateEmail"),
-label=>WebGUI::International::get('validate email','AuthWebGUI')
);
$f->yesNo(
-name=>"webguiUseCaptcha",
-value=>$session{setting}{webguiUseCaptcha},
-value=>$self->session->setting->get("webguiUseCaptcha"),
-label=>WebGUI::International::get('use captcha','AuthWebGUI')
);
$f->template(
-name=>"webguiAccountTemplate",
-value=>$session{setting}{webguiAccountTemplate},
-value=>$self->session->setting->get("webguiAccountTemplate"),
-namespace=>"Auth/WebGUI/Account",
-label=>WebGUI::International::get("account template","AuthWebGUI")
);
$f->template(
-name=>"webguiCreateAccountTemplate",
-value=>$session{setting}{webguiCreateAccountTemplate},
-value=>$self->session->setting->get("webguiCreateAccountTemplate"),
-namespace=>"Auth/WebGUI/Create",
-label=>WebGUI::International::get("create account template","AuthWebGUI")
);
$f->template(
-name=>"webguiExpiredPasswordTemplate",
-value=>$session{setting}{webguiExpiredPasswordTemplate},
-value=>$self->session->setting->get("webguiExpiredPasswordTemplate"),
-namespace=>"Auth/WebGUI/Expired",
-label=>WebGUI::International::get("expired password template","AuthWebGUI")
);
$f->template(
-name=>"webguiLoginTemplate",
-value=>$session{setting}{webguiLoginTemplate},
-value=>$self->session->setting->get("webguiLoginTemplate"),
-namespace=>"Auth/WebGUI/Login",
-label=>WebGUI::International::get("login template","AuthWebGUI")
);
$f->template(
-name=>"webguiPasswordRecoveryTemplate",
-value=>$session{setting}{webguiPasswordRecoveryTemplate},
-value=>$self->session->setting->get("webguiPasswordRecoveryTemplate"),
-namespace=>"Auth/WebGUI/Recovery",
-label=>WebGUI::International::get("password recovery template","AuthWebGUI")
);
@ -445,36 +441,36 @@ sub editUserSettingsForm {
#-------------------------------------------------------------------
sub getAccountTemplateId {
return $session{setting}{webguiAccountTemplate} || "PBtmpl0000000000000010";
return $self->session->setting->get("webguiAccountTemplate") || "PBtmpl0000000000000010";
}
#-------------------------------------------------------------------
sub getCreateAccountTemplateId {
return $session{setting}{webguiCreateAccountTemplate} || "PBtmpl0000000000000011";
return $self->session->setting->get("webguiCreateAccountTemplate") || "PBtmpl0000000000000011";
}
#-------------------------------------------------------------------
sub getExpiredPasswordTemplateId {
return $session{setting}{webguiExpiredPasswordTemplate} || "PBtmpl0000000000000012";
return $self->session->setting->get("webguiExpiredPasswordTemplate") || "PBtmpl0000000000000012";
}
#-------------------------------------------------------------------
sub getLoginTemplateId {
return $session{setting}{webguiLoginTemplate} || "PBtmpl0000000000000013";
return $self->session->setting->get("webguiLoginTemplate") || "PBtmpl0000000000000013";
}
#-------------------------------------------------------------------
sub getPasswordRecoveryTemplateId {
return $session{setting}{webguiPasswordRecoveryTemplate} || "PBtmpl0000000000000014";
return $self->session->setting->get("webguiPasswordRecoveryTemplate") || "PBtmpl0000000000000014";
}
#-------------------------------------------------------------------
sub login {
my $self = shift;
if(!$self->authenticate($session{form}{username},$session{form}{identifier})){
WebGUI::HTTP::setStatus("401","Incorrect Credentials");
WebGUI::ErrorHandler::security("login to account ".$session{form}{username}." with invalid information.");
if(!$self->authenticate($self->session->form->process("username"),$self->session->form->process("identifier"))){
$self->session->http->setStatus("401","Incorrect Credentials");
$self->session->errorHandler->security("login to account ".$self->session->form->process("username")." with invalid information.");
return $self->displayLogin("<h1>".WebGUI::International::get(70)."</h1>".$self->error);
}
@ -482,7 +478,7 @@ sub login {
if($self->getSetting("passwordTimeout") && $userData->{passwordTimeout}){
my $expireTime = $userData->{passwordLastUpdated} + $userData->{passwordTimeout};
if(time() >= $expireTime){
$session{form}{uid} = $self->userId;
$self->session->form->process("uid") = $self->userId;
$self->logout;
return $self->resetExpiredPassword;
}
@ -497,7 +493,7 @@ sub new {
my $authMethod = $_[0];
my $userId = $_[1];
my @callable = ('validateEmail','createAccount','deactivateAccount','displayAccount','displayLogin','login','logout','recoverPassword','resetExpiredPassword','recoverPasswordFinish','createAccountSave','deactivateAccountConfirm','resetExpiredPasswordSave','updateAccount');
my $self = WebGUI::Auth->new($authMethod,$userId,\@callable);
my $self = WebGUI::Auth->new($self->session,$authMethod,$userId,\@callable);
bless $self, $class;
}
@ -515,30 +511,30 @@ sub recoverPassword {
$vars->{'recover.form.submit'} = WebGUI::Form::submit({});
$vars->{'recover.form.footer'} = WebGUI::Form::formFooter();
$vars->{'login.url'} = WebGUI::URL::page('op=auth;method=init');
$vars->{'login.url'} = $self->session->url->page('op=auth;method=init');
$vars->{'login.label'} = WebGUI::International::get(58);
$vars->{'anonymousRegistration.isAllowed'} = ($session{setting}{anonymousRegistration});
$vars->{'createAccount.url'} = WebGUI::URL::page('op=auth=;method=createAccount');
$vars->{'anonymousRegistration.isAllowed'} = ($self->session->setting->get("anonymousRegistration"));
$vars->{'createAccount.url'} = $self->session->url->page('op=auth=;method=createAccount');
$vars->{'createAccount.label'} = WebGUI::International::get(67);
$vars->{'recover.message'} = $_[0] if ($_[0]);
$vars->{'recover.form.email'} = WebGUI::Form::text({"name"=>"email"});
$vars->{'recover.form.email.label'} = WebGUI::International::get(56);
return WebGUI::Asset::Template->new($self->getPasswordRecoveryTemplateId)->process($vars);
return WebGUI::Asset::Template->new($self->session,$self->getPasswordRecoveryTemplateId)->process($vars);
}
#-------------------------------------------------------------------
sub recoverPasswordFinish {
my $self = shift;
return $self->recoverPassword('<ul><li>'.WebGUI::International::get(743).'</li></ul>') if ($session{form}{email} eq "");
return $self->displayLogin unless ($session{setting}{webguiPasswordRecovery});
return $self->recoverPassword('<ul><li>'.WebGUI::International::get(743).'</li></ul>') if ($self->session->form->process("email") eq "");
return $self->displayLogin unless ($self->session->setting->get("webguiPasswordRecovery"));
my($sth,$username,$userId,$password,$flag,$message,$output,$encryptedPassword,$authMethod);
$sth = WebGUI::SQL->read("select users.username,users.userId from users, userProfileData where users.userId=userProfileData.userId and
users.authMethod='WebGUI' and userProfileData.fieldName='email' and userProfileData.fieldData=".quote($session{form}{email}));
$sth = $self->session->db->read("select users.username,users.userId from users, userProfileData where users.userId=userProfileData.userId and
users.authMethod='WebGUI' and userProfileData.fieldName='email' and userProfileData.fieldData=".$self->session->db->quote($self->session->form->process("email")));
$flag = 0;
while (($username,$userId) = $sth->array) {
my $len = $session{setting}{webguiPasswordLength} || 6;
my $len = $self->session->setting->get("webguiPasswordLength") || 6;
$password = "";
for(my $i = 0; $i < $len; $i++) {
$password .= chr(ord('A') + randint(32));
@ -546,11 +542,11 @@ sub recoverPasswordFinish {
$encryptedPassword = Digest::MD5::md5_base64($password);
$self->saveParams($userId,"WebGUI",{identifier=>$encryptedPassword});
_logSecurityMessage();
WebGUI::ErrorHandler::security("recover a password. Password emailed to: ".$session{form}{email});
$message = $session{setting}{webguiRecoverPasswordEmail};
$self->session->errorHandler->security("recover a password. Password emailed to: ".$self->session->form->process("email"));
$message = $self->session->setting->get("webguiRecoverPasswordEmail");
$message .= "\n".WebGUI::International::get(50).": ".$username."\n";
$message .= WebGUI::International::get(51).": ".$password."\n";
WebGUI::Mail::send($session{form}{email},WebGUI::International::get(74),$message);
WebGUI::Mail::send($self->session->form->process("email"),WebGUI::International::get(74),$message);
$flag++;
}
$sth->finish();
@ -569,7 +565,7 @@ sub resetExpiredPassword {
$vars->{'expired.form.header'} = "\n\n".WebGUI::Form::formHeader({});
$vars->{'expired.form.hidden'} = WebGUI::Form::hidden({"name"=>"op","value"=>"auth"});
$vars->{'expired.form.hidden'} .= WebGUI::Form::hidden({"name"=>"method","value"=>"resetExpiredPasswordSave"});
$vars->{'expired.form.hidden'} .= WebGUI::Form::hidden({"name"=>"uid","value"=>$session{form}{uid}});
$vars->{'expired.form.hidden'} .= WebGUI::Form::hidden({"name"=>"uid","value"=>$self->session->form->process("uid")});
$vars->{'expired.form.oldPassword'} = WebGUI::Form::password({"name"=>"oldPassword"});
$vars->{'expired.form.oldPassword.label'} = WebGUI::International::get(10,'AuthWebGUI');
@ -580,7 +576,7 @@ sub resetExpiredPassword {
$vars->{'expired.form.submit'} = WebGUI::Form::submit({});
$vars->{'expired.form.footer'} = WebGUI::Form::formFooter();
return WebGUI::Asset::Template->new($self->getExpiredPasswordTemplateId)->process($vars);
return WebGUI::Asset::Template->new($self->session,$self->getExpiredPasswordTemplateId)->process($vars);
}
#-------------------------------------------------------------------
@ -588,17 +584,17 @@ sub resetExpiredPasswordSave {
my $self = shift;
my ($error,$u,$properties,$msg);
$u = WebGUI::User->new($session{form}{uid});
$session{form}{username} = $u->username;
$u = WebGUI::User->new($self->session,$self->session->form->process("uid"));
$self->session->form->process("username") = $u->username;
$error .= $self->error if(!$self->authenticate($u->username,$session{form}{oldPassword}));
$error .= '<li>'.WebGUI::International::get(5,'AuthWebGUI').'</li>' if($session{form}{identifier} eq "password");
$error .= '<li>'.WebGUI::International::get(12,'AuthWebGUI').'</li>' if ($session{form}{oldPassword} eq $session{form}{identifier});
$error .= $self->error if(!$self->_isValidPassword($session{form}{identifier},$session{form}{identifierConfirm}));
$error .= $self->error if(!$self->authenticate($u->username,$self->session->form->process("oldPassword")));
$error .= '<li>'.WebGUI::International::get(5,'AuthWebGUI').'</li>' if($self->session->form->process("identifier") eq "password");
$error .= '<li>'.WebGUI::International::get(12,'AuthWebGUI').'</li>' if ($self->session->form->process("oldPassword") eq $self->session->form->process("identifier"));
$error .= $self->error if(!$self->_isValidPassword($self->session->form->process("identifier"),$self->session->form->process("identifierConfirm")));
return $self->resetExpiredPassword("<h1>".WebGUI::International::get(70)."</h1>".$error) if($error ne "");
$properties->{identifier} = Digest::MD5::md5_base64($session{form}{identifier});
$properties->{identifier} = Digest::MD5::md5_base64($self->session->form->process("identifier"));
$properties->{passwordLastUpdated} = time();
$self->saveParams($u->userId,$self->authMethod,$properties);
@ -614,7 +610,7 @@ sub resetExpiredPasswordSave {
#-------------------------------------------------------------------
sub validateEmail {
my $self = shift;
my ($userId) = WebGUI::SQL->quickArray("select userId from authentication where fieldData=".quote($session{form}{key})." and fieldName='emailValidationKey' and authMethod='WebGUI'");
my ($userId) = $self->session->db->quickArray("select userId from authentication where fieldData=".$self->session->db->quote($self->session->form->process("key"))." and fieldName='emailValidationKey' and authMethod='WebGUI'");
if (defined $userId) {
my $u = WebGUI::User->new($userId);
$u->status("Active");
@ -634,9 +630,9 @@ sub validateEmail {
sub updateAccount {
my $self = shift;
my $username = $session{form}{'authWebGUI.username'};
my $password = $session{form}{'authWebGUI.identifier'};
my $passConfirm = $session{form}{'authWebGUI.identifierConfirm'};
my $username = $self->session->form->get('authWebGUI.username');
my $password = $self->session->form->get('authWebGUI.identifier');
my $passConfirm = $self->session->form->get('authWebGUI.identifierConfirm');
my $display = '<li>'.WebGUI::International::get(81).'</li>';
my $error = "";
@ -669,7 +665,7 @@ sub updateAccount {
if(!$error){
if($username){
$u->username($username);
$session{form}{uid} = $u->userId;
$self->session->form->process("uid") = $u->userId;
}
if($password){
my $userData = $self->getParams;

View file

@ -14,7 +14,6 @@ package WebGUI::Cache;
=cut
use WebGUI::Session;
use File::Path;
use HTTP::Headers;
use HTTP::Request;
@ -77,7 +76,8 @@ Flushes the caching system. Must be overridden.
=cut
sub flush {
rmtree($WebGUI::Session::session{config}{uploadsPath}."/temp");
my $self = shift;
rmtree($self->session->config->get("uploadsPath")."/temp");
}
#-------------------------------------------------------------------
@ -95,10 +95,14 @@ sub get {
#-------------------------------------------------------------------
=head2 new ( key, [ namepsace ] )
=head2 new ( session, key, [ namepsace ] )
The new method will return a handler for the configured caching mechanism. Defaults to WebGUI::Cache::FileCache. You must override this method when building your own cache plug-in.
=head3 session
A reference to the current session.
=head3 key
A key to store the value under or retrieve it from.
@ -112,12 +116,13 @@ A subdivider to store this cache under. When building your own cache plug-in def
sub new {
my $cache;
my $class = shift;
if($WebGUI::Session::session{config}{memcached_servers}) {
my $session = shift;
if($session->config->get("memcached_servers")) {
require WebGUI::Cache::Memcached;
return WebGUI::Cache::Memcached->new(@_);
return WebGUI::Cache::Memcached->new($session,@_);
} else {
require WebGUI::Cache::FileCache;
return WebGUI::Cache::FileCache->new(@_);
return WebGUI::Cache::FileCache->new($session,@_);
}
}
@ -154,6 +159,19 @@ sub parseKey {
#-------------------------------------------------------------------
=head2 session ( )
Returns a reference session.
=cut
sub session {
my $self = shift;
return $self->{_session};
}
#-------------------------------------------------------------------
=head2 set ( value [, ttl] )
Sets a key value to the cache. Must be overridden.
@ -197,13 +215,13 @@ sub setByHTTP {
$userAgent->agent("WebGUI/".$WebGUI::VERSION);
$userAgent->timeout(30);
my $header = new HTTP::Headers;
my $referer = "http://webgui.http.request/".$WebGUI::Session::session{env}{SERVER_NAME}.$WebGUI::Session::session{env}{REQUEST_URI};
my $referer = "http://webgui.http.request/".$self->session->env->get("SERVER_NAME").$self->session->env->get("REQUEST_URI");
chomp $referer;
$header->referer($referer);
my $request = new HTTP::Request (GET => $url, $header);
my $response = $userAgent->request($request);
if ($response->is_error) {
WebGUI::ErrorHandler::error($url." could not be retrieved.");
$self->session->errorHandler->error($url." could not be retrieved.");
} else {
$self->set($response->content,$ttl);
}

View file

@ -106,7 +106,7 @@ Retrieve content from the filesystem cache.
sub get {
my $self = shift;
return undef if ($WebGUI::Session::session{config}{disableCache});
return undef if ($self->session->config->get("disableCache"));
my $folder = $self->getFolder;
if (-e $folder."/expires" && -e $folder."/cache" && open(FILE,"<".$folder."/expires")) {
my $expires = <FILE>;
@ -146,10 +146,10 @@ Figures out what the cache root for this namespace should be. A class method.
sub getNamespaceRoot {
my $self = shift;
my $root = $WebGUI::Session::session{config}{fileCacheRoot};
my $root = $self->session->config->get("fileCacheRoot");
unless ($root) {
if ($WebGUI::Session::session{os}{windowsish}) {
$root = $WebGUI::Session::session{env}{TEMP} || $WebGUI::Session::session{env}{TMP} || "/temp";
if ($self->session->os->get("windowsish")) {
$root = $self->session->env->get("TEMP") || $self->session->env->get("TMP") || "/temp";
} else {
$root = "/tmp";
}
@ -167,18 +167,10 @@ Returns the size (in bytes) of the current cache under this namespace. Consequen
=cut
#-------------------------------------------------------------------
=head2 getNamespaceSize ( )
Returns the size (in bytes) of the current cache under this namespace. Consequently it also cleans up expired cache items.
=cut
sub getNamespaceSize {
my $self = shift;
my $expiresModifier = shift || 0;
$session{cacheSize} = 0;
$self->session->stow->set("cacheSize", 0);
File::Find::find({no_chdir=>1, wanted=> sub {
return unless $File::Find::name =~ m/^(.*)expires$/;
my $dir = $1;
@ -188,20 +180,24 @@ sub getNamespaceSize {
if ($expires < time()+$expiresModifier) {
rmtree($dir);
} else {
$session{cacheSize} += -s $dir.'cache';
$self->session->stow->set("cacheSize", $self->session->stow->get("cacheSize") + -s $dir.'cache');
}
}
}
}, $self->getNamespaceRoot);
return $session{cacheSize};
return $self->session->stow->get("cacheSize");
}
#-------------------------------------------------------------------
=head2 new ( key [, namespace ] )
=head2 new ( session, key [, namespace ] )
Constructor.
=head3 session
A reference to the current session.
=head3 key
A key unique to this namespace. It is used to uniquely identify the cached content.
@ -215,9 +211,10 @@ Defaults to the config filename for the current site. The only reason to overrid
sub new {
my $cache;
my $class = shift;
my $session = shift;
my $key = $class->parseKey(shift);
my $namespace = shift || $WebGUI::Session::session{config}{configFile};
bless {_key=>$key, _namespace=>$namespace}, $class;
my $namespace = shift || $session->config->getFilename;
bless {_session=>$session, _key=>$key, _namespace=>$namespace}, $class;
}
@ -247,7 +244,7 @@ sub set {
unless (-e $path) {
eval {mkpath($path,0)};
if ($@) {
WebGUI::ErrorHandler::error("Couldn't create cache folder: ".$path." : ".$@);
$self->session->errorHandler->error("Couldn't create cache folder: ".$path." : ".$@);
return;
}
}

View file

@ -16,7 +16,6 @@ package WebGUI::Cache::Memcached;
use Cache::Memcached;
use Digest::MD5;
use WebGUI::Session;
our @ISA = qw(WebGUI::Cache);
@ -89,16 +88,20 @@ Retrieve content from the filesystem cache.
=cut
sub get {
return undef if ($WebGUI::Session::session{config}{disableCache});
return undef if ($_[0]->session->get("disableCache"));
return $_[0]->{_cache}->get($_[0]->{_key});
}
#-------------------------------------------------------------------
=head2 new ( key [, namespace ] )
=head2 new ( session, key [, namespace ] )
Constructor.
=head3 session
A reference to the current session.
=head3 key
A key unique to this namespace. It is used to uniquely identify the cached content.
@ -112,15 +115,16 @@ Defaults to the config filename for the current site. The only reason to overrid
sub new {
my $cache;
my $class = shift;
my $session = shift;
my $key = $class->parseKey(shift);
my $namespace = shift || $WebGUI::Session::session{config}{configFile};
my $namespace = shift || $session->config->getFilename;
# Overcome maximum key length of 255 characters
if(length($key.$namespace) > 255) {
$key = Digest::MD5::md5_base64($key);
}
my $servers = $WebGUI::Session::session{config}{memcached_servers};
my $servers = $session->config->get("memcached_servers");
$servers = [ $servers ] unless (ref $servers);
my %options = (
@ -129,7 +133,7 @@ sub new {
);
$cache = new Cache::Memcached(\%options);
bless {_cache => $cache, _key => $key}, $class;
bless {_session=>$session, _cache => $cache, _key => $key}, $class;
}

View file

@ -1,17 +1,16 @@
package WebGUI::Commerce;
use strict;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub setCommerceSetting {
my ($entry);
$entry = shift;
WebGUI::SQL->write("delete from commerceSettings where ".
"namespace=".quote($entry->{namespace})." and ".
"type=".quote($entry->{type})." and fieldName=".quote($entry->{fieldName}));
WebGUI::SQL->write("insert into commerceSettings (namespace, type, fieldName, fieldValue) values ".
"(".quote($entry->{namespace}).",".quote($entry->{type}).",".quote($entry->{fieldName}).",".quote($entry->{fieldValue}).")");
$self->session->db->write("delete from commerceSettings where ".
"namespace=".$self->session->db->quote($entry->{namespace})." and ".
"type=".$self->session->db->quote($entry->{type})." and fieldName=".$self->session->db->quote($entry->{fieldName}));
$self->session->db->write("insert into commerceSettings (namespace, type, fieldName, fieldValue) values ".
"(".$self->session->db->quote($entry->{namespace}).",".$self->session->db->quote($entry->{type}).",".$self->session->db->quote($entry->{fieldName}).",".$self->session->db->quote($entry->{fieldValue}).")");
}
1;

View file

@ -55,7 +55,7 @@ This returns the description of the item. This must be implemented by an item pl
=cut
sub description {
return WebGUI::ErrorHandler::fatal('The description method of WebGUI::Commerce::Item must be overridden.');
return $self->session->errorHandler->fatal('The description method of WebGUI::Commerce::Item must be overridden.');
}
#-------------------------------------------------------------------
@ -95,7 +95,7 @@ by an item plugin.
=cut
sub id {
return WebGUI::ErrorHandler::fatal('The id method of WebGUI::Commerce::Item must be overridden.');
return $self->session->errorHandler->fatal('The id method of WebGUI::Commerce::Item must be overridden.');
}
#-------------------------------------------------------------------
@ -120,7 +120,7 @@ Returns the name of the item. This must be implemented by an item plugin.
=cut
sub name {
return WebGUI::ErrorHandler::fatal('The name method of WebGUI::Commerce::Item must be overridden.');
return $self->session->errorHandler->fatal('The name method of WebGUI::Commerce::Item must be overridden.');
}
#-------------------------------------------------------------------
@ -160,15 +160,15 @@ sub new {
$id = shift;
$namespace = shift;
WebGUI::ErrorHandler::fatal('No namespace') unless ($namespace);
WebGUI::ErrorHandler::fatal('No ID') unless ($id);
$self->session->errorHandler->fatal('No namespace') unless ($namespace);
$self->session->errorHandler->fatal('No ID') unless ($id);
$cmd = "WebGUI::Commerce::Item::$namespace";
$load = "use $cmd";
eval($load);
WebGUI::ErrorHandler::warn("Item plugin failed to compile: $cmd.".$@) if($@);
$self->session->errorHandler->warn("Item plugin failed to compile: $cmd.".$@) if($@);
$plugin = eval($cmd."->new('$id', '$namespace')");
WebGUI::ErrorHandler::warn("Couldn't instantiate Item plugin: $cmd.".$@) if($@);
$self->session->errorHandler->warn("Couldn't instantiate Item plugin: $cmd.".$@) if($@);
return $plugin;
}
@ -182,7 +182,7 @@ term price. This must be implemented by an item plugin.
=cut
sub price {
return WebGUI::ErrorHandler::fatalError('The price method of WebGUI::Commerce::Item must be overridden.');
return $self->session->errorHandler->fatalError('The price method of WebGUI::Commerce::Item must be overridden.');
}
#-------------------------------------------------------------------
@ -194,7 +194,7 @@ Returns the type (namespace) of the item.
=cut
sub type {
return WebGUI::ErrorHandler::fatalError('The type method of WebGUI::Commerce::Item must be overridden.');
return $self->session->errorHandler->fatalError('The type method of WebGUI::Commerce::Item must be overridden.');
}
#-------------------------------------------------------------------

View file

@ -173,7 +173,7 @@ Returns a reference to an array of all enabled instantiated payment plugins.
sub getEnabledPlugins {
my (@enabledPlugins, $plugin, @plugins);
@enabledPlugins = WebGUI::SQL->buildArray("select namespace from commerceSettings where type='Payment' and fieldName='enabled' and fieldValue='1'");
@enabledPlugins = $self->session->db->buildArray("select namespace from commerceSettings where type='Payment' and fieldName='enabled' and fieldValue='1'");
foreach (@enabledPlugins) {
$plugin = WebGUI::Commerce::Payment->load($_);
@ -200,7 +200,7 @@ sub init {
$class = shift;
$namespace = shift;
$properties = WebGUI::SQL->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".quote($namespace)." and type='Payment'");
$properties = $self->session->db->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".$self->session->db->quote($namespace)." and type='Payment'");
bless {_properties=>$properties, _namespace=>$namespace, _enabled=>$properties->{enabled}}, $class;
}
@ -214,7 +214,7 @@ Returns the gatewayId of the transaction. You must override this method.
=cut
sub gatewayId {
return WebGUI::ErrorHandler::fatal("You must override the gatewayId method in your Payment plugin.");
return $self->session->errorHandler->fatal("You must override the gatewayId method in your Payment plugin.");
}
#-------------------------------------------------------------------
@ -252,7 +252,7 @@ Returns the error code of the last submission.
=cut
sub errorCode {
return WebGUI::ErrorHandler::fatal("You must override thie errorCode method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override thie errorCode method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -276,9 +276,9 @@ sub load {
$cmd = "WebGUI::Commerce::Payment::$namespace";
$load = "use $cmd";
eval($load);
WebGUI::ErrorHandler::warn("Payment plugin failed to compile: $cmd.".$@) if($@);
$self->session->errorHandler->warn("Payment plugin failed to compile: $cmd.".$@) if($@);
$plugin = eval($cmd."->init");
WebGUI::ErrorHandler::warn("Couldn't instantiate payment plugin: $cmd.".$@) if($@);
$self->session->errorHandler->warn("Couldn't instantiate payment plugin: $cmd.".$@) if($@);
return $plugin;
}
@ -291,7 +291,7 @@ Returns the (display) name of the plugin. You must override this method.
=cut
sub name {
return WebGUI::ErrorHandler::fatal("You must override the name method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the name method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -362,7 +362,7 @@ Returns the result code of the transaction. You must override this method.
=cut
sub resultCode {
return WebGUI::ErrorHandler::fatal("You must override the resultCode method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the resultCode method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -374,7 +374,7 @@ Returns the result message of the transaction. You must override this method.
=cut
sub resultMessage {
return WebGUI::ErrorHandler::fatal("You must override the resultMessage method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the resultMessage method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -449,7 +449,7 @@ The amaount of money that's being charged for shipping.
=cut
sub shippingCost {
return WebGUI::ErrorHandler::fatal("You must override the shippingCost method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the shippingCost method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -466,7 +466,7 @@ The description of the shiping cost.
=cut
sub shippingDescription {
return WebGUI::ErrorHandler::fatal("You must override the shippingDescription method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the shippingDescription method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -483,7 +483,7 @@ You must override this method.
=cut
sub supports {
return WebGUI::ErrorHandler::fatal("You must override the supports method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the supports method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -495,7 +495,7 @@ A boolean indicating whether the payment has been finished or not. You must over
=cut
sub transactionCompleted {
return WebGUI::ErrorHandler::fatal("You must override the transactionCompleted method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the transactionCompleted method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -507,7 +507,7 @@ Returns an error message if a transaction error has occurred. You must override
=cut
sub transactionError {
return WebGUI::ErrorHandler::fatal("You must override the transactionError method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the transactionError method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -519,7 +519,7 @@ A boolean indicating whether the payment is pending or not. You must override th
=cut
sub transactionPending {
return WebGUI::ErrorHandler::fatal("You must override the transactionPending method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the transactionPending method in the payment plugin.");
}
#-------------------------------------------------------------------
@ -533,7 +533,7 @@ undef. You must override this method.
=cut
sub validateFormData {
return WebGUI::ErrorHandler::fatal("You must override the validateFormData method in the payment plugin.");
return $self->session->errorHandler->fatal("You must override the validateFormData method in the payment plugin.");
}
1;

View file

@ -61,7 +61,7 @@ sub cancelRecurringPayment {
# print "FIRST PAGE SUCCESS!\n";
# print "(".$response->base.")\n";
} else {
WebGUI::ErrorHandler::fatalError(
$self->session->errorHandler->fatalError(
'Connection Error while trying to cancel transaction '.$recurring->{transaction}->transactionId." \n".
"Could not reach login page.\n".
"(".$response->base.")\n".
@ -84,7 +84,7 @@ sub cancelRecurringPayment {
# print "CANCELATION PAGE SUCCESS!\n";
# print "(".$response->base.")\n";
} else {
WebGUI::ErrorHandler::fatalError(
$self->session->errorHandler->fatalError(
'Connection Error while trying to cancel transaction '.$recurring->{transaction}->transactionId." \n".
"(".$response->base.")\n".
$response->status_line. "\n");
@ -108,38 +108,38 @@ sub checkoutForm {
$i18n = WebGUI::International->new('CommercePaymentITransact');
$u = WebGUI::User->new($session{user}{userId});
$u = WebGUI::User->new($self->session->user->profileField("userId"));
$f = WebGUI::HTMLForm->new;
$f->text(
-name => 'firstName',
-label => $i18n->get('firstName'),
-value => $session{form}{firstName} || $u->profileField('firstName')
-value => $self->session->form->process("firstName") || $u->profileField('firstName')
);
$f->text(
-name => 'lastName',
-label => $i18n->get('lastName'),
-value => $session{form}{lastName} || $u->profileField('lastName')
-value => $self->session->form->process("lastName") || $u->profileField('lastName')
);
$f->text(
-name => 'address',
-label => $i18n->get('address'),
-value => $session{form}{address} || $u->profileField('homeAddress')
-value => $self->session->form->process("address") || $u->profileField('homeAddress')
);
$f->text(
-name => 'city',
-label => $i18n->get('city'),
-value => $session{form}{city} || $u->profileField('homeCity')
-value => $self->session->form->process("city") || $u->profileField('homeCity')
);
$f->text(
-name => 'state',
-label => $i18n->get('state'),
-value => $session{form}{state} || $u->profileField('homeState')
-value => $self->session->form->process("state") || $u->profileField('homeState')
);
$f->zipcode(
-name => 'zipcode',
-label => $i18n->get('zipcode'),
-value => $session{form}{zipcode} || $u->profileField('homeZip')
-value => $self->session->form->process("zipcode") || $u->profileField('homeZip')
);
my %countries;
tie %countries, 'Tie::IxHash';
@ -389,25 +389,25 @@ sub checkoutForm {
$f->selectBox(
-name=>"country",
-label=>$i18n->get("country"),
-value=>[$session{form}{country}],
-value=>[$self->session->form->process("country")],
-defaultValue=>[$u->profileField("homeCountry")],
-options=>\%countries
);
$f->phone(
-name=>"phone",
-label=>$i18n->get("phone"),
-value=>$session{form}{phone},
-value=>$self->session->form->process("phone"),
-defaultValue=>$u->profileField("homePhone")
);
$f->email(
-name => 'email',
-label => $i18n->get('email'),
-value => $session{form}{email} || $u->profileField('email')
-value => $self->session->form->process("email") || $u->profileField('email')
);
$f->text(
-name => 'cardNumber',
-label => $i18n->get('cardNumber'),
-value => $session{form}{cardNumber}
-value => $self->session->form->process("cardNumber")
);
tie %months, "Tie::IxHash";
%months = map {sprintf('%02d',$_) => sprintf('%02d',$_)} 1..12;
@ -416,14 +416,14 @@ sub checkoutForm {
$f->readOnly(
-label => $i18n->get('expiration date'),
-value =>
WebGUI::Form::selectBox({name => 'expMonth', options => \%months, value => [$session{form}{expMonth}]}).
WebGUI::Form::selectBox({name => 'expMonth', options => \%months, value => [$self->session->form->process("expMonth")]}).
" / ".
WebGUI::Form::selectBox({name => 'expYear', options => \%years, value => [$session{form}{expYear}]})
WebGUI::Form::selectBox({name => 'expYear', options => \%years, value => [$self->session->form->process("expYear")]})
);
$f->integer(
-name => 'cvv2',
-label => $i18n->get('cvv2'),
-value => $session{form}{cvv2}
-value => $self->session->form->process("cvv2")
) if ($self->get('useCVV2'));
return $f->printRowsOnly;
@ -468,7 +468,7 @@ sub configurationForm {
-value => '<br />'
);
$f->readOnly(
-value => $i18n->get('extra info').'<br /><b>https://'.$session{config}{defaultSitename}.'/?op=confirmRecurringTransaction;gateway='.$self->namespace
-value => $i18n->get('extra info').'<br /><b>https://'.$self->session->config->get("defaultSitename").'/?op=confirmRecurringTransaction;gateway='.$self->namespace
);
return $self->SUPER::configurationForm($f->printRowsOnly);
@ -480,18 +480,18 @@ sub confirmRecurringTransaction {
my $self = shift;
my $form = $session{form};
my $transaction = WebGUI::Commerce::Transaction->getByGatewayId($session{form}{orig_xid}, $self->namespace);
my $transaction = WebGUI::Commerce::Transaction->getByGatewayId($self->session->form->process("orig_xid"), $self->namespace);
my $itemProperties = $transaction->getItems->[0];
my $item = WebGUI::Commerce::Item->new($itemProperties->{itemId}, $itemProperties->{itemType});
my $startEpoch = WebGUI::DateTime::setToEpoch(sprintf("%4d-%02d-%02d %02d:%02d:%02d", unpack('a4a2a2a2a2a2', $form->{start_date})));
my $currentEpoch = WebGUI::DateTime::setToEpoch(sprintf("%4d-%02d-%02d %02d:%02d:%02d", unpack('a4a2a2a2a2a2', $form->{when})));
WebGUI::SQL->write("delete from ITransact_recurringStatus where gatewayId=".quote($form->{orig_xid}));
WebGUI::SQL->write("insert into ITransact_recurringStatus ".
$self->session->db->write("delete from ITransact_recurringStatus where gatewayId=".$self->session->db->quote($form->{orig_xid}));
$self->session->db->write("insert into ITransact_recurringStatus ".
"(gatewayId, initDate, lastTransaction, status, errorMessage, recipe) values ".
"(".quote($form->{orig_xid}).", $startEpoch, $currentEpoch, ".quote($form->{status}).", ".quote($form->{error_message}).
", ".quote($form->{recipe_name}).")");
"(".$self->session->db->quote($form->{orig_xid}).", $startEpoch, $currentEpoch, ".$self->session->db->quote($form->{status}).", ".$self->session->db->quote($form->{error_message}).
", ".$self->session->db->quote($form->{recipe_name}).")");
}
#-------------------------------------------------------------------
@ -534,9 +534,9 @@ sub getRecurringPaymentStatus {
yearly => 365*3600*24
);
my $transactionData = WebGUI::SQL->quickHashRef("select * from ITransact_recurringStatus where gatewayId=".quote($recurringId));
my $transactionData = $self->session->db->quickHashRef("select * from ITransact_recurringStatus where gatewayId=".$self->session->db->quote($recurringId));
unless ($transactionData->{recipe}) { # if for some reason there's no transaction data, we shouldn't calc anything
WebGUI::ErrorHandler::error("For some reason recurring transaction $recurringId doesn't have any recurring status transaction data. This is most likely because you don't have the Recurring Postback URL set in your ITransact virtual terminal.");
$self->session->errorHandler->error("For some reason recurring transaction $recurringId doesn't have any recurring status transaction data. This is most likely because you don't have the Recurring Postback URL set in your ITransact virtual terminal.");
return undef;
}
my $lastTerm = int(($transactionData->{lastTransaction} - $transactionData->{initDate}) / $resolve{$transactionData->{recipe}}) + 1;
@ -691,7 +691,7 @@ my %transactionData = %{$self->{_transactionParams}};
<TransactionData>
<VendorId>".$self->get('vendorId')."</VendorId>
<VendorPassword>".$self->get('password')."</VendorPassword>
<HomePage>".$session{setting}{companyURL}."</HomePage>";
<HomePage>".$self->session->setting->get("companyURL")."</HomePage>";
if ($self->{_recurring}) {
$xml .=
@ -804,44 +804,44 @@ sub validateFormData {
$i18n = WebGUI::International->new('CommercePaymentITransact');
push (@error, $i18n->get('invalid firstName')) unless ($session{form}{firstName});
push (@error, $i18n->get('invalid lastName')) unless ($session{form}{lastName});
push (@error, $i18n->get('invalid address')) unless ($session{form}{address});
push (@error, $i18n->get('invalid city')) unless ($session{form}{city});
push (@error, $i18n->get('invalid zip')) if ($session{form}{zipcode} eq "" && $session{form}{country} eq "United States");
push (@error, $i18n->get('invalid email')) unless ($session{form}{email});
push (@error, $i18n->get('invalid firstName')) unless ($self->session->form->process("firstName"));
push (@error, $i18n->get('invalid lastName')) unless ($self->session->form->process("lastName"));
push (@error, $i18n->get('invalid address')) unless ($self->session->form->process("address"));
push (@error, $i18n->get('invalid city')) unless ($self->session->form->process("city"));
push (@error, $i18n->get('invalid zip')) if ($self->session->form->process("zipcode") eq "" && $self->session->form->process("country") eq "United States");
push (@error, $i18n->get('invalid email')) unless ($self->session->form->process("email"));
push (@error, $i18n->get('invalid card number')) unless ($session{form}{cardNumber} =~ /^\d+$/);
push (@error, $i18n->get('invalid cvv2')) if ($session{form}{cvv2} !~ /^\d+$/ && $self->get('useCVV2'));
push (@error, $i18n->get('invalid card number')) unless ($self->session->form->process("cardNumber") =~ /^\d+$/);
push (@error, $i18n->get('invalid cvv2')) if ($self->session->form->process("cvv2") !~ /^\d+$/ && $self->get('useCVV2'));
($currentYear, $currentMonth) = WebGUI::DateTime::localtime;
# Check if expDate and expYear have sane values
unless (($session{form}{expMonth} =~ /^(0[1-9]|1[0-2])$/) && ($session{form}{expYear} =~ /^\d\d\d\d$/)) {
unless (($self->session->form->process("expMonth") =~ /^(0[1-9]|1[0-2])$/) && ($self->session->form->process("expYear") =~ /^\d\d\d\d$/)) {
push (@error, $i18n->get('invalid expiration date'));
} elsif (($session{form}{expYear} < $currentYear) ||
(($session{form}{expYear} == $currentYear) && ($session{form}{expMonth} < $currentMonth))) {
} elsif (($self->session->form->process("expYear") < $currentYear) ||
(($self->session->form->process("expYear") == $currentYear) && ($self->session->form->process("expMonth") < $currentMonth))) {
push (@error, $i18n->get('invalid expiration date'));
}
unless (@error) {
$self->{_cardData} = {
ACCT => $session{form}{cardNumber},
EXPMONTH => $session{form}{expMonth},
EXPYEAR => $session{form}{expYear},
CVV2 => $session{form}{cvv2},
ACCT => $self->session->form->process("cardNumber"),
EXPMONTH => $self->session->form->process("expMonth"),
EXPYEAR => $self->session->form->process("expYear"),
CVV2 => $self->session->form->process("cvv2"),
};
$self->{_userData} = {
STREET => $session{form}{address},
ZIP => $session{form}{zipcode},
CITY => $session{form}{city},
FIRSTNAME => $session{form}{firstName},
LASTNAME => $session{form}{lastName},
EMAIL => $session{form}{email},
STATE => $session{form}{state},
COUNTRY => $session{form}{country},
PHONE => $session{form}{phone},
STREET => $self->session->form->process("address"),
ZIP => $self->session->form->process("zipcode"),
CITY => $self->session->form->process("city"),
FIRSTNAME => $self->session->form->process("firstName"),
LASTNAME => $self->session->form->process("lastName"),
EMAIL => $self->session->form->process("email"),
STATE => $self->session->form->process("state"),
COUNTRY => $self->session->form->process("country"),
PHONE => $self->session->form->process("phone"),
};
return 0;

View file

@ -134,7 +134,7 @@ Returns a reference to an array of all enabled instantiated payment plugins.
sub getEnabledPlugins {
my (@enabledPlugins, $plugin, @plugins);
@enabledPlugins = WebGUI::SQL->buildArray("select namespace from commerceSettings where type='Shipping' and fieldName='enabled' and fieldValue='1'");
@enabledPlugins = $self->session->db->buildArray("select namespace from commerceSettings where type='Shipping' and fieldName='enabled' and fieldValue='1'");
foreach (@enabledPlugins) {
$plugin = WebGUI::Commerce::Shipping->load($_);
@ -161,9 +161,9 @@ sub init {
$class = shift;
$namespace = shift;
WebGUI::ErrorHandler::fatal('No namespace passed to init.') unless ($namespace);
$self->session->errorHandler->fatal('No namespace passed to init.') unless ($namespace);
$properties = WebGUI::SQL->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".quote($namespace)." and type='Shipping'");
$properties = $self->session->db->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".$self->session->db->quote($namespace)." and type='Shipping'");
$shoppingCart = WebGUI::Commerce::ShoppingCart->new;
bless {_properties=>$properties,
@ -204,14 +204,14 @@ sub load {
$class = shift;
$namespace = shift;
WebGUI::ErrorHandler::fatal('No namespace passed to load.') unless ($namespace);
$self->session->errorHandler->fatal('No namespace passed to load.') unless ($namespace);
$cmd = "WebGUI::Commerce::Shipping::$namespace";
$load = "use $cmd";
eval($load);
WebGUI::ErrorHandler::warn("Shipping plugin failed to compile: $cmd.".$@) if($@);
$self->session->errorHandler->warn("Shipping plugin failed to compile: $cmd.".$@) if($@);
$plugin = eval($cmd."->init");
WebGUI::ErrorHandler::warn("Couldn't instantiate shipping plugin: $cmd.".$@) if($@);
$self->session->errorHandler->warn("Couldn't instantiate shipping plugin: $cmd.".$@) if($@);
return $plugin;
}
@ -224,7 +224,7 @@ Returns the (display) name of the plugin. You must override this method.
=cut
sub name {
return WebGUI::ErrorHandler::fatal("You must override the name method in the shipping plugin.");
return $self->session->errorHandler->fatal("You must override the name method in the shipping plugin.");
}
#-------------------------------------------------------------------

View file

@ -74,10 +74,10 @@ sub add {
quantity => $self->{_items}{$itemId."_".$itemType}{quantity} + $quantity
};
WebGUI::SQL->write("delete from shoppingCart where sessionId=".quote($self->{_sessionId})." and itemId=".quote($itemId)." and itemType=".quote($itemType));
WebGUI::SQL->write("insert into shoppingCart ".
$self->session->db->write("delete from shoppingCart where sessionId=".$self->session->db->quote($self->{_sessionId})." and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
$self->session->db->write("insert into shoppingCart ".
"(sessionId, itemId, itemType, quantity) values ".
"(".quote($self->{_sessionId}).",".quote($itemId).",".quote($itemType).",".$self->{_items}{$itemId."_".$itemType}{quantity}.")");
"(".$self->session->db->quote($self->{_sessionId}).",".$self->session->db->quote($itemId).",".$self->session->db->quote($itemType).",".$self->{_items}{$itemId."_".$itemType}{quantity}.")");
}
#-------------------------------------------------------------------
@ -103,8 +103,8 @@ sub delete {
$itemId = shift;
$itemType = shift;
WebGUI::SQL->write("delete from shoppingCart where sessionId=".quote($self->{_sessionId}).
" and itemId=".quote($itemId)." and itemType=".quote($itemType));
$self->session->db->write("delete from shoppingCart where sessionId=".$self->session->db->quote($self->{_sessionId}).
" and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
delete $self->{_items}{$itemId."_".$itemType};
}
@ -143,14 +143,14 @@ sub setQuantity {
$itemType = shift;
$quantity = shift;
WebGUI::ErrorHandler::fatal('No quantity or quantity is not a number: ('.$quantity.')') unless ($quantity =~ /^-?\d+$/);
$self->session->errorHandler->fatal('No quantity or quantity is not a number: ('.$quantity.')') unless ($quantity =~ /^-?\d+$/);
return $self->delete($itemId, $itemType) if ($quantity <= 0);
$self->{_items}{$itemId."_".$itemType}->{quantity} = $quantity;
WebGUI::SQL->write("update shoppingCart set quantity=".quote($quantity).
" where sessionId=".quote($self->{_sessionId})." and itemId=".quote($itemId)." and itemType=".quote($itemType));
$self->session->db->write("update shoppingCart set quantity=".$self->session->db->quote($quantity).
" where sessionId=".$self->session->db->quote($self->{_sessionId})." and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
}
#-------------------------------------------------------------------
@ -165,7 +165,7 @@ sub empty {
my ($self);
$self = shift;
WebGUI::SQL->write("delete from shoppingCart where sessionId=".quote($self->{_sessionId}));
$self->session->db->write("delete from shoppingCart where sessionId=".$self->session->db->quote($self->{_sessionId}));
}
#-------------------------------------------------------------------
@ -246,9 +246,9 @@ of the current user.
sub new {
my ($class, $sessionId, $sth, $row, %items);
$class = shift;
$sessionId = shift || $session{var}{sessionId};
$sessionId = shift || $self->session->var->get("sessionId");
$sth = WebGUI::SQL->read("select * from shoppingCart where sessionId=".quote($sessionId));
$sth = $self->session->db->read("select * from shoppingCart where sessionId=".$self->session->db->quote($sessionId));
while ($row = $sth->hashRef) {
$items{$row->{itemId}."_".$row->{itemType}} = $row;
}

View file

@ -28,12 +28,12 @@ sub addItem {
$item = shift;
$quantity = shift;
WebGUI::SQL->write("insert into transactionItem ".
$self->session->db->write("insert into transactionItem ".
"(transactionId, itemName, amount, quantity, itemId, itemType) values ".
"(".quote($self->{_transactionId}).",".quote($item->name).",".quote($item->price).",".quote($quantity).",".
quote($item->id).",".quote($item->type).")");
"(".$self->session->db->quote($self->{_transactionId}).",".$self->session->db->quote($item->name).",".$self->session->db->quote($item->price).",".$self->session->db->quote($quantity).",".
$self->session->db->quote($item->id).",".$self->session->db->quote($item->type).")");
# Adjust total amount in the transaction table.
WebGUI::SQL->write("update transaction set amount=amount+".($item->price * $quantity)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set amount=amount+".($item->price * $quantity)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
$self->{_properties}{amount} += ($item->price * $quantity);
push @{$self->{_items}}, {
transactionId => $self->{_transactionId},
@ -107,8 +107,8 @@ Deletes the transaction from the database;
sub delete {
my ($self) = shift;
WebGUI::SQL->write("delete from transaction where transactionId=".quote($self->{_transactionId}));
WebGUI::SQL->write("delete from transactionItem where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("delete from transaction where transactionId=".$self->session->db->quote($self->{_transactionId}));
$self->session->db->write("delete from transactionItem where transactionId=".$self->session->db->quote($self->{_transactionId}));
undef $self;
}
@ -144,8 +144,8 @@ sub deleteItem {
$itemId = shift;
$itemType = shift;
WebGUI::ErrorHandler::fatal('No itemId') unless ($itemId);
WebGUI::ErrorHandler::fatal('No itemType') unless ($itemType);
$self->session->errorHandler->fatal('No itemId') unless ($itemId);
$self->session->errorHandler->fatal('No itemType') unless ($itemType);
$amount = $self->get('amount');
@ -158,10 +158,10 @@ sub deleteItem {
}
}
WebGUI::SQL->write("delete from transactionItem where transactionId=".quote($self->get('transactionId')).
" and itemId=".quote($itemId)." and itemType=".quote($itemType));
$self->session->db->write("delete from transactionItem where transactionId=".$self->session->db->quote($self->get('transactionId')).
" and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
WebGUI::SQL->write("update transaction set amount=".quote($amount)." where transactionId=".quote($self->get('transactionId')));
$self->session->db->write("update transaction set amount=".$self->session->db->quote($amount)." where transactionId=".$self->session->db->quote($self->get('transactionId')));
$self->{_properties}{amount} = $amount;
@ -187,7 +187,7 @@ sub gateway {
if ($gateway) {
$self->{_properties}{gateway} = $gateway;
WebGUI::SQL->write("update transaction set gateway=".quote($gateway)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set gateway=".$self->session->db->quote($gateway)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{gateway};
@ -212,7 +212,7 @@ sub gatewayId {
if ($gatewayId) {
$self->{_properties}{gatewayId} = $gatewayId;
WebGUI::SQL->write("update transaction set gatewayId=".quote($gatewayId)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set gatewayId=".$self->session->db->quote($gatewayId)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{gatewayId};
@ -263,8 +263,8 @@ sub getByGatewayId {
$gatewayId = shift;
$paymentGateway = shift;
($transactionId) = WebGUI::SQL->quickArray("select transactionId from transaction where gatewayId=".quote($gatewayId).
" and gateway=".quote($paymentGateway));
($transactionId) = $self->session->db->quickArray("select transactionId from transaction where gatewayId=".$self->session->db->quote($gatewayId).
" and gateway=".$self->session->db->quote($paymentGateway));
return WebGUI::Commerce::Transaction->new($transactionId) if $transactionId;
return undef;
@ -320,17 +320,17 @@ sub getTransactions {
$self = shift;
$criteria = shift;
push (@constraints, 'initDate >= '.quote($criteria->{initStart})) if (defined $criteria->{initStart});
push (@constraints, 'initDate <= '.quote($criteria->{initStop})) if (defined $criteria->{initStop});
push (@constraints, 'completionDate >= '.quote($criteria->{completionStart})) if (defined $criteria->{completionStart});
push (@constraints, 'completionDate <= '.quote($criteria->{completionStop})) if (defined $criteria->{completionStop});
push (@constraints, 'status='.quote($criteria->{paymentStatus})) if (defined $criteria->{paymentStatus});
push (@constraints, 'shippingStatus='.quote($criteria->{shippingStatus})) if (defined $criteria->{shippingStatus});
push (@constraints, 'initDate >= '.$self->session->db->quote($criteria->{initStart})) if (defined $criteria->{initStart});
push (@constraints, 'initDate <= '.$self->session->db->quote($criteria->{initStop})) if (defined $criteria->{initStop});
push (@constraints, 'completionDate >= '.$self->session->db->quote($criteria->{completionStart})) if (defined $criteria->{completionStart});
push (@constraints, 'completionDate <= '.$self->session->db->quote($criteria->{completionStop})) if (defined $criteria->{completionStop});
push (@constraints, 'status='.$self->session->db->quote($criteria->{paymentStatus})) if (defined $criteria->{paymentStatus});
push (@constraints, 'shippingStatus='.$self->session->db->quote($criteria->{shippingStatus})) if (defined $criteria->{shippingStatus});
$sql = 'select transactionId from transaction';
$sql .= ' where '.join(' and ', @constraints) if (@constraints);
@transactionIds = WebGUI::SQL->buildArray($sql);
@transactionIds = $self->session->db->buildArray($sql);
foreach (@transactionIds) {
push(@transactions, WebGUI::Commerce::Transaction->new($_));
@ -360,7 +360,7 @@ sub isRecurring {
if (defined $recurring) {
$self->{_properties}{recurring} = $recurring;
WebGUI::SQL->write("update transaction set recurring=".quote($recurring)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set recurring=".$self->session->db->quote($recurring)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{recurring};
@ -385,7 +385,7 @@ sub lastPayedTerm {
if (defined $lastPayedTerm) {
$self->{_properties}{lastPayedTerm} = $lastPayedTerm;
WebGUI::SQL->write("update transaction set lastPayedTerm=".quote($lastPayedTerm)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set lastPayedTerm=".$self->session->db->quote($lastPayedTerm)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{lastPayedTerm};
@ -418,18 +418,18 @@ sub new {
$class = shift;
$transactionId = shift;
$gatewayId = shift;
$userId = shift || $session{user}{userId};
$userId = shift || $self->session->user->profileField("userId");
if ($transactionId eq 'new') {
$transactionId = WebGUI::Id::generate;
WebGUI::SQL->write("insert into transaction ".
$self->session->db->write("insert into transaction ".
"(transactionId, userId, amount, gatewayId, initDate, completionDate, status) values ".
"(".quote($transactionId).",".quote($userId).",0,".quote($gatewayId).",".quote(time).",NULL,'Pending')");
"(".$self->session->db->quote($transactionId).",".$self->session->db->quote($userId).",0,".$self->session->db->quote($gatewayId).",".$self->session->db->quote(time).",NULL,'Pending')");
}
$properties = WebGUI::SQL->quickHashRef("select * from transaction where transactionId=".quote($transactionId));
$sth = WebGUI::SQL->read("select * from transactionItem where transactionId=".quote($transactionId));
$properties = $self->session->db->quickHashRef("select * from transaction where transactionId=".$self->session->db->quote($transactionId));
$sth = $self->session->db->read("select * from transactionItem where transactionId=".$self->session->db->quote($transactionId));
while ($row = $sth->hashRef) {
push(@items, $row);
}
@ -447,7 +447,7 @@ Returns a reference to an array which contains transaction objects of all pendin
sub pendingTransactions {
my (@transactionIds, @transactions);
@transactionIds = WebGUI::SQL->buildArray("select transactionId from transaction where status = 'Pending'");
@transactionIds = $self->session->db->buildArray("select transactionId from transaction where status = 'Pending'");
foreach (@transactionIds) {
push(@transactions, WebGUI::Commerce::Transaction->new($_));
@ -475,7 +475,7 @@ sub shippingCost {
if ($shippingCost) {
$self->{_properties}{shippingCost} = $shippingCost;
WebGUI::SQL->write("update transaction set shippingCost=".quote($shippingCost)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set shippingCost=".$self->session->db->quote($shippingCost)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{shippingCost};
@ -500,7 +500,7 @@ sub shippingMethod {
if ($shippingMethod) {
$self->{_properties}{shippingMethod} = $shippingMethod;
WebGUI::SQL->write("update transaction set shippingMethod=".quote($shippingMethod)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set shippingMethod=".$self->session->db->quote($shippingMethod)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{shippingMethod};
@ -526,7 +526,7 @@ sub shippingOptions {
if ($shippingOptions) {
$self->{_properties}{shippingOptions} = $shippingOptions;
WebGUI::SQL->write("update transaction set shippingOptions=".quote($shippingOptions)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set shippingOptions=".$self->session->db->quote($shippingOptions)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{shippingOptions};
@ -551,7 +551,7 @@ sub shippingStatus {
if ($shippingStatus) {
$self->{_properties}{shippingStatus} = $shippingStatus;
WebGUI::SQL->write("update transaction set shippingStatus=".quote($shippingStatus)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set shippingStatus=".$self->session->db->quote($shippingStatus)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{shippingStatus};
@ -576,7 +576,7 @@ sub status {
if ($status) {
$self->{_properties}{status} = $status;
WebGUI::SQL->write("update transaction set status=".quote($status)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set status=".$self->session->db->quote($status)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{status};
@ -602,7 +602,7 @@ sub trackingNumber {
if ($trackingNumber) {
$self->{_properties}{trackingNumber} = $trackingNumber;
WebGUI::SQL->write("update transaction set trackingNumber=".quote($trackingNumber)." where transactionId=".quote($self->{_transactionId}));
$self->session->db->write("update transaction set trackingNumber=".$self->session->db->quote($trackingNumber)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
}
return $self->{_properties}{trackingNumber};
@ -638,7 +638,7 @@ sub transactionsByUser {
my $self = shift;
my $userId = shift;
@transactionIds = WebGUI::SQL->buildArray("select transactionId from transaction where userId =".quote($userId));
@transactionIds = $self->session->db->buildArray("select transactionId from transaction where userId =".$self->session->db->quote($userId));
foreach (@transactionIds) {
push (@transactions, WebGUI::Commerce::Transaction->new($_));
}

View file

@ -18,8 +18,6 @@ package WebGUI::DatabaseLink;
use strict;
use Tie::CPHash;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::SQL;
=head1 NAME
@ -32,13 +30,14 @@ This package contains utility methods for WebGUI's database link system.
=head1 SYNOPSIS
use WebGUI::DatabaseLink;
$hashRef = WebGUI::DatabaseLink::getList();
%databaseLink = WebGUI::DatabaseLink::get($databaseLinkId);
$hashRef = WebGUI::DatabaseLink->getList($session);
$dbLink = WebGUI::DatabaseLink->new($databaseLinkId);
$dbh = $dbLink->dbh;
$dbLink = WebGUI::DatabaseLink->new($session,$databaseLinkId);
$dbh = $dbLink->db;
$dbLink->disconnect;
$session = $dbLink->session;
=head1 METHODS
These subroutines are available from this package:
@ -46,94 +45,170 @@ These subroutines are available from this package:
=cut
#-------------------------------------------------------------------
=head2 getList ( )
Returns a hash reference containing all database links. The format is:
databaseLinkId => title
=head2 copy ( )
Returns a new database link id, after copying the properties of this database link to a new entry.
=cut
sub getList {
my $list = WebGUI::SQL->buildHashRef("select databaseLinkId, title from databaseLink order by title");
$list->{'0'} = WebGUI::International::get(1076);
return $list;
sub copy {
my $self = shift;
my %params = %{$self->{_databaseLink}};
$params{databaseLinkId} = "new";
return $self->session->db->setRow("databaseLink","databaseLinkId",\%params);
}
#-------------------------------------------------------------------
=head2 get ( databaseLinkId )
Returns a hash containing a single database link.
=head2 create ( session, params)
=head3 databaseLinkId
Constructor. Creates a new database link based upon the passed in params and returns a reference to the database link.
A valid databaseLinkId
=head3 session
A reference to the current session.
=head3 params
A hash reference containing the list of params to set. See the set() method for details.
=cut
sub get {
return WebGUI::SQL->quickHash("select * from databaseLink where databaseLinkId=".quote($_[0]));
sub create {
my $class = shift;
my $session = shift;
my $params = shift;
$params->{databaseLinkId} = "new";
my $Id = $session->db->setRow("databaseLink","databaseLinkId",$params);
return $class->new($session,$id);
}
#-------------------------------------------------------------------
=head3 delete ( )
Deletes the current database link.
=cut
sub delete {
my $self = shift;
$self->session->db->deleteRow("databaseLink","databaseLinkId",$self->getId) unless ($self->getId eq "0");
$self->disconnect;
}
#-------------------------------------------------------------------
=head2 disconnect ( )
Disconnect cleanly from the current databaseLink.
Disconnect cleanly from the current databaseLink. You should always use this method rather than the disconnect method of the actual WebGUI::SQL database handle otherwise you may accidentally close the database handle to the WebGUI database prematurely.
=cut
sub disconnect {
my ($class, $value);
$class = shift;
my ($self, $value);
$self = shift;
$value = shift;
if (defined $class->{_dbh}) {
$class->{_dbh}->disconnect() unless ($class->{_databaseLink}{databaseLinkId} eq "0");
if (defined $self>{_dbh}) {
$self->{_dbh}->disconnect() unless ($self->getId eq "0");
}
undef $self;
}
#-------------------------------------------------------------------
=head2 dbh ( )
Return a DBI handle for the current databaseLink, connecting if necessary.
=head2 db ( )
Return a WebGUI::SQL database handle for the current databaseLink, connecting if necessary.
=cut
sub dbh {
my ($class, $value);
my ($dsn, $username, $identifier);
$class = shift;
$value = shift;
if (defined $class->{_dbh}) {
return $class->{_dbh};
sub db {
my $self = shift;
my $value = shift;
if (defined $self->{_dbh}) {
return $self->{_dbh};
}
$dsn = $class->{_databaseLink}{DSN};
$username = $class->{_databaseLink}{username};
$identifier = $class->{_databaseLink}{identifier};
if ($class->{_databaseLinkId} eq "0") {
$class->{_dbh} = $session{dbh};
return $session{dbh};
my $dsn = $self->{_databaseLink}{DSN};
my $username = $self->{_databaseLink}{username};
my $identifier = $self->{_databaseLink}{identifier};
if ($self->getId eq "0") {
$self->{_dbh} = $self->sesssion->db;
return $self->{_dbh};
} elsif ($dsn =~ /\DBI\:\w+\:\w+/i) {
eval{
$class->{_dbh} = DBI->connect($dsn,$username,$identifier);
$self->{_dbh} = WebGUI::SQL->connect($session,$dsn,$username,$identifier);
};
if ($@) {
WebGUI::ErrorHandler::warn("DatabaseLink [".$_[0]."] ".$@);
$self->session->errorHandler->warn("DatabaseLink [".$self->getId."] ".$@);
} else {
return $class->{_dbh};
return $self->{_dbh};
}
} else {
WebGUI::ErrorHandler::warn("DatabaseLink [".$_[0]."] The DSN specified is of an improper format.");
$self->session->errorHandler->warn("DatabaseLink [".$self->getId."] The DSN specified is of an improper format.");
}
return undef;
}
#-------------------------------------------------------------------
=head2 new ( databaseLinkId )
=head2 get ( )
Returns the properties of this database link as a hash reference.
=cut
sub get {
my $self = shift;
$self->{_databaseLink};
}
#-------------------------------------------------------------------
=head2 getId ( )
Returns the ID of this database link.
=cut
sub getId {
my $self = shift;
$self->{_databaseLink}{databaseLinkId};
}
#-------------------------------------------------------------------
=head2 getList ( session )
Class method. Returns a hash reference containing all database links. The format is:
databaseLinkId => title
=head3 session
A reference to the current session.
=cut
sub getList {
my $session = shift;
my $list = $session->db->buildHashRef("select databaseLinkId, title from databaseLink order by title");
$list->{'0'} = WebGUI::International::get(1076);
return $list;
}
#-------------------------------------------------------------------
=head2 new ( session, databaseLinkId )
Constructor.
=head3 session
A reference to the current session.
=head3 databaseLinkId
The databaseLinkId of the databaseLink you're creating an object reference for.
@ -149,17 +224,67 @@ sub new {
if ($databaseLinkId eq "0") {
%databaseLink = (
databaseLinkId=>"0",
DSN=>$session{config}{dsn},
username=>$session{config}{dbuser},
identifier=>$session{config}{dbpass},
DSN=>$self->session->config->get("dsn"),
username=>$self->session->config->get("dbuser"),
identifier=>$self->session->config->get("dbpass"),
title=>"WebGUI Database"
);
} else {
%databaseLink = WebGUI::SQL->quickHash("select * from databaseLink where databaseLinkId=".quote($databaseLinkId));
%databaseLink = $self->session->db->quickHash("select * from databaseLink where databaseLinkId=".$self->session->db->quote($databaseLinkId));
}
}
bless {_databaseLinkId => $databaseLinkId, _databaseLink => \%databaseLink }, $class;
return undef unless $databaseLink{databaseLinkId};
bless {_session=>$session, _databaseLink => \%databaseLink }, $class;
}
#-------------------------------------------------------------------
=head2 session
Returns a reference to the current session.
=cut
sub session {
my $self = shift;
return $self->{_session};
}
#-------------------------------------------------------------------
=head3 set ( params )
Updates the parameters of this database link.
=head3 params
A hash reference containing the parameters to set.
=head4 DSN
The database service name, which follows the perl DBI DSN structure. DBI:dbtype:dbname;otherparams
=head4 username
THe username to connect to the database with.
=head4 identifier
The password to connect to the database with.
=head4 title
A text label to identify this database to humans in the UI.
=cut
sub set {
my $self = shift;
my $params = shift;
$params->{databaseLinkId} = $self->getId;
$self->session->db->setRow("databaseLink","databaseLinkId",$params);
}
1;

View file

@ -205,18 +205,18 @@ A string representing the output format for the date. Defaults to '%z %Z'. You c
=cut
sub epochToHuman {
my $language = WebGUI::International::getLanguage($session{user}{language});
my $language = WebGUI::International::getLanguage($self->session->user->profileField("language"));
my $locale = $language->{languageAbbreviation} || "en";
$locale .= "_".$language->{locale} if ($language->{locale});
my $timeZone = $session{user}{timeZone} || "America/Chicago";
my $timeZone = $self->session->user->profileField("timeZone") || "America/Chicago";
my $dt = DateTime->from_epoch( epoch=>shift||time(), time_zone=>$timeZone, locale=>$locale );
my $output = shift || "%z %Z";
my $temp;
#---date format preference
$temp = $session{user}{dateFormat} || '%M/%D/%y';
$temp = $self->session->user->profileField("dateFormat") || '%M/%D/%y';
$output =~ s/\%z/$temp/g;
#---time format preference
$temp = $session{user}{timeFormat} || '%H:%n %p';
$temp = $self->session->user->profileField("timeFormat") || '%H:%n %p';
$output =~ s/\%Z/$temp/g;
#--- convert WebGUI date formats to DateTime formats
my %conversion = (
@ -270,7 +270,7 @@ A boolean indicating that the time should be added to the output, thust turning
=cut
sub epochToSet {
my $timeZone = $session{user}{timeZone} || "America/Chicago";
my $timeZone = $self->session->user->profileField("timeZone") || "America/Chicago";
my $dt = DateTime->from_epoch( epoch =>shift, time_zone=>$timeZone);
my $withTime = shift;
if ($withTime) {
@ -526,6 +526,7 @@ The number of seconds since January 1, 1970. Defaults to now.
sub localtime {
my $dt = DateTime->from_epoch( epoch => shift || time() );
$dt->set_time_zone($self->session->user->profileField("timeZone")|| "America/Chicago"); # assign the user's timezone
return ( $dt->year, $dt->month, $dt->day, $dt->hour, $dt->minute, $dt->second, $dt->day_of_year, $dt->day_of_week, $dt->is_dst );
}
@ -661,7 +662,7 @@ sub setToEpoch {
$dt = $parser->parse_datetime($set);
}
# in epochToSet we apply the user's time zone, so now we have to remove it.
$dt->set_time_zone($session{user}{timeZone}|| "America/Chicago"); # assign the user's timezone
$dt->set_time_zone($self->session->user->profileField("timeZone")|| "America/Chicago"); # assign the user's timezone
return $dt->epoch;
}

View file

@ -69,7 +69,7 @@ sub AUTOLOAD {
my $cmd = "use WebGUI::Form::".$name;
eval ($cmd);
if ($@) {
WebGUI::ErrorHandler::error("Couldn't compile form control: ".$name.". Root cause: ".$@);
$self->session->errorHandler->error("Couldn't compile form control: ".$name.". Root cause: ".$@);
return undef;
}
my $class = "WebGUI::Form::".$name;
@ -116,7 +116,7 @@ If you want to add anything special to the form header like javascript actions o
sub formHeader {
my $params = shift;
my $action = $params->{action} || WebGUI::URL::page();
my $action = $params->{action} || $self->session->url->page();
my $hidden;
if ($action =~ /\?/) {
my ($path,$query) = split(/\?/,$action);

View file

@ -79,7 +79,7 @@ Renders a code area field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/TabFix.js',{type=>"text/javascript"});
$self->session->style->setScript($self->session->config->get("extrasURL").'/TabFix.js',{type=>"text/javascript"});
$self->get("extras") .= ' style="width: 99%; min-width: 440px; height: 400px" onkeypress="return TabFix_keyPress(event)" onkeydown="return TabFix_keyDown(event)"';
return $self->SUPER::toHtml;
}

View file

@ -82,7 +82,7 @@ Renders a color picker control.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/colorPicker.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/colorPicker.js',{ type=>'text/javascript' });
return '<script type="text/javascript">initColorPicker("'.$self->get("name").'","'.($self->get("value")).'");</script>';
}

View file

@ -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();
}

View file

@ -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. '<script type="text/javascript">
Calendar.setup({
inputField : "'.$self->{id}.'",

View file

@ -119,10 +119,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" });
my $mondayFirst = $self->session->user->profileField("firstDayOfWeek") ? "true" : "false";
return WebGUI::Form::Text->new(
name=>$self->get("name"),

View file

@ -93,12 +93,12 @@ sub new {
}
# Return the appropriate field object.
if ($fieldType eq "") {
WebGUI::ErrorHandler::warn("Something is trying to create a dynamic field called ".$param->{name}.", but didn't pass in a field type.");
$self->session->errorHandler->warn("Something is trying to create a dynamic field called ".$param->{name}.", but didn't pass in a field type.");
$fieldType = "Text";
}
##No infinite loops, please
elsif ($fieldType eq 'DynamicField') {
WebGUI::ErrorHandler::warn("Something is trying to create a DynamicField via DynamicField.");
$self->session->errorHandler->warn("Something is trying to create a DynamicField via DynamicField.");
$fieldType = "Text";
}
no strict 'refs';
@ -106,7 +106,7 @@ sub new {
my $load = "use ".$cmd;
eval ($load);
if ($@) {
WebGUI::ErrorHandler::error("Couldn't compile form control: ".$fieldType.". Root cause: ".$@);
$self->session->errorHandler->error("Couldn't compile form control: ".$fieldType.". Root cause: ".$@);
return undef;
}
my $formObj = $cmd->new($param);

View file

@ -96,7 +96,7 @@ Renders an email address field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/emailCheck.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/emailCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onchange="emailCheck(this.value)" ';
return $self->SUPER::toHtml;
}

View file

@ -132,7 +132,7 @@ sub toHtml {
my $cmd = "use ".$class;
eval ($cmd);
if ($@) {
WebGUI::ErrorHandler::error("Couldn't compile form control: ".$type.". Root cause: ".$@);
$self->session->errorHandler->error("Couldn't compile form control: ".$type.". Root cause: ".$@);
next;
}
$options{$type} = $class->getName;

View file

@ -179,7 +179,7 @@ Renders a file upload control.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/FileUploadControl.js',{type=>"text/javascript"});
$self->session->style->setScript($self->session->config->get("extrasURL").'/FileUploadControl.js',{type=>"text/javascript"});
my $uploadControl = '<script type="text/javascript">
var fileIcons = new Array();
';

View file

@ -116,7 +116,7 @@ Renders a floating point field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-.\')"';
return $self->SUPER::toHtml;
}

View file

@ -116,7 +116,7 @@ Renders an HTML area field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/textFix.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/textFix.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onblur="fixChars(this.form.'.$self->get("name").')" mce_editable="true" ';
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->get("richEditId"))->getRichEditor($self->{id});
my $richEdit = WebGUI::Asset::RichEdit->new($self->get("richEditId"));

View file

@ -116,7 +116,7 @@ Renders an integer field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-\')"';
return $self->SUPER::toHtml;
}

View file

@ -95,7 +95,7 @@ Renders a phone number field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-()+ \')" ';
return $self->SUPER::toHtml;
}

View file

@ -109,7 +109,7 @@ Renders a time field.
sub toHtml {
my $self = shift;
my $value = WebGUI::DateTime::secondsToTime($self->get("value"));
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789:\')"';
return $self->SUPER::toHtml
.WebGUI::Form::Button->new(

View file

@ -106,7 +106,7 @@ Renders a URL field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/addHTTP.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/addHTTP.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onBlur="addHTTP(this.form.'.$self->get("name").')"';
return $self->SUPER::toHtml;
}

View file

@ -102,7 +102,7 @@ Renders a zip code field.
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->session->style->setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')"';
return $self->SUPER::toHtml;
}

View file

@ -71,8 +71,8 @@ These methods are available from this class:
#-------------------------------------------------------------------
sub _create {
my $groupId = WebGUI::Id::generate();
WebGUI::SQL->write("insert into groups (groupId,dateCreated,expireOffset,karmaThreshold) values
(".quote($groupId).",".time().",314496000,1000000000)");
$self->session->db->write("insert into groups (groupId,dateCreated,expireOffset,karmaThreshold) values
(".$self->session->db->quote($groupId).",".time().",314496000,1000000000)");
WebGUI::Grouping::addGroupsToGroups([3],[$groupId]);
return $groupId;
}
@ -127,8 +127,8 @@ sub autoAdd {
$value = shift;
if (defined $value) {
$class->{_group}{"autoAdd"} = $value;
WebGUI::SQL->write("update groups set autoAdd=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set autoAdd=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"autoAdd"};
}
@ -152,8 +152,8 @@ sub autoDelete {
$value = shift;
if (defined $value) {
$class->{_group}{"autoDelete"} = $value;
WebGUI::SQL->write("update groups set autoDelete=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set autoDelete=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"autoDelete"};
}
@ -181,9 +181,9 @@ Deletes this group and all references to it.
=cut
sub delete {
WebGUI::SQL->write("delete from groups where groupId=".quote($_[0]->{_groupId}));
WebGUI::SQL->write("delete from groupings where groupId=".quote($_[0]->{_groupId}));
WebGUI::SQL->write("delete from groupGroupings where inGroup=".quote($_[0]->{_groupId})." or groupId=".quote($_[0]->{_groupId}));
$self->session->db->write("delete from groups where groupId=".$self->session->db->quote($_[0]->{_groupId}));
$self->session->db->write("delete from groupings where groupId=".$self->session->db->quote($_[0]->{_groupId}));
$self->session->db->write("delete from groupGroupings where inGroup=".$self->session->db->quote($_[0]->{_groupId})." or groupId=".$self->session->db->quote($_[0]->{_groupId}));
}
#-------------------------------------------------------------------
@ -237,8 +237,8 @@ sub deleteOffset {
$value = shift;
if (defined $value) {
$class->{_group}{"deleteOffset"} = $value;
WebGUI::SQL->write("update groups set deleteOffset=$value,
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set deleteOffset=$value,
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"deleteOffset"};
}
@ -262,8 +262,8 @@ sub description {
$value = shift;
if (defined $value) {
$class->{_group}{"description"} = $value;
WebGUI::SQL->write("update groups set description=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set description=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"description"};
}
@ -287,8 +287,8 @@ sub expireNotify {
$value = shift;
if (defined $value) {
$class->{_group}{"expireNotify"} = $value;
WebGUI::SQL->write("update groups set expireNotify=$value,
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set expireNotify=$value,
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"expireNotify"};
}
@ -312,8 +312,8 @@ sub expireNotifyMessage {
$value = shift;
if (defined $value) {
$class->{_group}{"expireNotifyMessage"} = $value;
WebGUI::SQL->write("update groups set expireNotifyMessage=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set expireNotifyMessage=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"expireNotifyMessage"};
}
@ -338,8 +338,8 @@ sub expireNotifyOffset {
$value = shift;
if (defined $value) {
$class->{_group}{"expireNotifyOffset"} = $value;
WebGUI::SQL->write("update groups set expireNotifyOffset=$value,
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set expireNotifyOffset=$value,
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"expireNotifyOffset"};
}
@ -362,8 +362,8 @@ sub expireOffset {
my $value = shift;
if (defined $value) {
$class->{_group}{"expireOffset"} = $value;
WebGUI::SQL->write("update groups set expireOffset=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set expireOffset=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"expireOffset"};
}
@ -384,7 +384,7 @@ The name of the group you wish to instantiate.
sub find {
my $class = shift;
my $name = shift;
my ($groupId) = WebGUI::SQL->quickArray("select groupId from groups where groupName=".quote($name));
my ($groupId) = $self->session->db->quickArray("select groupId from groups where groupName=".$self->session->db->quote($name));
return WebGUI::Group->new($groupId);
}
@ -420,8 +420,8 @@ sub karmaThreshold {
$value = shift;
if (defined $value) {
$class->{_group}{"karmaThreshold"} = $value;
WebGUI::SQL->write("update groups set karmaThreshold=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set karmaThreshold=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"karmaThreshold"};
}
@ -445,8 +445,8 @@ sub ipFilter {
$value = shift;
if (defined $value) {
$class->{_group}{"ipFilter"} = $value;
WebGUI::SQL->write("update groups set ipFilter=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set ipFilter=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"ipFilter"};
}
@ -470,8 +470,8 @@ sub isEditable {
$value = shift;
if (defined $value) {
$class->{_group}{"isEditable"} = $value;
WebGUI::SQL->write("update groups set isEditable=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set isEditable=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"isEditable"};
}
@ -508,8 +508,8 @@ sub name {
$value = shift;
if (defined $value) {
$class->{_group}{"groupName"} = $value;
WebGUI::SQL->write("update groups set groupName=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set groupName=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"groupName"};
}
@ -543,7 +543,7 @@ sub new {
$group{databaseLinkId} = 0;
$group{dbCacheTimeout} = 3600;
} else {
%group = WebGUI::SQL->quickHash("select * from groups where groupId=".quote($groupId));
%group = $self->session->db->quickHash("select * from groups where groupId=".$self->session->db->quote($groupId));
}
bless {_groupId => $groupId, _group => \%group }, $class;
}
@ -566,8 +566,8 @@ sub scratchFilter {
$value = shift;
if (defined $value) {
$class->{_group}{"scratchFilter"} = $value;
WebGUI::SQL->write("update groups set scratchFilter=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set scratchFilter=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"scratchFilter"};
}
@ -590,8 +590,8 @@ sub showInForms {
$value = shift;
if (defined $value) {
$class->{_group}{"showInForms"} = $value;
WebGUI::SQL->write("update groups set showInForms=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set showInForms=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"showInForms"};
}
@ -617,8 +617,8 @@ sub dbQuery {
$value = shift;
if (defined $value) {
$class->{_group}{"dbQuery"} = $value;
WebGUI::SQL->write("update groups set dbQuery=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set dbQuery=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"dbQuery"};
}
@ -641,8 +641,8 @@ sub databaseLinkId {
$value = shift;
if (defined $value) {
$class->{_group}{"databaseLinkId"} = $value;
WebGUI::SQL->write("update groups set databaseLinkId=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set databaseLinkId=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"databaseLinkId"};
}
@ -665,8 +665,8 @@ sub dbCacheTimeout {
$value = shift;
if (defined $value) {
$class->{_group}{"dbCacheTimeout"} = $value;
WebGUI::SQL->write("update groups set dbCacheTimeout=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set dbCacheTimeout=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"dbCacheTimeout"};
}
@ -689,8 +689,8 @@ sub ldapGroup {
$value = shift;
if (defined $value) {
$class->{_group}{"ldapGroup"} = $value;
WebGUI::SQL->write("update groups set ldapGroup=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set ldapGroup=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"ldapGroup"};
}
@ -713,8 +713,8 @@ sub ldapGroupProperty {
$value = shift;
if (defined $value) {
$class->{_group}{"ldapGroupProperty"} = $value;
WebGUI::SQL->write("update groups set ldapGroupProperty=".quote($value).",
lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set ldapGroupProperty=".$self->session->db->quote($value).",
lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"ldapGroupProperty"};
}
@ -737,7 +737,7 @@ sub ldapRecursiveProperty {
$value = shift;
if (defined $value) {
$class->{_group}{"ldapRecursiveProperty"} = $value;
WebGUI::SQL->write("update groups set ldapRecursiveProperty=".quote($value).", lastUpdated=".time()." where groupId=".quote($class->{_groupId}));
$self->session->db->write("update groups set ldapRecursiveProperty=".$self->session->db->quote($value).", lastUpdated=".time()." where groupId=".$self->session->db->quote($class->{_groupId}));
}
return $class->{_group}{"ldapRecursiveProperty"};
}

View file

@ -77,14 +77,14 @@ sub addGroupsToGroups {
foreach my $gid (@{$_[0]}) {
next if ($gid eq '1');
foreach my $toGid (@{$_[1]}) {
my ($isIn) = WebGUI::SQL->quickArray("select count(*) from groupGroupings
where groupId=".quote($gid)." and inGroup=".quote($toGid));
my ($isIn) = $self->session->db->quickArray("select count(*) from groupGroupings
where groupId=".$self->session->db->quote($gid)." and inGroup=".$self->session->db->quote($toGid));
my $recursive = isIn($toGid, @{getGroupsInGroup($gid,1)});
unless ($isIn || $recursive) {
WebGUI::SQL->write("insert into groupGroupings (groupId,inGroup) values (".quote($gid).",".quote($toGid).")");
my $cache = WebGUI::Cache->new("groups_in_group_".$gid);
$self->session->db->write("insert into groupGroupings (groupId,inGroup) values (".$self->session->db->quote($gid).",".$self->session->db->quote($toGid).")");
my $cache = WebGUI::Cache->new($self->session,"groups_in_group_".$gid);
$cache->delete if (defined $cache);
$cache = WebGUI::Cache->new("groups_in_group_".$toGid);
$cache = WebGUI::Cache->new($self->session,"groups_in_group_".$toGid);
$cache->delete if (defined $cache);
}
}
@ -119,14 +119,14 @@ sub addUsersToGroups {
if ($_[2]) {
$expireOffset = $_[2];
} else {
($expireOffset) = WebGUI::SQL->quickArray("select expireOffset from groups where groupId=".quote($gid));
($expireOffset) = $self->session->db->quickArray("select expireOffset from groups where groupId=".$self->session->db->quote($gid));
}
foreach my $uid (@{$_[0]}) {
next if ($uid eq '1');
my ($isIn) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId=".quote($gid)." and userId=".quote($uid));
my ($isIn) = $self->session->db->quickArray("select count(*) from groupings where groupId=".$self->session->db->quote($gid)." and userId=".$self->session->db->quote($uid));
unless ($isIn) {
WebGUI::SQL->write("insert into groupings (groupId,userId,expireDate)
values (".quote($gid).", ".quote($uid).", ".(WebGUI::DateTime::time()+$expireOffset).")");
$self->session->db->write("insert into groupings (groupId,userId,expireDate)
values (".$self->session->db->quote($gid).", ".$self->session->db->quote($uid).", ".(WebGUI::DateTime::time()+$expireOffset).")");
} else {
if ($_[2]) {
userGroupExpireDate($uid,$gid,(WebGUI::DateTime::time()+$expireOffset));
@ -156,8 +156,8 @@ sub deleteGroupsFromGroups {
delete $session{isInGroup};
foreach my $gid (@{$_[0]}) {
foreach my $fromGid (@{$_[1]}) {
WebGUI::Cache->new("groups_in_group_".$fromGid)->delete;
WebGUI::SQL->write("delete from groupGroupings where groupId=".quote($gid)." and inGroup=".quote($fromGid));
WebGUI::Cache->new($self->session,"groups_in_group_".$fromGid)->delete;
$self->session->db->write("delete from groupGroupings where groupId=".$self->session->db->quote($gid)." and inGroup=".$self->session->db->quote($fromGid));
}
}
}
@ -183,7 +183,7 @@ sub deleteUsersFromGroups {
delete $session{isInGroup};
foreach my $gid (@{$_[1]}) {
foreach my $uid (@{$_[0]}) {
WebGUI::SQL->write("delete from groupings where groupId=".quote($gid)." and userId=".quote($uid));
$self->session->db->write("delete from groupings where groupId=".$self->session->db->quote($gid)." and userId=".$self->session->db->quote($uid));
}
}
}
@ -202,7 +202,7 @@ A unique identifier for the group.
=cut
sub getGroupsForGroup {
return WebGUI::SQL->buildArrayRef("select inGroup from groupGroupings where groupId=".quote($_[0]));
return $self->session->db->buildArrayRef("select inGroup from groupGroupings where groupId=".$self->session->db->quote($_[0]));
}
@ -231,11 +231,11 @@ sub getGroupsForUser {
} elsif (exists $session{gotGroupsForUser}{$userId}) {
return $session{gotGroupsForUser}{$userId};
} else {
my @groups = WebGUI::SQL->buildArray("select groupId from groupings where userId=".quote($userId)." $clause");
my @groups = $self->session->db->buildArray("select groupId from groupings where userId=".$self->session->db->quote($userId)." $clause");
foreach my $gid (@groups) {
$session{isInGroup}{$userId}{$gid} = 1;
}
$session{gotGroupsForUser}{$userId} = \@groups unless ($session{config}{disableCache});
$session{gotGroupsForUser}{$userId} = \@groups unless ($self->session->config->get("disableCache"));
return \@groups;
}
}
@ -267,15 +267,15 @@ sub getGroupsInGroup {
} elsif (exists $session{gotGroupsInGroup}{recursive}{$groupId}) {
return $session{gotGroupsInGroup}{direct}{$groupId};
}
my $groups = WebGUI::Cache->new("groups_in_group_".$groupId)->get;
my $groups = WebGUI::Cache->new($self->session,"groups_in_group_".$groupId)->get;
unless (defined $groups) {
$groups = WebGUI::SQL->buildArrayRef("select groupId from groupGroupings where inGroup=".quote($groupId));
WebGUI::Cache->new("groups_in_group_".$groupId)->set($groups);
$groups = $self->session->db->buildArrayRef("select groupId from groupGroupings where inGroup=".$self->session->db->quote($groupId));
WebGUI::Cache->new($self->session,"groups_in_group_".$groupId)->set($groups);
}
if ($isRecursive) {
$loopCount++;
if ($loopCount > 99) {
WebGUI::ErrorHandler::fatal("Endless recursive loop detected while determining".
$self->session->errorHandler->fatal("Endless recursive loop detected while determining".
" groups in group.\nRequested groupId: ".$groupId."\nGroups in that group: ".join(",",@$groups));
}
my @groupsOfGroups = @$groups;
@ -283,7 +283,7 @@ sub getGroupsInGroup {
my $gog = getGroupsInGroup($group,1,$loopCount);
push(@groupsOfGroups, @$gog);
}
$session{gotGroupsInGroup}{recursive}{$groupId} = \@groupsOfGroups unless ($session{config}{disableCache});
$session{gotGroupsInGroup}{recursive}{$groupId} = \@groupsOfGroups unless ($self->session->config->get("disableCache"));
return \@groupsOfGroups;
}
$session{gotGroupsInGroup}{direct}{$groupId} = $groups;
@ -319,21 +319,21 @@ sub getUsersInGroup {
if ($withoutExpired) {
$clause = "expireDate > ".time()." and ";
}
$clause .= "(groupId=".quote($groupId);
$clause .= "(groupId=".$self->session->db->quote($groupId);
if ($recursive) {
my $groups = getGroupsInGroup($groupId,1);
if ($#$groups >= 0) {
if ($withoutExpired) {
foreach my $groupId (@$groups) {
$clause .= " OR (groupId = ".quote($groupId)." AND expireDate > ".time().") ";
$clause .= " OR (groupId = ".$self->session->db->quote($groupId)." AND expireDate > ".time().") ";
}
} else {
$clause .= " OR groupId IN (".quoteAndJoin($groups).")";
$clause .= " OR groupId IN (".$self->session->db->quoteAndJoin($groups).")";
}
}
}
$clause .= ")";
return WebGUI::SQL->buildArrayRef("select userId from groupings where $clause");
return $self->session->db->buildArrayRef("select userId from groupings where $clause");
}
@ -357,7 +357,7 @@ sub isInGroup {
my (@data, %group, $groupId);
my ($gid, $uid, $secondRun) = @_;
$gid = 3 unless (defined $gid);
$uid = $session{user}{userId} if ($uid eq "");
$uid = $self->session->user->profileField("userId") if ($uid eq "");
### The following several checks are to increase performance. If this section were removed, everything would continue to work as normal.
return 1 if ($gid eq '7'); # everyone is in the everyone group
return 1 if ($gid eq '1' && $uid eq '1'); # visitors are in the visitors group
@ -374,7 +374,7 @@ sub isInGroup {
unless ($secondRun) { # don't look up user groups if we've already done it once.
my $groups = WebGUI::Grouping::getGroupsForUser($uid,1);
foreach (@{$groups}) {
$session{isInGroup}{$uid}{$_} = 1 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$_} = 1 unless ($self->session->config->get("disableCache"));
}
if ($session{isInGroup}{$uid}{$gid} eq '1') {
return 1;
@ -382,7 +382,7 @@ sub isInGroup {
}
### Get data for auxillary checks.
tie %group, 'Tie::CPHash';
%group = WebGUI::SQL->quickHash("select karmaThreshold,ipFilter,scratchFilter,databaseLinkId,dbQuery,dbCacheTimeout,ldapGroup,ldapGroupProperty,ldapRecursiveProperty from groups where groupId=".quote($gid));
%group = $self->session->db->quickHash("select karmaThreshold,ipFilter,scratchFilter,databaseLinkId,dbQuery,dbCacheTimeout,ldapGroup,ldapGroupProperty,ldapRecursiveProperty from groups where groupId=".$self->session->db->quote($gid));
### Check IP Address
if ($group{ipFilter} ne "") {
$group{ipFilter} =~ s/\t//g;
@ -392,8 +392,8 @@ sub isInGroup {
$group{ipFilter} =~ s/\./\\\./g;
my @ips = split(";",$group{ipFilter});
foreach my $ip (@ips) {
if ($session{env}{REMOTE_ADDR} =~ /^$ip/) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($session{config}{disableCache});
if ($self->session->env->get("REMOTE_ADDR") =~ /^$ip/) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($self->session->config->get("disableCache"));
return 1;
}
}
@ -408,21 +408,21 @@ sub isInGroup {
foreach my $var (@vars) {
my ($name, $value) = split(/\=/,$var);
if ($session{scratch}{$name} eq $value) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 1 unless ($self->session->config->get("disableCache"));
return 1;
}
}
}
### Check karma levels.
if ($session{setting}{useKarma}) {
if ($self->session->setting->get("useKarma")) {
my $karma;
if ($uid eq $session{user}{userId}) {
$karma = $session{user}{karma};
if ($uid eq $self->session->user->profileField("userId")) {
$karma = $self->session->user->profileField("karma");
} else {
($karma) = WebGUI::SQL->quickHash("select karma from users where userId=".quote($uid));
($karma) = $self->session->db->quickHash("select karma from users where userId=".$self->session->db->quote($uid));
}
if ($karma >= $group{karmaThreshold}) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 1 unless ($self->session->config->get("disableCache"));
return 1;
}
}
@ -430,32 +430,32 @@ sub isInGroup {
if ($group{dbQuery} ne "" && $group{databaseLinkId}) {
# skip if not logged in and query contains a User macro
unless ($group{dbQuery} =~ /\^User/i && $uid eq '1') {
my $dbLink = WebGUI::DatabaseLink->new($group{databaseLinkId});
my $dbLink = WebGUI::DatabaseLink->new($session,$group{databaseLinkId});
my $dbh = $dbLink->dbh;
if (defined $dbh) {
if ($group{dbQuery} =~ /select 1/i) {
my $query = $group{dbQuery};
WebGUI::Macro::process(\$query);
WebGUI::Macro::process($self->session,\$query);
$group{dbQuery} = $query;
my $sth = WebGUI::SQL->unconditionalRead($group{dbQuery},$dbh);
my $sth = $self->session->db->unconditionalRead($group{dbQuery},$dbh);
unless ($sth->errorCode < 1) {
WebGUI::ErrorHandler::warn("There was a problem with the database query for group ID $gid.");
$self->session->errorHandler->warn("There was a problem with the database query for group ID $gid.");
} else {
my ($result) = $sth->array;
if ($result == 1) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 1 unless ($self->session->config->get("disableCache"));
if ($group{dbCacheTimeout} > 0) {
WebGUI::Grouping::deleteUsersFromGroups([$uid],[$gid]);
WebGUI::Grouping::addUsersToGroups([$uid],[$gid],$group{dbCacheTimeout});
}
} else {
$session{isInGroup}{$uid}{$gid} = 0 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 0 unless ($self->session->config->get("disableCache"));
WebGUI::Grouping::deleteUsersFromGroups([$uid],[$gid]) if ($group{dbCacheTimeout} > 0);
}
}
$sth->finish;
} else {
WebGUI::ErrorHandler::warn("Database query for group ID $gid must use 'select 1'");
$self->session->errorHandler->warn("Database query for group ID $gid must use 'select 1'");
}
$dbLink->disconnect;
return 1 if ($session{isInGroup}{$uid}{$gid});
@ -482,13 +482,13 @@ sub isInGroup {
}
if(isIn($params->{connectDN},@{$people})) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 1 unless ($self->session->config->get("disableCache"));
if ($group{dbCacheTimeout} > 10) {
WebGUI::Grouping::deleteUsersFromGroups([$uid],[$gid]);
WebGUI::Grouping::addUsersToGroups([$uid],[$gid],$group{dbCacheTimeout});
}
} else {
$session{isInGroup}{$uid}{$gid} = 0 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 0 unless ($self->session->config->get("disableCache"));
WebGUI::Grouping::deleteUsersFromGroups([$uid],[$gid]) if ($group{dbCacheTimeout} > 10);
}
$ldapLink->unbind;
@ -503,11 +503,11 @@ sub isInGroup {
foreach (@{$groups}) {
$session{isInGroup}{$uid}{$_} = isInGroup($_, $uid, 1);
if ($session{isInGroup}{$uid}{$_}) {
$session{isInGroup}{$uid}{$gid} = 1 unless ($session{config}{disableCache}); # cache current group also so we don't have to do the group in group check again
$session{isInGroup}{$uid}{$gid} = 1 unless ($self->session->config->get("disableCache")); # cache current group also so we don't have to do the group in group check again
return 1;
}
}
$session{isInGroup}{$uid}{$gid} = 0 unless ($session{config}{disableCache});
$session{isInGroup}{$uid}{$gid} = 0 unless ($self->session->config->get("disableCache"));
return 0;
}
@ -537,10 +537,10 @@ If specified the admin flag will be set to this value.
sub userGroupAdmin {
if ($_[2] ne "") {
WebGUI::SQL->write("update groupings set groupAdmin=".quote($_[2])." where groupId=".quote($_[1])." and userId=".quote($_[0]));
$self->session->db->write("update groupings set groupAdmin=".$self->session->db->quote($_[2])." where groupId=".$self->session->db->quote($_[1])." and userId=".$self->session->db->quote($_[0]));
return $_[2];
} else {
my ($admin) = WebGUI::SQL->quickArray("select groupAdmin from groupings where groupId=".quote($_[1])." and userId=".quote($_[0]));
my ($admin) = $self->session->db->quickArray("select groupAdmin from groupings where groupId=".$self->session->db->quote($_[1])." and userId=".$self->session->db->quote($_[0]));
return $admin;
}
}
@ -567,10 +567,10 @@ If specified the expire date will be set to this value.
sub userGroupExpireDate {
if ($_[2]) {
WebGUI::SQL->write("update groupings set expireDate=".quote($_[2])." where groupId=".quote($_[1])." and userId=".quote($_[0]));
$self->session->db->write("update groupings set expireDate=".$self->session->db->quote($_[2])." where groupId=".$self->session->db->quote($_[1])." and userId=".$self->session->db->quote($_[0]));
return $_[2];
} else {
my ($expireDate) = WebGUI::SQL->quickArray("select expireDate from groupings where groupId=".quote($_[1])." and userId=".quote($_[0]));
my ($expireDate) = $self->session->db->quickArray("select expireDate from groupings where groupId=".$self->session->db->quote($_[1])." and userId=".$self->session->db->quote($_[0]));
return $expireDate;
}
}

View file

@ -282,7 +282,7 @@ sub makeAbsolute {
next;
}
if ($tag_attr{"$tagname $_"}) { # make this absolute
$attr->{$_} = WebGUI::URL::makeAbsolute($attr->{$_}, $baseURL);
$attr->{$_} = $self->session->url->makeAbsolute($attr->{$_}, $baseURL);
}
$session{temp}{makeAbsolute}{html} .= qq' $_="$attr->{$_}"';
}
@ -318,7 +318,7 @@ sub processReplacements {
$content =~ s/\Q$searchFor/$replaceWith/gs;
}
} else {
my $sth = WebGUI::SQL->read("select searchFor,replaceWith from replacements",WebGUI::SQL->getSlave);
my $sth = $self->session->db->read("select searchFor,replaceWith from replacements",$self->session->db->getSlave);
while (my ($searchFor,$replaceWith) = $sth->array) {
$session{replacements}{$searchFor} = $replaceWith;
$content =~ s/\Q$searchFor/$replaceWith/gs;

View file

@ -65,7 +65,7 @@ These methods are available from this class:
#-------------------------------------------------------------------
sub _uiLevelChecksOut {
if ($_[0] <= $session{user}{uiLevel}) {
if ($_[0] <= $self->session->user->profileField("uiLevel")) {
return 1;
} else {
return 0;
@ -90,7 +90,7 @@ sub AUTOLOAD {
my $cmd = "use WebGUI::Form::".$name;
eval ($cmd);
if ($@) {
WebGUI::ErrorHandler::error("Couldn't compile form control: ".$name.". Root cause: ".$@);
$self->session->errorHandler->error("Couldn't compile form control: ".$name.". Root cause: ".$@);
return undef;
}
my $class = "WebGUI::Form::".$name;
@ -168,7 +168,7 @@ Returns the HTML for this form object.
=cut
sub print {
return $_[0]->{_header}.$_[0]->{_data}.$_[0]->{_footer}.'<script type="text/javascript" src="'.$session{config}{extrasURL}.'/wz_tooltip.js"></script>';
return $_[0]->{_header}.$_[0]->{_data}.$_[0]->{_footer}.'<script type="text/javascript" src="'.$self->session->config->get("extrasURL").'/wz_tooltip.js"></script>';
}
#-------------------------------------------------------------------

View file

@ -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") },
],
},

View file

@ -34,7 +34,7 @@ our $HELP = {
{ tag => $tag,
namespace => $namespace }
}
values %{ $session{config}{macros} }
values %{ $self->session->config->get("macros") }
],
},

View file

@ -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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'copy.gif" align="middle" border="0" alt="'.WebGUI::International::get('Copy','Icon').'" title="'.WebGUI::International::get('Copy','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'cut.gif" align="middle" border="0" alt="'.WebGUI::International::get('Cut','Icon').'" title="'.WebGUI::International::get('Cut','Icon').'" /></a>';
return $output;
}
@ -160,7 +160,7 @@ sub deleteIcon {
$pageURL = $_[1] || $session{requestedUrl};
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'" '.$confirmText.'>';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'" '.$confirmText.'>';
$output .= '<img src="'._getBaseURL().'delete.gif" align="middle" border="0" alt="'.WebGUI::International::get('Delete','Icon').'" title="'.WebGUI::International::get('Delete','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'edit.gif" align="middle" border="0" alt="'.WebGUI::International::get('Edit','Icon').'" title="'.WebGUI::International::get('Edit','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
# TODO Change icon to Jeffs export icon
$output .= '<img src="'._getBaseURL().'export.gif" align="middle" border="0" alt="'.WebGUI::International::get('Export','Icon').'" title="'.WebGUI::International::get('Export','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::page('op=viewHelp;hid='.$_[0].';namespace='.$namespace).
$output = '<a href="'.$self->session->url->page('op=viewHelp;hid='.$_[0].';namespace='.$namespace).
'" target="_blank"><img src="'._getBaseURL().'help.gif" border="0" align="right" title="'.WebGUI::International::get('Help','Icon').'" Alt="'.WebGUI::International::get('Help','Icon').'"></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'locked.gif" align="middle" border="0" alt="'.WebGUI::International::get('locked','Icon').'" title="'.WebGUI::International::get('locked','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'manage.gif" align="middle" border="0" alt="'.WebGUI::International::get('Manage','Icon').'" title="'.WebGUI::International::get('Manage','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'moveBottom.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move To Bottom','Icon').'" title="'.WebGUI::International::get('Move To Bottom','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'moveDown.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Down','Icon').'" title="'.WebGUI::International::get('Move Down','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'moveLeft.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Left','Icon').'" title="'.WebGUI::International::get('Move Left','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'moveRight.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Right','Icon').'" title="'.WebGUI::International::get('Move Right','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'moveTop.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move To Top','Icon').'" title="'.WebGUI::International::get('Move To Top','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'moveUp.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Up','Icon').'" title="'.WebGUI::International::get('Move Up','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'paste.gif" align="middle" border="0" alt="'.WebGUI::International::get('Paste','Icon').'" title="'.WebGUI::International::get('Paste','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'shortcut.gif" align="middle" border="0" alt="'.WebGUI::International::get('Create Shortcut','Icon').'" title="'.WebGUI::International::get('Create Shortcut','Icon').'" /></a>';
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 = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
$output = '<a href="'.$self->session->url->gateway($pageURL,$_[0]).'">';
$output .= '<img src="'._getBaseURL().'view.gif" align="middle" border="0" alt="'.WebGUI::International::get('View','Icon').'" title="'.WebGUI::International::get('View','Icon').'" /></a>';
return $output;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -34,7 +34,7 @@ B<NOTE:> 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

View file

@ -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/<html>/i) || ($_[2] =~ m/<a\sname=/i)) {
@ -99,34 +99,34 @@ sub send {
$message .= "Content-Type: text/plain; charset=UTF-8\n";
}
$message .= "\n";
WebGUI::Macro::process(\$message);
WebGUI::Macro::process($self->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"));
}
}
}

View file

@ -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]));
}

View file

@ -88,7 +88,7 @@ sub www_viewActiveSessions {
$output .= $p->getPage($session->form->process("pn"));
$output .= '</table>';
$output .= $p->getBarTraditional($session->form->process("pn"));
return WebGUI::AdminConsole->new("activeSessions")->render($output);
return WebGUI::AdminConsole->new($session,"activeSessions")->render($output);
}
1;

View file

@ -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 .= '<table>';
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get('cache type').':</td><td class="tableData">'.ref($cache).'</td></tr>';

View file

@ -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');
}

View file

@ -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] = '<tr><td valign="top" class="tableData"></td><td valign="top" class="tableData">'.WebGUI::International::get(1076).'</td></tr>';
$i++;
while (%data = $sth->hash) {
$row[$i] = '<tr><td valign="top" class="tableData">'
.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 = '<table border="1" cellpadding="3" cellspacing="0" align="center">';
foreach my $id (keys %{$links}) {
$output .= '<tr><td valign="top" class="tableData"></td><td valign="top" class="tableData">'.WebGUI::International::get(1076).'</td></tr>';
$output = '<tr><td valign="top" class="tableData">'
.deleteIcon('op=deleteDatabaseLink;dlid='.$id)
.editIcon('op=editDatabaseLink;dlid='.$id)
.copyIcon('op=copyDatabaseLink;dlid='.$id)
.'</td>';
$row[$i] .= '<td valign="top" class="tableData">'.$data{title}.'</td></tr>';
$i++;
$output .= '<td valign="top" class="tableData">'.$links->{$id}.'</td></tr>';
}
$sth->finish;
$p = WebGUI::Paginator->new($session->url->page('op=listDatabaseLinks'));
$p->setDataByArrayRef(\@row);
$output .= '<table border="1" cellpadding="3" cellspacing="0" align="center">';
$output .= $p->getPage;
$output .= '</table>';
$output .= $p->getBarTraditional;
return _submenu($output,"database links manage");
}

View file

@ -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")]);

View file

@ -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 .= '</td></tr></table>';
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 .= '</td></tr></table>';
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 .= '<p><a href="'._link($id,$namespace).'">'.WebGUI::International::get($help->{$id}{title},$namespace).'</a></p>';
}
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));

View file

@ -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");
}

View file

@ -64,7 +64,7 @@ sub www_viewLoginHistory {
$output .= $p->getPage($session->form->process("pn"));
$output .= '</table>';
$output .= $p->getBar($session->form->process("pn"));
return WebGUI::AdminConsole->new("loginHistory")->render($output);
return WebGUI::AdminConsole->new($session,"loginHistory")->render($output);
}
1;

View file

@ -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');
}

View file

@ -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();
}

View file

@ -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);
}

View file

@ -289,7 +289,7 @@ sub www_editSettings {
$tabform->getTab("auth")->raw('<tr id="'.$_.$style.'"><td colspan="2" width="100%"><table border="0" cellspacing="0" cellpadding="0" width="100%">'.$authInstance->editUserSettingsForm.'<tr><td width="304">&nbsp;</td><td width="496">&nbsp;</td></tr></table></td></tr>');
}
$tabform->submit();
my $ac = WebGUI::AdminConsole->new("settings");
my $ac = WebGUI::AdminConsole->new($session,"settings");
$ac->setHelp("settings");
return $ac->render($tabform->print);
}

View file

@ -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);

View file

@ -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');
}

View file

@ -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;

View file

@ -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 = '|&lt;'.WebGUI::International::get(404);
if ($pn > 1) {
return '<a href="'.
WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'=1'))
$self->session->url->append($_[0]->{_url},($_[0]->{_formVar}.'=1'))
.'">'.$text.'</a>';
} else {
return $text;
@ -243,7 +241,7 @@ sub getLastPageLink {
$text = WebGUI::International::get(405).'&gt;|';
if ($pn != $_[0]->getNumberOfPages) {
return '<a href="'.
WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.$_[0]->getNumberOfPages))
$self->session->url->append($_[0]->{_url},($_[0]->{_formVar}.'='.$_[0]->getNumberOfPages))
.'">'.$text.'</a>';
} else {
return $text;
@ -264,7 +262,7 @@ sub getNextPageLink {
$pn = $_[0]->getPageNumber;
$text = WebGUI::International::get(92).'&raquo;';
if ($pn < $_[0]->getNumberOfPages) {
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.($pn+1))).'">'.$text.'</a>';
return '<a href="'.$self->session->url->append($_[0]->{_url},($_[0]->{_formVar}.'='.($pn+1))).'">'.$text.'</a>';
} else {
return $text;
}
@ -365,7 +363,7 @@ sub getPageLinks {
if ($i+1 == $pn) {
push(@pages,($i+1));
} else {
push(@pages,'<a href="'.WebGUI::URL::append($self->{_url},($self->{_formVar}.'='.($i+1))).'">'.($i+1).'</a>');
push(@pages,'<a href="'.$self->session->url->append($self->{_url},($self->{_formVar}.'='.($i+1))).'">'.($i+1).'</a>');
}
}
if ($limit) {
@ -401,7 +399,7 @@ sub getPreviousPageLink {
$pn = $_[0]->getPageNumber;
$text = '&laquo;'.WebGUI::International::get(91);
if ($pn > 1) {
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.($pn-1))).'">'.$text.'</a>';
return '<a href="'.$self->session->url->append($_[0]->{_url},($_[0]->{_formVar}.'='.($pn-1))).'">'.$text.'</a>';
} 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;

View file

@ -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;
}

View file

@ -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 = '<h1>'.WebGUI::International::get(37).'</h1>';

View file

@ -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;

View file

@ -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);
}

View file

@ -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;$count<scalar(@results);$count++) {
@ -229,7 +229,7 @@ Returns an array reference of WebGUI::ProfileField objects that are marked "edit
sub getEditableFields {
my $self = shift;
my @fields = ();
foreach my $fieldName (WebGUI::SQL->buildArray("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);

View file

@ -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<NOTE:> 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 "") {

View file

@ -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});

View file

@ -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=>'/'
);

View file

@ -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));
}

View file

@ -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];
}
</script>
@ -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;
}

View file

@ -94,7 +94,7 @@ sub append {
Encodes a string to make it safe to pass in a URL.
B<NOTE:> See WebGUI::URL::unescape()
B<NOTE:> 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<NOTE:> See WebGUI::URL::escape()
B<NOTE:> See $self->session->url->escape()
=head3 string

View file

@ -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;
}

Some files were not shown because too many files have changed in this diff Show more