more session changes

This commit is contained in:
JT Smith 2006-01-02 02:58:29 +00:00
parent f429daa942
commit eb98aaaf29
6 changed files with 48 additions and 48 deletions

View file

@ -53,21 +53,21 @@ sub _clearCheckoutScratch {
#-------------------------------------------------------------------
sub _clearPaymentScratch {
my $session = shift;
WebGUI::Session::setScratch('paymentGateway', '-delete-');
$session->scratch->set('paymentGateway', '-delete-');
}
#-------------------------------------------------------------------
sub _clearShippingScratch {
my $session = shift;
WebGUI::Session::setScratch('shippingMethod', '-delete-');
WebGUI::Session::setScratch('shippingOptions', '-delete-');
$session->scratch->set('shippingMethod', '-delete-');
$session->scratch->set('shippingOptions', '-delete-');
}
#-------------------------------------------------------------------
sub _paymentSelected {
my $session = shift;
return 0 unless (WebGUI::Session::getScratch('paymentGateway'));
my $plugin = WebGUI::Commerce::Payment->load(WebGUI::Session::getScratch('paymentGateway'));
return 0 unless ($session->scratch->get('paymentGateway'));
my $plugin = WebGUI::Commerce::Payment->load($session->scratch->get('paymentGateway'));
return 1 if ($plugin && $plugin->enabled);
return 0;
}
@ -75,11 +75,11 @@ sub _paymentSelected {
#-------------------------------------------------------------------
sub _shippingSelected {
my $session = shift;
return 0 unless (WebGUI::Session::getScratch('shippingMethod'));
return 0 unless ($session->scratch->get('shippingMethod'));
my $plugin = WebGUI::Commerce::Shipping->load(WebGUI::Session::getScratch('shippingMethod'));
my $plugin = WebGUI::Commerce::Shipping->load($session->scratch->get('shippingMethod'));
if ($plugin) {
$plugin->setOptions(Storable::thaw(WebGUI::Session::getScratch('shippingOptions'))) if (WebGUI::Session::getScratch('shippingOptions'));
$plugin->setOptions(Storable::thaw($session->scratch->get('shippingOptions'))) if ($session->scratch->get('shippingOptions'));
return 1 if ($plugin->enabled && $plugin->optionsOk);
}
@ -130,7 +130,7 @@ sub www_checkoutConfirm {
# If the user isn't logged in yet, let him do so or have him create an account
if ($session->user->profileField("userId") == 1) {
WebGUI::Session::setScratch('redirectAfterLogin', $session->url->page('op=checkout'));
$session->scratch->set('redirectAfterLogin', $session->url->page('op=checkout'));
return WebGUI::Operation::execute('auth');
}
@ -169,15 +169,15 @@ sub www_checkoutConfirm {
$var{subTotal} = sprintf('%.2f', $total);
$shipping = WebGUI::Commerce::Shipping->load(WebGUI::Session::getScratch('shippingMethod'));
$shipping->setOptions(Storable::thaw(WebGUI::Session::getScratch('shippingOptions'))) if (WebGUI::Session::getScratch('shippingOptions'));
$shipping = WebGUI::Commerce::Shipping->load($session->scratch->get('shippingMethod'));
$shipping->setOptions(Storable::thaw($session->scratch->get('shippingOptions'))) if ($session->scratch->get('shippingOptions'));
$var{shippingName} = $shipping->name;
$var{shippingCost} = sprintf('%.2f', $shipping->calc);
$var{total} = sprintf('%.2f', $total + $shipping->calc);
$plugin = WebGUI::Commerce::Payment->load(WebGUI::Session::getScratch('paymentGateway'));
$plugin = WebGUI::Commerce::Payment->load($session->scratch->get('paymentGateway'));
$f = WebGUI::HTMLForm->new;
$f->hidden(
@ -211,7 +211,7 @@ sub www_checkoutSubmit {
# check if user has already logged in
if ($session->user->profileField("userId") == 1) {
WebGUI::Session::setScratch('redirectAfterLogin', $session->url->page('op=checkout'));
$session->scratch->set('redirectAfterLogin', $session->url->page('op=checkout'));
return WebGUI::Operation::execute('displayLogin');
}
@ -219,11 +219,11 @@ sub www_checkoutSubmit {
return WebGUI::Operation::execute('checkout') unless (_paymentSelected && _shippingSelected);
# Load shipping plugin.
$shipping = WebGUI::Commerce::Shipping->load(WebGUI::Session::getScratch('shippingMethod'));
$shipping->setOptions(Storable::thaw(WebGUI::Session::getScratch('shippingOptions'))) if (WebGUI::Session::getScratch('shippingOptions'));
$shipping = WebGUI::Commerce::Shipping->load($session->scratch->get('shippingMethod'));
$shipping->setOptions(Storable::thaw($session->scratch->get('shippingOptions'))) if ($session->scratch->get('shippingOptions'));
# Load payment plugin.
$plugin = WebGUI::Commerce::Payment->load(WebGUI::Session::getScratch('paymentGateway'));
$plugin = WebGUI::Commerce::Payment->load($session->scratch->get('paymentGateway'));
$shoppingCart = WebGUI::Commerce::ShoppingCart->new;
($normal, $recurring) = $shoppingCart->getItems;
@ -703,9 +703,9 @@ sub www_selectPaymentGateway {
sub www_selectPaymentGatewaySave {
my $session = shift;
if (WebGUI::Commerce::Payment->load($session->form->process("paymentGateway"))->enabled) {
WebGUI::Session::setScratch('paymentGateway', $session->form->process("paymentGateway"));
$session->scratch->set('paymentGateway', $session->form->process("paymentGateway"));
} else {
WebGUI::Session::setScratch('paymentGateway', '-delete-');
$session->scratch->set('paymentGateway', '-delete-');
}
return WebGUI::Operation::execute('checkout');
@ -754,10 +754,10 @@ sub www_selectShippingMethodSave {
return WebGUI::Operation::execute('selectShipping') unless ($shipping->optionsOk);
if ($shipping->enabled) {
WebGUI::Session::setScratch('shippingMethod', $shipping->namespace);
WebGUI::Session::setScratch('shippingOptions', Storable::freeze($shipping->getOptions));
$session->scratch->set('shippingMethod', $shipping->namespace);
$session->scratch->set('shippingOptions', Storable::freeze($shipping->getOptions));
} else {
WebGUI::Session::setScratch('shippingMethod', '-delete-');
$session->scratch->set('shippingMethod', '-delete-');
}
return WebGUI::Operation::execute('checkout');

View file

@ -76,10 +76,10 @@ sub doGroupSearch {
my $returnPaginator = shift;
my $groupFilter = shift;
push(@{$groupFilter},0);
my $keyword = $session{scratch}{groupSearchKeyword};
if ($session{scratch}{groupSearchModifier} eq "startsWith") {
my $keyword = $session->scratch->get("groupSearchKeyword");
if ($session->scratch->get("groupSearchModifier") eq "startsWith") {
$keyword .= "%";
} elsif ($session{scratch}{groupSearchModifier} eq "contains") {
} elsif ($session->scratch->get("groupSearchModifier") eq "contains") {
$keyword = "%".$keyword."%";
} else {
$keyword = "%".$keyword;
@ -103,8 +103,8 @@ sub getGroupSearchForm {
my $session = shift;
my $op = shift;
my $params = shift;
WebGUI::Session::setScratch("groupSearchKeyword",$session->form->process("keyword"));
WebGUI::Session::setScratch("groupSearchModifier",$session->form->process("modifier"));
$session->scratch->set("groupSearchKeyword",$session->form->process("keyword"));
$session->scratch->set("groupSearchModifier",$session->form->process("modifier"));
my $output = '<div align="center">';
my $f = WebGUI::HTMLForm->new(1);
foreach my $key (keys %{$params}) {
@ -123,7 +123,7 @@ sub getGroupSearchForm {
);
$f->selectBox(
-name=>"modifier",
-value=>($session{scratch}{groupSearchModifier} || WebGUI::International::get("contains") ),
-value=>($session->scratch->get("groupSearchModifier") || WebGUI::International::get("contains") ),
-options=>{
startsWith=>WebGUI::International::get("starts with"),
contains=>WebGUI::International::get("contains"),
@ -132,7 +132,7 @@ sub getGroupSearchForm {
);
$f->text(
-name=>"keyword",
-value=>$session{scratch}{groupSearchKeyword},
-value=>$session->scratch->get("groupSearchKeyword"),
-size=>15
);
$f->submit(value=>WebGUI::International::get(170));

View file

@ -30,7 +30,7 @@ sub _submenu {
$ac->setHelp($help, 'ProductManager');
}
my $productId = $session->form->process("productId") || WebGUI::Session::getScratch('managingProduct');
my $productId = $session->form->process("productId") || $session->scratch->get('managingProduct');
undef $productId if ($productId eq 'new');
$ac->addSubmenuItem($session->url->page('op=editProduct;productId=new'), $i18n->get('add product'));
$ac->addSubmenuItem($session->url->page('op=listProducts'), $i18n->get('list products'));
@ -490,7 +490,7 @@ sub www_listProducts {
$i18n = WebGUI::International->new('ProductManager');
WebGUI::Session::setScratch('managingProduct', '-delete-');
$session->scratch->set('managingProduct', '-delete-');
$sth = $session->db->read('select * from products order by title');
@ -518,7 +518,7 @@ sub www_listProductVariants {
$i18n = WebGUI::International->new("ProductManager");
$productId = $session->form->process("productId") || WebGUI::Session::getScratch('managingProduct');
$productId = $session->form->process("productId") || $session->scratch->get('managingProduct');
return WebGUI::Operation::execute('listProducts') if ($productId eq 'new' || !$productId);
@ -600,9 +600,9 @@ sub www_manageProduct {
$i18n = WebGUI::International->new("ProductManager");
$productId = $session->form->process("productId") || WebGUI::Session::getScratch('managingProduct');
$productId = $session->form->process("productId") || $session->scratch->get('managingProduct');
return WebGUI::Operation::execute('listProducts') if ($productId eq 'new' || !$productId);
WebGUI::Session::setScratch('managingProduct', $productId);
$session->scratch->set('managingProduct', $productId);
$product = WebGUI::Product->new($productId);

View file

@ -34,7 +34,7 @@ variable, scratchName.
sub www_deleteScratch {
my $session = shift;
WebGUI::Session::deleteScratch("www_".$session->form->process("scratchName"));
$session->scratch->delete("www_".$session->form->process("scratchName"));
return "";
}
@ -51,7 +51,7 @@ the value the variable should take.
sub www_setScratch {
my $session = shift;
WebGUI::Session::setScratch("www_".$session->form->process("scratchName"),$session->form->process("scratchValue"));
$session->scratch->set("www_".$session->form->process("scratchName"),$session->form->process("scratchValue"));
return "";
}

View file

@ -57,7 +57,7 @@ overriding the style without setting a printable style and on a per user basis.
sub www_setPersonalStyle {
my $session = shift;
WebGUI::Session::setScratch("personalStyleId",$session->form->process("styleId"));
$session->scratch->set("personalStyleId",$session->form->process("styleId"));
return "";
}
@ -71,7 +71,7 @@ Clears the personalStyleId from the scratch area of the session variable.
sub www_unsetPersonalStyle {
my $session = shift;
WebGUI::Session::deleteScratch("personalStyleId");
$session->scratch->delete("personalStyleId");
return "";
}

View file

@ -118,15 +118,15 @@ sub doUserSearch {
my $userFilter = shift;
push(@{$userFilter},0);
my $selectedStatus;
if ($session{scratch}{userSearchStatus}) {
$selectedStatus = "status='".$session{scratch}{userSearchStatus}."'";
if ($session->scratch->get("userSearchStatus")) {
$selectedStatus = "status='".$session->scratch->get("userSearchStatus")."'";
} else {
$selectedStatus = "status like '%'";
}
my $keyword = $session{scratch}{userSearchKeyword};
if ($session{scratch}{userSearchModifier} eq "startsWith") {
my $keyword = $session->scratch->get("userSearchKeyword");
if ($session->scratch->get("userSearchModifier") eq "startsWith") {
$keyword .= "%";
} elsif ($session{scratch}{userSearchModifier} eq "contains") {
} elsif ($session->scratch->get("userSearchModifier") eq "contains") {
$keyword = "%".$keyword."%";
} else {
$keyword = "%".$keyword;
@ -167,9 +167,9 @@ sub getUserSearchForm {
my $session = shift;
my $op = shift;
my $params = shift;
WebGUI::Session::setScratch("userSearchKeyword",$session->form->process("keyword"));
WebGUI::Session::setScratch("userSearchStatus",$session->form->process("status"));
WebGUI::Session::setScratch("userSearchModifier",$session->form->process("modifier"));
$session->scratch->set("userSearchKeyword",$session->form->process("keyword"));
$session->scratch->set("userSearchStatus",$session->form->process("status"));
$session->scratch->set("userSearchModifier",$session->form->process("modifier"));
my $output = '<div align="center">'
.WebGUI::Form::formHeader()
.WebGUI::Form::hidden(
@ -188,7 +188,7 @@ sub getUserSearchForm {
)
.WebGUI::Form::selectBox(
-name=>"modifier",
-value=>($session{scratch}{userSearchModifier} || "contains"),
-value=>($session->scratch->get("userSearchModifier") || "contains"),
-options=>{
startsWith=>WebGUI::International::get("starts with"),
contains=>WebGUI::International::get("contains"),
@ -197,12 +197,12 @@ sub getUserSearchForm {
)
.WebGUI::Form::text(
-name=>"keyword",
-value=>$session{scratch}{userSearchKeyword},
-value=>$session->scratch->get("userSearchKeyword"),
-size=>15
)
.WebGUI::Form::selectBox(
-name => "status",
-value => ($session{scratch}{userSearchStatus} || "users.status like '%'"),
-value => ($session->scratch->get("userSearchStatus") || "users.status like '%'"),
-options=> {
"" => WebGUI::International::get(821),
Active => WebGUI::International::get(817),