merged with SVN HEAD
This commit is contained in:
commit
5222ad6be1
74 changed files with 10757 additions and 434 deletions
|
|
@ -11,6 +11,7 @@ package WebGUI::Asset::Shortcut;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Carp;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::International;
|
||||
|
|
@ -605,6 +606,26 @@ sub getPrefFieldsToImport {
|
|||
return split("\n",$self->getValue("prefFieldsToImport"));
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTemplateVars
|
||||
|
||||
Gets the template vars for this shortcut.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
|
||||
my $shortcut = $self->getShortcut;
|
||||
if ( $shortcut->can('getTemplateVars') ) {
|
||||
return $shortcut->getTemplateVars;
|
||||
}
|
||||
else {
|
||||
return $shortcut->get;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub isDashlet {
|
||||
my $self = shift;
|
||||
|
|
@ -648,6 +669,34 @@ sub processPropertiesFromFormPost {
|
|||
$self->uncacheOverrides;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 setOverride ( overrides )
|
||||
|
||||
Set this shortcut's overrides. C<overrides> is a hash reference of overrides
|
||||
to set.
|
||||
|
||||
=cut
|
||||
|
||||
sub setOverride {
|
||||
my $self = shift;
|
||||
my $override = shift;
|
||||
|
||||
croak "Shortcut->setOverride - first argument must be hash reference"
|
||||
unless $override && ref $override eq "HASH";
|
||||
|
||||
for my $key ( %$override ) {
|
||||
$self->session->db->write(
|
||||
"DELETE FROM Shortcut_overrides WHERE assetId=? AND fieldName=?",
|
||||
[$self->getId, $key],
|
||||
);
|
||||
$self->session->db->write(
|
||||
"INSERT INTO Shortcut_overrides VALUES (?,?,?)",
|
||||
[$self->getId, $key, $override->{$key}],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
|
|
@ -880,23 +929,23 @@ sub www_editOverride {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_saveOverride {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
my $fieldName = $self->session->form->process("overrideFieldName");
|
||||
my %overrides = $self->getOverrides;
|
||||
my $output = '';
|
||||
my %props;
|
||||
foreach my $def (@{$self->getShortcutOriginal->definition($self->session)}) {
|
||||
%props = (%props,%{$def->{properties}});
|
||||
}
|
||||
my $fieldType = $props{$fieldName}{fieldType};
|
||||
my $value = $self->session->form->process($fieldName,$fieldType);
|
||||
$value = $self->session->form->process("newOverrideValueText") || $value;
|
||||
$self->session->db->write("delete from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." and fieldName=".$self->session->db->quote($fieldName));
|
||||
$self->session->db->write("insert into Shortcut_overrides values (".$self->session->db->quote($self->getId).",".$self->session->db->quote($fieldName).",".$self->session->db->quote($value).")");
|
||||
$self->uncacheOverrides;
|
||||
$self->getShortcutOriginal->purgeCache();
|
||||
return $self->www_manageOverrides;
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
my $fieldName = $self->session->form->process("overrideFieldName");
|
||||
my %overrides = $self->getOverrides;
|
||||
my $output = '';
|
||||
my %props;
|
||||
foreach my $def (@{$self->getShortcutOriginal->definition($self->session)}) {
|
||||
%props = (%props,%{$def->{properties}});
|
||||
}
|
||||
my $fieldType = $props{$fieldName}{fieldType};
|
||||
my $value = $self->session->form->process($fieldName,$fieldType);
|
||||
$value = $self->session->form->process("newOverrideValueText") || $value;
|
||||
$self->session->db->write("delete from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." and fieldName=".$self->session->db->quote($fieldName));
|
||||
$self->session->db->write("insert into Shortcut_overrides values (".$self->session->db->quote($self->getId).",".$self->session->db->quote($fieldName).",".$self->session->db->quote($value).")");
|
||||
$self->uncacheOverrides;
|
||||
$self->getShortcutOriginal->purgeCache();
|
||||
return $self->www_manageOverrides;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -928,5 +977,43 @@ sub www_view {
|
|||
return $output;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head1 STATIC METHODS
|
||||
|
||||
These methods are called using CLASS->method
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getShortcutsForAssetId ( session, assetId [, properties] )
|
||||
|
||||
Get an arrayref of assetIds of all the shortcuts for the passed-in assetId.
|
||||
|
||||
"properties" is a hash reference of properties to give to getLineage.
|
||||
Probably the only useful key will be "returnObjects".
|
||||
|
||||
=cut
|
||||
|
||||
sub getShortcutsForAssetId {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $assetId = shift;
|
||||
my $properties = shift || {};
|
||||
|
||||
croak "First argument to getShortcutsForAssetId must be WebGUI::Session"
|
||||
unless $session && $session->isa("WebGUI::Session");
|
||||
croak "Second argument to getShortcutsForAssetId must be assetId"
|
||||
unless $assetId;
|
||||
croak "Third argument to getShortcutsForAssetId must be hash reference"
|
||||
if $properties && !ref $properties eq "HASH";
|
||||
|
||||
my $db = $session->db;
|
||||
|
||||
$properties->{ joinClass } = 'WebGUI::Asset::Shortcut';
|
||||
$properties->{ whereClause } = 'Shortcut.shortcutToAssetId = ' . $db->quote($assetId);
|
||||
|
||||
return WebGUI::Asset->getRoot($session)->getLineage(['descendants'], $properties);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue