Merge branch 'master' into WebGUI8
This commit is contained in:
commit
2400f19099
797 changed files with 33894 additions and 27196 deletions
|
|
@ -67,7 +67,7 @@ sub canView {
|
|||
my $uid = $self->uid;
|
||||
|
||||
return 1 if (($session->user->userId eq $uid || $uid eq "") && $session->user->profileField('ableToBeFriend'));
|
||||
|
||||
|
||||
my $user = WebGUI::User->new($session,$uid);
|
||||
return 0 if($user->isVisitor); #This should never happen but let's make sure
|
||||
return 0 unless ($user->profileField('ableToBeFriend')); #User doesn't have friends enabled
|
||||
|
|
@ -310,7 +310,7 @@ sub www_removeFriend {
|
|||
my $i18n = WebGUI::International->new($session,"Account_Friends");
|
||||
$errorMsg = $i18n->get("not a friend error");
|
||||
}
|
||||
|
||||
|
||||
if($errorMsg ne "") {
|
||||
my $backUrl = $self->getUrl("module=friends");
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId);
|
||||
|
|
@ -352,7 +352,7 @@ sub www_removeFriendConfirm {
|
|||
elsif(!$friend->isFriend($friendId)){
|
||||
$errorMsg = $i18n->get("not a friend error");
|
||||
}
|
||||
|
||||
|
||||
if($errorMsg ne "") {
|
||||
my $backUrl = $self->getUrl("module=friends");
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId);
|
||||
|
|
@ -401,7 +401,7 @@ sub www_sendFriendsRequest {
|
|||
#Overwrite these
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
|
||||
|
||||
my $defaultComment = sprintf(
|
||||
$i18n->get('default friend comments'),
|
||||
$user->getFirstName,
|
||||
|
|
@ -419,12 +419,12 @@ sub www_sendFriendsRequest {
|
|||
value => $defaultComment,
|
||||
width => "600",
|
||||
});
|
||||
|
||||
|
||||
$var->{'form_header' } = WebGUI::Form::formHeader($session,{
|
||||
action => $self->getUrl("module=friends;do=sendFriendsRequestSave;uid=$uid"),
|
||||
extras => q{name="messageForm"}
|
||||
});
|
||||
|
||||
|
||||
$var->{'submit_button' } = WebGUI::Form::submit($session,{});
|
||||
$var->{'form_footer' } = WebGUI::Form::formFooter($session, {});
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ sub www_view {
|
|||
my $user = $self->getUser;
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
|
||||
my $displayView = $uid ne "";
|
||||
$var->{'display_message'} = $msg;
|
||||
|
||||
|
|
@ -507,10 +507,13 @@ sub www_view {
|
|||
#Deal with rows per page
|
||||
my $rpp = $session->form->get("rpp") || 25;
|
||||
my $rpp_url = ";rpp=$rpp";
|
||||
|
||||
#Cache the base url
|
||||
my $friendsUrl = $self->getUrl("op=account;module=friends;do=view");
|
||||
|
||||
# Handle viewing someone else's friends
|
||||
my $uid_url = $session->user->userId eq $uid ? q{} : ";uid=$uid";
|
||||
|
||||
#Cache the base url
|
||||
my $friendsUrl = $self->getUrl("op=account;module=friends;do=view$uid_url");
|
||||
|
||||
#Note for anyone who attempts to sort this list by the user's whole name:
|
||||
#You can do this, but the only way to do it efficiently is to join
|
||||
#the users, userProfileData, and groupings table. This will break if the groups API
|
||||
|
|
@ -525,7 +528,7 @@ sub www_view {
|
|||
$rpp
|
||||
);
|
||||
$p->setDataByArrayRef(\@friendIds);
|
||||
|
||||
|
||||
#Export page to template
|
||||
my @friends = ();
|
||||
foreach my $friendId ( @{$p->getPageData} ) {
|
||||
|
|
@ -533,7 +536,7 @@ sub www_view {
|
|||
next if($friend->isVisitor);
|
||||
#If you have friends turned off you shouldn't show up when other people view your friends friends
|
||||
next if($displayView && !$friend->profileField('ableToBeFriend'));
|
||||
|
||||
|
||||
my $hash = {};
|
||||
# TODO Move this into a sub that can be more easily overridden
|
||||
$hash->{'friend_full_name' } = $friend->getWholeName;
|
||||
|
|
@ -564,7 +567,7 @@ sub www_view {
|
|||
push(@friends,$hash);
|
||||
}
|
||||
my $friendCount = $p->getRowCount;
|
||||
|
||||
|
||||
$var->{'friends_loop' } = \@friends;
|
||||
$var->{'has_friends' } = $friendCount > 0;
|
||||
$var->{'friends_total' } = $friendCount;
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ sub getInboxNotificationTemplateId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInboxSMSNotificationTemplateId ( )
|
||||
=head2 getInboxSmsNotificationTemplateId ( )
|
||||
|
||||
This method returns the template ID for inbox SMS notifications.
|
||||
|
||||
|
|
@ -947,7 +947,8 @@ sub www_inviteUserSave {
|
|||
my $invitation = WebGUI::Mail::Send->create(
|
||||
$session, {
|
||||
to => $to,
|
||||
from => $email,
|
||||
from => $session->setting->get('companyEmail'),
|
||||
replyTo => $email,
|
||||
subject => $subject,
|
||||
}
|
||||
);
|
||||
|
|
@ -957,9 +958,9 @@ sub www_inviteUserSave {
|
|||
|
||||
my $emailBody = $self->processTemplate( $var, $self->getInviteUserMessageTemplateId );
|
||||
|
||||
$invitation->addText($emailBody);
|
||||
$invitation->addHtml($emailBody);
|
||||
|
||||
$invitation->send;
|
||||
$invitation->queue;
|
||||
|
||||
} ## end for my $inviteeEmail (@toList)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use WebGUI::Exception;
|
|||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Shop::Vendor;
|
||||
use JSON qw{ from_json };
|
||||
|
||||
use base qw/WebGUI::Account/;
|
||||
|
|
@ -58,6 +59,10 @@ sub appendCommonVars {
|
|||
|
||||
$var->{ 'manage_tax_url' } = $self->getUrl( 'module=shop;do=manageTaxData' );
|
||||
$var->{ 'manageTaxIsActive' } = $method eq 'manageTaxData';
|
||||
|
||||
eval { WebGUI::Shop::Vendor->newByUserId($session, $session->user->userId); };
|
||||
$var->{ 'userIsVendor' } = ! Exception::Class->caught();
|
||||
$session->log->warn($@);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -253,36 +258,39 @@ Page that show your earnings if you are a vendor.
|
|||
sub www_viewSales {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $vendor = WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId );
|
||||
|
||||
my $var = $vendor->getPayoutTotals;
|
||||
my $totalSales = 0;
|
||||
my $vendor = eval { WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId ); };
|
||||
my @products;
|
||||
my $totalSales = 0;
|
||||
my $var = {};
|
||||
if (! Exception::Class->caught()) {
|
||||
|
||||
my $sth = $session->db->read(
|
||||
q{ SELECT t1.*, sum(t1.quantity) as quantity, sum(t1.vendorPayoutAmount) as payoutAmount }
|
||||
. q{ FROM transactionItem as t1, transaction as t2 }
|
||||
. q{ WHERE t1.transactionId=t2.transactionId AND t2.isSuccessful <> 0 }
|
||||
. q{ AND vendorId=? }
|
||||
. q{ group by assetId order by quantity desc },
|
||||
[ $vendor->getId ]
|
||||
);
|
||||
ROW: while (my $row = $sth->hashRef) {
|
||||
my $data = $row;
|
||||
$var = $vendor->getPayoutTotals;
|
||||
|
||||
# Add asset properties to tmpl_vars.
|
||||
my $asset = eval { WebGUI::Asset->newById( $session, $row->{ assetId } ); };
|
||||
if (Exception::Class->caught()) {
|
||||
$session->log->error('Unable to instanciate assetId '.$row->{ assetId }.": $@");
|
||||
next ROW;
|
||||
my $sth = $session->db->read(
|
||||
q{ SELECT t1.*, sum(t1.quantity) as quantity, sum(t1.vendorPayoutAmount) as payoutAmount }
|
||||
. q{ FROM transactionItem as t1, transaction as t2 }
|
||||
. q{ WHERE t1.transactionId=t2.transactionId AND t2.isSuccessful <> 0 }
|
||||
. q{ AND vendorId=? }
|
||||
. q{ group by assetId order by quantity desc },
|
||||
[ $vendor->getId ]
|
||||
);
|
||||
while (my $row = $sth->hashRef) {
|
||||
my $data = $row;
|
||||
|
||||
# Add asset properties to tmpl_vars.
|
||||
my $asset = eval { WebGUI::Asset->newById( $session, $row->{ assetId } ); };
|
||||
if (Exception::Class->caught()) {
|
||||
$session->log->error('Unable to instanciate assetId '.$row->{ assetId }.": $@");
|
||||
next;
|
||||
}
|
||||
$row = { %{ $row }, %{ $asset->get } } if $asset;
|
||||
|
||||
push @products, $row;
|
||||
|
||||
$totalSales += $row->{quantity};
|
||||
}
|
||||
$row = { %{ $row }, %{ $asset->get } } if $asset;
|
||||
|
||||
push @products, $row;
|
||||
|
||||
$totalSales += $row->{quantity};
|
||||
$sth->finish;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
$var->{ product_loop } = \@products;
|
||||
$var->{ total_products } = scalar @products;
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ sub checkView {
|
|||
return "chunked";
|
||||
}
|
||||
elsif ($var->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard
|
||||
my $queryFrag = "func=manageTrash";
|
||||
my $queryFrag = "func=manageClipboard";
|
||||
if ($self->session->form->process('revision')) {
|
||||
$queryFrag .= ";revision=".$self->session->form->process('revision');
|
||||
}
|
||||
|
|
@ -860,6 +860,26 @@ sub getClassById {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getWwwCacheKey ( )
|
||||
|
||||
Returns a cache object specific to this asset, and whether or not the request is in SSL mode.
|
||||
|
||||
=cut
|
||||
|
||||
sub getWwwCacheKey {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $method = shift;
|
||||
my $cacheKey = join '_', @_, $self->getId;
|
||||
if ($session->env->sslRequest) {
|
||||
$cacheKey .= '_ssl';
|
||||
}
|
||||
return $cacheKey;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getContainer ( )
|
||||
|
|
@ -1082,10 +1102,27 @@ sub getEditForm {
|
|||
$tabform->getTab($tab)->dynamicField(%params);
|
||||
}
|
||||
|
||||
# send back the rendered form
|
||||
# send back the object
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
sub setupFormField {
|
||||
my ($self, $tabform, $fieldName, $extraFields, $overrides) = @_;
|
||||
my %params = %{$extraFields->{$fieldName}};
|
||||
my $tab = delete $params{tab};
|
||||
|
||||
if (exists $overrides->{fields}{$fieldName}) {
|
||||
my %overrideParams = %{$overrides->{fields}{$fieldName}};
|
||||
my $overrideTab = delete $overrideParams{tab};
|
||||
$tab = $overrideTab if defined $overrideTab;
|
||||
foreach my $key (keys %overrideParams) {
|
||||
$params{"-$key"} = $overrideParams{$key};
|
||||
}
|
||||
}
|
||||
|
||||
$tab ||= 'properties';
|
||||
return $tabform->getTab($tab)->dynamicField(%params);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -1208,16 +1245,31 @@ sub getImportNode {
|
|||
|
||||
=head2 getIsa ( $session, [ $offset ] )
|
||||
|
||||
A class method to return an iterator for getting all Assets by class (and all sub-classes)
|
||||
as Asset objects, one at a time. When the end of the assets is reached, then the iterator
|
||||
will close the database handle that it uses and return undef.
|
||||
A class method to return an iterator for getting all committed Assets by
|
||||
class (and all sub-classes) as Asset objects, one at a time. When the end
|
||||
of the assets is reached, then the iterator will close the database handle
|
||||
that it uses and return undef.
|
||||
|
||||
Assets are processed in order by revisionDate. If the iterator cannot
|
||||
instanciate an asset, it will not return undef. Instead, it will throw
|
||||
an exception. This allows the error condition to be distinguished from the
|
||||
end of the set of assets.
|
||||
|
||||
It should be used like this:
|
||||
|
||||
my $productIterator = WebGUI::Asset::Product->getIsa($session);
|
||||
while (my $product = $productIterator->()) {
|
||||
##Do something useful with $product
|
||||
}
|
||||
my $productIterator = WebGUI::Asset::Product->getIsa($session);
|
||||
ASSET: while (1) {
|
||||
my $product = eval { $productIterator->() };
|
||||
if (my $e = Exception::Class->caught()) {
|
||||
$session->log->error($@);
|
||||
next ASSET;
|
||||
}
|
||||
last ASSET unless $product;
|
||||
##Do something useful with $product
|
||||
}
|
||||
|
||||
In upgrade scripts, the eval and exception handling are best left off, because it is a good time
|
||||
to make the user aware that they have broken assets in their database.
|
||||
|
||||
=head3 $session
|
||||
|
||||
|
|
@ -1228,23 +1280,47 @@ A reference to a WebGUI::Session object.
|
|||
An offset, from the beginning of the results returned from the query, to really begin
|
||||
returning results. This allows very large sets of results to be handled in chunks.
|
||||
|
||||
=head3 $options
|
||||
|
||||
A hashref of options to change how getIsa works.
|
||||
|
||||
=head4 returnAll
|
||||
|
||||
If set to true, then all assets will be returned, regardless of status and state.
|
||||
|
||||
=cut
|
||||
|
||||
sub getIsa {
|
||||
my ($class, $session, $offset) = @_;
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $offset = shift;
|
||||
my $options = shift;
|
||||
my $tableName = $class->tableName;
|
||||
my $sql = "select distinct(assetId) from $tableName";
|
||||
if (defined $offset) {
|
||||
$sql .= ' LIMIT '. $offset . ',1234567890';
|
||||
#Strategy, generate the correct set of assetIds
|
||||
my $sql = "select assetId from assetData as ad ";
|
||||
if ($tableName ne 'assetData') {
|
||||
$sql .= "join `$tableName` using (assetId, revisionDate) ";
|
||||
}
|
||||
my $sth = $session->db->read($sql);
|
||||
$sql .= 'WHERE ';
|
||||
if (! $options->{returnAll}) {
|
||||
$sql .= q{(status='approved' OR status='archived') AND };
|
||||
}
|
||||
$sql .= q{revisionDate = (SELECT MAX(revisionDate) FROM assetData AS a WHERE a.assetId = ad.assetId) order by revisionDate };
|
||||
if (defined $offset) {
|
||||
$sql .= 'LIMIT '. $offset . ',1234567890 ';
|
||||
}
|
||||
my $sth = $session->db->read($sql);
|
||||
return sub {
|
||||
my ($assetId) = $sth->array;
|
||||
my ($assetId, $revisionDate) = $sth->array;
|
||||
if (!$assetId) {
|
||||
$sth->finish;
|
||||
return undef;
|
||||
}
|
||||
return WebGUI::Asset->newPending($session, $assetId);
|
||||
my $asset = eval { WebGUI::Asset->newPending($session, $assetId); };
|
||||
if (!$asset) {
|
||||
WebGUI::Error::ObjectNotFound->throw(id => $assetId);
|
||||
}
|
||||
return $asset;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1378,6 +1454,21 @@ sub getRoot {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSearchUrl ( )
|
||||
|
||||
Returns the URL for the search screen of the asset manager.
|
||||
|
||||
=cut
|
||||
|
||||
sub getSearchUrl {
|
||||
my $self = shift;
|
||||
return $self->getUrl( 'op=assetManager;method=search' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSeparator
|
||||
|
|
@ -2150,18 +2241,20 @@ sub processTemplate {
|
|||
my $var = shift;
|
||||
my $templateId = shift;
|
||||
my $template = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
# Sanity checks
|
||||
if (ref $var ne "HASH") {
|
||||
$self->session->errorHandler->error("First argument to processTemplate() should be a hash reference.");
|
||||
$session->errorHandler->error("First argument to processTemplate() should be a hash reference.");
|
||||
return "Error: Can't process template for asset ".$self->getId." of type ".$self->get("className");
|
||||
}
|
||||
if (!defined $template) {
|
||||
$template = eval { WebGUI::Asset->newById($self->session, $templateId) };
|
||||
$template = eval { WebGUI::Asset->newById($session, $templateId) };
|
||||
}
|
||||
if (! Exception::Class->caught() ) {
|
||||
$var = { %{ $var }, %{ $self->getMetaDataAsTemplateVariables } };
|
||||
$var->{'controls'} = $self->getToolbar if $self->session->var->isAdminOn;
|
||||
$var->{'controls'} = $self->getToolbar if $session->var->isAdminOn;
|
||||
$var->{'assetIdHex'} = $session->id->toHex($self->getId);
|
||||
my %vars = (
|
||||
%{$self->get},
|
||||
'title' => $self->getTitle,
|
||||
|
|
@ -2171,7 +2264,7 @@ sub processTemplate {
|
|||
return $template->process(\%vars);
|
||||
}
|
||||
else {
|
||||
$self->session->errorHandler->error("Can't instantiate template $templateId for asset ".$self->getId);
|
||||
$session->errorHandler->error("Can't instantiate template $templateId for asset ".$self->getId);
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset');
|
||||
return $i18n->get('Error: Cannot instantiate template').' '.$templateId;
|
||||
}
|
||||
|
|
@ -2235,7 +2328,7 @@ sub publish {
|
|||
my $assetIds = $self->session->db->buildArrayRef("select assetId from asset where lineage like ".$self->session->db->quote($self->get("lineage").'%')." $where");
|
||||
my $idList = $self->session->db->quoteAndJoin($assetIds);
|
||||
|
||||
$self->session->db->write("update asset set state='published', stateChangedBy=".$self->session->db->quote($self->session->user->userId).", stateChanged=".$self->session->datetime->time()." where assetId in (".$idList.")");
|
||||
$self->session->db->write("update asset set state='published', stateChangedBy=".$self->session->db->quote($self->session->user->userId).", stateChanged=".time()." where assetId in (".$idList.")");
|
||||
foreach my $id (@{$assetIds}) {
|
||||
my $asset = WebGUI::Asset->newById($self->session, $id);
|
||||
if (defined $asset) {
|
||||
|
|
@ -2684,8 +2777,7 @@ sub www_editSave {
|
|||
|
||||
=head2 www_manageAssets ( )
|
||||
|
||||
Redirect to the asset manager content handler (for backwards
|
||||
compatibility)
|
||||
Redirect to the asset manager content handler (for backwards compatibility)
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -2697,6 +2789,21 @@ sub www_manageAssets {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_searchAssets ( )
|
||||
|
||||
Redirect to the asset manager content handler (for backwards
|
||||
compatibility)
|
||||
|
||||
=cut
|
||||
|
||||
sub www_searchAssets {
|
||||
my $self = shift;
|
||||
$self->session->http->setRedirect( $self->getSearchUrl );
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view ( )
|
||||
|
||||
Returns the view() method of the asset object if the requestor canView.
|
||||
|
|
|
|||
745
lib/WebGUI/Asset/EMSSubmission.pm
Normal file
745
lib/WebGUI/Asset/EMSSubmission.pm
Normal file
|
|
@ -0,0 +1,745 @@
|
|||
package WebGUI::Asset::EMSSubmission;
|
||||
|
||||
=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 Class::C3;
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset);
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Inbox;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Asset::EMSSubmission
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Describe your New Asset's functionality and features here.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Asset::EMSSubmission;
|
||||
|
||||
=head1 TODO
|
||||
|
||||
the comments tab may need to be added in a getEditForm function like Sku::EMSTicket
|
||||
|
||||
make a button/link for the admin to view the submission as the owner sees it.
|
||||
|
||||
the www_edit function should see if the userid is the owner and call a seperate function
|
||||
else if it is not in the admin group return insufitient priviledges
|
||||
else call the getEditForm function like sku::EMSTicket does...
|
||||
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addComment ( comment [, rating, user ] )
|
||||
|
||||
send email when a comment is added
|
||||
|
||||
=cut
|
||||
|
||||
sub addComment {
|
||||
my $self = shift;
|
||||
$self->update({lastReplyBy => $self->session->user->userId});
|
||||
$self->next::method(@_);
|
||||
$self->sendEmailUpdate;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addRevision
|
||||
|
||||
This method exists for demonstration purposes only. The superclass
|
||||
handles revisions to NewAsset Assets.
|
||||
|
||||
=cut
|
||||
|
||||
#sub addRevision {
|
||||
# my $self = shift;
|
||||
# my $newSelf = $self->next::method(@_);
|
||||
# return $newSelf;
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
defines asset properties for New Asset instances. You absolutely need
|
||||
this method in your new Assets.
|
||||
|
||||
=head3 session
|
||||
|
||||
=head3 definition
|
||||
|
||||
A hash reference passed in from a subclass definition.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" );
|
||||
my $EMS_i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
|
||||
my $SKU_i18n = WebGUI::International->new($session, "Asset_Sku");
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
submissionId => {
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
defaultValue => undef,
|
||||
},
|
||||
submissionStatus => {
|
||||
fieldType =>"selectList",
|
||||
defaultValue => 'pending',
|
||||
customDrawMethod=> 'drawStatusField',
|
||||
label => $i18n->get("submission status"),
|
||||
hoverHelp => $i18n->get("submission status help")
|
||||
},
|
||||
description => {
|
||||
tab => "properties",
|
||||
fieldType => "HTMLArea",
|
||||
defaultValue => undef,
|
||||
label => $SKU_i18n->get("description"),
|
||||
hoverHelp => $SKU_i18n->get("description help")
|
||||
},
|
||||
sku => {
|
||||
tab => "shop",
|
||||
fieldType => "text",
|
||||
defaultValue => $session->id->generate,
|
||||
label => $SKU_i18n->get("sku"),
|
||||
hoverHelp => $SKU_i18n->get("sku help")
|
||||
},
|
||||
displayTitle => {
|
||||
tab => "display",
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 1,
|
||||
label => $SKU_i18n->get("display title"),
|
||||
hoverHelp => $SKU_i18n->get("display title help")
|
||||
},
|
||||
vendorId => {
|
||||
tab => "shop",
|
||||
fieldType => "vendor",
|
||||
defaultValue => 'defaultvendor000000000',
|
||||
label => $SKU_i18n->get("vendor"),
|
||||
hoverHelp => $SKU_i18n->get("vendor help")
|
||||
},
|
||||
shipsSeparately => {
|
||||
tab => 'shop',
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
label => $SKU_i18n->get('shipsSeparately'),
|
||||
hoverHelp => $SKU_i18n->get('shipsSeparately help'),
|
||||
},
|
||||
|
||||
price => {
|
||||
tab => "shop",
|
||||
fieldType => "float",
|
||||
defaultValue => 0.00,
|
||||
label => $EMS_i18n->get("price"),
|
||||
hoverHelp => $EMS_i18n->get("price help"),
|
||||
},
|
||||
seatsAvailable => {
|
||||
tab => "shop",
|
||||
fieldType => "integer",
|
||||
defaultValue => 25,
|
||||
label => $EMS_i18n->get("seats available"),
|
||||
hoverHelp => $EMS_i18n->get("seats available help"),
|
||||
},
|
||||
startDate => {
|
||||
noFormPost => 1,
|
||||
fieldType => "dateTime",
|
||||
defaultValue => '',
|
||||
label => $EMS_i18n->get("add/edit event start date"),
|
||||
hoverHelp => $EMS_i18n->get("add/edit event start date help"),
|
||||
autoGenerate => 0,
|
||||
},
|
||||
duration => {
|
||||
tab => "properties",
|
||||
fieldType => "float",
|
||||
defaultValue => 1.0,
|
||||
subtext => $EMS_i18n->get('hours'),
|
||||
label => $EMS_i18n->get("duration"),
|
||||
hoverHelp => $EMS_i18n->get("duration help"),
|
||||
},
|
||||
location => {
|
||||
fieldType => "combo",
|
||||
tab => "properties",
|
||||
customDrawMethod=> 'drawLocationField',
|
||||
label => $EMS_i18n->get("location"),
|
||||
hoverHelp => $EMS_i18n->get("location help"),
|
||||
},
|
||||
relatedBadgeGroups => {
|
||||
tab => "properties",
|
||||
fieldType => "checkList",
|
||||
customDrawMethod=> 'drawRelatedBadgeGroupsField',
|
||||
label => $EMS_i18n->get("related badge groups"),
|
||||
hoverHelp => $EMS_i18n->get("related badge groups ticket help"),
|
||||
},
|
||||
relatedRibbons => {
|
||||
tab => "properties",
|
||||
fieldType => "checkList",
|
||||
customDrawMethod=> 'drawRelatedRibbonsField',
|
||||
label => $EMS_i18n->get("related ribbons"),
|
||||
hoverHelp => $EMS_i18n->get("related ribbons help"),
|
||||
},
|
||||
eventMetaData => {
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
defaultValue => '{}',
|
||||
},
|
||||
ticketId => {
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
defaultValue => '',
|
||||
},
|
||||
);
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'EMSSubmission.gif',
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'EMSSubmission',
|
||||
className => 'WebGUI::Asset::EMSSubmission',
|
||||
properties => \%properties,
|
||||
};
|
||||
return $class->next::method( $session, $definition );
|
||||
} ## end sub definition
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawLocationField ()
|
||||
|
||||
Draws the field for the location property.
|
||||
|
||||
=cut
|
||||
|
||||
sub drawLocationField {
|
||||
my ($self, $params) = @_;
|
||||
my $ems = $self->ems;
|
||||
my $options = { map { $_ => $_ } ( @{ $ems->getSubmissionLocations || [ $ems->getLocations ] } ) } ;
|
||||
if( $ems->isRegistrationStaff ) {
|
||||
return WebGUI::Form::combo($self->session, {
|
||||
name => 'location',
|
||||
value => $self->get('location'),
|
||||
options => $options,
|
||||
});
|
||||
} else {
|
||||
return WebGUI::Form::selectBox($self->session, {
|
||||
name => 'location',
|
||||
value => $self->get('location'),
|
||||
options => $options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawRelatedBadgeGroupsField ()
|
||||
|
||||
Draws the field for the relatedBadgeGroups property.
|
||||
|
||||
=cut
|
||||
|
||||
sub drawRelatedBadgeGroupsField {
|
||||
my ($self, $params) = @_;
|
||||
return WebGUI::Form::checkList($self->session, {
|
||||
name => $params->{name},
|
||||
value => $self->get($params->{name}),
|
||||
vertical => 1,
|
||||
options => $self->getParent->getParent->getBadgeGroups,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawRelatedRibbonsField ()
|
||||
|
||||
Draws the field for the relatedRibbons property.
|
||||
|
||||
=cut
|
||||
|
||||
sub drawRelatedRibbonsField {
|
||||
my ($self, $params) = @_;
|
||||
my %ribbons = ();
|
||||
foreach my $ribbon (@{$self->getParent->getParent->getRibbons}) {
|
||||
$ribbons{$ribbon->getId} = $ribbon->getTitle;
|
||||
}
|
||||
return WebGUI::Form::checkList($self->session, {
|
||||
name => $params->{name},
|
||||
value => $self->get($params->{name}),
|
||||
vertical => 1,
|
||||
options => \%ribbons,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawStatusField
|
||||
|
||||
=cut
|
||||
|
||||
sub drawStatusField {
|
||||
my ($self, $params) = @_;
|
||||
my $options = $self->ems->getSubmissionStatus;
|
||||
my $currentStatus = $self->get('submissionStatus');
|
||||
for my $key ( qw/pending created failed/ ) {
|
||||
delete $options->{$key} unless $currentStatus eq $key;
|
||||
}
|
||||
return WebGUI::Form::SelectBox($self->session, {
|
||||
name => 'submissionStatus',
|
||||
value => $currentStatus,
|
||||
options => $options,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate
|
||||
|
||||
This method exists for demonstration purposes only. The superclass
|
||||
handles duplicating NewAsset Assets. This method will be called
|
||||
whenever a copy action is executed
|
||||
|
||||
=cut
|
||||
|
||||
#sub duplicate {
|
||||
# my $self = shift;
|
||||
# my $newAsset = $self->next::method(@_);
|
||||
# return $newAsset;
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 ems
|
||||
|
||||
returns the ems ansestor of this asset
|
||||
|
||||
=cut
|
||||
|
||||
sub ems {
|
||||
my $self = shift;
|
||||
$self->getParent->getParent
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 sendEmailUpdate
|
||||
|
||||
if the sendEmail on change is turned on then send email to the owner
|
||||
|
||||
=cut
|
||||
|
||||
sub sendEmailUpdate {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" );
|
||||
WebGUI::Inbox->new($session)->addMessage( {
|
||||
status => 'unread',
|
||||
message => $i18n->get('your submission has been updated') . "\n\n" .
|
||||
$self->get('title'),
|
||||
userId => $self->get('createdBy'),
|
||||
sentBy => $session->user->userId,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmission ( parent, params )
|
||||
|
||||
edit a submission
|
||||
|
||||
=head3 parent
|
||||
|
||||
ref to the EMSSubmissionForm that is parent to the new submission
|
||||
|
||||
=head3 params
|
||||
|
||||
parameters for the submission
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmission {
|
||||
my $this = shift;
|
||||
my $self;
|
||||
my $parent;
|
||||
if( $this eq __PACKAGE__ ) { # called as a constructor
|
||||
$parent = shift;
|
||||
} else {
|
||||
$self = $this;
|
||||
$parent = $self->getParent;
|
||||
}
|
||||
my $params = shift || { };
|
||||
my $session = $parent->session;
|
||||
my $i18n = WebGUI::International->new($parent->session,'Asset_EventManagementSystem');
|
||||
my $i18n_WG = WebGUI::International->new($parent->session,'WebGUI');
|
||||
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId') || 'new';
|
||||
|
||||
if( $assetId ne 'new' ) {
|
||||
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
|
||||
if (!defined $self) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
||||
}
|
||||
}
|
||||
my $asset = $self || $parent;
|
||||
my $url = $asset->getUrl('func=editSubmissionSave');
|
||||
my $newform = WebGUI::HTMLForm->new($session,action => $url);
|
||||
$newform->hidden(name => 'assetId', value => $assetId);
|
||||
my $formDescription = $parent->getFormDescription;
|
||||
my @defs = reverse @{__PACKAGE__->definition($session)};
|
||||
my @fieldNames = qw/title submissionStatus startDate duration seatsAvailable location description/;
|
||||
my $fields;
|
||||
for my $def ( @defs ) {
|
||||
my $properties = $def->{properties};
|
||||
for my $fieldName ( keys %$properties ) {
|
||||
if( defined $formDescription->{$fieldName} ) {
|
||||
$fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy
|
||||
if( $fieldName eq 'description' ) {
|
||||
$fields->{description}{height} = 200;
|
||||
$fields->{description}{width} = 350;
|
||||
}
|
||||
$fields->{$fieldName}{fieldId} = $fieldName;
|
||||
$fields->{$fieldName}{name} = $fieldName;
|
||||
$fields->{$fieldName}{value} = $self->get($fieldName) if $self;
|
||||
}
|
||||
}
|
||||
}
|
||||
# add the meta field
|
||||
for my $metaField ( @{$parent->getParent->getEventMetaFields} ) {
|
||||
my $fieldId = $metaField->{fieldId};
|
||||
if( defined $formDescription->{$fieldId} ) {
|
||||
push @fieldNames, $fieldId;
|
||||
$fields->{$fieldId} = { %$metaField }; # a simple first level copy
|
||||
# meta fields call it data type, we copy it to simplify later on
|
||||
$fields->{$fieldId}{fieldType} = $metaField->{dataType};
|
||||
$fields->{$fieldId}{name} = $fieldId;
|
||||
$fields->{$fieldId}{value} = $self->get($fieldId) if $self;
|
||||
}
|
||||
}
|
||||
|
||||
# for each field
|
||||
if( $fields->{submissionStatus}{value} eq 'created' ) {
|
||||
$formDescription = { } ; # no editable fields once the ticket is created.
|
||||
}
|
||||
for my $fieldId ( @fieldNames ) {
|
||||
my $field = $fields->{$fieldId};
|
||||
if( $formDescription->{$field->{fieldId}} || $asset->ems->isRegistrationStaff ) {
|
||||
my $drawMethod = __PACKAGE__ . '::' . $field->{customDrawMethod};
|
||||
if ($asset->can( $drawMethod )) {
|
||||
$field->{value} = $asset->$drawMethod($field);
|
||||
delete $field->{name}; # don't want readOnly to generate a hidden field
|
||||
$field->{fieldType} = "readOnly";
|
||||
}
|
||||
|
||||
$newform->dynamicField(%$field);
|
||||
} else {
|
||||
my $value;
|
||||
# TODO see that the data gets formatted
|
||||
if( $fieldId eq 'submissionStatus' ) {
|
||||
$value = $field->{value} || 'pending';
|
||||
$value = $i18n->get($value);
|
||||
} else {
|
||||
$value = $field->{value} || '[ ]';
|
||||
}
|
||||
$newform->readOnly(
|
||||
label => $field->{label},
|
||||
value => $value,
|
||||
fieldId => $field->{fieldId},
|
||||
);
|
||||
}
|
||||
}
|
||||
$newform->submit;
|
||||
my $title = $asset->get('title');
|
||||
my $content =
|
||||
$asset->processTemplate({
|
||||
errors => $params->{errors} || [],
|
||||
isDynamic => $session->form->get('asJson') || 0,
|
||||
backUrl => $parent->getUrl,
|
||||
pageTitle => $title,
|
||||
pageForm => $newform->print,
|
||||
commentForm => $self ? $self->getFormattedComments : '',
|
||||
commentFlag => $self ? 1 : 0 ,
|
||||
},$parent->getParent->get('eventSubmissionTemplateId'));
|
||||
WebGUI::Macro::process( $session, \$content );
|
||||
if( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title, };
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
return $asset->processStyle( $content );
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmissionSave
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmissionSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
my $formParams = $self->processForm;
|
||||
if( $formParams->{_isValid} ) {
|
||||
delete $formParams->{_isValid};
|
||||
$self->addRevision($formParams);
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { override => 1, allowComments => 0 });
|
||||
$self = $self->cloneFromDb;
|
||||
$self->sendEmailUpdate;
|
||||
return $self->ems->www_viewSubmissionQueue;
|
||||
} else {
|
||||
return $self->www_editSubmission($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view
|
||||
|
||||
calles ems->view
|
||||
|
||||
=cut
|
||||
|
||||
sub www_view { $_[0]->ems->www_viewSubmissionQueue }
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm ( )
|
||||
|
||||
Extends the base class to add Tax information for the Sku, in a new tab.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $tabform = $self->SUPER::getEditForm;
|
||||
|
||||
# TODO once comments can be submitted using AJAX this will work...
|
||||
# be sure to uncomment the tab in the next function also...
|
||||
#my $comments = $tabform->getTab( 'comments' );
|
||||
|
||||
# $comments->div({name => 'comments',
|
||||
# contentCallback => sub { $self->getFormattedComments },
|
||||
# });
|
||||
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditTabs ( )
|
||||
|
||||
defines 2 new tabs.
|
||||
the shop tab is created here to mimic the function of the sku-created
|
||||
shop tab. this class holds data like Sku assets so that they can be assigned
|
||||
in the future when the sku asset is created from this data.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditTabs {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_EMSSubmission");
|
||||
my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku");
|
||||
return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9],
|
||||
# The comment tab is not available because comments are not AJAX yet...
|
||||
# ['comments', $i18n->get('comments'), 9]
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getQueueUrl
|
||||
|
||||
returns the URL for the submission queue page with the submisison id in the hash part
|
||||
|
||||
=cut
|
||||
|
||||
sub getQueueUrl {
|
||||
my $self = shift;
|
||||
return $self->ems->getUrl('func=viewSubmissionQueue#' . $self->get('submissionId') );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 indexContent ( )
|
||||
|
||||
Making private. See WebGUI::Asset::indexContent() for additonal details.
|
||||
|
||||
=cut
|
||||
|
||||
sub indexContent {
|
||||
my $self = shift;
|
||||
my $indexer = $self->next::method;
|
||||
$indexer->setIsPublic(0);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->ems->prepareView;
|
||||
#$self->next::method();
|
||||
#my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") );
|
||||
#$template->prepare($self->getMetaDataAsTemplateVariables);
|
||||
#$self->{_viewTemplate} = $template;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
=head2 processForm ( $parent )
|
||||
|
||||
pull data componenets out of $session->form
|
||||
|
||||
=head3 parent
|
||||
|
||||
reference to the EMS asset that is parent to the new submission form asset
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub processForm {
|
||||
my $this = shift;
|
||||
my $form;
|
||||
my $asset;
|
||||
my $parent;
|
||||
my $self;
|
||||
if( $this eq __PACKAGE__ ) {
|
||||
$parent = shift;
|
||||
$form = $parent->session->form;
|
||||
$asset = $parent;
|
||||
} else {
|
||||
$self = $this;
|
||||
$parent = $self->getParent;
|
||||
$form = $self->session->form;
|
||||
$asset = $self;
|
||||
}
|
||||
my $params = {_isValid=>1};
|
||||
my $formDescription = $parent->getFormDescription;
|
||||
my @idList;
|
||||
if( $asset->ems->isRegistrationStaff ) {
|
||||
@idList = ( 'submissionStatus', keys %$formDescription );
|
||||
} else {
|
||||
@idList = @{$formDescription->{_fieldList}} ;
|
||||
}
|
||||
for my $fieldId ( @idList ) {
|
||||
next if $fieldId =~ /^_/;
|
||||
$params->{$fieldId} = $form->get($fieldId);
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processPropertiesFromFormPost ( )
|
||||
|
||||
Used to process properties from the form posted. Do custom things with
|
||||
noFormPost fields here, or do whatever you want. This method is called
|
||||
when /yourAssetUrl?func=editSave is requested/posted.
|
||||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->next::method;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge ( )
|
||||
|
||||
This method is called when data is purged by the system.
|
||||
removes collateral data associated with a NewAsset when the system
|
||||
purges it's data. This method is unnecessary, but if you have
|
||||
auxiliary, ancillary, or "collateral" data or files related to your
|
||||
asset instances, you will need to purge them here.
|
||||
|
||||
=cut
|
||||
|
||||
#sub purge {
|
||||
# my $self = shift;
|
||||
# return $self->next::method;
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purgeRevision ( )
|
||||
|
||||
This method is called when data is purged by the system.
|
||||
|
||||
=cut
|
||||
|
||||
#sub purgeRevision {
|
||||
# my $self = shift;
|
||||
# return $self->next::method;
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the container www_view method.
|
||||
NOTE: this should net get called, all views are redirected elsewhere.
|
||||
|
||||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
return $self->ems->view;
|
||||
#my $var = $self->get; # $var is a hash reference.
|
||||
#$var->{controls} = $self->getToolbar;
|
||||
#return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
Web facing method which is the default edit page. Unless the method needs
|
||||
special handling or formatting, it does not need to be included in
|
||||
the module.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new( $session, 'Asset_EMSSubmission' );
|
||||
return $self->getAdminConsole->render( $self->getEditForm->print, $i18n->get('edit asset') );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
#vim:ft=perl
|
||||
505
lib/WebGUI/Asset/EMSSubmissionForm.pm
Normal file
505
lib/WebGUI/Asset/EMSSubmissionForm.pm
Normal file
|
|
@ -0,0 +1,505 @@
|
|||
package WebGUI::Asset::EMSSubmissionForm;
|
||||
|
||||
|
||||
=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 Tie::IxHash;
|
||||
use base 'WebGUI::Asset';
|
||||
use JSON;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Asset::EMSSubmissionForm
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This Asset describes and builds a form which provides an interface for submitting a custom
|
||||
subset of the EMSTicket asset. Users create submissions which can be editted by admins
|
||||
and then become EMSTicket's.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Asset::EMSSubmissionForm;
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addSubmission
|
||||
|
||||
Creates an EMSSubmission object based on the params
|
||||
( called by www_saveSubmission )
|
||||
|
||||
=cut
|
||||
|
||||
sub addSubmission {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
my $newParams = {};
|
||||
my $fieldList = $self->getFormDescription->{_fieldList};
|
||||
for my $field ( @$fieldList ) {
|
||||
$newParams->{$field} = $form->get($field);
|
||||
}
|
||||
$newParams->{className} = 'WebGUI::Asset::EMSSubmission';
|
||||
$newParams->{submissionStatus} = 'pending';
|
||||
$newParams->{submissionId} = $self->ems->getNextSubmissionId;
|
||||
my $newAsset = $self->addChild($newParams);
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, { override => 1, allowComments => 0 });
|
||||
$self = $self->cloneFromDb;
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canSubmit
|
||||
|
||||
returns true if current user can submit using this form
|
||||
|
||||
=cut
|
||||
|
||||
sub canSubmit {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->user->isInGroup($self->get('canSubmitGroupId'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
defines asset properties for New Asset instances. You absolutely need
|
||||
this method in your new Assets.
|
||||
|
||||
=head3 session
|
||||
|
||||
=head3 definition
|
||||
|
||||
A hash reference passed in from a subclass definition.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
canSubmitGroupId => {
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
defaultValue => 2,
|
||||
label => $i18n->get("can submit group label"),
|
||||
hoverHelp => $i18n->get("can submit group label help")
|
||||
},
|
||||
daysBeforeCleanup => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 7,
|
||||
label => $i18n->get("days before cleanup label"),
|
||||
hoverHelp => $i18n->get("days before cleanup label help")
|
||||
},
|
||||
deleteCreatedItems => {
|
||||
tab => "properties",
|
||||
fieldType => "yesNo",
|
||||
defaultValue => undef,
|
||||
label => $i18n->get("delete created items label"),
|
||||
hoverHelp => $i18n->get("delete created items label help")
|
||||
},
|
||||
submissionDeadline => {
|
||||
tab => "properties",
|
||||
fieldType => "Date",
|
||||
defaultValue => time + ( 30 * 24 * 60 * 60 ) , # 30 days
|
||||
label => $i18n->get("submission deadline label"),
|
||||
hoverHelp => $i18n->get("submission deadline label help")
|
||||
},
|
||||
pastDeadlineMessage => {
|
||||
tab => "properties",
|
||||
fieldType => "HTMLArea",
|
||||
defaultValue => $i18n->get('past deadline message'),
|
||||
label => $i18n->get("past deadline label"),
|
||||
hoverHelp => $i18n->get("past deadline label help")
|
||||
},
|
||||
formDescription => {
|
||||
tab => "properties",
|
||||
fieldType => "textarea",
|
||||
defaultValue => '{ }',
|
||||
label => $i18n->get("form dscription label"),
|
||||
hoverHelp => $i18n->get("form dscription label help")
|
||||
},
|
||||
);
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'EMSSubmissionForm.gif',
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'EMSSubmissionForm',
|
||||
className => 'WebGUI::Asset::EMSSubmissionForm',
|
||||
properties => \%properties,
|
||||
};
|
||||
return $class->SUPER::definition( $session, $definition );
|
||||
} ## end sub definition
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 ems
|
||||
|
||||
returns the ems ansestor of this asset
|
||||
|
||||
=cut
|
||||
|
||||
sub ems {
|
||||
my $self = shift;
|
||||
$self->getParent
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmissionForm ( [ parent, ] [ params ] )
|
||||
|
||||
create an html form for user to enter params for a new submissionForm asset
|
||||
|
||||
=head3 parent
|
||||
|
||||
the parent ems object -- needs to be passed only if this is a class level call
|
||||
|
||||
=head3 params
|
||||
|
||||
optional set of possibly incorrect submission form params
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmissionForm {
|
||||
my $this = shift;
|
||||
my $self;
|
||||
my $parent;
|
||||
if( $this eq __PACKAGE__ ) { # called as constructor or menu
|
||||
$parent = shift;
|
||||
} else {
|
||||
$self = $this;
|
||||
$parent = $self->getParent;
|
||||
}
|
||||
my $params = shift || { };
|
||||
my $session = $parent->session;
|
||||
my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem');
|
||||
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId');
|
||||
|
||||
if( ! defined( $assetId ) ) {
|
||||
my $res = $parent->getLineage(['children'],{ returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
if( scalar(@$res) == 1 ) {
|
||||
$self = $res->[0];
|
||||
$assetId = $self->getId;
|
||||
} else {
|
||||
my $makeAnchorList =sub{ my $u=shift; my $n=shift; my $d=shift;
|
||||
return qq{<li><a href='$u' title='$d'>$n</a></li>} } ;
|
||||
my $listOfLinks = join '', ( map {
|
||||
$makeAnchorList->(
|
||||
$_->getQueueUrl,
|
||||
$_->get('title'),
|
||||
WebGUI::HTML::filter($_->get('description'),'all')
|
||||
)
|
||||
} ( @$res ) );
|
||||
my $title = $i18n->get('select form to edit') ;
|
||||
my $content = '<h1>' . $title . '</h1><ul>' . $listOfLinks . '</ul>' ;
|
||||
if( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title, } ;
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
return $parent->ems->processStyle( $content );
|
||||
}
|
||||
}
|
||||
} elsif( $assetId ne 'new' ) {
|
||||
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
|
||||
if (!defined($self)) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
||||
}
|
||||
}
|
||||
my $asset = $self || $parent;
|
||||
my $url = $asset->getUrl('func=editSubmissionFormSave');
|
||||
my $newform = WebGUI::HTMLForm->new( $session, action => $url );
|
||||
$newform->hidden(name => 'assetId', value => $assetId);
|
||||
my @fieldNames = qw/title description startDate duration seatsAvailable location/;
|
||||
my $fields;
|
||||
my @defs = reverse @{WebGUI::Asset::EMSSubmission->definition($session)};
|
||||
for my $def ( @defs ) {
|
||||
foreach my $fieldName ( @fieldNames ) {
|
||||
my $properties = $def->{properties};
|
||||
if( defined $properties->{$fieldName} ) {
|
||||
$fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy
|
||||
# field definitions don't contain their own name, we will need it later on
|
||||
$fields->{$fieldName}{fieldId} = $fieldName;
|
||||
};
|
||||
}
|
||||
}
|
||||
for my $metaField ( @{$parent->getEventMetaFields} ) {
|
||||
push @fieldNames, $metaField->{fieldId};
|
||||
$fields->{$metaField->{fieldId}} = { %$metaField }; # a simple first level copy
|
||||
# meta fields call it data type, we copy it to simplify later on
|
||||
$fields->{$metaField->{fieldId}}{fieldType} = $metaField->{dataType};
|
||||
$fields->{$metaField->{fieldId}}{hoverHelp} = $metaField->{helpText};
|
||||
}
|
||||
$newform->hidden( name => 'fieldNames', value => join( ' ', @fieldNames ) );
|
||||
@defs = reverse @{WebGUI::Asset::EMSSubmissionForm->definition($session)};
|
||||
for my $def ( @defs ) {
|
||||
my $properties = $def->{properties};
|
||||
for my $fieldName ( qw/title menuTitle url description canSubmitGroupId daysBeforeCleanup
|
||||
deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) {
|
||||
if( defined $properties->{$fieldName} ) {
|
||||
my %fieldParams = %{$properties->{$fieldName}};
|
||||
$fieldParams{name} = $fieldName;
|
||||
$fieldParams{value} = $params->{$fieldName} || $self ? $self->get($fieldName) : undef ;
|
||||
$newform->dynamicField(%fieldParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $formDescription = $params->{formDescription} || $self ? $self->getFormDescription : { };
|
||||
for my $fieldId ( @fieldNames ) {
|
||||
next if $fieldId eq 'submissionStatus';
|
||||
my $field = $fields->{$fieldId};
|
||||
$newform->yesNo(
|
||||
label => $field->{label},
|
||||
name => $field->{fieldId} . '_yesNo',
|
||||
defaultValue => 0,
|
||||
value => $formDescription->{$field->{fieldId}},
|
||||
);
|
||||
}
|
||||
$newform->submit;
|
||||
my $title = $assetId eq 'new' ? $i18n->get('new form') || 'new' : $asset->get('title');
|
||||
if( $params->{asHashRef} ) {
|
||||
; # not setting mimie type
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
}
|
||||
my $content = $asset->processTemplate({
|
||||
errors => $params->{errors} || [],
|
||||
isDynamic => $session->form->get('asJson') || 0,
|
||||
backUrl => $parent->getUrl,
|
||||
pageTitle => $title,
|
||||
pageForm => $newform->print,
|
||||
},$parent->get('eventSubmissionTemplateId'));
|
||||
WebGUI::Macro::process( $session, \$content );
|
||||
if( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title };
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
|
||||
} else {
|
||||
return $asset->ems->processStyle( $content );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmissionFormSave
|
||||
|
||||
test and save new params
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmissionFormSave {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
my $formParams = $self->processForm();
|
||||
if( $formParams->{_isValid} ) {
|
||||
delete $formParams->{_isValid};
|
||||
$self->addRevision($formParams);
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
|
||||
$self = $self->cloneFromDb;
|
||||
return $self->getParent->www_viewSubmissionQueue;
|
||||
} else {
|
||||
return $self->www_editSubmissionForm($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view
|
||||
|
||||
calls ems->view
|
||||
|
||||
=cut
|
||||
|
||||
sub www_view { $_[0]->ems->www_viewSubmissionQueue }
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFormDescription
|
||||
|
||||
returns a hash ref decoded from the JSON in the form description field
|
||||
|
||||
=cut
|
||||
|
||||
sub getFormDescription {
|
||||
my $self = shift;
|
||||
return JSON->new->decode($self->get('formDescription'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getQueueUrl
|
||||
|
||||
returns the URL for the submission queue page with the submisison id in the hash part
|
||||
|
||||
=cut
|
||||
|
||||
sub getQueueUrl {
|
||||
my $self = shift;
|
||||
return $self->ems->getUrl('func=viewSubmissionQueue#' . $self->getId );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the container www_view method.
|
||||
Note: this really shouldn't get called, all views are redirected elsewhere
|
||||
|
||||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
return $self->ems->view;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
=head2 www_addSubmission ( )
|
||||
|
||||
calls www_editSubmission with assetId == new
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addSubmission {
|
||||
my $self = shift;
|
||||
my $params = shift || { };
|
||||
$self->www_editSubmission( { assetId => 'new', %$params } );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmission { params }
|
||||
|
||||
calls WebGUI::Asset::EMSSubmission->editSubmission
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmission {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canSubmit;
|
||||
return WebGUI::Asset::EMSSubmission->www_editSubmission($self,shift);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmissionSave
|
||||
|
||||
validate and create a new submission
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmissionSave {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canSubmit;
|
||||
my $formParams = WebGUI::Asset::EMSSubmission->processForm($self);
|
||||
if( $formParams->{_isValid} ) {
|
||||
delete $formParams->{_isValid};
|
||||
$self->addSubmission($formParams);
|
||||
return $self->getParent->www_viewSubmissionQueue;
|
||||
} else {
|
||||
return $self->www_editSubmission($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
=head2 processForm ( $parent )
|
||||
|
||||
pull data componenets out of $session->form
|
||||
|
||||
=head3 parent
|
||||
|
||||
reference to the EMS asset that is parent to the new submission form asset
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub processForm {
|
||||
my $this = shift;
|
||||
my $form;
|
||||
my $session;
|
||||
if( $this eq __PACKAGE__ ) {
|
||||
my $parent = shift;
|
||||
$session = $parent->session;
|
||||
$form = $session->form;
|
||||
} elsif( ref $this eq __PACKAGE__ ) {
|
||||
$session = $this->session;
|
||||
$form = $session->form;
|
||||
} else {
|
||||
return {_isValid => 0, errors => [ { text => 'invalid function call' } ] };
|
||||
}
|
||||
my $params = {_isValid=>1};
|
||||
for my $fieldName ( qw/assetId title menuTitle url description canSubmitGroupId daysBeforeCleanup
|
||||
deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) {
|
||||
$params->{$fieldName} = $form->get($fieldName);
|
||||
}
|
||||
my @fieldNames = split( ' ', $form->get('fieldNames') );
|
||||
$params->{formDescription} = { map { $_ => $form->get($_ . '_yesNo') } ( @fieldNames ) };
|
||||
$params->{formDescription}{submissionStatus} = 0;
|
||||
$params->{formDescription}{_fieldList} = [ map { $params->{formDescription}{$_} ? $_ : () } ( @fieldNames ) ];
|
||||
if( scalar( @{$params->{formDescription}{_fieldList}} ) == 0 ) {
|
||||
$params->{_isValid} = 0;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );
|
||||
push @{$params->{errors}}, {text => $i18n->get('turn on one field') };
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 update ( )
|
||||
|
||||
We overload the update method from WebGUI::Asset in order to handle file system privileges.
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
if( ref $properties->{formDescription} eq 'HASH' ) {
|
||||
$properties->{formDescription} = JSON->new->encode($properties->{formDescription});
|
||||
}
|
||||
$self->SUPER::update({%$properties, isHidden => 1});
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
#vim:ft=perl
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -575,7 +575,7 @@ Generate the view method for the Asset, and handle caching.
|
|||
sub view {
|
||||
my $self = shift;
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
my $out = eval{$self->session->cache->get("view_".$self->getId)};
|
||||
my $out = eval{$self->session->cache->get($self->getViewCacheKey)};
|
||||
return $out if $out;
|
||||
}
|
||||
my %var = %{$self->get};
|
||||
|
|
@ -585,7 +585,7 @@ sub view {
|
|||
$var{fileSize} = formatBytes($self->get("assetSize"));
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
eval{$self->session->cache->set("view_".$self->getId, $out, $self->get("cacheTimeout"))};
|
||||
eval{$self->session->cache->set($self->getViewCacheKey, $out, $self->get("cacheTimeout"))};
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ sub canEdit {
|
|||
my $album = $self->getParent;
|
||||
|
||||
return 1 if $userId eq $self->ownerUserId;
|
||||
return $album->canEdit($userId);
|
||||
return $album && $album->canEdit($userId);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -224,7 +224,7 @@ sub canView {
|
|||
my $userId = shift || $self->session->user->userId;
|
||||
|
||||
my $album = $self->getParent;
|
||||
return 0 unless $album->canView($userId);
|
||||
return 0 unless $album && $album->canView($userId);
|
||||
|
||||
if ($self->isFriendsOnly && $userId ne $self->ownerUserId ) {
|
||||
my $owner = WebGUI::User->new( $self->session, $self->ownerUserId );
|
||||
|
|
@ -401,7 +401,14 @@ override getParent => sub {
|
|||
return $album;
|
||||
}
|
||||
# Only get the pending version if we're allowed to see this photo in its pending status
|
||||
elsif ( $self->getGallery->canEdit || $self->ownerUserId eq $self->session->user->userId ) {
|
||||
my $gallery
|
||||
= $self->getLineage( ['ancestors'], {
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Wobject::Gallery' ],
|
||||
returnObjects => 1,
|
||||
statusToInclude => [ 'pending', 'approved' ],
|
||||
invertTree => 1,
|
||||
} )->[ 0 ];
|
||||
if ( ($gallery && $gallery->canEdit) || $self->ownerUserId eq $self->session->user->userId ) {
|
||||
my $album
|
||||
= $self->getLineage( ['ancestors'], {
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Wobject::GalleryAlbum' ],
|
||||
|
|
@ -411,10 +418,81 @@ override getParent => sub {
|
|||
} )->[ 0 ];
|
||||
return $album;
|
||||
}
|
||||
return undef;
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getFirstFile ( )
|
||||
|
||||
Get the first file in the GalleryAlbum. Returns an instance of a GalleryFile
|
||||
or undef if there is no first file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFirstFile {
|
||||
my $self = shift;
|
||||
my $allFileIds = $self->getParent->getFileIds;
|
||||
|
||||
return undef unless @{ $allFileIds };
|
||||
return WebGUI::Asset->newByDynamicClass( $self->session, shift @{ $allFileIds });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getLastFile ( )
|
||||
|
||||
Get the last file in the GalleryAlbum. Returns an instance of a GalleryFile
|
||||
or undef if there is no last file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLastFile {
|
||||
my $self = shift;
|
||||
my $allFileIds = $self->getParent->getFileIds;
|
||||
|
||||
return undef unless @{ $allFileIds };
|
||||
return WebGUI::Asset->newByDynamicClass( $self->session, pop @{ $allFileIds });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getNextFile ( )
|
||||
|
||||
Get the next file in the GalleryAlbum. Returns an instance of a GalleryFile,
|
||||
or undef if there is no next file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextFile {
|
||||
my $self = shift;
|
||||
return $self->{_nextFile} if $self->{_nextFile};
|
||||
my $nextId = $self->getParent->getNextFileId( $self->getId );
|
||||
return undef unless $nextId;
|
||||
$self->{_nextFile} = WebGUI::Asset->newByDynamicClass( $self->session, $nextId );
|
||||
return $self->{_nextFile};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getPreviousFile ( )
|
||||
|
||||
Get the previous file in the GalleryAlbum. Returns an instance of a GalleryFile,
|
||||
or undef if there is no previous file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPreviousFile {
|
||||
my $self = shift;
|
||||
return $self->{_previousFile} if $self->{_previousFile};
|
||||
my $previousId = $self->getParent->getPreviousFileId( $self->getId );
|
||||
return undef unless $previousId;
|
||||
$self->{_previousFile} = WebGUI::Asset->newByDynamicClass( $self->session, $previousId );
|
||||
return $self->{_previousFile};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getThumbnailUrl ( )
|
||||
|
||||
Gets the URL to the thumbnail for this GalleryFile. This should probably be
|
||||
|
|
@ -489,10 +567,30 @@ sub getTemplateVars {
|
|||
= $self->getGallery->getUrl('func=listFilesForUser;userId=' . $self->ownerUserId);
|
||||
$var->{ url_promote } = $self->getUrl('func=promote');
|
||||
|
||||
if ( my $firstFile = $self->getFirstFile ) {
|
||||
$var->{ firstFile_url } = $firstFile->getUrl;
|
||||
$var->{ firstFile_title } = $firstFile->get( "title" );
|
||||
$var->{ firstFile_thumbnailUrl } = $firstFile->getThumbnailUrl;
|
||||
}
|
||||
if ( my $nextFile = $self->getNextFile ) {
|
||||
$var->{ nextFile_url } = $nextFile->getUrl;
|
||||
$var->{ nextFile_title } = $nextFile->get( "title" );
|
||||
$var->{ nextFile_thumbnailUrl } = $nextFile->getThumbnailUrl;
|
||||
}
|
||||
if ( my $prevFile = $self->getPreviousFile ) {
|
||||
$var->{ previousFile_url } = $prevFile->getUrl;
|
||||
$var->{ previousFile_title } = $prevFile->get( "title" );
|
||||
$var->{ previousFile_thumbnailUrl } = $prevFile->getThumbnailUrl;
|
||||
}
|
||||
if ( my $lastFile = $self->getLastFile ) {
|
||||
$var->{ lastFile_url } = $lastFile->getUrl;
|
||||
$var->{ lastFile_title } = $lastFile->get( "title" );
|
||||
$var->{ lastFile_thumbnailUrl } = $lastFile->getThumbnailUrl;
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 isFriendsOnly ( )
|
||||
|
|
@ -539,6 +637,13 @@ sub makeShortcut {
|
|||
$shortcut->setOverride( $overrides );
|
||||
}
|
||||
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
}) eq 'redirect') {
|
||||
return 'redirect';
|
||||
};
|
||||
|
||||
return $shortcut;
|
||||
}
|
||||
|
||||
|
|
@ -722,6 +827,19 @@ sub valid_parent_classes {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 validParent ( )
|
||||
|
||||
Override validParent to only allow GalleryAlbums to hold GalleryFiles.
|
||||
|
||||
=cut
|
||||
|
||||
sub validParent {
|
||||
my ($class, $session) = @_;
|
||||
return $session->asset->isa('WebGUI::Asset::Wobject::GalleryAlbum');
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the container www_view method.
|
||||
|
|
@ -765,13 +883,13 @@ sub view {
|
|||
keyword => $keyword,
|
||||
url_searchKeyword
|
||||
=> $self->getGallery->getUrl(
|
||||
"func=search;submit=1;keywords=" . uri_escape($keyword)
|
||||
"func=search;submit=1;keywords=" . uri_escape_utf8($keyword)
|
||||
),
|
||||
url_searchKeywordUser
|
||||
=> $self->getGallery->getUrl(
|
||||
"func=search;submit=1;"
|
||||
. "userId=" . $self->ownerUserId . ';'
|
||||
. 'keywords=' . uri_escape( $keyword )
|
||||
. 'keywords=' . uri_escape_utf8( $keyword )
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -456,10 +456,12 @@ This page is only available to those who can edit this Photo.
|
|||
sub www_edit {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $form = $session->form;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
return $self->session->privilege->locked unless $self->canEditIfLocked;
|
||||
return $session->privilege->insufficient unless $self->canEdit;
|
||||
return $session->privilege->locked unless $self->canEditIfLocked;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||
|
||||
# Prepare the template variables
|
||||
# Cannot get all template vars since they require a storage location, doesn't work for
|
||||
|
|
@ -517,7 +519,7 @@ sub www_edit {
|
|||
$var->{ form_submit }
|
||||
= WebGUI::Form::submit( $session, {
|
||||
name => "submit",
|
||||
value => "Save",
|
||||
value => $i18n->get('save'),
|
||||
});
|
||||
|
||||
$var->{ form_title }
|
||||
|
|
|
|||
|
|
@ -95,11 +95,7 @@ override applyConstraints => sub {
|
|||
super();
|
||||
my $maxImageSize = $options->{maxImageSize} || $self->maxImageSize || $self->session->setting->get("maxImageSize");
|
||||
my $thumbnailSize = $options->{thumbnailSize} || $self->thumbnailSize || $self->session->setting->get("thumbnailSize");
|
||||
my $parameters = $self->parameters;
|
||||
my $storage = $self->getStorageLocation;
|
||||
unless ($parameters =~ /alt\=/) {
|
||||
$self->update({parameters=>$parameters.' alt="'.$self->title.'"'});
|
||||
}
|
||||
my $file = $self->filename;
|
||||
$storage->adjustMaxImageSize($file, $maxImageSize);
|
||||
$self->generateThumbnail($thumbnailSize);
|
||||
|
|
@ -139,34 +135,52 @@ Returns the TabForm object that will be used in generating the edit page for thi
|
|||
=cut
|
||||
|
||||
override getEditForm => sub {
|
||||
my $self = shift;
|
||||
my $tabform = super();
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
$tabform->getTab("properties")->integer(
|
||||
-name=>"thumbnailSize",
|
||||
-label=>$i18n->get('thumbnail size'),
|
||||
-hoverHelp=>$i18n->get('Thumbnail size description'),
|
||||
-value=>$self->thumbnailSize,
|
||||
);
|
||||
$tabform->getTab("properties")->textarea(
|
||||
-name=>"parameters",
|
||||
-label=>$i18n->get('parameters'),
|
||||
-hoverHelp=>$i18n->get('Parameters description'),
|
||||
-value=>$self->parameters,
|
||||
);
|
||||
if ($self->get("filename") ne "") {
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>$i18n->get('thumbnail'),
|
||||
-hoverHelp=>$i18n->get('Thumbnail description'),
|
||||
-value=>'<a href="'.$self->getFileUrl.'"><img src="'.$self->getThumbnailUrl.'?noCache='.$self->session->datetime->time().'" alt="thumbnail" /></a>'
|
||||
);
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->get("filename"));
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>$i18n->get('image size'),
|
||||
-value=>$x.' x '.$y
|
||||
);
|
||||
}
|
||||
return $tabform;
|
||||
my $self = shift;
|
||||
my $tabform = super();
|
||||
|
||||
# Add the fields defined locally and apply any overrides from the config file
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
|
||||
tie my %extraFields, "Tie::IxHash";
|
||||
|
||||
$extraFields{thumbnailSize} = {
|
||||
fieldType => "integer",
|
||||
name => "thumbnailSize",
|
||||
label => $i18n->get('thumbnail size'),
|
||||
hoverHelp => $i18n->get('Thumbnail size description'),
|
||||
value => $self->thumbnailSize,
|
||||
};
|
||||
$extraFields{parameters} = {
|
||||
fieldType => "textarea",
|
||||
name => "parameters",
|
||||
label => $i18n->get('parameters'),
|
||||
hoverHelp => $i18n->get('Parameters description'),
|
||||
value => $self->parameters,
|
||||
};
|
||||
|
||||
if ($self->filename ne "") {
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->filename);
|
||||
|
||||
$extraFields{thumbnail} = {
|
||||
fieldType => "readOnly",
|
||||
label => $i18n->get('thumbnail'),
|
||||
hoverHelp => $i18n->get('Thumbnail description'),
|
||||
value => '<a href="'.$self->getFileUrl.'"><img src="'.$self->getThumbnailUrl.'?noCache='.time().'" alt="thumbnail" /></a>'
|
||||
};
|
||||
$extraFields{imageSize} = {
|
||||
fieldType => "readOnly",
|
||||
label => $i18n->get('image size'),
|
||||
value => $x.' x '.$y,
|
||||
};
|
||||
}
|
||||
|
||||
my $overrides = $self->session->config->get("assets/".$self->className);
|
||||
|
||||
foreach my $fieldName (keys %extraFields) {
|
||||
$self->setupFormField($tabform, $fieldName, \%extraFields, $overrides);
|
||||
}
|
||||
|
||||
return $tabform;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -206,16 +220,18 @@ Renders this asset.
|
|||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $session = $self->session;
|
||||
my $cache = $session->cache;
|
||||
my $cacheKey = $self->getWwwCacheKey('view');
|
||||
if (!$session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval { $cache->get( $cacheKey ) };
|
||||
return $out if $out;
|
||||
}
|
||||
my %var = %{$self->get};
|
||||
my ($crop_js, $domMe) = $self->annotate_js({ just_image => 1 });
|
||||
|
||||
if ($crop_js) {
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
$style->setLink($url->extras('yui/build/fonts/fonts-min.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
$style->setLink($url->extras('yui/container/assets/container.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
|
|
@ -223,18 +239,17 @@ sub view {
|
|||
$style->setScript($url->extras('yui/build/container/container-min.js'), {type=>'text/javascript'});
|
||||
}
|
||||
|
||||
$var{controls} = $self->getToolbar;
|
||||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{thumbnail} = $self->getThumbnailUrl;
|
||||
$var{annotateJs} = "$crop_js$domMe";
|
||||
$var{parameters} = sprintf("id=%s", $self->getId());
|
||||
my $form = $self->session->form;
|
||||
$var{controls} = $self->getToolbar;
|
||||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{thumbnail} = $self->getThumbnailUrl;
|
||||
$var{annotateJs} = $crop_js . $domMe;
|
||||
$var{parameters} .= sprintf("id=%s", $self->getId);
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->get("cacheTimeout"))};
|
||||
}
|
||||
return $out;
|
||||
if (!$session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{ $cache->set( $cacheKey, $out, $self->get("cacheTimeout") ) };
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -262,23 +277,27 @@ Also adds the Image template form variable.
|
|||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_Image');
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=resize'),$i18n->get("resize image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=rotate'),$i18n->get("rotate image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=crop'),$i18n->get("crop image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=annotate'),$i18n->get("annotate image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=undo'),$i18n->get("undo image")) if ($self->filename);
|
||||
my $tabform = $self->getEditForm;
|
||||
$tabform->getTab("display")->template(
|
||||
-value=>$self->get("templateId"),
|
||||
-namespace=>"ImageAsset",
|
||||
-hoverHelp=>$i18n->get('image template description'),
|
||||
-defaultValue=>"PBtmpl0000000000000088"
|
||||
);
|
||||
return $self->getAdminConsole->render($tabform->print,$i18n->get("edit image"));
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Image');
|
||||
if ($self->filename) {
|
||||
my $ac = $self->getAdminConsole;
|
||||
$ac->addSubmenuItem($self->getUrl('func=resize'), $i18n->get("resize image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=rotate'), $i18n->get("rotate image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=crop'), $i18n->get("crop image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=annotate'), $i18n->get("annotate image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=undo'), $i18n->get("undo image"));
|
||||
}
|
||||
my $tabform = $self->getEditForm;
|
||||
$tabform->getTab("display")->template(
|
||||
-value => $self->templateId,
|
||||
-namespace => "ImageAsset",
|
||||
-hoverHelp => $i18n->get('image template description'),
|
||||
-defaultValue => "PBtmpl0000000000000088",
|
||||
);
|
||||
return $self->getAdminConsole->render($tabform->print,$i18n->get("edit image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -293,10 +312,8 @@ have been done to it.
|
|||
sub www_undo {
|
||||
my $self = shift;
|
||||
my $previous = (@{$self->getRevisions()})[1];
|
||||
# instantiate assetId
|
||||
if ($previous) {
|
||||
$self = $self->purgeRevision();
|
||||
$self = $previous;
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
return $self->www_edit();
|
||||
|
|
@ -317,20 +334,21 @@ Allow the user to place some text on their image. This is done via JS and toolt
|
|||
=cut
|
||||
|
||||
sub www_annotate {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if (1) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->annotate($newSelf->filename,$newSelf,$newSelf->session->form);
|
||||
$newSelf->getStorageLocation->annotate($newSelf->filename,$newSelf,$session->form);
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
# $style->setLink($url->extras('annotate/imageMap.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
$style->setLink($url->extras('yui/build/resize/assets/skins/sam/resize.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
$style->setLink($url->extras('yui/build/fonts/fonts-min.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
|
|
@ -342,10 +360,7 @@ sub www_annotate {
|
|||
$style->setScript($url->extras('yui/build/resize/resize-min.js'), {type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/imagecropper/imagecropper-min.js'), {type=>'text/javascript'});
|
||||
|
||||
# my $imageAsset = $self->session->db->getRow("ImageAsset","assetId",$self->getId);
|
||||
|
||||
my @pieces = split(/\n/, $self->annotations);
|
||||
# my ($top_left, $width_height, $note) = split(/\n/, $imageAsset->{annotations});
|
||||
|
||||
my ($img_null, $tooltip_block, $tooltip_none) = ('', '', '');
|
||||
for (my $i = 0; $i < $#pieces; $i += 3) {
|
||||
|
|
@ -353,7 +368,6 @@ sub www_annotate {
|
|||
$tooltip_block .= "YAHOO.util.Dom.setStyle('tooltip$i', 'display', 'block');\n";
|
||||
$tooltip_none .= "YAHOO.util.Dom.setStyle('tooltip$i', 'display', 'none');\n";
|
||||
my $j = $i + 2;
|
||||
# warn("i: $i: ", $self->session->form->process("delAnnotate$i"));
|
||||
}
|
||||
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>';
|
||||
|
|
@ -361,8 +375,8 @@ sub www_annotate {
|
|||
my ($width, $height) = $self->getStorageLocation->getSize($self->filename);
|
||||
|
||||
my @checkboxes = ();
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
$f->hidden(
|
||||
|
|
@ -539,49 +553,51 @@ Returns the user to the roate form.
|
|||
=cut
|
||||
|
||||
sub www_rotate {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if (defined $self->session->form->process("Rotate")) {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if (defined $session->form->process("Rotate")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->rotate($newSelf->filename,$newSelf->session->form->process("Rotate"));
|
||||
$newSelf->getStorageLocation->rotate($newSelf->filename,$session->form->process("Rotate"));
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->filename);
|
||||
|
||||
##YUI specific datatable CSS
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
my $img_name = $self->getStorageLocation->getUrl($self->filename);
|
||||
my $img_file = $self->filename;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>';
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"rotate"
|
||||
);
|
||||
);
|
||||
$f->button(
|
||||
-value=>"Left",
|
||||
-extras=>qq(onclick="var deg = document.getElementById('Rotate_formId').value; deg = parseInt(deg) + 90; document.getElementById('Rotate_formId').value = deg;"),
|
||||
);
|
||||
);
|
||||
$f->button(
|
||||
-value=>"Right",
|
||||
-extras=>qq(onclick="var deg = document.getElementById('Rotate_formId').value; deg = parseInt(deg) - 90; document.getElementById('Rotate_formId').value = deg;"),
|
||||
);
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('degree'),
|
||||
-name=>"Rotate",
|
||||
-value=>0,
|
||||
);
|
||||
);
|
||||
$f->submit;
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("rotate image"));
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("rotate image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -596,22 +612,24 @@ Returns the user to the resize form.
|
|||
=cut
|
||||
|
||||
sub www_resize {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if ($self->session->form->process("newWidth") || $self->session->form->process("newHeight")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->resize($newSelf->filename,$newSelf->session->form->process("newWidth"),$newSelf->session->form->process("newHeight"));
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if ($session->form->process("newWidth") || $session->form->process("newHeight")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->resize($newSelf->filename,$session->form->process("newWidth"),$session->form->process("newHeight"));
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->filename);
|
||||
|
||||
##YUI specific datatable CSS
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
$style->setLink($url->extras('yui/build/fonts/fonts-min.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
$style->setLink($url->extras('yui/build/resize/assets/skins/sam/resize.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
|
|
@ -630,8 +648,8 @@ sub www_resize {
|
|||
var resize = new YAHOO.util.Resize('yui_img', {
|
||||
handles: 'all',
|
||||
knobHandles: true,
|
||||
height: '${x}px',
|
||||
width: '${y}px',
|
||||
height: '${y}px',
|
||||
width: '${x}px',
|
||||
proxy: true,
|
||||
ghost: true,
|
||||
status: true,
|
||||
|
|
@ -658,33 +676,33 @@ sub www_resize {
|
|||
</script>
|
||||
);
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"resize"
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>$i18n->get('image size'),
|
||||
-hoverHelp=>$i18n->get('image size description'),
|
||||
-value=>$x.' x '.$y,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new width'),
|
||||
-hoverHelp=>$i18n->get('new width description'),
|
||||
-name=>"newWidth",
|
||||
-value=>$x,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new height'),
|
||||
-hoverHelp=>$i18n->get('new height description'),
|
||||
-name=>"newHeight",
|
||||
-value=>$y,
|
||||
);
|
||||
$f->submit;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>'.$resize_js;
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("resize image"));
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"resize"
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>$i18n->get('image size'),
|
||||
-hoverHelp=>$i18n->get('image size description'),
|
||||
-value=>$x.' x '.$y,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new width'),
|
||||
-hoverHelp=>$i18n->get('new width description'),
|
||||
-name=>"newWidth",
|
||||
-value=>$x,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new height'),
|
||||
-hoverHelp=>$i18n->get('new height description'),
|
||||
-name=>"newHeight",
|
||||
-value=>$y,
|
||||
);
|
||||
$f->submit;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>'.$resize_js;
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("resize image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -700,29 +718,31 @@ Returns the user to the cropping form.
|
|||
=cut
|
||||
|
||||
sub www_crop {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
|
||||
if ($self->session->form->process("Width") || $self->session->form->process("Height")
|
||||
|| $self->session->form->process("Top") || $self->session->form->process("Left")) {
|
||||
if ($session->form->process("Width") || $session->form->process("Height")
|
||||
|| $session->form->process("Top") || $session->form->process("Left")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->crop(
|
||||
$newSelf->filename,
|
||||
$newSelf->session->form->process("Width"),
|
||||
$newSelf->session->form->process("Height"),
|
||||
$newSelf->session->form->process("Top"),
|
||||
$newSelf->session->form->process("Left")
|
||||
$session->form->process("Width"),
|
||||
$session->form->process("Height"),
|
||||
$session->form->process("Top"),
|
||||
$session->form->process("Left")
|
||||
);
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my $filename = $self->filename;
|
||||
|
||||
##YUI specific datatable CSS
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
my $crop_js = qq(
|
||||
<script>
|
||||
|
|
@ -760,10 +780,10 @@ sub www_crop {
|
|||
$style->setScript($url->extras('yui/build/resize/resize-min.js'), {type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/imagecropper/imagecropper-min.js'), {type=>'text/javascript'});
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
-name=>"degree",
|
||||
-value=>"0"
|
||||
|
|
@ -799,7 +819,7 @@ sub www_crop {
|
|||
);
|
||||
$f->submit;
|
||||
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($filename).'" style="border-style:none;" alt="'.$filename.'" id="yui_img" /></div>'.$crop_js;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($filename).'" style="border-style:none;" alt="'.$filename.'" id="yui_img" /></div>'.$crop_js;
|
||||
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("crop image"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,8 +184,9 @@ used to show the file to administrators.
|
|||
sub view {
|
||||
my $self = shift;
|
||||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $cacheKey = $self->getWwwCacheKey('view');
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval { $cache->get( $cacheKey ) };
|
||||
return $out if $out;
|
||||
}
|
||||
my %var = %{$self->get};
|
||||
|
|
@ -207,10 +208,10 @@ sub view {
|
|||
$var{noInitialPage} = $i18n->get('noInitialPage');
|
||||
$var{noFileSpecified} = $i18n->get('noFileSpecified');
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->cacheTimeout)};
|
||||
}
|
||||
return $out;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{ $cache->set( $cacheKey, $out, $self->cacheTimeout) };
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Moose;
|
|||
use WebGUI::Definition::Asset;
|
||||
extends 'WebGUI::Asset';
|
||||
define assetName => ['assetName', 'Asset_MapPoint'];
|
||||
define icon => 'MapPoint.gif';
|
||||
define icon => 'mappoint.png';
|
||||
define tableName => 'MapPoint';
|
||||
property latitude => (
|
||||
tab => "properties",
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ sub setRatings {
|
|||
if ($ratings->{$category}) {
|
||||
$db->write("insert into MatrixListing_rating
|
||||
(userId, category, rating, timeStamp, listingId, ipAddress, assetId) values (?,?,?,?,?,?,?)",
|
||||
[$session->user->userId,$category,$ratings->{$category},$session->datetime->time(),$self->getId,
|
||||
[$session->user->userId,$category,$ratings->{$category},time(),$self->getId,
|
||||
$session->env->get("HTTP_X_FORWARDED_FOR"),$matrixId]);
|
||||
}
|
||||
my $sql = "from MatrixListing_rating where listingId=? and category=?";
|
||||
|
|
|
|||
|
|
@ -458,6 +458,34 @@ sub getDeleteUrl {
|
|||
return $self->getUrl("func=delete;revision=".$self->revisionDate);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getThreadLinkUrl ( )
|
||||
|
||||
Returns the URL for this Post, which links directly to its anchor and page.
|
||||
|
||||
=cut
|
||||
|
||||
sub getThreadLinkUrl {
|
||||
my $self = shift;
|
||||
my $url;
|
||||
my $paginator = WebGUI::Paginator->new($self->session, '', $self->getThread->getParent->get('postsPerPage'));
|
||||
my $page_size = $paginator->{_rpp}; ##To make sure defaults are handled correctly.
|
||||
my $place = $self->getRank+1;
|
||||
my $page = int($place/$page_size) + 1;
|
||||
my $page_frag = 'pn='.$page;
|
||||
if ($self->get("status") eq "pending") {
|
||||
$url = $self->getUrl($page_frag.";revision=".$self->get("revisionDate"));
|
||||
}
|
||||
else {
|
||||
$url = $self->getUrl($page_frag);
|
||||
}
|
||||
$url .= "#id".$self->getId;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditUrl ( )
|
||||
|
|
@ -673,30 +701,31 @@ Returns a hash reference of template variables for this Post.
|
|||
=cut
|
||||
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my %var = %{$self->get};
|
||||
my %var = %{$self->get};
|
||||
my $postUser = WebGUI::User->new($session, $self->ownerUserId);
|
||||
$var{"userId"} = $self->ownerUserId;
|
||||
$var{"user.isPoster"} = $self->isPoster;
|
||||
$var{"avatar.url"} = $self->getAvatarUrl;
|
||||
$var{"userProfile.url"} = $postUser->getProfileUrl($self->getUrl());
|
||||
$var{"dateSubmitted.human"} =$self->session->datetime->epochToHuman($self->creationDate);
|
||||
$var{"dateUpdated.human"} =$self->session->datetime->epochToHuman($self->revisionDate);
|
||||
$var{'title.short'} = $self->chopTitle;
|
||||
$var{content} = $self->formatContent if ($self->getThread);
|
||||
$var{'user.canEdit'} = $self->canEdit if ($self->getThread);
|
||||
$var{"delete.url"} = $self->getDeleteUrl;
|
||||
$var{"edit.url"} = $self->getEditUrl;
|
||||
$var{"status"} = $self->getStatus;
|
||||
$var{"reply.url"} = $self->getReplyUrl;
|
||||
$var{'reply.withquote.url'} = $self->getReplyUrl(1);
|
||||
$var{'url'} = $self->getUrl.'#id'.$self->getId;
|
||||
$var{'url.raw'} = $self->getUrl;
|
||||
$var{'rating.value'} = $self->rating+0;
|
||||
$var{'rate.url.thumbsUp'} = $self->getRateUrl(1);
|
||||
$var{'rate.url.thumbsDown'} = $self->getRateUrl(-1);
|
||||
$var{'hasRated'} = $self->hasRated;
|
||||
$var{"userId"} = $self->ownerUserId;
|
||||
$var{"user.isPoster"} = $self->isPoster;
|
||||
$var{"avatar.url"} = $self->getAvatarUrl;
|
||||
$var{"userProfile.url"} = $postUser->getProfileUrl($self->getUrl());
|
||||
$var{"hideProfileUrl" } = $self->ownerUserId eq '1' || $session->user->isVisitor;
|
||||
$var{"dateSubmitted.human"} = $self->session->datetime->epochToHuman($self->creationDate);
|
||||
$var{"dateUpdated.human"} = $self->session->datetime->epochToHuman($self->revisionDate);
|
||||
$var{'title.short'} = $self->chopTitle;
|
||||
$var{content} = $self->formatContent if ($self->getThread);
|
||||
$var{'user.canEdit'} = $self->canEdit if ($self->getThread);
|
||||
$var{"delete.url"} = $self->getDeleteUrl;
|
||||
$var{"edit.url"} = $self->getEditUrl;
|
||||
$var{"status"} = $self->getStatus;
|
||||
$var{"reply.url"} = $self->getReplyUrl;
|
||||
$var{'reply.withquote.url'} = $self->getReplyUrl(1);
|
||||
$var{'url'} = $self->getUrl.'#id'.$self->getId;
|
||||
$var{'url.raw'} = $self->getUrl;
|
||||
$var{'rating.value'} = $self->rating+0;
|
||||
$var{'rate.url.thumbsUp'} = $self->getRateUrl(1);
|
||||
$var{'rate.url.thumbsDown'} = $self->getRateUrl(-1);
|
||||
$var{'hasRated'} = $self->hasRated;
|
||||
my $gotImage;
|
||||
my $gotAttachment;
|
||||
@{$var{'attachment_loop'}} = ();
|
||||
|
|
@ -854,7 +883,7 @@ sub insertUserPostRating {
|
|||
[$self->getId,
|
||||
$self->session->user->userId,
|
||||
$self->session->env->getIp,
|
||||
$self->session->datetime->time(),
|
||||
time(),
|
||||
$rating,]
|
||||
);
|
||||
}
|
||||
|
|
@ -1062,6 +1091,9 @@ override processPropertiesFromFormPost => sub {
|
|||
else {
|
||||
$self->getThread->unsubscribe;
|
||||
}
|
||||
if ($self->canEdit && $form->process('skip_notification')) {
|
||||
$self->setSkipNotification;
|
||||
}
|
||||
if ($self->getThread->getParent->canEdit) {
|
||||
$form->process('isLocked') ? $self->getThread->lock : $self->getThread->unlock;
|
||||
$form->process('isSticky') ? $self->getThread->stick : $self->getThread->unstick;
|
||||
|
|
@ -1176,19 +1208,20 @@ An integer indicating either thumbss up (+1) or thumbs down (-1)
|
|||
=cut
|
||||
|
||||
sub rate {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $rating = shift;
|
||||
return undef unless ($rating == -1 || $rating == 1);
|
||||
return undef if $self->hasRated;
|
||||
my $session = $self->session;
|
||||
$self->insertUserPostRating($rating);
|
||||
$self->recalculatePostRating();
|
||||
my $thread = $self->getThread;
|
||||
$thread->updateThreadRating();
|
||||
if ($self->session->setting->get("useKarma")
|
||||
&& $self->session->user->karma > $thread->getParent->karmaSpentToRate) {
|
||||
$self->session->user->karma(-$self->getThread->getParent->karmaSpentToRate, "Rated Post ".$self->getId, "Rated a CS Post.");
|
||||
my $u = WebGUI::User->new($self->session, $self->ownerUserId);
|
||||
$u->karma($self->getThread->getParent->karmaRatingMultiplier, "Post ".$self->getId." Rated by ".$self->session->user->userId, "Had post rated.");
|
||||
if ($session->setting->get("useKarma")
|
||||
&& $session->user->karma > $thread->getParent->karmaSpentToRate) {
|
||||
$session->user->karma(-$thread->getParent->karmaSpentToRate, "Rated Post ".$self->getId, "Rated a CS Post.");
|
||||
my $u = WebGUI::User->new($session, $self->ownerUserId);
|
||||
$u->karma($thread->getParent->karmaRatingMultiplier, "Post ".$self->getId." Rated by ".$session->user->userId, "Had post rated.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1394,16 +1427,15 @@ Renders a template form for adding and editing posts.
|
|||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
my $privilege = $session->privilege;
|
||||
my $user = $session->user;
|
||||
my $func = $form->process("func");
|
||||
|
||||
my (%var, $content, $title, $synopsis);
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
|
||||
my (%var, $content, $title, $synopsis);
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
|
||||
my $className = $form->process("class","className") || $self->className;
|
||||
if ($func eq "add" || ($func eq "editSave" && $form->process("assetId") eq "new")) { # new post
|
||||
|
|
@ -1609,7 +1641,12 @@ sub www_edit {
|
|||
});
|
||||
}
|
||||
$var{'form.submit'} = WebGUI::Form::submit($session, {
|
||||
extras=>"onclick=\"this.value='".$i18n->get(452)."'; this.form.func.value='editSave';return true;\""
|
||||
extras=>"onclick=\"this.value='".$i18n->get(452)."'; this.form.func.value='editSave';return true;\""
|
||||
});
|
||||
$var{'form.cancel'} = WebGUI::Form::button( $session, {
|
||||
name => "cancel",
|
||||
value => $i18n->get("cancel"),
|
||||
extras => 'onclick="history.go(-1)"',
|
||||
});
|
||||
$var{'karmaScale.form'} = WebGUI::Form::integer($session, {
|
||||
name=>"karmaScale",
|
||||
|
|
@ -1618,7 +1655,7 @@ sub www_edit {
|
|||
});
|
||||
$var{karmaIsEnabled} = $session->setting->useKarma;
|
||||
$var{'form.preview'} = WebGUI::Form::submit($session, {
|
||||
value=>$i18n->get("preview","Asset_Collaboration")
|
||||
value=>$i18n->get("preview","Asset_Collaboration")
|
||||
});
|
||||
my $numberOfAttachments = $self->getThread->getParent->attachmentsPerPost;
|
||||
$var{'attachment.form'} = WebGUI::Form::image($session, {
|
||||
|
|
@ -1632,6 +1669,10 @@ sub www_edit {
|
|||
name=>'contentType',
|
||||
value=>$self->contentType || "mixed",
|
||||
});
|
||||
$var{'skipNotification.form'} = WebGUI::Form::yesNo($session, {
|
||||
name=>'skip_notification',
|
||||
value=>$form->get("skip_notification",'yesNo') || 0,
|
||||
});
|
||||
if ($session->setting->get("metaDataEnabled")
|
||||
&& $self->getThread->getParent->enablePostMetaData) {
|
||||
my $meta = $self->getMetaDataFields();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ use WebGUI::Group;
|
|||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::SQL;
|
||||
use POSIX qw/ceil/;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -96,7 +97,7 @@ override addRevision => sub {
|
|||
|
||||
=head2 archive
|
||||
|
||||
Archives all posts under this thread.
|
||||
Archives all posts under this thread. Update the thread count in the parent CS.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -105,6 +106,8 @@ sub archive {
|
|||
foreach my $post (@{$self->getPosts}) {
|
||||
$post->setStatusArchived;
|
||||
}
|
||||
my $cs = $self->getParent;
|
||||
$cs->incrementThreads($cs->get("lastPostDate"), $cs->get("lastPostId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -119,7 +122,7 @@ in the default asset, which better be a Collaboration System.
|
|||
sub canAdd {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
return $session->user->isInGroup($session->asset->canStartThreadGroupId);
|
||||
return $session->asset->isa('WebGUI::Asset::Wobject::Collaboration') && $session->asset->canStartThread;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -326,6 +329,77 @@ sub getAutoCommitWorkflowId {
|
|||
return $self->getThread->getParent->threadApprovalWorkflow;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCSLinkUrl ( )
|
||||
|
||||
This URL links to the page of the CS containing this thread, similar
|
||||
to the getThreadLink for the Post. It does not contain the gateway
|
||||
for the site.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCSLinkUrl {
|
||||
my $self = shift;
|
||||
if ($self->get('status') eq 'archived') {
|
||||
return $self->get('url');
|
||||
}
|
||||
my $session = $self->session;
|
||||
my $url;
|
||||
my $cs = $self->getParent;
|
||||
my $page_size = $cs->get('threadsPerPage');
|
||||
my $sql =<<EOSQL;
|
||||
select lineage from asset
|
||||
left join Thread using (assetId)
|
||||
left join assetData using (assetId)
|
||||
where parentId=?
|
||||
and className='WebGUI::Asset::Post::Thread'
|
||||
and state='published'
|
||||
and status='approved'
|
||||
group by assetData.assetId
|
||||
order by Thread.isSticky DESC,
|
||||
lineage DESC
|
||||
EOSQL
|
||||
|
||||
my $sth = $session->db->read($sql, [$cs->getId]);
|
||||
my $place = 1; ##1 based indexing
|
||||
my $found = 0;
|
||||
my $lineage = $self->get('lineage');
|
||||
THREAD: while (my $arrayRef = $sth->arrayRef) {
|
||||
if ($arrayRef->[0] eq $lineage) {
|
||||
$found = 1;
|
||||
last THREAD;
|
||||
}
|
||||
++$place;
|
||||
}
|
||||
$sth->finish;
|
||||
return $self->get('url') if !$found;
|
||||
my $page = ceil($place/$page_size);
|
||||
my $page_frag = 'pn='.$page.';sortBy=lineage;sortOrder=desc';
|
||||
$url = $session->url->append($cs->get('url'), $page_frag);
|
||||
return $url;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getThreadLinkUrl ( )
|
||||
|
||||
Extend the base method from Post to remove the pagination query fragment
|
||||
|
||||
=cut
|
||||
|
||||
sub getThreadLinkUrl {
|
||||
my $self = shift;
|
||||
my $url = $self->SUPER::getThreadLinkUrl();
|
||||
$url =~ s/\?pn=\d+//;
|
||||
if ($url =~ m{;revision=\d+}) {
|
||||
$url =~ s/;revision/?revision/;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLastPost
|
||||
|
|
@ -950,15 +1024,17 @@ sub updateThreadRating {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $calcRating = 0;
|
||||
my $postIds = $self->getLineage(["descendants","self"], {
|
||||
includeOnlyClasses => ["WebGUI::Asset::Post","WebGUI::Asset::Post::Thread"],
|
||||
includeArchived => 1,
|
||||
});
|
||||
|
||||
$calcRating += $session->db->quickScalar(
|
||||
"SELECT SUM(rating) FROM Post_rating WHERE assetId IN (".$session->db->quoteAndJoin($postIds).")"
|
||||
);
|
||||
my $calcRating = 0;
|
||||
if (scalar @{ $postIds }) {
|
||||
$calcRating += $session->db->quickScalar(
|
||||
"SELECT SUM(rating) FROM Post_rating WHERE assetId IN (".$session->db->quoteAndJoin($postIds).")"
|
||||
);
|
||||
}
|
||||
|
||||
$self->update({
|
||||
threadRating => $calcRating
|
||||
|
|
@ -967,7 +1043,8 @@ sub updateThreadRating {
|
|||
my $parent = $self->getParent;
|
||||
if (defined $parent) {
|
||||
$parent->recalculateRating;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$self->session->errorHandler->error("Couldn't get parent for thread ".$self->getId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,7 +600,7 @@ sub getRichEditor {
|
|||
$config{theme_advanced_source_editor_height} = $self->sourceEditorHeight if ($self->sourceEditorHeight > 0);
|
||||
}
|
||||
}
|
||||
my $language = $i18n->getLanguage($self->session->user->profileField("language"),"languageAbbreviation");
|
||||
my $language = $i18n->getLanguage('' ,"languageAbbreviation");
|
||||
unless ($language) {
|
||||
$language = $i18n->getLanguage("English","languageAbbreviation");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ sub _drawQueryBuilder {
|
|||
"AND" => $i18n->get("AND"),
|
||||
"OR" => $i18n->get("OR")},
|
||||
value=>["OR"],
|
||||
extras=>'class="qbselect"',
|
||||
extras=>'class="qbselect" '. $self->{_disabled},
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -129,6 +129,7 @@ sub _drawQueryBuilder {
|
|||
|
||||
# Here starts the field loop
|
||||
my $i = 1;
|
||||
my $addLabel = $i18n->get('add', 'Asset_Wobject');
|
||||
foreach my $field (keys %$fields) {
|
||||
my $fieldLabel = $fields->{$field}{fieldName};
|
||||
my $fieldType = $fields->{$field}{fieldType} || "text";
|
||||
|
|
@ -139,7 +140,7 @@ sub _drawQueryBuilder {
|
|||
name=>$opFieldName,
|
||||
uiLevel=>5,
|
||||
options=>$operator{$fieldType},
|
||||
extras=>'class="qbselect"'
|
||||
extras=>'class="qbselect" '. $self->{_disabled},
|
||||
});
|
||||
# The value select field
|
||||
my $valFieldName = "val_field".$i;
|
||||
|
|
@ -148,13 +149,14 @@ sub _drawQueryBuilder {
|
|||
fieldType=>$fieldType,
|
||||
name=>$valFieldName,
|
||||
uiLevel=>5,
|
||||
extras=>qq/title="$fields->{$field}{description}" class="qbselect"/,
|
||||
extras=>qq/title="$fields->{$field}{description}" class="qbselect" /. $self->{_disabled},
|
||||
options=>$options,
|
||||
);
|
||||
# An empty row
|
||||
$output .= qq|<tr><td></td><td></td><td></td><td></td><td class="qbtdright"></td></tr>|;
|
||||
|
||||
# Table row with field info
|
||||
my $disabled = $self->{_disabled};
|
||||
$output .= qq|
|
||||
<tr>
|
||||
<td class="qbtdleft"><p class="qbfieldLabel">$fieldLabel</p></td>
|
||||
|
|
@ -166,7 +168,7 @@ sub _drawQueryBuilder {
|
|||
</td>
|
||||
<td class="qbtd"></td>
|
||||
<td class="qbtdright">
|
||||
<input class="qbButton" type=button value=Add onclick="addCriteria('$fieldLabel', this.form.$opFieldName, this.form.$valFieldName)"></td>
|
||||
<input class="qbButton" type=button value=$addLabel onclick="addCriteria('$fieldLabel', this.form.$opFieldName, this.form.$valFieldName)" $disabled></td>
|
||||
</tr>
|
||||
|;
|
||||
$i++;
|
||||
|
|
@ -266,8 +268,14 @@ Return the largest of either the asset revision date, or the shortcut revision d
|
|||
sub getContentLastModified {
|
||||
my $self = shift;
|
||||
my $assetRev = $self->get('revisionDate');
|
||||
my $shortcuttedRev = $self->getShortcut->get('revisionDate');
|
||||
return $assetRev > $shortcuttedRev ? $assetRev : $shortcuttedRev;
|
||||
my $shortcut = $self->getShortcut;
|
||||
my $shortcuttedRev;
|
||||
if (defined $shortcut) {
|
||||
$shortcuttedRev = $shortcut->get('revisionDate');
|
||||
return $assetRev > $shortcuttedRev ? $assetRev : $shortcuttedRev;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -303,19 +311,12 @@ override getEditForm => sub {
|
|||
);
|
||||
if($self->session->setting->get("metaDataEnabled")) {
|
||||
$tabform->getTab("properties")->yesNo(
|
||||
-name=>"shortcutByCriteria",
|
||||
-value=>$self->getValue("shortcutByCriteria"),
|
||||
-label=>$i18n->get("Shortcut by alternate criteria"),
|
||||
-hoverHelp=>$i18n->get("Shortcut by alternate criteria description"),
|
||||
-extras=>q|onchange="
|
||||
if (this.form.shortcutByCriteria[0].checked) {
|
||||
this.form.resolveMultiples.disabled=false;
|
||||
this.form.shortcutCriteria.disabled=false;
|
||||
} else {
|
||||
this.form.resolveMultiples.disabled=true;
|
||||
this.form.shortcutCriteria.disabled=true;
|
||||
}"|
|
||||
);
|
||||
-name => "shortcutByCriteria",
|
||||
-value => $self->getValue("shortcutByCriteria"),
|
||||
-label => $i18n->get("Shortcut by alternate criteria"),
|
||||
-hoverHelp=> $i18n->get("Shortcut by alternate criteria description"),
|
||||
-extras => q|onchange="wgCriteriaDisable(this.form, this.form.shortcutByCriteria[0].checked)"|,
|
||||
);
|
||||
$tabform->getTab("properties")->yesNo(
|
||||
-name=>"disableContentLock",
|
||||
-value=>$self->getValue("disableContentLock"),
|
||||
|
|
@ -1281,6 +1282,8 @@ sub getShortcutsForAssetId {
|
|||
|
||||
$properties->{ joinClass } = 'WebGUI::Asset::Shortcut';
|
||||
$properties->{ whereClause } = 'Shortcut.shortcutToAssetId = ' . $db->quote($assetId);
|
||||
$properties->{ statesToInclude } = ['published', 'trash', 'clipboard', 'clipboard-limbo', 'trash-limbo'];
|
||||
$properties->{ statusToInclude } = ['approved', 'pending', 'archived'];
|
||||
|
||||
return WebGUI::Asset->getRoot($session)->getLineage(['descendants'], $properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,49 +294,51 @@ inserts the ad into the adspace...
|
|||
=cut
|
||||
|
||||
sub onCompletePurchase {
|
||||
my $self = shift;
|
||||
my $item = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $item = shift;
|
||||
my $options = $self->getOptions;
|
||||
my $ad;
|
||||
|
||||
# LATER: if we use Temp Storage for the image we need to move it to perm storage
|
||||
|
||||
my $userId = $item->transaction->get('userId');
|
||||
if( $options->{adId} ne '' ) {
|
||||
$ad = WebGUI::AdSpace::Ad->new($self->session,$options->{adId});
|
||||
my $clicks = $options->{clicks} + $ad->get('clicksBought');
|
||||
$ad = WebGUI::AdSpace::Ad->new($session, $options->{adId});
|
||||
my $clicks = $options->{clicks} + $ad->get('clicksBought');
|
||||
my $impressions = $options->{impressions} + $ad->get('impressionsBought');
|
||||
$ad->set({
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $clicks,
|
||||
impressionsBought => $impressions,
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $clicks,
|
||||
impressionsBought => $impressions,
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
});
|
||||
}
|
||||
else {
|
||||
$ad = WebGUI::AdSpace::Ad->create($self->session,$self->adSpace,{
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $options->{'clicks'},
|
||||
impressionsBought => $options->{'impressions'},
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
ownerUserId => $self->session->user->userId,
|
||||
isActive => 1,
|
||||
type => 'image',
|
||||
priority => $self->priority,
|
||||
adSpace => $self->adSpace,
|
||||
$ad = WebGUI::AdSpace::Ad->create($session, $self->adSpace, {
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $options->{'clicks'},
|
||||
impressionsBought => $options->{'impressions'},
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
ownerUserId => $userId,
|
||||
isActive => 1,
|
||||
type => 'image',
|
||||
priority => $self->priority,
|
||||
adSpace => $self->adSpace,
|
||||
});
|
||||
}
|
||||
|
||||
WebGUI::AssetCollateral::Sku::Ad::Ad->create($self->session,{
|
||||
userId => $item->transaction->get('userId'),
|
||||
transactionItemId => $item->getId,
|
||||
adId => $ad->getId,
|
||||
clicksPurchased => $options->{'clicks'},
|
||||
impressionsPurchased => $options->{'impressions'},
|
||||
dateOfPurchase => $item->transaction->get('dateOfPurchase'),
|
||||
storedImage => $options->{'image'},
|
||||
isDeleted => 0,
|
||||
WebGUI::AssetCollateral::Sku::Ad::Ad->create($session, {
|
||||
userId => $userId,
|
||||
transactionItemId => $item->getId,
|
||||
adId => $ad->getId,
|
||||
clicksPurchased => $options->{'clicks'},
|
||||
impressionsPurchased => $options->{'impressions'},
|
||||
dateOfPurchase => $item->transaction->get('dateOfPurchase'),
|
||||
storedImage => $options->{'image'},
|
||||
isDeleted => 0,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ This asset makes donations possible.
|
|||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Asset::Sku::Dnoation;
|
||||
use WebGUI::Asset::Sku::Donation;
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ sub onCompletePurchase {
|
|||
my ($self, $item) = @_;
|
||||
my $badgeInfo = $self->getOptions;
|
||||
$badgeInfo->{purchaseComplete} = 1;
|
||||
$badgeInfo->{userId} = $self->session->user->userId; # they have to be logged in at this point
|
||||
$badgeInfo->{userId} = $item->transaction->get('userId'); # they have to be logged in at this point
|
||||
$badgeInfo->{transactionItemId} = $item->getId;
|
||||
$self->session->db->setRow("EMSRegistrant","badgeId", $badgeInfo);
|
||||
return undef;
|
||||
|
|
|
|||
|
|
@ -123,37 +123,37 @@ property warranty => (
|
|||
);
|
||||
property variantsJSON => (
|
||||
##Collateral data is stored as JSON in here
|
||||
noFormPost => 0,
|
||||
noFormPost => 1,
|
||||
default => '[]',
|
||||
fieldType => "textarea",
|
||||
);
|
||||
property accessoryJSON => (
|
||||
##Collateral data is stored as JSON in here
|
||||
noFormPost => 0,
|
||||
noFormPost => 1,
|
||||
default => '[]',
|
||||
fieldType => "textarea",
|
||||
);
|
||||
property relatedJSON => (
|
||||
##Collateral data is stored as JSON in here
|
||||
noFormPost => 0,
|
||||
noFormPost => 1,
|
||||
default => '[]',
|
||||
fieldType => "textarea",
|
||||
);
|
||||
property specificationJSON => (
|
||||
##Collateral data is stored as JSON in here
|
||||
noFormPost => 0,
|
||||
noFormPost => 1,
|
||||
default => '[]',
|
||||
fieldType => "textarea",
|
||||
);
|
||||
property featureJSON => (
|
||||
##Collateral data is stored as JSON in here
|
||||
noFormPost => 0,
|
||||
noFormPost => 1,
|
||||
default => '[]',
|
||||
fieldType => "textarea",
|
||||
);
|
||||
property benefitJSON => (
|
||||
##Collateral data is stored as JSON in here
|
||||
noFormPost => 0,
|
||||
noFormPost => 1,
|
||||
default => '[]',
|
||||
fieldType => "textarea",
|
||||
);
|
||||
|
|
@ -1655,8 +1655,9 @@ sub view {
|
|||
my $error = shift;
|
||||
my $session = $self->session;
|
||||
my $cache = $session->cache;
|
||||
my $cacheKey = $self->getWwwCacheKey( 'view' );
|
||||
if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10){
|
||||
my $out = $cache->get("view_".$self->getId);
|
||||
my $out = $cache->get( $cacheKey );
|
||||
return $out if $out;
|
||||
}
|
||||
my (%data, $segment, %var, @featureloop, @benefitloop, @specificationloop, @accessoryloop, @relatedloop);
|
||||
|
|
@ -1859,7 +1860,7 @@ sub view {
|
|||
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10 && $self->{_hasAddedToCart} != 1){
|
||||
$cache->set("view_".$self->getId, $out, $self->cacheTimeout);
|
||||
$cache->set( $cacheKey, $out, $self->cacheTimeout );
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ around snippet => sub {
|
|||
if ( $self->mimeType eq "text/html" ) {
|
||||
HTML::Packer::minify( \$packed, {
|
||||
remove_comments => 1,
|
||||
remove_newlines => 1,
|
||||
do_javascript => "shrink",
|
||||
do_stylesheet => "minify",
|
||||
} );
|
||||
|
|
@ -166,6 +165,30 @@ sub exportGetUrlAsPath {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCache ( $calledAsWebMethod )
|
||||
|
||||
Overrides the base method to handle Snippet specific caching.
|
||||
|
||||
=head3 $calledAsWebMethod
|
||||
|
||||
If this is true, then change the cache key.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCache {
|
||||
my $self = shift;
|
||||
my $calledAsWebMethod = shift;
|
||||
my $session = $self->session;
|
||||
my $cacheKey = "view_".$calledAsWebMethod.'_'.$self->getId;
|
||||
if ($session->env->sslRequest) {
|
||||
$cacheKey .= '_ssl';
|
||||
}
|
||||
my $cache = WebGUI::Cache->new($session, $cacheKey);
|
||||
return $cache;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getToolbar ( )
|
||||
|
||||
Returns a toolbar with a set of icons that hyperlink to functions that delete, edit, promote, demote, cut, and copy.
|
||||
|
|
@ -207,7 +230,9 @@ override purgeCache => sub {
|
|||
my $cache = $self->session->cache;
|
||||
eval {
|
||||
$cache->delete("view__".$self->getId);
|
||||
$cache->delete("view_1_".$self->getId);
|
||||
$cache->delete("view_1_".$self->getId);
|
||||
$cache->delete("view__".$self->getId . '_ssl');
|
||||
$cache->delete("view_1_".$self->getId . '_ssl');
|
||||
};
|
||||
super();
|
||||
};
|
||||
|
|
@ -238,16 +263,17 @@ toolbar if in adminMode.
|
|||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $calledAsWebMethod = shift;
|
||||
my $session = $self->session;
|
||||
my $session = $self->session;
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session, 1);
|
||||
my $noCache =
|
||||
$session->var->isAdminOn
|
||||
|| $self->cacheTimeout <= 10
|
||||
|| ($versionTag && $versionTag->getId eq $self->tagId);
|
||||
my $cacheKey = $self->getWwwCacheKey('view', $calledAsWebMethod);
|
||||
unless ($noCache) {
|
||||
my $out = eval{$session->cache->get("view_".$calledAsWebMethod."_".$self->getId)};
|
||||
my $out = eval { $session->cache->get( $cacheKey )};
|
||||
return $out if $out;
|
||||
}
|
||||
my $output = $self->usePacked
|
||||
|
|
@ -260,7 +286,7 @@ sub view {
|
|||
}
|
||||
WebGUI::Macro::process($session,\$output);
|
||||
unless ($noCache) {
|
||||
eval{$session->cache->set("view_".$calledAsWebMethod."_".$self->getId, $output, $self->cacheTimeout)};
|
||||
eval { $session->cache->set( $cacheKey, $output, $self->cacheTimeout) };
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ sub getRssData {
|
|||
my $self = shift;
|
||||
my $data = {
|
||||
title => $self->headline || $self->getTitle,
|
||||
description => $self->subtitle,
|
||||
description => $self->story,
|
||||
'link' => $self->getUrl,
|
||||
author => $self->byline,
|
||||
date => $self->lastModified,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ sub _template_autopack {
|
|||
my $packed = $new;
|
||||
HTML::Packer::minify( \$packed, {
|
||||
remove_comments => 1,
|
||||
remove_newlines => 1,
|
||||
do_javascript => "shrink",
|
||||
do_stylesheet => "minify",
|
||||
} );
|
||||
|
|
@ -132,20 +131,16 @@ sub addAttachments {
|
|||
|
||||
my $db = $self->session->db;
|
||||
|
||||
my $sql = q{
|
||||
INSERT INTO template_attachments
|
||||
(templateId, revisionDate, url, type, sequence)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?)
|
||||
};
|
||||
|
||||
foreach my $a (@$attachments) {
|
||||
my @params = (
|
||||
$self->getId,
|
||||
$self->revisionDate,
|
||||
@{$a}{qw(url type sequence)}
|
||||
my %params = (
|
||||
templateId => $self->getId,
|
||||
revisionDate => $self->revisionDate,
|
||||
url => $a->{url},
|
||||
type => $a->{type},
|
||||
sequence => $a->{sequence},
|
||||
attachId => 'new',
|
||||
);
|
||||
$db->write($sql, \@params);
|
||||
$db->setRow('template_attachments', 'attachId', \%params);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -197,6 +192,7 @@ override duplicate => sub {
|
|||
my $self = shift;
|
||||
my $newTemplate = super();
|
||||
$newTemplate->update({isDefault => 0});
|
||||
$newTemplate->addAttachments($self->getAttachments);
|
||||
return $newTemplate;
|
||||
};
|
||||
|
||||
|
|
@ -380,9 +376,12 @@ override getEditForm => sub {
|
|||
);
|
||||
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/dom/dom-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/dom/dom-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/event/event-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/connection/connection-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui-webgui/build/i18n/i18n.js'), {type => 'text/javascript'});
|
||||
|
||||
pop(@headers);
|
||||
my $scriptUrl = $url->extras('templateAttachments.js');
|
||||
|
|
@ -705,9 +704,23 @@ sub processRaw {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge ( )
|
||||
|
||||
Extend the master to purge attachments in all revisions.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
$self->session->db->write('delete from template_attachments where templateId=?', [$self->getId]);
|
||||
return $self->SUPER::purge(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purgeRevision ( )
|
||||
|
||||
Override the master purgeRevision to purge attachments
|
||||
Extend the master purgeRevision to purge attachments
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
|
|
@ -262,8 +262,9 @@ sub getTemplateVars {
|
|||
historyUrl => $self->getUrl("func=getHistory"),
|
||||
editContent => $self->getEditForm,
|
||||
allowsAttachments => $wiki->allowAttachments,
|
||||
comments => $self->getFormattedComments(),
|
||||
comments => $self->getFormattedComments,
|
||||
canEdit => $self->canEdit,
|
||||
canAdminister => $wiki->canAdminister,
|
||||
isProtected => $self->isProtected,
|
||||
content => $wiki->autolinkHtml(
|
||||
$self->scrubContent,
|
||||
|
|
@ -351,21 +352,22 @@ Extends the master method to handle properties and attachments.
|
|||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->next::method(@_);
|
||||
my $actionTaken = ($self->session->form->process("assetId") eq "new") ? "Created" : "Edited";
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
$self->next::method(@_);
|
||||
my $actionTaken = ($session->form->process("assetId") eq "new") ? "Created" : "Edited";
|
||||
my $wiki = $self->getWiki;
|
||||
my $properties = {
|
||||
groupIdView => $wiki->groupIdView,
|
||||
groupIdEdit => $wiki->groupToAdminister,
|
||||
actionTakenBy => $self->session->user->userId,
|
||||
actionTaken => $actionTaken,
|
||||
};
|
||||
my $properties = {
|
||||
groupIdView => $wiki->groupIdView,
|
||||
groupIdEdit => $wiki->groupToAdminister,
|
||||
actionTakenBy => $session->user->userId,
|
||||
actionTaken => $actionTaken,
|
||||
};
|
||||
|
||||
if ($wiki->canAdminister) {
|
||||
$properties->{isProtected} = $self->session->form->get("isProtected");
|
||||
$properties->{isFeatured} = $self->session->form->get("isFeatured");
|
||||
}
|
||||
if ($wiki->canAdminister) {
|
||||
$properties->{isProtected} = $session->form->get("isProtected");
|
||||
$properties->{isFeatured} = $session->form->get("isFeatured");
|
||||
}
|
||||
|
||||
$self->update($properties);
|
||||
|
||||
|
|
@ -374,10 +376,10 @@ sub processPropertiesFromFormPost {
|
|||
maxImageSize => $wiki->maxImageSize,
|
||||
thumbnailSize => $wiki->thumbnailSize,
|
||||
};
|
||||
my @attachments = $self->session->form->param("attachments");
|
||||
my @attachments = $session->form->param("attachments");
|
||||
my @tags = ();
|
||||
foreach my $assetId (@attachments) {
|
||||
my $asset = WebGUI::Asset->newById($self->session, $assetId);
|
||||
my $asset = WebGUI::Asset->newById($session, $assetId);
|
||||
if (defined $asset) {
|
||||
unless ($asset->parentId eq $self->getId) {
|
||||
$asset->setParent($self);
|
||||
|
|
@ -519,6 +521,36 @@ sub www_getHistory {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_purgeRevision
|
||||
|
||||
Override the main method to change which group is allowed to purge revisions for WikiPages. Only
|
||||
members who can administer the parent wiki (canAdminister) can purge revisions.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_purgeRevision {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->getWiki->canAdminister;
|
||||
my $revisionDate = $session->form->process("revisionDate");
|
||||
return undef unless $revisionDate;
|
||||
my $asset = WebGUI::Asset->new($session, $self->getId, $self->get("className"), $revisionDate);
|
||||
return undef if ($asset->get('revisionDate') != $revisionDate);
|
||||
my $parent = $asset->getParent;
|
||||
$asset->purgeRevision;
|
||||
if ($session->form->process("proceed") eq "manageRevisionsInTag") {
|
||||
my $working = (defined $self) ? $self : $parent;
|
||||
$session->http->setRedirect($working->getUrl("op=manageRevisionsInTag"));
|
||||
return undef;
|
||||
}
|
||||
unless (defined $self) {
|
||||
return $parent->www_view;
|
||||
}
|
||||
return $self->www_manageRevisions;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_restoreWikiPage
|
||||
|
||||
Publishes a wiki page that has been put into the trash or the clipboard.
|
||||
|
|
|
|||
|
|
@ -508,12 +508,6 @@ sub www_view {
|
|||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
##Have to dupe this code here because Wobject does not call SUPER.
|
||||
if ($self->get('synopsis')) {
|
||||
$self->session->style->setMeta({
|
||||
name => 'Description',
|
||||
content => $self->get('synopsis'),
|
||||
});
|
||||
}
|
||||
$self->prepareView;
|
||||
my $style = $self->processStyle($self->getSeparator, { noHeadTags => 1 });
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ sub view {
|
|||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10 && !$self->session->form->process("overrideTemplateId") &&
|
||||
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $out = eval{$cache->get($self->getViewCacheKey)};
|
||||
return $out if $out;
|
||||
}
|
||||
my %var;
|
||||
|
|
@ -386,7 +386,7 @@ sub view {
|
|||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10 && !$self->session->form->process("overrideTemplateId") &&
|
||||
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->cacheTimeout)};
|
||||
eval{$cache->set($self->getViewCacheKey, $out, $self->cacheTimeout)};
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ property groupIdSubscribed => (
|
|||
fieldType => 'hidden',
|
||||
);
|
||||
|
||||
|
||||
##### TEMPLATES - DISPLAY #####
|
||||
# Month
|
||||
property templateIdMonth => (
|
||||
|
|
@ -770,18 +769,18 @@ sub getEventsIn {
|
|||
&& Event.endTime IS NULL
|
||||
&&
|
||||
!(
|
||||
Event.startDate >= '$endDate'
|
||||
|| Event.endDate < '$startDate'
|
||||
Event.startDate > '$endDate'
|
||||
|| Event.endDate < '$startDate'
|
||||
)
|
||||
)
|
||||
|| (
|
||||
CONCAT(Event.startDate,' ',Event.startTime) >= '$start'
|
||||
&& CONCAT(Event.startDate,' ',Event.startTime) < '$end'
|
||||
|| !(
|
||||
CONCAT(Event.startDate,' ',Event.startTime) >= '$end'
|
||||
|| CONCAT(Event.endDate, ' ',Event.endTime ) <= '$start'
|
||||
)
|
||||
};
|
||||
|
||||
my @order_priority
|
||||
= ( 'Event.startDate',
|
||||
= ( 'Event.startDate',
|
||||
'Event.startTime',
|
||||
'Event.endDate',
|
||||
'Event.endTime',
|
||||
|
|
@ -1275,9 +1274,11 @@ sub viewList {
|
|||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Calendar");
|
||||
my $var = $self->getTemplateVars;
|
||||
my $tz = $session->datetime->getTimeZone();
|
||||
|
||||
### Get the events
|
||||
my $dtStart = WebGUI::DateTime->new( $session, $params->{start} )->truncate( to => "day" );
|
||||
my $dtStart = WebGUI::DateTime->new( $session, $params->{start} );
|
||||
$dtStart->set_time_zone($tz);
|
||||
my $dtEnd = $dtStart->clone->add( seconds => $self->listViewPageInterval );
|
||||
|
||||
my @events
|
||||
|
|
@ -1446,8 +1447,8 @@ sub viewMonth {
|
|||
}
|
||||
|
||||
# Day names
|
||||
my @dayNames = @{$dt->locale->day_names}[6,0..5]; # Put sunday first
|
||||
my @dayAbbrs = @{$dt->locale->day_abbreviations}[6,0..5];
|
||||
my @dayNames = @{$dt->locale->day_format_wide}[6,0..5]; # Put sunday first
|
||||
my @dayAbbrs = @{$dt->locale->day_format_abbreviated}[6,0..5];
|
||||
# Take from FirstDOW to the end and put it on the beginning
|
||||
unshift @dayNames,splice(@dayNames,$first_dow);
|
||||
unshift @dayAbbrs,splice(@dayAbbrs,$first_dow);
|
||||
|
|
@ -1885,7 +1886,7 @@ sub www_ical {
|
|||
);
|
||||
}
|
||||
else {
|
||||
$dt_start = WebGUI::DateTime->new($self->session, time);
|
||||
$dt_start = WebGUI::DateTime->new($session, time);
|
||||
$dt_start->set_time_zone( $session->datetime->getTimeZone );
|
||||
}
|
||||
|
||||
|
|
@ -1893,7 +1894,7 @@ sub www_ical {
|
|||
my $end = $form->param("end");
|
||||
if ($end) {
|
||||
$dt_end
|
||||
= WebGUI::DateTime->new($self->session,
|
||||
= WebGUI::DateTime->new($session,
|
||||
mysql => $end,
|
||||
time_zone => $session->datetime->getTimeZone,
|
||||
);
|
||||
|
|
@ -1902,8 +1903,6 @@ sub www_ical {
|
|||
$dt_end = $dt_start->clone->add( seconds => $self->icalInterval );
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Get all the events we're going to display
|
||||
my @events = $self->getEventsIn($dt_start->toMysql,$dt_end->toMysql);
|
||||
|
||||
|
|
@ -2104,6 +2103,7 @@ sub www_search {
|
|||
$var->{"form.header"}
|
||||
= WebGUI::Form::formHeader($session, {
|
||||
action => $self->getUrl,
|
||||
method => 'GET',
|
||||
})
|
||||
. WebGUI::Form::hidden($self->session, {
|
||||
name => "func",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ $VERSION = "1.0.0";
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use JSON;
|
||||
use WebGUI::International;
|
||||
use Moose;
|
||||
|
|
|
|||
|
|
@ -532,14 +532,16 @@ A reference to a WebGUI::Paginator object.
|
|||
=cut
|
||||
|
||||
sub appendPostListTemplateVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $p = shift;
|
||||
my $page = $p->getPageData;
|
||||
my $i = 0;
|
||||
my ($icon, $datetime) = $self->session->quick(qw(icon datetime));
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = shift;
|
||||
my $p = shift;
|
||||
my $page = $p->getPageData;
|
||||
my $i = 0;
|
||||
my ($icon, $datetime) = $session->quick(qw(icon datetime));
|
||||
my $isVisitor = $session->user->isVisitor;
|
||||
foreach my $row (@$page) {
|
||||
my $post = WebGUI::Asset->newById($self->session,$row->{assetId}, $row->{revisionDate});
|
||||
my $post = WebGUI::Asset->newById($session,$row->{assetId}, $row->{revisionDate});
|
||||
$post->{_parent} = $self; # caching parent for efficiency
|
||||
my $controls = $icon->delete('func=delete',$post->url,"Delete") . $icon->edit('func=edit',$post->url);
|
||||
if ($self->sortBy eq "lineage") {
|
||||
|
|
@ -560,10 +562,11 @@ sub appendPostListTemplateVars {
|
|||
if ($self->displayLastReply) {
|
||||
my $lastPost = $post->getLastPost();
|
||||
%lastReply = (
|
||||
"lastReply.url" => $lastPost->getUrl.'#'.$lastPost->getId,
|
||||
"lastReply.url" => $lastPost->getThreadLinkUrl,
|
||||
"lastReply.title" => $lastPost->title,
|
||||
"lastReply.user.isVisitor" => $lastPost->ownerUserId eq "1",
|
||||
"lastReply.username" => $lastPost->username,
|
||||
"lastReply.hideProfileUrl" => $lastPost->ownerUserId eq "1" || $isVisitor,
|
||||
"lastReply.userProfile.url" => $lastPost->getPosterProfileUrl(),
|
||||
"lastReply.dateSubmitted.human" => $datetime->epochToHuman($lastPost->creationDate,"%z"),
|
||||
"lastReply.timeSubmitted.human" => $datetime->epochToHuman($lastPost->creationDate,"%Z"),
|
||||
|
|
@ -571,16 +574,10 @@ sub appendPostListTemplateVars {
|
|||
}
|
||||
$hasRead = $post->isMarkedRead;
|
||||
}
|
||||
my $url;
|
||||
if ($post->status eq "pending") {
|
||||
$url = $post->getUrl("revision=".$post->revisionDate)."#".$post->getId;
|
||||
} else {
|
||||
$url = $post->getUrl."#".$post->getId;
|
||||
}
|
||||
my %postVars = (
|
||||
%{$post->get},
|
||||
"id" => $post->getId,
|
||||
"url" => $url,
|
||||
"url" => $post->getThreadLinkUrl,
|
||||
rating_loop => \@rating_loop,
|
||||
"content" => $post->formatContent,
|
||||
"status" => $post->getStatus,
|
||||
|
|
@ -590,14 +587,15 @@ sub appendPostListTemplateVars {
|
|||
"dateUpdated.human" => $datetime->epochToHuman($post->revisionDate,"%z"),
|
||||
"timeSubmitted.human" => $datetime->epochToHuman($post->creationDate,"%Z"),
|
||||
"timeUpdated.human" => $datetime->epochToHuman($post->revisionDate,"%Z"),
|
||||
"hideProfileUrl" => $post->ownerUserId eq '1' || $isVisitor,
|
||||
"userProfile.url" => $post->getPosterProfileUrl,
|
||||
"user.isVisitor" => $post->ownerUserId eq "1",
|
||||
"edit.url" => $post->getEditUrl,
|
||||
'controls' => $controls,
|
||||
"isSecond" => (($i+1)%2==0),
|
||||
"isThird" => (($i+1)%3==0),
|
||||
"isFourth" => (($i+1)%4==0),
|
||||
"isFifth" => (($i+1)%5==0),
|
||||
"isSecond" => (($i+1) == 2),
|
||||
"isThird" => (($i+1) == 3),
|
||||
"isFourth" => (($i+1) == 4),
|
||||
"isFifth" => (($i+1) == 5),
|
||||
"user.hasRead" => $hasRead,
|
||||
"user.isPoster" => $post->isPoster,
|
||||
"avatar.url" => $post->getAvatarUrl,
|
||||
|
|
@ -607,7 +605,7 @@ sub appendPostListTemplateVars {
|
|||
if ($row->{className} =~ m/^WebGUI::Asset::Post::Thread/) {
|
||||
$postVars{'rating'} = $post->threadRating;
|
||||
}
|
||||
push(@{$var->{post_loop}}, \%postVars );
|
||||
push(@{$var->{post_loop}}, \%postVars );
|
||||
$i++;
|
||||
}
|
||||
$p->appendTemplateVars($var);
|
||||
|
|
@ -926,7 +924,8 @@ sub createSubscriptionGroup {
|
|||
|
||||
=head2 duplicate
|
||||
|
||||
Extend the base method to handle making a subscription group for the new CS.
|
||||
Extend the base method to handle making a subscription group for the new CS, and
|
||||
to build a new Cron job. It also recalculates the number of threads and replies.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -934,7 +933,33 @@ sub duplicate {
|
|||
my $self = shift;
|
||||
my $newAsset = $self->next::method(@_);
|
||||
$newAsset->createSubscriptionGroup;
|
||||
return $newAsset;
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Collaboration");
|
||||
my $newCron = WebGUI::Workflow::Cron->create($self->session, {
|
||||
title=>$self->getTitle." ".$i18n->get("mail"),
|
||||
minuteOfHour=>"*/".($self->get("getMailInterval")/60),
|
||||
className=>(ref $self),
|
||||
methodName=>"new",
|
||||
parameters=>$self->getId,
|
||||
workflowId=>"csworkflow000000000001"
|
||||
});
|
||||
$newAsset->update({getMailCronId=>$newCron->getId});
|
||||
$newAsset->incrementReplies('','');
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicateBranch.
|
||||
|
||||
Extend the base method to recalculate the number of threads and replies.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicateBranch {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->next::method(@_);
|
||||
$newAsset->incrementReplies('','');
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1126,62 +1151,75 @@ Collaboration System
|
|||
=cut
|
||||
|
||||
sub getThreadsPaginator {
|
||||
my $self = shift;
|
||||
|
||||
my $scratchSortBy = $self->getId."_sortBy";
|
||||
my $scratchSortOrder = $self->getId."_sortDir";
|
||||
my $sortBy = $self->session->form->process("sortBy") || $self->session->scratch->get($scratchSortBy) || $self->sortBy;
|
||||
my $sortOrder = $self->session->scratch->get($scratchSortOrder) || $self->sortOrder;
|
||||
if ($sortBy ne $self->session->scratch->get($scratchSortBy) && $self->session->form->process("func") ne "editSave") {
|
||||
$self->session->scratch->set($scratchSortBy,$self->session->form->process("sortBy"));
|
||||
$self->session->scratch->set($scratchSortOrder, $sortOrder);
|
||||
} elsif ($self->session->form->process("sortBy") && $self->session->form->process("func") ne "editSave") {
|
||||
if ($sortOrder eq "asc") {
|
||||
$sortOrder = "desc";
|
||||
} else {
|
||||
$sortOrder = "asc";
|
||||
}
|
||||
$self->session->scratch->set($scratchSortOrder, $sortOrder);
|
||||
}
|
||||
$sortBy ||= "assetData.revisionDate";
|
||||
$sortOrder ||= "desc";
|
||||
# Sort by the thread rating instead of the post rating. other places don't care about threads.
|
||||
if ($sortBy eq 'rating') {
|
||||
$sortBy = 'threadRating';
|
||||
}
|
||||
$sortBy = join('.', map { $self->session->db->dbh->quote_identifier($_) } split(/\./, $sortBy));
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $sql = "
|
||||
select
|
||||
asset.assetId,
|
||||
asset.className,
|
||||
assetData.revisionDate as revisionDate
|
||||
from Thread
|
||||
left join asset on Thread.assetId=asset.assetId
|
||||
left join Post on Post.assetId=Thread.assetId and Thread.revisionDate = Post.revisionDate
|
||||
left join assetData on assetData.assetId=Thread.assetId and Thread.revisionDate = assetData.revisionDate
|
||||
where
|
||||
asset.parentId=".$self->session->db->quote($self->getId)."
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::Post::Thread'
|
||||
and assetData.revisionDate=(
|
||||
select
|
||||
max(revisionDate)
|
||||
from
|
||||
assetData
|
||||
where
|
||||
assetData.assetId=asset.assetId
|
||||
and (status='approved' or status='archived')
|
||||
)
|
||||
and status='approved'
|
||||
group by
|
||||
assetData.assetId
|
||||
order by
|
||||
Thread.isSticky desc,
|
||||
".$sortBy."
|
||||
".$sortOrder;
|
||||
my $p = WebGUI::Paginator->new($self->session,$self->getUrl,$self->threadsPerPage);
|
||||
$p->setDataByQuery($sql);
|
||||
my $scratchSortBy = $self->getId."_sortBy";
|
||||
my $scratchSortOrder = $self->getId."_sortDir";
|
||||
my $sortBy = $self->session->form->process("sortBy")
|
||||
|| $self->session->scratch->get($scratchSortBy)
|
||||
|| $self->sortBy;
|
||||
$sortBy =~ s/^\w+\.//;
|
||||
# Sort by the thread rating instead of the post rating. other places don't care about threads.
|
||||
$sortBy = $sortBy eq 'rating' ? 'threadRating' : $sortBy;
|
||||
if (! WebGUI::Utility::isIn($sortBy, qw/userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating/)) {
|
||||
$sortBy = 'revisionDate';
|
||||
}
|
||||
if ($sortBy eq 'assetId' || $sortBy eq 'revisionDate') {
|
||||
$sortBy = 'assetData.' . $sortBy;
|
||||
}
|
||||
my $sortOrder = $self->session->form->process("sortOrder")
|
||||
|| $self->session->scratch->get($scratchSortOrder)
|
||||
|| $self->get("sortOrder");
|
||||
#$sortOrder = lc $sortOrder;
|
||||
#$sortOrder = 'desc' if ($sortOrder ne 'asc' && $sortOrder ne 'desc');
|
||||
if ($sortBy ne $self->session->scratch->get($scratchSortBy) && $self->session->form->process("func") ne "editSave") {
|
||||
$self->session->scratch->set($scratchSortBy,$self->session->form->process("sortBy"));
|
||||
$self->session->scratch->set($scratchSortOrder, $sortOrder);
|
||||
}
|
||||
elsif ($self->session->form->process("sortBy") && $self->session->form->process("func") ne "editSave" && ! $self->session->form->process('sortOrder')) {
|
||||
if ($sortOrder eq "asc") {
|
||||
$sortOrder = "desc";
|
||||
}
|
||||
else {
|
||||
$sortOrder = "asc";
|
||||
}
|
||||
$self->session->scratch->set($scratchSortOrder, $sortOrder);
|
||||
}
|
||||
$sortBy = join('.', map { $self->session->db->dbh->quote_identifier($_) } split(/\./, $sortBy));
|
||||
$sortOrder ||= 'desc';
|
||||
|
||||
my $sql = "
|
||||
select
|
||||
asset.assetId,
|
||||
asset.className,
|
||||
assetData.revisionDate as revisionDate
|
||||
from Thread
|
||||
left join asset on Thread.assetId=asset.assetId
|
||||
left join Post on Post.assetId=Thread.assetId and Thread.revisionDate = Post.revisionDate
|
||||
left join assetData on assetData.assetId=Thread.assetId and Thread.revisionDate = assetData.revisionDate
|
||||
where
|
||||
asset.parentId=".$self->session->db->quote($self->getId)."
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::Post::Thread'
|
||||
and assetData.revisionDate=(
|
||||
select
|
||||
max(revisionDate)
|
||||
from
|
||||
assetData
|
||||
where
|
||||
assetData.assetId=asset.assetId
|
||||
and (status='approved' or status='archived')
|
||||
)
|
||||
and status='approved'
|
||||
group by
|
||||
assetData.assetId
|
||||
order by
|
||||
Thread.isSticky desc,
|
||||
".$sortBy."
|
||||
".$sortOrder;
|
||||
my $p = WebGUI::Paginator->new($session,$self->getUrl,$self->threadsPerPage);
|
||||
$p->setDataByQuery($sql);
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
|
@ -1214,10 +1252,10 @@ sub getViewTemplateVars {
|
|||
my %var;
|
||||
$var{'user.canPost'} = $self->canPost;
|
||||
$var{'user.canStartThread'} = $self->canStartThread;
|
||||
$var{"add.url"} = $self->getNewThreadUrl;
|
||||
$var{"rss.url"} = $self->getRssFeedUrl;
|
||||
$var{'user.isModerator'} = $self->canModerate;
|
||||
$var{'user.isVisitor'} = ($self->session->user->isVisitor);
|
||||
$var{"add.url"} = $self->getNewThreadUrl;
|
||||
$var{"rss.url"} = $self->getRssFeedUrl;
|
||||
$var{'user.isModerator'} = $self->canModerate;
|
||||
$var{'user.isVisitor'} = ($self->session->user->isVisitor);
|
||||
$var{'user.isSubscribed'} = $self->isSubscribed;
|
||||
$var{'sortby.title.url'} = $self->getSortByUrl("title");
|
||||
$var{'sortby.username.url'} = $self->getSortByUrl("username");
|
||||
|
|
@ -1564,6 +1602,23 @@ sub view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit
|
||||
|
||||
Override the master class to add an "Unarchive All" link.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_Collaboration');
|
||||
$self->getAdminConsole->addConfirmedSubmenuItem($self->getUrl('func=unarchiveAll'),$i18n->get("unarchive all"),$i18n->get("unarchive confirm"));
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,$i18n->get("assetName"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_search ( )
|
||||
|
||||
The web method to display and use the forum search interface.
|
||||
|
|
@ -1578,7 +1633,8 @@ sub www_search {
|
|||
|
||||
my $query = $self->session->form->process("query","text");
|
||||
$var->{'form.header'} = WebGUI::Form::formHeader($self->session,{
|
||||
action=>$self->getUrl("func=search;doit=1")
|
||||
action=> $self->getUrl("func=search;doit=1"),
|
||||
method=> 'GET',
|
||||
});
|
||||
$var->{'query.form'} = WebGUI::Form::text($self->session,{
|
||||
name => 'query',
|
||||
|
|
@ -1619,6 +1675,35 @@ sub www_subscribe {
|
|||
return $self->www_view;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_unarchiveAll ( )
|
||||
|
||||
Unarchive all the threads in this collaboration system
|
||||
|
||||
=cut
|
||||
|
||||
sub www_unarchiveAll {
|
||||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Collaboration');
|
||||
$pb->start($i18n->get('unarchive all'), $self->getUrl('func=edit'));
|
||||
my $threadIds = $self->getLineage(['children'],{
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Post::Thread' ],
|
||||
statusToInclude => [ 'archived' ],
|
||||
} );
|
||||
ASSET: foreach my $threadId (@$threadIds) {
|
||||
my $thread = WebGUI::Asset->newPending($session, $threadId);
|
||||
if (!$thread || !$thread->canEdit) {
|
||||
next ASSET;
|
||||
}
|
||||
$thread->unarchive;
|
||||
}
|
||||
return $pb->finish( $self->getUrl('func=edit') );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_unsubscribe ( )
|
||||
|
|
|
|||
|
|
@ -223,9 +223,11 @@ has '+uiLevel' => (
|
|||
use WebGUI::Pluggable;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Group;
|
||||
use WebGUI::AssetCollateral::DataForm::Entry;
|
||||
use WebGUI::Form::SelectRichEditor;
|
||||
use WebGUI::Paginator;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -413,13 +415,13 @@ sub deleteTab {
|
|||
=head2 getContentLastModified
|
||||
|
||||
Extends the base method to modify caching. If the currentView is in list mode, or
|
||||
an entry is being viewed, bypass caching altogether.
|
||||
an entry is being viewed, or the DataForm has a captcha, bypass caching altogether.
|
||||
|
||||
=cut
|
||||
|
||||
override getContentLastModified => sub {
|
||||
my $self = shift;
|
||||
if ($self->currentView eq 'list' || $self->session->form->process('entryId')) {
|
||||
if ($self->currentView eq 'list' || $self->session->form->process('entryId') || $self->hasCaptcha) {
|
||||
return time;
|
||||
}
|
||||
return super();
|
||||
|
|
@ -427,6 +429,19 @@ override getContentLastModified => sub {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hasCaptcha
|
||||
|
||||
Returns true if the DataForm uses a captcha as one of the fields.
|
||||
|
||||
=cut
|
||||
|
||||
sub hasCaptcha {
|
||||
my $self = shift;
|
||||
return isIn('Captcha', map { $_->{type} } map { $self->getFieldConfig($_) } @{ $self->getFieldOrder });
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 renameField ($oldName, $newName)
|
||||
|
||||
Renames a field by name
|
||||
|
|
@ -693,9 +708,10 @@ A hash reference. New template variables will be appended to it.
|
|||
=cut
|
||||
|
||||
sub getListTemplateVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_DataForm");
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = shift;
|
||||
my $i18n = WebGUI::International->new($session,"Asset_DataForm");
|
||||
$var->{"back.url"} = $self->getFormUrl;
|
||||
$var->{"back.label"} = $i18n->get('go to form');
|
||||
my $fieldConfig = $self->getFieldConfig;
|
||||
|
|
@ -709,7 +725,9 @@ sub getListTemplateVars {
|
|||
} @{ $self->getFieldOrder };
|
||||
$var->{field_loop} = \@fieldLoop;
|
||||
my @recordLoop;
|
||||
my $entryIter = $self->entryClass->iterateAll($self);
|
||||
my $p = WebGUI::Paginator->new($session);
|
||||
$p->setDataByCallback(sub { return $self->entryClass->iterateAll($self, { offset => $_[0], limit => $_[1], }); });
|
||||
my $entryIter = $p->getPageIterator();
|
||||
while ( my $entry = $entryIter->() ) {
|
||||
my $entryData = $entry->fields;
|
||||
my @dataLoop;
|
||||
|
|
@ -730,9 +748,9 @@ sub getListTemplateVars {
|
|||
%dataVars,
|
||||
"record.ipAddress" => $entry->ipAddress,
|
||||
"record.edit.url" => $self->getFormUrl("func=view;entryId=".$entry->getId),
|
||||
"record.edit.icon" => $self->session->icon->edit("func=view;entryId=".$entry->getId, $self->url),
|
||||
"record.edit.icon" => $session->icon->edit("func=view;entryId=".$entry->getId, $self->url),
|
||||
"record.delete.url" => $self->getUrl("func=deleteEntry;entryId=".$entry->getId),
|
||||
"record.delete.icon" => $self->session->icon->delete("func=deleteEntry;entryId=".$entry->getId, $self->url, $i18n->get('Delete entry confirmation')),
|
||||
"record.delete.icon" => $session->icon->delete("func=deleteEntry;entryId=".$entry->getId, $self->url, $i18n->get('Delete entry confirmation')),
|
||||
"record.username" => $entry->username,
|
||||
"record.userId" => $entry->userId,
|
||||
"record.submissionDate.epoch" => $entry->submissionDate->epoch,
|
||||
|
|
@ -742,6 +760,7 @@ sub getListTemplateVars {
|
|||
};
|
||||
}
|
||||
$var->{record_loop} = \@recordLoop;
|
||||
$p->appendTemplateVars($var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
|
@ -1258,6 +1277,9 @@ sub viewForm {
|
|||
$entry = $self->entryClass->new($self, ($entryId && $self->canEdit) ? $entryId : ());
|
||||
}
|
||||
$var = $passedVars || $self->getRecordTemplateVars($var, $entry);
|
||||
if ($self->hasCaptcha) {
|
||||
$self->session->http->setCacheControl('none');
|
||||
}
|
||||
return $self->processTemplate($var, undef, $self->{_viewFormTemplate});
|
||||
}
|
||||
|
||||
|
|
@ -1338,6 +1360,8 @@ sub www_deleteFieldConfirm {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $newSelf = $self->addRevision;
|
||||
$newSelf->deleteField($self->session->form->process("fieldName"));
|
||||
$newSelf->{_mode} = 'form';
|
||||
|
|
@ -1363,6 +1387,8 @@ sub www_deleteTabConfirm {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $newSelf = $self->addRevision;
|
||||
$newSelf->deleteTab($self->session->form->process("tabId"));
|
||||
$newSelf->{_mode} = 'form';
|
||||
|
|
@ -1385,6 +1411,8 @@ sub www_editField {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_DataForm");
|
||||
my $fieldName = shift || $self->session->form->process("fieldName");
|
||||
my $field;
|
||||
|
|
@ -1534,6 +1562,8 @@ sub www_editFieldSave {
|
|||
my $session = $self->session;
|
||||
return $session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $form = $session->form;
|
||||
my $fieldName = $form->process('fieldName');
|
||||
my $newName = $session->url->urlize($form->process('newName') || $form->process('label'));
|
||||
|
|
@ -1587,7 +1617,7 @@ sub www_editFieldSave {
|
|||
$newSelf->createField($newName, \%field);
|
||||
}
|
||||
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session);
|
||||
my $freshSelf = $newSelf->cloneFromDb();
|
||||
if ($form->process("proceed") eq "editField") {
|
||||
return $freshSelf->www_editField('new');
|
||||
|
|
@ -1677,6 +1707,8 @@ sub www_editTab {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_DataForm");
|
||||
my $tabId = shift || $self->session->form->process("tabId") || "new";
|
||||
my $tab;
|
||||
|
|
@ -1732,6 +1764,8 @@ sub www_editTabSave {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $name = $self->session->form->process("name") || $self->session->form->process("label");
|
||||
$name = $self->session->url->urlize($name);
|
||||
my $tabId = $self->session->form->process('tabId');
|
||||
|
|
@ -1825,6 +1859,8 @@ sub www_moveFieldDown {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $newSelf = $self->addRevision;
|
||||
my $fieldName = $self->session->form->process('fieldName');
|
||||
$newSelf->moveFieldDown($fieldName);
|
||||
|
|
@ -1883,6 +1919,8 @@ sub www_moveFieldUp {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $newSelf = $self->addRevision;
|
||||
my $fieldName = $self->session->form->process('fieldName');
|
||||
$newSelf->moveFieldUp($fieldName);
|
||||
|
|
@ -1942,6 +1980,8 @@ sub www_moveTabRight {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $newSelf = $self->addRevision;
|
||||
my $tabId = $self->session->form->process('tabId');
|
||||
$newSelf->moveTabRight($tabId);
|
||||
|
|
@ -1996,6 +2036,8 @@ sub www_moveTabLeft {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient
|
||||
unless $self->canEdit;
|
||||
return $self->session->privilege->locked
|
||||
unless $self->canEditIfLocked;
|
||||
my $newSelf = $self->addRevision;
|
||||
my $tabId = $self->session->form->process('tabId');
|
||||
$newSelf->moveTabLeft($tabId);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ sub getDataTemplateVars {
|
|||
my $self = shift;
|
||||
|
||||
my $json = $self->getDataJson;
|
||||
my $dt = JSON->new->decode($json);
|
||||
my $dt = eval { JSON->new->decode($json) };
|
||||
|
||||
# Make row data more friendly to templates
|
||||
my %cols = map { $_->{key} => $_ } @{ $dt->{columns} };
|
||||
|
|
@ -131,7 +131,8 @@ override getEditForm => sub {
|
|||
my $tabform = super();
|
||||
|
||||
$tabform->getTab("data")->raw(
|
||||
WebGUI::Form::DataTable->new(
|
||||
q{<tr><td>}
|
||||
. WebGUI::Form::DataTable->new(
|
||||
$self->session, {
|
||||
name => "data",
|
||||
value => $self->data,
|
||||
|
|
@ -139,6 +140,7 @@ override getEditForm => sub {
|
|||
showEdit => 1,
|
||||
}
|
||||
)->toHtml
|
||||
. q{</td></tr>}
|
||||
);
|
||||
|
||||
return $tabform;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package WebGUI::Asset::Wobject::EventManagementSystem;
|
||||
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
|
@ -83,6 +84,38 @@ property printTicketTemplateId => (
|
|||
hoverHelp => ['print ticket template help', 'Asset_EventManagementSystem'],
|
||||
namespace => 'EMS/PrintTicket',
|
||||
);
|
||||
property eventSubmissionMainTemplateId => (
|
||||
fieldType => 'template',
|
||||
default => 'DoVNijm6lMDE0cYrtvEbDQ',
|
||||
tab => 'display',
|
||||
label => ['event submission main template', 'Asset_EventManagementSystem'],
|
||||
hoverHelp => ['event submission main template help', 'Asset_EventManagementSystem'],
|
||||
namespace => 'EMS/SubmissionMain',
|
||||
);
|
||||
property eventSubmissionTemplateId => (
|
||||
fieldType => 'template',
|
||||
default => '8tqyQx-LwYUHIWOlKPjJrA',
|
||||
tab => 'display',
|
||||
label => ['event submission template', 'Asset_EventManagementSystem'],
|
||||
hoverHelp => ['event submission template help', 'Asset_EventManagementSystem'],
|
||||
namespace => 'EMS/Submission',
|
||||
);
|
||||
property eventSubmissionQueueTemplateId => (
|
||||
fieldType => 'template',
|
||||
default => 'ktSvKU8riGimhcsxXwqvPQ',
|
||||
tab => 'display',
|
||||
label => ['event submission queue template', 'Asset_EventManagementSystem'],
|
||||
hoverHelp => ['event submission queue template help', 'Asset_EventManagementSystem'],
|
||||
namespace => 'EMS/SubmissionQueue',
|
||||
);
|
||||
property printRemainingTicketsTemplateId => (
|
||||
fieldType => 'template',
|
||||
default => 'hreA_bgxiTX-EzWCSZCZJw',
|
||||
tab => 'display',
|
||||
label => ['print remaining ticket template', 'Asset_EventManagementSystem'],
|
||||
hoverHelp => ['print remaining ticket template help', 'Asset_EventManagementSystem'],
|
||||
namespace => 'EMS/PrintRemainingTickets',
|
||||
);
|
||||
property badgeInstructions => (
|
||||
fieldType => 'HTMLArea',
|
||||
builder => '_badgeInstructions_builder',
|
||||
|
|
@ -142,6 +175,18 @@ property registrationStaffGroupId => (
|
|||
label => ['registration staff group', 'Asset_EventManagementSystem'],
|
||||
hoverHelp => ['registration staff group help', 'Asset_EventManagementSystem'],
|
||||
);
|
||||
property submittedLocationsList => (
|
||||
fieldType => 'textarea',
|
||||
tab => 'properties',
|
||||
default => '',
|
||||
label => ['submitted location list label', 'Asset_EventManagementSystem'],
|
||||
hoverHelp => ['submitted location list help', 'Asset_EventManagementSystem'],
|
||||
);
|
||||
property eventSubmissionGroups => (
|
||||
fieldType => 'hidden',
|
||||
default => '',
|
||||
noFormPost => 1,
|
||||
);
|
||||
|
||||
|
||||
use Digest::MD5;
|
||||
|
|
@ -161,6 +206,89 @@ use WebGUI::Utility;
|
|||
use WebGUI::Workflow::Instance;
|
||||
use Data::Dumper;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addGroupToSubmitList ( groupId )
|
||||
|
||||
adds the parameter to eventSubmissionGroups
|
||||
|
||||
=cut
|
||||
|
||||
sub addGroupToSubmitList {
|
||||
my $self = shift;
|
||||
my $groupId = shift;
|
||||
my ($idString) = $self->session->db->read('select eventSubmissionGroups from EventManagementSystem where assetId = ?', [ $self->getId ] )->array;
|
||||
my @ids = split(' ', $idString);
|
||||
my %h;
|
||||
@ids = map { $h{$_}++ == 0 ? $_ : () } ( $groupId, @ids );
|
||||
$self->update({eventSubmissionGroups => join( ' ', @ids ) });
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addSubmissionForm
|
||||
|
||||
creates a child of class WG::Asset::EMSSubmissionForm
|
||||
|
||||
=head3 params
|
||||
|
||||
parameters that define the form
|
||||
|
||||
=head4 title
|
||||
|
||||
the title for the form
|
||||
|
||||
=head4 canSubmitGroupId ( optional )
|
||||
|
||||
group id for the users that are allowed to submit via this form
|
||||
defaults to 2 -- registered users
|
||||
|
||||
=head4 daysBeforeCleanup ( optional )
|
||||
|
||||
number fo days to leave denied/created status items in the database before deleting
|
||||
defaults to 7
|
||||
|
||||
=head4 deleteCreatedItems ( optional )
|
||||
|
||||
1 indicates that items with status 'created' should be deleted as well as denied
|
||||
default: 0
|
||||
|
||||
=head4 formDescription
|
||||
|
||||
a JSON description of the form data fields -- a hash of the names of fields (each is 1 for active, 0 for inactive) plus
|
||||
'_fieldList' added as an ARRAYREF of the fields that are active
|
||||
|
||||
=cut
|
||||
|
||||
sub addSubmissionForm {
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
$params->{className} = 'WebGUI::Asset::EMSSubmissionForm';
|
||||
$params->{canSubmitGroupId} ||= 2;
|
||||
$self->addGroupToSubmitList($params->{canSubmitGroupId});
|
||||
my $newAsset = $self->addChild($params);
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
|
||||
$self = $self->cloneFromDb;
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canSubmit
|
||||
|
||||
returns true is the current user can submit to any form attached to this EMS
|
||||
|
||||
=cut
|
||||
|
||||
sub canSubmit {
|
||||
my $self = shift;
|
||||
my $user = $self->session->user;
|
||||
return 0 if ! $self->hasSubmissionForms;
|
||||
for my $groupId (split ' ', $self->get('eventSubmissionGroups')) {
|
||||
return 1 if $user->isInGroup($groupId);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------
|
||||
|
||||
|
|
@ -178,6 +306,21 @@ sub deleteEventMetaField {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 ems
|
||||
|
||||
this is called by the submission sub-system
|
||||
it is for compatability and ensures that the ems
|
||||
object is used for certain calls
|
||||
|
||||
=cut
|
||||
|
||||
sub ems {
|
||||
my $self = shift;
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getBadges ()
|
||||
|
|
@ -276,6 +419,7 @@ sub getEventFieldsForImport {
|
|||
type => $field->{dataType},
|
||||
options => $field->{possibleValues},
|
||||
defaultValue => $field->{defaultValues},
|
||||
helpText => $field->{defaultValues},
|
||||
});
|
||||
}
|
||||
return \@fields;
|
||||
|
|
@ -292,33 +436,37 @@ may be SQL optimized for quick access
|
|||
|
||||
sub getLocations {
|
||||
my $self = shift;
|
||||
my $dateRef = shift || [ ];
|
||||
my $dateRef = shift;
|
||||
|
||||
my %hash;
|
||||
my %hashDate;
|
||||
my %h;
|
||||
my $tickets = $self->getTickets;
|
||||
for my $ticket ( @$tickets ) {
|
||||
my $name = $ticket->location;
|
||||
my $date = $ticket->startDate;
|
||||
$hash{$name} = 1 if defined $name;
|
||||
# cut off the time from the startDate.
|
||||
$date =~ s/\s*\d+:\d+(:\d+)?// if defined $date;
|
||||
$hashDate{$date} = 1 if defined $date;
|
||||
# this is a really compact 'uniq' operation
|
||||
my @locations = map { $h{$_}++ == 0 ? $_ : () } ( map { $_->location } ( @$tickets ) );
|
||||
# the dates have the time data removed with a pattern substitution
|
||||
if( $dateRef ) {
|
||||
push @$dateRef, map { s/\s*\d+:\d+(:\d+)?//; $h{$_}++ == 0 ? $_ : () } ( map { $_->startDate } ( @$tickets ) );
|
||||
}
|
||||
my @locations = sort keys %hash;
|
||||
push @$dateRef, sort keys %hashDate ;
|
||||
# @locations = $self->session->db->read(q{
|
||||
# select distinct(EMSTicket.location)
|
||||
# from EMSTicket join asset using (assetId)
|
||||
# where asset.parentId = ?
|
||||
# order by EMSTicket.location
|
||||
# },[$self->getId])->array;
|
||||
|
||||
return @locations;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNextSubmissionId
|
||||
|
||||
get a sequence number for the submission id
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextSubmissionId {
|
||||
my $self = shift;
|
||||
return $self->session->db->getNextId( 'SubmissionId' );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getRegistrant ( badgeId )
|
||||
|
||||
Returns a hash reference containing the properties of a registrant.
|
||||
|
|
@ -349,6 +497,80 @@ sub getRibbons {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSubmissionLocations
|
||||
|
||||
retuns an arrayref of the locations found in the submission location list
|
||||
|
||||
=cut
|
||||
|
||||
sub getSubmissionLocations {
|
||||
my $self = shift;
|
||||
my $text = $self->get('submittedLocationsList');
|
||||
return undef if $text eq '';
|
||||
return [ split( /[\n]+/, $text ) ];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSubmissionForms
|
||||
|
||||
returns a list of objects; one for each submission form related to this EMS
|
||||
|
||||
this function is called twice in just a few lines of code so the results are cached
|
||||
to prevent extra hits to the database
|
||||
|
||||
=cut
|
||||
|
||||
sub getSubmissionForms {
|
||||
my $self = shift;
|
||||
|
||||
return $self->{_submissionForms} if $self->{_submissionFormTime} > time;
|
||||
|
||||
$self->{_submissionForms} = $self->getLineage( ['children'], { returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
$self->{_submissionFormTime} = time + 60;
|
||||
|
||||
return $self->{_submissionForms};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSubmissionStatus
|
||||
|
||||
returns internationalized hash of submission status values or one internationalized name if a status is passed in
|
||||
|
||||
=cut
|
||||
|
||||
sub getSubmissionStatus {
|
||||
my $self = shift;
|
||||
my $key = shift;
|
||||
|
||||
unless ($self->{_status}) {
|
||||
tie my %hash, "Tie::IxHash";
|
||||
my $i18n = $self->i18n;
|
||||
for my $item (
|
||||
'pending',
|
||||
'feedback',
|
||||
'denied',
|
||||
'approved',
|
||||
'created',
|
||||
'failed',
|
||||
) {
|
||||
$hash{$item} = $i18n->get($item),
|
||||
}
|
||||
$self->{_status} = \%hash;
|
||||
}
|
||||
|
||||
if($key) {
|
||||
return $self->{_status}{$key};
|
||||
}
|
||||
|
||||
return $self->{_status};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getTickets ()
|
||||
|
||||
Returns an array reference of ticket objects.
|
||||
|
|
@ -384,6 +606,54 @@ sub getTokens {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hasSubmissionForms
|
||||
|
||||
returns true if the EMS has subission forms attached
|
||||
|
||||
=cut
|
||||
|
||||
sub hasSubmissionForms {
|
||||
my $self = shift;
|
||||
# are there ~any~ forms attached to this ems?
|
||||
my $res = $self->getLineage(['children'],{ limit => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
return scalar(@$res);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hasSubmissions
|
||||
|
||||
returns true if the current user has submission forms in this EMS
|
||||
|
||||
=cut
|
||||
|
||||
sub hasSubmissions {
|
||||
my $self = shift;
|
||||
return 0 if ! $self->canSubmit;
|
||||
my $res = $self->getLineage(['descendants'],{ limit => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
whereClause => q{createdBy='} . $self->session->user->userId . q/'/,
|
||||
} );
|
||||
return scalar(@$res);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 i18n
|
||||
|
||||
returns the internationalisation object for this asset
|
||||
|
||||
=cut
|
||||
|
||||
sub i18n {
|
||||
my $self = shift;
|
||||
return $self->{_i18n} ||= WebGUI::International->new($self->session,'Asset_EventManagementSystem');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isRegistrationStaff ( [ user ] )
|
||||
|
||||
Returns a boolean indicating whether the user is a member of the registration staff.
|
||||
|
|
@ -397,7 +667,7 @@ A WebGUI::User object. Defaults to $session->user.
|
|||
sub isRegistrationStaff {
|
||||
my $self = shift;
|
||||
my $user = shift || $self->session->user;
|
||||
$user->isInGroup($self->registrationStaffGroupId);
|
||||
$user->isInGroup($self->registrationStaffGroupId) || $self->canEdit;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -477,9 +747,18 @@ sub view {
|
|||
addBadgeUrl => $self->getUrl('func=add;class=WebGUI::Asset::Sku::EMSBadge'),
|
||||
buildBadgeUrl => $self->getUrl('func=buildBadge'),
|
||||
viewScheduleUrl => $self->getUrl('func=viewSchedule'),
|
||||
addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue'),
|
||||
# addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#addSubmission'),
|
||||
viewSubmissionQueueUrl => $self->getUrl('func=viewSubmissionQueue'),
|
||||
addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue'),
|
||||
# addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'),
|
||||
manageBadgeGroupsUrl=> $self->getUrl('func=manageBadgeGroups'),
|
||||
getBadgesUrl => $self->getUrl('func=getBadgesAsJson'),
|
||||
canEdit => $self->canEdit,
|
||||
isRegistrationStaff => $self->isRegistrationStaff,
|
||||
canEdit => $self->canEdit,
|
||||
canSubmit => $self->canSubmit && ! $self->isRegistrationStaff,
|
||||
hasSubmissions => $self->hasSubmissions,
|
||||
hasSubmissionForms => $self->hasSubmissionForms,
|
||||
lookupRegistrantUrl => $self->getUrl('func=lookupRegistrant'),
|
||||
);
|
||||
|
||||
|
|
@ -510,6 +789,76 @@ sub www_addRibbonToBadge {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_addSubmission ()
|
||||
|
||||
display a form or links to forms to create a new submission
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addSubmission {
|
||||
my $self = shift;
|
||||
my $params = shift || {};
|
||||
my $session = $self->session;
|
||||
my $formId = $params->{formId} || $session->form->get('formId');
|
||||
my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem');
|
||||
my $form;
|
||||
|
||||
if( ! defined $formId ) {
|
||||
my $res = $self->getSubmissionForms;
|
||||
my @new = map { $_->canSubmit ? $_ : () } ( @$res);
|
||||
if( scalar(@new) == 0 ) {
|
||||
return $self->www_view;
|
||||
} elsif( scalar(@new) == 1 ) {
|
||||
$form = $new[0];
|
||||
$formId = $form->getId;
|
||||
} else {
|
||||
my $makeAnchorList =sub{ my $u=shift; my $n=shift; my $d=shift;
|
||||
return qq{<li><a href='$u' onclick='WebGUI.EMS.loadItemFromAnchor(this)' title='$d'>$n</a></li>} } ;
|
||||
my $listOfLinks = join '', ( map {
|
||||
$makeAnchorList->(
|
||||
$self->getUrl('func=viewSubmissionQueue#' . $_->getId . '_new' ), # _new has to match same in sub www_viewSubmissionQueue in this module
|
||||
$_->get('title'),
|
||||
WebGUI::HTML::filter($_->get('description'),'all')
|
||||
)
|
||||
} ( @new ) );
|
||||
my $title = $i18n->get('select form to submit') ;
|
||||
my $asJson = $session->form->get('asJson');
|
||||
if( $asJson ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
}
|
||||
my $content = '<h1>' . $title . '</h1><ul>' . $listOfLinks . '</ul>' ;
|
||||
if( $asJson ) {
|
||||
return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } );
|
||||
} else {
|
||||
return $self->ProcessStyle( $content );
|
||||
}
|
||||
}
|
||||
}
|
||||
$form = WebGUI::Asset->newByDynamicClass($session,$formId);
|
||||
if (!defined $form) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $formId");
|
||||
}
|
||||
return $form->www_addSubmission;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_addSubmissionForm ()
|
||||
|
||||
call www_editSubmissionForm with assetId == new
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addSubmissionForm {
|
||||
my $self = shift;
|
||||
my $params = shift || { };
|
||||
$self->www_editSubmissionForm( { assetId => 'new', %$params } );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_addTicketsToBadge ()
|
||||
|
||||
Adds selected tickets to a badge. Expects two form parameters, assetId (multiples fine) and badgeId, where assetId represents the ticket and badgeId represents the badge.
|
||||
|
|
@ -572,6 +921,7 @@ sub www_buildBadge {
|
|||
importTicketsUrl => $self->getUrl('func=importEvents'),
|
||||
exportTicketsUrl => $self->getUrl('func=exportEvents'),
|
||||
getTicketsUrl => $self->getUrl('func=getTicketsAsJson;badgeId='.$badgeId),
|
||||
printRemainingTicketsUrl => $self->getUrl('func=printRemainingTickets'),
|
||||
canEdit => $self->canEdit,
|
||||
hasBadge => ($badgeId ne ""),
|
||||
badgeId => $badgeId,
|
||||
|
|
@ -686,6 +1036,62 @@ sub www_editBadgeGroupSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmission
|
||||
|
||||
use getLineage to find the item to edit based on submissionId
|
||||
then call www_editSubmission on it
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmission {
|
||||
my $self = shift;
|
||||
my $submissionId = $self->session->form->get('submissionId');
|
||||
my $asset = $self->getLineage(['descendants'], { returnObjects => 1,
|
||||
joinClass => "WebGUI::Asset::EMSSubmission",
|
||||
whereClause => 'submissionId = ' . int($submissionId),
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
} );
|
||||
return $asset->[0]->www_editSubmission;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmissionForm
|
||||
|
||||
calls editSubmissionForm in WebGUI::Asset::EMSSubmissionForm
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmissionForm {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->isRegistrationStaff || $self->canEdit;
|
||||
return WebGUI::Asset::EMSSubmissionForm->www_editSubmissionForm($self,shift);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSubmissionFormSave
|
||||
|
||||
test and save data posted from editSubmissionForm...
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSubmissionFormSave {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->isRegistrationStaff || $self->canEdit;
|
||||
my $formParams = WebGUI::Asset::EMSSubmissionForm->processForm($self);
|
||||
if( $formParams->{_isValid} ) {
|
||||
delete $formParams->{_isValid};
|
||||
$self->addSubmissionForm($formParams);
|
||||
return $self->www_viewSubmissionQueue;
|
||||
} else {
|
||||
return $self->www_editSubmissionForm($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editEventMetaField ( )
|
||||
|
||||
Displays the edit form for event meta fields.
|
||||
|
|
@ -712,6 +1118,7 @@ sub www_editEventMetaField {
|
|||
required => $self->session->form->process("required",'yesNo'),
|
||||
possibleValues => $self->session->form->process("possibleValues",'textarea'),
|
||||
defaultValues => $self->session->form->process("defaultValues",'textarea'),
|
||||
helpText => $self->session->form->process("helpText",'textarea'),
|
||||
};
|
||||
$f->readOnly(
|
||||
-name => 'error',
|
||||
|
|
@ -768,6 +1175,12 @@ sub www_editEventMetaField {
|
|||
-hoverHelp => $i18n->get('488 description'),
|
||||
-value => $data->{defaultValues},
|
||||
);
|
||||
$f->textarea(
|
||||
-name => "helpText",
|
||||
-label => $i18n2->get('meta field help text'),
|
||||
-hoverHelp => $i18n2->get('meta field help text description'),
|
||||
-value => $data->{helpText},
|
||||
);
|
||||
$f->submit;
|
||||
return $self->processStyle($f->print);
|
||||
}
|
||||
|
|
@ -800,6 +1213,7 @@ sub www_editEventMetaFieldSave {
|
|||
required => $self->session->form->process("required",'yesNo'),
|
||||
possibleValues => $self->session->form->process("possibleValues",'textarea'),
|
||||
defaultValues => $self->session->form->process("defaultValues",'textarea'),
|
||||
helpText => $self->session->form->process("helpText",'textarea'),
|
||||
},1,1);
|
||||
return $self->www_manageEventMetaFields();
|
||||
}
|
||||
|
|
@ -884,6 +1298,90 @@ sub www_exportEvents {
|
|||
return "chunked";
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_getAllSubmissions ( )
|
||||
|
||||
Get a page of Asset Manager data, ajax style. Returns a JSON array to be
|
||||
formatted in a WebGUI submission queue data table.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_getAllSubmissions {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $datetime = $session->datetime;
|
||||
my $form = $session->form;
|
||||
my $tableInfo = {};
|
||||
|
||||
return $session->privilege->insufficient unless $self->canSubmit || $self->isRegistrationStaff;
|
||||
|
||||
my $orderByColumn = $form->get( 'orderByColumn' ) || $self->get("sortColumn");
|
||||
my $dir = $form->get('orderByDirection') || $self->get('sortOrder');
|
||||
my $orderByDirection = lc ($dir) eq "asc" ? "ASC" : "DESC";
|
||||
|
||||
my $whereClause ;
|
||||
if(!$self->isRegistrationStaff) {
|
||||
my $userId = $session->user->userId;
|
||||
$whereClause .= qq{ createdBy='$userId'};
|
||||
}
|
||||
|
||||
my $rules;
|
||||
$rules->{'joinClass' } = "WebGUI::Asset::EMSSubmission";
|
||||
$rules->{'whereClause' } = $whereClause;
|
||||
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::EMSSubmission'];
|
||||
$rules->{'orderByClause' } = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection if $orderByColumn;
|
||||
|
||||
my $sql = "";
|
||||
|
||||
$sql = $self->getLineageSql(['descendants'], $rules);
|
||||
|
||||
my $startIndex = $form->get( 'startIndex' ) || 1;
|
||||
my $rowsPerPage = $form->get( 'rowsPerPage' ) || 25;
|
||||
my $currentPage = int ( $startIndex / $rowsPerPage ) + 1;
|
||||
|
||||
my $p = WebGUI::Paginator->new( $session, '', $rowsPerPage, 'pn', $currentPage );
|
||||
$p->setDataByQuery($sql);
|
||||
|
||||
$tableInfo->{'recordsReturned'} = $rowsPerPage;
|
||||
$tableInfo->{'totalRecords' } = $p->getRowCount;
|
||||
$tableInfo->{'startIndex' } = $startIndex;
|
||||
$tableInfo->{'sort' } = $orderByColumn;
|
||||
$tableInfo->{'dir' } = $orderByDirection;
|
||||
$tableInfo->{'records' } = [];
|
||||
|
||||
for my $record ( @{ $p->getPageData } ) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $record->{assetId} );
|
||||
|
||||
my $lastReplyBy = $asset->get("lastReplyBy");
|
||||
if ($lastReplyBy) {
|
||||
$lastReplyBy = WebGUI::User->new($session,$lastReplyBy)->username;
|
||||
}
|
||||
|
||||
# Populate the required fields to fill in
|
||||
my $lastReplyDate = $asset->get("lastReplyDate");
|
||||
if($lastReplyDate) {
|
||||
$lastReplyDate = $datetime->epochToHuman($lastReplyDate,"%y-%m-%d @ %H:%n %p");
|
||||
}
|
||||
|
||||
my %fields = (
|
||||
submissionId => $asset->get("submissionId"),
|
||||
url => $asset->getQueueUrl,
|
||||
title => $asset->get( "title" ),
|
||||
createdBy => WebGUI::User->new($session,$asset->get( "createdBy" ))->username,
|
||||
creationDate => $datetime->epochToSet($asset->get( "creationDate" )),
|
||||
submissionStatus => $self->getSubmissionStatus($asset->get( "submissionStatus" ) || 'pending' ),
|
||||
lastReplyDate => $lastReplyDate || '',
|
||||
lastReplyBy => $lastReplyBy || '',
|
||||
);
|
||||
|
||||
push @{ $tableInfo->{ records } }, \%fields;
|
||||
}
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
return JSON->new->encode( $tableInfo );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_getBadgesAsJson ()
|
||||
|
|
@ -922,6 +1420,36 @@ sub www_getBadgesAsJson {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_getSubmissionById
|
||||
|
||||
returns a JSON dataset with info about the requested submission
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub www_getSubmissionById {
|
||||
my $self = shift;
|
||||
my $submissionId = $self->session->form->get('submissionId');
|
||||
my $result;
|
||||
my $res = $self->getLineage(['descendants'],{ limit => 1, returnObjects=>1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
joinClass => "WebGUI::Asset::EMSSubmission",
|
||||
whereClause => q{submissionId='} . $submissionId . q/'/,
|
||||
} );
|
||||
if( scalar(@$res) == 0 ) {
|
||||
$result->{hasError} = 1;
|
||||
$result->{errors} = [ 'failed to load submission' ];
|
||||
} else {
|
||||
$result->{text} = $res->[0]->www_editSubmission;
|
||||
$result->{title} = $submissionId;
|
||||
$result->{id} = $submissionId;
|
||||
}
|
||||
$self->session->http->setMimeType('application/json');
|
||||
return JSON->new->encode($result);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_getRegistrantAsJson ( )
|
||||
|
||||
Retrieves the properties of a specific badge and the items attached to it. Expects badgeId to be one of the form params.
|
||||
|
|
@ -1206,7 +1734,7 @@ sub www_getScheduleDataJSON {
|
|||
and ( assetData.status = 'approved'
|
||||
or assetData.tagId = ? )
|
||||
)
|
||||
order by EMSTicket.startDate
|
||||
order by EMSTicket.startDate, eventNumber asc
|
||||
},[ $self->getId, $currentDate,
|
||||
$session->scratch->get("versionTag")
|
||||
]);
|
||||
|
|
@ -1214,8 +1742,10 @@ sub www_getScheduleDataJSON {
|
|||
tie %hash, 'Tie::IxHash';
|
||||
while( my $row = $tickets->hashRef ) {
|
||||
$row->{type} = 'ticket';
|
||||
$hash{$row->{startDate}}{$row->{location}} = $row;
|
||||
$row->{location} = ' ' if $row->{location} eq '';
|
||||
push @{$hash{$row->{startDate}}{$row->{location}}}, $row;
|
||||
}
|
||||
grep { $_ = ' ' if defined $_ && $_ eq '' } @ticketLocations;
|
||||
my %results = ();
|
||||
$results{records} = []; ##Initialize to an empty array
|
||||
my $ctr = 0;
|
||||
|
|
@ -1223,20 +1753,25 @@ sub www_getScheduleDataJSON {
|
|||
# fill out the columns in the table
|
||||
while( $ctr < $locationsPerPage ) { $locationMap{ 'col' . ++$ctr } = '' };
|
||||
push @{$results{records}}, { colDate => '' , map { $_ , { type => 'label', title => $locationMap{$_} || '' } } ( keys %locationMap ) };
|
||||
my $redo = 0;
|
||||
for my $startDate ( keys %hash ) {
|
||||
$redo = 0;
|
||||
my $row = { colDate => $startDate };
|
||||
my $empty = 1;
|
||||
for my $col ( keys %locationMap ) {
|
||||
my $location = $locationMap{$col};
|
||||
if( exists $hash{$startDate}{$location} ) {
|
||||
$row->{$col} = $hash{$startDate}{$location};
|
||||
$row->{$col} = pop @{$hash{$startDate}{$location}};
|
||||
$empty = 0;
|
||||
$redo = 1 if scalar(@{$hash{$startDate}{$location}}) > 0;
|
||||
delete $hash{$startDate}{$location} if scalar(@{$hash{$startDate}{$location}}) == 0;
|
||||
} else {
|
||||
$row->{$col} = { type => 'empty' };
|
||||
}
|
||||
}
|
||||
next if $empty;
|
||||
push @{$results{records}}, $row;
|
||||
redo if $redo;
|
||||
}
|
||||
|
||||
my $rowCount = scalar(@{$results{records}});
|
||||
|
|
@ -1257,8 +1792,6 @@ sub www_getScheduleDataJSON {
|
|||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_getTicketsAsJson ()
|
||||
|
|
@ -1969,6 +2502,75 @@ sub www_printBadge {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_printRemainingTickets ()
|
||||
|
||||
Displays all of the remaining tickets for this EMS
|
||||
|
||||
=cut
|
||||
|
||||
sub www_printRemainingTickets {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless ($self->isRegistrationStaff);
|
||||
|
||||
my $var = $self->get;
|
||||
my $sth = $session->db->read(qq{
|
||||
SELECT
|
||||
asset.creationDate,
|
||||
assetData.*,
|
||||
assetData.title as ticketTitle,
|
||||
EMSTicket.price,
|
||||
EMSTicket.seatsAvailable,
|
||||
EMSTicket.startDate as ticketStart,
|
||||
EMSTicket.duration as ticketDuration,
|
||||
EMSTicket.eventNumber as ticketEventNumber,
|
||||
EMSTicket.location as ticketLocation,
|
||||
EMSTicket.relatedBadgeGroups,
|
||||
EMSTicket.relatedRibbons,
|
||||
EMSTicket.eventMetaData,
|
||||
(seatsAvailable - (select count(*) from EMSRegistrantTicket where ticketAssetId = asset.assetId)) as seatsRemaining
|
||||
FROM
|
||||
asset
|
||||
join assetData using (assetId)
|
||||
left join EMSTicket using (assetId)
|
||||
WHERE
|
||||
parentId=?
|
||||
and className='WebGUI::Asset::Sku::EMSTicket'
|
||||
and state='published'
|
||||
and EMSTicket.revisionDate=(select max(revisionDate) from EMSTicket where assetId=asset.assetId)
|
||||
and (seatsAvailable - (select count(*) from EMSRegistrantTicket where ticketAssetId = asset.assetId)) > 0
|
||||
GROUP BY
|
||||
asset.assetId
|
||||
ORDER BY
|
||||
title desc
|
||||
},[$self->getId]);
|
||||
|
||||
$var->{'tickets_loop'} = [];
|
||||
while (my $hash = $sth->hashRef) {
|
||||
my $seatsRemaining = $hash->{seatsRemaining};
|
||||
#Put start time in the correct timezone
|
||||
my $startTime = WebGUI::DateTime->new($hash->{ticketStart})->set_time_zone($self->get('timezone'));
|
||||
$hash->{ticketStart} = $startTime->strftime('%F %R');
|
||||
$hash->{ticketStart_epoch} = $startTime->epoch;
|
||||
#Add meta data fields
|
||||
my $data = $hash->{eventMetaData} || '{}';
|
||||
my $meta = JSON->new->decode($data);
|
||||
foreach my $key (keys %{$meta}) {
|
||||
my $tmplKey = $key;
|
||||
$tmplKey =~ s/[\s\W]/_/g;
|
||||
$hash->{'ticketMeta_'.$tmplKey} = $meta->{$key};
|
||||
}
|
||||
#Add to the loop
|
||||
for (my $i = 0; $i < $seatsRemaining; $i++ ) {
|
||||
push(@{$var->{'tickets_loop'}},$hash);
|
||||
}
|
||||
}
|
||||
|
||||
return $self->processTemplate($var,$self->get('printRemainingTicketsTemplateId'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_printTicket ( )
|
||||
|
||||
Prints a ticket using a template.
|
||||
|
|
@ -2049,7 +2651,7 @@ Toggles the registrant checked in flag.
|
|||
|
||||
sub www_toggleRegistrantCheckedIn {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insfufficient() unless ($self->isRegistrationStaff);
|
||||
return $self->session->privilege->insufficient() unless ($self->isRegistrationStaff);
|
||||
my $db = $self->session->db;
|
||||
my $badgeId = $self->session->form->param('badgeId');
|
||||
my $flag = $db->quickScalar("select hasCheckedIn from EMSRegistrant where badgeId=?",[$badgeId]);
|
||||
|
|
@ -2058,7 +2660,6 @@ sub www_toggleRegistrantCheckedIn {
|
|||
return $self->www_manageRegistrant;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewSchedule ()
|
||||
|
|
@ -2070,7 +2671,6 @@ View the schedule table.
|
|||
sub www_viewSchedule {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canView;
|
||||
my $db = $self->session->db;
|
||||
my $rowsPerPage = 25;
|
||||
my $locationsPerPage = $self->scheduleColumnsPerPage;
|
||||
|
||||
|
|
@ -2091,5 +2691,80 @@ sub www_viewSchedule {
|
|||
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
|
||||
=head2 www_viewSubmissionQueue
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewSubmissionQueue {
|
||||
my $self = shift;
|
||||
my $isRegistrationStaff = $self->isRegistrationStaff;
|
||||
my $canSubmit = $self->canSubmit && ! $isRegistrationStaff;
|
||||
my $canEdit = $self->canEdit;
|
||||
my $i18n = $self->i18n;
|
||||
return $self->session->privilege->insufficient() unless $canSubmit || $isRegistrationStaff;
|
||||
|
||||
# this map returns an array of hash refs with an id,url pair to describe the submissionForm assets
|
||||
my @submissionFormUrls = map { { # edit form
|
||||
id => $_->getId,
|
||||
edit => 1,
|
||||
title => $_->get('title'),
|
||||
linkUrl => $self->getUrl('func=viewSubmissionQueue#' . $_->getId ),
|
||||
ajaxUrl => $_->getUrl('func=editSubmissionForm'),
|
||||
},{ # new submission ( _new has to match same in sub www_addSubmission in this module
|
||||
id => $_->getId . '_new',
|
||||
title => $_->get('title') . ' - ' . $i18n->get('add submission'),
|
||||
linkUrl => $self->getUrl('func=viewSubmissionQueue#' . $_->getId . '_new' ),
|
||||
ajaxUrl => $_->getUrl('func=addSubmission'),
|
||||
} } (
|
||||
@{$self->getSubmissionForms}
|
||||
);
|
||||
my $params = {
|
||||
backUrl => $self->getUrl,
|
||||
isRegistrationStaff => $isRegistrationStaff,
|
||||
canEdit => $canEdit,
|
||||
canSubmit => $canSubmit,
|
||||
hasSubmissionForms => $self->hasSubmissionForms,
|
||||
getSubmissionQueueDataUrl => $self->getUrl('func=getAllSubmissions'),
|
||||
editSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#editSubmission'),
|
||||
editSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#editSubmissionForm'),
|
||||
addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'),
|
||||
addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#addSubmission'),
|
||||
editSubmissionAjaxUrl => $self->getUrl('func=editSubmission'),
|
||||
editSubmissionFormAjaxUrl => $self->getUrl('func=editSubmissionForm'),
|
||||
addSubmissionFormAjaxUrl => $self->getUrl('func=addSubmissionForm'),
|
||||
addSubmissionAjaxUrl => $self->getUrl('func=addSubmission'),
|
||||
submissionFormUrls => \@submissionFormUrls,
|
||||
};
|
||||
push( @{$params->{tabs}}, {
|
||||
title => $isRegistrationStaff ? $i18n->get('submission queue') : $i18n->get('my submissions'),
|
||||
text => $self->processTemplate($params,$self->get('eventSubmissionQueueTemplateId')),
|
||||
} );
|
||||
if( $isRegistrationStaff ) {
|
||||
for my $tabSource ( @{$self->getSubmissionForms} ) {
|
||||
push @{$params->{tabs}}, $tabSource->www_editSubmissionForm( { asHashRef => 1 } );
|
||||
}
|
||||
push @{$params->{tabs}}, $self->www_addSubmissionForm( { asHashRef => 1 } );
|
||||
if( scalar( @{$params->{tabs}} ) == 2 ) { # there were no existing forms
|
||||
$params->{tabs}[1]{selected} = 1; # the new submission form tab
|
||||
} else {
|
||||
$params->{tabs}[0]{selected} = 1; # the submission queue tab
|
||||
}
|
||||
}
|
||||
elsif( $canSubmit ) {
|
||||
for my $tabSource ( @{$self->getSubmissionForms} ) {
|
||||
next unless $tabSource->canSubmit;
|
||||
push @{$params->{tabs}}, $tabSource->www_addSubmission( { asHashRef => 1 } );
|
||||
}
|
||||
$params->{tabs}[0]{selected} = 1;
|
||||
}
|
||||
my $tabid = 'tab01';
|
||||
for my $tab ( @{$params->{tabs}} ) { $tab->{id} = $tabid ++; }
|
||||
|
||||
return $self->processStyle(
|
||||
$self->processTemplate( $params, $self->get('eventSubmissionMainTemplateId')));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -758,11 +758,12 @@ sub getRssFeedItems {
|
|||
perpage => $self->itemsPerFeed,
|
||||
} );
|
||||
|
||||
my $var = [];
|
||||
my $var = [];
|
||||
my $siteUrl = $self->session->url->getSiteURL();
|
||||
for my $assetId ( @{ $p->getPageData } ) {
|
||||
my $asset = WebGUI::Asset::Wobject::GalleryAlbum->newPending( $self->session, $assetId );
|
||||
push @{ $var }, {
|
||||
'link' => $asset->getUrl,
|
||||
'link' => $siteUrl . $asset->getUrl,
|
||||
'guid' => $asset->{_properties}->{ 'assetId' },
|
||||
'title' => $asset->getTitle,
|
||||
'description' => $asset->{_properties}->{ 'description' },
|
||||
|
|
|
|||
|
|
@ -47,8 +47,10 @@ use Carp qw( croak );
|
|||
use File::Find;
|
||||
use File::Spec;
|
||||
use File::Temp qw{ tempdir };
|
||||
use JSON ();
|
||||
use WebGUI::International;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::ProgressBar;
|
||||
|
||||
use Archive::Any;
|
||||
|
||||
|
|
@ -61,10 +63,11 @@ use Archive::Any;
|
|||
=head1 DIAGNOSTICS
|
||||
|
||||
=head1 METHODS
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 addArchive ( filename, properties )
|
||||
=head2 addArchive ( filename, properties, [$outputSub] )
|
||||
|
||||
Add an archive of Files to this Album. C<filename> is the full path of the
|
||||
archive. C<properties> is a hash reference of properties to assign to the
|
||||
|
|
@ -75,13 +78,29 @@ a directory outside of the storage location.
|
|||
|
||||
Will only handle file types handled by the parent Gallery.
|
||||
|
||||
=head3 filename
|
||||
|
||||
The name of the file archive to import.
|
||||
|
||||
=head3 properties
|
||||
|
||||
A base set of properties to add to each file in the archive.
|
||||
|
||||
=head3 $outputSub
|
||||
|
||||
A callback to use for outputting data, most likely to a progress bar. It expects the
|
||||
callback to accept an i18n key for use in sprintf, and then any extra fields to stuff
|
||||
into the translated key.
|
||||
|
||||
=cut
|
||||
|
||||
sub addArchive {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $properties = shift;
|
||||
my $outputSub = shift || sub {};
|
||||
my $gallery = $self->getParent;
|
||||
my $session = $self->session;
|
||||
|
||||
my $archive = Archive::Any->new( $filename );
|
||||
|
||||
|
|
@ -89,11 +108,12 @@ sub addArchive {
|
|||
if $archive->is_naughty;
|
||||
|
||||
my $tempdirName = tempdir( "WebGUI-Gallery-XXXXXXXX", TMPDIR => 1, CLEANUP => 1);
|
||||
$outputSub->('Extracting archive');
|
||||
$archive->extract( $tempdirName );
|
||||
|
||||
# Get all the files in the archive
|
||||
my @files;
|
||||
my $wanted = sub { push @files, $File::Find::name };
|
||||
my $wanted = sub { push @files, $File::Find::name; $outputSub->('Found file: %s', $File::Find::name); };
|
||||
find( {
|
||||
wanted => $wanted,
|
||||
}, $tempdirName );
|
||||
|
|
@ -106,23 +126,26 @@ sub addArchive {
|
|||
my $class = $gallery->getAssetClassForFile( $filePath );
|
||||
next unless $class; # class is undef for those files the Gallery can't handle
|
||||
|
||||
$self->session->errorHandler->info( "Adding $filename to album!" );
|
||||
# Remove the file extention
|
||||
$session->errorHandler->info( "Adding $filename to album!" );
|
||||
$outputSub->('Adding %s to album', $filename);
|
||||
# Remove the file extension
|
||||
$filename =~ s{\.[^.]+}{};
|
||||
|
||||
$properties->{ className } = $class;
|
||||
$properties->{ menuTitle } = $filename;
|
||||
$properties->{ title } = $filename;
|
||||
$properties->{ url } = $self->session->url->urlize( $self->getUrl . "/" . $filename );
|
||||
$properties->{ ownerUserId } = $session->user->userId;
|
||||
$properties->{ url } = $session->url->urlize( $self->getUrl . "/" . $filename );
|
||||
|
||||
my $asset = $self->addChild( $properties, undef, undef, { skipAutoCommitWorkflows => 1 } );
|
||||
$asset->setFile( $filePath );
|
||||
}
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking( $self->session );
|
||||
my $versionTag = WebGUI::VersionTag->getWorking( $session );
|
||||
$versionTag->set({
|
||||
"workflowId" => $self->getParent->workflowIdCommit,
|
||||
});
|
||||
$outputSub->('Requesting commit for version tag');
|
||||
$versionTag->requestCommit;
|
||||
|
||||
return undef;
|
||||
|
|
@ -236,16 +259,12 @@ sub canEdit {
|
|||
my $form = $self->session->form;
|
||||
|
||||
# Handle adding a photo
|
||||
if ( $form->get("func") eq "add" ) {
|
||||
return $self->canAddFile;
|
||||
}
|
||||
elsif ( $form->get("func") eq "editSave" && $form->get("className") eq __PACKAGE__ ) {
|
||||
if ( $form->get("func") eq "add" || $form->get("func") eq "editSave" ) {
|
||||
return $self->canAddFile;
|
||||
}
|
||||
else {
|
||||
return 1 if $userId eq $self->ownerUserId;
|
||||
|
||||
return $gallery->canEdit($userId);
|
||||
return $gallery && $gallery->canEdit($userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -394,6 +413,58 @@ sub getFileIds {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getNextFileId ( fileId )
|
||||
|
||||
Gets the next fileId from the list of fileIds. C<fileId> is the base
|
||||
fileId we want to find the next file for.
|
||||
|
||||
Returns C<undef> if there is no next fileId.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextFileId {
|
||||
my $self = shift;
|
||||
my $fileId = shift;
|
||||
my $allFileIds = $self->getFileIds;
|
||||
|
||||
while ( my $checkId = shift @{ $allFileIds } ) {
|
||||
# If this is the last albumId
|
||||
return undef unless @{ $allFileIds };
|
||||
|
||||
if ( $fileId eq $checkId ) {
|
||||
return shift @{ $allFileIds };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getPreviousFileId ( fileId )
|
||||
|
||||
Gets the previous fileId from the list of fileIds. C<fileId> is the base
|
||||
fileId we want to find the previous file for.
|
||||
|
||||
Returns C<undef> if there is no previous fileId.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPreviousFileId {
|
||||
my $self = shift;
|
||||
my $fileId = shift;
|
||||
my $allFileIds = $self->getFileIds;
|
||||
|
||||
while ( my $checkId = pop @{ $allFileIds } ) {
|
||||
# If this is the last albumId
|
||||
return undef unless @{ $allFileIds };
|
||||
|
||||
if ( $fileId eq $checkId ) {
|
||||
return pop @{ $allFileIds };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getFilePaginator ( paginatorUrl )
|
||||
|
||||
Gets a WebGUI::Paginator for the files in this album. C<paginatorUrl> is the
|
||||
|
|
@ -854,7 +925,7 @@ sub www_addArchive {
|
|||
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
|
||||
$var->{ error } = $params->{ error };
|
||||
$var->{ error } = $params->{ error } || $form->get('error');
|
||||
|
||||
$var->{ form_start }
|
||||
= WebGUI::Form::formHeader( $session, {
|
||||
|
|
@ -909,32 +980,27 @@ sub www_addArchiveSave {
|
|||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $i18n = WebGUI::International->new( $session, 'Asset_GalleryAlbum' );
|
||||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
my $properties = {
|
||||
keywords => $form->get("keywords"),
|
||||
friendsOnly => $form->get("friendsOnly"),
|
||||
};
|
||||
|
||||
$pb->start($i18n->get('Uploading archive'), $session->url->extras('adminConsole/assets.gif'));
|
||||
my $storageId = $form->get("archive", "File");
|
||||
my $storage = WebGUI::Storage->get( $session, $storageId );
|
||||
if (!$storage) {
|
||||
return $self->www_addArchive({
|
||||
error => sprintf $i18n->get('addArchive error too big'),
|
||||
});
|
||||
return $pb->finish($self->getUrl('func=addArchive;error='.$i18n->get('addArchive error too big')));
|
||||
}
|
||||
my $filename = $storage->getPath( $storage->getFiles->[0] );
|
||||
|
||||
eval { $self->addArchive( $filename, $properties ) };
|
||||
eval { $self->addArchive( $filename, $properties, sub{ $pb->update(sprintf $i18n->get(shift), @_); }); };
|
||||
$storage->delete;
|
||||
if ( my $error = $@ ) {
|
||||
return $self->www_addArchive({
|
||||
error => sprintf( $i18n->get('addArchive error generic'), $error ),
|
||||
});
|
||||
return $pb->finish($self->getUrl('func=addArchive;error='.sprintf $i18n->get('addArchive error generic'), $error ));
|
||||
}
|
||||
|
||||
$storage->delete;
|
||||
|
||||
return $self->processStyle(
|
||||
sprintf $i18n->get('addArchive message'), $self->getUrl,
|
||||
);
|
||||
return $pb->finish($self->getUrl);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -1076,6 +1142,172 @@ sub www_deleteConfirm {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_ajax ( )
|
||||
|
||||
Generic AJAX service for gallery.
|
||||
|
||||
Arguments are accepted in JSON format in the form variable C<args>. The single
|
||||
obligatory argument is C<action> determining the service to be called. A list
|
||||
of available services is given in the following. Additional arguments may be
|
||||
required depending on the service.
|
||||
|
||||
Results are returned in JSON format. The information returned depends on the
|
||||
service called. Generally, success is indicated by a value of 0 in C<err>.
|
||||
|
||||
=head3 moveFile
|
||||
|
||||
Service for changing the rank of files. Accepts the asset Id of the photo to be moved
|
||||
in C<target>. The asset Id of the photo to be replaced is specified in C<before>
|
||||
or C<after> depending on the desired order. Returns -1 in C<err> and an error
|
||||
message in C<errMessage> if moving of the photo failed.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_ajax {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $result;
|
||||
|
||||
# Get arguments encoded in json format
|
||||
my $args = decode_json($form->get("args"));
|
||||
|
||||
# Log some debug information
|
||||
$session->log->debug("Ajax service called with args=" . $form->get("args"));
|
||||
|
||||
# Process requests depending on action argument
|
||||
SWITCH: {
|
||||
|
||||
# Return if no action was specified
|
||||
if ( $args->{action} eq '' ) {
|
||||
$session->log->error("Call of ajax service without action argument.");
|
||||
$result->{ errMessage } = "Action argument is missing.";
|
||||
last;
|
||||
}
|
||||
|
||||
# ----- Move file action -----
|
||||
$args->{action} eq 'moveFile' && do { $result = $self->_moveFileAjaxRequest( $args ); last; };
|
||||
|
||||
# ----- Unkown action -----
|
||||
$session->log->error("Call of ajax service with unknown action '" . $args->{action} . "'.");
|
||||
$result->{ errMessage } = "Action '" . $args->{action} ."' is unknown.";
|
||||
}
|
||||
|
||||
# Set error flag if error message exists
|
||||
$result->{ err } = -1 if $result->{ errMessage };
|
||||
|
||||
# Return results encoded in json format
|
||||
return encode_json( $result );
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 _moveFileAjaxRequest ( args )
|
||||
|
||||
AJAX service for changing the rank of single files. Returns a hash ref with
|
||||
error information. Arguments passed to the ajax service are provided via the
|
||||
hash ref C<args>. Note that this is a private function owned by www_ajax. It
|
||||
should not be used directly.
|
||||
|
||||
=cut
|
||||
|
||||
sub _moveFileAjaxRequest {
|
||||
my $self = shift;
|
||||
my $args = shift;
|
||||
|
||||
my $session = $self->session;
|
||||
my %result;
|
||||
|
||||
# Return if current user is not allowed to edit this album
|
||||
unless ( $self->canEdit ) {
|
||||
$session->log->error("Call of moveFile action without having edit permission.");
|
||||
$result{ errMessage } = "You do not have permission to move files.";
|
||||
return \%result;
|
||||
}
|
||||
# Return if no target was specified
|
||||
if ( $args->{target} eq '') {
|
||||
$session->log->error("Call of moveFile action without target argument.");
|
||||
$result{ errMessage } = "Target argument is missing.";
|
||||
return \%result;
|
||||
}
|
||||
# Return if before or after argument is missing
|
||||
unless( $args->{before} or $args->{after} ) {
|
||||
$session->log->error("Call of moveFile action without before/after argument.");
|
||||
$result{ errMessage } = "Before/after argument is missing.";
|
||||
return \%result;
|
||||
}
|
||||
# Return if before and after arguments were specified
|
||||
unless( $args->{before} xor $args->{after} ) {
|
||||
$session->log->error("Call of moveFile action with before *and* after argument.");
|
||||
$result{ errMessage } = "Both, before and after arguments were specified.";
|
||||
return \%result;
|
||||
}
|
||||
|
||||
# Get Id of target photo and instantiate asset
|
||||
my $targetId = $args->{target};
|
||||
my $target = WebGUI::Asset->newByDynamicClass( $session, $targetId );
|
||||
|
||||
# Return if target photo could not be instantiated
|
||||
unless ( $target ) {
|
||||
$session->log->error("Couldn't move file '$targetId' because we couldn't instantiate it.");
|
||||
$result{ errMessage } = "ID of target file seems to be invalid.";
|
||||
return \%result;
|
||||
}
|
||||
# Return if target is not a child of the current album
|
||||
unless ( $target->getParent->getId eq $self->getId ) {
|
||||
$session->log->error("Couldn't move file '$targetId' because it is not a child of this album.");
|
||||
$result{ errMessage } = "ID of target file seems to be invalid.";
|
||||
return \%result;
|
||||
}
|
||||
|
||||
my ($destId, $dest);
|
||||
|
||||
# Instantiate file with ID in before/after argument
|
||||
$destId = $args->{before} ? $args->{before} : $args->{after};
|
||||
$dest = WebGUI::Asset->newByDynamicClass( $session, $destId );
|
||||
|
||||
# Return if destination file could not be instantiated
|
||||
unless ( $dest ) {
|
||||
$session->log->error("Couldn't move file '$targetId' before/after file '$destId' because we couldn't instantiate the latter.");
|
||||
$result{ errMessage } = "ID in before/after argument seems to be invalid.";
|
||||
return \%result;
|
||||
}
|
||||
# Return if destination file is not a child of the current album
|
||||
unless ( $dest->getParent->getId eq $self->getId ) {
|
||||
$session->log->error("Couldn't move file '$targetId' before/after file '$destId' because the latter is not a child of the same album.");
|
||||
$result{ errMessage } = "ID in before/after argument seems to be invalid.";
|
||||
return \%result;
|
||||
}
|
||||
|
||||
# Check for use of after argument when lowering the rank
|
||||
if ( $args->{after} && $target->getRank() > $dest->getRank() ) {
|
||||
# Get ID of next sibling
|
||||
$destId = $self->getNextFileId( $destId );
|
||||
# Instantiate next sibling
|
||||
$dest = WebGUI::Asset->newByDynamicClass( $session, $destId );
|
||||
}
|
||||
# Check for use of before argument when increasing the rank
|
||||
if ( $args->{before} && $target->getRank() < $dest->getRank() ) {
|
||||
# Get ID of previous sibling
|
||||
$destId = $self->getPreviousFileId( $destId );
|
||||
# Instantiate previous sibling
|
||||
$dest = WebGUI::Asset->newByDynamicClass( $session, $destId );
|
||||
}
|
||||
|
||||
# Update rank of target photo
|
||||
$target->setRank( $dest->getRank );
|
||||
|
||||
# Log some debug information
|
||||
$session->log->debug("Successfully moved file '$targetId' before/after file '$destId'.");
|
||||
|
||||
# Return reporting success
|
||||
$result{ err } = 0;
|
||||
return \%result;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
Show the form to add / edit a GalleryAlbum asset.
|
||||
|
|
|
|||
|
|
@ -408,11 +408,11 @@ sub www_setStatus {
|
|||
$db->write("delete from InOutBoard_status where userId=? and assetId=?", [ $sessionUserId, $self->getId ]);
|
||||
$db->write(
|
||||
"insert into InOutBoard_status (assetId,userId,status,dateStamp,message) values (?,?,?,?,?)",
|
||||
[$self->getId, $sessionUserId, $status, $session->datetime->time(), $message ],
|
||||
[$self->getId, $sessionUserId, $status, time(), $message ],
|
||||
);
|
||||
$db->write(
|
||||
"insert into InOutBoard_statusLog (assetId,userId,createdBy,status,dateStamp,message) values (?,?,?,?,?,?)",
|
||||
[$self->getId, $sessionUserId, $session->user->userId, $status, $session->datetime->time(), $message ],
|
||||
[$self->getId, $sessionUserId, $session->user->userId, $status, time(), $message ],
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
|
@ -446,7 +446,7 @@ sub www_viewReport {
|
|||
-name=>"doit",
|
||||
-value=>"1"
|
||||
);
|
||||
my $startDate = $self->session->datetime->addToDate($self->session->datetime->time(),0,0,-15);
|
||||
my $startDate = $self->session->datetime->addToDate(time(),0,0,-15);
|
||||
$startDate = $self->session->form->date("startDate") if ($self->session->form->process("doit"));
|
||||
$f->date(
|
||||
-name=>"startDate",
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ property mobileTemplateId => (
|
|||
fieldType => 'template',
|
||||
namespace => 'Layout',
|
||||
default => 'PBtmpl0000000000000054',
|
||||
label => ['mobileTemplateId label', 'Asset_Layout'],
|
||||
hoverHelp => ['mobileTemplateId description', 'Asset_Layout'],
|
||||
noFormPost => 1,
|
||||
);
|
||||
property contentPositions => (
|
||||
|
|
@ -53,6 +55,8 @@ property assetsToHide => (
|
|||
property assetOrder => (
|
||||
default => 'asc',
|
||||
fieldType => 'selectBox',
|
||||
label => ['asset order label', 'Asset_Layout'],
|
||||
hoverHelp => ['asset order hoverHelp', 'Asset_Layout'],
|
||||
noFormPost => 1,
|
||||
);
|
||||
|
||||
|
|
@ -97,66 +101,88 @@ override getEditForm => sub {
|
|||
else {
|
||||
$templateId = $self->templateId;
|
||||
}
|
||||
$tabform->getTab("display")->template(
|
||||
-value=>$templateId,
|
||||
-label=>$i18n->get('layout template title'),
|
||||
-hoverHelp=>$i18n->get('template description'),
|
||||
-namespace=>"Layout"
|
||||
);
|
||||
|
||||
tie my %extraFields, "Tie::IxHash";
|
||||
%extraFields = (
|
||||
templateId => {
|
||||
fieldType => 'template',
|
||||
tab => 'display',
|
||||
value => $templateId,
|
||||
label => $i18n->get('layout template title'),
|
||||
hoverHelp => $i18n->get('template description'),
|
||||
namespace => "Layout",
|
||||
});
|
||||
|
||||
if ( $self->session->setting->get('useMobileStyle') ) {
|
||||
$tabform->getTab("display")->template(
|
||||
name => 'mobileTemplateId',
|
||||
value => $self->mobileTemplateId,
|
||||
label => $i18n->get('mobileTemplateId label'),
|
||||
hoverHelp => $i18n->get('mobileTemplateId description'),
|
||||
namespace => 'Layout',
|
||||
);
|
||||
$extraFields{mobileTemplateId} = {
|
||||
fieldType => 'template',
|
||||
tab => 'display',
|
||||
name => 'mobileTemplateId',
|
||||
value => $self->mobileTemplateId,
|
||||
label => $i18n->get('mobileTemplateId label'),
|
||||
hoverHelp => $i18n->get('mobileTemplateId description'),
|
||||
namespace => 'Layout',
|
||||
};
|
||||
}
|
||||
else {
|
||||
$tabform->getTab("display")->hidden(
|
||||
$extraFields{mobileTemplateId} = {
|
||||
fieldType => 'hidden',
|
||||
tab => 'display',
|
||||
name => 'mobileTemplateId',
|
||||
value => $self->mobileTemplateId,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
tie my %assetOrder, "Tie::IxHash";
|
||||
%assetOrder = (
|
||||
"asc" =>$i18n->get("asset order asc"),
|
||||
"desc" =>$i18n->get("asset order desc"),
|
||||
);
|
||||
$tabform->getTab("display")->selectBox(
|
||||
-name => 'assetOrder',
|
||||
-label => $i18n->get('asset order label'),
|
||||
-hoverHelp => $i18n->get('asset order hoverHelp'),
|
||||
-value => $self->assetOrder,
|
||||
-options => \%assetOrder
|
||||
"asc" => $i18n->get("asset order asc"),
|
||||
"desc" => $i18n->get("asset order desc"),
|
||||
);
|
||||
$extraFields{assetOrder} = {
|
||||
tab => 'display',
|
||||
fieldType => 'selectBox',
|
||||
name => 'assetOrder',
|
||||
label => $i18n->get('asset order label'),
|
||||
hoverHelp => $i18n->get('asset order hoverHelp'),
|
||||
value => $self->assetOrder,
|
||||
options => \%assetOrder,
|
||||
};
|
||||
|
||||
if ($self->get("assetId") eq "new") {
|
||||
$tabform->getTab("properties")->whatNext(
|
||||
-options=>{
|
||||
view=>$i18n->get(823),
|
||||
viewParent=>$i18n->get(847)
|
||||
},
|
||||
-value=>"view"
|
||||
);
|
||||
} else {
|
||||
$extraFields{whatNext} = {
|
||||
fieldType => 'whatNext',
|
||||
value => "view",
|
||||
options => {
|
||||
view => $i18n->get(823),
|
||||
viewParent => $i18n->get(847)
|
||||
},
|
||||
};
|
||||
}
|
||||
else {
|
||||
my @assetsToHide = split("\n",$self->assetsToHide);
|
||||
my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
|
||||
my %childIds;
|
||||
foreach my $child (@{$children}) {
|
||||
$childIds{$child->getId} = $child->getTitle;
|
||||
}
|
||||
$tabform->getTab("display")->checkList(
|
||||
-name=>"assetsToHide",
|
||||
-value=>\@assetsToHide,
|
||||
-options=>\%childIds,
|
||||
-label=>$i18n->get('assets to hide'),
|
||||
-hoverHelp=>$i18n->get('assets to hide description'),
|
||||
-vertical=>1,
|
||||
-uiLevel=>9
|
||||
);
|
||||
$extraFields{assetsToHide} = {
|
||||
fieldType => 'checkList',
|
||||
tab => 'display',
|
||||
name => "assetsToHide",
|
||||
value => \@assetsToHide,
|
||||
options => \%childIds,
|
||||
label => $i18n->get('assets to hide'),
|
||||
hoverHelp => $i18n->get('assets to hide description'),
|
||||
vertical => 1,
|
||||
uiLevel => 9,
|
||||
};
|
||||
}
|
||||
|
||||
my $overrides = $self->session->config->get("assets/".$self->get("className"));
|
||||
foreach my $fieldName (keys %extraFields) {
|
||||
$self->setupFormField($tabform, $fieldName, \%extraFields, $overrides);
|
||||
}
|
||||
|
||||
return $tabform;
|
||||
};
|
||||
|
||||
|
|
@ -391,17 +417,14 @@ override www_view => sub {
|
|||
) {
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
my $cacheKey = "view_".$self->getId;
|
||||
if ($session->env->sslRequest) {
|
||||
$cacheKey .= '_ssl';
|
||||
}
|
||||
my $cacheKey = $self->getWwwCacheKey('view');
|
||||
my $cache = $session->cache;
|
||||
my $out = eval{$cache->get($cacheKey)};
|
||||
my $out = eval{ $cache->get($cacheKey) };
|
||||
unless ($out) {
|
||||
$self->prepareView;
|
||||
$session->stow->set("cacheFixOverride", 1);
|
||||
$out = $self->processStyle($self->view, { noHeadTags => 1 });
|
||||
eval{$cache->set($cacheKey, $out, 60)};
|
||||
eval{ $cache->set($cacheKey, $out, 60) };
|
||||
$session->stow->delete("cacheFixOverride");
|
||||
}
|
||||
# keep those ads rotating even though the output is cached
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ property templateIdEditPoint => (
|
|||
tab => "display",
|
||||
fieldType => "template",
|
||||
namespace => "MapPoint/Edit",
|
||||
default => 'oHh0UqAJeY7u2n--WD-BAA',
|
||||
label => ["templateIdEditPoint label", 'Asset_Map'],
|
||||
hoverHelp => ["templateIdEditPoint description", 'Asset_Map'],
|
||||
);
|
||||
|
|
@ -97,6 +98,7 @@ property templateIdView => (
|
|||
tab => "display",
|
||||
fieldType => "template",
|
||||
namespace => "Map/View",
|
||||
default => '9j0_Z1j3Jd0QBbY2akb6qw',
|
||||
label => ["templateIdView label", 'Asset_Map'],
|
||||
hoverHelp => ["templateIdView description", 'Asset_Map'],
|
||||
);
|
||||
|
|
@ -104,6 +106,7 @@ property templateIdViewPoint => (
|
|||
tab => "display",
|
||||
fieldType => "template",
|
||||
namespace => "MapPoint/View",
|
||||
default => 'u9vfx33XDk5la1-QC5FK7g',
|
||||
label => ["templateIdViewPoint label", 'Asset_Map'],
|
||||
hoverHelp => ["templateIdViewPoint description", 'Asset_Map'],
|
||||
);
|
||||
|
|
@ -291,6 +294,8 @@ sub loadMapApiTags {
|
|||
my $style = $self->session->style;
|
||||
my $url = $self->session->url;
|
||||
|
||||
$style->setLink($url->extras('yui/build/container/assets/skins/sam/container.css'),{type=>'text/css',rel=>'stylesheet'});
|
||||
$style->setLink($url->extras('yui/build/button/assets/skins/sam/button.css'),{type=>'text/css',rel=>'stylesheet'});
|
||||
$style->setScript("http://www.google.com/jsapi?key=" . $self->mapApiKey,{type=>"text/javascript"});
|
||||
$style->setRawHeadTags(<<'ENDHTML');
|
||||
<script type="text/javascript">
|
||||
|
|
@ -300,6 +305,10 @@ ENDHTML
|
|||
$style->setScript('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js', {type=>"text/javascript"});
|
||||
$style->setScript($url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/connection/connection-min.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/dragdrop/dragdrop-min.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/element/element-min.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/button/button-min.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/container/container-min.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'),{type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui-webgui/build/map/map.js'),{type=>'text/javascript'});
|
||||
|
||||
|
|
@ -355,14 +364,17 @@ sub view {
|
|||
;
|
||||
|
||||
# The script to load the map into the container
|
||||
$mapHtml .= sprintf <<'ENDHTML', $self->getId, $self->getUrl, $self->startLatitude, $self->startLongitude, $self->startZoom;
|
||||
$mapHtml .= sprintf <<'ENDHTML', $self->getId, $self->getUrl, $self->startLatitude, $self->startLongitude, $self->startZoom, $session->url->extras;
|
||||
<script type="text/javascript">
|
||||
google.setOnLoadCallback( function() {
|
||||
var mapId = "%s";
|
||||
var mapUrl = "%s";
|
||||
var map = new GMap2( document.getElementById("map_" + mapId) );
|
||||
map.url = mapUrl;
|
||||
map.assetId = mapId;
|
||||
map.setCenter(new GLatLng(%s, %s), %s);
|
||||
map.setUIToDefault();
|
||||
map.extrasUrl = "%s";
|
||||
|
||||
var markermanager = new MarkerManager(map, {trackMarkers: true});
|
||||
ENDHTML
|
||||
|
|
@ -386,7 +398,7 @@ ENDHTML
|
|||
}
|
||||
|
||||
$mapHtml .= <<'ENDHTML';
|
||||
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, mapUrl, points), 1 );
|
||||
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, points), 0 );
|
||||
ENDHTML
|
||||
}
|
||||
|
||||
|
|
@ -406,13 +418,13 @@ ENDHTML
|
|||
if ( document.getElementById( "setCenter_" + mapId ) ) {
|
||||
var button = document.getElementById( "setCenter_" + mapId );
|
||||
GEvent.addDomListener( button, "click", function () {
|
||||
WebGUI.Map.setCenter( map, mapUrl );
|
||||
WebGUI.Map.setCenter( map );
|
||||
} );
|
||||
}
|
||||
if ( document.getElementById( "addPoint_" + mapId ) ) {
|
||||
var button = document.getElementById( "addPoint_" + mapId );
|
||||
GEvent.addDomListener( button, "click", function () {
|
||||
WebGUI.Map.editPoint( map, markermanager, mapUrl );
|
||||
WebGUI.Map.editPoint( map, markermanager );
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
|
@ -435,6 +447,22 @@ ENDHTML
|
|||
id => sprintf( 'setCenter_%s', $self->getId ),
|
||||
} );
|
||||
|
||||
# Select box to choose a map point
|
||||
tie my %selectPointOptions, 'Tie::IxHash', (
|
||||
"" => '-- ' . $i18n->get('select a point'),
|
||||
);
|
||||
if ( $var->{mapPoints} ) {
|
||||
for my $point ( sort { $a->{title} cmp $b->{title} } @{$var->{mapPoints}} ) {
|
||||
$selectPointOptions{ $point->{assetId} } = $point->{title};
|
||||
}
|
||||
}
|
||||
$var->{ selectPoint }
|
||||
= WebGUI::Form::selectBox( $session, {
|
||||
extras => q{onchange="WebGUI.Map.focusOn(this.options[this.selectedIndex].value);"},
|
||||
id => sprintf( q{selectPoint_%s}, $self->getId ),
|
||||
options => \%selectPointOptions,
|
||||
} );
|
||||
|
||||
return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
|
||||
}
|
||||
|
||||
|
|
@ -528,8 +556,19 @@ sub www_ajaxEditPointSave {
|
|||
my $errors = $asset->processAjaxEditForm;
|
||||
|
||||
# Commit!
|
||||
if ($asset->getAutoCommitWorkflowId && $self->hasBeenCommitted) {
|
||||
$asset->requestAutoCommit;
|
||||
if ( $asset->getAutoCommitWorkflowId ) {
|
||||
if ( $self->hasBeenCommitted) {
|
||||
$asset->requestAutoCommit;
|
||||
}
|
||||
else {
|
||||
# Add mappoint to map's version tag
|
||||
my $oldTagId = $asset->get('tagId');
|
||||
$asset->setVersionTag( $self->get('tagId') );
|
||||
my $oldTag = WebGUI::VersionTag->new( $session, $oldTagId );
|
||||
if ( $oldTag->getAssetCount <= 0 ) {
|
||||
$oldTag->rollback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Encode entities because we're returning as HTML
|
||||
|
|
|
|||
|
|
@ -595,20 +595,14 @@ sub view {
|
|||
$style->setLink($url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
|
||||
{type =>'text/css', rel=>'stylesheet'});
|
||||
|
||||
$style->setScript($url->extras('yui/build/utilities/utilities.js'),
|
||||
{type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'),
|
||||
{type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/datasource/datasource-min.js'),
|
||||
{type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/datatable/datatable-min.js'),
|
||||
{type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/button/button-min.js'),
|
||||
{type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/utilities/utilities.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/datasource/datasource-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/datatable/datatable-min.js'), {type => 'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/button/button-min.js'), {type => 'text/javascript'});
|
||||
|
||||
my ($varStatistics,$varStatisticsEncoded);
|
||||
my $var = $self->get;
|
||||
$var->{listing_loop} = $self->getListings;
|
||||
$var->{isLoggedIn} = ($session->user->userId ne "1");
|
||||
$var->{addMatrixListing_url} = $self->getUrl('func=add;class=WebGUI::Asset::MatrixListing');
|
||||
$var->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
|
||||
|
|
@ -729,7 +723,7 @@ sub view {
|
|||
push (@{ $varStatistics->{last_updated_loop} }, {
|
||||
url => $lastUpdatedListing->getUrl,
|
||||
name => $lastUpdatedListing->title,
|
||||
lastUpdated => $self->session->datetime->epochToHuman($lastUpdatedListing->lastUpdated,"%z")
|
||||
lastUpdated => $session->datetime->epochToHuman($lastUpdatedListing->lastUpdated,"%z")
|
||||
});
|
||||
}
|
||||
$varStatistics->{lastUpdated_sortButton} = "<span id='sortByUpdated'><button type='button'>"
|
||||
|
|
@ -757,6 +751,7 @@ sub view {
|
|||
rating.category =?
|
||||
and asset.parentId=?
|
||||
and asset.state='published'
|
||||
and rating.countValue >= 10
|
||||
and assetData.revisionDate=(
|
||||
select
|
||||
max(revisionDate)
|
||||
|
|
@ -772,21 +767,21 @@ sub view {
|
|||
|
||||
$data = $db->quickHashRef($sql." desc limit 1",[$category,$self->getId]);
|
||||
push(@{ $varStatistics->{best_rating_loop} },{
|
||||
url=>'/'.$data->{url},
|
||||
category=>$category,
|
||||
name=>$data->{productName},
|
||||
mean=>$data->{meanValue},
|
||||
median=>$data->{medianValue},
|
||||
count=>$data->{countValue}
|
||||
url => $session->url->gateway($data->{url}),
|
||||
category => $category,
|
||||
name => $data->{productName},
|
||||
mean => 0+$data->{meanValue},
|
||||
median => 0+$data->{medianValue},
|
||||
count => 0+$data->{countValue}
|
||||
});
|
||||
$data = $db->quickHashRef($sql." asc limit 1",[$category,$self->getId]);
|
||||
push(@{ $varStatistics->{worst_rating_loop} },{
|
||||
url=>'/'.$data->{url},
|
||||
category=>$category,
|
||||
name=>$data->{productName},
|
||||
mean=>$data->{meanValue},
|
||||
median=>$data->{medianValue},
|
||||
count=>$data->{countValue}
|
||||
url => $session->url->gateway($data->{url}),
|
||||
category => $category,
|
||||
name => $data->{productName},
|
||||
mean => 0+$data->{meanValue},
|
||||
median => 0+$data->{medianValue},
|
||||
count => 0+$data->{countValue}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1156,34 +1151,35 @@ sub www_getCompareFormData {
|
|||
if($form->process("search")) {
|
||||
if ($searchParamList) {
|
||||
RESULT: foreach my $result (@{$self->getListings}) {
|
||||
my $checked = '';
|
||||
my $matrixListing_attributes = $session->db->buildHashRefOfHashRefs("
|
||||
select value, fieldType, attributeId from Matrix_attribute
|
||||
left join MatrixListing_attribute as listing using(attributeId)
|
||||
where listing.matrixListingId = ?
|
||||
and attributeId IN(".$searchParamList.")",
|
||||
[$result->{assetId}],'attributeId');
|
||||
##Searching is AND based.
|
||||
PARAM: foreach my $param (@searchParams_sorted) {
|
||||
my $fieldType = $matrixListing_attributes->{$param->{attributeId}}->{fieldType};
|
||||
my $listingValue = $matrixListing_attributes->{$param->{attributeId}}->{value};
|
||||
if(($fieldType eq 'MatrixCompare') && ($listingValue < $param->{value})){
|
||||
$result->{checked} = '';
|
||||
$checked = '';
|
||||
last PARAM;
|
||||
}
|
||||
elsif(($fieldType ne 'MatrixCompare' && $fieldType ne '') && ($param->{value} ne $listingValue)){
|
||||
$result->{checked} = '';
|
||||
$checked = '';
|
||||
last PARAM;
|
||||
}
|
||||
else{
|
||||
$result->{checked} = 'checked';
|
||||
$checked = 'checked';
|
||||
}
|
||||
}
|
||||
$result->{assetId} =~ s/-/_____/g;
|
||||
push @results, $result if $result->{checked} eq 'checked';
|
||||
push @results, $result if $checked eq 'checked';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach my $result (@{$self->getListings}) {
|
||||
$result->{checked} = 'checked';
|
||||
$result->{assetId} =~ s/-/_____/g;
|
||||
push @results, $result;
|
||||
}
|
||||
|
|
@ -1353,7 +1349,7 @@ sub www_listAttributes {
|
|||
|
||||
=head2 www_search ( )
|
||||
|
||||
Returns the search screen.
|
||||
Returns the search screen. Uses www_getCompareFormData with search=1 for doing AJAX requests.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,9 @@ to be displayed within the page style
|
|||
sub view {
|
||||
my $self = shift;
|
||||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $cacheKey = $self->getWwwCacheKey( 'view' );
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval { $cache->get( $cacheKey ) };
|
||||
return $out if $out;
|
||||
}
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_MultiSearch');
|
||||
|
|
@ -111,10 +112,10 @@ sub view {
|
|||
$var{'submit'} = WebGUI::Form::Submit->new($self->session, {name=>'SearchSubmit',value=>$i18n->get('submit','WebGUI')})->toHtml();
|
||||
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->cacheTimeout)};
|
||||
}
|
||||
return $out;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval { $cache->set( $cacheKey, $out, $self->cacheTimeout) };
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -278,20 +278,6 @@ override getEditForm => sub {
|
|||
".($ancestorsChecked ? "" : "toggleAncestorEndPoint();")."
|
||||
//]]>
|
||||
</script>");
|
||||
my $previewButton;# = qq{
|
||||
# <INPUT TYPE="button" VALUE="Preview" NAME="preview"
|
||||
# OnClick="
|
||||
# window.open('', 'navPreview', 'toolbar=no,status=no,location=no,scrollbars=yes,resizable=yes');
|
||||
# this.form.func.value='preview';
|
||||
# this.form.target = 'navPreview';
|
||||
# this.form.submit()">};
|
||||
my $saveButton = ' <input type="button" class="forwardButton" value="'.$i18n->get(62,'WebGUI').'" onclick="
|
||||
this.value=\''.$i18n->get(452,'WebGUI').'\';
|
||||
this.form.func.value=\'editSave\';
|
||||
this.form.target=\'_self\';
|
||||
this.form.submit();
|
||||
" />';
|
||||
$tabform->{_submit} = $previewButton." ".$saveButton;
|
||||
return $tabform;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -316,6 +316,11 @@ override getEditForm => sub {
|
|||
### Download
|
||||
# Download Type
|
||||
my %downloadTypes;
|
||||
tie %downloadTypes, 'Tie::IxHash',
|
||||
"none" => $i18n->get("No Download"),
|
||||
"csv" => $i18n->get("CSV"),
|
||||
"template" => $i18n->get("Template"),
|
||||
;
|
||||
|
||||
$tabform->getTab("properties")->radioList(
|
||||
-name=>"downloadType", # ID is downloadType_formId
|
||||
|
|
@ -508,7 +513,9 @@ sub download {
|
|||
}
|
||||
elsif ($self->downloadType eq "template") {
|
||||
my $data = $self->_processQuery(1,0);
|
||||
return $self->processTemplate($data,$self->downloadTemplateId);
|
||||
my $output = $self->processTemplate($data,$self->downloadTemplateId);
|
||||
WebGUI::Macro::process($self->session, \$output);
|
||||
return $output;
|
||||
}
|
||||
else {
|
||||
# I don't know what to do
|
||||
|
|
@ -568,8 +575,9 @@ if the user is not in Admin Mode.
|
|||
sub view {
|
||||
my $self = shift;
|
||||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $cacheKey = $self->getWwwCacheKey( 'view' );
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{ $cache->get( $cacheKey ) };
|
||||
return $out if $out;
|
||||
}
|
||||
# Initiate an empty debug loop
|
||||
|
|
@ -594,10 +602,10 @@ sub view {
|
|||
}
|
||||
|
||||
my $out = $self->processTemplate($var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->cacheTimeout)};
|
||||
}
|
||||
return $out;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval { $cache->set( $cacheKey, $out, $self->cacheTimeout ) };
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -681,14 +689,15 @@ sub _processQuery {
|
|||
$page = 1 unless defined $page;
|
||||
my $nr = shift || 1;
|
||||
my ($query, %var, $prefix);
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_SQLReport");
|
||||
|
||||
if($nr > 1) {
|
||||
$prefix = 'query'.$nr.'.';
|
||||
}
|
||||
|
||||
if (! $self->{_query}{$nr}{dbQuery}) {
|
||||
if (! $self->{_query}{$nr}{dbQuery} || $self->{_query}{$nr}{dbQuery} =~ m{\A \s* \Z}msx) {
|
||||
$self->session->errorHandler->warn("No query specified for query $nr on '" . $self->getId . "'");
|
||||
push @{$self->{_debug_loop}}, { 'debug.output' => "No query specfied for query $nr" };
|
||||
push @{$self->{_debug_loop}}, { 'debug.output' => sprintf($i18n->get('No query specified for query'), $nr) };
|
||||
return \%var;
|
||||
}
|
||||
|
||||
|
|
@ -703,7 +712,6 @@ sub _processQuery {
|
|||
$query = $self->{_query}{$nr}{dbQuery};
|
||||
}
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_SQLReport");
|
||||
push(@{$self->{_debug_loop}},{'debug.output'=>$i18n->get(17).$query});
|
||||
push(@{$self->{_debug_loop}},{'debug.output'=>$i18n->get('debug placeholder parameters').join(",",@$placeholderParams)});
|
||||
my $dbLink = WebGUI::DatabaseLink->new($self->session,$self->{_query}{$nr}{databaseLinkId});
|
||||
|
|
@ -782,7 +790,7 @@ sub _processQuery {
|
|||
$row{$prefix.'row.field.'.$tmpl_name.'.value'} = $data->{$name};
|
||||
}
|
||||
# Process nested query
|
||||
if($nest && $self->{_query}{$nr + 1}{dbQuery}) {
|
||||
if ($nest && $self->{_query}{$nr + 1}{dbQuery} =~ m/\S/) {
|
||||
my $nest = $self->_processQuery($nest,$page,$nr+1);
|
||||
%row = (%row , %$nest);
|
||||
$row{$prefix.'hasNest'} = $nest->{'query'.($nr+1).'.rows.count'};
|
||||
|
|
@ -832,12 +840,10 @@ sub www_download {
|
|||
unless $self->session->user->isInGroup($self->downloadUserGroup);
|
||||
|
||||
# Set filename and mimetype
|
||||
if ($self->downloadType eq "csv")
|
||||
{
|
||||
if ($self->downloadType eq "csv") {
|
||||
$self->session->http->setFilename($self->downloadFilename,"application/octet-stream");
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$self->session->http->setFilename($self->downloadFilename, $self->downloadMimeType);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,13 +143,17 @@ sub view {
|
|||
value=>$keywords
|
||||
});
|
||||
$var{'no_results' } = $i18n->get("no results");
|
||||
my $searchRoot = $self->searchRoot;
|
||||
if (my $searchOverride = $form->get('searchroot', 'asset')) {
|
||||
$searchRoot = $searchOverride;
|
||||
}
|
||||
|
||||
if ($form->get("doit")) {
|
||||
my $search = WebGUI::Search->new($session);
|
||||
my %rules = (
|
||||
keywords =>$keywords,
|
||||
lineage =>[
|
||||
WebGUI::Asset->newById($session,$self->searchRoot)->get("lineage")
|
||||
WebGUI::Asset->newById($session,$searchRoot)->get("lineage")
|
||||
],
|
||||
);
|
||||
my @classes = split("\n",$self->classLimiter);
|
||||
|
|
@ -157,7 +161,7 @@ sub view {
|
|||
$search->search(\%rules);
|
||||
|
||||
#Instantiate the highlighter
|
||||
my @words = split(/\s+/,$keywords);
|
||||
my @words = grep { $_ ne '' } map { tr/+?*//d; $_; } split(/\s+/,$keywords);
|
||||
my @wildcards = map { "%" } @words;
|
||||
my $hl = HTML::Highlight->new(
|
||||
words => \@words,
|
||||
|
|
@ -182,7 +186,8 @@ sub view {
|
|||
if (defined $asset) {
|
||||
my $properties = $asset->get;
|
||||
if ($self->useContainers) {
|
||||
$properties->{url} = $asset->getContainer->url;
|
||||
$properties->{url} = $asset->isa('WebGUI::Asset::Post::Thread') ? $asset->getCSLinkUrl()
|
||||
: $asset->getContainer->url;
|
||||
}
|
||||
#Add highlighting
|
||||
$properties->{'title' } = $hl->highlight($properties->{title} || '');
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ sub getKeywordStaticURL {
|
|||
my $url = $self->getUrl;
|
||||
my @parts = split /\//, $url;
|
||||
my $lastPart = pop @parts;
|
||||
if (index $lastPart, '.' == -1) {
|
||||
if (index( $lastPart, '.' ) == -1) {
|
||||
return join '/', $self->getUrl, $self->getKeywordFilename($keyword);
|
||||
}
|
||||
else {
|
||||
|
|
@ -573,7 +573,7 @@ sub viewTemplateVariables {
|
|||
}
|
||||
$var->{keywordCloud} = WebGUI::Keyword->new($session)->generateCloud($cloudOptions);
|
||||
if (! $exporting) {
|
||||
$var->{searchHeader} = WebGUI::Form::formHeader($session, { action => $self->getUrl })
|
||||
$var->{searchHeader} = WebGUI::Form::formHeader($session, { action => $self->getUrl, method => 'GET', })
|
||||
. WebGUI::Form::hidden($session, { name => 'func', value => 'view' });
|
||||
$var->{searchFooter} = WebGUI::Form::formFooter($session);
|
||||
$var->{searchButton} = WebGUI::Form::submit($session, { name => 'search', value => $i18n->get('search','Asset')});
|
||||
|
|
|
|||
|
|
@ -35,6 +35,13 @@ property timeLimit => (
|
|||
label => ['timelimit', 'Asset_Survey'],
|
||||
hoverHelp => ['timelimit hoverHelp', 'Asset_Survey'],
|
||||
);
|
||||
property maxResponsesPerUser => (
|
||||
fieldType => 'integer',
|
||||
tab => 'properties',
|
||||
default => 1,
|
||||
label => ['Max user responses', 'Asset_Survey'],
|
||||
hoverHelp => ['Max user responses help', 'Asset_Survey'],
|
||||
);
|
||||
property doAfterTimeLimit => (
|
||||
fieldType => 'selectBox',
|
||||
default => 'exitUrl',
|
||||
|
|
@ -209,13 +216,6 @@ property groupToViewReports => (
|
|||
label => ['Group to view reports', 'Asset_Survey'],
|
||||
hoverHelp => ['Group to view reports help', 'Asset_Survey'],
|
||||
);
|
||||
property maxResponsesPerUser => (
|
||||
fieldType => 'integer',
|
||||
tab => 'security',
|
||||
default => 1,
|
||||
label => ['Max user responses', 'Asset_Survey'],
|
||||
hoverHelp => ['Max user responses help', 'Asset_Survey'],
|
||||
);
|
||||
|
||||
# Other
|
||||
property surveyJSON => (
|
||||
|
|
@ -236,11 +236,6 @@ use Text::CSV_XS;
|
|||
use Params::Validate qw(:all);
|
||||
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
|
||||
|
||||
my $TAP_PARSER_MISSING = <<END_WARN;
|
||||
The Survey Test Suite feature requires TAP::Parser and TAP::Parser::Aggregator CPAN modules.
|
||||
These will be installed as a dependency if you upgrade to Test::Harness 3.x
|
||||
END_WARN
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 surveyJSON_update ( )
|
||||
|
|
@ -668,15 +663,18 @@ test suite.
|
|||
|
||||
sub getAdminConsole {
|
||||
my $self = shift;
|
||||
my $ac = WebGUI::AdminConsole->new( $self->session, 'Survey' );
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Survey");
|
||||
$ac->addSubmenuItem($self->session->url->page("func=edit"), WebGUI::International->new($self->session, "WebGUI")->get(575));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=editSurvey"), $i18n->get('edit survey'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=takeSurvey"), $i18n->get('take survey'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=graph"), $i18n->get('visualize'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=editTestSuite"), $i18n->get("test suite"));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=runTests"), $i18n->get("run all tests"));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=runTests;format=tap"), $i18n->get("run all tests") . " (TAP)");
|
||||
my $ac = $self->SUPER::getAdminConsole;
|
||||
unless ($self->{_modifiedAdminConsole}) {
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Survey");
|
||||
$ac->addSubmenuItem($self->session->url->page("func=edit"), WebGUI::International->new($self->session, "WebGUI")->get(575));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=editSurvey"), $i18n->get('edit survey'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=takeSurvey"), $i18n->get('take survey'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=graph"), $i18n->get('visualize'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=editTestSuite"), $i18n->get("test suite"));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=runTests"), $i18n->get("run all tests"));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=runTests;format=tap"), $i18n->get("run all tests") . " (TAP)");
|
||||
$self->{_modifiedAdminConsole} = 1;
|
||||
}
|
||||
return $ac;
|
||||
}
|
||||
|
||||
|
|
@ -1233,6 +1231,8 @@ sub www_loadSurvey {
|
|||
$editHtml = $self->processTemplate( $var, $self->answerEditTemplateId );
|
||||
}
|
||||
|
||||
WebGUI::Macro::process($self->session, \$editHtml);
|
||||
|
||||
# Generate the list of valid goto targets
|
||||
my $gotoTargets = $self->getSurveyJSON->getGotoTargets;
|
||||
|
||||
|
|
@ -1962,6 +1962,7 @@ sub prepareShowSurveyTemplate {
|
|||
$section->{allowBackBtn} = $self->allowBackBtn;
|
||||
|
||||
my $out = $self->processTemplate( $section, $self->surveyQuestionsId );
|
||||
WebGUI::Macro::process($self->session, \$out);
|
||||
|
||||
$self->session->http->setMimeType('application/json');
|
||||
return to_json( { type => 'displayquestions', section => $section, questions => $questions, html => $out } );
|
||||
|
|
@ -2256,6 +2257,9 @@ END_SQL
|
|||
}
|
||||
$var->{response_loop} = \@responseloop;
|
||||
$paginator->appendTemplateVars($var);
|
||||
|
||||
# Clean up
|
||||
$self->clearTempReportTable;
|
||||
|
||||
my $out = $self->processTemplate( $var, $self->gradebookTemplateId );
|
||||
return $self->processStyle($out);
|
||||
|
|
@ -2346,6 +2350,9 @@ sub www_viewStatisticalOverview {
|
|||
|
||||
$var->{question_loop} = \@questionloop;
|
||||
$paginator->appendTemplateVars($var);
|
||||
|
||||
# Clean up
|
||||
$self->clearTempReportTable;
|
||||
|
||||
my $out = $self->processTemplate( $var, $self->overviewTemplateId );
|
||||
return $self->processStyle($out);
|
||||
|
|
@ -2401,6 +2408,9 @@ sub export {
|
|||
$content = $self->session->db->$method( $opts{sql}, $opts{sqlParams} );
|
||||
}
|
||||
|
||||
# Clean up
|
||||
$self->clearTempReportTable;
|
||||
|
||||
my $filename = $self->session->url->escape( $self->title . "_$opts{name}.$format" );
|
||||
$self->session->http->setFilename($filename,"text/$format");
|
||||
return $content;
|
||||
|
|
@ -2541,6 +2551,21 @@ END_HTML
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 clearTempReportTable
|
||||
|
||||
Clears the Survey_tempReport table
|
||||
|
||||
Typically called after L<loadTempReportTable> has been used
|
||||
|
||||
=cut
|
||||
|
||||
sub clearTempReportTable {
|
||||
my $self = shift;
|
||||
$self->session->db->write( 'delete from Survey_tempReport where assetId = ?', [ $self->getId() ] );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 loadTempReportTable
|
||||
|
||||
Loads the responses from the survey into the Survey_tempReport table, so that other or custom reports can be ran against this data.
|
||||
|
|
@ -2563,7 +2588,7 @@ sub loadTempReportTable {
|
|||
my %opts = validate(@_, { ignoreRevisionDate => 0 });
|
||||
|
||||
# Remove old temp report data
|
||||
$self->session->db->write( 'delete from Survey_tempReport where assetId = ?', [ $self->getId() ] );
|
||||
$self->clearTempReportTable;
|
||||
|
||||
# Build the sql that will select all responses
|
||||
my $sql = 'select * from Survey_response where assetId = ?';
|
||||
|
|
@ -2879,11 +2904,7 @@ sub www_runTest {
|
|||
my $i18n = WebGUI::International->new($session, 'Asset_Survey');
|
||||
my $ac = $self->getAdminConsole;
|
||||
|
||||
eval { require TAP::Parser };
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return $ac->render($TAP_PARSER_MISSING, $i18n->get('test results'));
|
||||
}
|
||||
require TAP::Parser;
|
||||
|
||||
my $testId = $session->form->get("testId");
|
||||
|
||||
|
|
@ -2915,11 +2936,7 @@ all interesting TAP::Parser and TAP::Parser::Result properties) and the template
|
|||
sub parseTap {
|
||||
my ($self, $tap) = @_;
|
||||
|
||||
eval { require TAP::Parser };
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return;
|
||||
}
|
||||
require TAP::Parser;
|
||||
my $parser = TAP::Parser->new( { tap => $tap } );
|
||||
|
||||
# Expose TAP::Parser and TAP::Parser::Result info as template variables
|
||||
|
|
@ -3014,16 +3031,8 @@ sub www_runTests {
|
|||
|
||||
|
||||
my @parsers;
|
||||
eval { require TAP::Parser };
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return $ac->render($TAP_PARSER_MISSING, $i18n->get('test results'));
|
||||
}
|
||||
eval { require TAP::Parser::Aggregator };
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return $ac->render($TAP_PARSER_MISSING, $i18n->get('test results'));
|
||||
}
|
||||
require TAP::Parser;
|
||||
require TAP::Parser::Aggregator;
|
||||
my $aggregate = TAP::Parser::Aggregator->new;
|
||||
$aggregate->start;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ use WebGUI::Asset;
|
|||
use WebGUI::Asset::Wobject::Survey;
|
||||
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
|
||||
|
||||
# We need these as semi-globals so that utility subs (which are shared with the safe compartment)
|
||||
# We need these as file-scoped lexicals so that our utility subs (which are shared with the safe compartment)
|
||||
# can access them.
|
||||
# N.B. If you add any new ones, make sure you initialize them in L<run> otherwise they will be cached across
|
||||
# unrelated engine runs, which leads to bugs that are hairy to track down
|
||||
my $session;
|
||||
my $values;
|
||||
my $scores;
|
||||
|
|
@ -431,7 +433,7 @@ sub run {
|
|||
my ( $s, $expression, $opts )
|
||||
= validate_pos( @_, { isa => 'WebGUI::Session' }, { type => SCALAR }, { type => HASHREF, default => {} } );
|
||||
|
||||
# Init package globals
|
||||
# Initialize all file-scoped lexicals that our Safe utility subs have access to
|
||||
$session = $s;
|
||||
$values = $opts->{values} || {};
|
||||
$scores = $opts->{scores} || {};
|
||||
|
|
@ -439,6 +441,7 @@ sub run {
|
|||
$validate = $opts->{validate};
|
||||
$validTargets = $opts->{validTargets};
|
||||
$tags = $opts->{tags} || {};
|
||||
$otherInstances = {};
|
||||
|
||||
if ( !$session->config->get('enableSurveyExpressionEngine') ) {
|
||||
$session->log->debug('enableSurveyExpressionEngine config option disabled, skipping');
|
||||
|
|
|
|||
|
|
@ -918,7 +918,7 @@ sub responseValues {
|
|||
# Find out what we're indexing responses by
|
||||
my $identifier
|
||||
= $opts{indexBy} eq 'variable' ? $question && $question->{variable}
|
||||
: $self->questionId($address);
|
||||
: $self->questionId(@address);
|
||||
next unless $identifier;
|
||||
|
||||
my $answer = $self->survey->answer([@address]);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,13 @@ property hasTerms => (
|
|||
hoverHelp => ['hasTermsLabel description', 'Asset_SyndicatedContent'],
|
||||
maxlength => 255,
|
||||
);
|
||||
property sortItems => (
|
||||
tab => 'properties',
|
||||
fieldType => 'yesNo',
|
||||
default => 1,
|
||||
label => ['sortItemsLabel', 'Asset_SyndicatedContent'],
|
||||
hoverHelp => ['sortItemsLabel description', 'Asset_SyndicatedContent'],
|
||||
);
|
||||
has '+uiLevel' => (
|
||||
default => 6,
|
||||
);
|
||||
|
|
@ -110,7 +117,7 @@ sub generateFeed {
|
|||
my $limit = shift || $self->maxHeadlines;
|
||||
my $feed = XML::FeedPP::Atom->new();
|
||||
my $log = $self->session->log;
|
||||
|
||||
|
||||
# build one feed out of many
|
||||
my $newlyCached = 0;
|
||||
my $cache = $self->session->cache;
|
||||
|
|
@ -131,33 +138,47 @@ sub generateFeed {
|
|||
utf8::downgrade($value, 1);
|
||||
eval {
|
||||
my $singleFeed = XML::FeedPP->new($value, utf8_flag => 1, -type => 'string');
|
||||
$feed->merge($singleFeed);
|
||||
$feed->merge_channel($singleFeed);
|
||||
$feed->merge_item($singleFeed);
|
||||
};
|
||||
if ($@) {
|
||||
$log->error("Syndicated Content asset (".$self->getId.") has a bad feed URL (".$url."). Failed with ".$@);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# build a new feed that matches the term the user is interested in
|
||||
if ($self->hasTerms ne '') {
|
||||
my @terms = split /,\s*/, $self->hasTerms; # get the list of terms
|
||||
my $termRegex = join("|", map quotemeta($_), @terms); # turn the terms into a regex string
|
||||
my @items = $feed->match_item(title=>qr/$termRegex/msi, description=>qr/$termRegex/msi);
|
||||
$feed->clear_item;
|
||||
foreach my $item (@items) {
|
||||
$feed->add_item($item);
|
||||
}
|
||||
my @items = $feed->match_item(title => qr/$termRegex/msi);
|
||||
push @items, $feed->match_item(description => qr/$termRegex/msi);
|
||||
$feed->clear_item;
|
||||
ITEM: foreach my $item (@items) {
|
||||
$feed->add_item($item);
|
||||
}
|
||||
}
|
||||
|
||||
# sort them by date
|
||||
$feed->sort_item();
|
||||
|
||||
|
||||
my %seen = {};
|
||||
my @items = $feed->get_item;
|
||||
$feed->clear_item;
|
||||
ITEM: foreach my $item (@items) {
|
||||
my $key = join "\n", $item->link, $item->pubDate, $item->description, $item->title;
|
||||
next ITEM if $seen{$key}++;
|
||||
$feed->add_item($item);
|
||||
}
|
||||
|
||||
# sort them by date and remove any duplicate from the OR based term matching above
|
||||
if ($self->sortItems) {
|
||||
$feed->sort_item();
|
||||
}
|
||||
|
||||
# limit the feed to the maximum number of headlines (or the feed generator limit).
|
||||
$feed->limit_item($limit);
|
||||
|
||||
|
||||
# mark this asset as updated
|
||||
$self->update({}) if ($newlyCached);
|
||||
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +243,8 @@ sub getTemplateVariables {
|
|||
$item{author} = WebGUI::HTML::filter(scalar $object->author, 'javascript');
|
||||
$item{guid} = WebGUI::HTML::filter(scalar $object->guid, 'javascript');
|
||||
$item{link} = WebGUI::HTML::filter(scalar $object->link, 'javascript');
|
||||
$item{description} = WebGUI::HTML::filter(scalar($object->description), 'javascript');
|
||||
my $description = WebGUI::HTML::filter(scalar($object->description), 'javascript');
|
||||
$item{description} = defined $description ? $description : '';
|
||||
$item{descriptionFirst100words} = $item{description};
|
||||
$item{descriptionFirst100words} =~ s/(((\S+)\s+){100}).*/$1/s;
|
||||
$item{descriptionFirst75words} = $item{descriptionFirst100words};
|
||||
|
|
|
|||
|
|
@ -65,12 +65,13 @@ always taken from the field hashref.
|
|||
|
||||
sub addField {
|
||||
|
||||
my $self = shift;
|
||||
my $field = shift;
|
||||
my $isImport = shift;
|
||||
my $self = shift;
|
||||
my $field = shift;
|
||||
my $isImport = shift;
|
||||
my $dbDataType = shift || $self->_getDbDataType($field->{fieldType});
|
||||
my $db = $self->session->db;
|
||||
my $error = $self->session->errorHandler;
|
||||
my $session = $self->session;
|
||||
my $db = $session->db;
|
||||
my $error = $session->errorHandler;
|
||||
my ($oldFieldId, $newFieldId,$useAssetId,$useSequence);
|
||||
|
||||
$error->info("Adding Field, label: ".$field->{label}.", fieldId: ".$field->{fieldId}.",thingId: ".$field->{thingId});
|
||||
|
|
@ -415,13 +416,37 @@ The id of row of data that should be copied.
|
|||
=cut
|
||||
|
||||
sub copyThingData {
|
||||
my $self = shift;
|
||||
my $thingId = shift;
|
||||
my $self = shift;
|
||||
my $thingId = shift;
|
||||
my $thingDataId = shift;
|
||||
my $db = $self->session->db;
|
||||
return undef unless $self->canEditThingData($thingId, $thingDataId);;
|
||||
my $session = $self->session;
|
||||
my $db = $session->db;
|
||||
return undef unless $self->canEditThingData($thingId, $thingDataId);
|
||||
|
||||
$self->copyCollateral("Thingy_".$thingId,"thingDataId",$thingDataId);
|
||||
my $origCollateral = $self->getCollateral("Thingy_".$thingId, "thingDataId", $thingDataId);
|
||||
use Data::Dumper;
|
||||
$session->log->warn(Dumper $origCollateral);
|
||||
$origCollateral->{thingDataId} = "new";
|
||||
##Get all fields
|
||||
my $fields = $db->buildArrayRefOfHashRefs('select * from Thingy_fields where assetId=? and thingId=?'
|
||||
,[$self->getId,$thingId]);
|
||||
my @storage_field_ids = ();
|
||||
##Check to see if any of them are File or Image
|
||||
foreach my $field (@{ $fields }) {
|
||||
if ($field->{fieldType} eq 'File' or $field->{fieldType} eq 'Image') {
|
||||
push @storage_field_ids, $field->{fieldId};
|
||||
}
|
||||
}
|
||||
##Instance the storage object and duplicate it
|
||||
foreach my $fieldId (@storage_field_ids) {
|
||||
my $currentId = $origCollateral->{"field_". $fieldId};
|
||||
my $storage = WebGUI::Storage->get($session, $currentId);
|
||||
my $new_store = $storage->copy;
|
||||
##Update the copy with the new storageId.
|
||||
$origCollateral->{"field_". $fieldId} = $new_store->getId;
|
||||
}
|
||||
##Update the copy
|
||||
$self->setCollateral("Thingy_".$thingId, "thingDataId", $origCollateral, 0, 0);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -445,12 +470,13 @@ The id of row of data that should be deleted.
|
|||
|
||||
sub deleteThingData {
|
||||
|
||||
my $self = shift;
|
||||
my $thingId = shift;
|
||||
my $self = shift;
|
||||
my $thingId = shift;
|
||||
my $thingDataId = shift;
|
||||
my $db = $self->session->db;
|
||||
my $session = $self->session;
|
||||
my $db = $session->db;
|
||||
|
||||
return undef unless $self->canEditThingData($thingId, $thingDataId);;
|
||||
return undef unless $self->canEditThingData($thingId, $thingDataId);
|
||||
|
||||
my ($onDeleteWorkflowId) = $db->quickArray("select onDeleteWorkflowId from Thingy_things where thingId=?"
|
||||
,[$thingId]);
|
||||
|
|
@ -458,7 +484,22 @@ sub deleteThingData {
|
|||
$self->triggerWorkflow($onDeleteWorkflowId, $thingId,$thingDataId);
|
||||
}
|
||||
|
||||
my $origCollateral = $self->getCollateral("Thingy_".$thingId, "thingDataId", $thingDataId);
|
||||
$self->deleteCollateral("Thingy_".$thingId,"thingDataId",$thingDataId);
|
||||
my $fields = $db->buildArrayRefOfHashRefs('select * from Thingy_fields where assetId=? and thingId=?'
|
||||
,[$self->getId,$thingId]);
|
||||
my @storage_field_ids = ();
|
||||
##Check to see if any of them are File or Image
|
||||
foreach my $field (@{ $fields }) {
|
||||
if ($field->{fieldType} eq 'File' or $field->{fieldType} eq 'Image') {
|
||||
push @storage_field_ids, $field->{fieldId};
|
||||
}
|
||||
}
|
||||
foreach my $fieldId (@storage_field_ids) {
|
||||
my $currentId = $origCollateral->{"field_". $fieldId};
|
||||
my $storage = WebGUI::Storage->get($session, $currentId);
|
||||
$storage->delete;
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -839,10 +880,10 @@ sub getFieldValue {
|
|||
my $processedValue = $value;
|
||||
my $dbh = $self->session->db->dbh;
|
||||
|
||||
if ($field->{fieldType} eq "date"){
|
||||
if (lc $field->{fieldType} eq "date"){
|
||||
$processedValue = $self->session->datetime->epochToHuman($value,$dateFormat);
|
||||
}
|
||||
elsif ($field->{fieldType} eq "dateTime"){
|
||||
elsif (lc $field->{fieldType} eq "datetime"){
|
||||
$processedValue = $self->session->datetime->epochToHuman($value,$dateTimeFormat);
|
||||
}
|
||||
# TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be
|
||||
|
|
@ -895,7 +936,7 @@ sub getFormElement {
|
|||
|
||||
Returns an instanciated WebGUI::Form::* plugin.
|
||||
|
||||
=head3 proeprties
|
||||
=head3 properties
|
||||
|
||||
The properties to configure the form plugin with. The fieldType key should contain the type of the form plugin.
|
||||
|
||||
|
|
@ -912,19 +953,19 @@ sub getFormPlugin {
|
|||
|
||||
my %param;
|
||||
my $session = $self->session;
|
||||
my $db = $session->db;
|
||||
my $dbh = $db->dbh;
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Thingy");
|
||||
my $db = $session->db;
|
||||
my $dbh = $db->dbh;
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Thingy");
|
||||
|
||||
$param{name} = "field_".$data->{fieldId};
|
||||
my $name = $param{name};
|
||||
my $name = $param{name};
|
||||
$name =~ s/\^.*?\;//xgs ; # remove macro's from user input
|
||||
$param{value} = $data->{value} || $data->{defaultValue};
|
||||
$param{size} = $data->{size};
|
||||
$param{height} = $data->{height};
|
||||
$param{width} = $data->{width};
|
||||
$param{extras} = $data->{extras};
|
||||
$param{vertical} = $data->{vertical};
|
||||
$param{value} = $data->{value} || $data->{defaultValue};
|
||||
$param{size} = $data->{size};
|
||||
$param{height} = $data->{height};
|
||||
$param{width} = $data->{width};
|
||||
$param{extras} = $data->{extras};
|
||||
$param{vertical} = $data->{vertical};
|
||||
$param{fieldType} = $data->{fieldType};
|
||||
|
||||
if ($data->{fieldType} eq "Checkbox") {
|
||||
|
|
@ -936,7 +977,7 @@ sub getFormPlugin {
|
|||
|
||||
if ( WebGUI::Utility::isIn( $data->{fieldType}, qw(SelectList CheckList SelectBox Attachments) ) ) {
|
||||
my @values;
|
||||
if ( $useFormPostData && $self->session->form->param($name) ) {
|
||||
if ( $useFormPostData && $session->form->param($name) ) {
|
||||
$param{ value } = [ $session->form->process( $name, $data->{fieldType} ) ];
|
||||
}
|
||||
elsif ( $data->{ value } ) {
|
||||
|
|
@ -947,7 +988,7 @@ sub getFormPlugin {
|
|||
$param{value} = \@values;
|
||||
}
|
||||
}
|
||||
elsif ( $useFormPostData && $self->session->form->param($name) ) {
|
||||
elsif ( $useFormPostData && $session->form->param($name) ) {
|
||||
$param{value} = $session->form->process( $name, $data->{fieldType} );
|
||||
}
|
||||
|
||||
|
|
@ -981,30 +1022,36 @@ sub getFormPlugin {
|
|||
}
|
||||
|
||||
if ($data->{fieldType} =~ m/^otherThing/x){
|
||||
my $otherThingId = $data->{fieldType};
|
||||
$otherThingId =~ s/^otherThing_(.*)/$1/x;
|
||||
$param{fieldType} = "SelectList";
|
||||
$class = 'WebGUI::Form::'. $param{fieldType};
|
||||
my $otherThingId = $data->{fieldType};
|
||||
$otherThingId =~ s/^otherThing_(.*)/$1/x;
|
||||
$param{fieldType} = "SelectList";
|
||||
$class = 'WebGUI::Form::'. $param{fieldType};
|
||||
my $options = ();
|
||||
|
||||
my $tableName = 'Thingy_'.$otherThingId;
|
||||
my $fieldName = 'field_'.$data->{fieldInOtherThingId};
|
||||
my $tableName = 'Thingy_'.$otherThingId;
|
||||
my $fieldName = 'field_'.$data->{fieldInOtherThingId};
|
||||
my $errorMessage = $self->badOtherThing($tableName, $fieldName);
|
||||
return $errorMessage if $errorMessage;
|
||||
|
||||
$options = $db->buildHashRef('select thingDataId, '
|
||||
my $sth = $session->db->read('select thingDataId, '
|
||||
.$dbh->quote_identifier($fieldName)
|
||||
.' from '.$dbh->quote_identifier($tableName));
|
||||
|
||||
while (my $result = $sth->hashRef){
|
||||
if ($self->canViewThingData($otherThingId,$result->{thingDataId})){
|
||||
$options->{$result->{thingDataId}} = $result->{$fieldName}
|
||||
}
|
||||
}
|
||||
|
||||
my $value = $data->{value} || $data->{defaultValue};
|
||||
($param{value}) = $db->quickArray('select '
|
||||
.$dbh->quote_identifier($fieldName)
|
||||
.' from '.$dbh->quote_identifier($tableName)
|
||||
.' where thingDataId = ?',[$value]);
|
||||
$param{size} = 1;
|
||||
$param{size} = 1;
|
||||
$param{multiple} = 0;
|
||||
$param{options} = $options;
|
||||
$param{value} = $data->{value} || $data->{defaultValue};
|
||||
$param{options} = $options;
|
||||
$param{value} = $data->{value} || $data->{defaultValue};
|
||||
}
|
||||
|
||||
my $formElement = eval { WebGUI::Pluggable::instanciate($class, "new", [$session, \%param ])};
|
||||
|
|
@ -1874,7 +1921,7 @@ sub www_editThing {
|
|||
);
|
||||
|
||||
# create the options hash for the 'Who can edit' and 'Who can view' selectBoxes.
|
||||
%editViewOptions = ('owner'=>'owner',$session->db->buildHash(
|
||||
%editViewOptions = ('owner'=>$i18n->get('owner'),$session->db->buildHash(
|
||||
"select groupId,groupName from groups where showInForms=1 order by groupName"
|
||||
));
|
||||
|
||||
|
|
@ -2161,53 +2208,53 @@ Processes and saves a field. Returns the edited/added fieldId and the inner html
|
|||
|
||||
sub www_editFieldSave {
|
||||
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
my ($fieldId, $fieldTypeChanged, $newFieldId, $formClass, $dbDataType, $thingyTableName, $columnName);
|
||||
my (%properties,$listItemHTML,$formElement);
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Thingy");
|
||||
my $label = $session->form->process("label");
|
||||
my $thingId = $self->session->form->process("thingId");
|
||||
my $error = $self->session->errorHandler;
|
||||
my $i18n = WebGUI::International->new($session, "Asset_Thingy");
|
||||
my $label = $session->form->process("label");
|
||||
my $thingId = $session->form->process("thingId");
|
||||
my $log = $session->log;
|
||||
my $defaultValue = $session->form->process("defaultValue");
|
||||
my $fieldType = $session->form->process("fieldType") || "ReadOnly";
|
||||
my $fieldType = $session->form->process("fieldType") || "ReadOnly";
|
||||
|
||||
if ($fieldType =~ m/^otherThing/){
|
||||
$defaultValue = $session->form->process("defaultFieldInThing");
|
||||
}
|
||||
|
||||
$fieldId = $self->session->form->process("fieldId");
|
||||
$fieldId = $session->form->process("fieldId");
|
||||
%properties = (
|
||||
fieldId=>$fieldId,
|
||||
thingId=>$thingId,
|
||||
label=>$label,
|
||||
fieldType=>$fieldType,
|
||||
defaultValue=>$defaultValue,
|
||||
possibleValues=>$self->session->form->process("possibleValues"),
|
||||
pretext=>$self->session->form->process("pretext"),
|
||||
subtext=>$self->session->form->process("subtext"),
|
||||
status=>$self->session->form->process("status"),
|
||||
size=>$self->session->form->process("size"),
|
||||
width=>$self->session->form->process("width"),
|
||||
height=>$self->session->form->process("height"),
|
||||
vertical=>$self->session->form->process("vertical"),
|
||||
extras=>$self->session->form->process("extras"),
|
||||
display=>$self->session->form->process("display") || 1,
|
||||
viewScreenTitle=>$self->session->form->process("viewScreenTitle") || 0,
|
||||
fieldInOtherThingId=>$session->form->process("fieldInOtherThingId") || "",
|
||||
fieldId => $fieldId,
|
||||
thingId => $thingId,
|
||||
label => $label,
|
||||
fieldType => $fieldType,
|
||||
defaultValue => $defaultValue,
|
||||
possibleValues => $session->form->process("possibleValues"),
|
||||
pretext => $session->form->process("pretext"),
|
||||
subtext => $session->form->process("subtext"),
|
||||
status => $session->form->process("status"),
|
||||
size => $session->form->process("size"),
|
||||
width => $session->form->process("width"),
|
||||
height => $session->form->process("height"),
|
||||
vertical => $session->form->process("vertical"),
|
||||
extras => $session->form->process("extras"),
|
||||
display => $session->form->process("display") || 1,
|
||||
viewScreenTitle => $session->form->process("viewScreenTitle") || 0,
|
||||
fieldInOtherThingId => $session->form->process("fieldInOtherThingId") || "",
|
||||
);
|
||||
# Get the field's data type
|
||||
$dbDataType = $self->_getDbDataType($properties{fieldType});
|
||||
|
||||
if ($fieldId eq "new") {
|
||||
$properties{dateCreated} = time();
|
||||
$properties{createdBy} = $self->session->user->userId;
|
||||
$properties{createdBy} = $session->user->userId;
|
||||
$newFieldId = $self->addField(\%properties,0,$dbDataType);
|
||||
}
|
||||
else{
|
||||
$properties{dateUpdated} = time();
|
||||
$properties{updatedBy} = $self->session->user->userId;
|
||||
$properties{updatedBy} = $session->user->userId;
|
||||
# Check if column has to be altered for existing fields.
|
||||
$self->_updateFieldType($fieldType,$fieldId,$thingId,$self->getId,$dbDataType);
|
||||
$newFieldId = $self->setCollateral("Thingy_fields","fieldId",\%properties,1,1,"thingId",$thingId);
|
||||
|
|
@ -2231,13 +2278,13 @@ sub www_editFieldSave {
|
|||
|
||||
$listItemHTML = "<table>\n<tr>\n<td style='width:100px;' valign='top' class='formDescription'>".$label."</td>\n"
|
||||
."<td style='width:370px;'>".$formElement."</td>\n"
|
||||
."<td style='width:120px;' valign='top'> <input onClick=\"editListItem('".$self->session->url->page()
|
||||
."<td style='width:120px;' valign='top'> <input onClick=\"editListItem('".$session->url->page()
|
||||
."?func=editField;fieldId=".$newFieldId.";thingId=".$properties{thingId}."','".$newFieldId."')\" value='".$i18n->get('Edit','Icon')."' type='button'>"
|
||||
."<input onClick=\"deleteListItem('".$self->session->url->page()."','".$newFieldId
|
||||
."<input onClick=\"deleteListItem('".$session->url->page()."','".$newFieldId
|
||||
."','".$properties{thingId}."')\" value='".$i18n->get('Delete','Icon')."' type='button'></td>\n</tr>\n</table>";
|
||||
|
||||
# Make sure we send debug information along with the field.
|
||||
$session->log->preventDebugOutput;
|
||||
$log->preventDebugOutput;
|
||||
|
||||
$session->output->print($newFieldId.$listItemHTML);
|
||||
return "chunked";
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ sub view {
|
|||
$var{user_loop} = \@users;
|
||||
$var{alphabetSearch_loop} = $self->getAlphabetSearchLoop($self->alphabetSearchField,$self->alphabet);
|
||||
|
||||
$var{searchFormHeader} = WebGUI::Form::formHeader($self->session,{action => $self->getUrl});
|
||||
$var{searchFormHeader} = WebGUI::Form::formHeader($self->session,{action => $self->getUrl, method => 'GET', });
|
||||
$var{searchFormSubmit} = WebGUI::Form::submit($self->session,{value => $i18n->get('submit search label')});
|
||||
$var{searchFormFooter} = WebGUI::Form::formFooter($self->session);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,17 +16,6 @@ package WebGUI::Asset::Wobject::WeatherData;
|
|||
|
||||
use strict;
|
||||
use Weather::Com::Finder;
|
||||
BEGIN {
|
||||
# This is horrible, and needs to be removed when Weather::Com > 0.5.3 is released.
|
||||
my $old_get_weather = \&Weather::Com::Base::get_weather;
|
||||
no warnings 'redefine';
|
||||
*Weather::Com::Base::get_weather = sub {
|
||||
my $self = shift;
|
||||
$self->{LINKS} = 1;
|
||||
return $self->$old_get_weather(@_);
|
||||
};
|
||||
}
|
||||
|
||||
use WebGUI::International;
|
||||
use Moose;
|
||||
use WebGUI::Definition::Asset;
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ sub appendSearchBoxVars {
|
|||
my $queryText = shift;
|
||||
my $submitText = WebGUI::International->new($self->session, 'Asset_WikiMaster')->get('searchLabel');
|
||||
$var->{'searchFormHeader'} = join '',
|
||||
(WebGUI::Form::formHeader($self->session, { action => $self->getUrl}),
|
||||
(WebGUI::Form::formHeader($self->session, { action => $self->getUrl, method => 'GET', }),
|
||||
WebGUI::Form::hidden($self->session, { name => 'func', value => 'search' }));
|
||||
$var->{'searchQuery'} = WebGUI::Form::text($self->session, { name => 'query', value => $queryText });
|
||||
$var->{'searchSubmit'} = WebGUI::Form::submit($self->session, { value => $submitText });
|
||||
|
|
@ -324,7 +324,7 @@ sub appendSearchBoxVars {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 autolinkHtml ($html)
|
||||
=head2 autolinkHtml ($html, [options])
|
||||
|
||||
Scan HTML for words and phrases that match wiki titles, and automatically
|
||||
link them to those wiki pages. Returns the modified HTML.
|
||||
|
|
@ -333,6 +333,14 @@ link them to those wiki pages. Returns the modified HTML.
|
|||
|
||||
The HTML to scan.
|
||||
|
||||
=head3 options
|
||||
|
||||
Either a hashref, or a hash of options.
|
||||
|
||||
=head4 skipTitles
|
||||
|
||||
An array reference of titles that should not be autolinked.
|
||||
|
||||
=cut
|
||||
|
||||
sub autolinkHtml {
|
||||
|
|
@ -340,18 +348,21 @@ sub autolinkHtml {
|
|||
my $html = shift;
|
||||
# opts is always the last parameter, and a hash ref
|
||||
my %opts = ref $_[-1] eq 'HASH' ? %{pop @_} : ();
|
||||
my $skipTitles = $opts{skipTitles} || [];
|
||||
$opts{skipTitles} ||= [];
|
||||
|
||||
# LC all the skip titles once, for efficiency
|
||||
my @skipTitles = map { lc $_ } @{ $opts{skipTitles} };
|
||||
# TODO: ignore caching for now, but maybe do it later.
|
||||
my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage' and i.state='published' and d.status='approved'", [$self->getId]);
|
||||
foreach my $key (keys %mapping) {
|
||||
if (grep {lc $_ eq $key} @$skipTitles) {
|
||||
delete $mapping{$key};
|
||||
next;
|
||||
}
|
||||
$key =~ s{\(}{\\\(}gxms; # escape parens
|
||||
$key =~ s{\)}{\\\)}gxms; # escape parens
|
||||
$mapping{$key} = $self->session->url->gateway($mapping{$key});
|
||||
}
|
||||
# This query returns multiple entries for each asset, so we order by revisionDate and count on the hash to only have the
|
||||
# latest version.
|
||||
my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage' and i.state='published' and d.status='approved' order by d.revisionDate ASC", [$self->getId]);
|
||||
TITLE: foreach my $title (keys %mapping) {
|
||||
my $url = delete $mapping{$title};
|
||||
##isIn short circuits and is faster than grep and/or first
|
||||
next TITLE if isIn($title, @skipTitles);
|
||||
$mapping{$title} = $self->session->url->gateway($url);
|
||||
}
|
||||
|
||||
return $html unless %mapping;
|
||||
# sort by length so it prefers matching longer titles
|
||||
my $matchString = join('|', map{quotemeta} sort {length($b) <=> length($a)} keys %mapping);
|
||||
|
|
@ -385,7 +396,7 @@ sub autolinkHtml {
|
|||
=head2 canAdminister
|
||||
|
||||
Returns true if the current user is in the groupToAdminister group, or the user can edit
|
||||
this WikiMaster.
|
||||
this WikiMaster due to groupIdEdit or ownerUserId.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -398,34 +409,28 @@ sub canAdminister {
|
|||
|
||||
=head2 canEdit ( )
|
||||
|
||||
Overriding canEdit method to check permissions correctly when someone is adding a wikipage
|
||||
Overriding canEdit method to check permissions correctly when someone is adding a wikipage.
|
||||
|
||||
=cut
|
||||
|
||||
around canEdit => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
return (
|
||||
(
|
||||
(
|
||||
$self->session->form->process("func") eq "add" ||
|
||||
(
|
||||
$self->session->form->process("assetId") eq "new" &&
|
||||
$self->session->form->process("func") eq "editSave" &&
|
||||
$self->session->form->process("class") eq "WebGUI::Asset::WikiPage"
|
||||
)
|
||||
) &&
|
||||
$self->canEditPages
|
||||
) || # account for new posts
|
||||
$self->$orig(@_)
|
||||
);
|
||||
my $form = $self->session->form;
|
||||
my $addNew = $form->process("func" ) eq "add";
|
||||
my $editSave = $form->process("assetId" ) eq "new"
|
||||
&& $form->process("func" ) eq "editSave"
|
||||
&& $form->process("class","className" ) eq "WebGUI::Asset::WikiPage";
|
||||
my $canEdit = ( ($addNew || $editSave) && $self->canEditPages )
|
||||
|| $self->$orig(@_);
|
||||
return $canEdit;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canEditPages
|
||||
|
||||
Returns true is the current user is in the group that can edit page, or if
|
||||
Returns true is the current user is in the group that can edit pages, or if
|
||||
they can administer the wiki (canAdminister).
|
||||
|
||||
=cut
|
||||
|
|
|
|||
|
|
@ -317,6 +317,8 @@ sub www_editBranchSave {
|
|||
my %data;
|
||||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
$pb->start($i18n->get('edit branch'), $session->url->extras('adminConsole/assets.gif'));
|
||||
$pb->update($i18n->get('Processing form data'));
|
||||
$data{isHidden} = $form->yesNo("isHidden") if ($form->yesNo("change_isHidden"));
|
||||
$data{newWindow} = $form->yesNo("newWindow") if ($form->yesNo("change_newWindow"));
|
||||
$data{encryptPage} = $form->yesNo("encryptPage") if ($form->yesNo("change_encryptPage"));
|
||||
|
|
@ -353,7 +355,6 @@ sub www_editBranchSave {
|
|||
$urlBase = $form->text("baseUrl");
|
||||
$endOfUrl = $form->selectBox("endOfUrl");
|
||||
}
|
||||
$pb->start($i18n->get('edit branch'), $session->url->extras('adminConsole/assets.gif'));
|
||||
my $descendants = $self->getLineage(["self","descendants"],{returnObjects=>1});
|
||||
DESCENDANT: foreach my $descendant (@{$descendants}) {
|
||||
if ( !$descendant->canEdit ) {
|
||||
|
|
@ -401,6 +402,7 @@ sub www_editBranchSave {
|
|||
}
|
||||
}
|
||||
}
|
||||
$pb->update(sprintf $i18n->get('Attempting to commit changes'));
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ sub cut {
|
|||
return undef if ($self->getId eq $session->setting->get("defaultPage") || $self->getId eq $session->setting->get("notFoundPage"));
|
||||
$session->db->beginTransaction;
|
||||
$session->db->write("update asset set state='clipboard-limbo' where lineage like ? and state='published'",[$self->get("lineage").'%']);
|
||||
$session->db->write("update asset set state='clipboard', stateChangedBy=?, stateChanged=? where assetId=?", [$session->user->userId, $session->datetime->time(), $self->getId]);
|
||||
$session->db->write("update asset set state='clipboard', stateChangedBy=?, stateChanged=? where assetId=?", [$session->user->userId, time(), $self->getId]);
|
||||
$session->db->commit;
|
||||
$self->state("clipboard");
|
||||
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
|
||||
|
|
@ -446,7 +446,7 @@ sub www_emptyClipboard {
|
|||
my $self = shift;
|
||||
my $ac = WebGUI::AdminConsole->new($self->session,"clipboard");
|
||||
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(4));
|
||||
foreach my $asset (@{$self->getAssetsInClipboard(!($self->session->form->process("systemClipboard") && $self->session->user->isAdmin))}) {
|
||||
foreach my $asset (@{$self->getAssetsInClipboard(!($self->session->form->process("systemClipboard") && $self->session->user->isInGroup($self->session->setting->get('groupIdAdminClipboard'))))}) {
|
||||
$asset->trash;
|
||||
}
|
||||
return $self->www_manageClipboard();
|
||||
|
|
@ -466,20 +466,29 @@ sub www_manageClipboard {
|
|||
my $ac = WebGUI::AdminConsole->new($self->session,"clipboard");
|
||||
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(12));
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset");
|
||||
my ($header,$limit);
|
||||
if ($self->session->form->process("systemClipboard") && $self->session->user->isAdmin) {
|
||||
$header = $i18n->get(966);
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageClipboard'), $i18n->get(949));
|
||||
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard;systemClipboard=1'), $i18n->get(959),
|
||||
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
|
||||
} else {
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageClipboard;systemClipboard=1'), $i18n->get(954));
|
||||
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard'), $i18n->get(950),
|
||||
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
|
||||
$limit = 1;
|
||||
}
|
||||
$self->session->style->setLink($self->session->url->extras('assetManager/assetManager.css'), {rel=>"stylesheet",type=>"text/css"});
|
||||
$self->session->style->setScript($self->session->url->extras('assetManager/assetManager.js'), {type=>"text/javascript"});
|
||||
|
||||
my $header;
|
||||
my $limit = 1;
|
||||
|
||||
my $canAdmin = $self->session->user->isInGroup($self->session->setting->get('groupIdAdminClipboard'));
|
||||
if ($self->session->form->process("systemClipboard") && $canAdmin) {
|
||||
$header = $i18n->get(966);
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageClipboard'), $i18n->get(949));
|
||||
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard;systemClipboard=1'), $i18n->get(959),
|
||||
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
|
||||
$limit = undef;
|
||||
}
|
||||
elsif ( $canAdmin ) {
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageClipboard;systemClipboard=1'), $i18n->get(954));
|
||||
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard'), $i18n->get(950),
|
||||
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
|
||||
}
|
||||
else {
|
||||
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard'), $i18n->get(950),
|
||||
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
|
||||
}
|
||||
$self->session->style->setLink($self->session->url->extras('assetManager/assetManager.css'), {rel=>"stylesheet",type=>"text/css"});
|
||||
$self->session->style->setScript($self->session->url->extras('assetManager/assetManager.js'), {type=>"text/javascript"});
|
||||
my $output = "
|
||||
<script type=\"text/javascript\">
|
||||
//<![CDATA[
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ sub getId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 iterateAll ( $asset )
|
||||
=head2 iterateAll ( $asset, [ $options ] )
|
||||
|
||||
This class method returns an iterator set to iterate over all entries for a Dataform.
|
||||
|
||||
|
|
@ -215,13 +215,33 @@ This class method returns an iterator set to iterate over all entries for a Data
|
|||
|
||||
A reference to a Dataform object.
|
||||
|
||||
=head3 $options
|
||||
|
||||
A hashreference of options.
|
||||
|
||||
=head4 offset
|
||||
|
||||
The record number to start the iterator at. Defaults to 0 if not set.
|
||||
|
||||
=head4 limit
|
||||
|
||||
The number of records for the iterator to return. Defaults to a very large number if not set.
|
||||
|
||||
=cut
|
||||
|
||||
sub iterateAll {
|
||||
my $class = shift;
|
||||
my $asset = shift;
|
||||
my $sth = $asset->session->dbSlave->read("SELECT `DataForm_entryId`, `userId`, `username`, `ipAddress`, `submissionDate`, `entryData` FROM `DataForm_entry` WHERE `assetId` = ? ORDER BY `submissionDate` DESC", [$asset->getId]);
|
||||
my $sub = sub {
|
||||
my $class = shift;
|
||||
my $asset = shift;
|
||||
my $options = shift;
|
||||
my $sql = "SELECT SQL_CALC_FOUND_ROWS `DataForm_entryId`, `userId`, `username`, `ipAddress`, `submissionDate`, `entryData` FROM `DataForm_entry` WHERE `assetId` = ? ORDER BY `submissionDate` DESC LIMIT ?,?";
|
||||
my $placeHolders = [ $asset->getId ];
|
||||
push @{ $placeHolders }, exists $options->{offset} ? $options->{offset} : 0;
|
||||
push @{ $placeHolders }, exists $options->{limit} ? $options->{limit} : 1234567890;
|
||||
my $slave = $asset->session->dbSlave; ##Use the same slave to calculate the number of rows
|
||||
my $sth = $slave->read($sql, $placeHolders);
|
||||
my $allRows = $slave->quickScalar('SELECT FOUND_ROWS()');
|
||||
my $sub = sub {
|
||||
return $allRows if $_[0] eq 'rowCount';
|
||||
if (defined wantarray) {
|
||||
my $properties = $sth->hashRef;
|
||||
if ($properties) {
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ sub exportAsHtml {
|
|||
my $i18n = WebGUI::International->new($self->session, 'Asset');
|
||||
|
||||
# take down when we started to tell the user how long the process took.
|
||||
my $startTime = $session->datetime->time;
|
||||
my $startTime = time;
|
||||
|
||||
# get the export path and ensure it is valid.
|
||||
my $exportPath = $self->exportCheckPath;
|
||||
|
|
@ -297,7 +297,7 @@ sub exportAsHtml {
|
|||
}
|
||||
|
||||
# we're done. give the user a status report.
|
||||
my $timeRequired = $session->datetime->time - $startTime;
|
||||
my $timeRequired = time - $startTime;
|
||||
my $message = sprintf $i18n->get('export information'), $exportedCount, $timeRequired;
|
||||
return $message;
|
||||
}
|
||||
|
|
@ -789,14 +789,15 @@ sub exportWriteFile {
|
|||
my $dest = $self->exportGetUrlAsPath;
|
||||
my $parent = $dest->parent;
|
||||
|
||||
eval { $parent->absolute->mkpath };
|
||||
if($@) {
|
||||
WebGUI::Error->throw(error => "could not make directory " . $parent->absolute->stringify);
|
||||
$parent->absolute->mkpath( {error => \my $err} );
|
||||
if (@$err) {
|
||||
(undef, my $message) = %{ $err->[0] };
|
||||
WebGUI::Error->throw(error => "Could not make directory " . $parent->absolute->stringify . ": " . $message);
|
||||
}
|
||||
|
||||
# next, get the contents, open the file, and write the contents to the file.
|
||||
my $fh = eval { $dest->open('>:utf8') };
|
||||
if($@) {
|
||||
if(! $fh) {
|
||||
WebGUI::Error->throw(error => "can't open " . $dest->absolute->stringify . " for writing: $!");
|
||||
}
|
||||
$self->session->asset($self);
|
||||
|
|
@ -807,6 +808,7 @@ sub exportWriteFile {
|
|||
unless($contents eq 'chunked') {
|
||||
$self->session->output->print($contents);
|
||||
}
|
||||
$fh->close;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -56,11 +56,9 @@ An epoch representing the time this asset was created.
|
|||
|
||||
=head3 options
|
||||
|
||||
A hash reference that allows passed in options to change how this method behaves.
|
||||
|
||||
=head4 skipAutoCommitWorkflows
|
||||
|
||||
If this is set to 1 assets that normally autocommit their workflows (like CS Posts) won't do that.
|
||||
A hash reference that allows passed in options to change how this method behaves. Currently,
|
||||
these options are passed down to L<addRevision>, and are not actually used by C<addChild>.
|
||||
Please see the POD for L<addRevision> for a list of options.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -69,7 +67,7 @@ sub addChild {
|
|||
my $session = $self->session;
|
||||
my $properties = shift;
|
||||
my $id = shift || $session->id->generate();
|
||||
my $now = shift || $session->datetime->time();
|
||||
my $now = shift || time();
|
||||
my $options = shift;
|
||||
# Check for valid parentage using validParent on child's class
|
||||
WebGUI::Asset->loadModule($properties->{className});
|
||||
|
|
@ -829,6 +827,10 @@ sub newByLineage {
|
|||
my $id = $assetLineage->{$lineage}{id};
|
||||
unless ($id) {
|
||||
($id) = $session->db->quickArray("select assetId from asset where lineage=?",[$lineage]);
|
||||
if (!$id) {
|
||||
$session->errorHandler->error("Couldn't instantiate asset from lineage: ".$lineage. ": assetId missing");
|
||||
return undef;
|
||||
}
|
||||
$assetLineage->{$lineage}{id} = $id;
|
||||
$session->stow->set("assetLineage",$assetLineage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,19 @@ A hash reference of options to change how the import works
|
|||
Forces the all assets in the package to inherit ownerUserId, groupIdView and groupIdEdit
|
||||
from the asset where it is deployed.
|
||||
|
||||
=head4 overwriteLatest
|
||||
|
||||
Forces the package to ignore the revisionDate inside it. This makes the imported package the
|
||||
latest revision of an asset.
|
||||
|
||||
=head4 clearPackageFlag
|
||||
|
||||
Clears the isPackage flag on the incoming asset.
|
||||
|
||||
=head4 setDefaultTemplate
|
||||
|
||||
Set the isDefault flag on the incoming asset. Really only works on templates.
|
||||
|
||||
=cut
|
||||
|
||||
sub importAssetData {
|
||||
|
|
@ -133,7 +146,7 @@ sub importAssetData {
|
|||
my $error = $session->errorHandler;
|
||||
my $id = $data->{properties}{assetId};
|
||||
my $class = $data->{properties}{className};
|
||||
my $version = $data->{properties}{revisionDate};
|
||||
my $version = $options->{overwriteLatest} ? time : $data->{properties}{revisionDate};
|
||||
|
||||
# Load the class
|
||||
WebGUI::Asset->loadModule( $class );
|
||||
|
|
@ -144,6 +157,12 @@ sub importAssetData {
|
|||
delete $properties{groupIdView};
|
||||
delete $properties{groupIdEdit};
|
||||
}
|
||||
if ($options->{clearPackageFlag}) {
|
||||
$properties{isPackage} = 0;
|
||||
}
|
||||
if ($options->{setDefaultTemplate}) {
|
||||
$properties{isDefault} = 1;
|
||||
}
|
||||
|
||||
my $asset = eval { $class->new($session, $id, $version); };
|
||||
|
||||
|
|
@ -170,16 +189,10 @@ sub importAssetData {
|
|||
};
|
||||
if (! Exception::Class->caught()) { # create a new revision of an existing asset
|
||||
$error->info("Creating a new revision of asset $id");
|
||||
$asset = $asset->addRevision($data->{properties}, $version, {skipAutoCommitWorkflows => 1});
|
||||
$asset = $asset->addRevision(\%properties, $version, {skipAutoCommitWorkflows => 1});
|
||||
}
|
||||
else { # add an entirely new asset
|
||||
$error->info("Adding $id that didn't previously exist.");
|
||||
my %properties = %{ $data->{properties} };
|
||||
if ($options->{inheritPermissions}) {
|
||||
$properties{ownerUserId} = $self->get('ownerUserId');
|
||||
$properties{groupIdView} = $self->get('groupIdView');
|
||||
$properties{groupIdEdit} = $self->get('groupIdEdit');
|
||||
}
|
||||
$asset = $self->addChild(\%properties, $id, $version, {skipAutoCommitWorkflows => 1});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ sub purge {
|
|||
}
|
||||
|
||||
# Delete shortcuts to this asset
|
||||
# Also publish any shortcuts to this asset that are in the trash
|
||||
# Also purge any shortcuts to this asset that are in the trash
|
||||
$outputSub->($i18n->get('Purging shortcuts'));
|
||||
require WebGUI::Asset::Shortcut;
|
||||
my $shortcuts
|
||||
|
|
@ -271,7 +271,7 @@ sub trash {
|
|||
$index->delete;
|
||||
$outputSub->($i18n->get('Deleting exported files'));
|
||||
$asset->_invokeWorkflowOnExportedFiles($session->setting->get('trashWorkflow'), 1);
|
||||
$outputSub->($i18n->get('Purging the cache'));
|
||||
$outputSub->($i18n->get('Clearing cache'));
|
||||
$asset->purgeCache;
|
||||
$asset->updateHistory("trashed");
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ sub trash {
|
|||
$db->beginTransaction;
|
||||
$outputSub->($i18n->get('Clearing asset tables'));
|
||||
$db->write("update asset set state='trash-limbo' where lineage like ?",[$self->get("lineage").'%']);
|
||||
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$session->user->userId, $session->datetime->time(), $self->getId]);
|
||||
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$session->user->userId, time(), $self->getId]);
|
||||
$db->commit;
|
||||
|
||||
# Update ourselves since we didn't use update()
|
||||
|
|
@ -393,15 +393,19 @@ sub www_manageTrash {
|
|||
my $ac = WebGUI::AdminConsole->new($self->session,"trash");
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset");
|
||||
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(12));
|
||||
my ($header, $limit);
|
||||
$ac->setHelp("trash manage");
|
||||
if ($self->session->form->process("systemTrash") && $self->session->user->isAdmin) {
|
||||
$ac->setHelp("trash manage");
|
||||
my $header;
|
||||
my $limit = 1;
|
||||
my $canAdmin = $self->session->user->isInGroup($self->session->setting->get('groupIdAdminTrash'));
|
||||
my $systemTrash = $self->session->form->process("systemTrash");
|
||||
if ($systemTrash && $canAdmin) {
|
||||
$header = $i18n->get(965);
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageTrash'), $i18n->get(10,"WebGUI"));
|
||||
} else {
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageTrash;systemTrash=1'), $i18n->get(964));
|
||||
$limit = 1;
|
||||
$limit = undef;
|
||||
}
|
||||
elsif ( $canAdmin ) {
|
||||
$ac->addSubmenuItem($self->getUrl('func=manageTrash;systemTrash=1'), $i18n->get(964));
|
||||
}
|
||||
$self->session->style->setLink($self->session->url->extras('assetManager/assetManager.css'), {rel=>"stylesheet",type=>"text/css"});
|
||||
$self->session->style->setScript($self->session->url->extras('assetManager/assetManager.js'), {type=>"text/javascript"});
|
||||
my $output = "
|
||||
|
|
@ -434,6 +438,7 @@ sub www_manageTrash {
|
|||
assetManager.AddButton("'.$i18n->get("restore").'","restoreList","manageTrash");
|
||||
assetManager.AddButton("'.$i18n->get("purge").'","purgeList","manageTrash");
|
||||
assetManager.AddFormHidden({ name:"webguiCsrfToken", value:"'.$self->session->scratch->get('webguiCsrfToken').'"});
|
||||
assetManager.AddFormHidden({ name:"systemTrash", value:"'.$systemTrash.'"});
|
||||
assetManager.Write();
|
||||
var assetListSelectAllToggle = false;
|
||||
function toggleAssetListSelectAll(form) {
|
||||
|
|
@ -483,6 +488,9 @@ sub www_purgeList {
|
|||
}
|
||||
}
|
||||
my $method = ($session->form->process("proceed")) ? $session->form->process('proceed') : 'manageTrash';
|
||||
if ($session->form->process('systemTrash') ) {
|
||||
$method .= ';systemTrash=1';
|
||||
}
|
||||
$pb->finish($self->getUrl('func='.$method));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ A hash reference containing a list of properties to associate with the child.
|
|||
=head3 revisionDate
|
||||
|
||||
An epoch date representing the date/time stamp that this revision was
|
||||
created. Defaults to $self->session->datetime->time().
|
||||
created. Defaults to time().
|
||||
|
||||
=head3 options
|
||||
|
||||
|
|
@ -85,15 +85,15 @@ Posts) will know not to send them under certain conditions.
|
|||
=cut
|
||||
|
||||
sub addRevision {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $properties = shift || {};
|
||||
my $now = shift || $session->datetime->time();
|
||||
my $options = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $properties = shift || {};
|
||||
my $now = shift || time();
|
||||
my $options = shift;
|
||||
|
||||
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
|
||||
|
||||
my $workingTag;
|
||||
my ($workingTag, $oldWorking);
|
||||
if ( $autoCommitId ) {
|
||||
$workingTag
|
||||
= WebGUI::VersionTag->create( $session, {
|
||||
|
|
@ -102,7 +102,18 @@ sub addRevision {
|
|||
} );
|
||||
}
|
||||
else {
|
||||
$workingTag = WebGUI::VersionTag->getWorking($session);
|
||||
my $parentAsset;
|
||||
if ( not defined( $parentAsset = $self->getParent ) ) {
|
||||
$parentAsset = WebGUI::Asset->newPending( $session, $self->parentId );
|
||||
}
|
||||
if ( $parentAsset->hasBeenCommitted ) {
|
||||
$workingTag = WebGUI::VersionTag->getWorking( $session );
|
||||
}
|
||||
else {
|
||||
my $oldWorking = WebGUI::VersionTag->getWorking($session, 'noCreate');
|
||||
$workingTag = WebGUI::VersionTag->new( $session, $parentAsset->tagId );
|
||||
$workingTag->setWorking();
|
||||
}
|
||||
}
|
||||
|
||||
#Create a dummy revision to be updated with real data later
|
||||
|
|
@ -124,6 +135,7 @@ sub addRevision {
|
|||
$newVersion->setVersionLock;
|
||||
$newVersion->update(\%mergedProperties);
|
||||
$newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId);
|
||||
$oldWorking->setWorking if $oldWorking;
|
||||
|
||||
return $newVersion;
|
||||
}
|
||||
|
|
@ -235,7 +247,8 @@ sub getRevisionCount {
|
|||
|
||||
=head2 getRevisions ( [ status ] )
|
||||
|
||||
Returns an array reference of the revision objects of this asset.
|
||||
Returns an array reference of the revision objects of this asset, sorted by revision date in descending
|
||||
order. The most recent version will always be first.
|
||||
|
||||
=head3 status
|
||||
|
||||
|
|
@ -443,6 +456,7 @@ Sets a flag so that developers know whether to send notifications out on certain
|
|||
sub setSkipNotification {
|
||||
my $self = shift;
|
||||
$self->session->db->write("update assetData set skipNotification=1 where assetId=? and revisionDate=?", [$self->getId, $self->get("revisionDate")]);
|
||||
$self->{_properties}->{skipNotification} = 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -537,7 +551,7 @@ sub updateHistory {
|
|||
my $session = $self->session;
|
||||
my $action = shift;
|
||||
my $userId = shift || $session->user->userId || '3';
|
||||
my $dateStamp =$session->datetime->time();
|
||||
my $dateStamp =time();
|
||||
$session->db->write("insert into assetHistory (assetId, userId, actionTaken, dateStamp, url) values (?,?,?,?,?)", [$self->getId, $userId, $action, $dateStamp, $self->get('url')]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ sub _isDuplicateUsername {
|
|||
my ($otherUser) = $self->session->db->quickArray("select count(*) from users where username=".$self->session->db->quote($username));
|
||||
return 0 if !$otherUser;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
$self->error('<li>'.sprintf($i18n->get(77), $username,$username,$username,$self->session->datetime->epochToHuman($self->session->datetime->time(),"%y")).'</li>');
|
||||
$self->error('<li>'.sprintf($i18n->get(77), $username,$username,$username,$self->session->datetime->epochToHuman(time(),"%y")).'</li>');
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -99,11 +99,11 @@ sub _logLogin {
|
|||
[
|
||||
$_[0],
|
||||
$_[1],
|
||||
$self->session->datetime->time(),
|
||||
time(),
|
||||
$self->session->env->getIp,
|
||||
$self->session->env->get("HTTP_USER_AGENT"),
|
||||
$self->session->getId,
|
||||
$self->session->datetime->time(),
|
||||
time(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ sub createAccount {
|
|||
$formField = $field->formField($properties, undef, undef, undef, $defaultValue);
|
||||
}
|
||||
else {
|
||||
$formField = $field->formField($properties);
|
||||
$formField = $field->formField($properties, undef, undef, undef, undef, undef, 'useFormDefault');
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ sub deactivateAccount {
|
|||
$var{'yes.label'} = $i18n->get(44);
|
||||
$var{'no.url'} = $self->session->url->page();
|
||||
$var{'no.label'} = $i18n->get(45);
|
||||
return WebGUI::Asset::Template->newById($self->session,"PBtmpl0000000000000057")->process(\%var);
|
||||
return WebGUI::Asset::Template->newById($self->session,$self->get('getDeactivateAccountTemplateId'))->process(\%var);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -562,7 +562,8 @@ sub displayLogin {
|
|||
$vars->{'anonymousRegistration.isAllowed'} = ($self->session->setting->get("anonymousRegistration"));
|
||||
$vars->{'createAccount.url'} = $self->session->url->page('op=auth;method=createAccount');
|
||||
$vars->{'createAccount.label'} = $i18n->get(67);
|
||||
return WebGUI::Asset::Template->newById($self->session,$self->getLoginTemplateId)->process($vars);
|
||||
my $template = $self->getLoginTemplate;
|
||||
return $template->process($vars);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -652,6 +653,30 @@ sub getCreateAccountTemplateId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDeactivateAccountTemplateId ( )
|
||||
|
||||
This method should be overridden by the subclass and should return the template ID for the deactivate account screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDeactivateAccountTemplateId {
|
||||
return "PBtmpl0000000000000057";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultLoginTemplateId ( )
|
||||
|
||||
This method should be overridden by the subclass and should return the default template ID for the login screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDefaultLoginTemplateId {
|
||||
return "PBtmpl0000000000000013";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getExtrasStyle ( )
|
||||
|
||||
This method returns the proper field to display for required fields.
|
||||
|
|
@ -673,6 +698,27 @@ sub getExtrasStyle {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLoginTemplate ( )
|
||||
|
||||
Returns a WebGUI::Asset::Template object for the login template. If the configured
|
||||
template cannot be used, then it returns a default template object.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLoginTemplate {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $templateId = $self->getLoginTemplateId;
|
||||
my $template = WebGUI::Asset::Template->newById($session, $templateId);
|
||||
if (!$template) {
|
||||
$templateId = $self->getDefaultLoginTemplateId;
|
||||
$template = WebGUI::Asset::Template->newById($session, $templateId);
|
||||
}
|
||||
return $template;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLoginTemplateId ( )
|
||||
|
||||
This method should be overridden by the subclass and should return the template ID for the login screen.
|
||||
|
|
@ -692,8 +738,8 @@ Returns a hash reference with the user's authentication information. This metho
|
|||
=cut
|
||||
|
||||
sub getParams {
|
||||
my $self = shift;
|
||||
my $userId = $_[0] || $self->userId;
|
||||
my $self = shift;
|
||||
my $userId = $_[0] || $self->userId;
|
||||
my $authMethod = $_[1] || $self->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));
|
||||
}
|
||||
|
|
@ -796,11 +842,10 @@ Open version tag is reclaimed if user is in site wide or singlePerUser mode.
|
|||
|
||||
sub login {
|
||||
my $self = shift;
|
||||
my ($cmd, $uid, $u);
|
||||
|
||||
#Create a new user
|
||||
$uid = $self->userId;
|
||||
$u = WebGUI::User->new($self->session,$uid);
|
||||
my $uid = $self->userId;
|
||||
my $u = WebGUI::User->new($self->session,$uid);
|
||||
$self->session->user({user=>$u});
|
||||
$u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma"));
|
||||
$self->_logLogin($uid,"success");
|
||||
|
|
@ -820,29 +865,29 @@ sub login {
|
|||
}
|
||||
|
||||
|
||||
# Set the proper redirect
|
||||
if ( $self->session->setting->get( 'showMessageOnLogin' )
|
||||
&& $self->user->profileField( $LOGIN_MESSAGE_SEEN )
|
||||
< $self->session->setting->get( 'showMessageOnLoginTimes' )
|
||||
) {
|
||||
return $self->showMessageOnLogin;
|
||||
}
|
||||
elsif ( $self->session->setting->get("redirectAfterLoginUrl") ) {
|
||||
$self->session->http->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
|
||||
}
|
||||
elsif ( $self->session->form->get('returnUrl') ) {
|
||||
# Set the proper redirect
|
||||
if ( $self->session->setting->get( 'showMessageOnLogin' )
|
||||
&& $self->user->profileField( $LOGIN_MESSAGE_SEEN )
|
||||
< $self->session->setting->get( 'showMessageOnLoginTimes' )
|
||||
) {
|
||||
return $self->showMessageOnLogin;
|
||||
}
|
||||
elsif ( $self->session->form->get('returnUrl') ) {
|
||||
$self->session->http->setRedirect( $self->session->form->get('returnUrl') );
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
elsif ( $self->session->scratch->get("redirectAfterLogin") ) {
|
||||
$self->session->http->setRedirect($self->session->scratch->get("redirectAfterLogin"));
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
elsif ( my $url = $self->session->scratch->delete("redirectAfterLogin") ) {
|
||||
$self->session->http->setRedirect($url);
|
||||
}
|
||||
elsif ( $self->session->setting->get("redirectAfterLoginUrl") ) {
|
||||
$self->session->http->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
|
||||
# Get open version tag. This is needed if we want
|
||||
# to reclaim a version right after login (singlePerUser and siteWide mode)
|
||||
# and to have the correct version displayed.
|
||||
WebGUI::VersionTag->getWorking($self->session(), q{noCreate});
|
||||
# Get open version tag. This is needed if we want
|
||||
# to reclaim a version right after login (singlePerUser and siteWide mode)
|
||||
# and to have the correct version displayed.
|
||||
WebGUI::VersionTag->getWorking($self->session(), q{noCreate});
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -868,6 +913,9 @@ sub logout {
|
|||
my $error = qx($command);
|
||||
$self->session->errorHandler->warn($error) if $error;
|
||||
}
|
||||
|
||||
# Do not allow caching of the logout page (to ensure the page gets requested)
|
||||
$self->session->http->setCacheControl( "none" );
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,11 @@ i.e., it does not validate their username or ensure their account is active.
|
|||
=cut
|
||||
|
||||
sub _isValidLDAPUser {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
my ($error, $ldap, $search, $auth, $connectDN);
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
|
||||
my $connection = $self->getLDAPConnection;
|
||||
return 0 unless $connection;
|
||||
|
|
@ -52,8 +54,8 @@ sub _isValidLDAPUser {
|
|||
$self->error('<li>'.$i18n->get(2,'AuthLDAP').'</li>');
|
||||
return 0;
|
||||
}
|
||||
my $username = $self->session->form->get("authLDAP_ldapId") || $self->session->form->get("username");
|
||||
my $password = $self->session->form->get("authLDAP_identifier") || $self->session->form->get("identifier");
|
||||
my $username = $form->get("authLDAP_ldapId") || $form->get("username");
|
||||
my $password = $form->get("authLDAP_identifier") || $form->get("identifier");
|
||||
|
||||
my $uri = URI->new($connection->{ldapUrl}) or $error = '<li>'.$i18n->get(2,'AuthLDAP').'</li>';
|
||||
|
||||
|
|
@ -63,7 +65,7 @@ sub _isValidLDAPUser {
|
|||
}
|
||||
|
||||
# Create an LDAP object
|
||||
if ($ldap = Net::LDAP->new($uri->host, (port=>$uri->port))) {
|
||||
if ($ldap = Net::LDAP->new($uri->host, (port=>$uri->port,scheme=>$uri->scheme))) {
|
||||
|
||||
# Bind as a proxy user to search for the user trying to login
|
||||
if($connection->{connectDn}) {
|
||||
|
|
@ -101,27 +103,27 @@ sub _isValidLDAPUser {
|
|||
# Invalid login credentials, directory did not authenticate the user
|
||||
if ($auth->code == 48 || $auth->code == 49) {
|
||||
$error .= '<li>'.$i18n->get(68).'</li>';
|
||||
$self->session->errorHandler->warn("Invalid LDAP information for registration of LDAP ID: ".$self->session->form->process('authLDAP_ldapId'));
|
||||
$session->log->warn("Invalid LDAP information for registration of LDAP ID: ".$self->session->form->process('authLDAP_ldapId'));
|
||||
}
|
||||
elsif ($auth->code > 0) { # Some other LDAP error occured
|
||||
$error .= '<li>LDAP error "'.$self->ldapStatusCode($auth->code).'" occured. '.$i18n->get(69).'</li>';
|
||||
$self->session->errorHandler->error("LDAP error: ".$self->ldapStatusCode($auth->code));
|
||||
$session->log->error("LDAP error: ".$self->ldapStatusCode($auth->code));
|
||||
}
|
||||
$ldap->unbind;
|
||||
}
|
||||
else { # Could not find the user in the directory to build a DN
|
||||
$error .= '<li>'.$i18n->get(68).'</li>';
|
||||
$self->session->errorHandler->warn("Invalid LDAP information for registration of LDAP ID: ".$self->session->form->process("authLDAP_ldapId"));
|
||||
$session->log->warn("Invalid LDAP information for registration of LDAP ID: ".$self->session->form->process("authLDAP_ldapId"));
|
||||
}
|
||||
}
|
||||
else { # Unable to bind with proxy user credentials or anonymously for our search
|
||||
$error = '<li>'.$i18n->get(2,'AuthLDAP').'</li>';
|
||||
$self->session->errorHandler->error("Couldn't bind to LDAP server: ".$connection->{ldapUrl});
|
||||
$session->log->error("Couldn't bind to LDAP server: ".$connection->{ldapUrl});
|
||||
}
|
||||
}
|
||||
else { # Could not create our LDAP object
|
||||
$error = '<li>'.$i18n->get(2,'AuthLDAP').'</li>';
|
||||
$self->session->errorHandler->error("Couldn't create LDAP object: ".$connection->{ldapUrl});
|
||||
$session->log->error("Couldn't create LDAP object: ".$connection->{ldapUrl});
|
||||
}
|
||||
|
||||
$self->error($error);
|
||||
|
|
@ -175,21 +177,32 @@ sub authenticate {
|
|||
|
||||
# Try to bind using the users dn and password
|
||||
$auth = $ldap->bind(dn=>$userData->{connectDN}, password=>$identifier);
|
||||
|
||||
# Failure to bind could have resulted from change to in DN on LDAP server.
|
||||
# Test for new DN and update user account as needed
|
||||
if ($auth->code > 0 && $self->_isValidLDAPUser()) {
|
||||
# Update user profile and log change
|
||||
# _isValidLDAPUser will set _connectDN to new correct value
|
||||
$auth = $ldap->bind(dn=>$self->{_connectDN}, password=>$identifier);
|
||||
my $message = "DN has been changed for user ".$_[0]." from \"".$userData->{connectDN}."\" to \"".$self->{_connectDN}."\"";
|
||||
$self->saveParams($self->user->userId, $self->authMethod, { connectDN => $self->{_connectDN} });
|
||||
$self->session->errorHandler->warn($message);
|
||||
}
|
||||
|
||||
# Authentication failed
|
||||
if ($auth->code == 48 || $auth->code == 49){
|
||||
if ($auth->code == 48 || $auth->code == 49 || $auth->code == 32){
|
||||
$error .= $self->SUPER::authenticationError;
|
||||
}
|
||||
elsif ($auth->code > 0) { # Some other LDAP error happened
|
||||
$error .= '<li>LDAP error "'.$self->ldapStatusCode($auth->code).'" occured.'.$i18n->get(69).'</li>';
|
||||
$self->session->errorHandler->error("LDAP error: ".$self->ldapStatusCode($auth->code));
|
||||
$self->session->log->error("LDAP error: ".$self->ldapStatusCode($auth->code));
|
||||
}
|
||||
|
||||
$ldap->unbind;
|
||||
}
|
||||
else {
|
||||
$error .= '<li>'.$i18n->get(13,'AuthLDAP').'</li>';
|
||||
$self->session->errorHandler->error("Could not process this LDAP URL: ".$userData->{ldapUrl});
|
||||
$self->session->log->error("Could not process this LDAP URL: ".$userData->{ldapUrl});
|
||||
}
|
||||
|
||||
if($error ne ""){
|
||||
|
|
@ -311,7 +324,7 @@ sub createAccountSave {
|
|||
}
|
||||
#Get connectDN from settings
|
||||
my $uri = URI->new($connection->{ldapUrl});
|
||||
my $ldap = Net::LDAP->new($uri->host, (port=>$uri->port));
|
||||
my $ldap = Net::LDAP->new($uri->host, (port=>$uri->port,scheme=>$uri->scheme));
|
||||
my $auth;
|
||||
if($connection->{connectDn}) {
|
||||
$auth = $ldap->bind(dn=>$connection->{connectDn}, password=>$connection->{identifier});
|
||||
|
|
@ -480,7 +493,7 @@ sub editUserForm {
|
|||
);
|
||||
$f->text(
|
||||
-name => "authLDAP_connectDN",
|
||||
-label => $i18n->get(4),
|
||||
-label => $i18n->get('LDAP User DN'),
|
||||
-value => $connectDN,
|
||||
);
|
||||
$self->session->style->setRawHeadTags($jscript);
|
||||
|
|
@ -586,7 +599,34 @@ sub getCreateAccountTemplateId {
|
|||
my $self = shift;
|
||||
my $ldapConnect = $self->getLDAPConnection;
|
||||
return "PBtmpl0000000000000005" unless $ldapConnect;
|
||||
return ($self->getLDAPConnection->{ldapCreateAccountTemplate} || "PBtmpl0000000000000005");
|
||||
return ($ldapConnect->{ldapCreateAccountTemplate} || "PBtmpl0000000000000005");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDeactivateAccountTemplateId ( )
|
||||
|
||||
Get the default template ID for the deactivate account form.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDeactivateAccountTemplateId {
|
||||
my $self = shift;
|
||||
my $ldapConnect = $self->getLDAPConnection;
|
||||
return $self->SUPER::getDeactivateAccountTemplateId unless $ldapConnect;
|
||||
return ($ldapConnect->{ldapDeactivateAccountTemplate} || $self->SUPER::getDeactivateAccountTemplateId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultLoginTemplateId ( )
|
||||
|
||||
Get the default template ID for the login form.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDefaultLoginTemplateId {
|
||||
return "PBtmpl0000000000000006";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -629,8 +669,8 @@ Get the template ID for the login form.
|
|||
sub getLoginTemplateId {
|
||||
my $self = shift;
|
||||
my $ldapConnect = $self->getLDAPConnection;
|
||||
return "PBtmpl0000000000000006" unless $ldapConnect;
|
||||
return ($self->getLDAPConnection->{ldapLoginTemplate} || "PBtmpl0000000000000006");
|
||||
return $self->getDefaultLoginTemplateId unless $ldapConnect;
|
||||
return ($self->getLDAPConnection->{ldapLoginTemplate} || $self->getDefaultLoginTemplateId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -644,8 +684,8 @@ Process the login form. Create a new account if auto registration is enabled.
|
|||
sub login {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $username = $self->session->form->process("username");
|
||||
my $identifier = $self->session->form->process("identifier");
|
||||
my $username = $self->session->form->process("username");
|
||||
my $identifier = $self->session->form->process("identifier");
|
||||
my $autoRegistration = $self->session->setting->get("automaticLDAPRegistration");
|
||||
my $hasAuthenticated = 0;
|
||||
|
||||
|
|
@ -683,7 +723,7 @@ sub login {
|
|||
}
|
||||
return $self->SUPER::login() if $hasAuthenticated; #Standard login routine for login
|
||||
|
||||
$self->session->errorHandler->security("login to account ".$self->session->form->process("username")." with invalid information.");
|
||||
$self->session->log->security("login to account ".$self->session->form->process("username")." with invalid information.");
|
||||
return $self->displayLogin("<h1>".$i18n->get(70)."</h1>".$self->error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ sub createAccount {
|
|||
unless($setting->get('webguiUseEmailAsUsername')){
|
||||
my $username = $form->process("authWebGUI.username");
|
||||
$vars->{'create.form.username'}
|
||||
= WebGUI::Form::text($self->session, {
|
||||
= WebGUI::Form::username($self->session, {
|
||||
name => "authWebGUI.username",
|
||||
value => $username,
|
||||
extras => $self->getExtrasStyle($username)
|
||||
|
|
@ -266,7 +266,7 @@ sub createAccountSave {
|
|||
$properties->{ changeUsername } = $setting->get("webguiChangeUsername");
|
||||
$properties->{ changePassword } = $setting->get("webguiChangePassword");
|
||||
$properties->{ identifier } = $self->hashPassword($password);
|
||||
$properties->{ passwordLastUpdated } = $session->datetime->time();
|
||||
$properties->{ passwordLastUpdated } = time();
|
||||
$properties->{ passwordTimeout } = $setting->get("webguiPasswordTimeout");
|
||||
$properties->{ status } = 'Deactivated' if ($setting->get("webguiValidateEmail"));
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ WebGUI::Asset::Template->newById($self->session,$self->getSetting('accountActiva
|
|||
WebGUI::Macro::process($self->session,\$text);
|
||||
$mail->addText($text);
|
||||
$mail->addFooter;
|
||||
$mail->send;
|
||||
$mail->queue;
|
||||
$self->user->status("Deactivated");
|
||||
$session->var->end($session->var->get("sessionId"));
|
||||
$session->var->start(1,$session->getId);
|
||||
|
|
@ -326,6 +326,18 @@ sub deactivateAccountConfirm {
|
|||
return $self->displayLogin(sprintf( $i18n->get("deactivateAccount success"), $username ));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 checkField ( )
|
||||
|
||||
Performs AJAX checks on form field input. For example, can check whether a user
|
||||
name is free for registration.
|
||||
|
||||
Returns the JSON {"error":"errorString"} where errorString is an error message
|
||||
or an empty string if the check was successful.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub displayAccount {
|
||||
my $self = shift;
|
||||
|
|
@ -433,16 +445,16 @@ sub editUserFormSave {
|
|||
unless (!$identifier || $identifier eq "password") {
|
||||
$properties->{identifier} = $self->hashPassword($self->session->form->process('authWebGUI.identifier'));
|
||||
if($userData->{identifier} ne $properties->{identifier}){
|
||||
$properties->{passwordLastUpdated} =$self->session->datetime->time();
|
||||
$properties->{passwordLastUpdated} =time();
|
||||
}
|
||||
}
|
||||
$properties->{passwordTimeout} = $self->session->form->interval('authWebGUI.passwordTimeout');
|
||||
$properties->{changeUsername} = $self->session->form->process('authWebGUI.changeUsername');
|
||||
$properties->{changePassword} = $self->session->form->process('authWebGUI.changePassword');
|
||||
if($userId eq "new") {
|
||||
$properties->{passwordLastUpdated} =$self->session->datetime->time();
|
||||
$properties->{passwordLastUpdated} =time();
|
||||
if ($self->session->setting->get("webguiExpirePasswordOnCreation")){
|
||||
$properties->{passwordLastUpdated} =$self->session->datetime->time() - $properties->{passwordTimeout};
|
||||
$properties->{passwordLastUpdated} =time() - $properties->{passwordTimeout};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -568,6 +580,13 @@ sub editUserSettingsForm {
|
|||
-namespace => "Auth/WebGUI/Create",
|
||||
-label => $i18n->get("create account template"),
|
||||
-hoverHelp => $i18n->get("create account template help"),
|
||||
);
|
||||
$f->template(
|
||||
-name => "webguiDeactivateAccountTemplate",
|
||||
-value => $self->session->setting->get("webguiDeactivateAccountTemplate"),
|
||||
-namespace => "Auth/WebGUI/Deactivate",
|
||||
-label => $i18n->get("deactivate account template"),
|
||||
-hoverHelp => $i18n->get("deactivate account template help"),
|
||||
);
|
||||
$f->template(
|
||||
-name => "webguiExpiredPasswordTemplate",
|
||||
|
|
@ -649,15 +668,16 @@ sub editUserSettingsFormSave {
|
|||
}
|
||||
|
||||
$s->set("webguiPasswordRecoveryRequireUsername", $f->process("webguiPasswordRecoveryRequireUsername","yesNo"));
|
||||
$s->set("webguiValidateEmail", $f->process("webguiValidateEmail","yesNo"));
|
||||
$s->set("webguiUseCaptcha", $f->process("webguiUseCaptcha","yesNo"));
|
||||
$s->set("webguiAccountTemplate", $f->process("webguiAccountTemplate","template"));
|
||||
$s->set("webguiCreateAccountTemplate", $f->process("webguiCreateAccountTemplate","template"));
|
||||
$s->set("webguiExpiredPasswordTemplate", $f->process("webguiExpiredPasswordTemplate","template"));
|
||||
$s->set("webguiLoginTemplate", $f->process("webguiLoginTemplate","template"));
|
||||
$s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template"));
|
||||
$s->set("webguiWelcomeMessageTemplate", $f->process("webguiWelcomeMessageTemplate","template"));
|
||||
$s->set("webguiAccountActivationTemplate", $f->process("webguiAccountActivationTemplate","template"));
|
||||
$s->set("webguiValidateEmail", $f->process("webguiValidateEmail","yesNo"));
|
||||
$s->set("webguiUseCaptcha", $f->process("webguiUseCaptcha","yesNo"));
|
||||
$s->set("webguiAccountTemplate", $f->process("webguiAccountTemplate","template"));
|
||||
$s->set("webguiCreateAccountTemplate", $f->process("webguiCreateAccountTemplate","template"));
|
||||
$s->set("webguiDeactivateAccountTemplate", $f->process("webguiDeactivateAccountTemplate","template"));
|
||||
$s->set("webguiExpiredPasswordTemplate", $f->process("webguiExpiredPasswordTemplate","template"));
|
||||
$s->set("webguiLoginTemplate", $f->process("webguiLoginTemplate","template"));
|
||||
$s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template"));
|
||||
$s->set("webguiWelcomeMessageTemplate", $f->process("webguiWelcomeMessageTemplate","template"));
|
||||
$s->set("webguiAccountActivationTemplate", $f->process("webguiAccountActivationTemplate","template"));
|
||||
|
||||
if (@errors) {
|
||||
return \@errors;
|
||||
|
|
@ -679,6 +699,17 @@ sub getCreateAccountTemplateId {
|
|||
return $self->session->setting->get("webguiCreateAccountTemplate") || "PBtmpl0000000000000011";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getDeactivateAccountTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("webguiDeactivateAccountTemplate") || $self->SUPER::getDeactivateAccountTemplateId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getDefaultLoginTemplateId {
|
||||
return "PBtmpl0000000000000013";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getExpiredPasswordTemplateId {
|
||||
my $self = shift;
|
||||
|
|
@ -688,7 +719,7 @@ sub getExpiredPasswordTemplateId {
|
|||
#-------------------------------------------------------------------
|
||||
sub getLoginTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("webguiLoginTemplate") || "PBtmpl0000000000000013";
|
||||
return $self->session->setting->get("webguiLoginTemplate") || $self->getDefaultLoginTemplateId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -753,7 +784,7 @@ sub login {
|
|||
my $userData = $self->getParams;
|
||||
if($self->getSetting("passwordTimeout") && $userData->{passwordTimeout}){
|
||||
my $expireTime = $userData->{passwordLastUpdated} + $userData->{passwordTimeout};
|
||||
if ($self->session->datetime->time() >= $expireTime){
|
||||
if (time() >= $expireTime){
|
||||
my $userId = $self->userId;
|
||||
$self->logout;
|
||||
return $self->resetExpiredPassword($userId);
|
||||
|
|
@ -1031,7 +1062,7 @@ sub profileRecoverPasswordFinish {
|
|||
$self->user( $user );
|
||||
$self->saveParams($userId, $self->authMethod,
|
||||
{ identifier => $self->hashPassword($password),
|
||||
passwordLastUpdated => $self->session->datetime->time });
|
||||
passwordLastUpdated => time });
|
||||
$self->_logSecurityMessage;
|
||||
return $self->SUPER::login;
|
||||
} else {
|
||||
|
|
@ -1086,7 +1117,7 @@ sub emailRecoverPasswordFinish {
|
|||
|
||||
my $mail = WebGUI::Mail::Send->create($session, { to=>$email, subject=>$i18n->get('WebGUI password recovery')});
|
||||
$mail->addText($i18n->get('recover password email text1', 'AuthWebGUI') . $url. ". \n\n".$i18n->get('recover password email text2', 'AuthWebGUI')." \n\n ".$url."?op=auth;method=emailResetPassword;token=$recoveryGuid"."\n\n ". $i18n->get('recover password email text3', 'AuthWebGUI'));
|
||||
$mail->send;
|
||||
$mail->queue;
|
||||
return "<h1>". $i18n->get('recover password banner', 'AuthWebGUI')." </h1> <br> <br> <h3>". $i18n->get('email recover password finish message', 'AuthWebGUI') . "</h3>";
|
||||
}
|
||||
|
||||
|
|
@ -1182,7 +1213,7 @@ sub emailResetPasswordFinish {
|
|||
$self->user(WebGUI::User->new($self->session, $userId));
|
||||
$self->saveParams($userId, $self->authMethod,
|
||||
{ identifier => $self->hashPassword($password),
|
||||
passwordLastUpdated => $self->session->datetime->time });
|
||||
passwordLastUpdated => time });
|
||||
$self->_logSecurityMessage;
|
||||
|
||||
# delete the emailRecoverPasswordVerificationNumber
|
||||
|
|
@ -1236,7 +1267,7 @@ sub resetExpiredPasswordSave {
|
|||
return $self->resetExpiredPassword($u->userId, "<h1>".$i18n->get(70)."</h1><ul>".$error.'</ul>') if ($error);
|
||||
|
||||
$properties->{identifier} = $self->hashPassword($self->session->form->process("identifier"));
|
||||
$properties->{passwordLastUpdated} =$self->session->datetime->time();
|
||||
$properties->{passwordLastUpdated} =time();
|
||||
|
||||
$self->saveParams($u->userId,$self->authMethod,$properties);
|
||||
$self->_logSecurityMessage();
|
||||
|
|
@ -1299,7 +1330,7 @@ sub updateAccount {
|
|||
}
|
||||
|
||||
if($error){
|
||||
$display = $error;
|
||||
$display = '<ul>'.$error.'</ul>';
|
||||
}
|
||||
|
||||
my $properties;
|
||||
|
|
@ -1314,7 +1345,7 @@ sub updateAccount {
|
|||
$properties->{identifier} = $self->hashPassword($password);
|
||||
$self->_logSecurityMessage();
|
||||
if($userData->{identifier} ne $properties->{identifier}){
|
||||
$properties->{passwordLastUpdated} =$self->session->datetime->time();
|
||||
$properties->{passwordLastUpdated} =time();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,9 +170,9 @@ sub new {
|
|||
my $webguiPath = Cwd::realpath(shift);
|
||||
my $filename = shift;
|
||||
my $noCache = shift;
|
||||
my $fullPath = $webguiPath.'/etc/'.$filename;
|
||||
if (exists $config{$filename}) {
|
||||
return $config{$filename};
|
||||
my $fullPath = Cwd::realpath($webguiPath.'/etc/'.$filename);
|
||||
if (exists $config{$fullPath}) {
|
||||
return $config{$fullPath};
|
||||
} else {
|
||||
my $self = Config::JSON->new($fullPath);
|
||||
register($self, $class);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,9 @@ sub handler {
|
|||
my $asset = getAsset($session, getRequestedAssetUrl($session));
|
||||
|
||||
# display from cache if page hasn't been modified.
|
||||
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
|
||||
if ($var->get("userId") eq "1"
|
||||
&& defined $asset
|
||||
&& !$http->ifModifiedSince($asset->getContentLastModified, $session->setting->get('maxCacheTimeout'))) {
|
||||
$http->setStatus("304","Content Not Modified");
|
||||
$http->sendHeader;
|
||||
$session->close;
|
||||
|
|
|
|||
|
|
@ -20,17 +20,20 @@ Gets a select box to choose a class name.
|
|||
|
||||
sub getClassSelectBox {
|
||||
my $session = shift;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
||||
tie my %classes, "Tie::IxHash", (
|
||||
"" => "Any Class",
|
||||
"" => $i18n->get("Any Class"),
|
||||
$session->db->buildHash("select distinct(className) from asset"),
|
||||
);
|
||||
delete $classes{"WebGUI::Asset"}; # don't want to search for the root asset
|
||||
|
||||
my $className = $session->form->process("class","className") || $session->scratch->get('assetManagerSearchClassName');
|
||||
$session->scratch->set('assetManagerSearchClassName', $className);
|
||||
return WebGUI::Form::selectBox( $session, {
|
||||
name => "class",
|
||||
value => $session->form->process("class","className"),
|
||||
defaultValue => "",
|
||||
name => "class",
|
||||
value => $className,
|
||||
defaultValue => "",
|
||||
options => \%classes,
|
||||
});
|
||||
}
|
||||
|
|
@ -143,8 +146,10 @@ sub getSearchPaginator {
|
|||
$queryString .= ';class=' . $class;
|
||||
}
|
||||
|
||||
my $p = $s->getPaginatorResultSet( $session->url->page( $queryString ) );
|
||||
my $pageNumber = $session->form->get('pn') || $session->scratch->get('assetManagerSearchPageNumber');
|
||||
my $p = $s->getPaginatorResultSet( $session->url->page( $queryString ), undef, $pageNumber );
|
||||
|
||||
$session->scratch->set('assetManagerSearchPageNumber', $pageNumber);
|
||||
return $p;
|
||||
}
|
||||
|
||||
|
|
@ -170,56 +175,56 @@ sub getMoreMenu {
|
|||
# These links are shown based on UI level
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "changeUrl" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=changeUrl;proceed=manageAssets',
|
||||
url => 'func=changeUrl;proceed=manageAssets',
|
||||
label => $i18n->get( 'change url' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "editBranch" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=editBranch',
|
||||
url => 'func=editBranch',
|
||||
label => $i18n->get( 'edit branch' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "shortcut" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=createShortcut;proceed=manageAssets',
|
||||
url => 'func=createShortcut;proceed=manageAssets',
|
||||
label => $i18n->get( 'create shortcut' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "revisions" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=manageRevisions',
|
||||
url => 'func=manageRevisions',
|
||||
label => $i18n->get( 'revisions' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "view" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>',
|
||||
url => '',
|
||||
label => $i18n->get( 'view' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "edit" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=edit;proceed=manageAssets',
|
||||
url => 'func=edit;proceed=manageAssets',
|
||||
label => $i18n->get( 'edit' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $userUiLevel >= $toolbarUiLevel->{ "lock" } ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=lock;proceed=manageAssets',
|
||||
url => 'func=lock;proceed=manageAssets',
|
||||
label => $i18n->get( 'lock' ),
|
||||
};
|
||||
}
|
||||
|
||||
if ( $session->config->get("exportPath") && $userUiLevel >= $toolbarUiLevel->{"export"} ) {
|
||||
push @more_fields, {
|
||||
url => '<url>?func=export',
|
||||
url => 'func=export',
|
||||
label => $i18n->get( 'Export Page' ),
|
||||
};
|
||||
}
|
||||
|
|
@ -407,11 +412,11 @@ ENDHTML
|
|||
<div id="dataTableContainer">
|
||||
</div>
|
||||
<p class="actions"> %s
|
||||
<input type="submit" name="action_update" value="%s" onclick="this.form.func.value='setRanks'; this.form.submit();" />
|
||||
<input type="submit" name="action_delete" value="%s" onclick="if( confirm('%s')){ this.form.func.value='deleteList'; this.form.submit(); }{ return false; }" />
|
||||
<input type="submit" name="action_cut" value="%s" onclick="this.form.func.value='cutList'; this.form.submit();"/>
|
||||
<input type="submit" name="action_copy" value="%s" onclick="this.form.func.value='copyList'; this.form.submit();"/>
|
||||
<input type="submit" name="action_duplicate" value="%s" onclick="this.form.func.value='duplicateList'; this.form.submit();"/>
|
||||
<input type="submit" name="action_update" value="%s" onclick="this.form.func.value='setRanks'; this.form.submit(); return false;" />
|
||||
<input type="submit" name="action_delete" value="%s" onclick="if( confirm('%s')){ this.form.func.value='deleteList'; this.form.submit(); return false;}{ return false; }" />
|
||||
<input type="submit" name="action_cut" value="%s" onclick="this.form.func.value='cutList'; this.form.submit(); return false;"/>
|
||||
<input type="submit" name="action_copy" value="%s" onclick="this.form.func.value='copyList'; this.form.submit(); return false;"/>
|
||||
<input type="submit" name="action_duplicate" value="%s" onclick="this.form.func.value='duplicateList'; this.form.submit(); return false;"/>
|
||||
</p>
|
||||
</form>
|
||||
<div id="pagination">
|
||||
|
|
@ -534,64 +539,36 @@ sub www_search {
|
|||
$session->style->setScript( $session->url->extras( 'yui/build/yahoo-dom-event/yahoo-dom-event.js' ) );
|
||||
$session->style->setScript( $session->url->extras( 'yui-webgui/build/assetManager/assetManager.js' ) );
|
||||
$session->style->setScript( $session->url->extras( 'yui-webgui/build/form/form.js' ) );
|
||||
my $keywords = $session->form->get('keywords') || $session->scratch->get('assetManagerSearchKeywords');
|
||||
|
||||
### Show the form
|
||||
$output .= q{<form method="post" enctype="multipart/form-data" action="} . $currentAsset->getUrl . q{"><p>}
|
||||
. q{<input type="hidden" name="op" value="assetManager" />}
|
||||
. q{<input type="hidden" name="method" value="search" />}
|
||||
. q{<input type="text" size="45" name="keywords" value="} . $session->form->get('keywords') . q{" />}
|
||||
. q{<input type="text" size="45" name="keywords" value="} . $keywords . q{" />}
|
||||
. getClassSelectBox( $session )
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( "search" ).q{" />}
|
||||
. q{</p></form>}
|
||||
;
|
||||
|
||||
### Actions
|
||||
if ( my $action = lc $session->form->get( 'action' ) ) {
|
||||
my @assetIds = $session->form->get( 'assetId' );
|
||||
|
||||
if ( $action eq "delete" ) { ##aka trash
|
||||
for my $assetId ( @assetIds ) {
|
||||
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
||||
next unless $asset;
|
||||
$asset->trash;
|
||||
}
|
||||
}
|
||||
elsif ( $action eq "cut" ) {
|
||||
for my $assetId ( @assetIds ) {
|
||||
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
||||
next unless $asset;
|
||||
$asset->cut;
|
||||
}
|
||||
}
|
||||
elsif ( $action eq "copy" ) {
|
||||
for my $assetId ( @assetIds ) {
|
||||
# Copy == Duplicate + Cut
|
||||
my $asset = WebGUI::Asset->newById( $session, $assetId);
|
||||
my $newAsset = $asset->duplicate( { skipAutoCommitWorkflows => 1 } );
|
||||
$newAsset->update( { title => $newAsset->getTitle . ' (copy)' } );
|
||||
$newAsset->cut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### Run the search
|
||||
if ( $session->form->get( 'keywords' ) || $session->form->get( 'class' ) ) {
|
||||
my $keywords = $session->form->get( 'keywords' );
|
||||
my @classes = $session->form->get( 'class' );
|
||||
if ( $keywords || $session->form->get( 'class' ) ) {
|
||||
my @classes = $session->form->get( 'class' );
|
||||
my $keywordsScrubbed = $keywords;
|
||||
|
||||
# Detect a helper word key
|
||||
my @assetIds = ($keywords =~ /assetid:\s*([^\s]+)/gi);
|
||||
|
||||
# purge helper word keys
|
||||
if (@assetIds) {
|
||||
$keywords =~ s/\bassetid:\s*[^\s]+//gi;
|
||||
$keywordsScrubbed =~ s/\bassetid:\s*[^\s]+//gi;
|
||||
}
|
||||
$keywords =~ s/^\s+//g;
|
||||
$keywords =~ s/\s+$//g;
|
||||
$keywordsScrubbed =~ s/^\s+//g;
|
||||
$keywordsScrubbed =~ s/\s+$//g;
|
||||
|
||||
my $p = getSearchPaginator( $session, {
|
||||
assetIds => \@assetIds,
|
||||
keywords => $keywords,
|
||||
keywords => $keywordsScrubbed,
|
||||
classes => \@classes,
|
||||
orderByColumn => $session->form->get( 'orderByColumn' ),
|
||||
orderByDirection => $session->form->get( 'orderByDirection' ),
|
||||
|
|
@ -602,9 +579,10 @@ sub www_search {
|
|||
}
|
||||
else {
|
||||
### Display the search results
|
||||
$output .= q{<form method="post" enctype="multipart/form-data">}
|
||||
. q{<input type="hidden" name="op" value="assetManager" />}
|
||||
. q{<input type="hidden" name="method" value="search" />}
|
||||
$output .= q{<form method="post" enctype="multipart/form-data" action="}.$currentAsset->getUrl.q{">}
|
||||
. q{<input type="hidden" name="func" value="searchAssets" />}
|
||||
. q{<input type="hidden" name="proceed" value="searchAssets" />}
|
||||
. WebGUI::Form::CsrfToken->new($session)->toHtml
|
||||
. q{<input type="hidden" name="pn" value="} . $session->form->get('pn') . q{" />}
|
||||
. q{<input type="hidden" name="keywords" value="} . $keywords . q{" />}
|
||||
;
|
||||
|
|
@ -708,9 +686,9 @@ sub www_search {
|
|||
$output .= q{</tbody>}
|
||||
. q{</table>}
|
||||
. q{<p class="actions">} . $i18n->get( 'with selected' )
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( 'delete' ) . q{" />}
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( "cut" ) . q{" />}
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( "Copy" ) .q{" />}
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( 'delete' ) . q[" onclick="if(confirm('].$i18n->get('43').q[')){this.form.func.value='deleteList'; this.form.submit();}{ return false; }" />]
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( "cut" ) . q{" onclick="this.form.func.value='cutList'; this.form.submit();" />}
|
||||
. q{<input type="submit" name="action" value="}.$i18n->get( "Copy" ) .q{" onclick="this.form.func.value='copyList'; this.form.submit();" />}
|
||||
. q{</p>}
|
||||
. q{</form>}
|
||||
;
|
||||
|
|
@ -731,6 +709,7 @@ sub www_search {
|
|||
|
||||
$output .= '</div>';
|
||||
|
||||
$session->scratch->set('assetManagerSearchKeywords', $keywords);
|
||||
return $ac->render( $output );
|
||||
}
|
||||
|
||||
|
|
|
|||
83
lib/WebGUI/Content/SetLanguage.pm
Normal file
83
lib/WebGUI/Content/SetLanguage.pm
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
package WebGUI::Content::SetLanguage;
|
||||
|
||||
=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 WebGUI::Session;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Content::SetLanguage
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Sets or delete an scratch variable that overrides the profile field language
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Content::SetLanguage;
|
||||
WebGUI::Content::SetLanguage::handler();
|
||||
|
||||
=head1 SUBROUTINES
|
||||
|
||||
These subroutines are available from this package:
|
||||
|
||||
handler
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------
|
||||
|
||||
=head2 handler ( session, op, setLanguage )
|
||||
|
||||
sets or delete scratch variable in a session and returns undef
|
||||
|
||||
=head3 session
|
||||
|
||||
The current WebGUI::Session object.
|
||||
|
||||
=head3 op
|
||||
|
||||
op should be setLanguage to call the handler
|
||||
|
||||
=head3 language
|
||||
|
||||
language should be an installed language or delete
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub handler {
|
||||
my ($session) = @_;
|
||||
return undef unless $session->form->get('op') eq 'setLanguage';
|
||||
my $language = $session->form->get('language');
|
||||
#check whether a language has been given in the url
|
||||
if (!$language) {
|
||||
$session->log->error('There is no language given to this method');
|
||||
return undef;
|
||||
}
|
||||
#make it possible to delete the language scratch variable from the session
|
||||
if ($language eq 'delete' ) {
|
||||
$session->scratch->removeLanguageOverride;
|
||||
return undef;
|
||||
}
|
||||
#set a scratch variable language or throw error if language is not installed
|
||||
else {
|
||||
return $session->scratch->setLanguageOverride($language);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
|
@ -111,21 +111,44 @@ The current WebGUI::Session object.
|
|||
|
||||
sub handler {
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
unless ($session->setting->get("specialState") eq "init") {
|
||||
return undef;
|
||||
}
|
||||
$session->http->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new($session, "WebGUI");
|
||||
my ($output,$legend) = "";
|
||||
if ($session->form->process("step") eq "2") {
|
||||
if ($form->process("step") eq "2") {
|
||||
$legend = $i18n->get('company information');
|
||||
|
||||
my $timezone = $form->timeZone("timeZone");
|
||||
my $language = $form->selectBox("language");
|
||||
|
||||
##update Admin and Visitor users
|
||||
my $u = WebGUI::User->new($session,"3");
|
||||
$u->username($session->form->process("username","text","Admin"));
|
||||
$u->profileField("email",$session->form->email("email"));
|
||||
$u->profileField("timeZone",$session->form->timeZone("timeZone"));
|
||||
$u->identifier(Digest::MD5::md5_base64($session->form->process("identifier","password","123qwe")));
|
||||
$u->username($form->process("username","text","Admin"));
|
||||
$u->profileField("email",$form->email("email"));
|
||||
$u->profileField("timeZone",$timezone);
|
||||
$u->profileField("language",$language);
|
||||
$u->identifier(Digest::MD5::md5_base64($form->process("identifier","password","123qwe")));
|
||||
|
||||
$u = WebGUI::User->new($session,"1");
|
||||
$u->profileField("timeZone",$session->form->timeZone("timeZone"));
|
||||
$u->profileField("timeZone",$timezone);
|
||||
$u->profileField("language",$language);
|
||||
|
||||
##update ProfileField defaults so new users the get the defaults, too
|
||||
my $properties;
|
||||
|
||||
my $zoneField = WebGUI::ProfileField->new($session, 'timeZone');
|
||||
$properties = $zoneField->get();
|
||||
$properties->{dataDefault} = $timezone;
|
||||
$zoneField->set($properties);
|
||||
|
||||
my $languageField = WebGUI::ProfileField->new($session, 'language');
|
||||
$properties = $languageField->get();
|
||||
$properties->{dataDefault} = $language;
|
||||
$languageField->set($properties);
|
||||
|
||||
my $f = WebGUI::HTMLForm->new($session,action=>$session->url->gateway());
|
||||
$f->hidden( name=>"step", value=>"3");
|
||||
$f->text(
|
||||
|
|
@ -515,9 +538,17 @@ a:visited { color: '.$form->get("visitedLinkColor").'; }
|
|||
-hoverHelp=>$i18n->get('56 description'),
|
||||
);
|
||||
$f->timeZone(
|
||||
-name=>"timeZone",
|
||||
-value=>$u->profileField("timeZone"),
|
||||
-label=>$i18n->get('timezone','DateTime'),
|
||||
-name => "timeZone",
|
||||
-value => $u->profileField("timeZone"),
|
||||
-label => $i18n->get('timezone','DateTime'),
|
||||
-hoverHelp => $i18n->get('timezone help'),
|
||||
);
|
||||
$f->selectBox(
|
||||
-name => "language",
|
||||
-value => $u->profileField("language"),
|
||||
-label => $i18n->get('304'),
|
||||
-hoverHelp => $i18n->get('language help'),
|
||||
-options => $i18n->getLanguages(),
|
||||
);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package WebGUI::Content::SiteIndex;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Exception;
|
||||
use XML::Simple;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -53,17 +54,28 @@ sub handler {
|
|||
unless ($p =~ m/sitemap\.xml$/i) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $whereClause = "assetData.groupIdView = 7";
|
||||
if (! $session->config->get("siteIndex")->{showHiddenPages}) {
|
||||
$whereClause .= ' AND assetData.isHidden=0';
|
||||
}
|
||||
|
||||
my $pages = WebGUI::Asset->getRoot($session)->getLineage(["self","descendants"],{
|
||||
my $pages = WebGUI::Asset->getRoot($session)->getLineageIterator(["self","descendants"],{
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ["WebGUI::Asset::Wobject::Layout"],
|
||||
whereClause => "assetData.groupIdView = 7",
|
||||
whereClause => $whereClause,
|
||||
limit => 20000
|
||||
});
|
||||
|
||||
|
||||
my $url = [];
|
||||
foreach my $page (@{$pages}) {
|
||||
ASSET: while (1) {
|
||||
my $page = eval { $pages->() };
|
||||
if (my $e = Exception::Class->caught()) {
|
||||
$session->log->error($@);
|
||||
next ASSET;
|
||||
}
|
||||
last ASSET unless $page;
|
||||
push(@{$url},{
|
||||
loc => $session->url->getSiteURL().formatXML($page->getUrl),
|
||||
lastmod => $session->datetime->epochToSet($page->get("revisionDate")),
|
||||
|
|
@ -112,4 +124,3 @@ sub formatXML {
|
|||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -337,11 +337,10 @@ is reserved for the WebGUI database.
|
|||
=cut
|
||||
|
||||
sub new {
|
||||
my ($class, $databaseLinkId, %databaseLink);
|
||||
tie %databaseLink, 'Tie::CPHash';
|
||||
$class = shift;
|
||||
my $session = shift;
|
||||
$databaseLinkId = shift;
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $databaseLinkId = shift;
|
||||
tie my %databaseLink, 'Tie::CPHash';
|
||||
unless ($databaseLinkId eq "") {
|
||||
if ($databaseLinkId eq "0") {
|
||||
%databaseLink = (
|
||||
|
|
|
|||
|
|
@ -137,9 +137,11 @@ sub new
|
|||
|
||||
#use Data::Dumper;
|
||||
#warn "Args to DateTime->new: ".Dumper \@_;
|
||||
|
||||
if (@_ > 1 && grep /^mysql$/, @_)
|
||||
{
|
||||
|
||||
if (! scalar(@_) || $_[0] eq '') {
|
||||
$self = $class->SUPER::now();
|
||||
}
|
||||
elsif (@_ > 1 && grep /^mysql$/, @_) {
|
||||
my %hash = @_;
|
||||
$hash{time_zone} ||= "UTC";
|
||||
my $string = delete $hash{mysql};
|
||||
|
|
@ -149,12 +151,10 @@ sub new
|
|||
|
||||
$self = $class->SUPER::new(%hash);
|
||||
}
|
||||
elsif (@_ > 1)
|
||||
{
|
||||
elsif (@_ > 1) {
|
||||
$self = $class->SUPER::new(@_);
|
||||
}
|
||||
elsif ($_[0] =~ /^\d+$/)
|
||||
{
|
||||
elsif ($_[0] =~ /^-?\d+$/) {
|
||||
$self = DateTime->from_epoch(epoch=>$_[0], time_zone=>"UTC", locale=>$locale);
|
||||
}
|
||||
else {
|
||||
|
|
@ -594,19 +594,27 @@ sub _splitMysql
|
|||
|
||||
@hash{ qw( year month day hour minute second ) }
|
||||
= $string =~ m{
|
||||
(\d+) # Year
|
||||
^
|
||||
\D*
|
||||
(\d+) # Month
|
||||
(\d{1,4}) # Year
|
||||
\D+
|
||||
(\d{1,2}) # Month
|
||||
\D+
|
||||
(\d{1,2}) # Day
|
||||
(?: \D+
|
||||
(\d{1,2}) # Hours
|
||||
\D+
|
||||
(\d{1,2}) # Minutes
|
||||
\D+
|
||||
(\d{1,2}) # Seconds
|
||||
)?
|
||||
\D*
|
||||
(\d+) # Day
|
||||
\D*
|
||||
(\d+) # Hours
|
||||
\D*
|
||||
(\d+) # Minutes
|
||||
\D*
|
||||
(\d+) # Seconds
|
||||
$
|
||||
}x;
|
||||
|
||||
$hash{ hour } ||= 0;
|
||||
$hash{ minute } ||= 0;
|
||||
$hash{ second } ||= 0;
|
||||
return %hash;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,60 @@ package WebGUI::Exception;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Exception::Class (
|
||||
|
||||
'WebGUI::Error' => {
|
||||
description => "A general error occured.",
|
||||
},
|
||||
'WebGUI::Error::OverrideMe' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => 'This method should be overridden by subclasses.',
|
||||
},
|
||||
'WebGUI::Error::MethodNotFound' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => q|Called a method that doesn't exist.|,
|
||||
fields => 'method'
|
||||
},
|
||||
'WebGUI::Error::InvalidObject' => {
|
||||
isa => 'WebGUI::Error::InvalidParam',
|
||||
description => "Expected to get a reference to an object type that wasn't gotten.",
|
||||
fields => ["expected","got"],
|
||||
},
|
||||
'WebGUI::Error::InvalidParam' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "Expected to get a param we didn't get.",
|
||||
fields => ["param"],
|
||||
},
|
||||
'WebGUI::Error::ObjectNotFound' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "The object you were trying to retrieve does not exist.",
|
||||
fields => ["id"],
|
||||
},
|
||||
'WebGUI::Error::ObjectNotFound::Template' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "The template an asset was trying to retrieve does not exist.",
|
||||
fields => [qw/templateId assetId/],
|
||||
},
|
||||
'WebGUI::Error::InvalidFile' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "The file you have provided has errors.",
|
||||
fields => [qw{ brokenFile brokenLine }],
|
||||
},
|
||||
'WebGUI::Error::Template' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "A template has errors that prevent it from being processed.",
|
||||
},
|
||||
);
|
||||
|
||||
sub WebGUI::Error::full_message {
|
||||
my $self = shift;
|
||||
my $message = $self->message ? $self->message : $self->description;
|
||||
my @fields = map { defined $self->$_ ? ($_ . ': ' . $self->$_) : () } $self->Fields;
|
||||
if (@fields) {
|
||||
$message .= ' (' . join( q{, }, @fields ) . ')';
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use File::Basename;
|
|||
use CSS::Minifier::XS;
|
||||
use JavaScript::Minifier::XS;
|
||||
use LWP;
|
||||
use DateTime::Format::HTTP;
|
||||
use Data::Dumper;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -618,9 +619,10 @@ sub fetchHttp {
|
|||
if (! $response->is_success) {
|
||||
return {};
|
||||
}
|
||||
my $lastModified =
|
||||
my $guts = {
|
||||
content => $response->content,
|
||||
lastModified => $response->header('last-modified'),
|
||||
lastModified => DateTime::Format::HTTP->parse_datetime($response->header('last-modified'))->epoch,
|
||||
};
|
||||
return $guts;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ sub toHtml {
|
|||
my $pubKey = $self->session->setting->get('recaptchaPublicKey');
|
||||
my $server = "http://api.recaptcha.net";
|
||||
if ($env->sslRequest) {
|
||||
$server = "http://api-secure.recaptcha.net";
|
||||
$server = "https://api-secure.recaptcha.net";
|
||||
}
|
||||
return
|
||||
'<script type="text/javascript" src="' . $server . '/challenge?k=' . $pubKey . '"></script>'
|
||||
|
|
@ -178,8 +178,9 @@ sub toHtml {
|
|||
my ($filename, $challenge) = $storage->addFileFromCaptcha;
|
||||
$self->set("size", 6);
|
||||
$self->set("maxlength", 6);
|
||||
$self->set("extras", 'class="wg-captchaForm"');
|
||||
$self->session->scratch->set("captcha_".$self->get("name"), $challenge);
|
||||
return $self->SUPER::toHtml.'<p style="display:inline;vertical-align:middle;"><img src="'.$storage->getUrl($filename).'" style="border-style:none;vertical-align:middle;" alt="captcha" /></p>';
|
||||
return $self->SUPER::toHtml.'<img src="'.$storage->getUrl($filename).'" class="wg-captchaImage" alt="captcha" />';
|
||||
}
|
||||
|
||||
=head2 getErrorMessage ( )
|
||||
|
|
|
|||
|
|
@ -169,14 +169,19 @@ sub toHtml {
|
|||
$style->setScript($url->extras("yui/build/resize/resize-min.js"),{type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui/build/editor/editor-min.js"),{type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui-webgui/build/code-editor/code-editor.js"),{type=>"text/javascript"});
|
||||
#$style->setLink($url->extras("yui/build/logger/assets/logger.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
#$style->setLink($url->extras("yui/build/logger/assets/skins/sam/logger.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
#$style->setScript($url->extras("yui/build/logger/logger.js"),{type=>"text/javascript"});
|
||||
my $codeCss = $url->extras("yui-webgui/build/code-editor/code.css");
|
||||
my $out = <<"END_HTML";
|
||||
<textarea id="$id" name="$name" $extras rows="10" cols="60" style="font-family: monospace; $styleAttr; height: 100%; width: 100%; resize: none;">$value</textarea>
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
YAHOO.util.Event.onDOMReady( function () {
|
||||
var myeditor = new YAHOO.widget.CodeEditor('${id}', { handleSubmit: true, css_url: '${codeCss}', height: '${height}px', width: '${width}px', status: true, resize: true });
|
||||
var myeditor = new YAHOO.widget.CodeEditor('${id}', { toggleButton: true, handleSubmit: true, css_url: '${codeCss}', height: '${height}px', width: '${width}px', status: true, resize: true });
|
||||
myeditor.render();
|
||||
|
||||
//var myLogReader = new YAHOO.widget.LogReader();
|
||||
} );
|
||||
}());
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ sub toHtml {
|
|||
my $options = $self->getOptions;
|
||||
$options->{''} = '['.$i18n->get(582).']';
|
||||
$options->{_new_} = $i18n->get(581).'->';
|
||||
$self->set('options', $options);
|
||||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::Text->new($self->session,
|
||||
size=>$self->session->setting->get("textBoxSize")-5,
|
||||
|
|
|
|||
|
|
@ -116,18 +116,18 @@ sub getCountries {
|
|||
'Cayman Islands', 'Central African Republic',
|
||||
'Chad', 'Chile',
|
||||
'China', 'Christmas Island',
|
||||
'Cocos (Keeling) Islands', 'Colombia',
|
||||
'Comoros', 'Congo',
|
||||
'Congo, the Democratic Republic of the', 'Cook Islands',
|
||||
'Costa Rica', 'Cote d\'Ivoire',
|
||||
'Croatia', 'Cyprus',
|
||||
'Czech Republic', 'Denmark',
|
||||
'Djibouti', 'Dominica',
|
||||
'Dominican Republic', 'East Timor',
|
||||
'Ecuador', 'Egypt',
|
||||
'El Salvador', 'England',
|
||||
'Equatorial Guinea', 'Eritrea',
|
||||
'Espana', 'Estonia',
|
||||
'Christmas Island (Kiribati)', 'Cocos (Keeling) Islands',
|
||||
'Colombia', 'Comoros',
|
||||
'Congo', 'Congo, the Democratic Republic of the',
|
||||
'Cook Islands', 'Costa Rica',
|
||||
'Cote d\'Ivoire', 'Croatia',
|
||||
'Cyprus', 'Czech Republic',
|
||||
'Denmark', 'Djibouti',
|
||||
'Dominica', 'Dominican Republic',
|
||||
'East Timor', 'Ecuador',
|
||||
'Egypt', 'El Salvador',
|
||||
'England', 'Equatorial Guinea',
|
||||
'Eritrea', 'Estonia',
|
||||
'Ethiopia', 'Falkland Islands',
|
||||
'Faroe Islands', 'Fiji',
|
||||
'Finland', 'France',
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ sub getDataTableHtml {
|
|||
|
||||
### Prepare the columns data
|
||||
my %parsers = (
|
||||
date => "YAHOO.util.DataSource.parseDate",
|
||||
date => "YAHOO.lang.JSON.stringToDate",
|
||||
number => "YAHOO.util.DataSource.parseNumber",
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ use base 'WebGUI::Form::Text';
|
|||
use WebGUI::Form::Hidden;
|
||||
use WebGUI::International;
|
||||
|
||||
my $isaEpoch = qr/^-?\d+$/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Date
|
||||
|
|
@ -80,7 +82,7 @@ sub definition {
|
|||
|
||||
push(@{$definition}, {
|
||||
defaultValue=>{
|
||||
defaultValue=>$session->datetime->time()
|
||||
defaultValue=>time()
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 10
|
||||
|
|
@ -137,9 +139,9 @@ sub getValue {
|
|||
my $self = shift;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ m/^\d+$/) {
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ $isaEpoch) {
|
||||
# Epoch format
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $value;
|
||||
}
|
||||
return $self->session->datetime->setToEpoch($value);
|
||||
|
|
@ -150,10 +152,7 @@ sub getValue {
|
|||
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
|
||||
# MySQL format
|
||||
# YY(YY)?-MM-DD HH:MM:SS
|
||||
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $self->session->datetime->epochToSet($value,$self->session->user->profileField( 'timeZone' ));
|
||||
}
|
||||
|
||||
|
|
@ -173,17 +172,17 @@ Return the date in a human readable format.
|
|||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
return $self->session->datetime->epochToHuman($self->getOriginalValue,"%z");
|
||||
}
|
||||
if ( !$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ $isaEpoch
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ $isaEpoch) {
|
||||
return $self->session->datetime->epochToHuman($self->getOriginalValue, '%z');
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
my $value = $self->getOriginalValue;
|
||||
# MySQL format
|
||||
my $value = $self->getOriginalValue;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
@ -217,23 +216,15 @@ sub toHtml {
|
|||
# No default date
|
||||
$value = $self->set("value",'');
|
||||
}
|
||||
elsif (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $session->datetime->epochToSet($self->getOriginalValue);
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
$value = eval { WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate; };
|
||||
$value = WebGUI::DateTime->new($session,0)->toMysqlDate if $value eq '';
|
||||
}
|
||||
|
||||
my $style = $session->style;
|
||||
my $url = $session->url;
|
||||
$style->setLink($url->extras('yui/build/calendar/assets/skins/sam/calendar.css'), { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
$style->setScript($url->extras('/yui/build/utilities/utilities.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/utilities/utilities.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/dom/dom-min.js'), { type => 'text/javascript' });
|
||||
|
|
@ -262,25 +253,13 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value;
|
||||
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
$value = $self->session->datetime->epochToSet($self->getOriginalValue,"%z");
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
}
|
||||
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $value = WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate;
|
||||
return WebGUI::Form::Hidden->new($session,
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ use WebGUI::Form::Hidden;
|
|||
use WebGUI::International;
|
||||
use WebGUI::DateTime;
|
||||
|
||||
my $isaEpoch = qr/^-?\d+$/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::DateTime
|
||||
|
|
@ -82,7 +84,7 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
push(@{$definition}, {
|
||||
defaultValue=>{
|
||||
defaultValue=>$session->datetime->time()
|
||||
defaultValue=>time()
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 19
|
||||
|
|
@ -139,9 +141,9 @@ sub getValue {
|
|||
# This should probably be rewritten as a cascading ternary
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ m/^\d+$/) {
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ $isaEpoch) {
|
||||
# Epoch format
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $value;
|
||||
}
|
||||
return $self->session->datetime->setToEpoch($value);
|
||||
|
|
@ -150,7 +152,7 @@ sub getValue {
|
|||
# MySQL format
|
||||
# YY(YY)?-MM-DD HH:MM:SS
|
||||
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $self->session->datetime->epochToSet($value,$self->session->user->profileField( 'timeZone' ));
|
||||
}
|
||||
|
||||
|
|
@ -178,8 +180,10 @@ Return the date in a human readable format.
|
|||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
my $formatValue = $self->getDefaultValue || $self->getOriginalValue;
|
||||
if (!$formatValue || $formatValue =~ m/^\d+$/) {
|
||||
if ( !$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ $isaEpoch
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ $isaEpoch) {
|
||||
return $self->session->datetime->epochToHuman($self->getOriginalValue,"%z %Z");
|
||||
}
|
||||
else {
|
||||
|
|
@ -216,22 +220,10 @@ Renders a date picker control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $value;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $session->datetime->epochToSet($self->getOriginalValue,1);
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# Fix time zone
|
||||
$value = WebGUI::DateTime->new($session, mysql => $value)
|
||||
->set_time_zone($self->get("timeZone"))
|
||||
->strftime("%Y-%m-%d %H:%M:%S");
|
||||
}
|
||||
my $value = eval { WebGUI::DateTime->new($session, $self->getOriginalValue); };
|
||||
$value = WebGUI::DateTime->new($session,0) if $value eq '';
|
||||
$value = $value->set_time_zone($self->get("timeZone"))->strftime("%Y-%m-%d %H:%M:%S");
|
||||
|
||||
my $style = $session->style;
|
||||
my $url = $session->url;
|
||||
$style->setLink($url->extras('yui/build/calendar/assets/skins/sam/calendar.css'), { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
|
|
@ -245,12 +237,12 @@ sub toHtml {
|
|||
$style->setScript($url->extras('yui-webgui/build/datepicker/datepicker.js'),{ type => 'text/javascript' });
|
||||
|
||||
return WebGUI::Form::Text->new($self->session,
|
||||
name=>$self->get("name"),
|
||||
value=>$value,
|
||||
size=>$self->get("size"),
|
||||
extras=>$self->get("extras") . ' onfocus="YAHOO.WebGUI.Form.DatePicker.display(this, true);"',
|
||||
id=>$self->get('id'),
|
||||
maxlength=>$self->get("maxlength")
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
size => $self->get("size"),
|
||||
extras => $self->get("extras") . ' onfocus="YAHOO.WebGUI.Form.DatePicker.display(this, true);"',
|
||||
id => $self->get('id'),
|
||||
maxlength => $self->get("maxlength")
|
||||
)->toHtml;
|
||||
}
|
||||
|
||||
|
|
@ -263,28 +255,15 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value;
|
||||
my $self = shift;
|
||||
my $value = WebGUI::DateTime->new($self->session, $self->getOriginalValue)
|
||||
->set_time_zone($self->get("timeZone"))
|
||||
->strftime("%Y-%m-%d %H:%M:%S");
|
||||
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
$value = $self->session->datetime->epochToSet($self->getOriginalValue,1);
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# Fix Time zone
|
||||
$value = WebGUI::DateTime->new($self->session, mysql => $value)
|
||||
->set_time_zone($self->get("timeZone"))
|
||||
->strftime("%Y-%m-%d %H:%M:%S");
|
||||
}
|
||||
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
114
lib/WebGUI/Form/Div.pm
Normal file
114
lib/WebGUI/Form/Div.pm
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
package WebGUI::Form::Div;
|
||||
|
||||
=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::Form::Control';
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Div
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
dreates a HTML div element with contents provided by caller
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::Control.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 usage
|
||||
|
||||
$form->div({
|
||||
contentCallback => sub { $self->getDivContents(shift); }
|
||||
});
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 contentCallback
|
||||
|
||||
A code enclosure which returns the html text to insert into the div element. The divId is passed as parameter 0 when it is called. This function MUST return good html text, it is NOT processed here at all.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
push(@{$definition}, {
|
||||
contentCallback=>{
|
||||
defaultValue=> sub { return '' },
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the name of the form control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($class, $session) = @_;
|
||||
return WebGUI::International->new($session, "Form_Div")->get("topicName");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Does some special processing.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return $self->get('contentCallback')->($self->get('id'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an input tag of type text.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
return '<div id="'.$self->get('id').'" name="'.$self->get("name").'" '.$self->get("extras").'>' . $self->getValue . '</div>' ;
|
||||
}
|
||||
|
||||
1;
|
||||
#vim:ft=perl
|
||||
|
|
@ -172,7 +172,7 @@ sub toHtml {
|
|||
my $richEdit = eval { WebGUI::Asset::RichEdit->newById($self->session, $self->get("richEditId")); };
|
||||
if (! Exception::Class->caught() ) {
|
||||
$self->session->style->setScript($self->session->url->extras('textFix.js'),{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onblur="fixChars(this.form.'.$self->get("name").')" mce_editable="true" ');
|
||||
$self->set("extras", $self->get('extras') . q{ onblur="fixChars(this.form['}.$self->get("name").q{'])" mce_editable="true" });
|
||||
$self->set("resizable", 0);
|
||||
return $self->SUPER::toHtml.$richEdit->getRichEditor($self->get('id'));
|
||||
} else {
|
||||
|
|
@ -386,8 +386,8 @@ sub www_addFolderSave {
|
|||
title => $filename,
|
||||
menuTitle => $filename,
|
||||
url => $base->getUrl.'/'.$filename,
|
||||
groupIdEdit => $session->form->process('groupIdEdit') || $base->get('groupIdEdit'),
|
||||
groupIdView => $session->form->process('groupIdView') || $base->get('groupIdView'),
|
||||
groupIdEdit => $base->get('groupIdEdit'),
|
||||
groupIdView => $base->get('groupIdView'),
|
||||
ownerUserId => $session->user->userId,
|
||||
startDate => $base->get('startDate'),
|
||||
endDate => $base->get('endDate'),
|
||||
|
|
@ -410,6 +410,7 @@ sub www_addFolderSave {
|
|||
className => 'WebGUI::Asset::Wobject::Folder',
|
||||
#filename => $filename,
|
||||
});
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -495,6 +496,7 @@ sub www_addImageSave {
|
|||
$child->update({url => $child->fixUrl});
|
||||
$child->applyConstraints;
|
||||
}
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,29 @@ sub getName {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUnitOptions ( )
|
||||
|
||||
Returns a hash with i18n labels and values for units of time.
|
||||
|
||||
=cut
|
||||
|
||||
sub getUnitOptions {
|
||||
my $self = shift;
|
||||
tie my %units, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
%units = (seconds => $i18n->get(704),
|
||||
minutes => $i18n->get(705),
|
||||
hours => $i18n->get(706),
|
||||
days => $i18n->get(700),
|
||||
weeks => $i18n->get(701),
|
||||
months => $i18n->get(702),
|
||||
years => $i18n->get(703),
|
||||
);
|
||||
return %units;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ num_and_units ] )
|
||||
|
||||
Returns either the interval that was posted (in seconds) or if nothing comes back it returns 0.
|
||||
|
|
@ -165,17 +188,7 @@ Renders an interval control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my %units;
|
||||
tie %units, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
%units = (seconds => $i18n->get(704),
|
||||
minutes => $i18n->get(705),
|
||||
hours => $i18n->get(706),
|
||||
days => $i18n->get(700),
|
||||
weeks => $i18n->get(701),
|
||||
months => $i18n->get(702),
|
||||
years => $i18n->get(703),
|
||||
);
|
||||
my %units = $self->getUnitOptions();
|
||||
my %reverseUnits = reverse %units;
|
||||
my ($interval, $units) = $self->session->datetime->secondsToExactInterval($self->getOriginalValue);
|
||||
# not sure why, but these things need to be defined like this or
|
||||
|
|
@ -208,16 +221,20 @@ Returns the field as hidden controls rather than displayable controls.
|
|||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my ($interval, $units) = $self->session->datetime->secondsToExactInterval($self->getOriginalValue);
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name").'_interval',
|
||||
value=>$interval
|
||||
)->toHtmlAsHidden
|
||||
.WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name").'_units',
|
||||
value=>$units
|
||||
)->toHtmlAsHidden;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my %units = $self->getUnitOptions();
|
||||
my %reverseUnits = reverse %units;
|
||||
my ($interval, $units) = $session->datetime->secondsToExactInterval($self->getOriginalValue);
|
||||
my $unitVal = $reverseUnits{$units};
|
||||
return WebGUI::Form::Hidden->new($session,
|
||||
name => $self->get("name").'_interval',
|
||||
value => $interval,
|
||||
)->toHtmlAsHidden
|
||||
. WebGUI::Form::Hidden->new($session,
|
||||
name => $self->get("name").'_units',
|
||||
value => $unitVal,
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ sub toHtml {
|
|||
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
|
||||
$mimeTypes->{$_}=$_;
|
||||
}
|
||||
my $value = $self->getOriginalValue();
|
||||
$mimeTypes->{$value} = $value;
|
||||
$self->set("options", $mimeTypes);
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,19 +110,6 @@ sub getDefaultValue {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOriginalValue( [ value ] )
|
||||
|
||||
See WebGUI::Form::Control::getOriginalValue()
|
||||
|
||||
=cut
|
||||
|
||||
sub getOriginalValue{
|
||||
my $self = shift;
|
||||
return $self->WebGUI::Form::Control::getOriginalValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ Returns the form element used for manual input. You must overload this method.
|
|||
sub getInputElement {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Session must overload getInputElement");
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Slider must overload getInputElement");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -174,7 +174,7 @@ from this class. For instance WebGUI::Form::SelectSlider.
|
|||
sub getOnChangeInputElement {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Session must overload getOnChangeInputElement");
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Slider must overload getOnChangeInputElement");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -195,7 +195,7 @@ from this class. For instance WebGUI::Form::SelectSlider.
|
|||
sub getOnChangeSlider {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Session must overload getOnChangeSlider");
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Slider must overload getOnChangeSlider");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -95,6 +95,26 @@ sub isDynamicCompatible {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( )
|
||||
|
||||
Extend the base method to handle spaces in the value and/or default value.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = $class->SUPER::new(@_);
|
||||
my $value = $self->get('value');
|
||||
$value =~ tr/ /_/;
|
||||
$self->set('value', $value);
|
||||
my $defaultValue = $self->get('defaultValue');
|
||||
$defaultValue =~ tr/ /_/;
|
||||
$self->set('defaultValue', $defaultValue);
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a database connection picker control.
|
||||
|
|
|
|||
127
lib/WebGUI/Form/Username.pm
Normal file
127
lib/WebGUI/Form/Username.pm
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
package WebGUI::Form::Username;
|
||||
|
||||
=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::Form::Text';
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Username
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a text input box form field specifically for a user name.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::Text.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 maxlength
|
||||
|
||||
Defaults to 255. Determines the maximum number of characters allowed in this field.
|
||||
|
||||
=head4 size
|
||||
|
||||
Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big of a text box to display.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.
|
||||
|
||||
=head3 value
|
||||
|
||||
An optional value to process, instead of POST input.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a user name field.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->session->style->setScript($self->session->url->extras('form/fieldCheck.js'),{ type=>'text/javascript' });
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'), {type=>'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/connection/connection-min.js'), {type => 'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type=>'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/datasource/datasource-min.js'), {type=>'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui-webgui/build/i18n/i18n.js'), {type=>'text/javascript'});
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
$self->set("extras", $self->get('extras') . ' onblur="new WebGUI.FieldCheck(\''. $self->get("id").'\',\'Username\',1);"');
|
||||
return '<input id="'.$self->get('id').'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" maxlength="'.$self->get("maxlength").'" '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_check ($session)
|
||||
|
||||
www_check() is called by an Ajax call from the user registration page.
|
||||
|
||||
It checks whether a user name is free for registration. Returns a hash
|
||||
(error => $error)
|
||||
if the username is not free.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_check {
|
||||
my $session = shift;
|
||||
my $input = $session->form->param('input');
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
my $i18n = WebGUI::International->new($session, 'Form_Username');
|
||||
|
||||
my $error = '';
|
||||
my ($existingUserId) = $session->db->quickArray("select userId from users where username=".$session->db->quote($input));
|
||||
$error = $i18n->get('username in use') if $existingUserId;
|
||||
|
||||
my %checkResults = (error => $error);
|
||||
return JSON::encode_json(\%checkResults);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -82,6 +82,7 @@ sub getName {
|
|||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a validated form post result. If the result does not pass validation, it returns undef instead.
|
||||
Uppercases any lowercase letters.
|
||||
|
||||
=head3 value
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ sub getValue {
|
|||
my $self = shift;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
$value =~ tr/a-z/A-Z/d;
|
||||
if ($value =~ /^[A-Z\d\s\-]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -122,7 +124,7 @@ Renders a zip code field.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->session->style->setScript($self->session->url->extras('inputCheck.js'),{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(document.getElementById(\''.$self->get("id").'\'),\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')"');
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(document.getElementById(\''.$self->get("id").'\'),\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- \')"');
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ sub _defaults {
|
|||
my $self = shift;
|
||||
return {
|
||||
groupId=>"new",
|
||||
dateCreated=>$self->session->datetime->time(),
|
||||
dateCreated=>time(),
|
||||
expireOffset=>314496000,
|
||||
karmaThreshold=>1000000000,
|
||||
groupName=>"New Group",
|
||||
|
|
@ -100,7 +100,7 @@ sub _defaults {
|
|||
expireNotify=>0,
|
||||
databaseLinkId=>0,
|
||||
groupCacheTimeout=>3600,
|
||||
lastUpdated=>$self->session->datetime->time(),
|
||||
lastUpdated=>time(),
|
||||
autoAdd=>0,
|
||||
autoDelete=>0,
|
||||
isEditable=>1,
|
||||
|
|
@ -151,7 +151,7 @@ is updated.
|
|||
|
||||
=head3 users
|
||||
|
||||
An array reference containing a list of users.
|
||||
An array reference containing a list of userIds.
|
||||
|
||||
=head3 expireOffset
|
||||
|
||||
|
|
@ -167,10 +167,10 @@ sub addUsers {
|
|||
foreach my $uid (@{$users}) {
|
||||
my ($isIn) = $self->session->db->quickArray("select count(*) from groupings where groupId=? and userId=?", [$self->getId, $uid]);
|
||||
unless ($isIn) {
|
||||
$self->session->db->write("insert into groupings (groupId,userId,expireDate) values (?,?,?)", [$self->getId, $uid, ($self->session->datetime->time()+$expireOffset)]);
|
||||
$self->session->db->write("insert into groupings (groupId,userId,expireDate) values (?,?,?)", [$self->getId, $uid, (time()+$expireOffset)]);
|
||||
$self->session->stow->delete("gotGroupsForUser");
|
||||
} else {
|
||||
$self->userGroupExpireDate($uid,($self->session->datetime->time()+$expireOffset));
|
||||
$self->userGroupExpireDate($uid,(time()+$expireOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -733,14 +733,14 @@ sub getIpUsers {
|
|||
my $IpFilter;
|
||||
return [] unless $IpFilter = $self->ipFilter();
|
||||
|
||||
my $time = $self->session->datetime->time();
|
||||
my $time = time();
|
||||
|
||||
$IpFilter =~ s/\s//g;
|
||||
my @filters = split /;/, $IpFilter;
|
||||
|
||||
my $query = "select userId,lastIP from userSession where expires > ?";
|
||||
|
||||
my $sth = $self->session->db->read($query, [ $self->session->datetime->time() ]);
|
||||
my $sth = $self->session->db->read($query, [ time() ]);
|
||||
my %localCache = ();
|
||||
my @ipUsers = ();
|
||||
while (my ($userId, $lastIP) = $sth->array() ) {
|
||||
|
|
@ -838,7 +838,7 @@ sub getScratchUsers {
|
|||
my $scratchFilter;
|
||||
return [] unless $scratchFilter = $self->scratchFilter();
|
||||
|
||||
my $time = $self->session->datetime->time();
|
||||
my $time = time();
|
||||
|
||||
$scratchFilter =~ s/\s//g;
|
||||
my @filters = split /;/, $scratchFilter;
|
||||
|
|
@ -879,7 +879,7 @@ sub getUserList {
|
|||
my $withoutExpired = shift;
|
||||
my $expireTime = 0;
|
||||
if ($withoutExpired) {
|
||||
$expireTime = $self->session->datetime->time();
|
||||
$expireTime = time();
|
||||
}
|
||||
return $self->session->db->buildHashRef("select users.userId, users.username from users join groupings using(userId) where expireDate > ? and groupId = ? order by username asc", [$expireTime, $self->getId]);
|
||||
}
|
||||
|
|
@ -904,7 +904,7 @@ sub getUsers {
|
|||
my $withoutExpired = shift;
|
||||
my $expireTime = 0;
|
||||
if ($withoutExpired) {
|
||||
$expireTime = $self->session->datetime->time();
|
||||
$expireTime = time();
|
||||
}
|
||||
my @users = $self->session->db->buildArray("select userId from groupings where expireDate > ? and groupId = ?", [$expireTime, $self->getId]);
|
||||
return \@users;
|
||||
|
|
@ -939,7 +939,7 @@ sub getUsersNotIn {
|
|||
|
||||
my $expireTime = 0;
|
||||
if ($withoutExpired) {
|
||||
$expireTime = $self->session->datetime->time();
|
||||
$expireTime = time();
|
||||
}
|
||||
|
||||
my $sql = q{
|
||||
|
|
@ -1499,7 +1499,7 @@ sub set {
|
|||
my $value = shift;
|
||||
$self->get("groupId") unless ($self->{_group}); # precache group stuff
|
||||
$self->{_group}{$name} = $value;
|
||||
$self->session->db->setRow("groups","groupId",{groupId=>$self->getId, $name=>$value, lastUpdated=>$self->session->datetime->time()});
|
||||
$self->session->db->setRow("groups","groupId",{groupId=>$self->getId, $name=>$value, lastUpdated=>time()});
|
||||
$self->clearCaches;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ our $HELP = {
|
|||
variables => [
|
||||
{ name => "manage_purchases_url", },
|
||||
{ name => "managePurchasesIsActive", },
|
||||
{ name => "userIsVendor", },
|
||||
],
|
||||
related => [ ],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,20 +15,22 @@ our $HELP = {
|
|||
title => 'asset template asset var title',
|
||||
body => '',
|
||||
variables => [
|
||||
{ name => 'title', },
|
||||
{ name => 'assetId', },
|
||||
{ name => 'assetIdHex', },
|
||||
{ name => 'title', },
|
||||
{ name => 'menuTitle', },
|
||||
{ name => 'url', },
|
||||
{ name => 'isHidden', },
|
||||
{ name => 'url', },
|
||||
{ name => 'isHidden', },
|
||||
{ name => 'newWindow', },
|
||||
{ name => 'encryptPage', },
|
||||
{ name => 'ownerUserId', },
|
||||
{ name => 'groupIdView', },
|
||||
{ name => 'groupIdEdit', },
|
||||
{ name => 'synopsis', },
|
||||
{ name => 'synopsis', },
|
||||
{ name => 'extraHeadTags', },
|
||||
{ name => 'isPackage', },
|
||||
{ name => 'isPackage', },
|
||||
{ name => 'isPrototype', },
|
||||
{ name => 'status', },
|
||||
{ name => 'status', },
|
||||
{ name => 'assetSize', },
|
||||
{ name => 'keywords',
|
||||
description => 'keywords template var' },
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ our $HELP = {
|
|||
'view calendar template' => {
|
||||
title => 'view calendar title',
|
||||
body => 'view calendar body',
|
||||
private => '1',
|
||||
isa => [
|
||||
{ namespace => "Asset_Template",
|
||||
tag => "template variables"
|
||||
|
|
@ -66,6 +67,61 @@ our $HELP = {
|
|||
],
|
||||
},
|
||||
|
||||
'view month template' => {
|
||||
title => 'view calendar month title',
|
||||
body => 'view calendar month body',
|
||||
isa => [
|
||||
{ namespace => "Asset_Calendar",
|
||||
tag => "view calendar template"
|
||||
},
|
||||
],
|
||||
fields => [],
|
||||
variables => [
|
||||
{ 'name' => 'weeks',
|
||||
'variables' => [
|
||||
{ 'name' => 'days',
|
||||
'variables' => [
|
||||
{ 'name' => 'dayUrl' },
|
||||
{ 'name' => 'dayMonth',
|
||||
'description' => 'dayOfMonth' },
|
||||
{ 'name' => 'dayCurrent' },
|
||||
{ 'name' => 'events',
|
||||
'description' => 'events weekVar',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ 'name' => 'pageNextUrl',
|
||||
'description' => 'pageNextUrl monthVar'
|
||||
},
|
||||
{ 'name' => 'pagePrevUrl',
|
||||
'description' => 'pagePrevUrl monthVar'
|
||||
},
|
||||
{ 'name' => 'pageNextYear', },
|
||||
{ 'name' => 'pagePrevYear', },
|
||||
{ 'name' => 'monthName', },
|
||||
{ 'name' => 'monthAbbr', },
|
||||
{ 'name' => 'year' },
|
||||
{ 'name' => 'dayNames',
|
||||
'variables' => [
|
||||
{ 'name' => 'dayName' },
|
||||
{ 'name' => 'dayAbbr' },
|
||||
],
|
||||
},
|
||||
{ 'name' => 'months',
|
||||
'variables' => [
|
||||
{ 'name' => 'monthName' },
|
||||
{ 'name' => 'monthAbbr' },
|
||||
{ 'name' => 'monthEpoch' },
|
||||
{ 'name' => 'monthUrl' },
|
||||
{ 'name' => 'monthCurrent' },
|
||||
],
|
||||
},
|
||||
],
|
||||
related => []
|
||||
},
|
||||
|
||||
'view week template' => {
|
||||
title => 'view calendar week title',
|
||||
body => 'view calendar week body',
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ our $HELP = {
|
|||
{ 'name' => 'back.label' },
|
||||
{ 'name' => 'compensation.label' },
|
||||
{ 'name' => 'open.label' },
|
||||
{ 'name' => 'captcha_label' },
|
||||
{ 'name' => 'close.label' },
|
||||
{ 'name' => 'closed.label' },
|
||||
{ 'name' => 'critical.label' },
|
||||
|
|
@ -34,6 +35,9 @@ our $HELP = {
|
|||
{ 'name' => 'job.title.label' },
|
||||
{ 'name' => 'job.description.label' },
|
||||
{ 'name' => 'job.requirements.label' },
|
||||
{ 'name' => 'karmascale.label' },
|
||||
{ 'name' => 'karmaRank.label' },
|
||||
{ 'name' => 'keywords.label' },
|
||||
{ 'name' => 'location.label' },
|
||||
{ 'name' => 'layout.flat.label' },
|
||||
{ 'name' => 'link.header.label' },
|
||||
|
|
@ -64,6 +68,7 @@ our $HELP = {
|
|||
{ 'name' => 'synopsis.label' },
|
||||
{ 'name' => 'thumbnail.label' },
|
||||
{ 'name' => 'title.label' },
|
||||
{ 'name' => 'transferkarma.label' },
|
||||
{ 'name' => 'unlock.label' },
|
||||
{ 'name' => 'unstick.label' },
|
||||
{ 'name' => 'unsubscribe.label' },
|
||||
|
|
@ -80,6 +85,11 @@ our $HELP = {
|
|||
title => 'collaboration post list template variables title',
|
||||
body => '',
|
||||
fields => [],
|
||||
isa => [
|
||||
{ tag => 'pagination template variables',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{ 'name' => 'post_loop',
|
||||
'variables' => [
|
||||
|
|
@ -103,7 +113,9 @@ our $HELP = {
|
|||
{ 'name' => 'timeSubmitted.human' },
|
||||
{ 'name' => 'timeUpdated.human' },
|
||||
{ 'name' => 'userProfile.url' },
|
||||
{ 'name' => 'user.isVisitor' },
|
||||
{ 'name' => 'hideProfileUrl' },
|
||||
{ 'name' => 'user.isVisitor',
|
||||
'description' => 'post_loop_user.isVisitor' },
|
||||
{ 'name' => 'edit.url' },
|
||||
{ 'name' => 'controls' },
|
||||
{ 'name' => 'isSecond' },
|
||||
|
|
@ -116,6 +128,7 @@ our $HELP = {
|
|||
{ 'name' => 'lastReply.url' },
|
||||
{ 'name' => 'lastReply.title' },
|
||||
{ 'name' => 'lastReply.user.isVisitor' },
|
||||
{ 'name' => 'lastReply.hideProfileUrl' },
|
||||
{ 'name' => 'lastReply.username' },
|
||||
{ 'name' => 'lastReply.userProfile.url' },
|
||||
{ 'name' => 'lastReply.dateSubmitted.human' },
|
||||
|
|
@ -136,6 +149,7 @@ our $HELP = {
|
|||
fields => [],
|
||||
variables => [
|
||||
{ 'name' => 'displayLastReply' },
|
||||
{ 'name' => 'user.canStartThread' },
|
||||
{ 'name' => 'user.canPost' },
|
||||
{ 'name' => 'user.isModerator' },
|
||||
{ 'name' => 'user.isVisitor', },
|
||||
|
|
@ -156,7 +170,7 @@ our $HELP = {
|
|||
{ 'name' => 'sortby.rating.url' },
|
||||
{ 'name' => 'collaborationAssetId' },
|
||||
],
|
||||
related => [
|
||||
isa => [
|
||||
{ tag => 'collaboration template labels',
|
||||
namespace => 'Asset_Collaboration',
|
||||
},
|
||||
|
|
@ -170,76 +184,19 @@ our $HELP = {
|
|||
title => 'collaboration search template title',
|
||||
body => '',
|
||||
fields => [],
|
||||
isa => [
|
||||
{ namespace => "Asset_Collaboration",
|
||||
tag => "collaboration post list template variables"
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{ 'name' => 'form.header' },
|
||||
{ 'name' => 'query.form' },
|
||||
{ 'name' => 'form.search' },
|
||||
{ 'name' => 'form.footer' },
|
||||
{ 'name' => 'back.url' },
|
||||
{ 'name' => 'unsubscribe.url', },
|
||||
{ 'name' => 'sortby.title.url', },
|
||||
{ 'name' => 'sortby.username.url', },
|
||||
{ 'name' => 'sortby.date.url', },
|
||||
{ 'name' => 'sortby.lastreply.url', },
|
||||
{ 'name' => 'sortby.views.url', },
|
||||
{ 'name' => 'sortby.replies.url', },
|
||||
{ 'name' => 'sortby.rating.url', }
|
||||
],
|
||||
related => [
|
||||
{ tag => 'collaboration post list template variables',
|
||||
namespace => 'Asset_Collaboration',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
'collaboration rss template' => {
|
||||
title => 'collaboration rss template title',
|
||||
body => '',
|
||||
fields => [],
|
||||
variables => [
|
||||
{ 'name' => 'title',
|
||||
'description' => 'feed title'
|
||||
},
|
||||
{ 'name' => 'link',
|
||||
'description' => 'collab link'
|
||||
},
|
||||
{ 'name' => 'description',
|
||||
'description' => 'feed description'
|
||||
},
|
||||
{ 'name' => 'generator' },
|
||||
{ 'name' => 'webMaster' },
|
||||
{ 'name' => 'docs' },
|
||||
{ 'name' => 'lastBuildDate' },
|
||||
{ 'name' => 'item_loop',
|
||||
'variables' => [
|
||||
{ 'name' => 'author' },
|
||||
{ 'name' => 'title',
|
||||
'description' => 'post title'
|
||||
},
|
||||
{ 'name' => 'link',
|
||||
'description' => 'full text link'
|
||||
},
|
||||
{ 'name' => 'description',
|
||||
'description' => 'item description'
|
||||
},
|
||||
{ 'name' => 'guid' },
|
||||
{ 'name' => 'pubDate' },
|
||||
{ 'name' => 'epochDate' },
|
||||
{ 'name' => 'attachmentLoop',
|
||||
'variables' => [
|
||||
{ 'name' => 'attachment_thumbnail' },
|
||||
{ 'name' => 'attachment.url' },
|
||||
{ 'name' => 'attachment.path' },
|
||||
{ 'name' => 'attachment.length' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
related => [
|
||||
{ tag => 'collaboration post list template variables',
|
||||
namespace => 'Asset_Collaboration',
|
||||
},
|
||||
]
|
||||
related => [ ],
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -141,6 +141,9 @@ our $HELP = {
|
|||
{ namespace => "Asset_Template",
|
||||
tag => "template variables"
|
||||
},
|
||||
{ namespace => "WebGUI",
|
||||
tag => "pagination template variables"
|
||||
},
|
||||
],
|
||||
fields => [],
|
||||
variables => [
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ our $HELP = {
|
|||
'required' => 1,
|
||||
},
|
||||
{ 'name' => 'formMenuTitle', },
|
||||
{ 'name' => 'formSynopsis', },
|
||||
{ 'name' => 'formLocation', },
|
||||
{ 'name' => 'formDescription', },
|
||||
{ 'name' => 'formGroupToView', },
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ our $HELP = {
|
|||
{ 'name' => 'addTokenUrl'},
|
||||
{ 'name' => 'importTicketsUrl'},
|
||||
{ 'name' => 'exportTicketsUrl'},
|
||||
{ 'name' => 'printRemainingTicketsUrl'},
|
||||
{ 'name' => 'canEdit'},
|
||||
{ 'name' => 'hasBadge'},
|
||||
{ 'name' => 'badgeId'},
|
||||
|
|
@ -226,6 +227,68 @@ our $HELP = {
|
|||
related => [],
|
||||
},
|
||||
|
||||
'ems print remaining ticket template' => {
|
||||
source => 'sub www_printRemainingTickets',
|
||||
title => 'print remaining ticket template help',
|
||||
body => '',
|
||||
variables => [
|
||||
{ 'name' => 'tickets_loop',
|
||||
'variables' => [
|
||||
{ 'name' => 'ticketTitle'},
|
||||
{ 'name' => 'ticketStart'},
|
||||
{ 'name' => 'ticketDuration'},
|
||||
{ 'name' => 'ticketLocation'},
|
||||
{ 'name' => 'ticketEventNumber'},
|
||||
{ 'name' => 'ticketMeta_[LABEL]'},
|
||||
{ 'name' => 'seatsRemaining'},
|
||||
{ 'name' => 'seatsAvailable'},
|
||||
{ 'name' => 'price'},
|
||||
{ 'name' => 'relatedRibbons'},
|
||||
{ 'name' => 'relatedBadgeGroups'},
|
||||
{ 'name' => 'eventMetaData'},
|
||||
{ 'name' => 'title'},
|
||||
{ 'name' => 'menuTitle'},
|
||||
{ 'name' => 'url'},
|
||||
{ 'name' => 'synopsis'},
|
||||
{ 'name' => 'assetId'},
|
||||
{ 'name' => 'assetSize'},
|
||||
{ 'name' => 'creationDate'},
|
||||
{ 'name' => 'encryptPage'},
|
||||
{ 'name' => 'extraHeadTags'},
|
||||
{ 'name' => 'extraHeadTagsPacked'},
|
||||
{ 'name' => 'groupIdEdit'},
|
||||
{ 'name' => 'groupIdView'},
|
||||
{ 'name' => 'inheritUrlFromParent'},
|
||||
{ 'name' => 'isExportable'},
|
||||
{ 'name' => 'isHidden'},
|
||||
{ 'name' => 'isPrototype'},
|
||||
{ 'name' => 'isPackage'},
|
||||
{ 'name' => 'lastModified'},
|
||||
{ 'name' => 'newWindow'},
|
||||
{ 'name' => 'ownerUserId'},
|
||||
{ 'name' => 'revisedBy'},
|
||||
{ 'name' => 'revisionDate'},
|
||||
{ 'name' => 'skipNotification'},
|
||||
{ 'name' => 'tagId'},
|
||||
{ 'name' => 'usePackedHeadTags'},
|
||||
],
|
||||
},
|
||||
],
|
||||
isa => [
|
||||
{ namespace => "Asset_EventManagementSystem",
|
||||
tag => "ems asset template variables"
|
||||
},
|
||||
{ namespace => "Asset_Template",
|
||||
tag => "template variables"
|
||||
},
|
||||
{ namespace => "Asset_Wobject",
|
||||
tag => "wobject template variables"
|
||||
},
|
||||
],
|
||||
fields => [],
|
||||
related => [],
|
||||
},
|
||||
|
||||
'ems asset template variables' => {
|
||||
source => 'sub definition',
|
||||
title => 'ems asset template variables',
|
||||
|
|
|
|||
|
|
@ -131,8 +131,8 @@ our $HELP = {
|
|||
],
|
||||
},
|
||||
{
|
||||
name => 'synopsis_text',
|
||||
description => 'helpvar synopsis_text',
|
||||
name => 'synopsis_textonly',
|
||||
description => 'helpvar synopsis_textonly',
|
||||
},
|
||||
{
|
||||
name => 'url_album',
|
||||
|
|
@ -174,6 +174,54 @@ our $HELP = {
|
|||
name => 'album_url',
|
||||
description => 'helpvar album_url',
|
||||
},
|
||||
{
|
||||
name => 'firstFile_url',
|
||||
description => 'helpvar firstFile_url',
|
||||
},
|
||||
{
|
||||
name => 'firstFile_title',
|
||||
description => 'helpvar firstFile_title',
|
||||
},
|
||||
{
|
||||
name => 'firstFile_thumbnailUrl',
|
||||
description => 'helpvar firstFile_thumbnailUrl',
|
||||
},
|
||||
{
|
||||
name => 'nextFile_url',
|
||||
description => 'helpvar nextFile_url',
|
||||
},
|
||||
{
|
||||
name => 'nextFile_title',
|
||||
description => 'helpvar nextFile_title',
|
||||
},
|
||||
{
|
||||
name => 'nextFile_thumbnailUrl',
|
||||
description => 'helpvar nextFile_thumbnailUrl',
|
||||
},
|
||||
{
|
||||
name => 'previousFile_url',
|
||||
description => 'helpvar previousFile_url',
|
||||
},
|
||||
{
|
||||
name => 'previousFile_title',
|
||||
description => 'helpvar previousFile_title',
|
||||
},
|
||||
{
|
||||
name => 'previousFile_thumbnailUrl',
|
||||
description => 'helpvar previousFile_thumbnailUrl',
|
||||
},
|
||||
{
|
||||
name => 'lastFile_url',
|
||||
description => 'helpvar lastFile_url',
|
||||
},
|
||||
{
|
||||
name => 'lastFile_title',
|
||||
description => 'helpvar lastFile_title',
|
||||
},
|
||||
{
|
||||
name => 'lastFile_thumbnailUrl',
|
||||
description => 'helpvar lastFile_thumbnailUrl',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ our $HELP = {
|
|||
{ 'name' => 'title.form.textarea' },
|
||||
{ 'name' => 'synopsis.form' },
|
||||
{ 'name' => 'content.form' },
|
||||
{ 'name' => 'skipNotification.form' },
|
||||
{ 'name' => 'form.submit' },
|
||||
{ 'name' => 'form.cancel' },
|
||||
{ 'name' => 'karmaScale.form' },
|
||||
{ 'name' => 'karmaIsEnabled' },
|
||||
{ 'name' => 'meta_loop',
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue