fix: Dashboard content positioning field problem
This commit is contained in:
parent
7ab7b97c5e
commit
f715c29c67
3 changed files with 61 additions and 18 deletions
|
|
@ -5,6 +5,7 @@
|
|||
- fix: purging old asset revisions on large sites never completes
|
||||
- fix: Can't add assets when not using preload.perl.
|
||||
- fix: wiki recent
|
||||
- fix: Dashboard content positioning field problem
|
||||
- fix: graphing doesn't work with GraphicsMagick
|
||||
- fix: Calendar generated iCal for last 30 days instead of next 30 days
|
||||
- fix: hover help doesn't appear for matrix fields
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use lib "../../lib";
|
|||
use strict;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
|
||||
use WebGUI::ProfileField;
|
||||
|
||||
my $toVersion = "7.4.9"; # make this match what version you're going to
|
||||
my $quiet; # this line required
|
||||
|
|
@ -21,10 +21,12 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
removeOrphanedGroupings($session); # upgrade functions go here
|
||||
fixDashboardContentPositions($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------
|
||||
sub removeOrphanedGroupings {
|
||||
my $session = shift;
|
||||
|
|
@ -34,12 +36,33 @@ sub removeOrphanedGroupings {
|
|||
}
|
||||
|
||||
|
||||
##-------------------------------------------------
|
||||
#sub exampleFunction {
|
||||
# my $session = shift;
|
||||
# print "\tWe're doing some stuff here that you should know about.\n" unless ($quiet);
|
||||
# # and here's our code
|
||||
#}
|
||||
#-------------------------------------------------
|
||||
sub fixDashboardContentPositions {
|
||||
my $session = shift;
|
||||
my $db = $session->db;
|
||||
print "\tFixing broken dashboard content positions.\n" unless ($quiet);
|
||||
foreach my $dashboardId ($db->quickArray("select assetId from asset where className='WebGUI::Asset::Wobject::Dashboard'")) {
|
||||
my $newContentPositionId = "contentPositions".$dashboardId;
|
||||
$newContentPositionId =~ s/-/_/g;
|
||||
my $newField = WebGUI::ProfileField->create($session, $newContentPositionId, {
|
||||
label=>'\'Dashboard User Preference - Content Positions\'',
|
||||
visible=>0,
|
||||
protected=>1,
|
||||
editable=>0,
|
||||
required=>0,
|
||||
fieldType=>'textarea'
|
||||
});
|
||||
my $oldContentPositionId = $dashboardId."contentPositions";
|
||||
my $userPositioning = $db->read("select userId, `".$oldContentPositionId."` from userProfileData");
|
||||
while (my ($userId, $positions) = $userPositioning->array) {
|
||||
$db->write("update userProfileData set $newContentPositionId = ? where userId=?", [$positions, $userId]);
|
||||
}
|
||||
my $oldField = WebGUI::ProfileField->new($session, $oldContentPositionId);
|
||||
if (defined $oldField) {
|
||||
$oldField->delete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,15 +95,29 @@ sub definition {
|
|||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub discernUserId {
|
||||
my $self = shift;
|
||||
return ($self->canManage && $self->session->var->isAdminOn) ? '1' : $self->session->user->userId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getContentPositions {
|
||||
my $self = shift;
|
||||
my $dummy = $self->initialize unless $self->get("isInitialized");
|
||||
my $u = WebGUI::User->new($self->session, $self->discernUserId);
|
||||
return $u->profileField($self->getId.'contentPositions')
|
||||
return $u->profileField($self->getContentPositionsId)
|
||||
|| $self->getContentPositionsDefault;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getContentPositionsId {
|
||||
my $self = shift;
|
||||
my $id = "contentPositions".$self->getId;
|
||||
$id =~ s/-/_/g;
|
||||
return $id;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getContentPositionsDefault ( )
|
||||
|
|
@ -117,13 +131,7 @@ sub getContentPositionsDefault {
|
|||
my $dummy = $self->initialize unless $self->get("isInitialized");
|
||||
# The default positions are saved under the "Visitor" user
|
||||
my $u = WebGUI::User->new($self->session, 1);
|
||||
return $u->profileField($self->getId.'contentPositions');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub discernUserId {
|
||||
my $self = shift;
|
||||
return ($self->canManage && $self->session->var->isAdminOn) ? '1' : $self->session->user->userId;
|
||||
return $u->profileField($self->getContentPositionsId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -154,13 +162,13 @@ sub getEditForm {
|
|||
#-------------------------------------------------------------------
|
||||
sub initialize {
|
||||
my $self = shift;
|
||||
my $userPrefField = WebGUI::ProfileField->create($self->session,$self->getId.'contentPositions',{
|
||||
my $userPrefField = WebGUI::ProfileField->create($self->session,$self->getContentPositionsId,{
|
||||
label=>'\'Dashboard User Preference - Content Positions\'',
|
||||
visible=>0,
|
||||
protected=>1,
|
||||
editable=>0,
|
||||
required=>0,
|
||||
fieldType=>'text'
|
||||
fieldType=>'textarea'
|
||||
});
|
||||
$self->update({isInitialized=>1});
|
||||
}
|
||||
|
|
@ -201,6 +209,17 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
my $userPrefField = WebGUI::ProfileField->new($self->session,$self->getContentPositionsId);
|
||||
if (defined $userPrefField) {
|
||||
$userPrefField->delete;
|
||||
}
|
||||
$self->SUPER::purge(@_);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
|
|
@ -309,7 +328,7 @@ sub www_setContentPositions {
|
|||
return 'empty' unless $self->get("isInitialized");
|
||||
my $dummy = $self->initialize unless $self->get("isInitialized");
|
||||
my $u = WebGUI::User->new($self->session, $self->discernUserId);
|
||||
my $success = $u->profileField($self->getId.'contentPositions',$self->session->form->process("map")) eq $self->session->form->process("map");
|
||||
my $success = $u->profileField($self->getContentPositionsId,$self->session->form->process("map")) eq $self->session->form->process("map");
|
||||
return "Map set: ".$self->session->form->process("map") if $success;
|
||||
return "Map failed to set.";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue