changing dashboard stuff around.
This commit is contained in:
parent
9e17031f84
commit
8442b362b7
2 changed files with 65 additions and 28 deletions
|
|
@ -24,6 +24,7 @@ start(); # this line required
|
||||||
|
|
||||||
upgradeRichEditor();
|
upgradeRichEditor();
|
||||||
fixCSFaqTemplateAnchors();
|
fixCSFaqTemplateAnchors();
|
||||||
|
convertDashboardPrefs();
|
||||||
|
|
||||||
finish(); # this line required
|
finish(); # this line required
|
||||||
|
|
||||||
|
|
@ -34,6 +35,22 @@ sub upgradeRichEditor {
|
||||||
rmtree("../../www/extras/tinymce");
|
rmtree("../../www/extras/tinymce");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------
|
||||||
|
sub convertDashboardPrefs {
|
||||||
|
print "\tConverting Dashboard preferences\n" unless ($quiet);
|
||||||
|
#purge all Fields.
|
||||||
|
my $a = WebGUI::SQL->read("select assetId from asset where className='WebGUI::Asset::Field'");
|
||||||
|
while (my ($assetId) = $a->array) {
|
||||||
|
WebGUI::Asset::Field->new($assetId)->purge;
|
||||||
|
}
|
||||||
|
unlink("../../lib/WebGUI/Asset/Field.pm");
|
||||||
|
WebGUI::SQL->write("DROP TABLE `wgField`");
|
||||||
|
WebGUI::SQL->write("ALERT TABLE `Dashboard` DROP COLUMN mapFieldId");
|
||||||
|
WebGUI::SQL->write("ALERT TABLE `Dashboard` ADD COLUMN `isInitialized` TINYINT UNSIGNED NOT NULL DEFAULT 0");
|
||||||
|
WebGUI::SQL->write("ALERT TABLE `Dashboard` ADD COLUMN `assetsToHide` TEXT");
|
||||||
|
WebGUI::SQL->write("ALERT TABLE `Shortcut` ADD COLUMN `prefFieldsToShow` TEXT");
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
sub fixCSFaqTemplateAnchors {
|
sub fixCSFaqTemplateAnchors {
|
||||||
print "\tFix Anchors in the CS FAQ Template\n" unless ($quiet);
|
print "\tFix Anchors in the CS FAQ Template\n" unless ($quiet);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ use WebGUI::Grouping;
|
||||||
use WebGUI::Privilege;
|
use WebGUI::Privilege;
|
||||||
use WebGUI::ErrorHandler;
|
use WebGUI::ErrorHandler;
|
||||||
use Time::HiRes;
|
use Time::HiRes;
|
||||||
use WebGUI::Asset::Field;
|
|
||||||
use WebGUI::Style;
|
use WebGUI::Style;
|
||||||
use WebGUI::Asset::Wobject;
|
use WebGUI::Asset::Wobject;
|
||||||
|
|
||||||
|
|
@ -38,7 +37,6 @@ sub canPersonalize {
|
||||||
return WebGUI::Grouping::isInGroup($self->get("usersGroupId"));
|
return WebGUI::Grouping::isInGroup($self->get("usersGroupId"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub definition {
|
sub definition {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
|
|
@ -59,10 +57,14 @@ sub definition {
|
||||||
fieldType=>"group",
|
fieldType=>"group",
|
||||||
defaultValue=>'2'
|
defaultValue=>'2'
|
||||||
},
|
},
|
||||||
mapFieldId =>{
|
isInitialized =>{
|
||||||
fieldType=>"text",
|
fieldType=>"yesNo",
|
||||||
defaultValue=>'',
|
defaultValue=>0,
|
||||||
noFormPost=>1,
|
noFormPost=>1,
|
||||||
|
},
|
||||||
|
assetsToHide => {
|
||||||
|
defaultValue=>undef,
|
||||||
|
fieldType=>"checkList"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
push(@{$definition}, {
|
push(@{$definition}, {
|
||||||
|
|
@ -78,8 +80,15 @@ sub definition {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub getContentPositions {
|
sub getContentPositions {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $dummy = $self->initializeDashletFields unless $self->get("mapFieldId");
|
my $dummy = $self->initialize unless $self->get("isInitialized");
|
||||||
return WebGUI::Asset::Field->getUserPref($self->get("mapFieldId"));
|
my $u = WebGUI::User->new($self->discernUserId);
|
||||||
|
return $u->profileField($self->getId.'contentPositions');
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub discernUserId {
|
||||||
|
my $self = shift;
|
||||||
|
return ($self->canManage && WebGUI::Session::isAdminOn()) ? '1' : $session{user}{userId};
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -106,29 +115,40 @@ sub getEditForm {
|
||||||
-hoverHelp=>$i18n->get('dashboard usersGroupId description'),
|
-hoverHelp=>$i18n->get('dashboard usersGroupId description'),
|
||||||
-value=>[$self->getValue("usersGroupId")]
|
-value=>[$self->getValue("usersGroupId")]
|
||||||
);
|
);
|
||||||
|
if ($session{form}{func} ne "add") {
|
||||||
|
my @assetsToHide = split("\n",$self->getValue("assetsToHide"));
|
||||||
|
my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
|
||||||
|
my %childIds;
|
||||||
|
foreach my $child (@{$children}) {
|
||||||
|
$childIds{$child->getId} = $child->getTitle.' ['.ref($child).']';
|
||||||
|
}
|
||||||
|
$tabform->getTab("display")->checkList(
|
||||||
|
-name=>"assetsToHide",
|
||||||
|
-value=>\@assetsToHide,
|
||||||
|
-options=>\%childIds,
|
||||||
|
-label=>WebGUI::International::get('assets to hide', 'Asset_Layout'),
|
||||||
|
-hoverHelp=>WebGUI::International::get('assets to hide description', 'Asset_Layout'),
|
||||||
|
-vertical=>1,
|
||||||
|
-uiLevel=>9
|
||||||
|
);
|
||||||
|
}
|
||||||
return $tabform;
|
return $tabform;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub initializeDashletFields {
|
sub initialize {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $child = $self->addChild({
|
my $userPrefField = WebGUI::ProfileField::addProfileField({
|
||||||
className=>'WebGUI::Asset::Field',
|
label=>'\'Dashboard User Preference - Content Positions\'',
|
||||||
title=>'Dashboard User Preference - Content Positions',
|
visible=>1,
|
||||||
menuTitle=>'Dashboard User Preference - Content Positions',
|
isProtected=>1,
|
||||||
isHidden=>1,
|
editable=>0,
|
||||||
startDate=>$self->get("startDate"),
|
dataType=>'text',
|
||||||
endDate=>$self->get("endDate"),
|
fieldName=>$self->getId.'contentPositions'
|
||||||
ownerUserId=>$self->get("ownerUserId"),
|
|
||||||
groupIdEdit=>$self->get("groupIdEdit"),
|
|
||||||
groupIdView=>$self->get("groupIdView"),
|
|
||||||
url=>'Dashboard User Preference - Content Positions',
|
|
||||||
fieldName=>'contentPositions'
|
|
||||||
});
|
});
|
||||||
$self->update({mapFieldId=>$child->getId});
|
$self->update({isInitialized=>1});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub isManaging {
|
sub isManaging {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
@ -141,7 +161,7 @@ sub processPropertiesFromFormPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->SUPER::processPropertiesFromFormPost;
|
$self->SUPER::processPropertiesFromFormPost;
|
||||||
if ($session{form}{assetId} eq "new" && $session{form}{class} eq 'WebGUI::Asset::Wobject::Dashboard') {
|
if ($session{form}{assetId} eq "new" && $session{form}{class} eq 'WebGUI::Asset::Wobject::Dashboard') {
|
||||||
$self->initializeDashletFields;
|
$self->initialize;
|
||||||
if (ref $self->getParent eq 'WebGUI::Asset::Wobject::Layout') {
|
if (ref $self->getParent eq 'WebGUI::Asset::Wobject::Layout') {
|
||||||
$self->getParent->update({assetsToHide=>$self->getParent->get("assetsToHide")."\n".$self->getId});
|
$self->getParent->update({assetsToHide=>$self->getParent->get("assetsToHide")."\n".$self->getId});
|
||||||
}
|
}
|
||||||
|
|
@ -149,13 +169,12 @@ sub processPropertiesFromFormPost {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub view {
|
sub view {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %vars = $self->get();
|
my %vars = $self->get();
|
||||||
my $templateId = $self->get("templateId");
|
my $templateId = $self->get("templateId");
|
||||||
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Field","WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
|
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
|
||||||
my %vars;
|
my %vars;
|
||||||
# I'm sure there's a more efficient way to do this. We'll figure it out someday.
|
# I'm sure there's a more efficient way to do this. We'll figure it out someday.
|
||||||
my @positions = split(/\./,$self->getContentPositions);
|
my @positions = split(/\./,$self->getContentPositions);
|
||||||
|
|
@ -252,13 +271,14 @@ sub www_setContentPositions {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return 'Visitors cannot save settings' if($session{user}{userId} eq '1');
|
return 'Visitors cannot save settings' if($session{user}{userId} eq '1');
|
||||||
return WebGUI::Privilege::insufficient() unless ($self->canPersonalize);
|
return WebGUI::Privilege::insufficient() unless ($self->canPersonalize);
|
||||||
return 'empty' unless $self->get("mapFieldId");
|
return 'empty' unless $self->get("isInitialized");
|
||||||
my $success = WebGUI::Asset::Field->setUserPref($self->get("mapFieldId"),$session{form}{map});
|
my $dummy = $self->initialize unless $self->get("isInitialized");
|
||||||
|
my $u = WebGUI::User->new($self->discernUserId);
|
||||||
|
my $success = $u->profileField($self->getId.'contentPositions',$session{form}{map}) eq $session{form}{map};
|
||||||
return "Map set: ".$session{form}{map} if $success;
|
return "Map set: ".$session{form}{map} if $success;
|
||||||
return "Map failed to set.";
|
return "Map failed to set.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_view ( )
|
=head2 www_view ( )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue