Merge commit '469c2b72b4' into WebGUI8. All tests passing.

This commit is contained in:
Colin Kuskie 2010-07-01 10:13:22 -07:00
commit 565cf955d7
147 changed files with 1526 additions and 1283 deletions

View file

@ -118,6 +118,7 @@ sub _fixReplyCount {
my $lastPostId = $asset->getLineage( [ qw{ self descendants } ], {
isa => 'WebGUI::Asset::Post',
orderByClause => 'assetData.revisionDate desc',
limit => 1,
} )->[0];
my $lastPost = eval { WebGUI::Asset->newById( $self->session, $lastPostId ); };
if ( ! Exception::Class->caught() ) {
@ -322,6 +323,53 @@ override cut => sub {
#-------------------------------------------------------------------
=head2 disqualifyAsLastPost ( )
This method should be called whenever something happens to the Post or Thread that would disqualify
it as being the last post in a Thread, or Collaboration System. Good examples are cutting to the
clipboard, trashing, or archiving.
If the Post was the last post, it will find the second to last post for each kind of parent asset,
and update that asset with that Post's information.
=cut
sub disqualifyAsLastPost {
my $self = shift;
my $thread = $self->getThread;
if ($thread->get('lastPostId') eq $self->getId) {
my $secondary_post = $thread->getLineage(['descendants'], {
returnObjects => 1,
includeOnlyClasses => ["WebGUI::Asset::Post", ],
limit => 1,
orderByClause => 'revisionDate,lineage DESC',
})->[0];
if ($secondary_post) { ##Handle edge case for no other
$thread->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), });
}
else {
$thread->update({ lastPostId => '', lastPostDate => '', });
}
}
my $cs = $thread->getParent;
if ($cs->get('lastPostId') eq $self->getId) {
my $secondary_post = $cs->getLineage(['descendants'], {
returnObjects => 1,
includeOnlyClasses => ["WebGUI::Asset::Post","WebGUI::Asset::Post::Thread"],
limit => 1,
orderByClause => 'revisionDate DESC',
})->[0];
if ($secondary_post) { ##Handle edge case for no other
$cs->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), });
}
else {
$cs->update({ lastPostId => '', lastPostDate => '', });
}
}
}
#-------------------------------------------------------------------
=head2 DESTROY
Extend the base method to delete the locally cached thread object.
@ -1109,6 +1157,22 @@ sub postProcess {
#-------------------------------------------------------------------
=head2 publish
Extend the base method to handle updating last post information in the parent Thread
and CS.
=cut
sub publish {
my $self = shift;
$self->next::method(@_);
$self->qualifyAsLastPost;
return 1;
}
#-------------------------------------------------------------------
=head2 purge
Extend the base method to handle cleaning up storage locations.
@ -1156,6 +1220,31 @@ override purgeRevision => sub {
#-------------------------------------------------------------------
=head2 qualifyAsLastPost ( )
This method should be called whenever something happens to the Post or Thread that would qualify
it as being the last post in a Thread, or Collaboration System. Good examples are pasting from
the clipboard, restoring from the trash, or changing the state from archiving.
It checks the parent Thread and CS to see if it is now the last Post, and updates that asset with
its information.
=cut
sub qualifyAsLastPost {
my ($self) = @_;
my $thread = $self->getThread();
if ($self->get('creationDate') > $thread->get('lastPostDate')) {
$thread->update({ lastPostId => $self->getId, lastPostDate => $self->get('creationDate'), });
}
my $cs = $thread->getParent;
if ($self->get('creationDate') > $cs->get('lastPostDate')) {
$cs->update({ lastPostId => $self->getId, lastPostDate => $self->get('creationDate'), });
}
}
#-------------------------------------------------------------------
=head2 rate ( rating )
@ -1260,14 +1349,16 @@ override setParent => sub {
=head2 setStatusArchived ( )
Sets the status of this post to archived.
Sets the status of this post to archived. Updates the parent thread and CS to remove
the lastPost, if this post is the last post.
=cut
sub setStatusArchived {
my ($self) = @_;
$self->update({status=>'archived'});
my ($self) = @_;
$self->update({status=>'archived'});
$self->disqualifyAsLastPost;
}
@ -1276,20 +1367,23 @@ sub setStatusArchived {
=head2 setStatusUnarchived ( )
Sets the status of this post to approved, but does so without any of the normal notifications and other stuff.
Updates the last post information in the parent Thread and CS if applicable.
=cut
sub setStatusUnarchived {
my ($self) = @_;
$self->update({status=>'approved'}) if ($self->status eq "archived");
my ($self) = @_;
$self->update({status=>'approved'}) if ($self->status eq "archived");
$self->qualifyAsLastPost;
}
#-------------------------------------------------------------------
=head2 trash ( )
Moves post to the trash, updates reply counter on thread and recalculates the thread rating.
Moves post to the trash, updates reply counter on thread, recalculates the thread rating,
and updates any lastPost information in the parent Thread, and CS.
=cut
@ -1298,23 +1392,9 @@ override trash => sub {
super();
$self->getThread->sumReplies if ($self->isReply);
$self->getThread->updateThreadRating;
if ($self->getThread->lastPostId eq $self->getId) {
my $threadLineage = $self->getThread->lineage;
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
order by creationDate desc",[$threadLineage.'%', $self->getId]);
$self->getThread->update({lastPostId=>$id, lastPostDate=>$date});
}
if ($self->getThread->getParent->lastPostId eq $self->getId) {
my $forumLineage = $self->getThread->getParent->lineage;
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
order by creationDate desc",[$forumLineage.'%', $self->getId]);
$self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date});
}
$self->disqualifyAsLastPost;
};
#-------------------------------------------------------------------
=head2 prepareView
@ -1513,6 +1593,7 @@ sub www_edit {
$var{'archive.form'} = WebGUI::Form::yesNo($session, {
name=>"archive"
});
$var{'isSubscribedToCs'} = $self->getThread->getParent->isSubscribed;
$var{'form.header'} .= WebGUI::Form::hidden($session, {
name=>"proceed",
value=>"showConfirmation"

View file

@ -211,8 +211,9 @@ sub appendTemplateVarsFileLoop {
my $assetIds = shift;
my $session = $self->session;
for my $assetId (@$assetIds) {
my $asset = WebGUI::Asset->newById($session, $assetId);
ASSET: for my $assetId (@$assetIds) {
my $asset = eval { WebGUI::Asset->newById($session, $assetId); };
next ASSET if Exception::Class->caught();
# Set the parent
$asset->{_parent} = $self;
push @{$var->{file_loop}}, $asset->getTemplateVars;

View file

@ -288,9 +288,14 @@ sub getFolder {
##For a fully automatic commit, save the current tag, create a new one
##with the commit without approval workflow, commit it, then restore
##the original if it exists
my $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
my $newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
$newVersionTag->setWorking;
my ($oldVersionTag, $newVersionTag);
$oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
if ($self->hasBeenCommitted) {
$newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
$newVersionTag->setWorking;
$newVersionTag->set({ name => 'Adding folder '. $folderName. ' to archive '. $self->getUrl});
}
##Call SUPER because my addChild calls getFolder
$folder = $self->addChild({
@ -301,7 +306,7 @@ sub getFolder {
isHidden => 1,
styleTemplateId => $self->styleTemplateId,
});
$newVersionTag->commit();
$newVersionTag->commit() if $newVersionTag;
##Restore the old one, if it exists
$oldVersionTag->setWorking() if $oldVersionTag;

View file

@ -996,20 +996,8 @@ sub getFormPlugin {
eval { WebGUI::Pluggable::load($class) };
if ($class->isa('WebGUI::Form::List')) {
delete $param{size};
my $values = WebGUI::Operation::Shared::secureEval($session,$data->{possibleValues});
if (ref $values eq 'HASH') {
$param{options} = $values;
}
else{
my %options;
tie %options, 'Tie::IxHash';
foreach (split(/\n/x, $data->{possibleValues})) {
s/\s+$//x; # remove trailing spaces
$options{$_} = $_;
}
$param{options} = \%options;
}
$param{options} = $values;
}
if ($data->{fieldType} eq "YesNo") {
@ -3238,7 +3226,7 @@ $self->session->form->process($_) eq "") {
sequenceNumber');
while (my $field = $fields->hashRef) {
if ($field->{searchIn}){
my $searchForm = $self->getFormElement($field);
my $searchForm = $self->getFormPlugin($field, 1);
my $searchTextForm = WebGUI::Form::Text($self->session, {
name=>"field_".$field->{fieldId},
size=>25,
@ -3253,9 +3241,10 @@ sequenceNumber');
push(@searchFields_loop, {
"searchFields_fieldId" => $field->{fieldId},
"searchFields_label" => $field->{label},
"searchFields_form" => $searchForm,
"searchFields_form" => $searchForm->toHtml,
"searchFields_textForm" => $searchTextForm,
"searchFields_is".$fieldType => 1,
"searchFields_listType" => $searchForm->isa('WebGUI::Form::List'),
});
my @searchValue = $session->form->process("field_".$field->{fieldId});

View file

@ -183,6 +183,7 @@ sub getAssetsInClipboard {
{
statesToInclude => ["clipboard"],
returnObjects => 1,
statusToInclude => [qw/approved pending archived/],
whereClause => $limit,
}
);

View file

@ -420,10 +420,6 @@ An array reference containing a list of asset classes to remove from the result
A boolean indicating that we should return objects rather than asset ids.
=head4 returnSQL
A boolean indicating that we should return the sql statement rather than asset ids.
=head4 invertTree
A boolean indicating whether the resulting asset tree should be returned in reverse order.
@ -446,7 +442,8 @@ A string containing as asset class to join in. There is no real reason to use a
=head4 whereClause
A string containing extra where clause information for the query.
A string containing extra WHERE clause information for the query. The AND conjunction will be added internally, so the clause
should not start with AND.
=head4 orderByClause
@ -591,6 +588,7 @@ An integer describing how many levels of ancestry from the start point that shou
=head4 excludeClasses
An array reference containing a list of asset classes to remove from the result set. The opposite of the includOnlyClasses rule.
Each class is internally appended with a SQL wildcard, so any subclass will also be excluded.
=head4 invertTree

View file

@ -57,39 +57,20 @@ sub getAssetsInTrash {
my $self = shift;
my $limitToUser = shift;
my $userId = shift || $self->session->user->userId;
my @assets;
my $limit;
if ($limitToUser) {
$limit = "and asset.stateChangedBy=".$self->session->db->quote($userId);
$limit = "asset.stateChangedBy=".$self->session->db->quote($userId);
}
my $sth = $self->session->db->read("
select
asset.assetId,
assetData.revisionDate
from
asset
left join
assetData on asset.assetId=assetData.assetId
where
asset.state='trash'
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId)
$limit
group by
assetData.assetId
order by
assetData.title desc
");
while (my ($id, $date) = $sth->array) {
my $asset = WebGUI::Asset->newById($self->session, $id, $date);
if (!Exception::Class->caught()) {
push(@assets, $asset);
}
else {
$self->session->errorHandler->error("AssetTrash::getAssetsInTrash - failed to instanciate asset with assetId $id and revisionDate $date");
}
}
$sth->finish;
return \@assets;
my $root = WebGUI::Asset->getRoot($self->session);
return $root->getLineage(
["descendants", ],
{
statesToInclude => ["trash"],
statusToInclude => [qw/approved pending archived/],
returnObjects => 1,
whereClause => $limit,
}
);
}
#----------------------------------------------------------------------------

View file

@ -800,7 +800,9 @@ Returns whether or not a method is callable
sub isCallable {
my $self = shift;
return isIn($_[0],@{$self->{callable}})
return 1 if isIn($_[0],@{$self->{callable}});
return 1 if $self->can( 'www_' . $_[0] );
return 0;
}
#-------------------------------------------------------------------

297
lib/WebGUI/Auth/Twitter.pm Normal file
View file

@ -0,0 +1,297 @@
package WebGUI::Auth::Twitter;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Auth';
use Net::Twitter;
=head1 NAME
WebGUI::Auth::Twitter -- Twitter auth for WebGUI
=head1 DESCRIPTION
Allow WebGUI to authenticate to WebGUI
=head1 METHODS
These methods are available from this class:
=cut
#----------------------------------------------------------------------------
=head2 new ( ... )
Create a new object
=cut
sub new {
my $self = shift->SUPER::new(@_);
return bless $self, __PACKAGE__; # Auth requires rebless
}
#----------------------------------------------------------------------------
=head2 createTwitterUser ( twitterUserId, username )
my $user = $self->createTwitterUser( $twitterUserId, $username );
Create a new Auth::Twitter user with the given twitter userId and screen name.
=cut
sub createTwitterUser {
my ( $self, $twitterUserId, $username ) = @_;
my $user = WebGUI::User->create( $self->session );
$user->username( $username );
$self->saveParams( $user->userId, $self->authMethod, {
"twitterUserId" => $twitterUserId,
} );
return $user;
}
#----------------------------------------------------------------------------
=head2 editUserSettingsForm ( )
Return the form to edit the settings of this Auth module
=cut
sub editUserSettingsForm {
my $self = shift;
my $session = $self->session;
my ( $setting ) = $session->quick(qw( setting ));
my $i18n = WebGUI::International->new( $session, 'Auth_Twitter' );
my $keyUrl = 'http://dev.twitter.com/apps/new';
my $f = WebGUI::HTMLForm->new( $session );
$f->yesNo(
name => 'twitterEnabled',
value => $setting->get( 'twitterEnabled' ),
label => $i18n->get('enabled'),
hoverHelp => $i18n->get('enabled help'),
);
$f->text(
name => 'twitterConsumerKey',
value => $setting->get( 'twitterConsumerKey' ),
label => $i18n->get('consumer key'),
hoverHelp => $i18n->get('consumer key help'),
subtext => sprintf( $i18n->get('get key'), ($keyUrl) x 2 ),
);
$f->text(
name => 'twitterConsumerSecret',
value => $setting->get( 'twitterConsumerSecret' ),
label => $i18n->get('consumer secret'),
hoverHelp => $i18n->get('consumer secret help'),
);
$f->template(
name => 'twitterTemplateIdChooseUsername',
value => $setting->get( 'twitterTemplateIdChooseUsername' ),
label => $i18n->get('choose username template'),
hoverHelp => $i18n->get('choose username template help'),
namespace => 'Auth/Twitter/ChooseUsername',
);
return $f->printRowsOnly;
}
#----------------------------------------------------------------------------
=head2 editUserSettingsFormSave ( )
Process the form for this Auth module's settings
=cut
sub editUserSettingsFormSave {
my $self = shift;
my $session = $self->session;
my ( $form, $setting ) = $session->quick(qw( form setting ));
my @fields = qw(
twitterEnabled twitterConsumerKey twitterConsumerSecret
twitterTemplateIdChooseUsername
);
for my $field ( @fields ) {
$setting->set( $field, $form->get( $field ) );
}
return;
}
#----------------------------------------------------------------------------
=head2 getTemplateChooseUsername ( )
Get the template to choose a username
=cut
sub getTemplateChooseUsername {
my ( $self ) = @_;
my $templateId = $self->session->setting->get('twitterTemplateIdChooseUsername');
return WebGUI::Asset->newById( $self->session, $templateId );
}
#----------------------------------------------------------------------------
=head2 getTwitter ( )
Get the Net::Twitter object with the appropriate keys
=cut
sub getTwitter {
my ( $self ) = @_;
my $setting = $self->session->setting;
if ( !$self->{_twitter} ) {
my $nt = Net::Twitter->new(
traits => [qw/API::REST OAuth/],
consumer_key => $setting->get( 'twitterConsumerKey' ), # Test: '3hvJpBr73pa4FycNrqw',
consumer_secret => $setting->get( 'twitterConsumerSecret' ), # Test: 'E4M5DJ66RAXiHgNCnJES96yTqglttsUes6OBcw9A',
);
$self->{_twitter} = $nt;
}
return $self->{_twitter};
}
#----------------------------------------------------------------------------
=head2 www_login ( )
Begin the login procedure
=cut
sub www_login {
my ( $self ) = @_;
my $session = $self->session;
my ( $url, $scratch, $setting ) = $session->quick( qw( url scratch setting ) );
my $nt = $self->getTwitter;
my $auth_url = $nt->get_authentication_url(
callback => $url->getSiteURL . $url->page('op=auth&authType=Twitter&method=callback'),
);
$scratch->set( 'AuthTwitterToken', $nt->request_token );
$scratch->set( 'AuthTwitterTokenSecret', $nt->request_token_secret );
$session->http->setRedirect($auth_url);
return "redirect";
}
#----------------------------------------------------------------------------
=head2 www_callback ( )
Callback from the Twitter authentication. Try to log the user in, creating a
new user account if necessary.
If the username is taken, allow the user to choose a new one.
=cut
sub www_callback {
my ( $self ) = @_;
my $session = $self->session;
my ( $form, $scratch, $db, $setting ) = $session->quick(qw( form scratch db setting ));
my $verifier = $form->get('oauth_verifier');
my $nt = $self->getTwitter;
$nt->request_token( $scratch->get('AuthTwitterToken') );
$nt->request_token_secret( $scratch->get('AuthTwitterTokenSecret') );
my ($access_token, $access_token_secret, $twitterUserId, $twitterScreenName )
= $nt->request_access_token(verifier => $verifier);
### Log the user in
# Find their twitter user ID
my $userId = $db->quickScalar(
"SELECT userId FROM authentication WHERE authMethod = ? AND fieldName = ? AND fieldData = ?",
[ "Twitter", "twitterUserId", $twitterUserId ],
);
# Returning user
if ( $userId ) {
my $user = WebGUI::User->new( $session, $userId );
$self->user( $user );
return $self->login;
}
# Otherwise see if their screen name exists and create a user
elsif ( !WebGUI::User->newByUsername( $session, $twitterScreenName ) ) {
my $user = $self->createTwitterUser( $twitterUserId, $twitterScreenName );
$self->user( $user );
return $self->login;
}
# Otherwise ask them for a new username to use
my $i18n = WebGUI::International->new( $session, 'Auth_Twitter' );
$scratch->set( "AuthTwitterUserId", $twitterUserId );
my $tmpl = $self->getTemplateChooseUsername;
my $var = {
message => sprintf( $i18n->get("twitter screen name taken"), $twitterScreenName ),
};
return $tmpl->process( $var );
}
#----------------------------------------------------------------------------
=head2 www_setUsername ( )
Set the username for a twitter user. Only used as part of the initial twitter
registration.
=cut
sub www_setUsername {
my ( $self ) = @_;
my $session = $self->session;
my ( $form, $scratch, $db ) = $session->quick(qw( form scratch db ));
my $i18n = WebGUI::International->new( $session, 'Auth_Twitter' );
# Don't allow just anybody to set a username
return unless $scratch->get('AuthTwitterUserId');
my $username = $form->get('newUsername');
if ( !WebGUI::User->newByUsername( $session, $username ) ) {
my $twitterUserId = $scratch->get( "AuthTwitterUserId" );
my $user = $self->createTwitterUser( $twitterUserId, $username );
$self->user( $user );
return $self->login;
}
# Username is again taken! Noooooo!
my $tmpl = $self->getTemplateChooseUsername;
my $var = {
message => sprintf( $i18n->get("webgui username taken"), $username ),
};
return $tmpl->process( $var );
}
1;

View file

@ -373,9 +373,6 @@ sub www_manage {
$session->style->setScript( $session->url->extras( 'yui-webgui/build/form/form.js' ) );
$session->style->setRawHeadTags( <<ENDHTML );
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.6.0/build/logger/assets/skins/sam/logger.css">
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/logger/logger-min.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady( WebGUI.AssetManager.initManager );
</script>

View file

@ -27,6 +27,7 @@ our $HELP = {
{ 'name' => 'reply.synopsis' },
{ 'name' => 'reply.content' },
{ 'name' => 'reply.userDefinedN' },
{ 'name' => 'isSubscribedToCs' },
{ 'name' => 'subscribe.form' },
{ 'name' => 'isNewThread' },
{ 'name' => 'archive.form' },

View file

@ -191,6 +191,7 @@ our $HELP = {
{ 'name' => 'searchFields_textForm' },
{ 'name' => 'searchFields_label' },
{ 'name' => 'searchFields_is__fieldType__' },
{ 'name' => 'searchFields_listType' },
],
},
{ 'name' => 'listOfThings',

View file

@ -72,6 +72,10 @@ our $HELP = {
name => "quantity",
description => "quantity help",
},
{
name => "removeBox",
description => "removeBox help",
},
{
name => "dateAdded",
description => "dateAdded help",
@ -102,32 +106,20 @@ our $HELP = {
description => "price help",
},
{
name => "removeButton",
description => "removeButton help",
required => 1,
},
{
name => "shipToButton",
description => "item shipToButton help",
name => "itemAddressChooser",
description => "itemAddressChooser help",
},
{
name => "shippingAddress",
description => "shippingAddress help",
},
{
name => "isCashier",
},
{
name => "posLookupForm",
},
{
name => "posUsername",
},
{
name => "posUserId",
},
],
},
{
name => "message",
description => "message help",
required => 1,
},
{
name => "error",
description => "error help",
@ -152,10 +144,26 @@ our $HELP = {
name => "continueShoppingButton",
description => "continueShoppingButton help",
},
{
name => "minimumCartAmount",
description => "minimumCartAmount help",
},
{
name => "subtotalPrice",
description => "subtotalPrice help",
},
{
name => "shippingAddressChooser",
description => "shippingAddressChooser help",
},
{
name => "billingAddressChooser",
description => "billingAddressChooser help",
},
{
name => "sameShippingAsBilling",
description => "sameShippingAsBilling help",
},
{
name => "shippingPrice",
description => "shippingPrice help",
@ -164,19 +172,27 @@ our $HELP = {
name => "tax",
description => "tax help",
},
{
name => "userIsVisitor",
description => "userIsVisitor help",
},
{
name => "shippableItemsInCart",
},
{
name => "hasShippingAddress",
description => "hasShippingAddress help",
},
{
name => "shippingAddress",
description => "shippingAddress help",
},
{
name => "shippingOptions",
description => "shippingOptions help",
required => 1,
},
{
name => "paymentOptions",
description => "paymentOptions help",
required => 1,
},
{
name => "totalPrice",
description => "totalPrice help",
@ -190,6 +206,158 @@ our $HELP = {
name => "inShopCreditDeduction",
description => "inShopCreditDeduction help",
},
{
name => "isCashier",
},
{
name => "posLookupForm",
},
{
name => "posUsername",
},
{
name => "posUserId",
},
{
name => "loginFormHeader",
description => "loginFormHeader help",
required => 1,
},
{
name => "loginFormFooter",
description => "loginFormFooter help",
required => 1,
},
{
name => "loginFormUsername",
description => "loginFormUsername help",
required => 1,
},
{
name => "loginFormPassword",
description => "loginFormPassword help",
required => 1,
},
{
name => "loginFormButton",
description => "loginFormButton help",
required => 1,
},
{
name => "registerLink",
description => "registerLink help",
required => 1,
},
{
name => "billing_address1Field",
description => "address1Field help",
required => 1,
},
{
name => "billing_address2Field",
description => "address2Field help",
required => 1,
},
{
name => "billing_address3Field",
description => "address3Field help",
required => 1,
},
{
name => "billing_labelField",
description => "address labelField help",
required => 1,
},
{
name => "billing_nameField",
description => "address nameField help",
required => 1,
},
{
name => "billing_cityField",
description => "cityField help",
required => 1,
},
{
name => "billing_stateField",
description => "stateField help",
required => 1,
},
{
name => "billing_countryField",
description => "countryField help",
required => 1,
},
{
name => "billing_codeField",
description => "codeField help",
required => 1,
},
{
name => "billing_phoneNumberField",
description => "phoneNumberField help",
required => 1,
},
{
name => "billing_emailField",
description => "emailField help",
required => 1,
},
{
name => "shipping_address1Field",
description => "address1Field help",
required => 1,
},
{
name => "shipping_address2Field",
description => "address2Field help",
required => 1,
},
{
name => "shipping_address3Field",
description => "address3Field help",
required => 1,
},
{
name => "shipping_labelField",
description => "address labelField help",
required => 1,
},
{
name => "shipping_nameField",
description => "address nameField help",
required => 1,
},
{
name => "shipping_cityField",
description => "cityField help",
required => 1,
},
{
name => "shipping_stateField",
description => "stateField help",
required => 1,
},
{
name => "shipping_countryField",
description => "countryField help",
required => 1,
},
{
name => "shipping_codeField",
description => "codeField help",
required => 1,
},
{
name => "shipping_phoneNumberField",
description => "phoneNumberField help",
required => 1,
},
{
name => "shipping_emailField",
description => "emailField help",
required => 1,
},
],
related => [
{
@ -379,6 +547,11 @@ our $HELP = {
description => "phoneNumberField help",
required => 1,
},
{
name => "emailField",
description => "emailField help",
required => 1,
},
],
related => [
{

View file

@ -0,0 +1,58 @@
package WebGUI::Macro::TwitterLogin;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use List::MoreUtils qw( any );
=head1 NAME
Package WebGUI::Macro::TwitterLogin
=head1 DESCRIPTION
Display a twitter login button
=head2 process( $session )
=over 4
=item *
A session variable
=item *
A URL to an image to log in via Twitter
=back
=cut
#-------------------------------------------------------------------
sub process {
my $session = shift;
return "" unless any { $_ eq 'Twitter' } @{ $session->config->get( 'authMethods' ) };
return "" unless $session->user->isVisitor;
return "" unless $session->setting->get('twitterEnabled'); # Don't allow if twitter login is disabled
my $loginUrl = $session->url->page('op=auth;authType=Twitter;method=login');
my $imgUrl = shift || $session->url->extras( 'twitter_login.png' );
my $output = sprintf '<a href="%s"><img src="%s" border="0" /></a>', $loginUrl, $imgUrl;
return $output;
}
1;
#vim:ft=perl

View file

@ -512,7 +512,6 @@ sub send {
my $status = 1;
if ($mail->parts <= 1) {
warn "making singlepart";
$mail->make_singlepart;
}
if ($mail->head->get("To")) {

View file

@ -14,6 +14,7 @@ package WebGUI::Operation::Auth;
# logic that defines how Authentication should happen
use strict qw(vars subs);
use List::MoreUtils qw( any );
use URI;
use WebGUI::Operation::Shared;
use WebGUI::Pluggable;
@ -33,9 +34,16 @@ Get the instance of this object or create a new instance if none exists
sub getInstance {
my $session = shift;
#Get Auth Settings
my $authMethod = $session->user->authMethod || $session->setting->get("authMethod");
$authMethod = $session->setting->get("authMethod") if($session->user->isVisitor);
$authMethod = $_[0] if($_[0] && isIn($_[0], @{$session->config->get("authMethods")}));
my $authMethod = $_[0]
|| ( !$session->user->isVisitor && $session->user->authMethod ) # Visitor has no authType
|| $session->form->get('authType')
|| $session->setting->get("authMethod")
;
# Verify is in auth method list
if ( !any { $_ eq $authMethod } @{$session->config->get('authMethods')} ) {
$authMethod = $session->setting->get('authMethod');
}
my $userId = $_[1];
#Create Auth Object
my $auth = eval { WebGUI::Pluggable::instanciate("WebGUI::Auth::".$authMethod, "new", [ $session, $authMethod, $userId ] ) };
@ -68,11 +76,15 @@ sub www_auth {
my $authMethod = getInstance($session,$auth);
my $methodCall = shift || $session->form->process("method") || "init";
if(!$authMethod->isCallable($methodCall)){
$session->errorHandler->security("access uncallable auth method");
$session->errorHandler->security("access uncallable auth method: $methodCall");
my $i18n = WebGUI::International->new($session);
return $i18n->get(1077);
}
my $out = $authMethod->$methodCall;
# Determine if we have a www_ method
my $method = $authMethod->can( 'www_' . $methodCall )
|| $authMethod->can( $methodCall );
my $out = $method->( $authMethod );
if (substr($session->http->getMimeType(),0,9) eq "text/html") {
return $session->style->userStyle($out);
}

View file

@ -17,6 +17,7 @@ package WebGUI::Paginator;
use strict;
use WebGUI::International;
use WebGUI::Utility;
use List::Util qw/min/;
=head1 NAME
@ -428,10 +429,10 @@ sub getPageData {
}
#Handle setByArrayRef or the old setDataByQuery method
my @pageRows = ();
my $rowsPerPage = $self->{_rpp};
my $rowsPerPage = $self->{_rpp};
my $pageStartRow = ($pageNumber*$rowsPerPage)-$rowsPerPage;
my $pageEndRow = $pageNumber*$rowsPerPage;
my $pageEndRow = min($pageNumber*$rowsPerPage, $#{$allRows}+1);
my @pageRows = ();
for (my $i=$pageStartRow; $i<$pageEndRow; $i++) {
$pageRows[$i-$pageStartRow] = $allRows->[$i] if ($i <= $#{$self->{_rowRef}});
}

View file

@ -762,6 +762,15 @@ sub updateFromForm {
$error{id $self} = $i18n->get('mixed items warning');
}
my @cartItemIds = $form->process('remove_item', 'checkList');
foreach my $cartItemId (@cartItemIds) {
my $item = eval { $self->getItem($cartItemId); };
$item->remove if ! Exception::Class->caught();
}
##Visitor cannot have an address book, or set a payment gateway, so skip the rest of this.
return 1 if $session->user->isVisitor;
my $book = $self->getAddressBook;
my $cartProperties = {};
@ -825,12 +834,6 @@ sub updateFromForm {
$cartProperties->{ shipperId } = $form->process( 'shipperId' ) if $form->process( 'shipperId' );
$cartProperties->{ gatewayId } = $form->process( 'gatewayId' ) if $form->process( 'gatewayId' );
$self->update( $cartProperties );
my @cartItemIds = $form->process('remove_item', 'checkList');
foreach my $cartItemId (@cartItemIds) {
my $item = eval { $self->getItem($cartItemId); };
$item->remove if ! Exception::Class->caught();
}
}
#-------------------------------------------------------------------

View file

@ -306,6 +306,7 @@ sub setApproved {
my $self = shift;
my $instance = shift;
$instance->setScratch( "status", "approved" );
$instance->set({}); ##Bump spectre to get it to run right now.
}
#----------------------------------------------------------------------------
@ -325,7 +326,8 @@ sub setDenied {
my $self = shift;
my $instance = shift;
$instance->setScratch( "status", "denied" );
}
$instance->set({}); ##Bump spectre to get it to run right now.
}
#----------------------------------------------------------------------------

View file

@ -48,6 +48,12 @@ editing an existing Post.|,
lastUpdated => 1149829706,
},
'isSubscribedToCs' => {
message => q|A boolean which will be true if the current user is subscribed to the CS containing this Post.|,
context => q|Template variable description|,
lastUpdated => 1149829706,
},
'subscribe.form' => {
message => q|A yes/no button to allow the user to subscribe to the thread this post belongs to.|,
lastUpdated => 1149829706,

View file

@ -584,14 +584,12 @@ you wish to appear, one per line. <br />
<br />If you want a different label for a value, the possible values list has to be
formatted as follows:
<pre>
&#123;
"key1"=>"value1",
"key2"=>"value2",
"key3"=>"value3"
key1|value1
key2|value2
key3|value3
...
&#125;
</pre>
Braces, quotes and all. You simply replace "key1"/"value1" with your own name/value pairs},
Simply replace "key1"/"value1" with your own name/value pairs},
lastUpdated => 1223372150,
},
@ -972,11 +970,17 @@ search has been done.|,
},
'searchFields_is__fieldType__' => {
message => q|A boolean indicating wether this field is of type __fieldType__. The first letter of __fieldType__ is always uppercase. Example: for a select box the value of &lt;tmpl_var searchFields_isSelectBox&gt; is true.|,
message => q|A boolean indicating whether this field is of type __fieldType__. The first letter of __fieldType__ is always uppercase. Example: for a select box the value of &lt;tmpl_var searchFields_isSelectBox&gt; is true.|,
lastUpdated => 1104630516,
context => q|Description of a tmpl_var for the template help.|,
},
'searchFields_listType' => {
message => q|A boolean indicating whether this field is a List type field.|,
lastUpdated => 1277849256,
context => q|Description of a tmpl_var for the template help.|,
},
'displayInSearchFields_loop' => {
message => q|A loop containing the fields that are displayed in the search results.|,
lastUpdated => 1104630516,

View file

@ -0,0 +1,80 @@
package WebGUI::i18n::English::Auth_Twitter;
use strict;
our $I18N = {
'enabled' => {
message => q{Enabled},
lastUpdated => 0,
context => q{Label for auth setting field},
},
'enabled help' => {
message => q{Enabled Twitter-based login},
lastUpdated => 0,
context => q{Hover help for auth setting field},
},
'get key' => {
message => q{Get a Twitter API key from <a href="%s">%s</a>},
lastUpdated => 0,
context => q{Link to get a twitter API key},
},
'consumer key' => {
message => q{Twitter Consumer Key},
lastUpdated => 0,
context => q{Label for auth setting field},
},
'consumer key help' => {
message => q{The Consumer Key from your application settings},
lastUpdated => 0,
context => q{Hover help for auth setting field},
},
'consumer secret' => {
message => q{Twitter Consumer Secret},
lastUpdated => 0,
context => q{Label for auth setting field},
},
'consumer secret help' => {
message => q{The Consumer Secret from your application settings},
lastUpdated => 0,
context => q{Hover help for auth setting field},
},
'choose username title' => {
message => q{Choose a Username},
lastUpdated => 0,
context => q{Title for screen to choose a username},
},
'twitter screen name taken' => {
message => q{Your twitter screen name "%s" is taken. Please choose a new username.},
lastUpdated => 0,
context => q{An error message for the choose a username screen},
},
'webgui username taken' => {
message => q{That username "%s" is taken. Please choose another.},
lastUpdated => 0,
context => q{An error message for the choose a username screen},
},
'choose username template' => {
message => q{Choose Username Template},
lastUpdated => 0,
context => q{Label for auth setting field},
},
'choose username template help' => {
message => q{The template to choose a username if the user's screen name already exists},
lastUpdated => 0,
context => q{Hover help for auth setting field},
},
};
1;
#vim:ft=perl

View file

@ -165,18 +165,6 @@ our $I18N = {
context => q|a help description|,
},
'removeButton help' => {
message => q|Clicking this button will remove the item from the cart.|,
lastUpdated => 0,
context => q|a help description|,
},
'item shipToButton help' => {
message => q|Clicking this button will set an alternate address as the destination of this item.|,
lastUpdated => 0,
context => q|a help description|,
},
'shippingAddress help' => {
message => q|The HTML formatted address to ship to.|,
lastUpdated => 0,
@ -189,6 +177,12 @@ our $I18N = {
context => q|a help description|,
},
'message help' => {
message => q|If the cart is empty, this internationalized message should be displayed to the user.|,
lastUpdated => 0,
context => q|a help description|,
},
'formHeader help' => {
message => q|The top of the form.|,
lastUpdated => 0,
@ -243,6 +237,12 @@ our $I18N = {
context => q|a help description|,
},
'paymentOptions help' => {
message => q|A select list containing all the configured payment options for this order.|,
lastUpdated => 0,
context => q|a help description|,
},
'inShopCreditAvailable help' => {
message => q|The amount of in-shop credit the user has.|,
lastUpdated => 0,
@ -447,6 +447,12 @@ our $I18N = {
context => q|a help description|,
},
'emailField help' => {
message => q|A field to contain the email address for this address.|,
lastUpdated => 0,
context => q|a help description|,
},
'phoneNumber help' => {
message => q|A phone number for this address.|,
lastUpdated => 0,
@ -1782,7 +1788,7 @@ our $I18N = {
'shippableItemsInCart' => {
message => q|A boolean which will be true if any item in the cart requires shipping.|,
lastUpdated => 0,
context => q|form label for the cart. Allows user to choose a payment method. Bart Jol for Minister in 2012!|
context => q|Template variable help.|
},
'no billing address' => {
@ -1905,6 +1911,84 @@ our $I18N = {
context => q|Cart error message|
},
'minimumCartAmount help' => {
message => q|The minimum cart amount, from the settings, formatted to two decimal places.|,
lastUpdated => 0,
context => q|Template variable help|
},
'userIsVisitor help' => {
message => q|A boolean which will be true if the currrent user is Visitor|,
lastUpdated => 0,
context => q|Template variable help|
},
'removeBox help' => {
message => q|A checkbox that will allow this item to be removed from the cart.|,
lastUpdated => 0,
context => q|Template variable help|
},
'itemAddressChooser help' => {
message => q|A dropdown for choosing an address to ship an individual item in the cart to, enabling per-item shipping.|,
lastUpdated => 0,
context => q|Template variable help|
},
'shippingAddressChooser help' => {
message => q|A dropdown for choosing a default shipping address for all items in the cart. Also contains actions for editing and adding new addresses.|,
lastUpdated => 0,
context => q|Template variable help|
},
'billingAddressChooser help' => {
message => q|A dropdown for choosing a default billing address.|,
lastUpdated => 0,
context => q|Template variable help|
},
'sameShippingAsBilling help' => {
message => q|A checkbox to tell the cart that the user wants to use the same shipping address, as their billing address.|,
lastUpdated => 0,
context => q|Template variable help|
},
'loginFormHeader help' => {
message => q|The start of the form to help a user log in. This variable will only be populated if the current user is Visitor.|,
lastUpdated => 0,
context => q|Template variable help|
},
'loginFormFooter help' => {
message => q|The end of the form to help a user log in. This variable will only be populated if the current user is Visitor.|,
lastUpdated => 0,
context => q|Template variable help|
},
'loginFormUsername help' => {
message => q|A text box for the user to enter in their name. This variable will only be populated if the current user is Visitor.|,
lastUpdated => 0,
context => q|Template variable help|
},
'loginFormPassword help' => {
message => q|A text box for the user to enter in their password, obscured. This variable will only be populated if the current user is Visitor.|,
lastUpdated => 0,
context => q|Template variable help|
},
'loginFormButton help' => {
message => q|The end of the form to help a user log in. This variable will only be populated if the current user is Visitor.|,
lastUpdated => 0,
context => q|Template variable help|
},
'registerLink help' => {
message => q|A link for a user to register an account on this site, if they do not already have one. This variable will only be populated if the current user is Visitor.|,
lastUpdated => 0,
context => q|Template variable help|
},
};
1;