readded packages system
This commit is contained in:
parent
22d3404b30
commit
3671e3f29d
10 changed files with 125 additions and 57 deletions
|
|
@ -200,15 +200,6 @@ sub getAdminFunction {
|
|||
op=>"listGroups",
|
||||
group=>"11"
|
||||
},
|
||||
"packages"=>{
|
||||
title=>{
|
||||
id=>"packages",
|
||||
namespace=>"WebGUI"
|
||||
},
|
||||
icon=>"packages.gif",
|
||||
op=>"managePackages",
|
||||
group=>"4"
|
||||
},
|
||||
"settings"=>{
|
||||
title=>{
|
||||
id=>"settings",
|
||||
|
|
|
|||
|
|
@ -319,6 +319,10 @@ sub definition {
|
|||
assetSize=>{
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>0
|
||||
},
|
||||
isPackage=>{
|
||||
fieldType=>'yesNo',
|
||||
defaultValue=>0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -344,6 +348,9 @@ sub demote {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 DESTROY ( )
|
||||
|
|
@ -359,17 +366,46 @@ sub DESTROY {
|
|||
$self->{_lastChild}->DESTROY if (exists $self->{_lastChild});
|
||||
$self = undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( )
|
||||
=head2 duplicate ( asset )
|
||||
|
||||
Duplicates an argument. Calls addChild with itself as an argument. Returns a new Asset object.
|
||||
Duplicates an asset. Calls addChild with self as an arguement. Returns a new Asset object.
|
||||
|
||||
=head3 asset
|
||||
|
||||
The asset to duplicate. Defaults to self.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->addChild($self->get);
|
||||
my $assetToDuplicate = shift || $self;
|
||||
my $newAsset = $self->addChild($assetToDuplicate->get);
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicateTree ( asset )
|
||||
|
||||
Duplicates an asset and all it's descendants. Calls addChild with asset as an argument. Returns a new Asset object.
|
||||
|
||||
=head3 asset
|
||||
|
||||
The asset to duplicate. Defaults to self.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicateTree {
|
||||
my $self = shift;
|
||||
my $assetToDuplicate = shift || $self;
|
||||
my $newAsset = $self->duplicate($assetToDuplicate);
|
||||
foreach my $child (@{$assetToDuplicate->getLineage(["children"],{returnObjects=>1})}) {
|
||||
$newAsset->duplicateTree($child);
|
||||
}
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
|
|
@ -770,6 +806,12 @@ sub getEditForm {
|
|||
-excludeGroups=>[1,7],
|
||||
-uiLevel=>6
|
||||
);
|
||||
$tabform->getTab("properties")->yesNo(
|
||||
-name=>"isPackage",
|
||||
-label=>"Make available as package?",
|
||||
-value=>$self->getValue("isPackage"),
|
||||
-uiLevel=>7
|
||||
);
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
|
|
@ -1014,6 +1056,30 @@ sub getNextChildRank {
|
|||
return $self->formatRank($rank);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head getPackageList ( )
|
||||
|
||||
Returns an array of hashes containing title, assetId, and className for all assets defined as packages.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPackageList {
|
||||
my $self = shift;
|
||||
my @assets;
|
||||
my $sth = WebGUI::SQL->read("select assetId, title, className from asset where isPackage=1 order by lastUpdated desc");
|
||||
while (my ($id, $title, $class) = $sth->array) {
|
||||
push(@assets, {
|
||||
title => $title,
|
||||
assetId => $id,
|
||||
className => $class
|
||||
});
|
||||
}
|
||||
$sth->finish;
|
||||
return \@assets;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getParent ( )
|
||||
|
|
@ -1837,6 +1903,28 @@ sub www_demote {
|
|||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deployPackage ( )
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deployPackage {
|
||||
my $self = shift;
|
||||
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
|
||||
my $packageMasterAssetId = $session{form}{assetId};
|
||||
if (defined $packageMasterAssetId) {
|
||||
my $packageMasterAsset = WebGUI::Asset->newByDynamicClass($packageMasterAssetId);
|
||||
if (defined $packageMasterAsset && $packageMasterAsset->canView) {
|
||||
my $deployedTreeMaster = $self->duplicateTree($packageMasterAsset);
|
||||
$deployedTreeMaster->update({isPackage=>0});
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
|
|
|||
|
|
@ -97,6 +97,16 @@ sub getBox {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
my $newStorage = $self->getStorageLocation->copy;
|
||||
$newAsset->update({storageId=>$newStorage->getId,olderVersions=>''});
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm ()
|
||||
|
|
|
|||
|
|
@ -166,21 +166,15 @@ sub confirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( [ pageId ] )
|
||||
=head2 duplicate ( asset )
|
||||
|
||||
Duplicates this wobject with a new wobject Id. Returns the new wobject Id.
|
||||
|
||||
B<NOTE:> This method is meant to be extended by all sub-classes.
|
||||
|
||||
=head3 pageId
|
||||
|
||||
If specified the wobject will be duplicated to this pageId, otherwise it will be duplicated to the clipboard.
|
||||
Extends the Asset duplicate method to also duplicate meta data.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate();
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
WebGUI::MetaData::MetaDataDuplicate($self->getId, $newAsset->getId);
|
||||
return $newAsset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ sub definition {
|
|||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate;
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
my (%dataField, %dataTab, $sthField, $sthTab, $newTabId);
|
||||
tie %dataTab, 'Tie::CPHash';
|
||||
tie %dataField, 'Tie::CPHash';
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ sub definition {
|
|||
#-------------------------------------------------------------------
|
||||
sub duplcate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate;
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
my $sth = WebGUI::SQL->read("select * from Poll_answer where assetId=".quote($self->getId));
|
||||
while (my $data = $sth->hashRef) {
|
||||
$newAsset->setVote($data->{answer}, $data->{userId}, $data->{ipAddress});
|
||||
|
|
|
|||
|
|
@ -1051,20 +1051,11 @@ This will be used if no value is specified.
|
|||
sub HTMLArea {
|
||||
my $params = shift;
|
||||
my ($output, $rows, $columns, $htmlArea);
|
||||
my $browser = HTTP::BrowserDetect->new($session{env}{HTTP_USER_AGENT});
|
||||
my %var;
|
||||
|
||||
# Store all scalar options in template variables
|
||||
foreach (keys %{$params}) {
|
||||
$var{"form.".$_} = $params->{$_} unless (ref $params->{$_});
|
||||
}
|
||||
|
||||
# Supported Rich Editors
|
||||
$var{"htmlArea.supported"} = ($browser->ie && $browser->version >= 5.5);
|
||||
$var{"midas.supported"} = (($browser->ie && $browser->version >= 6) || ($browser->gecko && $browser->version >= 1.3));
|
||||
$var{"htmlArea3.supported"} = (($browser->ie && $browser->version >= 5.5) || $var{"midas.supported"});
|
||||
$var{"classic.supported"} = ($browser->ie && $browser->version >= 5);
|
||||
|
||||
# Textarea field
|
||||
$rows = $params->{rows} || ($session{setting}{textAreaRows}+15);
|
||||
$columns = $params->{columns} || ($session{setting}{textAreaCols}+5);
|
||||
|
|
@ -1077,7 +1068,6 @@ sub HTMLArea {
|
|||
extras=>$params->{extras}.' onBlur="fixChars(this.form.'.$params->{name}.')" id="'.$params->{name}.'"'.' mce_editable="true" ',
|
||||
defaultValue=>$params->{defaultValue}
|
||||
});
|
||||
|
||||
# Other variables
|
||||
$var{"button"} = '<input type="button" onClick="openEditWindow(this.form.'.$params->{name}.')" value="'
|
||||
.WebGUI::International::get(171).'" style="font-size: 8pt;" /><br />';
|
||||
|
|
|
|||
|
|
@ -34,38 +34,29 @@ sub process {
|
|||
tie %hash, "Tie::IxHash";
|
||||
tie %hash2, "Tie::IxHash";
|
||||
tie %cphash, "Tie::CPHash";
|
||||
#--packages adder
|
||||
$var{'packages.canAdd'} = ($session{user}{uiLevel} >= 7);
|
||||
$var{'packages.label'} = WebGUI::International::get(376);
|
||||
my @packages;
|
||||
my $i;
|
||||
# my $sth = WebGUI::SQL->read("select pageId,title from page where parentId='5'");
|
||||
# while (my %data = $sth->hash) {
|
||||
# $data{title} =~ s/'//g;
|
||||
# push(@packages, {
|
||||
# 'package.url'=>WebGUI::URL::page('op=deployPackage&pid='.$data{pageId}),
|
||||
# 'package.label'=>$data{title},
|
||||
# 'package.count'=>$i
|
||||
# });
|
||||
# $i++;
|
||||
# }
|
||||
# $sth->finish;
|
||||
# $var{package_loop} = \@packages;
|
||||
#--contenttypes adder
|
||||
$var{'contentTypes.label'} = WebGUI::International::get(1083);
|
||||
$var{'addcontent.label'} = WebGUI::International::get(1);
|
||||
foreach my $link (@{$session{asset}->getAssetAdderLinks}) {
|
||||
push(@{$var{'contenttypes_loop'}},{'contenttype.url'=>$link->{url},'contenttype.label'=>$link->{label}});
|
||||
}
|
||||
#--clipboard paster
|
||||
$var{'clipboard.label'} = WebGUI::International::get(1082);
|
||||
if (exists $session{asset}) {
|
||||
foreach my $package (@{$session{asset}->getPackageList}) {
|
||||
my $title = $package->{title};
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{'package_loop'}},{
|
||||
'package.url'=>$session{asset}->getUrl("func=deployPackage&assetId=".$package->{assetId}),
|
||||
'package.label'=>$title
|
||||
});
|
||||
}
|
||||
foreach my $link (@{$session{asset}->getAssetAdderLinks}) {
|
||||
push(@{$var{'contenttypes_loop'}},{'contenttype.url'=>$link->{url},'contenttype.label'=>$link->{label}});
|
||||
}
|
||||
foreach my $item (@{$session{asset}->getAssetsInClipboard(1)}) {
|
||||
my $title = $item->{title};
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{clipboard_loop}}, {
|
||||
'clipboard.label'=>$title,
|
||||
'clipboard.url'=>WebGUI::URL::page("func=paste&assetId=".$item->{assetId})
|
||||
'clipboard.url'=>$session{asset}->getUrl("func=paste&assetId=".$item->{assetId})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +80,7 @@ sub process {
|
|||
);
|
||||
$var{'admin.label'} = WebGUI::International::get(82);
|
||||
my @admin;
|
||||
$i = 0;
|
||||
my $i = 0;
|
||||
foreach my $key (keys %hash) {
|
||||
push(@admin,{
|
||||
'admin.url'=>$key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue