From 39b949e9f3aff6cb78b7dc1765d410190f5964e9 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Thu, 1 Dec 2005 04:17:32 +0000 Subject: [PATCH] fixing several bugs. Also enabling saving of contentPositions for all users, not just admins. --- docs/upgrades/upgrade_6.7.8-6.8.0.pl | 3 +- lib/WebGUI/Asset/Field.pm | 4 +-- lib/WebGUI/Asset/Wobject/Dashboard.pm | 9 ++--- lib/WebGUI/Asset/Wobject/MultiSearch.pm | 2 +- lib/WebGUI/ErrorHandler.pm | 44 +++++++++++------------ lib/WebGUI/Session.pm | 1 + www/extras/wobject/Dashboard/draggable.js | 1 + 7 files changed, 34 insertions(+), 30 deletions(-) diff --git a/docs/upgrades/upgrade_6.7.8-6.8.0.pl b/docs/upgrades/upgrade_6.7.8-6.8.0.pl index 3fcd6c7c5..d8f04bab9 100644 --- a/docs/upgrades/upgrade_6.7.8-6.8.0.pl +++ b/docs/upgrades/upgrade_6.7.8-6.8.0.pl @@ -1513,8 +1513,9 @@ $rssFolder->addChild({ sub addTimeZonesToUserPreferences { print "\tDropping time offsets in favor of time zones.\n" unless ($quiet); WebGUI::SQL->write("delete from userProfileData where fieldName='timeOffset'"); - WebGUI::SQL->write("update userProfileField set dataValues='', fieldName='timeZone', dataType='timeZone', fieldLabel=".quote('WebGUI::International::get("timezone","DateTime");').",dataDefault=".quote("['America/Chicago']")." where fieldName='timeOffset'"); + WebGUI::SQL->write("update userProfileField set dataValues='', fieldName='timeZone', dataType='timeZone', fieldLabel=".quote('WebGUI::International::get("timezone","DateTime");').",dataDefault='America/Chicago' where fieldName='timeOffset'"); WebGUI::SQL->write("insert into userProfileData values ('1','timeZone','America/Chicago')"); + WebGUI::SQL->write("insert into userProfileData values ('3','timeZone','America/Chicago')"); } sub removeUnneededFiles { diff --git a/lib/WebGUI/Asset/Field.pm b/lib/WebGUI/Asset/Field.pm index 90e06accc..a97758d99 100644 --- a/lib/WebGUI/Asset/Field.pm +++ b/lib/WebGUI/Asset/Field.pm @@ -170,7 +170,7 @@ sub getUserPref { my $returnDataType = shift || 'string'; my $returnDataFormat = shift || 'raw'; my $sql = "select userValue from wgFieldUserData where assetId=".quote($fieldId)." and userId=".quote($userId); - #WebGUI::ErrorHandler::warn($sql); + WebGUI::ErrorHandler::warn($sql); my ($userValue) = WebGUI::SQL->quickArray($sql); unless ($userValue) { return '' if $fieldId eq 'skipThisRequest'; @@ -199,9 +199,9 @@ sub setUserPref { my $returnDataType = shift || 'string'; my $returnDataFormat = shift || 'raw'; my $sql = "delete from wgFieldUserData where assetId=".quote($fieldId)." and userId=".quote($userId); - #WebGUI::ErrorHandler::warn($sql); WebGUI::SQL->write($sql); my $sql2 = "insert into wgFieldUserData values (".quote($fieldId).",".quote($userId).",".quote($valueToSet).")"; + WebGUI::ErrorHandler::warn($sql2); return WebGUI::SQL->write($sql2); } diff --git a/lib/WebGUI/Asset/Wobject/Dashboard.pm b/lib/WebGUI/Asset/Wobject/Dashboard.pm index a547f39e5..5b76abe4f 100644 --- a/lib/WebGUI/Asset/Wobject/Dashboard.pm +++ b/lib/WebGUI/Asset/Wobject/Dashboard.pm @@ -53,11 +53,11 @@ sub definition { }, adminsGroupId =>{ fieldType=>"group", - defaultValue=>4 + defaultValue=>'4' }, usersGroupId =>{ fieldType=>"group", - defaultValue=>2 + defaultValue=>'2' }, mapFieldId =>{ fieldType=>"text", @@ -96,13 +96,13 @@ sub getEditForm { -name=>"adminsGroupId", -label=>$i18n->get('dashboard adminsGroupId field label'), -hoverHelp=>$i18n->get('dashboard adminsGroupId description'), - -value=>[$self->get("adminsGroupId")] + -value=>[$self->getValue("adminsGroupId")] ); $tabform->getTab("security")->group( -name=>"usersGroupId", -label=>$i18n->get('dashboard usersGroupId field label'), -hoverHelp=>$i18n->get('dashboard usersGroupId description'), - -value=>[$self->get("usersGroupId")] + -value=>[$self->getValue("usersGroupId")] ); return $tabform; } @@ -230,6 +230,7 @@ sub view { #------------------------------------------------------------------- sub www_setContentPositions { my $self = shift; + return 'Visitors cannot save settings' if $session{user}{userId} == 1; return WebGUI::Privilege::insufficient() unless ($self->canPersonalize); return '' unless $self->get("mapFieldId"); my $success = WebGUI::Asset::Field->setUserPref($self->get("mapFieldId"),$session{form}{map}); diff --git a/lib/WebGUI/Asset/Wobject/MultiSearch.pm b/lib/WebGUI/Asset/Wobject/MultiSearch.pm index 8972d02a6..a925ecb6c 100644 --- a/lib/WebGUI/Asset/Wobject/MultiSearch.pm +++ b/lib/WebGUI/Asset/Wobject/MultiSearch.pm @@ -84,7 +84,7 @@ sub view { my %var = $self->get(); #Set some template variables - #Build list of stocks as an array + #Build list of searches as an array my $defaults = $self->getValue("predefinedSearches"); return $self->processTemplate(\%var, $self->get("templateId")); diff --git a/lib/WebGUI/ErrorHandler.pm b/lib/WebGUI/ErrorHandler.pm index a07007ffa..6ed4da151 100644 --- a/lib/WebGUI/ErrorHandler.pm +++ b/lib/WebGUI/ErrorHandler.pm @@ -15,7 +15,7 @@ package WebGUI::ErrorHandler; =cut use FileHandle; -use Log::Log4perl; +#use Log::Log4perl; use strict; use WebGUI::Session; use Log::Log4perl; @@ -217,28 +217,28 @@ Returns a text message containing all of the session variables. sub getSessionVars { my $data; - while (my ($section, $hash) = each %WebGUI::Session::session) { + while (my ($section, $hash) = each %WebGUI::Session::session) { if ($section eq "debug") { next; } elsif (ref $hash eq 'HASH') { - while (my ($key, $value) = each %$hash) { - if (ref $value eq 'ARRAY') { - $value = '['.join(', ',@$value).']'; - } elsif (ref $value eq 'HASH') { - $value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}'; - } - unless (lc($key) eq "password" || lc($key) eq "identifier") { - $data .= "\t".$section.'.'.$key.' = '.$value."\n"; - } - } - } elsif (ref $hash eq 'ARRAY') { - my $i = 1; - foreach (@$hash) { - $data .= "\t".$section.'.'.$i.' = '.$_."\n"; - $i++; - } - } - } + while (my ($key, $value) = each %$hash) { + if (ref $value eq 'ARRAY') { + $value = '['.join(', ',@$value).']'; + } elsif (ref $value eq 'HASH') { + $value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}'; + } + unless (lc($key) eq "password" || lc($key) eq "identifier") { + $data .= "\t".$section.'.'.$key.' = '.$value."\n"; + } + } + } elsif (ref $hash eq 'ARRAY') { + my $i = 1; + foreach (@$hash) { + $data .= "\t".$section.'.'.$i.' = '.$_."\n"; + $i++; + } + } + } return $data; } @@ -279,7 +279,7 @@ sub info { my $message = shift; my $logger = getLogger(); $logger->info($message); - $WebGUI::Session::session{debug}{'info'} .= $message."\n"; + $WebGUI::Session::session{debug}{'info'} .= $message."\n"; } @@ -349,7 +349,7 @@ sub warn { my $message = shift; my $logger = getLogger(); $logger->warn($message); - $WebGUI::Session::session{debug}{'warn'} .= $message."\n"; + $WebGUI::Session::session{debug}{'warn'} .= $message."\n"; } diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 8382793d6..5238ecaac 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -96,6 +96,7 @@ sub setupUserInfo { my $u = WebGUI::User->new(shift); %{$session{user}} = (%{$u->{_profile}}, %{$u->{_user}}); $session{req}->user($session{user}{username}) if $session{req}; + $session{user}{userId} = $u->userId; $session{user}{alias} = $session{user}{username} if ($session{user}{alias} =~ /^\W+$/ || $session{user}{alias} eq ""); } diff --git a/www/extras/wobject/Dashboard/draggable.js b/www/extras/wobject/Dashboard/draggable.js index 1ed3b302b..9d7d0a483 100644 --- a/www/extras/wobject/Dashboard/draggable.js +++ b/www/extras/wobject/Dashboard/draggable.js @@ -371,6 +371,7 @@ function dragable_postNewContentMap() { ,'method':'POST' ,'map':dragable_getContentMap() ,'func':'setContentPositions' + // ,'onSuccess':function(req){ alert(req.responseText); } } ); }