Merge branch 'master' of git@github.com:plainblack/webgui

This commit is contained in:
daviddelikat 2009-10-23 05:07:49 -05:00
commit 945017d762
46 changed files with 1496 additions and 492 deletions

View file

@ -162,8 +162,9 @@ sub checkSchedule {
&& $self->checkSegment($now->day, $job->{dayOfMonth}, [1..31])
&& $self->checkSegment($now->month, $job->{monthOfYear}, [1..12])
&& $self->checkSegment($now->dow % 7, $job->{dayOfWeek}, [0..6]) ) {
$self->debug("It's time to run ".$jobId.". Creating workflow instance.");
$kernel->yield("runJob",$jobId);
$self->debug("It's time to run ".$jobId.". Creating workflow instance in ".$self->{_jobDelay}." seconds.");
$kernel->delay_set("runJob", $self->{_jobDelay}, $jobId);
$self->{_jobDelay} += $self->config->get('timeBetweenRunningWorkflows');
}
}
@ -180,8 +181,9 @@ sub checkSchedules {
$self->debug("Checking schedules against current time.");
my $now = DateTime->now(time_zone => 'local');
foreach my $id (keys %{$self->{_jobs}}) {
$kernel->yield("checkSchedule", $id, $now)
$kernel->delay_set("checkSchedule", $self->{_jobDelay}, $id, $now)
}
$self->{_jobDelay} = $self->config->get('timeBetweenRunningWorkflows');
$kernel->delay_set("checkSchedules",60);
}
@ -380,7 +382,13 @@ sub new {
my $config = shift;
my $logger = shift;
my $debug = shift;
my $self = {_jobs=>{}, _debug=>$debug, _config=>$config, _logger=>$logger};
my $self = {
_jobs => {},
_debug => $debug,
_config => $config,
_logger => $logger,
_jobDelay => $config->get('timeBetweenRunningWorkflows'),
};
bless $self, $class;
my @publicEvents = qw(runJob runJobResponse addJob deleteJob getJsonStatus);
POE::Session->create(

View file

@ -1,7 +1,7 @@
package WebGUI;
our $VERSION = '7.8.2';
our $VERSION = '7.8.3';
our $STATUS = 'beta';

View file

@ -826,6 +826,26 @@ sub getAdminConsole {
}
#-------------------------------------------------------------------
=head2 getCache ( )
Returns a cache object specific to this asset, and whether or not the request is in SSL mode.
=cut
sub getCache {
my $self = shift;
my $session = $self->session;
my $cacheKey = "view_".$self->getId;
if ($session->env->sslRequest) {
$cacheKey .= '_ssl';
}
my $cache = WebGUI::Cache->new($session, $cacheKey);
return $cache;
}
#-------------------------------------------------------------------
=head2 getContainer ( )

View file

@ -608,7 +608,8 @@ 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 = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my %var = %{$self->get};

View file

@ -223,7 +223,8 @@ Renders this asset.
sub view {
my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my %var = %{$self->get};
@ -277,23 +278,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->get("filename"));
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=rotate'),$i18n->get("rotate image")) if ($self->get("filename"));
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=crop'),$i18n->get("crop image")) if ($self->get("filename"));
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=annotate'),$i18n->get("annotate image")) if ($self->get("filename"));
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=undo'),$i18n->get("undo image")) if ($self->get("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->get('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->get("templateId"),
-namespace => "ImageAsset",
-hoverHelp => $i18n->get('image template description'),
-defaultValue => "PBtmpl0000000000000088",
);
return $self->getAdminConsole->render($tabform->print,$i18n->get("edit image"));
}
#-------------------------------------------------------------------
@ -308,18 +313,8 @@ have been done to it.
sub www_undo {
my $self = shift;
my $previous = (@{$self->getRevisions()})[1];
# instantiate assetId
if ($previous) {
# my $session = $self->session;
# my $cache = WebGUI::Cache->new($self->session, ["asset",$self->getId,$self->getRevisionDate]);
# $cache->flush;
# my $cache = WebGUI::Cache->new($previous->session, ["asset",$previous->getId,$previous->getRevisionDate]);
# $cache->flush;
$self = $self->purgeRevision();
# $self = undef;
# $self = WebGUI::Asset->new($previous->session, $previous->getId, ref $previous, $previous->getRevisionDate);
$self->purgeRevision();
$self = $previous;
$self->generateThumbnail;
}
@ -341,20 +336,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->get("filename"),$newSelf,$newSelf->session->form);
$newSelf->getStorageLocation->annotate($newSelf->get("filename"),$newSelf,$session->form);
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->get("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'});
@ -366,10 +362,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->get('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) {
@ -377,7 +370,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->get("filename")).'" style="border-style:none;" alt="'.$self->get("filename").'" id="yui_img" /></div>';
@ -385,8 +377,8 @@ sub www_annotate {
my ($width, $height) = $self->getStorageLocation->getSize($self->get("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(
@ -563,49 +555,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->get("filename"),$newSelf->session->form->process("Rotate"));
$newSelf->getStorageLocation->rotate($newSelf->get("filename"),$session->form->process("Rotate"));
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->get("filename")));
$self = $newSelf;
$self->generateThumbnail;
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
}
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->get("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->get("filename"));
my $img_file = $self->get("filename");
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->get("filename")).'" style="border-style:none;" alt="'.$self->get("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"));
}
#-------------------------------------------------------------------
@ -620,22 +614,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->get("filename"),$newSelf->session->form->process("newWidth"),$newSelf->session->form->process("newHeight"));
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->get("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->get("filename"),$session->form->process("newWidth"),$session->form->process("newHeight"));
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->get("filename")));
$self = $newSelf;
$self->generateThumbnail;
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
}
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->get("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'});
@ -682,33 +678,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->get("filename")).'" style="border-style:none;" alt="'.$self->get("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->get("filename")).'" style="border-style:none;" alt="'.$self->get("filename").'" id="yui_img" /></div>'.$resize_js;
return $self->getAdminConsole->render($f->print.$image,$i18n->get("resize image"));
}
#-------------------------------------------------------------------
@ -724,29 +720,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->get("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->get("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>
@ -784,10 +782,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"
@ -823,7 +821,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"));
}

View file

@ -221,7 +221,8 @@ used to show the file to administrators.
sub view {
my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my %var = %{$self->get};

View file

@ -1681,8 +1681,9 @@ sub view {
my $error = shift;
my $session = $self->session;
if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10){
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
return $out if $out;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my (%data, $segment, %var, @featureloop, @benefitloop, @specificationloop, @accessoryloop, @relatedloop);
tie %data, 'Tie::CPHash';

View file

@ -279,7 +279,8 @@ sub view {
|| $self->get("cacheTimeout") <= 10
|| ($versionTag && $versionTag->getId eq $self->get("tagId"));
unless ($noCache) {
my $out = WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my $output = $self->get('usePacked')

View file

@ -128,20 +128,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->get('revisionDate'),
@{$a}{qw(url type sequence)}
my %params = (
templateId => $self->getId,
revisionDate => $self->get('revisionDate'),
url => $a->{url},
type => $a->{type},
sequence => $a->{sequence},
attachId => 'new',
);
$db->write($sql, \@params);
$db->setRow('template_attachments', 'attachId', \%params);
}
}
@ -719,9 +715,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

View file

@ -350,7 +350,8 @@ sub view {
my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") &&
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my %var;

File diff suppressed because it is too large Load diff

View file

@ -1572,6 +1572,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.
@ -1627,6 +1644,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 ( )

View file

@ -409,12 +409,8 @@ sub www_view {
) {
my $check = $self->checkView;
return $check if (defined $check);
my $cacheKey = "view_".$self->getId;
if ($session->env->sslRequest) {
$cacheKey .= '_ssl';
}
my $cache = WebGUI::Cache->new($session, $cacheKey);
my $out = $cache->get if defined $cache;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
unless ($out) {
$self->prepareView;
$session->stow->set("cacheFixOverride", 1);

View file

@ -644,7 +644,6 @@ sub view {
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');
@ -1193,6 +1192,7 @@ 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)
@ -1203,24 +1203,21 @@ sub www_getCompareFormData {
my $fieldType = $matrixListing_attributes->{$param->{attributeId}}->{fieldType};
my $listingValue = $matrixListing_attributes->{$param->{attributeId}}->{value};
if(($fieldType eq 'MatrixCompare') && ($listingValue < $param->{value})){
$result->{checked} = '';
last PARAM;
}
elsif(($fieldType ne 'MatrixCompare' && $fieldType ne '') && ($param->{value} ne $listingValue)){
$result->{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;
}
@ -1390,7 +1387,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

View file

@ -130,7 +130,8 @@ to be displayed within the page style
sub view {
my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
my $i18n = WebGUI::International->new($self->session, 'Asset_MultiSearch');

View file

@ -534,7 +534,8 @@ if the user is not in Admin Mode.
sub view {
my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out;
}
# Initiate an empty debug loop

View file

@ -159,7 +159,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.
@ -168,6 +168,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 {
@ -175,18 +183,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);

View file

@ -274,7 +274,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

View file

@ -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' },

View file

@ -180,6 +180,13 @@ sub www_editSettings {
label => $i18n->get("edit address template"),
hoverHelp => $i18n->get("edit address template help"),
);
$form->template(
name => "selectGatewayTemplateId",
value => $setting->get("selectGatewayTemplateId"),
label => $i18n->get("select gateway template"),
namespace => "Shop/selectGateway",
hoverHelp => $i18n->get("select gateway template help"),
);
$form->template(
name => "shopMyPurchasesTemplateId",
value => $setting->get("shopMyPurchasesTemplateId"),
@ -226,7 +233,7 @@ sub www_editSettingsSave {
# Save shop templates
foreach my $template (qw(shopMyPurchasesDetailTemplateId shopMyPurchasesTemplateId
shopCartTemplateId shopAddressBookTemplateId shopAddressTemplateId shopReceiptEmailTemplateId)) {
shopCartTemplateId shopAddressBookTemplateId shopAddressTemplateId selectGatewayTemplateId shopReceiptEmailTemplateId)) {
$setting->set($template, $form->get($template, "template"));
}

View file

@ -423,12 +423,16 @@ sub www_selectPaymentGateway {
# TODO: If only one payOption exists, just send us there
# In order to do this, the PayDriver must give us a direct URL to go to
my $output .= $i18n->get('choose payment gateway message');
my $var;
my @paymentGateways;
foreach my $payOption ( values %{$payOptions} ) {
$output .= $payOption->{button} . '<br />';
push @paymentGateways, $payOption;
}
return $session->style->userStyle( $output );
$var->{ paymentGateways } = \@paymentGateways;
$var->{ choose } = $i18n->get('choose payment gateway message');
$session->log->warn('###'.$session->setting->get("selectGatewayTemplateId"));
my $template = WebGUI::Asset::Template->new($session, $session->setting->get("selectGatewayTemplateId"));
return $session->style->userStyle($template->process($var));
}
1;

View file

@ -0,0 +1,124 @@
package WebGUI::Shop::PayDriver::Skeleton; #change the Skeleton with your own PayDriver name
=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::Shop::PayDriver;
use base qw/WebGUI::Shop::PayDriver/;
#-------------------------------------------------------------------
=head2 definition ( )
In the definition you can add your own properties
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
WebGUI::Error::InvalidParam->throw( error => q{Must provide a session variable} )
unless $session && ref $session eq 'WebGUI::Session';
tie my %fields, 'Tie::IxHash';
#add some fields if you need your own parameters
# %fields = (
# currency => {
# fieldType => 'text',
# label => 'currency',
# hoverHelp => 'Fill in your currency',
# defaultValue => 'EUR',
# maxlength => 3,
# size => 3,
# },
# );
push @{ $definition }, {
name => 'Skeleton', #change the Skeleton with your own PayDriver name
properties => \%fields,
};
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
=head2 canCheckoutCart ( )
Returns whether the cart can be checked out by this plugin.
=cut
sub canCheckoutCart {
my $self = shift;
my $cart = $self->getCart;
return 0 unless $cart->readyForCheckout;
return 0 if $cart->requiresRecurringPayment;
return 1;
}
#-------------------------------------------------------------------
=head2 getButton ( )
Create a button for the screen where you select the payment method. Redirect it
to your first www_ method you need
=cut
sub getButton {
my $self = shift;
my $button = WebGUI::Form::formHeader($self->session) .
$self->getDoFormTags('finish') .
WebGUI::Form::submit($self->session, {value => $self->get('label') }) .
WebGUI::Form::formFooter($self->session);
return $button;
}
#-------------------------------------------------------------------
=head2 processPayment ( )
Should interact with the payment gateway and then return an array containing
success/failure (as 1 or 0), transaction code (or payment gateway's transaction
id), status code, and status message.
=cut
sub processPayment {
return (1, undef, 1, 'Success');
}
#-------------------------------------------------------------------
=head2 www_dosomething ( )
Create your own www_ method. They are available from the outside.
So www_finish can be called directly with:
http://www.mysite.com/?shop=pay;method=do;do=finish
=cut
sub www_finish {
my ($self) = @_;
#prcess the transaction (it needs an WebGUI::Shop::Address object)
my $transaction = $self->processTransaction(
$self->getCart->getShippingAddress
);
#return the thankyou page to the user
return $transaction->thankYou();
}
1;

View file

@ -588,16 +588,26 @@ Returns the status to which the item(s) are set.
=cut
sub www_setPayoutStatus {
my $class = shift;
my $session = shift;
my $class = shift;
my $session = shift;
my ( $form, $db ) = $session->quick( qw{ form db } );
my $admin = WebGUI::Shop::Admin->new($session);
return $session->privilege->adminOnly() unless ($admin->canManage);
my @itemIds = $session->form->process('itemId');
my $status = $session->form->process('status');
my $status = $form->process('status');
return "error: wrong status [$status]" unless isIn( $status, qw{ NotPaid Scheduled } );
my @itemIds;
if ( $form->process( 'all' ) ) {
@itemIds = $session->db->buildArray( 'select itemId from transactionItem where vendorPayoutStatus = ?' , [
( $status eq 'NotPaid' ) ? 'Scheduled' : 'NotPaid'
] );
}
else {
@itemIds = $form->process('itemId');
}
foreach my $itemId (@itemIds) {
my $item = WebGUI::Shop::TransactionItem->newByDynamicTransaction( $session, $itemId );
return "error: invalid transactionItemId [$itemId]" unless $item;

View file

@ -0,0 +1,262 @@
package WebGUI::Workflow::Activity::PayoutVendors;
=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 Business::PayPal::API qw{ MassPay };
use Data::Dumper;
use WebGUI::Mail::Send;
use base 'WebGUI::Workflow::Activity';
=head1 NAME
Package WebGUI::Workflow::Activity::PayoutVendors
=head1 DESCRIPTION
Pays profits to vendors, currently via paypal, but others may be added in the future.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ()
See WebGUI::Workflow::Activity for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_PayoutVendors");
tie my %properties, 'Tie::IxHash', (
paypalUsername => {
fieldType => 'text',
label => $i18n->get('PayPal username'),
},
paypalPassword => {
fieldType => 'password',
label => $i18n->get('PayPal password'),
},
paypalSignature => {
fieldType => 'text',
label => $i18n->get('PayPal signature'),
},
useSandbox => {
fieldType => 'yesNo',
label => $i18n->get('Use in Sandbox (test-mode)'),
defaultValue => 0,
},
currencyCode => {
fieldType => 'text',
label => $i18n->get('Currency code'),
maxlength => 3,
size => 3,
defaultValue => 'USD',
},
paypalSubject => {
fieldType => 'text',
label => $i18n->get('Subject for vendor notication email'),
defaultValue => $i18n->get('Vendor payout from').' ' . $session->setting->get('companyUrl'),
},
notificationGroupId => {
fieldType => 'group',
label => $i18n->get('Notify on error'),
},
);
push @{ $definition }, {
name => $i18n->get('Vendor Payout'),
properties => \%properties,
};
return $class->SUPER::definition( $session, $definition );
}
#-------------------------------------------------------------------
=head2 payoutVendor (vendorId)
Sends unsent vendor payouts to paypal.
=head3 vendorId
The vendor to be sent his payouts.
=cut
sub payoutVendor {
my $self = shift;
my $vendorId = shift;
my $db = $self->session->db;
my $payoutId = $self->session->id->generate;
# Instanciate vendor and check if he exists.
my $vendor = WebGUI::Shop::Vendor->new( $self->session, $vendorId );
unless ( $vendor ) {
$self->session->log->error( "Could not instanciate vendor with id [$vendorId] for payout" );
return undef;
}
# check to see that the vendor has a payout address
if ($vendor->get('paymentInformation') eq '') {
$self->session->log->warn("Vendor ".$vendor->getId." hasn't specified a payout address.");
return undef;
}
# Fetch all transactionItems that are scheduled for payout to the vendor.
my $sth = $db->read(
'select itemId, vendorPayoutAmount from transactionItem '
. ' where vendorId=? and vendorPayoutStatus=? and vendorPayoutAmount > 0',
[
$vendorId,
'Scheduled',
]
);
# Process all transaction items and log them in the db.
my $totalAmount = 0;
while ( my $item = $sth->hashRef ) {
$totalAmount += $item->{ vendorPayoutAmount };
$db->write( 'insert into vendorPayoutLog_items (payoutId, transactionItemId, amount) values (?,?,?)', [
$payoutId,
$item->{ itemId },
$item->{ vendorPayoutAmount },
] );
}
my $itemCount = $sth->rows;
$sth->finish;
# Do PayPal MassPay request
my $pp = new Business::PayPal::API(
Username => $self->get('paypalUsername'),
Password => $self->get('paypalPassword'),
Signature => $self->get('paypalSignature'),
sandbox => $self->get('useSandbox'),
);
my %response = $pp->MassPay(
EmailSubject => $self->get('paypalSubject'),
currencyID => $self->get('currencyCode'),
MassPayItems => [ {
ReceiverEmail => $vendor->get('paymentInformation'),
Amount => $totalAmount,
UniqueID => $payoutId,
Note => "Payout for $itemCount sold items",
} ],
);
# Process paypal response
my $payoutDetails = {
payoutId => $payoutId,
isSuccessful => $response{ Ack } eq 'Success' ? 1 : 0,
paypalTimestamp => $response{ Timestamp },
correlationId => $response{ CorrelationID },
amount => $totalAmount,
currency => $self->get('currencyCode'),
paymentInformation => $vendor->get('paymentInformation'),
};
if ( $response{ Ack } ne 'Success' ) {
# An error occurred, keep the error codes
my $errorCode = $response{ Error }->[ 0 ]->{ ErrorCode };
my $errorMessage = $response{ Error }->[ 0 ]->{ LongMessage };
# TODO: Send out email.
my $mail = WebGUI::Mail::Send->create($self->session, {
toGroup => $self->get('notificationGroupId'),
subject => 'Vendor payout error',
});
$mail->addText(
"An error occurred during an automated vendor payout attempt. Response details:\n"
. Dumper( \%response )
. "\n\nVendor information:\n"
. Dumper( $vendor->get )
);
$mail->send;
$payoutDetails->{ errorCode } = $errorCode;
$payoutDetails->{ errorMessage } = $errorMessage;
}
else {
# The transaction was successful, so change the state of the transactionItems to Paid.
$db->write(
'update transactionItem set vendorPayoutStatus=? where itemId in ( '
.' select transactionItemId from vendorPayoutLog_items where payoutId=? '
.')',
[
'Paid',
$payoutId,
]
);
}
# Persist response data to db
$db->setRow( 'vendorPayoutLog', 'payoutId', $payoutDetails, $payoutId );
};
#-------------------------------------------------------------------
=head2 execute ()
See WebGUI::Workflow::Activity for details.
=cut
sub execute {
my $self = shift;
my $object = shift;
my $instance = shift;
my $start = time;
my $ttl = $self->getTTL;
# Fetch vendors eligible for payout.
my $sth = $self->session->db->read(
"select distinct vendorId from transactionItem where vendorPayoutStatus='Scheduled' and vendorPayoutAmount > 0"
);
# Pay on a vendor by vendor basis.
while ( (my $vendorId) = $sth->array ) {
$self->payoutVendor( $vendorId );
# Make sure we won't run longer than allowed.
if ( ( time - $start + 1 ) >= $ttl ) {
$sth->finish;
return $self->WAITING( 1 );
}
}
$sth->finish;
return $self->COMPLETE;
}
1;

View file

@ -1088,6 +1088,16 @@ Couldn't open %-s because %-s <br />
lastUpdated => 1100463645,
},
'assetId' => {
message => q|The unique identifier for this Asset, in base64 encoding.|,
lastUpdated => 1256327617,
},
'assetIdHex' => {
message => q|The unique identifier for this Asset, in hexadecimal format.|,
lastUpdated => 1256327617,
},
'title' => {
message => q|The title of the Asset|,
lastUpdated => 1160773957,

View file

@ -1736,6 +1736,18 @@ the Collaboration Asset, the user will be notified.|,
lastUpdated => 1229910435,
},
'unarchive all' => {
message => q{Unarchive All Threads},
context => q{Label for link to unarchive all threads},
lastUpdated => 0,
},
'unarchive confirm' => {
message => q{Are you sure? Any threads past the 'Archive After' interval will be re-archived.},
context => q{Text for pop-up dialog to confirm unarchive all threads},
lastUpdated => 0,
},
};
1;

View file

@ -669,6 +669,18 @@ our $I18N = {
context => q|commerce setting help|
},
'select gateway template' => {
message => q|Select Gateway Template|,
lastUpdated => 0,
context => q|commerce setting|
},
'select gateway template help' => {
message => q|This template is the template for the Select Payment Gateway step.|,
lastUpdated => 0,
context => q|commerce setting help|
},
'transactions' => {
message => q|Transactions|,
lastUpdated => 0,
@ -1594,6 +1606,24 @@ our $I18N = {
context => q|Table heading in the vendor payout manager.|,
},
'vp select vendor' => {
message => q|Please select a vendor from the list above to manage individual payouts.|,
lastUpdated => 0,
context => q|Message in the vendor payouts manager when no vendor has been selected.|,
},
'vp vendors' => {
message => q|Vendors|,
lastUpdated => 0,
context => q|Label for the vendors section of the vendor payouts manager|,
},
'vp payouts' => {
message => q|Payouts|,
lastUpdated => 0,
context => q|Label for the vendors section of the vendor payouts manager|,
},
'vp item id' => {
message => q|Item ID|,
lastUpdated => 0,

View file

@ -0,0 +1,63 @@
package WebGUI::i18n::English::Workflow_Activity_PayoutVendors;
use strict;
our $I18N = {
'PayPal username' => {
message => q|PayPal username|,
lastUpdated => 0,
context => q|field label|
},
'PayPal password' => {
message => q|PayPal password|,
lastUpdated => 0,
context => q|field label|
},
'PayPal signature' => {
message => q|PayPal signature|,
lastUpdated => 0,
context => q|field label|
},
'Use in Sandbox (test-mode)' => {
message => q|Use in Sandbox (test-mode)|,
lastUpdated => 0,
context => q|field label|
},
'Currency code' => {
message => q|Currency code|,
lastUpdated => 0,
context => q|field label|
},
'Subject for vendor notification email' => {
message => q|Subject for vendor notification email|,
lastUpdated => 0,
context => q|field label|
},
'Vendor payout from' => {
message => q|Vendor payout from|,
lastUpdated => 0,
context => q|Prefix that goes before company URL to create the default value from Subject for vendor notification email.|
},
'Notify on error' => {
message => q|Notify on error|,
lastUpdated => 0,
context => q|field label|
},
'Vendor Payout' => {
message => q|Vendor Payout|,
lastUpdated => 0,
context => q|field label|
},
};
1;
#vim:ft=perl